Search in sources :

Example 16 with QueryModifier

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

the class PersistenceInMemoryTest method removeAASTest.

@Test
public void removeAASTest() throws ResourceNotFoundException {
    String AAS_IDENTIFIER = "https://acplt.org/Test_AssetAdministrationShell_Mandatory";
    Identifier aasId = new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier(AAS_IDENTIFIER).build();
    this.persistence.remove(aasId);
    Assert.assertThrows(ResourceNotFoundException.class, () -> this.persistence.get(aasId, new QueryModifier()));
}
Also used : Identifier(io.adminshell.aas.v3.model.Identifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) Test(org.junit.Test)

Example 17 with QueryModifier

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

the class PersistenceInMemoryTest method putIdentifiableChangeTest.

@Test
public void putIdentifiableChangeTest() throws ResourceNotFoundException {
    ConceptDescription expected = DeepCopyHelper.deepCopy(this.environment.getConceptDescriptions().get(0), this.environment.getConceptDescriptions().get(0).getClass());
    String category = "NewCategory";
    expected.setCategory(category);
    this.persistence.put(expected);
    ConceptDescription actual = (ConceptDescription) this.persistence.get(expected.getIdentification(), new QueryModifier());
    Assert.assertEquals(expected, actual);
}
Also used : QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) Test(org.junit.Test)

Example 18 with QueryModifier

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

the class PersistenceInMemoryTest method getConceptDescriptionsWithIsCaseOfTest.

@Test
public void getConceptDescriptionsWithIsCaseOfTest() {
    String conceptDescriptionIdShort = "TestConceptDescription";
    Reference isCaseOf = new DefaultReference.Builder().key(new DefaultKey.Builder().type(null).idType(KeyType.IRI).value("http://acplt.org/DataSpecifications/ConceptDescriptions/TestConceptDescription").build()).build();
    List<ConceptDescription> actualConceptDescriptions = this.persistence.get(null, isCaseOf, (Reference) null, new QueryModifier());
    List<ConceptDescription> expectedConceptDescriptions = this.environment.getConceptDescriptions().stream().filter(x -> x.getIdShort().equalsIgnoreCase(conceptDescriptionIdShort)).collect(Collectors.toList());
    Assert.assertEquals(actualConceptDescriptions, expectedConceptDescriptions);
}
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) 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) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) Test(org.junit.Test)

Example 19 with QueryModifier

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

the class DeleteConceptDescriptionByIdRequestHandler method process.

@Override
public DeleteConceptDescriptionByIdResponse process(DeleteConceptDescriptionByIdRequest request) {
    DeleteConceptDescriptionByIdResponse response = new DeleteConceptDescriptionByIdResponse();
    try {
        ConceptDescription conceptDescription = (ConceptDescription) persistence.get(request.getId(), new QueryModifier());
        persistence.remove(request.getId());
        response.setStatusCode(StatusCode.Success);
        publishElementDeleteEventMessage(AasUtils.toReference(conceptDescription), conceptDescription);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) DeleteConceptDescriptionByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteConceptDescriptionByIdResponse)

Example 20 with QueryModifier

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

the class DeleteSubmodelElementByPathRequestHandler method process.

@Override
public DeleteSubmodelElementByPathResponse process(DeleteSubmodelElementByPathRequest request) {
    DeleteSubmodelElementByPathResponse response = new DeleteSubmodelElementByPathResponse();
    try {
        Reference reference = ReferenceHelper.toReference(request.getPath(), request.getId(), Submodel.class);
        SubmodelElement submodelElement = persistence.get(reference, new QueryModifier());
        persistence.remove(reference);
        response.setStatusCode(StatusCode.Success);
        publishElementDeleteEventMessage(reference, submodelElement);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) Reference(io.adminshell.aas.v3.model.Reference) DeleteSubmodelElementByPathResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelElementByPathResponse) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Aggregations

QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)49 Test (org.junit.Test)41 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)25 Reference (io.adminshell.aas.v3.model.Reference)24 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)24 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)22 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)22 Identifier (io.adminshell.aas.v3.model.Identifier)21 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)21 ConceptDescription (io.adminshell.aas.v3.model.ConceptDescription)20 Submodel (io.adminshell.aas.v3.model.Submodel)20 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)18 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)18 AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)17 Identifiable (io.adminshell.aas.v3.model.Identifiable)17 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)16 Message (de.fraunhofer.iosb.ilt.faaast.service.model.api.Message)16 Result (de.fraunhofer.iosb.ilt.faaast.service.model.api.Result)16 Extend (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Extend)16 Level (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.Level)16