use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method createAnnotatedRelationshipElement.
/**
* Creates an Annotated Relationship Element.
*
* @param aasRelElem The AAS Annotated Relationship Element
* @param submodel The corresponding Submodel as parent object of the data element
* @param relElemRef The AAS reference to the AnnotatedRelationshipElement
* @param nodeId The desired NodeId for the node to be created
* @return The create UA Annotated Relationship Element
* @throws StatusException If the operation fails
*/
private AASRelationshipElementType createAnnotatedRelationshipElement(AnnotatedRelationshipElement aasRelElem, Submodel submodel, Reference relElemRef, NodeId nodeId) throws StatusException {
AASRelationshipElementType retval = null;
try {
AASAnnotatedRelationshipElementType relElemNode = createInstance(AASAnnotatedRelationshipElementType.class, nodeId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAnnotatedRelationshipElementType.getNamespaceUri(), aasRelElem.getIdShort()).toQualifiedName(getNamespaceTable()), LocalizedText.english(aasRelElem.getIdShort()));
// Annotations
for (DataElement de : aasRelElem.getAnnotations()) {
addAasDataElement(relElemNode.getAnnotationNode(), de, submodel, relElemRef, false);
}
retval = relElemNode;
} catch (Exception ex) {
LOG.error("createAnnotatedRelationshipElement Exception", ex);
throw ex;
}
return retval;
}
use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addEmbeddedDataSpecificationsReferences.
/**
* Adds the references to the given Embedded Data Specification references.
*
* @param refListNode The desired object where the DataSpecifications should be added
* @param refList The list of the desired Data Specification references
* @throws StatusException If the operation fails
*/
private void addEmbeddedDataSpecificationsReferences(AASReferenceList refListNode, List<Reference> refList) throws StatusException {
try {
if ((refListNode != null) && (!refList.isEmpty())) {
int count = 0;
for (Reference ref : refList) {
count++;
String name = AASAssetAdministrationShellType.DATA_SPECIFICATION;
if (count > 1) {
name += count;
}
addAasReferenceAasNS(refListNode, ref, name);
}
}
} catch (Exception ex) {
LOG.error(ADD_EMBED_DS_EXC, ex);
throw ex;
}
}
use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasReferenceList.
/**
* Creates a node with the given name and adds the given list of references.
*
* @param node The UA node in which the list of references should be created
* @param list The desired list of references
* @param name The desired name of the Node
* @throws StatusException If the operation fails
*/
private void addAasReferenceList(UaNode node, List<Reference> list, String name) throws StatusException {
if (node == null) {
throw new IllegalArgumentException(NODE_NULL);
} else if (list == null) {
throw new IllegalArgumentException("list = null");
}
try {
LOG.info("addAasReferenceList {}; to Node: {}", name, node);
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASReferenceList referenceListNode = createInstance(AASReferenceList.class, nid, browseName, LocalizedText.english(name));
int counter = 1;
for (Reference ref : list) {
addAasReferenceAasNS(referenceListNode, ref, name + counter++);
}
node.addComponent(referenceListNode);
} catch (Exception ex) {
LOG.error("addAasReferenceList Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasFile.
/**
* Adds an AAS file to the given node.
*
* @param node The desired UA node
* @param aasFile The AAS file object
* @param submodel The corresponding Submodel as parent object of the data element
* @param parentRef The AAS reference to the parent node
* @param ordered Specifies whether the file should be added ordered (true) or unordered (false)
* @param nodeName The desired Name of the node. If this value is not set,
* the IdShort of the file is used.
* @throws StatusException If the operation fails
*/
private void addAasFile(UaNode node, File aasFile, Submodel submodel, Reference parentRef, boolean ordered, String nodeName) throws StatusException {
try {
if ((node != null) && (aasFile != null)) {
String name = aasFile.getIdShort();
if ((nodeName != null) && (!nodeName.isEmpty())) {
name = nodeName;
}
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASFileType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASFileType fileNode = createInstance(AASFileType.class, nid, browseName, LocalizedText.english(name));
addSubmodelElementBaseData(fileNode, aasFile);
// MimeType
if (!aasFile.getMimeType().isEmpty()) {
fileNode.setMimeType(aasFile.getMimeType());
}
// Value
if (aasFile.getValue() != null) {
if (fileNode.getValueNode() == null) {
addFileValueNode(fileNode);
}
fileNode.setValue(aasFile.getValue());
if (!aasFile.getValue().isEmpty()) {
java.io.File f = new java.io.File(aasFile.getValue());
if (!f.exists()) {
LOG.warn("addAasFile: File '{}' does not exist!", f.getAbsolutePath());
} else {
// File Object: include only when the file exists
QualifiedName fileBrowseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASFileType.getNamespaceUri(), AASFileType.FILE).toQualifiedName(getNamespaceTable());
NodeId fileId = new NodeId(getNamespaceIndex(), fileNode.getNodeId().getValue().toString() + "." + AASFileType.FILE);
FileTypeNode fileType = createInstance(FileTypeNode.class, fileId, fileBrowseName, LocalizedText.english(AASFileType.FILE));
fileType.setFile(new java.io.File(aasFile.getValue()));
fileType.setWritable(false);
fileType.setUserWritable(false);
if (fileType.getNodeVersion() != null) {
fileType.getNodeVersion().setDescription(new LocalizedText("", ""));
}
fileNode.addReference(fileType, Identifiers.HasAddIn, false);
}
}
}
if (ordered) {
node.addReference(fileNode, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(fileNode);
}
if (parentRef != null) {
Reference fileRef = AasUtils.toReference(parentRef, aasFile);
referableMap.put(fileRef, new ObjectData(aasFile, fileNode, submodel));
}
}
} catch (Exception ex) {
LOG.error("addAasFile Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addSpecificAssetIds.
/**
* Adds a list of IdentifierKeyValuePairs to the given Node.
*
* @param assetInfoNode The AssetInformation node in which the
* IdentifierKeyValuePairs should be created or added
* @param list The desired list of IdentifierKeyValuePairs
* @param name The desired name of the Node
* @throws StatusException If the operation fails
*/
private void addSpecificAssetIds(AASAssetInformationType assetInfoNode, List<IdentifierKeyValuePair> list, String name) throws StatusException {
if (assetInfoNode == null) {
throw new IllegalArgumentException("assetInfoNode = null");
} else if (list == null) {
throw new IllegalArgumentException("list = null");
}
try {
LOG.info("addSpecificAssetIds {}; to Node: {}", name, assetInfoNode);
AASIdentifierKeyValuePairList listNode = assetInfoNode.getSpecificAssetIdNode();
boolean created = false;
if (listNode == null) {
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASIdentifierKeyValuePairList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(assetInfoNode, browseName);
listNode = createInstance(AASIdentifierKeyValuePairList.class, nid, browseName, LocalizedText.english(name));
created = true;
}
for (IdentifierKeyValuePair ikv : list) {
if (ikv != null) {
addIdentifierKeyValuePair(listNode, ikv, ikv.getKey());
}
}
if (created) {
assetInfoNode.addComponent(listNode);
}
} catch (Exception ex) {
LOG.error("addSpecificAssetIds Exception", ex);
throw ex;
}
}
Aggregations