Merge "Implements new ValueType format"
diff --git a/examples/basys.examples/examples/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelVAB.java b/examples/basys.examples/examples/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelVAB.java
index 8035292..a725c74 100644
--- a/examples/basys.examples/examples/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelVAB.java
+++ b/examples/basys.examples/examples/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelVAB.java
@@ -43,7 +43,7 @@
// Add example properties
// - Add simple property with value and idShort meta elements
this.putPath("properties/prop1/value", 234);
- this.putPath("properties/prop1/valueType", PropertyValueTypeDefHelper.fromObject(234).toString());
+ this.putPath("properties/prop1/valueType", PropertyValueTypeDefHelper.fromObject(234));
this.putPath("properties/prop1/idShort", "prop1");
// Add container property that holds other properties
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/ConnectedSubmodelElementCollection.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/ConnectedSubmodelElementCollection.java
index cac03eb..820f39c 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/ConnectedSubmodelElementCollection.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/ConnectedSubmodelElementCollection.java
@@ -241,7 +241,7 @@
@Override
public void setValue(Object obj) {
getProxy().updateElementValue(constructPath(Property.VALUE), obj);
- getProxy().updateElementValue(constructPath(Property.VALUETYPE), PropertyValueTypeDefHelper.fromObject(obj).toString());
+ getProxy().updateElementValue(constructPath(Property.VALUETYPE), PropertyValueTypeDefHelper.fromObject(obj));
}
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/operation/ConnectedOperation.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/operation/ConnectedOperation.java
index b7c776b..e403d22 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/operation/ConnectedOperation.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/operation/ConnectedOperation.java
@@ -1,6 +1,5 @@
package org.eclipse.basyx.aas.backend.connected.aas.submodelelement.operation;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -63,24 +62,23 @@
public List<IOperationVariable> getReturnTypes() {
return (List<IOperationVariable>) getProxy().readElementValue(constructPath(Operation.OUT));
}
-
+
+ /**
+ * Invoke a remote operation
+ * TODO C# includes idShort
+ */
+ @SuppressWarnings("unchecked")
@Override
public Object invoke(Object... params) throws Exception {
- // FIXME: endpoint contains a string and invokable is not explicitly in the
- // meta model
- //return getProxy().invoke(constructPath("invokable"), params);
// Wrap parameter with valuetype information
int i = 0;
for (Object param : params) {
HashMap<String, Object> valueWrapper = new HashMap<String, Object>();
- HashMap<String, Object> valueType = new HashMap<String, Object>();
- HashMap<String, Object> dataObjectType = new HashMap<String, Object>();
- dataObjectType.put("name", PropertyValueTypeDefHelper.fromObject(param).toString());
- valueType.put("dataObjectType", dataObjectType);
- valueWrapper.put("valueType", valueType);
+
+ valueWrapper.put("valueType", PropertyValueTypeDefHelper.fromObject(param));
valueWrapper.put("value", param);
- // left out idShort
+
params[i] = valueWrapper;
i++;
}
@@ -94,7 +92,7 @@
if (resultWrapper instanceof Map<?,?>) {
Map<String, Object> map = (Map<String, Object>) resultWrapper;
- if (map.get("idShort").equals("Response") && map.get("value") != null) {
+ if (map.get("idShort").equals("Response") && map.get("value") != null) { // TODO C# test access from C# to Java hosted operation
result = map.get("value");
}
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedProperty.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedProperty.java
index 00f8f36..30e0ac1 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedProperty.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedProperty.java
@@ -27,7 +27,7 @@
@Override
public void setValue(Object value) {
getProxy().updateElementValue(constructPath(Property.VALUE), value);
- getProxy().updateElementValue(constructPath(Property.VALUETYPE), PropertyValueTypeDefHelper.fromObject(value).toString());
+ getProxy().updateElementValue(constructPath(Property.VALUETYPE), PropertyValueTypeDefHelper.fromObject(value));
}
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedPropertyFactory.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedPropertyFactory.java
index 411edb0..ea564a4 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedPropertyFactory.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/backend/connected/aas/submodelelement/property/ConnectedPropertyFactory.java
@@ -22,18 +22,8 @@
return new ConnectedContainerProperty(path, proxy);
} else if (property.containsKey("valueType")) {
- PropertyValueTypeDef valueType = null;
- Object vType1 = property.get("valueType");
- if (vType1 instanceof String) {
- // try outdated java valuetype
- valueType = PropertyValueTypeDefHelper.fromName((String) vType1);
- } else if (vType1 instanceof Map<?,?>) {
- // extract from hashmap
- String vType2 = (String) ((Map<String, Object>) ((Map<String, Object>) vType1).get("dataObjectType")).get("name");
- valueType = PropertyValueTypeDefHelper.fromName(vType2);
-
- }
-
+ PropertyValueTypeDef valueType = PropertyValueTypeDefHelper.readTypeDef(property.get("valueType"));
+
if (valueType == PropertyValueTypeDef.Map) {
return new ConnectedMapProperty(path, proxy);
} else if (valueType == PropertyValueTypeDef.Collection) {
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/facades/PropertyFacade.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/facades/PropertyFacade.java
index 04537ac..e560e00 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/facades/PropertyFacade.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/facades/PropertyFacade.java
@@ -35,7 +35,7 @@
@Override
public PropertyType getPropertyType() {
- PropertyValueTypeDef type = PropertyValueTypeDefHelper.fromName((String) map.get(Property.VALUETYPE));
+ PropertyValueTypeDef type = PropertyValueTypeDefHelper.readTypeDef(map.get(Property.VALUETYPE));
if (type == PropertyValueTypeDef.Collection) {
return PropertyType.Collection;
} else if (type == PropertyValueTypeDef.Map) {
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/factory/MetaModelElementFactory.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/factory/MetaModelElementFactory.java
index 69b110c..ab983f0 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/factory/MetaModelElementFactory.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/factory/MetaModelElementFactory.java
@@ -1,7 +1,6 @@
package org.eclipse.basyx.aas.metamodel.factory;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -10,11 +9,9 @@
import java.util.function.Function;
import java.util.function.Supplier;
-import org.eclipse.basyx.aas.api.metamodel.aas.reference.IReference;
import org.eclipse.basyx.aas.api.resources.IElement;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.AssetAdministrationShell;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.SubModel;
-import org.eclipse.basyx.aas.metamodel.hashmap.aas.qualifier.haskind.Kind;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.submodelelement.SubmodelElement;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.submodelelement.SubmodelElementCollection;
import org.eclipse.basyx.aas.metamodel.hashmap.aas.submodelelement.operation.Operation;
@@ -78,7 +75,7 @@
ret.putAll(prop);
Map<String, Object> value = VABLambdaProviderHelper.createSimple(get, set);
ret.put("value", value);
- ret.put("valueType", PropertyValueTypeDefHelper.fromObject(get.get()).toString());
+ ret.put("valueType", PropertyValueTypeDefHelper.fromObject(get.get()));
return ret;
}
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/SubmodelElementCollection.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/SubmodelElementCollection.java
index 21d91ac..bed27ac 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/SubmodelElementCollection.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/SubmodelElementCollection.java
@@ -313,7 +313,7 @@
@Override
public void setValue(Object obj) {
put(Property.VALUE, obj);
- put(Property.VALUETYPE, PropertyValueTypeDefHelper.fromObject(obj).toString());
+ put(Property.VALUETYPE, PropertyValueTypeDefHelper.fromObject(obj));
}
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/Property.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/Property.java
index dbf5fbf..8e88956 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/Property.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/Property.java
@@ -62,7 +62,7 @@
@Override
public void setValue(Object value) {
put(VALUE, value);
- put(VALUETYPE, PropertyValueTypeDefHelper.fromObject(value).toString());
+ put(VALUETYPE, PropertyValueTypeDefHelper.fromObject(value));
}
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/valuetypedef/PropertyValueTypeDefHelper.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/valuetypedef/PropertyValueTypeDefHelper.java
index ab8b5b0..b887bca 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/valuetypedef/PropertyValueTypeDefHelper.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/aas/metamodel/hashmap/aas/submodelelement/property/valuetypedef/PropertyValueTypeDefHelper.java
@@ -24,6 +24,10 @@
typeMap.put(t.toString(), t);
}
}
+
+ // Strings required for meta-model conformant valueType format
+ static String name = "name";
+ static String dataObjectType = "dataObjectType";
/**
* Map the name of a PropertyValueTypeDef to a PropertyValueTypeDef
@@ -45,31 +49,59 @@
* @param obj
* @return
*/
- public static PropertyValueTypeDef fromObject(Object obj) {
- if (obj == null)
- return PropertyValueTypeDef.Null;
-
+ public static HashMap<String, Object> fromObject(Object obj) {
+
+ HashMap<String, Object> valueTypeWrapper = new HashMap<String, Object>();
+ HashMap<String, Object> dataObjectTypeWrapper = new HashMap<String, Object>();
+ valueTypeWrapper.put(dataObjectType, dataObjectTypeWrapper);
+
+ if (obj == null) {
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Null.toString());
+ return valueTypeWrapper;
+ }
+
Class<?> c = obj.getClass();
if (c == int.class || c == Integer.class) {
- return PropertyValueTypeDef.Integer;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Integer.toString());
+ return valueTypeWrapper;
} else if (c == void.class || c == Void.class) {
- return PropertyValueTypeDef.Void;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Void.toString());
+ return valueTypeWrapper;
} else if (c == boolean.class || c == Boolean.class) {
- return PropertyValueTypeDef.Boolean;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Boolean.toString());
+ return valueTypeWrapper;
} else if (c == float.class || c == Float.class) {
- return PropertyValueTypeDef.Float;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Float.toString()); // TODO C# deprecated due to new serialization
+ return valueTypeWrapper;
} else if (c == double.class || c == Double.class) {
- return PropertyValueTypeDef.Double;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Double.toString());
+ return valueTypeWrapper;
} else if (c == String.class) {
- return PropertyValueTypeDef.String;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.String.toString());
+ return valueTypeWrapper;
} else if (Map.class.isAssignableFrom(c)) {
- return PropertyValueTypeDef.Map;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Map.toString());
+ return valueTypeWrapper;
} else if (Collection.class.isAssignableFrom(c)) {
- return PropertyValueTypeDef.Collection;
+ dataObjectTypeWrapper.put(name, PropertyValueTypeDef.Collection.toString());
+ return valueTypeWrapper;
} else {
throw new RuntimeException("Cannot map object " + obj + " to any PropertyValueTypeDef");
}
// TODO: Container, Reference
}
+
+ @SuppressWarnings("unchecked")
+ public static PropertyValueTypeDef readTypeDef(Object vTypeMap) {
+
+ if (vTypeMap instanceof Map<?,?>) {
+
+ Map<String, Object> map = (Map<String, Object>) vTypeMap;
+ Map<String, Object> dot = (Map<String, Object>) map.get(dataObjectType);
+
+ return fromName(dot.get(name).toString());
+ }
+ return null;
+ }
}
diff --git a/sdks/java/basys.sdk/src/org/eclipse/basyx/vab/provider/VABModelProvider.java b/sdks/java/basys.sdk/src/org/eclipse/basyx/vab/provider/VABModelProvider.java
index ce2cdf6..40347d1 100644
--- a/sdks/java/basys.sdk/src/org/eclipse/basyx/vab/provider/VABModelProvider.java
+++ b/sdks/java/basys.sdk/src/org/eclipse/basyx/vab/provider/VABModelProvider.java
@@ -159,7 +159,7 @@
if (path.endsWith("/"))
return invokeOperation(path+"invokable", parameters);
else
- return invokeOperation(path+"/invokable", parameters); // needs to be adaptde to c#
+ return invokeOperation(path+"/invokable", parameters); // TODO C# needs to be adapted so C# can invoke operations on java
}
}