import oic.simulator.clientcontroller.remoteresource.DeviceAndPlatformInfo;
import oic.simulator.clientcontroller.remoteresource.MetaProperty;
import oic.simulator.clientcontroller.remoteresource.RemoteResource;
+import oic.simulator.clientcontroller.utils.AttributeValueStringConverter;
import oic.simulator.clientcontroller.utils.Constants;
import oic.simulator.clientcontroller.utils.Utility;
+import org.oic.simulator.ArrayProperty;
import org.oic.simulator.AttributeProperty;
import org.oic.simulator.AttributeProperty.Type;
import org.oic.simulator.AttributeValue;
import org.oic.simulator.AttributeValue.TypeInfo;
import org.oic.simulator.AttributeValue.ValueType;
+import org.oic.simulator.BooleanProperty;
import org.oic.simulator.DeviceInfo;
import org.oic.simulator.DeviceListener;
+import org.oic.simulator.DoubleProperty;
import org.oic.simulator.ILogger.Level;
+import org.oic.simulator.IntegerProperty;
import org.oic.simulator.PlatformInfo;
import org.oic.simulator.PlatformListener;
import org.oic.simulator.SimulatorException;
import org.oic.simulator.SimulatorResourceAttribute;
import org.oic.simulator.SimulatorResourceModel;
import org.oic.simulator.SimulatorResult;
+import org.oic.simulator.StringProperty;
import org.oic.simulator.client.FindResourceListener;
import org.oic.simulator.client.SimulatorRemoteResource;
import org.oic.simulator.client.SimulatorRemoteResource.GetResponseListener;
return null;
}
- SimulatorResourceModel resourceModel = resource.getResourceModelRef();
- if (null == resourceModel) {
- resource.setResourceModelRef(resourceModelN);
- } else {
- resourceModel.update(resourceModelN);
- }
-
+ resource.setResourceModelRef(resourceModelN);
resource.setResourceRepresentation(resourceModelN, false);
return resource;
}
AttributeValue val = att.value();
- if (null == val) {
+ if (null == val || null == val.get()) {
return null;
}
- List<String> values = new ArrayList<String>();
-
TypeInfo type = val.typeInfo();
+ if (type.mType == ValueType.RESOURCEMODEL
+ || type.mBaseType == ValueType.RESOURCEMODEL) {
+ return null;
+ }
+
+ List<String> values = new ArrayList<String>();
+
AttributeProperty prop = att.property();
- if (null == prop || prop.type().ordinal() == Type.UNKNOWN.ordinal()) {
- values.add(Utility.getAttributeValueAsString(val));
+ if (null == prop) {
+ values.add(new AttributeValueStringConverter(val).toString());
return values;
}
- Type valuesType = prop.type();
-
- if (type.mType != ValueType.RESOURCEMODEL) {
- if (type.mType == ValueType.ARRAY) {
- if (type.mDepth == 1) {
- AttributeProperty childProp = prop.getChildProperty();
- if (null != childProp) {
- valuesType = childProp.type();
- if (valuesType.ordinal() == Type.RANGE.ordinal()) {
- List<String> list = getRangeForPrimitiveNonArrayAttributes(
- childProp, type.mBaseType);
- if (null != list) {
- values.addAll(list);
+ if (type.mType == ValueType.ARRAY) {
+ if (type.mDepth == 1) {
+ ArrayProperty arrayProperty = prop.asArray();
+ if (null != arrayProperty) {
+ AttributeProperty childProp = arrayProperty
+ .getElementProperty();
+ switch (childProp.getType()) {
+ case INTEGER:
+ IntegerProperty intProperty = childProp.asInteger();
+ if (null != intProperty) {
+ values.addAll(getAllValues(intProperty,
+ Type.INTEGER));
}
- } else if (valuesType.ordinal() == Type.VALUESET
- .ordinal()) {
- List<String> list = getAllowedValuesForPrimitiveNonArrayAttributes(
- childProp.valueSet(), type.mBaseType);
- if (null != list) {
- values.addAll(list);
+ break;
+ case DOUBLE:
+ DoubleProperty dblProperty = childProp.asDouble();
+ if (null != dblProperty) {
+ values.addAll(getAllValues(dblProperty,
+ Type.DOUBLE));
}
- }
+ break;
+ case BOOLEAN:
+ BooleanProperty boolProperty = childProp
+ .asBoolean();
+ if (null != boolProperty) {
+ values.addAll(getAllValues(boolProperty,
+ Type.BOOLEAN));
+ }
+ break;
+ case STRING:
+ StringProperty stringProperty = childProp
+ .asString();
+ if (null != stringProperty) {
+ values.addAll(getAllValues(stringProperty,
+ Type.STRING));
+ }
+ break;
+ default:
+ break;
}
}
- } else {
- if (valuesType.ordinal() == Type.RANGE.ordinal()) {
- List<String> list = getRangeForPrimitiveNonArrayAttributes(
- prop, type.mType);
- if (null != list) {
- values.addAll(list);
+ }
+ } else {
+ switch (prop.getType()) {
+ case INTEGER:
+ IntegerProperty intProperty = prop.asInteger();
+ if (null != intProperty) {
+ values.addAll(getAllValues(intProperty, Type.INTEGER));
}
- } else if (valuesType.ordinal() == Type.VALUESET.ordinal()) {
- List<String> list = getAllowedValuesForPrimitiveNonArrayAttributes(
- prop.valueSet(), type.mType);
- if (null != list) {
- values.addAll(list);
+ break;
+ case DOUBLE:
+ DoubleProperty dblProperty = prop.asDouble();
+ if (null != dblProperty) {
+ values.addAll(getAllValues(dblProperty, Type.DOUBLE));
}
- }
+ break;
+ case BOOLEAN:
+ BooleanProperty boolProperty = prop.asBoolean();
+ if (null != boolProperty) {
+ values.addAll(getAllValues(boolProperty, Type.BOOLEAN));
+ }
+ break;
+ case STRING:
+ StringProperty stringProperty = prop.asString();
+ if (null != stringProperty) {
+ values.addAll(getAllValues(stringProperty, Type.STRING));
+ }
+ break;
+ default:
+ break;
}
}
- if (values.isEmpty()) {
- values.add(Utility.getAttributeValueAsString(val));
- }
-
return values;
}
- public List<String> getRangeForPrimitiveNonArrayAttributes(
- AttributeProperty prop, ValueType type) {
- if (null == prop) {
- return null;
- }
+ public List<String> getAllValues(IntegerProperty intProperty,
+ AttributeProperty.Type type) {
+ List<String> values = new ArrayList<String>();
- if (type == ValueType.ARRAY || type == ValueType.RESOURCEMODEL) {
- return null;
+ if (intProperty.hasRange()) {
+ int min = (int) intProperty.min();
+ int max = (int) intProperty.max();
+ for (int iVal = min; iVal <= max; iVal++) {
+ values.add(String.valueOf(iVal));
+ }
+ } else if (intProperty.hasValues()) {
+ for (Integer val : intProperty.getValues()) {
+ values.add(String.valueOf(val));
+ }
+ } else {
+ // Adding the default value.
+ values.add(String.valueOf(intProperty.getDefaultValue()));
}
+ return values;
+ }
+ public List<String> getAllValues(DoubleProperty dblProperty,
+ AttributeProperty.Type type) {
List<String> values = new ArrayList<String>();
- switch (type) {
- case INTEGER:
- int min = (int) prop.min();
- int max = (int) prop.max();
- for (int iVal = min; iVal <= max; iVal++) {
- values.add(String.valueOf(iVal));
- }
- break;
- case DOUBLE:
- double minD = (double) prop.min();
- double maxD = (double) prop.max();
- for (double iVal = minD; iVal <= maxD; iVal = iVal + 1.0) {
- values.add(String.valueOf(iVal));
- }
- break;
- default:
+
+ if (dblProperty.hasRange()) {
+ double min = (double) dblProperty.min();
+ double max = (double) dblProperty.max();
+ for (double iVal = min; iVal <= max; iVal = iVal + 1) {
+ values.add(String.valueOf(iVal));
+ }
+ } else if (dblProperty.hasValues()) {
+ for (Double val : dblProperty.getValues()) {
+ values.add(String.valueOf(val));
+ }
+ } else {
+ // Adding the default value.
+ values.add(String.valueOf(dblProperty.getDefaultValue()));
}
return values;
}
- public List<String> getAllowedValuesForPrimitiveNonArrayAttributes(
- AttributeValue[] attValues, ValueType type) {
- if (null == attValues || attValues.length < 1) {
- return null;
- }
-
- if (type == ValueType.ARRAY || type == ValueType.RESOURCEMODEL) {
- return null;
- }
+ public List<String> getAllValues(BooleanProperty boolProperty,
+ AttributeProperty.Type type) {
+ List<String> values = new ArrayList<String>();
+ values.add("true");
+ values.add("false");
+ return values;
+ }
- Object obj;
+ public List<String> getAllValues(StringProperty stringProperty,
+ AttributeProperty.Type type) {
List<String> values = new ArrayList<String>();
- for (AttributeValue val : attValues) {
- if (null == val) {
- continue;
- }
- obj = val.get();
- if (null == obj) {
- continue;
+
+ if (stringProperty.hasValues()) {
+ for (String val : stringProperty.getValues()) {
+ values.add(String.valueOf(val));
}
- values.add(String.valueOf(obj));
+ } else {
+ // Adding the default value.
+ values.add(String.valueOf(stringProperty.getDefaultValue()));
}
return values;
}
return false;
}
try {
- resourceN.startObserve(null, observeListener);
+ resourceN.observe(observeListener);
resource.setObserved(true);
// Add observed resource URI to show the proper status after every
// find/refresh operations.
}
// Store the resource model in the local cache
- SimulatorResourceModel resourceModel = resource
- .getResourceModelRef();
- if (null != resourceModel) {
- configuredResourceModel.update(resourceModel);
- }
- resource.setResourceModelRef(configuredResourceModel);
+ /*
+ * SimulatorResourceModel resourceModel = resource
+ * .getResourceModelRef(); if (null != resourceModel) {
+ * configuredResourceModel.update(resourceModel); }
+ * resource.setResourceModelRef(configuredResourceModel);
+ */
} catch (SimulatorException e) {
Activator
.getDefault()