use of io.adminshell.aas.v3.model.AssetInformation in project FAAAST-Service by FraunhoferIOSB.
the class IntegrationTestHttpEndpoint method testPUTAssetInformation.
@Test
public void testPUTAssetInformation() throws IOException, DeserializationException {
AssetAdministrationShell aas = environment.getAssetAdministrationShells().get(1);
AssetInformation expected = aas.getAssetInformation();
expected.setAssetKind(AssetKind.TYPE);
String url = HTTP_SHELLS + "/" + Base64.getUrlEncoder().encodeToString(aas.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8)) + "/aas/asset-information";
HttpResponse response = putCall(url, expected);
// TODO: StatusCode of spec seems to be wrong 204
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
AssetInformation actual = getCall(url, AssetInformation.class);
Assert.assertEquals(expected, actual);
}
use of io.adminshell.aas.v3.model.AssetInformation 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.AssetInformation 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;
}
}
use of io.adminshell.aas.v3.model.AssetInformation 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 {
logger.info("addSpecificAssetIds " + name + "; to Node: " + assetInfoNode.toString());
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 (Throwable ex) {
logger.error("addSpecificAssetIds Exception", ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.AssetInformation in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAssetAdministrationShell.
/**
* Adds the given AssetAdministrationShell.
*
* @throws StatusException If the operation fails
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws ServiceResultException If the operation fails
*/
private void addAssetAdministrationShell(AssetAdministrationShell aas) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
try {
TypeDefinitionBasedNodeBuilderConfiguration.Builder conf = TypeDefinitionBasedNodeBuilderConfiguration.builder();
Reference derivedFrom = aas.getDerivedFrom();
if (derivedFrom != null) {
UaBrowsePath bp = UaBrowsePath.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAssetAdministrationShellType.DERIVED_FROM));
conf.addOptional(bp);
}
this.setNodeBuilderConfiguration(conf.build());
QualifiedName browseName = UaQualifiedName.from(NAMESPACE_URI, aas.getIdShort()).toQualifiedName(getNamespaceTable());
String displayName = "AAS:" + aas.getIdShort();
NodeId nid = new NodeId(getNamespaceIndex(), aas.getIdShort());
if (findNode(nid) != null) {
// The NodeId already exists
nid = getDefaultNodeId();
}
AASAssetAdministrationShellType aasShell = createInstance(AASAssetAdministrationShellTypeNode.class, nid, browseName, LocalizedText.english(displayName));
addIdentifiable(aasShell, aas.getIdentification(), aas.getAdministration(), aas.getCategory());
// DataSpecifications
addEmbeddedDataSpecifications(aasShell, aas.getEmbeddedDataSpecifications());
// AssetInformation
AssetInformation assetInformation = aas.getAssetInformation();
if (assetInformation != null) {
addAssetInformation(aasShell, assetInformation);
}
// submodel references
List<Reference> submodelRefs = aas.getSubmodels();
if ((submodelRefs != null) && (!submodelRefs.isEmpty())) {
addSubmodelReferences(aasShell, submodelRefs);
}
// add AAS to Environment
addNodeAndReference(aasEnvironmentNode, aasShell, Identifiers.Organizes);
referableMap.put(AasUtils.toReference(aas), new ObjectData(aas, aasShell));
} catch (Throwable ex) {
logger.error("addAssetAdministrationShell Exception", ex);
throw ex;
}
}
Aggregations