diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index 38d7aa9..9156237 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -396,6 +396,10 @@ public abstract class ElementManagement { } } + public JsonNode serializeAsAffectedInstance() throws ResourceRegistryException { + return serializeSelfAsJsonNode(); + } + public JsonNode serializeSelfAsJsonNode() throws ResourceRegistryException { try { if(self==null || reload) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java index aad6db1..83a1d0b 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java @@ -213,7 +213,7 @@ public abstract class RelationElementManagement reallyAddToContext(); HeaderUtility.updateModifiedByAndLastUpdate(element); element.save(); - affectedInstances.put(uuid, serializeSelfAsJsonNode()); + affectedInstances.put(uuid, serializeAsAffectedInstance()); sanityCheck(); } catch(ResourceRegistryException e) { throw e; @@ -392,7 +392,7 @@ public abstract class EntityManagement reallyRemoveFromContext(); HeaderUtility.updateModifiedByAndLastUpdate(element); element.save(); - affectedInstances.put(uuid, serializeSelfAsJsonNode()); + affectedInstances.put(uuid, serializeAsAffectedInstance()); sanityCheck(); } catch(ResourceRegistryException e) { throw e; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java index 58e0649..591e96e 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java @@ -74,7 +74,7 @@ public class FacetManagement extends EntityManagement { consistsOfManagement = new ConsistsOfManagement(); consistsOfManagement.setElement(oEdge); consistsOfManagement.setTargetEntityManagement(this); - affectedInstances.put(uuid, consistsOfManagement.serializeSelfAsJsonNode()); + affectedInstances.put(uuid, consistsOfManagement.serializeAsAffectedInstance()); OVertex oVertex = getElement().getVertices(ODirection.IN).iterator().next(); resourceManagement = new ResourceManagement(); @@ -91,7 +91,7 @@ public class FacetManagement extends EntityManagement { consistsOfManagement = new ConsistsOfManagement(); consistsOfManagement.setElement(oEdge); consistsOfManagement.setTargetEntityManagement(this); - affectedInstances.put(uuid, consistsOfManagement.serializeSelfAsJsonNode()); + affectedInstances.put(uuid, consistsOfManagement.serializeAsAffectedInstance()); OVertex oVertex = getElement().getVertices(ODirection.IN).iterator().next(); resourceManagement = new ResourceManagement(); @@ -99,7 +99,7 @@ public class FacetManagement extends EntityManagement { resourceManagement.addToRelationManagements(consistsOfManagement); } - affectedInstances.put(uuid, serializeSelfAsJsonNode()); + affectedInstances.put(uuid, serializeAsAffectedInstance()); getElement().delete(); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java index 608b739..75ab093 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java @@ -251,7 +251,7 @@ public class ResourceManagement extends EntityManagement } - affectedInstances.put(uuid, serializeSelfAsJsonNode()); + affectedInstances.put(uuid, serializeAsAffectedInstance()); element.delete(); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java index 71b19c6..324206f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java @@ -382,7 +382,7 @@ public abstract class RelationManagement reallyAddToContext() + protected void reallyAddToContext() throws ContextException, ResourceRegistryException { getElement(); @@ -447,8 +447,6 @@ public abstract class RelationManagement forcedAddToContext() + public void forcedAddToContext() throws ContextException, ResourceRegistryException { setOperation(Operation.ADD_TO_CONTEXT); @@ -490,9 +488,7 @@ public abstract class RelationManagement affectedInstances = resourceManagement.getAffectedInstances(); logger.debug("Remove from Context affects the following instances {}", affectedInstances.values()); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java index 43e8ab7..65a5b6d 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/RuleTest.java @@ -73,21 +73,21 @@ public class RuleTest extends ContextTest { @SuppressWarnings("unused") UUID softwareFacetUUID = checkFacetCreation(eService); - SoftwareFacet softwareFacet = (SoftwareFacet) eService.getIdentificationFacets().get(0); - String softwareFacetString = ElementMapper.marshal(softwareFacet); - - // Trying to recreate SoftwareFacet - FacetManagement softwareFacetManagement = new FacetManagement(); - softwareFacetManagement.setElementType(SoftwareFacet.NAME); - softwareFacetManagement.setJson(softwareFacetString); - try{ - softwareFacetManagement.create(); - }catch (FacetAlreadyPresentException e) { - // OK - logger.debug("As expected {} cannot be recreated", softwareFacetString, e); - }catch (Exception e) { - throw e; - } +// SoftwareFacet softwareFacet = (SoftwareFacet) eService.getIdentificationFacets().get(0); +// String softwareFacetString = ElementMapper.marshal(softwareFacet); +// +// // Trying to recreate SoftwareFacet +// FacetManagement softwareFacetManagement = new FacetManagement(); +// softwareFacetManagement.setElementType(SoftwareFacet.NAME); +// softwareFacetManagement.setJson(softwareFacetString); +// try{ +// softwareFacetManagement.create(); +// }catch (FacetAlreadyPresentException e) { +// // OK +// logger.debug("As expected {} cannot be recreated", softwareFacetString, e); +// }catch (Exception e) { +// throw e; +// } // Trying to recreate EService