use of io.adminshell.aas.v3.model.AssetKind in project FAAAST-Service by FraunhoferIOSB.
the class JsonSerializerTest method testIdentifiableSerialization.
@Test
public void testIdentifiableSerialization() throws Exception {
AssetAdministrationShell shell = new DefaultAssetAdministrationShell.Builder().idShort("testShell").assetInformation(new DefaultAssetInformation.Builder().assetKind(AssetKind.INSTANCE).build()).build();
compareToAdminShellIoSerialization(shell);
}
use of io.adminshell.aas.v3.model.AssetKind in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAssetInformation.
/**
* Adds an AssetInformation object to the given Node.
*
* @param aasNode The AAS node where the AssetInformation should be added
* @param assetInformation The desired AssetInformation object
* @throws StatusException If the operation fails
*/
private void addAssetInformation(AASAssetAdministrationShellType aasNode, AssetInformation assetInformation) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
if (aasNode == null) {
throw new IllegalArgumentException("aasNode = null");
} else if (assetInformation == null) {
throw new IllegalArgumentException("assetInformation = null");
}
try {
boolean created = false;
AASAssetInformationType assetInfoNode;
assetInfoNode = aasNode.getAssetInformationNode();
if (assetInfoNode == null) {
String displayName = "AssetInformation";
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelType.getNamespaceUri(), displayName).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(aasNode, browseName);
assetInfoNode = createInstance(AASAssetInformationType.class, nid, browseName, LocalizedText.english(displayName));
created = true;
}
if (assetInfoNode != null) {
// AssetKind
AssetKind assetKind = assetInformation.getAssetKind();
assetInfoNode.setAssetKind(ValueConverter.convertAssetKind(assetKind));
// BillOfMaterials
List<Reference> assetBills = assetInformation.getBillOfMaterials();
if ((assetBills != null) && (!assetBills.isEmpty())) {
AASReferenceList assetBillsNode = assetInfoNode.getBillOfMaterialNode();
addBillOfMaterials(assetBillsNode, assetBills);
}
// DefaultThumbnail
File thumbnail = assetInformation.getDefaultThumbnail();
if (thumbnail != null) {
addAasFile(assetInfoNode, thumbnail, null, null, false, AASAssetInformationType.DEFAULT_THUMBNAIL);
}
// GlobalAssetId
Reference globalAssetId = assetInformation.getGlobalAssetId();
if (globalAssetId != null) {
addAasReferenceAasNS(assetInfoNode, globalAssetId, AASAssetInformationType.GLOBAL_ASSET_ID);
}
// SpecificAssetIds
List<IdentifierKeyValuePair> specificAssetIds = assetInformation.getSpecificAssetIds();
if ((specificAssetIds != null) && (!specificAssetIds.isEmpty())) {
addSpecificAssetIds(assetInfoNode, specificAssetIds, "SpecificAssetIds");
}
if (created) {
aasNode.addComponent(assetInfoNode);
}
}
} catch (Throwable ex) {
logger.error("addAssetInformation Exception", ex);
throw ex;
}
}
Aggregations