Refs #10238: Refactor Context Port Type
Task-Url: https://support.d4science.org/issues/10238 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158634 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
782e60ff13
commit
05ae780494
|
@ -62,6 +62,11 @@ public abstract class EntityManagement<E extends Entity> extends
|
|||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
/*
|
||||
* It works perfectly in case of any kind of update.
|
||||
* In case of use from create the cache does not work by using the ID because until commit the edge has a fake id
|
||||
* starting with - (minus) sign. This not imply any collateral effect but a better solution is a desiderata.
|
||||
*/
|
||||
protected RelationManagement getRelationManagement(Edge edge) throws ResourceRegistryException {
|
||||
String id = edge.getId().toString();
|
||||
RelationManagement relationManagement = relationManagements.get(id);
|
||||
|
@ -75,7 +80,7 @@ public abstract class EntityManagement<E extends Entity> extends
|
|||
protected void addToRelationManagement(@SuppressWarnings("rawtypes") RelationManagement relationManagement) throws ResourceRegistryException {
|
||||
Element elem = relationManagement.getElement();
|
||||
String id = elem.getId().toString();
|
||||
if(relationManagements.get(id)!=relationManagement) {
|
||||
if(relationManagements.get(id)!=null && relationManagements.get(id)!=relationManagement) {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
errorMessage.append("Two different instance of ");
|
||||
errorMessage.append(relationManagement.getClass().getSimpleName());
|
||||
|
|
|
@ -87,9 +87,11 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
|||
|
||||
@SuppressWarnings("rawtypes")
|
||||
RelationManagement relationManagement = getRelationManagement(edge);
|
||||
if(relationManagement.getSourceEntityManagement()==null) {
|
||||
if(relationManagement.giveMeSourceEntityManagementAsIs()==null) {
|
||||
relationManagement.setSourceEntityManagement(this);
|
||||
}else if(relationManagement.getSourceEntityManagement()!=null) {
|
||||
}
|
||||
|
||||
if(relationManagement.giveMeSourceEntityManagementAsIs()!=this) {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
errorMessage.append("SourceEntityManagement for ");
|
||||
errorMessage.append(relationManagement.getClass().getSimpleName());
|
||||
|
|
|
@ -52,8 +52,8 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
|||
|
||||
protected final Class<? extends Entity> targetEntityClass;
|
||||
|
||||
private S sourceEntityManagement;
|
||||
private T targetEntityManagement;
|
||||
protected S sourceEntityManagement;
|
||||
protected T targetEntityManagement;
|
||||
|
||||
protected RelationManagement(AccessType accessType) {
|
||||
super(accessType);
|
||||
|
@ -90,6 +90,14 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
|||
this.orientGraph = orientGraph;
|
||||
}
|
||||
|
||||
/*
|
||||
* Needed for ResourceManagement.serializeAsJson() function to check that sourceEntityManagement is the same of
|
||||
* the instance is creating this RelationManagement. TODO Look for a workaround
|
||||
*/
|
||||
public S giveMeSourceEntityManagementAsIs() throws ResourceRegistryException {
|
||||
return sourceEntityManagement;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public S getSourceEntityManagement() throws ResourceRegistryException {
|
||||
if (sourceEntityManagement == null) {
|
||||
|
|
Loading…
Reference in New Issue