Search in sources :

Example 1 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell in project FAAAST-Service by FraunhoferIOSB.

the class PutAssetAdministrationShellRequestHandler method process.

@Override
public PutAssetAdministrationShellResponse process(PutAssetAdministrationShellRequest request) {
    PutAssetAdministrationShellResponse response = new PutAssetAdministrationShellResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getAas().getIdentification(), new OutputModifier());
        shell = (AssetAdministrationShell) persistence.put(request.getAas());
        response.setPayload(shell);
        response.setStatusCode(StatusCode.Success);
        publishElementUpdateEventMessage(AasUtils.toReference(shell), shell);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : PutAssetAdministrationShellResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetAdministrationShellResponse) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) OutputModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Example 2 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell in project FAAAST-Service by FraunhoferIOSB.

the class PutAssetInformationRequestHandler method process.

@Override
public PutAssetInformationResponse process(PutAssetInformationRequest request) {
    PutAssetInformationResponse response = new PutAssetInformationResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), new QueryModifier());
        shell.setAssetInformation(request.getAssetInformation());
        persistence.put(shell);
        response.setStatusCode(StatusCode.Success);
        publishElementUpdateEventMessage(AasUtils.toReference(shell), shell);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) QueryModifier(de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier) PutAssetInformationResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.PutAssetInformationResponse)

Example 3 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testDELETESpecificShellEvent.

@Test
public void testDELETESpecificShellEvent() {
    AssetAdministrationShell expected = environment.getAssetAdministrationShells().get(1);
    String identifier = Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8));
    String url = HTTP_SHELLS + "/" + identifier;
    setUpEventCheck(expected, ElementDeleteEventMessage.class, () -> deleteCall(url));
}
Also used : DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) LangString(io.adminshell.aas.v3.model.LangString) Test(org.junit.Test)

Example 4 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testGETSpecificShellEvent.

@Test
public void testGETSpecificShellEvent() {
    AssetAdministrationShell expected = environment.getAssetAdministrationShells().get(1);
    setUpEventCheck(expected, ElementReadEventMessage.class, () -> getCall(HTTP_SHELLS + "/" + Base64.getUrlEncoder().encodeToString(expected.getIdentification().getIdentifier().getBytes(StandardCharsets.UTF_8)), AssetAdministrationShell.class));
}
Also used : DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Test(org.junit.Test)

Example 5 with AssetAdministrationShell

use of io.adminshell.aas.v3.model.AssetAdministrationShell in project FAAAST-Service by FraunhoferIOSB.

the class IntegrationTestHttpEndpoint method testPOSTShellEvent.

@Test
public void testPOSTShellEvent() {
    AssetAdministrationShell newShell = getNewShell();
    setUpEventCheck(newShell, ElementCreateEventMessage.class, () -> postCall(HTTP_SHELLS, newShell, AssetAdministrationShell.class));
}
Also used : DefaultAssetAdministrationShell(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Test(org.junit.Test)

Aggregations

AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)46 Test (org.junit.Test)29 DefaultAssetAdministrationShell (io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell)22 LangString (io.adminshell.aas.v3.model.LangString)14 HttpResponse (org.apache.http.HttpResponse)13 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)10 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)10 Reference (io.adminshell.aas.v3.model.Reference)8 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)8 AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)7 Submodel (io.adminshell.aas.v3.model.Submodel)7 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)6 AssetInformation (io.adminshell.aas.v3.model.AssetInformation)6 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)6 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)6 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)6 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)5 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)5 AssetAdministrationShellEnvironment (io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment)5 IdentifierType (io.adminshell.aas.v3.model.IdentifierType)5