refs #6086: Resoure Registry MUST automatically add to Relation default Referential Integrity directive when the client does not specify anything

https://support.d4science.org/issues/6086

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-orientdb-hooks@135137 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-11-30 16:19:11 +00:00
parent 05a4df55ff
commit 0e2daf1f07
1 changed files with 16 additions and 3 deletions

View File

@ -48,9 +48,8 @@ public abstract class RelationHook extends ODocumentHookAbstract implements
public DISTRIBUTED_EXECUTION_MODE getDistributedExecutionMode() {
return DISTRIBUTED_EXECUTION_MODE.BOTH;
}
@Override
public RESULT onRecordBeforeCreate(final ODocument iDocument) {
protected RESULT checkRelationProperty(final ODocument iDocument) {
OLogManager.instance().info(this, "Checking %s on %s",
RelationProperty.NAME, iDocument.toJSON());
@ -67,6 +66,8 @@ public abstract class RelationHook extends ODocumentHookAbstract implements
oDocument.field(RelationProperty.REFERENTIAL_INTEGRITY,
referentiaIntegrity.toString());
iDocument.field(Relation.RELATION_PROPERTY, oDocument);
OLogManager.instance().debug(this, "%s has now an %s",
iDocument.toJSON(), RelationProperty.NAME);
result = RESULT.RECORD_CHANGED;
@ -110,7 +111,19 @@ public abstract class RelationHook extends ODocumentHookAbstract implements
return result;
}
@Override
public RESULT onRecordBeforeCreate(final ODocument iDocument) {
return checkRelationProperty(iDocument);
}
@Override
public RESULT onRecordBeforeUpdate(final ODocument iDocument) {
return checkRelationProperty(iDocument);
}
@Override
public PRIORITY getPriority() {
return PRIORITY.REGULAR;