use of io.adminshell.aas.v3.model.Property in project uPMT by coco35700.
the class Main method writeMoment.
/**
* Recursive method used to recursively transform a Moment and its sub Moments into CSV compatible DATAZ
*/
private void writeMoment(DescriptionInterview ent, MomentExperience m, PrintWriter writer, String hierarchy) {
LinkedList<String> classes = new LinkedList<String>();
for (Type t : m.getTypes()) {
for (Type prop : t.getTypes()) {
Property p = (Property) prop;
classes.add(format(t.getName()) + "," + format(p.getName()) + "," + format(p.getValue()));
}
}
if (!classes.isEmpty()) {
for (String s : classes) {
writer.println(format(ent.getName()) + ",\"" + hierarchy + "\"" + "," + format(m.getName()) + "," + format(m.getDescripteme()) + "," + format(m.getColor()) + "," + format(m.getDuration()) + "," + s);
}
} else {
writer.println(format(ent.getName()) + ",\"" + hierarchy + "\"" + "," + format(m.getName()) + "," + format(m.getDescripteme()) + "," + format(m.getColor()) + "," + format(m.getDuration()) + ",\"\",\"\",\"\"");
}
for (int i = 0; i < m.getSubMoments().size(); i++) {
MomentExperience sub = m.getSubMoments().get(i);
writeMoment(ent, sub, writer, hierarchy + "." + (i + 1));
}
}
use of io.adminshell.aas.v3.model.Property in project uPMT by coco35700.
the class TypeClassRepresentationController method updateVue.
@Override
public void updateVue(Observable obs, Object value) {
// TODO Auto-generated method stub
if (obs.getClass().equals(RenameClassSchemeController.class)) {
renameClass((String) value);
}
if (obs.getClass().equals(ChangeColorClassSchemeController.class)) {
setColor((String) value);
}
if (obs.getClass().equals(AddPropertySchemeController.class)) {
Property n = new Property(((Property) value).getName());
boolean contain = false;
for (Type t : classe.getTypes()) {
if (t.getName().equals(n.getName())) {
contain = true;
break;
}
}
if (!this.classe.getTypes().contains(n)) {
addProperty((Property) n);
} else {
// System.out.println("AH BAH VOILA !!!!!");
}
}
if (obs.getClass().equals(RemovePropertySchemeController.class)) {
Property toRemove = (Property) value;
// System.out.println("Remove dans TypeClassRpzCtrl "+toRemove.getName());
RemoveProperty(toRemove);
}
if (obs.getClass().equals(AddPropertySchemeWithValueController.class)) {
addProperty(stack.pop());
}
if (obs.getClass().equals(RemoveClassSchemeController.class)) {
// System.out.println("DELETINGCLASS");
moment.removeTypeClassRep(this);
}
if (obs.getClass().equals(AddClassSchemeController.class)) {
// System.out.println("REPUTINGCLASS");
moment.putPreviousClassRep();
}
}
use of io.adminshell.aas.v3.model.Property in project uPMT by coco35700.
the class TypeTreeViewControllerClass method addProperty.
@FXML
public void addProperty() {
propertiesNumber++;
Property nt = new Property("Propriete " + propertiesNumber);
AddPropertyToClassCommand cmd = new AddPropertyToClassCommand(type, nt, tree.getTreeItem(), this.main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
}
use of io.adminshell.aas.v3.model.Property in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method doRemoveFromMaps.
/**
* Removes the given SubmodelElement from the maps.
*
* @param element The desired SubmodelElement
* @param reference The reference to the desired SubmodelElement
* @param referable The corresponding referable
*/
@SuppressWarnings("java:S2629")
private void doRemoveFromMaps(AASSubmodelElementType element, Reference reference, Referable referable) {
try {
LOG.debug("doRemoveFromMaps: remove SubmodelElement {}", AasUtils.asString(reference));
if (submodelElementOpcUAMap.containsKey(reference)) {
submodelElementOpcUAMap.remove(reference);
LOG.debug("doRemoveFromMaps: remove SubmodelElement from submodelElementOpcUAMap: {}", AasUtils.asString(reference));
}
if (element instanceof AASPropertyType) {
AASPropertyType prop = (AASPropertyType) element;
if (submodelElementAasMap.containsKey(prop.getValueNode().getNodeId())) {
submodelElementAasMap.remove(prop.getValueNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Property NodeId {}", prop.getValueNode().getNodeId());
}
} else if (element instanceof AASRangeType) {
AASRangeType range = (AASRangeType) element;
if (submodelElementAasMap.containsKey(range.getMinNode().getNodeId())) {
submodelElementAasMap.remove(range.getMinNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Range Min NodeId {}", range.getMinNode().getNodeId());
}
if (submodelElementAasMap.containsKey(range.getMaxNode().getNodeId())) {
submodelElementAasMap.remove(range.getMaxNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Range Max NodeId {}", range.getMaxNode().getNodeId());
}
} else if (element instanceof AASOperationType) {
AASOperationType oper = (AASOperationType) element;
if (submodelElementAasMap.containsKey(oper.getOperationNode().getNodeId())) {
submodelElementAasMap.remove(oper.getOperationNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Operation NodeId {}", oper.getOperationNode().getNodeId());
}
} else if (element instanceof AASBlobType) {
AASBlobType blob = (AASBlobType) element;
if (submodelElementAasMap.containsKey(blob.getValueNode().getNodeId())) {
submodelElementAasMap.remove(blob.getValueNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Blob NodeId {}", blob.getValueNode().getNodeId());
}
} else if (element instanceof AASMultiLanguagePropertyType) {
AASMultiLanguagePropertyType mlp = (AASMultiLanguagePropertyType) element;
if (submodelElementAasMap.containsKey(mlp.getValueNode().getNodeId())) {
submodelElementAasMap.remove(mlp.getValueNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove AASMultiLanguageProperty NodeId {}", mlp.getValueNode().getNodeId());
}
} else if (element instanceof AASReferenceElementType) {
AASReferenceElementType refElem = (AASReferenceElementType) element;
NodeId nid = refElem.getValueNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove AASReferenceElement NodeId {}", nid);
}
} else if (element instanceof AASRelationshipElementType) {
AASRelationshipElementType relElem = (AASRelationshipElementType) element;
NodeId nid = relElem.getFirstNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove AASRelationshipElement First NodeId {}", nid);
}
nid = relElem.getSecondNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove AASRelationshipElement Second NodeId {}", nid);
}
if ((relElem instanceof AASAnnotatedRelationshipElementType) && (referable instanceof AnnotatedRelationshipElement)) {
AnnotatedRelationshipElement annRelElem = (AnnotatedRelationshipElement) referable;
for (DataElement de : annRelElem.getAnnotations()) {
doRemoveFromMaps(reference, de);
}
}
} else if (element instanceof AASEntityType) {
AASEntityType ent = (AASEntityType) element;
if ((ent.getGlobalAssetIdNode() != null) && (ent.getGlobalAssetIdNode().getKeysNode() != null)) {
NodeId nid = ent.getGlobalAssetIdNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
LOG.debug("doRemoveFromMaps: remove Entity GlobalAssetId NodeId {}", nid);
}
}
if (submodelElementAasMap.containsKey(ent.getEntityTypeNode().getNodeId())) {
submodelElementAasMap.remove(ent.getEntityTypeNode().getNodeId());
LOG.debug("doRemoveFromMaps: remove Entity EntityType NodeId {}", ent.getEntityTypeNode().getNodeId());
}
} else if (referable instanceof SubmodelElementCollection) {
SubmodelElementCollection sec = (SubmodelElementCollection) referable;
for (SubmodelElement se : sec.getValues()) {
doRemoveFromMaps(reference, se);
}
}
// Capability and File are currently not relevant here
} catch (Exception ex) {
LOG.error("doRemoveFromMaps Exception", ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.Property in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasMultiLanguageProperty.
/**
* Adds an AAS Multi Language Property to the given node.
*
* @param node The desired UA node
* @param aasMultiLang The AAS Multi Language Property to add
* @param submodel The corresponding Submodel as parent object of the data element
* @param parentRef The AAS reference to the parent object
* @param ordered Specifies whether the multi language property should be
* added ordered (true) or unordered (false)
* @throws StatusException If the operation fails
*/
private void addAasMultiLanguageProperty(UaNode node, MultiLanguageProperty aasMultiLang, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
try {
if ((node != null) && (aasMultiLang != null)) {
String name = aasMultiLang.getIdShort();
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASMultiLanguagePropertyType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASMultiLanguagePropertyType multiLangNode = createInstance(AASMultiLanguagePropertyType.class, nid, browseName, LocalizedText.english(name));
addSubmodelElementBaseData(multiLangNode, aasMultiLang);
List<LangString> values = aasMultiLang.getValues();
if (values != null) {
if (multiLangNode.getValueNode() == null) {
addMultiLanguageValueNode(multiLangNode, values.size());
}
multiLangNode.getValueNode().setValue(ValueConverter.getLocalizedTextFromLangStringSet(values));
}
if (aasMultiLang.getValueId() != null) {
addAasReferenceAasNS(multiLangNode, aasMultiLang.getValueId(), AASMultiLanguagePropertyType.VALUE_ID);
}
Reference multiLangRef = AasUtils.toReference(parentRef, aasMultiLang);
submodelElementAasMap.put(multiLangNode.getValueNode().getNodeId(), new SubmodelElementData(aasMultiLang, submodel, SubmodelElementData.Type.MULTI_LANGUAGE_VALUE, multiLangRef));
submodelElementOpcUAMap.put(multiLangRef, multiLangNode);
if (ordered) {
node.addReference(multiLangNode, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(multiLangNode);
}
referableMap.put(multiLangRef, new ObjectData(aasMultiLang, multiLangNode, submodel));
}
} catch (Exception ex) {
LOG.error("addAasMultiLanguageProperty Exception", ex);
throw ex;
}
}
Aggregations