use of opc.i4aas.AASSubmodelElementList in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setEntityValue.
/**
* Sets the values for the given Entity.
*
* @param entity The desired Entity.
* @param value The new value.
* @throws StatusException If the operation fails
*/
private void setEntityValue(AASEntityType entity, EntityValue value) throws StatusException {
if (entity == null) {
throw new IllegalArgumentException("entity is null");
} else if (value == null) {
throw new IllegalArgumentException("value is null");
}
try {
// EntityType
entity.setEntityType(ValueConverter.getAasEntityType(value.getEntityType()));
// GlobalAssetId
if ((value.getGlobalAssetId() != null) && (value.getGlobalAssetId().size() > 0)) {
DefaultReference ref = new DefaultReference.Builder().keys(value.getGlobalAssetId()).build();
setAasReferenceData(ref, entity.getGlobalAssetIdNode());
}
// Statements
Map<String, ElementValue> valueMap = value.getStatements();
AASSubmodelElementList statementNode = entity.getStatementNode();
if (statementNode != null) {
UaNode[] statementNodes = statementNode.getComponents();
if (statementNodes.length != valueMap.size()) {
logger.warn("Size of Value (" + valueMap.size() + ") doesn't match the number of StatementNodes (" + statementNodes.length + ")");
throw new IllegalArgumentException("Size of Value doesn't match the number of StatementNodes");
}
for (UaNode statementNode1 : statementNodes) {
if (statementNode1 instanceof AASSubmodelElementType) {
if (value.getStatements().containsKey(statementNode1.getBrowseName().getName())) {
setSubmodelElementValue((AASSubmodelElementType) statementNode1, value.getStatements().get(statementNode1.getBrowseName().getName()));
}
}
}
}
} catch (Throwable ex) {
logger.error("setEntityValue Exception", ex);
throw ex;
}
}
Aggregations