// static public final String SUBJECT_TYPE = "subjectType";
static public final String SUBJECT_TYPE_QP = SUBJECT_QP + "Type";
+ // A query param for specifying either Subject or Object
+ static public final String SUBJECT_OR_OBJECT = "sbjOrObj";
+
/** The Constant PREDICATE. */
static public final String PREDICATE = "predicate";
static public final String PREDICATE_QP = "prd";
String predicate = queryParams.getFirst(IRelationsManager.PREDICATE_QP);
String objectCsid = queryParams.getFirst(IRelationsManager.OBJECT_QP);
String objectType = queryParams.getFirst(IRelationsManager.OBJECT_TYPE_QP);
+ String subjectOrObject = queryParams.getFirst(IRelationsManager.SUBJECT_OR_OBJECT);
- return this.getRelationList(parentCtx, uriInfo, subjectCsid, subjectType, predicate, objectCsid, objectType);
+ return this.getRelationList(parentCtx, uriInfo, subjectCsid, subjectType, predicate, objectCsid, objectType, subjectOrObject);
}
private RelationsCommonList getRelationList(
String subjectCsid, String subjectType,
String predicate,
String objectCsid,
- String objectType) throws CSWebApplicationException {
+ String objectType,
+ String subjectOrObject) throws CSWebApplicationException {
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) { // If the parent context has a non-null and open repository session then use it
}
DocumentHandler handler = createDocumentHandler(ctx);
- String relationClause = RelationsUtils.buildWhereClause(subjectCsid, subjectType, predicate, objectCsid, objectType);
+ String relationClause = RelationsUtils.buildWhereClause(subjectCsid, subjectType, predicate, objectCsid, objectType, subjectOrObject);
handler.getDocumentFilter().appendWhereClause(relationClause, IQueryManager.SEARCH_QUALIFIER_AND);
//
// Handle keyword clause
*/
public static String buildWhereClause(String subject, String subjectType,
String predicate,
- String object, String objectType) {
+ String object, String objectType,
+ String subjectOrObject) {
String result = null;
- StringBuilder stringBuilder = new StringBuilder();
+ StringBuilder stringBuilder = new StringBuilder();
+
if (subject != null) {
stringBuilder.append(RelationConstants.NUXEO_SCHEMA_NAME + ":" +
RelationJAXBSchema.SUBJECT_CSID + " = " + "'" + subject + "'");
}
+ // (subectCsid = ${csid} OR objectCsid = ${csid})
+ if (subjectOrObject != null) {
+ if (stringBuilder.length() > 0) {
+ stringBuilder.append(IQueryManager.SEARCH_QUALIFIER_AND);
+ }
+ stringBuilder.append("(" + RelationConstants.NUXEO_SCHEMA_NAME + ":" +
+ RelationJAXBSchema.SUBJECT_CSID + " = " + "'" + subjectOrObject + "'");
+ stringBuilder.append(" OR " + RelationConstants.NUXEO_SCHEMA_NAME + ":" +
+ RelationJAXBSchema.OBJECT_CSID + " = " + "'" + subjectOrObject + "'" + ")");
+ }
+
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.SUBJECT_DOCTYPE + " = " + "'" + subjectType + "'");
}
String id = NuxeoUtils.getCsid(docModel);
item.put(STANDARD_LIST_CSID_FIELD, id);
if (markRtSbj != null) {
- String relationClause = RelationsUtils.buildWhereClause(markRtSbj, null, null, id, null);
+ String relationClause = RelationsUtils.buildWhereClause(markRtSbj, null, null, id, null, null);
String whereClause = relationClause + IQueryManager.SEARCH_QUALIFIER_AND
+ NuxeoUtils.buildWorkflowNotDeletedWhereClause();
QueryContext queryContext = new QueryContext(ctx, whereClause);