2016-12-27 11:27:01 +01:00
|
|
|
package org.gcube.informationsystem.resourceregistry.er.entity;
|
2016-12-19 14:59:27 +01:00
|
|
|
|
|
|
|
import org.codehaus.jettison.json.JSONObject;
|
2017-03-29 16:53:37 +02:00
|
|
|
import org.gcube.informationsystem.model.AccessType;
|
2016-12-19 14:59:27 +01:00
|
|
|
import org.gcube.informationsystem.model.entity.Facet;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
|
2017-11-17 11:42:37 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAvailableInAnotherContextException;
|
2016-12-19 14:59:27 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
|
2017-11-17 11:42:37 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
|
2017-11-30 18:06:08 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext;
|
2016-12-27 11:27:01 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.er.ERManagement;
|
2016-12-19 14:59:27 +01:00
|
|
|
|
|
|
|
import com.tinkerpop.blueprints.Vertex;
|
|
|
|
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
|
|
|
public class FacetManagement extends EntityManagement<Facet> {
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2016-12-19 14:59:27 +01:00
|
|
|
public FacetManagement() {
|
2017-03-29 16:53:37 +02:00
|
|
|
super(AccessType.FACET);
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|
|
|
|
|
2017-11-28 17:34:43 +01:00
|
|
|
public FacetManagement(SecurityContext workingContext, OrientGraph orientGraph) {
|
|
|
|
super(AccessType.FACET, workingContext, orientGraph);
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|
2017-11-17 11:42:37 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected FacetNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) {
|
|
|
|
return new FacetNotFoundException(e.getMessage(), e.getCause());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected FacetAvailableInAnotherContextException getSpecificERAvailableInAnotherContextException(String message) {
|
|
|
|
return new FacetAvailableInAnotherContextException(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected FacetAlreadyPresentException getSpecificERAlreadyPresentException(String message) {
|
|
|
|
return new FacetAlreadyPresentException(message);
|
|
|
|
}
|
|
|
|
|
2016-12-19 14:59:27 +01:00
|
|
|
@Override
|
|
|
|
public String serialize() throws ResourceRegistryException {
|
2017-01-17 16:53:24 +01:00
|
|
|
return serializeSelfOnly().toString();
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public JSONObject serializeAsJson() throws ResourceRegistryException {
|
2017-01-17 16:53:24 +01:00
|
|
|
return serializeSelfOnly();
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|
2017-01-13 12:21:35 +01:00
|
|
|
|
|
|
|
@Override
|
2017-10-26 17:09:07 +02:00
|
|
|
protected Vertex reallyCreate() throws FacetAlreadyPresentException, ResourceRegistryException {
|
2016-12-19 14:59:27 +01:00
|
|
|
return createVertex();
|
|
|
|
}
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2016-12-19 14:59:27 +01:00
|
|
|
@Override
|
2017-10-26 17:09:07 +02:00
|
|
|
protected Vertex reallyUpdate() throws FacetNotFoundException, ResourceRegistryException {
|
2016-12-30 17:31:12 +01:00
|
|
|
Vertex facet = getElement();
|
2017-03-27 15:04:44 +02:00
|
|
|
facet = (Vertex) ERManagement.updateProperties(oClass, facet, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
2016-12-19 14:59:27 +01:00
|
|
|
return facet;
|
|
|
|
}
|
|
|
|
|
2017-01-13 12:21:35 +01:00
|
|
|
@Override
|
2017-10-26 17:09:07 +02:00
|
|
|
protected boolean reallyDelete() throws FacetNotFoundException, ResourceRegistryException {
|
2016-12-30 17:31:12 +01:00
|
|
|
getElement().remove();
|
2016-12-19 14:59:27 +01:00
|
|
|
return true;
|
|
|
|
}
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|