package org.gcube.informationsystem.resourceregistry.instances.model.entities; import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException; import org.gcube.informationsystem.types.reference.entities.FacetType; import com.orientechnologies.orient.core.record.OVertex; /** * @author Luca Frosini (ISTI - CNR) */ public class FacetManagement extends EntityManagement { public FacetManagement() { super(AccessType.FACET); } @Override protected FacetNotFoundException getSpecificElementNotFoundException(NotFoundException e) { return new FacetNotFoundException(e.getMessage(), e.getCause()); } @Override public FacetAvailableInAnotherContextException getSpecificERAvailableInAnotherContextException(String message) { return new FacetAvailableInAnotherContextException(message); } @Override protected FacetAlreadyPresentException getSpecificERAlreadyPresentException(String message) { return new FacetAlreadyPresentException(message); } @Override public JsonNode createCompleteJsonNode() throws ResourceRegistryException { return serializeSelfAsJsonNode(); } @Override protected OVertex reallyCreate() throws FacetAlreadyPresentException, ResourceRegistryException { return createVertex(); } @Override protected OVertex reallyUpdate() throws FacetNotFoundException, ResourceRegistryException { OVertex facet = getElement(); facet = (OVertex) updateProperties(oClass, facet, jsonNode, ignoreKeys, ignoreStartWithKeys); return facet; } @Override protected boolean reallyDelete() throws FacetNotFoundException, ResourceRegistryException { getElement().delete(); return true; } }