2019-11-04 18:01:20 +01:00
|
|
|
package org.gcube.informationsystem.resourceregistry.instances.model.relation;
|
2016-12-19 14:59:27 +01:00
|
|
|
|
2019-10-25 17:45:59 +02:00
|
|
|
import org.gcube.informationsystem.base.reference.AccessType;
|
2019-02-13 12:33:29 +01:00
|
|
|
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
2019-11-04 18:01:20 +01:00
|
|
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
|
|
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
2019-02-13 12:33:29 +01:00
|
|
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
|
|
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
|
|
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
|
|
|
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
2018-06-04 15:31:13 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
2017-11-17 12:31:22 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
2017-11-17 11:42:37 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAlreadyPresentException;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAvailableInAnotherContextException;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfNotFoundException;
|
2019-11-04 18:01:20 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.security.SecurityContext;
|
2016-12-19 14:59:27 +01:00
|
|
|
|
|
|
|
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
2019-11-04 18:01:20 +01:00
|
|
|
public class ConsistsOfManagement extends RelationManagement<ConsistsOf<Resource, Facet>, FacetManagement, Facet> {
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2018-06-11 11:01:10 +02:00
|
|
|
public static final PropagationConstraint DEFAULT_CONSISTS_OF_PC;
|
|
|
|
|
|
|
|
static {
|
|
|
|
DEFAULT_CONSISTS_OF_PC = new PropagationConstraintImpl();
|
|
|
|
DEFAULT_CONSISTS_OF_PC.setRemoveConstraint(RemoveConstraint.cascadeWhenOrphan);
|
|
|
|
DEFAULT_CONSISTS_OF_PC.setAddConstraint(AddConstraint.propagate);
|
|
|
|
}
|
|
|
|
|
2016-12-19 14:59:27 +01:00
|
|
|
public ConsistsOfManagement() {
|
2019-11-04 18:01:20 +01:00
|
|
|
super(AccessType.CONSISTS_OF, Facet.class, DEFAULT_CONSISTS_OF_PC);
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2017-11-28 17:34:43 +01:00
|
|
|
public ConsistsOfManagement(SecurityContext workingContext, OrientGraph orientGraph) {
|
2019-11-04 18:01:20 +01:00
|
|
|
super(AccessType.CONSISTS_OF, Facet.class, workingContext, orientGraph, DEFAULT_CONSISTS_OF_PC);
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2017-11-17 11:42:37 +01:00
|
|
|
@Override
|
2018-06-04 15:31:13 +02:00
|
|
|
protected ConsistsOfNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
|
2017-11-17 11:42:37 +01:00
|
|
|
return new ConsistsOfNotFoundException(e.getMessage(), e.getCause());
|
|
|
|
}
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2017-11-17 11:42:37 +01:00
|
|
|
@Override
|
|
|
|
protected ConsistsOfAvailableInAnotherContextException getSpecificERAvailableInAnotherContextException(
|
|
|
|
String message) {
|
|
|
|
return new ConsistsOfAvailableInAnotherContextException(message);
|
|
|
|
}
|
2016-12-19 14:59:27 +01:00
|
|
|
|
2017-11-17 11:42:37 +01:00
|
|
|
@Override
|
|
|
|
protected ConsistsOfAlreadyPresentException getSpecificERAlreadyPresentException(String message) {
|
|
|
|
return new ConsistsOfAlreadyPresentException(message);
|
|
|
|
}
|
2017-11-17 12:31:22 +01:00
|
|
|
|
|
|
|
@Override
|
2017-11-17 15:59:25 +01:00
|
|
|
protected FacetManagement newTargetEntityManagement() throws ResourceRegistryException {
|
2017-11-28 17:34:43 +01:00
|
|
|
return new FacetManagement(getWorkingContext(), orientGraph);
|
2017-11-17 12:31:22 +01:00
|
|
|
}
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|