* Fill relation.\r
* \r
* @param relation the relation\r
- * @param documentId1 the document id1\r
- * @param documentType1 the document type1\r
- * @param documentId2 the document id2\r
- * @param documentType2 the document type2\r
+ * @param subjectCsid the document id1\r
+ * @param subjectDocumentType the document type1\r
+ * @param objectCsid the document id2\r
+ * @param objectDocumentType the document type2\r
* @param rt the rt\r
*/\r
- void fillRelation(RelationsCommon relation, String documentId1, String documentType1,\r
- String documentId2, String documentType2, String rt)\r
+ void fillRelation(RelationsCommon relation, \r
+ String subjectCsid, String subjectDocumentType,\r
+ String objectCsid, String objectDocumentType,\r
+ String rt)\r
{\r
- relation.setDocumentId1(documentId1);\r
- relation.setDocumentType1(documentType1);\r
- relation.setDocumentId2(documentId2);\r
- relation.setDocumentType2(documentType2);\r
+ relation.setSubjectCsid(subjectCsid);\r
+ relation.setSubjectDocumentType(subjectDocumentType);\r
+ relation.setObjectCsid(objectCsid);\r
+ relation.setObjectDocumentType(objectDocumentType);\r
\r
relation.setRelationshipType(rt);\r
}\r
multiPartResponse.releaseConnection();
}
- Assert.assertEquals(resultRelation.getDocumentId1(), collectionObjectCsid);
+ Assert.assertEquals(resultRelation.getSubjectCsid(), collectionObjectCsid);
Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
- Assert.assertEquals(resultRelation.getDocumentId2(), intakeCsid);
+ Assert.assertEquals(resultRelation.getObjectCsid(), intakeCsid);
System.out.println();
i++;
}
multiPartResponse.releaseConnection();
}
- Assert.assertEquals(resultRelation.getDocumentId1(), intakeCsid);
+ Assert.assertEquals(resultRelation.getSubjectCsid(), intakeCsid);
Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE.toString());
- Assert.assertEquals(resultRelation.getDocumentId2(), collectionObjectCsid);
+ Assert.assertEquals(resultRelation.getObjectCsid(), collectionObjectCsid);
System.out.println();
i++;
}
<uri>/cspace-services/relations/</uri>\r
<filename>relation/r-1.xml</filename>\r
<vars>\r
- <var ID="documentId1">${Person1.CSID}</var>\r
- <var ID="documentId2">${Person2.CSID}</var>\r
- <var ID="documentType1">Persons</var>\r
- <var ID="documentType2">Persons</var>\r
+ <var ID="subjectCsid">${Person1.CSID}</var>\r
+ <var ID="objectCsid">${Person2.CSID}</var>\r
+ <var ID="subjectDocumentType">Persons</var>\r
+ <var ID="objectDocumentType">Persons</var>\r
<var ID="relationshipType">hasBroader</var>\r
</vars>\r
</test>\r
<!-- Person2 and Person1 are switched in this record. \r
Ultimately we don't want any hasNarrower actually stored.\r
-->\r
- <var ID="documentId1">${Person2.CSID}</var>\r
- <var ID="documentId2">${Person1.CSID}</var>\r
- <var ID="documentType1">Persons</var>\r
- <var ID="documentType2">Persons</var>\r
+ <var ID="subjectCsid">${Person2.CSID}</var>\r
+ <var ID="objectCsid">${Person1.CSID}</var>\r
+ <var ID="subjectDocumentType">Persons</var>\r
+ <var ID="objectDocumentType">Persons</var>\r
<var ID="relationshipType">hasNarrower</var>\r
</vars>\r
</test>\r
<fieldsReturned>subjectCsid|relationshipType|predicateDisplayName|objectCsid|uri|csid|subject|object</fieldsReturned>\r
<relation-list-item>\r
<subjectCsid>${myCSID}</subjectCsid>\r
- <documentType1>Person</documentType1>\r
- <documentType2>Person</documentType2>\r
+ <subjectDocumentType>Person</subjectDocumentType>\r
+ <objectDocumentType>Person</objectDocumentType>\r
<relationshipType>hasBroader</relationshipType>\r
<predicate>hasBroader</predicate>\r
<predicateDisplayName>hasBroader</predicateDisplayName>\r
</relation-list-item>\r
<relation-list-item>\r
<subjectCsid>${childCSID}</subjectCsid>\r
- <documentType1>Person</documentType1>\r
- <documentType2>Person</documentType2>\r
+ <subjectDocumentType>Person</subjectDocumentType>\r
+ <objectDocumentType>Person</objectDocumentType>\r
<relationshipType>hasBroader</relationshipType>\r
<predicate>hasBroader</predicate>\r
<predicateDisplayName>hasBroader</predicateDisplayName>\r
<fieldsReturned>subjectCsid|relationshipType|predicateDisplayName|objectCsid|uri|csid|subject|object</fieldsReturned>\r
<relation-list-item>\r
<subjectCsid>${myCSID}</subjectCsid>\r
- <documentType1>Person</documentType1>\r
- <documentType2>Person</documentType2>\r
+ <subjectDocumentType>Person</subjectDocumentType>\r
+ <objectDocumentType>Person</objectDocumentType>\r
<relationshipType>hasBroader</relationshipType>\r
<predicate>hasBroader</predicate>\r
<predicateDisplayName>hasBroader</predicateDisplayName>\r
<fieldsReturned>subjectCsid|relationshipType|predicateDisplayName|objectCsid|uri|csid|subject|object</fieldsReturned>\r
<relation-list-item>\r
<subjectCsid>${childCSID}</subjectCsid>\r
- <documentType1>Person</documentType1>\r
- <documentType2>Person</documentType2>\r
+ <subjectDocumentType>Person</subjectDocumentType>\r
+ <objectDocumentType>Person</objectDocumentType>\r
<relationshipType>hasBroader</relationshipType>\r
<predicate>hasBroader</predicate>\r
<predicateDisplayName>hasBroader</predicateDisplayName>\r
</relation-list-item>\r
<relation-list-item>\r
<subjectCsid>${child2CSID}</subjectCsid>\r
- <documentType1>Person</documentType1>\r
- <documentType2>Person</documentType2>\r
+ <subjectDocumentType>Person</subjectDocumentType>\r
+ <objectDocumentType>Person</objectDocumentType>\r
<relationshipType>hasBroader</relationshipType>\r
<predicate>hasBroader</predicate>\r
<predicateDisplayName>hasBroader</predicateDisplayName>\r
<ns2:relations_common
xmlns:ns2="http://collectionspace.org/services/relation"
xmlns:ns3="http://collectionspace.org/services/jaxb">
- <documentId1>${documentId1}</documentId1>
- <documentType1>${documentType1}</documentType1>
- <documentId2>${documentId2}</documentId2>
- <documentType2>${documentType1}</documentType2>
+ <subjectCsid>${subjectCsid}</subjectCsid>
+ <subjectDocumentType>${subjectDocumentType}</subjectDocumentType>
+ <objectCsid>${objectCsid}</objectCsid>
+ <objectDocumentType>${objectDocumentType}</objectDocumentType>
<relationshipType>${relationshipType}</relationshipType>
<predicateDisplayName>${relationshipType}</predicateDisplayName>
</ns2:relations_common>
<?xml version="1.0" encoding="UTF-8"?>
<document name="relations">
<ns2:relations_common xmlns:ns2="http://collectionspace.org/services/relation" xmlns:ns3="http://collectionspace.org/services/jaxb">
- <documentId1>${documentId1}</documentId1>
- <documentType1>${documentType1}</documentType1>
- <documentId2>${documentId2}</documentId2>
- <documentType2>${documentType2}</documentType2>
+ <subjectCsid>${subjectCsid}</subjectCsid>
+ <subjectDocumentType>${subjectDocumentType}</subjectDocumentType>
+ <subjectUri>/my/long/uri/${subjectCsid}</subjectUri>
+ <objectCsid>${objectCsid}</objectCsid>
+ <objectDocumentType>${objectDocumentType}</objectDocumentType>
+ <objectUri>/my/long/uri/${objectCsid}</objectUri>
<relationshipType>${relationshipType}</relationshipType>
<predicateDisplayName>${relationshipType}</predicateDisplayName>
- <subjectCsid>${documentId1}</subjectCsid>
- <objectCsid>${documentId2}</objectCsid>
- <subjectUri>/my/long/uri/${documentId1}</subjectUri>
- <objectUri>/my/long/uri/${documentId2}</objectUri>
</ns2:relations_common>
</document>
<uri>/cspace-services/relations/</uri>\r
<filename>relation/r-1.xml</filename>\r
<vars>\r
- <var ID="documentId1">${oe1.CSID}</var>\r
- <var ID="documentId2">${oe2.CSID}</var>\r
- <var ID="documentType1">objectexit</var>\r
- <var ID="documentType2">objectexit</var>\r
+ <var ID="subjectCsid">${oe1.CSID}</var>\r
+ <var ID="objectCsid">${oe2.CSID}</var>\r
+ <var ID="subjectDocumentType">objectexit</var>\r
+ <var ID="objectDocumentType">objectexit</var>\r
<var ID="relationshipType">hasBroader</var>\r
</vars>\r
</test>\r
<filename>relation/r-1.xml</filename>\r
<vars>\r
<!-- switched oe2 and oe1 on this -->\r
- <var ID="documentId1">${oe2.CSID}</var>\r
- <var ID="documentId2">${oe1.CSID}</var>\r
- <var ID="documentType1">objectexit</var>\r
- <var ID="documentType2">objectexit</var>\r
+ <var ID="subjectCsid">${oe2.CSID}</var>\r
+ <var ID="objectCsid">${oe1.CSID}</var>\r
+ <var ID="subjectDocumentType">objectexit</var>\r
+ <var ID="objectDocumentType">objectexit</var>\r
<var ID="relationshipType">hasBroader</var>\r
</vars>\r
</test>\r
<uri>/cspace-services/relations/</uri>\r
<filename>relation/r-2.xml</filename>\r
<vars>\r
- <var ID="documentId1">${oe1.CSID}</var>\r
- <var ID="documentId2">${itemCSID}</var>\r
- <var ID="documentType1">ObjectExit</var>\r
- <var ID="documentType2">ObjectExit</var>\r
+ <var ID="subjectCsid">${oe1.CSID}</var>\r
+ <var ID="objectCsid">${itemCSID}</var>\r
+ <var ID="subjectDocumentType">ObjectExit</var>\r
+ <var ID="objectDocumentType">ObjectExit</var>\r
<var ID="relationshipType">hasBroader</var>\r
</vars>\r
</test>\r
<uri>/cspace-services/relations/</uri>\r
<filename>relation/r-2.xml</filename>\r
<vars>\r
- <var ID="documentId1">1234-5678</var>\r
- <var ID="documentId2">${itemCSID}</var>\r
- <var ID="documentType1">ObjectExit</var>\r
- <var ID="documentType2">ObjectExit</var>\r
+ <var ID="subjectCsid">1234-5678</var>\r
+ <var ID="objectCsid">${itemCSID}</var>\r
+ <var ID="subjectDocumentType">ObjectExit</var>\r
+ <var ID="objectDocumentType">ObjectExit</var>\r
<var ID="relationshipType">hasBroader</var>\r
</vars>\r
</test>\r
* Fill relation.\r
* \r
* @param relation the relation\r
- * @param documentId1 the document id1\r
- * @param documentType1 the document type1\r
- * @param documentId2 the document id2\r
- * @param documentType2 the document type2\r
+ * @param subjectCsid the document id1\r
+ * @param subjectDocumentType the document type1\r
+ * @param objectCsid the document id2\r
+ * @param objectDocumentType the document type2\r
* @param rt the rt\r
*/\r
- void fillRelation(RelationsCommon relation, String documentId1, String documentType1,\r
- String documentId2, String documentType2, RelationshipType rt)\r
+ void fillRelation(RelationsCommon relation, String subjectCsid, String subjectDocumentType,\r
+ String objectCsid, String objectDocumentType, RelationshipType rt)\r
{\r
- relation.setDocumentId1(documentId1);\r
- relation.setDocumentType1(documentType1);\r
- relation.setDocumentId2(documentId2);\r
- relation.setDocumentType2(documentType2);\r
+ relation.setSubjectCsid(subjectCsid);\r
+ relation.setSubjectDocumentType(subjectDocumentType);\r
+ relation.setSubjectCsid(objectCsid);\r
+ relation.setObjectDocumentType(objectDocumentType);\r
\r
relation.setRelationshipType(rt.toString());\r
}\r
// Either value might be null for for each of Subject and Object
String subjectCsid = itemSubject.getCsid();
rc.setSubjectCsid(subjectCsid);
- rc.setDocumentId1(subjectCsid); // populate legacy field for backward compatibility
String objCsid = itemObject.getCsid();
rc.setObjectCsid(objCsid);
- rc.setDocumentId2(objCsid); // populate legacy field for backward compatibility
rc.setSubjectRefName(itemSubject.getRefName());
rc.setObjectRefName(itemObject.getRefName());
// This is superfluous, since it will be fetched by the Relations Create logic.
rc.setSubjectDocumentType(itemSubject.getDocumentType());
rc.setObjectDocumentType(itemObject.getDocumentType());
- // populate legacy fields for backward compatibility
- rc.setDocumentType1(itemSubject.getDocumentType());
- rc.setDocumentType2(itemObject.getDocumentType());
// This is superfluous, since it will be fetched by the Relations Create logic.
rc.setSubjectUri(itemSubject.getUri());
PoxPayloadOut payloadOut = new PoxPayloadOut(RelationClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart outputPart = new PayloadOutputPart(RelationClient.SERVICE_COMMONPART_NAME, rc);
payloadOut.addPart(outputPart);
- //System.out.println("\r\n==== TO CREATE: "+rc.getDocumentId1()+"==>"+rc.getPredicate()+"==>"+rc.getDocumentId2());
RelationResource relationResource = new RelationResource();
Object res = relationResource.create(ctx.getResourceMap(),
ctx.getUriInfo(), payloadOut.toXML()); //NOTE ui recycled from above to pass in unknown query params.
String relationPayload = "<document name=\"relations\">"
+ "<ns2:relations_common xmlns:ns2=\"http://collectionspace.org/services/relation\""
+ " xmlns:ns3=\"http://collectionspace.org/services/jaxb\">"
- + "<documentId1>"+loanCSID+"</documentId1>"
- + "<documentType1>"+LOAN_DOCTYPE+"</documentType1>"
- + "<documentId2>"+toCSID+"</documentId2>"
- + "<documentType2>"+context.getDocType()+"</documentType2>"
+ + "<subjectCsid>"+loanCSID+"</subjectCsid>"
+ + "<subjectDocumentType>"+LOAN_DOCTYPE+"</subjectDocumentType>"
+ + "<objectCsid>"+toCSID+"</objectCsid>"
+ + "<objectDocumentType>"+context.getDocType()+"</objectDocumentType>"
+ "<relationshipType>"+RELATION_TYPE+"</relationshipType>"
+ "<predicateDisplayName>"+RELATION_PREDICATE_DISP+"</predicateDisplayName>"
+ "</ns2:relations_common></document>";
<service:properties xmlns:service="http://collectionspace.org/services/common/service">
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNameProperty</types:key>
- <types:value>documentId1</types:value>
+ <types:value>subjectCsid</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNumberProperty</types:key>
</service:field>
<service:field>
<service:table>relations_common</service:table>
- <service:param>documentid1,documentid2</service:param>
+ <service:param>subjectcsid,objectcsid</service:param>
</service:field>
</service:params>
</service:initHandler>
RepositoryInstance repoSession = client.openRepository();\r
\r
DocumentModelList docModelList = repoSession\r
- .query("SELECT * FROM Relation WHERE relation:relationtype.documentId1='updated-Subject-1'");\r
+ .query("SELECT * FROM Relation WHERE relations_common:subjectCsid='updated-Subject-1'");\r
// DocumentModelList docModelList =\r
// repoSession.query("SELECT * FROM Relation");\r
// DocumentModelList docModelList =\r
System.out.println(docModel.getPathAsString());\r
System.out.println(docModel.getName());\r
System.out.println(docModel.getPropertyValue("dc:title"));\r
- // System.out.println("documentId1=" +\r
- // docModel.getProperty("relation",\r
- // "relationtype/documentId1").toString());\r
+ // System.out.println("subjectCsid=" +\r
+ // docModel.getProperty("relations_common",\r
+ // "subjectCsid").toString());\r
}\r
\r
} catch (Exception e) {\r
/** The Constant CSID. */\r
final static String CSID = "csid";\r
\r
- /** The Constant DOCUMENT_ID_1. */\r
- final static String DOCUMENT_ID_1 = "documentId1";\r
- \r
- /** The Constant DOCUMENT_TYPE_1. */\r
- final static String DOCUMENT_TYPE_1 = "documentType1";\r
- \r
- /** The Constant DOCUMENT_ID_2. */\r
- final static String DOCUMENT_ID_2 = "documentId2";\r
- \r
- /** The Constant DOCUMENT_TYPE_2. */\r
- final static String DOCUMENT_TYPE_2 = "documentType2";\r
- \r
/** The Constant RELATIONSHIP_TYPE. */\r
final static String RELATIONSHIP_TYPE = "relationshipType";\r
\r
/** The Constant RELATIONSHIP_TYPE_DISPLAYNAME. */\r
final static String RELATIONSHIP_TYPE_DISPLAYNAME = "predicateDisplayName";\r
\r
- final static String SUBJECT_URI = "subjectUri";\r
- final static String SUBJECT_CSID = "subjectCsid";\r
- final static String SUBJECT_REFNAME = "subjectRefName";\r
- final static String SUBJECT_DOCTYPE = "subjectDocumentType";\r
+ final static String SUBJECT_URI = "subjectUri";\r
+ final static String SUBJECT_CSID = "subjectCsid";\r
+ final static String SUBJECT_REFNAME = "subjectRefName";\r
+ final static String SUBJECT_DOCTYPE = "subjectDocumentType";\r
\r
- final static String OBJECT_URI = "objectUri";\r
- final static String OBJECT_CSID = "objectCsid";\r
- final static String OBJECT_REFNAME = "objectRefName";\r
- final static String OBJECT_DOCTYPE = "objectDocumentType";\r
+ final static String OBJECT_URI = "objectUri";\r
+ final static String OBJECT_CSID = "objectCsid";\r
+ final static String OBJECT_REFNAME = "objectRefName";\r
+ final static String OBJECT_DOCTYPE = "objectDocumentType";\r
\r
}\r
\r
StringBuilder stringBuilder = new StringBuilder();
if (subject != null) {
stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" +
- RelationJAXBSchema.DOCUMENT_ID_1 + " = " + "'" + subject + "'");
+ RelationJAXBSchema.SUBJECT_CSID + " = " + "'" + subject + "'");
}
if (subjectType != null) {
if (stringBuilder.length() > 0) {
stringBuilder.append(IQueryManager.SEARCH_QUALIFIER_AND);
}
+ // BUG - this should use the new field RelationJAXBSchema.SUBJECT_DOCTYPE
stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" +
- RelationJAXBSchema.DOCUMENT_TYPE_1 + " = " + "'" + subjectType + "'");
+ RelationJAXBSchema.SUBJECT_DOCTYPE + " = " + "'" + subjectType + "'");
}
if (predicate != null) {
stringBuilder.append(IQueryManager.SEARCH_QUALIFIER_AND);
}
stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" +
- RelationJAXBSchema.DOCUMENT_ID_2 + " = " + "'" + object + "'");
+ RelationJAXBSchema.OBJECT_CSID + " = " + "'" + object + "'");
}
if (objectType != null) {
if (stringBuilder.length() > 0) {
stringBuilder.append(IQueryManager.SEARCH_QUALIFIER_AND);
}
+ // BUG - this should use the new field RelationJAXBSchema.OBJECT_DOCTYPE
stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" +
- RelationJAXBSchema.DOCUMENT_TYPE_2 + " = " + "'" + objectType + "'");
+ RelationJAXBSchema.OBJECT_DOCTYPE + " = " + "'" + objectType + "'");
}
if (stringBuilder.length() > 0) {
<xs:complexType>\r
<xs:sequence>\r
<xs:element name="csid" type="xs:string" /> \r
- <xs:element name="documentId1" type="xs:string" minOccurs="1"/>\r
- <xs:element name="documentType1" type="xs:string" minOccurs="1"/>\r
- <xs:element name="documentId2" type="xs:string" minOccurs="1"/>\r
- <xs:element name="documentType2" type="xs:string" minOccurs="1"/>\r
<!-- type of relationship between two entities -->\r
<xs:element name="relationshipType" type="xs:string" minOccurs="1"/>\r
<xs:element name="predicateDisplayName" type="xs:string" minOccurs="1"/>\r
</templates>
<rows>
<row><widget>relationshipType</widget></row>
- <row><widget>documentId1</widget></row>
- <row><widget>documentType1</widget></row>
- <row><widget>documentId2</widget></row>
- <row><widget>documentType2</widget></row>
+ <row><widget>subjectCsid</widget></row>
+ <row><widget>subjectDocumentType</widget></row>
+ <row><widget>objectCsid</widget></row>
+ <row><widget>objectDocumentType</widget></row>
</rows>
<widget name="relationshipType" type="text">
</properties>
</widget>
- <widget name="documentId1" type="text">
+ <widget name="subjectCsid" type="text">
<labels>
- <label mode="any">Document ID 1</label>
+ <label mode="any">Subject CSID</label>
</labels>
<translated>true</translated>
<fields>
- <field schema="relations_common">documentId1</field>
+ <field schema="relations_common">subjectCsid</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</properties>
</widget>
- <widget name="documentType1" type="text">
+ <widget name="subjectDocumentType" type="text">
<labels>
- <label mode="any">Document Type 1</label>
+ <label mode="any">Subject Document Type</label>
</labels>
<translated>true</translated>
<fields>
- <field schema="relations_common">documentType1</field>
+ <field schema="relations_common">subjectDocumentType</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</properties>
</widget>
- <widget name="documentId2" type="text">
+ <widget name="objectCsid" type="text">
<labels>
- <label mode="any">Document ID 2</label>
+ <label mode="any">Object CSID</label>
</labels>
<translated>true</translated>
<fields>
- <field schema="relations_common">documentId2</field>
+ <field schema="relations_common">objectCsid</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
</properties>
</widget>
- <widget name="documentType2" type="text">
+ <widget name="objectDocumentType" type="text">
<labels>
- <label mode="any">Document Type 2</label>
+ <label mode="any">Object Document Type</label>
</labels>
<translated>true</translated>
<fields>
- <field schema="relations_common">documentType2</field>
+ <field schema="relations_common">objectDocumentType</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
<!-- document-type-1 would be the doc-type of the container collectionobject -->\r
<!-- document-id-2 would be the id of the contained (or child) collectionobject -->\r
<!-- document-type-2 would be the doc-type of the collectionobejct -->\r
- <xs:element name="documentId1" type="xs:string" minOccurs="1" maxOccurs="1"/>\r
<xs:element name="subjectCsid" type="xs:string" minOccurs="1" maxOccurs="1"/> <!-- new name for documentId1 -->\r
- <xs:element name="documentType1" type="xs:string" minOccurs="1" maxOccurs="1"/>\r
<xs:element name="subjectDocumentType" type="xs:string" minOccurs="1" maxOccurs="1"/> <!-- new name for documentType1 -->\r
\r
- <xs:element name="documentId2" type="xs:string" minOccurs="1" maxOccurs="1"/>\r
<xs:element name="objectCsid" type="xs:string" minOccurs="1" maxOccurs="1"/> <!-- new name for documentId2 -->\r
- <xs:element name="documentType2" type="xs:string" minOccurs="1" maxOccurs="1"/>\r
<xs:element name="objectDocumentType" type="xs:string" minOccurs="1" maxOccurs="1"/> <!-- new name for documentType2 -->\r
\r
<!-- type of relationship between two entities -->\r
String identifier = createIdentifier();
RelationsCommon relationsCommon = createRelationsCommon(identifier);
// Make the subject ID equal to the object ID
- relationsCommon.setDocumentId1(relationsCommon.getDocumentId2());
+ relationsCommon.setSubjectCsid(relationsCommon.getObjectCsid());
PoxPayloadOut multipart = createRelationInstance(relationsCommon);
ClientResponse<Response> res = client.create(multipart);
int statusCode = res.getStatus();
final String msg2 =
"Data in updated object was not correctly computed.";
Assert.assertEquals(
- updatedRelationCommon.getDocumentId1(), newSubjectId, msg);
+ updatedRelationCommon.getSubjectCsid(), newSubjectId, msg);
Assert.assertEquals(
- updatedRelationCommon.getDocumentType1(), newSubjectDocType, msg2);
+ updatedRelationCommon.getSubjectDocumentType(), newSubjectDocType, msg2);
Assert.assertEquals(
- updatedRelationCommon.getDocumentId2(), newObjectId, msg);
+ updatedRelationCommon.getObjectCsid(), newObjectId, msg);
Assert.assertEquals(
- updatedRelationCommon.getDocumentType2(), newObjectDocType, msg2);
+ updatedRelationCommon.getObjectDocumentType(), newObjectDocType, msg2);
Assert.assertEquals(
updatedRelationCommon.getPredicateDisplayName(), relationCommon.getPredicateDisplayName(), msg);
* Fills the relation.
*
* @param relationCommon the relation
- * @param documentId1 the document id1
- * @param documentType1 the document type1
- * @param documentId2 the document id2
- * @param documentType2 the document type2
+ * @param subjectCsid the subject document id
+ * @param subjectDocumentType the subject document type
+ * @param objectCsid the object document id
+ * @param objectDocumentType the object document type
* @param rt the rt
*/
private void fillRelation(RelationsCommon relationCommon,
- String documentId1, String documentType1,
- String documentId2, String documentType2,
+ String subjectCsid, String subjectDocumentType,
+ String objectCsid, String objectDocumentType,
String rt,
String rtDisplayName) {
- relationCommon.setDocumentId1(documentId1);
- relationCommon.setDocumentType1(documentType1);
- relationCommon.setDocumentId2(documentId2);
- relationCommon.setDocumentType2(documentType2);
+ relationCommon.setSubjectCsid(subjectCsid);
+ relationCommon.setSubjectDocumentType(subjectDocumentType);
+ relationCommon.setObjectCsid(objectCsid);
+ relationCommon.setObjectDocumentType(objectDocumentType);
relationCommon.setRelationshipType(rt);
relationCommon.setPredicateDisplayName(rtDisplayName);
String id = getCsid(docModel);
relationListItem.setCsid(id);
- relationListItem.setSubjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_1));
+ relationListItem.setSubjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.SUBJECT_CSID));
- String predicate = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.RELATIONSHIP_TYPE);
+ String predicate = (String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.RELATIONSHIP_TYPE);
relationListItem.setRelationshipType(predicate);
relationListItem.setPredicate(predicate); //predicate is new name for relationshipType.
- relationListItem.setPredicateDisplayName((String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.RELATIONSHIP_TYPE_DISPLAYNAME));
+ relationListItem.setPredicateDisplayName((String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.RELATIONSHIP_TYPE_DISPLAYNAME));
- relationListItem.setObjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_ID_2));
+ relationListItem.setObjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.OBJECT_CSID));
relationListItem.setUri(serviceContextPath + id);
//Now fill in summary info for the related docs: subject and object.
String subjectCsid = relationListItem.getSubjectCsid();
- String documentType = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_1);
- RelationsDocListItem subject = createRelationsDocListItem(ctx, sbt, subjectCsid, tReader, documentType);
+ String subjectDocumentType = (String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.SUBJECT_DOCTYPE);
+ RelationsDocListItem subject = createRelationsDocListItem(ctx, sbt, subjectCsid, tReader, subjectDocumentType);
- //Object o1 = docModel.getProperty(ctx.getCommonPartLabel(), "subject");
- //Object o2 = docModel.getProperty(ctx.getCommonPartLabel(), "object");
-
- String subjectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_URI);
+ String subjectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.SUBJECT_URI);
subject.setUri(subjectUri);
- String subjectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.SUBJECT_REFNAME);
+ String subjectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.SUBJECT_REFNAME);
subject.setRefName(subjectRefName);
relationListItem.setSubject(subject);
String objectCsid = relationListItem.getObjectCsid();
- String documentType2 = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.DOCUMENT_TYPE_2);
- RelationsDocListItem object = createRelationsDocListItem(ctx, sbt, objectCsid, tReader, documentType2);
+ String objectDocumentType = (String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.OBJECT_DOCTYPE);
+ RelationsDocListItem object = createRelationsDocListItem(ctx, sbt, objectCsid, tReader, objectDocumentType);
- String objectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_URI);
+ String objectUri = (String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.OBJECT_URI);
object.setUri(objectUri);
- String objectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(), RelationJAXBSchema.OBJECT_REFNAME);
+ String objectRefName = (String) docModel.getProperty(ctx.getCommonPartLabel(),
+ RelationJAXBSchema.OBJECT_REFNAME);
object.setRefName(objectRefName);
relationListItem.setObject(object);
TenantBindingConfigReaderImpl tReader,
String documentType) throws Exception {
RelationsDocListItem item = new RelationsDocListItem();
- item.setDocumentType(documentType);//this one comes from the record, as documentType1, documentType2.
- // CSPACE-4037 REMOVING: item.setService(documentType);//this one comes from the record, as documentType1, documentType2. Current app seems to use servicename for this.
+ item.setDocumentType(documentType);//this one comes from the record, as subjectDocumentType, objectDocumentType.
item.setCsid(itemCsid);
DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(getRepositorySession(), ctx, itemCsid); //null if not found.
if (itemDocModel != null) {
String itemDocType = itemDocModel.getDocumentType().getName();
- // CSPACE-4037 REMOVING: item.setDocumentTypeFromModel(itemDocType); //this one comes from the nuxeo documentType
-
- //DEBUG: System.out.println("\r\n******** AuthorityItemDocumentModelHandlder documentType **************\r\n\tdocModel: "+itemDocType+"\r\n\tpayload: "+documentType);
- //boolean usedDocumentTypeFromPayload = true;
- /*if ( ! Tools.isBlank(documentType)){
- if (documentType.equals(itemDocType)){
- //usedDocumentTypeFromPayload = true;
- } else {
- // Laramie20110510 CSPACE-3739 throw the exception for 3739, otherwise, don't throw it.
- //throw new Exception("documentType supplied was wrong. supplied: "+documentType+" required: "+itemDocType+ " itemCsid: "+itemCsid );
- }
- } else {
- //usedDocumentTypeFromPayload = false;
- item.setDocumentType(itemDocType);
- } */
if (Tools.isBlank(documentType)) {
item.setDocumentType(itemDocType);
}
- // TODO: clean all the output statements out of here when CSPACE-4037 is done.
//TODO: ensure that itemDocType is really the entry point, i.e. servicename==doctype
//ServiceBindingType itemSbt2 = tReader.getServiceBinding(ctx.getTenantId(), itemDocType);
String propName = "ERROR-FINDING-PROP-VALUE";
propName = ServiceBindingUtils.getPropertyValue(itemSbt, ServiceBindingUtils.OBJ_NAME_PROP);
String itemDocname = ServiceBindingUtils.getMappedFieldInDoc(itemSbt, ServiceBindingUtils.OBJ_NAME_PROP, itemDocModel);
if (propName == null || itemDocname == null) {
- //System.out.println("=== prop NOT found: "+ServiceBindingUtils.OBJ_NAME_PROP+"::"+propName+"="+itemDocname+" documentType: "+documentType);
} else {
item.setName(itemDocname);
- //System.out.println("=== found prop : "+ServiceBindingUtils.OBJ_NAME_PROP+"::"+propName+"="+itemDocname+" documentType: "+documentType);
}
} catch (Throwable t) {
- System.out.println("====Error finding objectNameProperty: " + itemDocModel + " field " + ServiceBindingUtils.OBJ_NAME_PROP + "=" + propName
+ logger.error("====Error finding objectNameProperty: " + itemDocModel + " field " + ServiceBindingUtils.OBJ_NAME_PROP + "=" + propName
+ " not found in itemDocType: " + itemDocType + " inner: " + t.getMessage());
}
propName = "ERROR-FINDING-PROP-VALUE";
String itemDocnumber = ServiceBindingUtils.getMappedFieldInDoc(itemSbt, ServiceBindingUtils.OBJ_NUMBER_PROP, itemDocModel);
if (propName == null || itemDocnumber == null) {
- //System.out.println("=== prop NOT found: "+ServiceBindingUtils.OBJ_NUMBER_PROP+"::"+propName+"="+itemDocnumber
- // +" documentType: "+documentType);
} else {
item.setNumber(itemDocnumber);
- //System.out.println("============ found prop : "+ServiceBindingUtils.OBJ_NUMBER_PROP+"::"+propName+"="+itemDocnumber
- // +" documentType: "+documentType);
}
} catch (Throwable t) {
logger.error("====Error finding objectNumberProperty: " + ServiceBindingUtils.OBJ_NUMBER_PROP + "=" + propName
try {
csid = (String) relationDocModel.getProperty(commonPartLabel,
(fSubject?RelationJAXBSchema.SUBJECT_CSID:RelationJAXBSchema.OBJECT_CSID));
- // FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record:
- if (Tools.isBlank(csid)) {
- csid = (String) relationDocModel.getProperty(commonPartLabel,
- (fSubject?RelationJAXBSchema.DOCUMENT_ID_1:RelationJAXBSchema.DOCUMENT_ID_2));
- }
} catch (PropertyException pe) {
// Per CSPACE-4468, ignore any property exception here.
// The objectCsid and/or subjectCsid field in a relation record
String doctype = (String) subjectOrObjectDocModel.getType();
properties.put((fSubject?RelationJAXBSchema.SUBJECT_DOCTYPE:RelationJAXBSchema.OBJECT_DOCTYPE),
doctype);
- // FIXME: Remove the line below when legacy fields are removed from the Relation record:
- properties.put((fSubject?RelationJAXBSchema.DOCUMENT_TYPE_1:RelationJAXBSchema.DOCUMENT_TYPE_2),
- doctype);
String csid = (String) subjectOrObjectDocModel.getName();
properties.put((fSubject?RelationJAXBSchema.SUBJECT_CSID:RelationJAXBSchema.OBJECT_CSID),
csid);
- // FIXME: Remove the two lines immediately below when legacy fields are removed from the Relation record:
- properties.put((fSubject?RelationJAXBSchema.DOCUMENT_ID_1:RelationJAXBSchema.DOCUMENT_ID_2),
- csid);
String uri = (String) subjectOrObjectDocModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA,
COLLECTIONSPACE_CORE_URI);
logger.trace(relationsCommon.toString());\r
}\r
\r
- String subjectCsid = getSubjectCsid(relationsCommon);\r
- String objectCsid = getObjectCsid(relationsCommon);\r
+ String subjectCsid = relationsCommon.getSubjectCsid();\r
+ String objectCsid = relationsCommon.getObjectCsid();\r
\r
// If no CSID for a subject or object is included in the create payload,\r
// a refName must be provided for that subject or object as an alternate identifier.\r
// TODO Auto-generated method stub\r
}\r
\r
- private String getSubjectCsid(RelationsCommon relationsCommon) {\r
- String subjectCsid = relationsCommon.getSubjectCsid();\r
- // FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record:\r
- if (Tools.isBlank(subjectCsid)) {\r
- subjectCsid = relationsCommon.getDocumentId1();\r
- }\r
- return subjectCsid;\r
- }\r
-\r
- private String getObjectCsid(RelationsCommon relationsCommon) {\r
- String objectCsid = relationsCommon.getObjectCsid();\r
- // FIXME: Remove this entire 'if' statement when legacy fields are removed from the Relation record:\r
- if (Tools.isBlank(objectCsid)) {\r
- objectCsid = relationsCommon.getDocumentId2();\r
- }\r
- return objectCsid;\r
- }\r
-\r
private boolean hasCsid(String csid) {\r
boolean hasCsid = false;\r
if (Tools.notBlank(csid)) {\r