2019-11-06 12:14:27 +01:00
|
|
|
package org.gcube.informationsystem.resourceregistry.instances.model.relations;
|
2016-12-19 14:59:27 +01:00
|
|
|
|
2021-02-05 17:50:16 +01:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
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;
|
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;
|
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-06 12:13:19 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
2016-12-19 14:59:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
2019-11-08 12:29:32 +01:00
|
|
|
public class ConsistsOfManagement extends RelationManagement<FacetManagement> {
|
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-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
|
2021-02-05 17:50:16 +01:00
|
|
|
public ConsistsOfAvailableInAnotherContextException getSpecificERAvailableInAnotherContextException(
|
2017-11-17 11:42:37 +01:00
|
|
|
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 {
|
2021-02-10 15:45:48 +01:00
|
|
|
FacetManagement facetManagement = new FacetManagement();
|
|
|
|
facetManagement.setoDatabaseDocument(oDatabaseDocument);
|
|
|
|
facetManagement.setWorkingContext(getWorkingContext());
|
|
|
|
return facetManagement;
|
2017-11-17 12:31:22 +01:00
|
|
|
}
|
2021-02-05 17:50:16 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws ResourceRegistryException {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
2017-11-30 18:06:08 +01:00
|
|
|
|
2016-12-19 14:59:27 +01:00
|
|
|
}
|