use of io.adminshell.aas.v3.model.Event in project formula1-telemetry-kafka by ppatierno.
the class EventDeserializer method deserialize.
@Override
public Event deserialize(String topic, Headers headers, byte[] bytes) {
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
ParticipantData participantData = null;
// check if the raw bytes contains the participant data, depending the kind of event to deserialize
if (bytes.length > PacketEventData.SIZE) {
participantData = new ParticipantData().fill(bb);
}
Event event = new Event(participantData, (PacketEventData) new PacketEventData().fill(bb));
return event;
}
use of io.adminshell.aas.v3.model.Event in project formkiq-core by formkiq.
the class AwsResourceTest method assertLambdaFunctionConfigurations.
/**
* Assert {@link LambdaFunctionConfiguration}.
*
* @param c {@link LambdaFunctionConfiguration}
* @param arn {@link String}
* @param event {@link String}
*/
private static void assertLambdaFunctionConfigurations(final LambdaFunctionConfiguration c, final String arn, final String event) {
assertTrue(c.lambdaFunctionArn().contains(arn));
assertEquals(1, c.events().size());
Event e = c.events().get(0);
assertEquals(event, e.toString());
}
use of io.adminshell.aas.v3.model.Event in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointIT method testAssetAdministrationShellInterfaceUpdateAssetInformation.
@Test
public void testAssetAdministrationShellInterfaceUpdateAssetInformation() throws InterruptedException, MessageBusException, IOException, URISyntaxException, SerializationException, DeserializationException {
AssetAdministrationShell aas = environment.getAssetAdministrationShells().get(1);
AssetInformation expected = aas.getAssetInformation();
expected.getSpecificAssetIds().add(new DefaultIdentifierKeyValuePair.Builder().key("foo").value("bar").build());
// TODO does this trigger any message bus event?
executeAndAssertSingleEntity(HttpMethod.PUT, API_PATHS.aasInterface(aas).assetInformation(), StatusCode.SUCCESS_NO_CONTENT, expected, null, AssetInformation.class);
}
use of io.adminshell.aas.v3.model.Event in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointIT method testAssetAdministrationShellInterfaceGetAssetInformation.
@Test
public void testAssetAdministrationShellInterfaceGetAssetInformation() throws IOException, DeserializationException, InterruptedException, URISyntaxException, SerializationException {
AssetAdministrationShell aas = environment.getAssetAdministrationShells().get(1);
AssetInformation expected = aas.getAssetInformation();
// TODO does this trigger any message bus event?
executeAndAssertSingleEntity(HttpMethod.GET, API_PATHS.aasInterface(aas).assetInformation(), StatusCode.SUCCESS, null, expected, AssetInformation.class);
}
use of io.adminshell.aas.v3.model.Event in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method elementCreated.
/**
* Handles an elementCreated event.
*
* @param element Reference to the created element.
* @param value The element that was added.
* @throws StatusException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
*/
@SuppressWarnings("java:S2629")
private void elementCreated(Reference element, Referable value) throws StatusException, ServiceResultException, ServiceException, AddressSpaceException {
if (element == null) {
throw new IllegalArgumentException(ELEMENT_NULL);
} else if (value == null) {
throw new IllegalArgumentException(VALUE_NULL);
}
try {
LOG.debug("elementCreated called. Reference {}", AasUtils.asString(element));
// The element is the parent object where the value is added
ObjectData parent = null;
if (referableMap.containsKey(element)) {
parent = referableMap.get(element);
} else {
LOG.info("elementCreated: element not found in referableMap: {}", AasUtils.asString(element));
}
if (value instanceof ConceptDescription) {
addConceptDescriptions(List.of((ConceptDescription) value));
} else if (value instanceof Asset) {
addAsset(aasEnvironmentNode, (Asset) value);
} else if (value instanceof Submodel) {
addSubmodel(aasEnvironmentNode, (Submodel) value);
} else if (value instanceof AssetAdministrationShell) {
addAssetAdministrationShell((AssetAdministrationShell) value);
} else if (parent != null) {
if (value instanceof EmbeddedDataSpecification) {
if (parent.getNode() instanceof AASAssetAdministrationShellType) {
addEmbeddedDataSpecifications((AASAssetAdministrationShellType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
} else if (parent.getNode() instanceof AASSubmodelType) {
addEmbeddedDataSpecifications((AASSubmodelType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
} else if (parent.getNode() instanceof AASSubmodelElementType) {
addEmbeddedDataSpecifications((AASSubmodelElementType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
} else if (parent.getNode() instanceof AASAssetType) {
addEmbeddedDataSpecifications((AASAssetType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
} else {
LOG.warn("elementCreated: EmbeddedDataSpecification parent class not found");
}
} else if (value instanceof Constraint) {
if (parent.getNode() instanceof AASSubmodelType) {
addQualifiers(((AASSubmodelType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
} else if (parent.getNode() instanceof AASSubmodelElementType) {
addQualifiers(((AASSubmodelElementType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
} else {
LOG.warn("elementCreated: Constraint parent class not found");
}
} else if (value instanceof SubmodelElement) {
if (parent.getNode() instanceof AASSubmodelType) {
LOG.info("elementCreated: call addSubmodelElements");
addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), (Submodel) parent.getReferable(), element);
} else if (parent.getNode() instanceof AASSubmodelElementType) {
LOG.info("elementCreated: call addSubmodelElements");
addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), parent.getSubmodel(), element);
} else {
LOG.warn("elementCreated: SubmodelElement parent class not found: {}; {}", parent.getNode().getNodeId(), parent.getNode());
}
}
} else {
LOG.warn("elementCreated: element not found: {}", AasUtils.asString(element));
}
} catch (Exception ex) {
LOG.error("elementCreated Exception", ex);
throw ex;
}
}
Aggregations