]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5036: Since we can't seem to get paging on CMIS queries working, we need to...
authorRichard Millet <remillet@berkeley.edu>
Wed, 13 Jun 2012 20:52:32 +0000 (13:52 -0700)
committerRichard Millet <remillet@berkeley.edu>
Wed, 13 Jun 2012 20:52:32 +0000 (13:52 -0700)
services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java

index b9e546010841e3d87ea303cdc1a18315f9cfed84..ba17076571d8cbd08c75f7ae332573d84dab689a 100644 (file)
@@ -128,22 +128,89 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
      * @return the multipart output
      */
     protected PoxPayloadOut createDimensionInstance(String commonPartName, String identifier) {
-        final String DIMENSION_VALUE = "78.306";
+        final String dimensionValue = Long.toString(System.currentTimeMillis());
        
         return createDimensionInstance(commonPartName, 
                 "dimensionType-" + identifier,
-                DIMENSION_VALUE,
+                dimensionValue,
                 "entryDate-" + identifier);
     }
     
        @Test void deleteCollectionObjectRelationshipToLockedDimension() {
+               // First create a CollectionObject
+               CollectionobjectsCommon co = new CollectionobjectsCommon();
+               fillCollectionObject(co, createIdentifier());           
+               PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
+               PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
+               
+               // Make the "create" call and check the response
+               ClientResponse<Response> response = collectionObjectClient.create(multipart);
+               String collectionObjectCsid = null;
+               try {
+                       Assert.assertEquals(response.getStatus(), Response.Status.CREATED
+                                       .getStatusCode());
+                       collectionObjectCsid = extractId(response);
+               } finally {
+                       response.releaseConnection();
+               }
+               
+               // Create a new dimension record
+           multipart = this.createDimensionInstance(createIdentifier());
+           // Make the call to create and check the response
+           response = dimensionClient.create(multipart);
+           String dimensionCsid1 = null;
+           try {
+                   Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+                   dimensionCsid1 = extractId(response);
+           } finally {
+               response.releaseConnection();
+           }
+           
+           // Relate the entities, by creating a new relation object
+           RelationsCommon relation = new RelationsCommon();
+           fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
+                       dimensionCsid1, DimensionsCommon.class.getSimpleName(),
+                       "collectionobject-dimension");
+           // Create the part and fill it with the relation object
+           multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
+           commonPart = multipart.addPart(relationClient.getCommonPartName(), relation);
+           // Create the relationship
+           response = relationClient.create(multipart);
+           String relationCsid1 = null;
+           try {
+                   Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+                   relationCsid1 = extractId(response);
+           } finally {
+               response.releaseConnection();
+           }       
+           
+           // Now lock the dimension record.
+           
+               @SuppressWarnings("unused")
+               ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
+           System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
+           
+           // Finally, try to delete the relationship
+           
+           // Try to delete the relationship -should fail because we don't allow delete if one of the sides is locked.
+           response = relationClient.delete(relationCsid1);
+           try {
+                   Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
+           } finally {
+               response.releaseConnection();
+           }
+           
+           // Also, try to soft-delete.  This should also fail.
+               workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE);
+           System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
+       }
+       
+       @Test void createCollectionObjectRelationshipToManyDimensions() {
                //
                // First create a CollectionObject
                //
                CollectionobjectsCommon co = new CollectionobjectsCommon();
-               fillCollectionObject(co, createIdentifier());
-               
-               // Next, create a part object
+               fillCollectionObject(co, createIdentifier());           
                PoxPayloadOut multipart = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
                PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
                
@@ -158,7 +225,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                        response.releaseConnection();
                }
                
-               //Next, create two Dimension records to relate the collection object to
+               //Next, create the first of three Dimension records to relate the collection object record
            multipart = this.createDimensionInstance(createIdentifier());
            // Make the call to create and check the response
            response = dimensionClient.create(multipart);
@@ -169,6 +236,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            } finally {
                response.releaseConnection();
            }
+           
                //Next, create a the second Dimension record
            multipart = this.createDimensionInstance(createIdentifier());
            // Make the call to create and check the response
@@ -180,6 +248,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            } finally {
                response.releaseConnection();
            }
+           
                //Next, create a the 3rd Dimension record
            multipart = this.createDimensionInstance(createIdentifier());
            // Make the call to create and check the response
@@ -194,8 +263,9 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            
            // Relate the entities, by creating a new relation object
            RelationsCommon relation = new RelationsCommon();
-           fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
-                       dimensionCsid1, DimensionsCommon.class.getSimpleName(),
+           fillRelation(relation,
+                       collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
+                       dimensionCsid1, DimensionsCommon.class.getSimpleName(), // the object of the relationship
                        "collectionobject-dimension");
            // Create the part and fill it with the relation object
            multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
@@ -209,10 +279,17 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            } finally {
                response.releaseConnection();
            }
-           // Create the second relationship
+           // Wait 1 second and create the second relationship
+           try {
+                       Thread.sleep(1001);
+               } catch (InterruptedException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
            relation = new RelationsCommon();
-           fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
-                       dimensionCsid2, DimensionsCommon.class.getSimpleName(),
+           fillRelation(relation,
+                       collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
+                       dimensionCsid2, DimensionsCommon.class.getSimpleName(), // the object of the relationship
                        "collectionobject-dimension");
            // Create the part and fill it with the relation object
            multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
@@ -227,11 +304,17 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            } finally {
                response.releaseConnection();
            }
-           // Create the 3rd relationship - but invert it this time
+           // Wait 1 second and create the 3rd relationship
+           try {
+                       Thread.sleep(1001);
+               } catch (InterruptedException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
            relation = new RelationsCommon();
            fillRelation(relation,
-                       dimensionCsid3, DimensionsCommon.class.getSimpleName(),
-                       collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
+                       collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(), // the subject of the relationship
+                       dimensionCsid3, DimensionsCommon.class.getSimpleName(), // the object of the relationship
                        "collectionobject-dimension");
            // Create the part and fill it with the relation object
            multipart = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
@@ -245,30 +328,8 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    relationCsid3 = extractId(response);
            } finally {
                response.releaseConnection();
-           }
-           
-           
-           // Now lock the dimension record.
-           
-               @SuppressWarnings("unused")
-               ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
-           System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
-           
-           // Finally, try to delete the relationship
-           
-           // Try to delete the relationship -should fail because we don't allow delete if one of the sides is locked.
-           response = relationClient.delete(relationCsid1);
-           try {
-                   Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
-           } finally {
-               response.releaseConnection();
-           }
-           
-           // Also, try to soft-delete.  This should also fail.
-               workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_DELETE);
-           System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
-       }
-    
+           }               
+       }    
        
        @Test void releteCollectionObjectToLockedDimension() {
                //
index 34ad399693274e735d6073d3a7474ef588591f7e..7bf98618544fe7d535643b722001e852a43cbd58 100644 (file)
@@ -837,6 +837,20 @@ public class RepositoryJavaClientImpl implements RepositoryClient<PoxPayloadIn,
             throw new DocumentException(e);
         }
         
+        //
+        // Since we're not supporting paging yet for CMIS queries, we need to perform
+        // a workaround for the paging information we return in our list of results
+        //
+        if (result != null) {
+               int totalSize = result.size();
+               DocumentFilter docFilter = handler.getDocumentFilter();
+               docFilter.setStartPage(0);
+               if (totalSize > docFilter.getPageSize()) {
+                       docFilter.setPageSize(totalSize);
+               ((DocumentModelListImpl)result).setTotalSize(totalSize);
+               }
+        }
+        
         return result;
     }