]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-473: Changing constraint to the 'relationshiptype' field instead of the deprecat...
authorRichard Millet <remillet@yahoo.com>
Fri, 31 Aug 2018 21:16:14 +0000 (14:16 -0700)
committerRichard Millet <remillet@yahoo.com>
Fri, 31 Aug 2018 21:16:14 +0000 (14:16 -0700)
3rdparty/nuxeo/nuxeo-server/7.10-HF17/config/vcsconfig.sql.txt
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationValidatorHandler.java

index bbc090f90a78f0dc9fddfeaa033fa14db855c263..4144c65dba41d60899c8153887ee0e027b827095 100644 (file)
@@ -37,4 +37,4 @@ LOG.INFO Adding constraint to the relations table to prevent duplicate relations
 SELECT constraint_name FROM information_schema.constraint_column_usage WHERE table_name = 'relations_common' AND constraint_name = 'relations_unique';
 
 #IF: emptyResult
-ALTER TABLE relations_common add CONSTRAINT relations_unique UNIQUE (subjectcsid, subjectrefname, predicate, objectcsid, objectrefname);
+ALTER TABLE relations_common add CONSTRAINT relations_unique UNIQUE (subjectcsid, subjectrefname, relationshiptype, objectcsid, objectrefname);
index d00793877fb1002bb2729fca503acfe9ba9da418..9ae8ea22718d770680412c3865727b112f7c6b41 100644 (file)
@@ -29,39 +29,39 @@ public class RelationValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn,
     }
     
     @Override
-    protected void handleCreate()
-               throws InvalidDocumentException{
-       try {
-               RelationsCommon relationsCommon = (RelationsCommon)getCommonPart();
-               CS_ASSERT(relationsCommon != null);
-               if (logger.isTraceEnabled() == true) {
-                       logger.trace(relationsCommon.toString());
-               }
-               
+    protected void handleCreate() throws InvalidDocumentException {
+        try {
+            RelationsCommon relationsCommon = (RelationsCommon) getCommonPart();
+            CS_ASSERT(relationsCommon != null);
+            if (logger.isTraceEnabled() == true) {
+                logger.trace(relationsCommon.toString());
+            }
+
             String subjectCsid = relationsCommon.getSubjectCsid();
             String objectCsid = relationsCommon.getObjectCsid();
-               
+
             // If no CSID for a subject or object is included in the create payload,
-            // a refName must be provided for that subject or object as an alternate identifier.
+            // a refName must be provided for that subject or object as an alternate
+            // identifier.
             CS_ASSERT(hasCsid(subjectCsid) || hasSubjectRefname(relationsCommon));
             CS_ASSERT(hasCsid(objectCsid) || hasObjectRefname(relationsCommon));
-               
+
             // The Subject identifier and Object ID must not be identical:
             // that is, a resource cannot be related to itself.
             if (hasCsid(subjectCsid) && hasCsid(objectCsid)) {
-               CS_ASSERT (subjectCsid.trim().equalsIgnoreCase(objectCsid.trim()) == false,
-                        SUBJECT_EQUALS_OBJECT_ERROR);
+                CS_ASSERT(subjectCsid.trim().equalsIgnoreCase(objectCsid.trim()) == false, SUBJECT_EQUALS_OBJECT_ERROR);
             }
 
-            // A relationship type must be provided.
+            // A relationship type must be provided.  Set the redundant "predicate" field to be the same
             CS_ASSERT(relationsCommon.getRelationshipType() != null);
+            relationsCommon.setPredicate(relationsCommon.getRelationshipType());
 
-       } catch (AssertionError e) {
-               if (logger.isErrorEnabled() == true) {
-                       logger.error(e.getMessage(), e);
-               }
-               throw new InvalidDocumentException(VALIDATION_ERROR, e);
-       }
+        } catch (AssertionError e) {
+            if (logger.isErrorEnabled() == true) {
+                logger.error(e.getMessage(), e);
+            }
+            throw new InvalidDocumentException(VALIDATION_ERROR, e);
+        }
     }
 
        @Override