Search in sources :

Example 11 with ConceptDescription

use of io.adminshell.aas.v3.model.ConceptDescription 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 12 with ConceptDescription

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

the class GetConceptDescriptionByIdRequestHandler method process.

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

Example 13 with ConceptDescription

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

the class PutConceptDescriptionByIdRequestHandler method process.

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

Example 14 with ConceptDescription

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

the class IdentifiablePersistenceManager method remove.

/**
 * Remove an identifiable by its identifier.
 * Following identifiables are supported:
 * <p>
 * <ul>
 * <li>{@link io.adminshell.aas.v3.model.AssetAdministrationShell}
 * <li>{@link io.adminshell.aas.v3.model.Submodel}
 * <li>{@link io.adminshell.aas.v3.model.ConceptDescription}
 * <li>{@link io.adminshell.aas.v3.model.Asset}
 * </ul>
 * <p>
 *
 * @param id of the indetifiable which should be removed
 * @throws ResourceNotFoundException if there is no identifiable with such an identifer
 */
public void remove(Identifier id) throws ResourceNotFoundException {
    if (id == null || this.aasEnvironment == null) {
        return;
    }
    Predicate<Identifiable> removeFilter = x -> !x.getIdentification().getIdentifier().equalsIgnoreCase(id.getIdentifier());
    Identifiable identifiable = getIdentifiableById(id);
    if (identifiable == null) {
        throw new ResourceNotFoundException("Resource not found with ID " + id.getIdentifier());
    }
    // TODO: use reflection?
    if (AssetAdministrationShell.class.isAssignableFrom(identifiable.getClass())) {
        List<AssetAdministrationShell> newAASList;
        newAASList = this.aasEnvironment.getAssetAdministrationShells().stream().filter(removeFilter).collect(Collectors.toList());
        this.aasEnvironment.setAssetAdministrationShells(newAASList);
    } else if (Submodel.class.isAssignableFrom(identifiable.getClass())) {
        List<Submodel> newSubmodelList;
        newSubmodelList = this.aasEnvironment.getSubmodels().stream().filter(removeFilter).collect(Collectors.toList());
        this.aasEnvironment.setSubmodels(newSubmodelList);
        Reference referenceOfIdentifiable = AasUtils.toReference(identifiable);
        this.aasEnvironment.getAssetAdministrationShells().forEach(x -> x.getSubmodels().remove(referenceOfIdentifiable));
    } else if (ConceptDescription.class.isAssignableFrom(identifiable.getClass())) {
        List<ConceptDescription> newConceptDescriptionList;
        newConceptDescriptionList = this.aasEnvironment.getConceptDescriptions().stream().filter(removeFilter).collect(Collectors.toList());
        this.aasEnvironment.setConceptDescriptions(newConceptDescriptionList);
    } else if (Asset.class.isAssignableFrom(identifiable.getClass())) {
        List<Asset> newAssetList;
        newAssetList = this.aasEnvironment.getAssets().stream().filter(removeFilter).collect(Collectors.toList());
        this.aasEnvironment.setAssets(newAssetList);
    }
}
Also used : GlobalAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) Predicate(java.util.function.Predicate) Reference(io.adminshell.aas.v3.model.Reference) SpecificAssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.SpecificAssetIdentification) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) AasUtils(io.adminshell.aas.v3.dataformat.core.util.AasUtils) Identifier(io.adminshell.aas.v3.model.Identifier) ArrayList(java.util.ArrayList) ReferenceHelper(de.fraunhofer.iosb.ilt.faaast.service.util.ReferenceHelper) AssetIdentification(de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification) Asset(io.adminshell.aas.v3.model.Asset) Identifiable(io.adminshell.aas.v3.model.Identifiable) List(java.util.List) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) DeepCopyHelper(de.fraunhofer.iosb.ilt.faaast.service.util.DeepCopyHelper) EnvironmentHelper(de.fraunhofer.iosb.ilt.faaast.service.persistence.memory.util.EnvironmentHelper) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Submodel(io.adminshell.aas.v3.model.Submodel) Submodel(io.adminshell.aas.v3.model.Submodel) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Reference(io.adminshell.aas.v3.model.Reference) Asset(io.adminshell.aas.v3.model.Asset) ArrayList(java.util.ArrayList) List(java.util.List) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ResourceNotFoundException(de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException) Identifiable(io.adminshell.aas.v3.model.Identifiable)

Example 15 with ConceptDescription

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

the class AasServiceNodeManager method addConceptDescriptions.

/**
 * Adds the given list of AAS Concept Descriptions.
 *
 * @param descriptions The desired list of AAS Concept Descriptions
 * @throws StatusException If the operation fails
 * @throws ServiceResultException Generic service exception
 */
private void addConceptDescriptions(List<ConceptDescription> descriptions) throws StatusException, ServiceResultException {
    try {
        // create folder DictionaryEntries
        final UaNode dictionariesFolder = getServer().getNodeManagerRoot().getNodeOrExternal(Identifiers.Dictionaries);
        // Folder for my objects
        final NodeId dictionarieEntriesFolderId = new NodeId(getNamespaceIndex(), "Dictionaries.DictionaryEntries");
        FolderTypeNode dictEntriesFolder = createInstance(FolderTypeNode.class, "DictionaryEntries", dictionarieEntriesFolderId);
        this.addNodeAndReference(dictionariesFolder, dictEntriesFolder, Identifiers.Organizes);
        for (ConceptDescription c : descriptions) {
            String name = c.getIdShort();
            NodeId nid = createNodeId(dictionariesFolder, name);
            DictionaryEntryType dictNode;
            switch(c.getIdentification().getIdType()) {
                case IRDI:
                    AASIrdiConceptDescriptionType irdiNode = createInstance(AASIrdiConceptDescriptionType.class, name, nid);
                    addIdentifiable(irdiNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(irdiNode, getReference(c));
                    dictEntriesFolder.addComponent(irdiNode);
                    dictionaryMap.put(getReference(c), irdiNode);
                    dictNode = irdiNode;
                    break;
                case IRI:
                    AASIriConceptDescriptionType iriNode = createInstance(AASIriConceptDescriptionType.class, name, nid);
                    addIdentifiable(iriNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(iriNode, getReference(c));
                    dictEntriesFolder.addComponent(iriNode);
                    dictionaryMap.put(getReference(c), iriNode);
                    dictNode = iriNode;
                    break;
                default:
                    AASCustomConceptDescriptionType customNode = createInstance(AASCustomConceptDescriptionType.class, name, nid);
                    addIdentifiable(customNode, c.getIdentification(), c.getAdministration(), name);
                    addConceptDescriptionReference(customNode, getReference(c));
                    dictEntriesFolder.addComponent(customNode);
                    dictionaryMap.put(getReference(c), customNode);
                    dictNode = customNode;
                    break;
            }
            referableMap.put(AasUtils.toReference(c), new ObjectData(c, dictNode));
        }
    } catch (Throwable ex) {
        logger.error("addConceptDescriptions Exception", ex);
        throw ex;
    }
}
Also used : AASIriConceptDescriptionType(opc.i4aas.AASIriConceptDescriptionType) DictionaryEntryType(com.prosysopc.ua.types.opcua.DictionaryEntryType) AASCustomConceptDescriptionType(opc.i4aas.AASCustomConceptDescriptionType) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) UaNode(com.prosysopc.ua.nodes.UaNode) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) FolderTypeNode(com.prosysopc.ua.types.opcua.server.FolderTypeNode) AASIrdiConceptDescriptionType(opc.i4aas.AASIrdiConceptDescriptionType)

Aggregations

ConceptDescription (io.adminshell.aas.v3.model.ConceptDescription)18 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)8 QueryModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.QueryModifier)8 Test (org.junit.Test)7 AssetAdministrationShell (io.adminshell.aas.v3.model.AssetAdministrationShell)6 Identifier (io.adminshell.aas.v3.model.Identifier)6 Submodel (io.adminshell.aas.v3.model.Submodel)6 OutputModifier (de.fraunhofer.iosb.ilt.faaast.service.model.api.modifier.OutputModifier)5 AssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.AssetIdentification)5 GlobalAssetIdentification (de.fraunhofer.iosb.ilt.faaast.service.model.asset.GlobalAssetIdentification)5 DeepCopyHelper (de.fraunhofer.iosb.ilt.faaast.service.util.DeepCopyHelper)5 Identifiable (io.adminshell.aas.v3.model.Identifiable)5 Reference (io.adminshell.aas.v3.model.Reference)5 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)5 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 AASFull (de.fraunhofer.iosb.ilt.faaast.service.model.AASFull)4 Message (de.fraunhofer.iosb.ilt.faaast.service.model.api.Message)4 Result (de.fraunhofer.iosb.ilt.faaast.service.model.api.Result)4