Search in sources :

Example 1 with Extend

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend in project FAAAST-Service by FraunhoferIOSB.

the class PersistenceInMemoryTest method putSubmodelElementChangeInSubmodelElementCollectionTest.

@Test
public void putSubmodelElementChangeInSubmodelElementCollectionTest() throws ResourceNotFoundException {
    String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell_Mandatory";
    String SUBMODEL_IDENTIFIER = "https://acplt.org/Test_Submodel_Mandatory";
    String SUBMODEL_ELEMENT_COLLECTION_IDSHORT = "ExampleSubmodelCollectionUnordered";
    SubmodelElement submodelElement = ((SubmodelElementCollection) this.environment.getSubmodels().stream().filter(x -> x.getIdentification().getIdentifier().equalsIgnoreCase(SUBMODEL_IDENTIFIER)).findFirst().get().getSubmodelElements().stream().filter(y -> y.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_COLLECTION_IDSHORT)).findFirst().orElse(null)).getValues().stream().findFirst().orElse(null);
    SubmodelElement changedSubmodelElement = DeepCopyHelper.deepCopy(submodelElement, submodelElement.getClass());
    String category = "NewCategory";
    changedSubmodelElement.setCategory(category);
    Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_COLLECTION_IDSHORT, submodelElement.getIdShort());
    this.persistence.put(null, reference, changedSubmodelElement);
    SubmodelElement actualSubmodelelement = this.persistence.get(reference, new QueryModifier.Builder().extend(Extend.WithBLOBValue).build());
    Assert.assertEquals(changedSubmodelElement, actualSubmodelelement);
}
Also used : KeyElements(io.adminshell.aas.v3.model.KeyElements) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) AASFull(de.fraunhofer.iosb.ilt.faaast.service.model.AASFull) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) Extend(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend) Identifier(io.adminshell.aas.v3.model.Identifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) Identifiable(io.adminshell.aas.v3.model.Identifiable) Message(de.fraunhofer.iosb.ilt.faaast.service.model.api.Message) DeepCopyHelper(de.fraunhofer.iosb.ilt.faaast.service.util.DeepCopyHelper) KeyType(io.adminshell.aas.v3.model.KeyType) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) Level(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Level) Before(org.junit.Before) GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) IdentifierType(io.adminshell.aas.v3.model.IdentifierType) Reference(io.adminshell.aas.v3.model.Reference) Test(org.junit.Test) Persistence(de.fraunhofer.iosb.ilt.faaast.service.persistence.Persistence) Collectors(java.util.stream.Collectors) Result(de.fraunhofer.iosb.ilt.faaast.service.model.api.Result) OperationHandle(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationHandle) List(java.util.List) ExecutionState(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.ExecutionState) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) OperationResult(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationResult) Assert(org.junit.Assert) Submodel(io.adminshell.aas.v3.model.Submodel) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) Test(org.junit.Test)

Example 2 with Extend

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend in project FAAAST-Service by FraunhoferIOSB.

the class PersistenceInMemoryTest method getSubmodelElementTestWithBlob.

@Test
public void getSubmodelElementTestWithBlob() throws ResourceNotFoundException {
    String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell_Mandatory";
    String SUBMODEL_IDENTIFIER = "https://acplt.org/Test_Submodel_Mandatory";
    String SUBMODEL_ELEMENT_COLLECTION_IDSHORT = "ExampleSubmodelCollectionUnordered";
    String SUBMODEL_ELEMENT_IDSHORT = "ExampleBlob";
    Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_COLLECTION_IDSHORT, SUBMODEL_ELEMENT_IDSHORT);
    QueryModifier queryModifier = new QueryModifier.Builder().extend(Extend.WithBLOBValue).build();
    SubmodelElement actualSubmodelElement = persistence.get(reference, queryModifier);
    SubmodelElement expectedSubmodelElementExpected = ((SubmodelElementCollection) environment.getSubmodels().stream().filter(x -> x.getIdentification().getIdentifier().equalsIgnoreCase(SUBMODEL_IDENTIFIER)).findFirst().get().getSubmodelElements().stream().filter(x -> x.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_COLLECTION_IDSHORT)).findFirst().get()).getValues().stream().filter(x -> x.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_IDSHORT)).findFirst().get();
    Assert.assertEquals(expectedSubmodelElementExpected, actualSubmodelElement);
}
Also used : KeyElements(io.adminshell.aas.v3.model.KeyElements) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) AASFull(de.fraunhofer.iosb.ilt.faaast.service.model.AASFull) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) Extend(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend) Identifier(io.adminshell.aas.v3.model.Identifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) Identifiable(io.adminshell.aas.v3.model.Identifiable) Message(de.fraunhofer.iosb.ilt.faaast.service.model.api.Message) DeepCopyHelper(de.fraunhofer.iosb.ilt.faaast.service.util.DeepCopyHelper) KeyType(io.adminshell.aas.v3.model.KeyType) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) Level(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Level) Before(org.junit.Before) GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) IdentifierType(io.adminshell.aas.v3.model.IdentifierType) Reference(io.adminshell.aas.v3.model.Reference) Test(org.junit.Test) Persistence(de.fraunhofer.iosb.ilt.faaast.service.persistence.Persistence) Collectors(java.util.stream.Collectors) Result(de.fraunhofer.iosb.ilt.faaast.service.model.api.Result) OperationHandle(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationHandle) List(java.util.List) ExecutionState(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.ExecutionState) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) OperationResult(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationResult) Assert(org.junit.Assert) Submodel(io.adminshell.aas.v3.model.Submodel) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) Test(org.junit.Test)

Example 3 with Extend

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend in project FAAAST-Service by FraunhoferIOSB.

the class PersistenceInMemoryTest method testQueryModifierExtend.

@Test
public void testQueryModifierExtend() throws ResourceNotFoundException {
    String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell_Mandatory";
    String SUBMODEL_IDENTIFIER = "https://acplt.org/Test_Submodel_Mandatory";
    String SUBMODEL_ELEMENT_COLLECTION_IDSHORT = "ExampleSubmodelCollectionUnordered";
    String SUBMODEL_ELEMENT_IDSHORT = "ExampleBlob";
    Reference reference = Util.createReference(AAS_IDENTIFIER, SUBMODEL_IDENTIFIER, SUBMODEL_ELEMENT_COLLECTION_IDSHORT, SUBMODEL_ELEMENT_IDSHORT);
    QueryModifier queryModifier = new QueryModifier.Builder().extend(Extend.WithBLOBValue).build();
    Identifier submodelId = new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier(SUBMODEL_IDENTIFIER).build();
    SubmodelElement actual = this.persistence.get(reference, queryModifier);
    SubmodelElement expected = ((SubmodelElementCollection) this.environment.getSubmodels().stream().filter(x -> x.getIdentification().equals(submodelId)).findFirst().get().getSubmodelElements().stream().filter(y -> y.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_COLLECTION_IDSHORT)).findFirst().get()).getValues().stream().filter(z -> z.getIdShort().equalsIgnoreCase(SUBMODEL_ELEMENT_IDSHORT)).findFirst().get();
    Assert.assertEquals(expected, actual);
    queryModifier = new QueryModifier.Builder().extend(Extend.WithoutBLOBValue).build();
    actual = this.persistence.get(reference, queryModifier);
    expected = null;
    Assert.assertEquals(expected, actual);
}
Also used : KeyElements(io.adminshell.aas.v3.model.KeyElements) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) AASFull(de.fraunhofer.iosb.ilt.faaast.service.model.AASFull) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) Extend(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend) Identifier(io.adminshell.aas.v3.model.Identifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) Identifiable(io.adminshell.aas.v3.model.Identifiable) Message(de.fraunhofer.iosb.ilt.faaast.service.model.api.Message) DeepCopyHelper(de.fraunhofer.iosb.ilt.faaast.service.util.DeepCopyHelper) KeyType(io.adminshell.aas.v3.model.KeyType) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) Level(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Level) Before(org.junit.Before) GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) IdentifierType(io.adminshell.aas.v3.model.IdentifierType) Reference(io.adminshell.aas.v3.model.Reference) Test(org.junit.Test) Persistence(de.fraunhofer.iosb.ilt.faaast.service.persistence.Persistence) Collectors(java.util.stream.Collectors) Result(de.fraunhofer.iosb.ilt.faaast.service.model.api.Result) OperationHandle(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationHandle) List(java.util.List) ExecutionState(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.ExecutionState) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) OperationResult(de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationResult) Assert(org.junit.Assert) Submodel(io.adminshell.aas.v3.model.Submodel) Identifier(io.adminshell.aas.v3.model.Identifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) Test(org.junit.Test)

Aggregations

ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)3 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)3 Message (de.fraunhofer.iosb.ilt.faaast.service.model.api.Message)3 Result (de.fraunhofer.iosb.ilt.faaast.service.model.api.Result)3 Extend (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend)3 Level (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Level)3 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)3 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)3 ExecutionState (de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.ExecutionState)3 OperationHandle (de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationHandle)3 OperationResult (de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationResult)3 AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)3 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)3 Persistence (de.fraunhofer.iosb.ilt.faaast.service.persistence.Persistence)3 DeepCopyHelper (de.fraunhofer.iosb.ilt.faaast.service.util.DeepCopyHelper)3 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)3 AssetAdministrationShellEnvironment (io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment)3 ConceptDescription (io.adminshell.aas.v3.model.ConceptDescription)3 Identifiable (io.adminshell.aas.v3.model.Identifiable)3 Identifier (io.adminshell.aas.v3.model.Identifier)3