Search in sources :

Example 21 with AssetAdministrationShell

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

the class GetAllSubmodelsReferencesRequestHandler method process.

@Override
public GetAllSubmodelReferencesResponse process(GetAllSubmodelReferencesRequest request) {
    GetAllSubmodelReferencesResponse response = new GetAllSubmodelReferencesResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), request.getOutputModifier());
        List<Reference> submodelReferences = shell.getSubmodels();
        response.setPayload(submodelReferences);
        response.setStatusCode(StatusCode.Success);
        publishElementReadEventMessage(AasUtils.toReference(shell), shell);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) GetAllSubmodelReferencesResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAllSubmodelReferencesResponse) Reference(io.adminshell.aas.v3.model.Reference) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Example 22 with AssetAdministrationShell

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

the class GetAssetAdministrationShellByIdRequestHandler method process.

@Override
public GetAssetAdministrationShellByIdResponse process(GetAssetAdministrationShellByIdRequest request) {
    GetAssetAdministrationShellByIdResponse response = new GetAssetAdministrationShellByIdResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), request.getOutputModifier());
        response.setPayload(shell);
        response.setStatusCode(StatusCode.Success);
        publishElementReadEventMessage(AasUtils.toReference(shell), shell);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) GetAssetAdministrationShellByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.GetAssetAdministrationShellByIdResponse) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

Example 23 with AssetAdministrationShell

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

the class GetAssetInformationRequestHandler method process.

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

Example 24 with AssetAdministrationShell

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

the class DeleteAssetAdministrationShellByIdRequestHandler method process.

@Override
public DeleteAssetAdministrationShellByIdResponse process(DeleteAssetAdministrationShellByIdRequest request) {
    DeleteAssetAdministrationShellByIdResponse response = new DeleteAssetAdministrationShellByIdResponse();
    try {
        AssetAdministrationShell shell = (AssetAdministrationShell) persistence.get(request.getId(), new QueryModifier());
        persistence.remove(request.getId());
        response.setStatusCode(StatusCode.Success);
        publishElementDeleteEventMessage(AasUtils.toReference(shell), shell);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } catch (Exception ex) {
        response.setStatusCode(StatusCode.ServerInternalError);
    }
    return response;
}
Also used : AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) DeleteAssetAdministrationShellByIdResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteAssetAdministrationShellByIdResponse) 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)

Example 25 with AssetAdministrationShell

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

the class DeleteSubmodelReferenceRequestHandler method process.

@Override
public DeleteSubmodelReferenceResponse process(DeleteSubmodelReferenceRequest request) {
    DeleteSubmodelReferenceResponse response = new DeleteSubmodelReferenceResponse();
    try {
        AssetAdministrationShell aas = (AssetAdministrationShell) persistence.get(request.getId(), new QueryModifier());
        aas.getSubmodels().remove(request.getSubmodelRef());
        persistence.put(aas);
        response.setStatusCode(StatusCode.Success);
        publishElementUpdateEventMessage(AasUtils.toReference(aas), aas);
    } catch (ResourceNotFoundException ex) {
        response.setStatusCode(StatusCode.ClientErrorResourceNotFound);
    } 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) DeleteSubmodelReferenceResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.DeleteSubmodelReferenceResponse) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)

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