Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@
import jakarta.validation.constraints.Min;
import java.math.BigInteger;
import org.openremote.model.asset.agent.AgentLink;
import org.openremote.model.util.JSONSchemaUtil.JsonSchemaTemplateParameter;
import org.openremote.model.util.JSONSchemaUtil.JsonSchemaTitle;

public class ModbusAgentLink extends AgentLink<ModbusAgentLink> {

@JsonPropertyDescription(
"Modbus unit ID (1-255). Required for Serial, optional for TCP (defaults to 1)")
@JsonSchemaTitle("Unit ID")
@JsonSchemaTemplateParameter
@Min(1) private Integer unitId;

@JsonPropertyDescription(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
@TsIgnoreTypeParams
public abstract class AgentLink<T extends AgentLink<?>> implements Serializable {

@JsonSchemaTitle("Agent ID")
@JsonSchemaFormat("or-agent-id")
@JsonSchemaTemplateParameter
protected String id;

@JsonSchemaDescription(
Expand Down
14 changes: 14 additions & 0 deletions model/src/main/java/org/openremote/model/util/JSONSchemaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ public static ObjectNode getSuppliedNode(JsonSchemaSupplier annotation)
String supplier();
}

/**
* Marks a field whose value a configuration template asks for on import, such as the agent of an
* agent link. Only mark fields that the standard JSON Forms renderers can render, as the import
* renders them outside of their custom renderers.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface JsonSchemaTemplateParameter {
String keyword() default "templateParameter";

String value() default "true";
}

private static class CustomModule implements Module {

private final ObjectMapper mapper;
Expand Down Expand Up @@ -338,6 +351,7 @@ public String getDefinitionNameForKey(
applyFieldAnnotation(fieldScope, JsonSchemaFormat.class, attrs);
applyFieldAnnotation(fieldScope, JsonSchemaDefault.class, attrs);
applyFieldAnnotation(fieldScope, JsonSchemaExamples.class, attrs);
applyFieldAnnotation(fieldScope, JsonSchemaTemplateParameter.class, attrs);

String key = getCanonicalMemberKey(fieldScope);
if (!applyI18nAnnotation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.openremote.model.util
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals

import com.fasterxml.jackson.annotation.*
import org.openremote.model.asset.agent.AgentLink
import org.openremote.model.util.JSONSchemaUtil.*
import org.openremote.model.value.ValueType
import org.reflections.Reflections
Expand Down Expand Up @@ -269,6 +270,7 @@ class JSONSchemaUtilTest extends Specification {
@JsonSchemaFormat("test")
@JsonSchemaDefault("false")
@JsonSchemaExamples(["test"])
@JsonSchemaTemplateParameter
public Boolean all
}

Expand All @@ -287,7 +289,8 @@ class JSONSchemaUtilTest extends Specification {
"description":"test",
"default": false,
"format":"test",
"examples":["test"]
"examples":["test"],
"templateParameter": true
}
},
"title": "Annotations For Fields",
Expand Down Expand Up @@ -708,6 +711,15 @@ class JSONSchemaUtilTest extends Specification {
assertEquals(expected.toString(), actual.toString(), true)
}

def "schema marks the agent id of an agent link as a template parameter"() {
when:
def properties = ValueUtil.getSchema(AgentLink).at("/definitions/DefaultAgentLink/properties")

then:
properties.at("/id/templateParameter").asBoolean()
!properties.at("/type").has("templateParameter")
}

def "schemas do not use allOf"() {
expect:
reflections.getTypesAnnotatedWith(JsonTypeInfo).each { clazz ->
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/ar/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -577,6 +580,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/cn/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -626,6 +629,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/cs/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,9 @@
},
"writeValueFilters": {
"description": "Podobné jako valueFilter, ale použije se na odchozí hodnoty, což umožňuje inverzní filtrování."
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -1322,6 +1325,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/de/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -672,6 +675,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions ui/app/shared/locales/en/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
"linkedUsers": "Linked users",
"setup": "Setup",
"selectFile": "Select file",
"selectAgent": "Select an agent",
"file": "File",
"discoverAssets": "Discover assets",
"discovering": "Discovering",
Expand Down Expand Up @@ -1305,6 +1306,9 @@
},
"writeValueFilters": {
"description": "Similar to valueFilter but will be applied to outgoing values allowing for inverse filtering."
},
"id": {
"label": "Agent ID"
}
}
}
Expand Down Expand Up @@ -1332,6 +1336,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": "Unit ID"
}
}
}
}
}
Expand All @@ -1356,6 +1367,10 @@
"back": "Back",
"next": "Next",
"json": "JSON",
"parametersDescription": "Choose which Agent Link parameter values to include",
"parametersHeading": "{{type}} parameters",
"unknownAgent": "The template's agent does not exist here. Pick another one.",
"noAgentOfType": "There is no agent for a {{type}} yet. Add one to continue; this list updates once it exists.",
"forbidden": "You are not allowed to import a configuration template into this asset.",
"failure": {
"INVALID_JSON": "The selected file does not hold valid JSON.",
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/es/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -629,6 +632,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/fr/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -632,6 +635,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/it/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -626,6 +629,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions ui/app/shared/locales/nl/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
"linkedUsers": "Gekoppelde gebruikers",
"setup": "Instellingen",
"selectFile": "Kies bestand",
"selectAgent": "Selecteer een agent",
"file": "Bestand",
"discoverAssets": "Haal assets op",
"discovering": "Assets ophalen",
Expand Down Expand Up @@ -1291,6 +1292,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -1318,6 +1322,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand All @@ -1342,6 +1353,10 @@
"back": "Terug",
"next": "Volgende",
"json": "JSON",
"parametersDescription": "Kies welke Agent Link parameterwaarden je wilt opnemen",
"parametersHeading": "{{type}} parameters",
"unknownAgent": "De agent uit de template bestaat hier niet. Kies een andere.",
"noAgentOfType": "Er is nog geen agent voor een {{type}}. Voeg er een toe om verder te gaan; deze lijst werkt bij zodra die bestaat.",
"forbidden": "Je hebt geen rechten om een configuratie template in dit asset te importeren.",
"failure": {
"INVALID_JSON": "Het geselecteerde bestand bevat geen geldige JSON.",
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/pl/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,9 @@
},
"writeValueFilters": {
"description": "Podobnie jak valueFilter, ale stosowany do wartości wychodzących - umożliwia odwrotne filtrowanie."
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -1532,6 +1535,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions ui/app/shared/locales/pt/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@
},
"writeValueFilters": {
"description": ""
},
"id": {
"label": ""
}
}
}
Expand Down Expand Up @@ -627,6 +630,13 @@
}
}
}
},
"modbus": {
"ModbusAgentLink": {
"unitId": {
"label": ""
}
}
}
}
}
Expand Down
Loading
Loading