From e6cea8dab1fd2457c5e9fef22e5da0fd015c8a45 Mon Sep 17 00:00:00 2001 From: Ryan Crichton Date: Thu, 30 Jul 2015 16:46:42 +0200 Subject: [PATCH] Added (initial not fully tested) ODD query support for GetAssociations, GetFolderAndContents and GetSubmissionSetAndContents queries. --- .../registry/ws/sq/GetFolderAndContents.java | 15 +++++++- .../registry/ws/sq/GetRelatedDocuments.java | 11 ++++++ .../ws/sq/GetSubmissionSetAndContents.java | 15 +++++++- .../sq/ebxmlrr21/EbXML21GetAssociations.java | 2 +- .../EbXML21GetDocumentsAndAssociations.java | 2 +- .../EbXML21GetFolderAndContents.java | 2 +- .../ebxmlrr21/EbXML21GetRelatedDocuments.java | 2 +- .../EbXML21GetSubmissionSetAndContents.java | 2 +- .../ws/sq/ebxmlrr21/EbXML21QuerySupport.java | 35 ++++++++++++------- 9 files changed, 66 insertions(+), 20 deletions(-) diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetFolderAndContents.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetFolderAndContents.java index 26c35bd..ed5520c 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetFolderAndContents.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetFolderAndContents.java @@ -1,5 +1,6 @@ package gov.nist.registry.ws.sq; +import gov.nist.registry.common2.registry.MetadataSupport; import org.openhealthtools.openxds.log.LoggerException; import gov.nist.registry.common2.exception.MetadataException; @@ -10,6 +11,9 @@ import gov.nist.registry.common2.registry.Metadata; import gov.nist.registry.common2.registry.storedquery.StoredQuerySupport; +import java.util.ArrayList; +import java.util.List; + /** Generic implementation of GetAssociations Stored Query. This class knows how to parse a * GetAssociations Stored Query request producing a collection of instance variables describing @@ -44,7 +48,8 @@ void validateParameters() throws MetadataValidationException { sqs.validate_parm("$XDSFolderEntryUUID", true, false, true, false, false, "$XDSFolderUniqueId"); sqs.validate_parm("$XDSFolderUniqueId", true, false, true, false, false, "$XDSFolderEntryUUID"); sqs.validate_parm("$XDSDocumentEntryFormatCode", false, true, true, true, false, (String[])null); - sqs.validate_parm("$XDSDocumentEntryConfidentialityCode", false, true, true, true, true, (String[])null); + sqs.validate_parm("$XDSDocumentEntryConfidentialityCode", false, true, true, true, true, (String[])null); + sqs.validate_parm("$XDSDocumentEntryType", false, true, true, false, false, (String[])null); System.out.println("GFAC: validating parms response: " + sqs.response); @@ -54,10 +59,18 @@ void validateParameters() throws MetadataValidationException { protected String fol_uuid; protected String fol_uid; + protected List object_type; void parseParameters() throws XdsInternalException, XdsException, LoggerException { fol_uuid = sqs.params.getStringParm("$XDSFolderEntryUUID"); fol_uid = sqs.params.getStringParm("$XDSFolderUniqueId"); + object_type = sqs.params.getListParm("$XDSDocumentEntryType"); + + // the default value of object_type is stable documents + if (object_type == null) { + object_type = new ArrayList(); + object_type.add(MetadataSupport.XDSDocumentEntry_objectType_stable_uuid); + } } /** diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetRelatedDocuments.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetRelatedDocuments.java index 5b89e4b..85f5c1f 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetRelatedDocuments.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetRelatedDocuments.java @@ -6,8 +6,10 @@ import gov.nist.registry.common2.exception.XdsException; import gov.nist.registry.common2.exception.XdsInternalException; import gov.nist.registry.common2.registry.Metadata; +import gov.nist.registry.common2.registry.MetadataSupport; import gov.nist.registry.common2.registry.storedquery.StoredQuerySupport; +import java.util.ArrayList; import java.util.List; import org.openhealthtools.openxds.log.LoggerException; @@ -46,6 +48,7 @@ void validateParameters() throws MetadataValidationException { sqs.validate_parm("$XDSDocumentEntryUniqueId", true, false, true, null, "$XDSDocumentEntryEntryUUID"); sqs.validate_parm("$XDSDocumentEntryEntryUUID", true, false, true, null, "$XDSDocumentEntryUniqueId"); sqs.validate_parm("$AssociationTypes", true, true, true, null, (String[])null); + sqs.validate_parm("$XDSDocumentEntryType", false, true, true, null, (String[])null); if (sqs.has_validation_errors) throw new MetadataValidationException("Metadata Validation error present"); @@ -54,11 +57,19 @@ void validateParameters() throws MetadataValidationException { protected String uid; protected String uuid; protected List assoc_types; + protected List object_type; void parseParameters() throws XdsInternalException, XdsException, LoggerException { uid = sqs.params.getStringParm("$XDSDocumentEntryUniqueId"); uuid = sqs.params.getStringParm("$XDSDocumentEntryEntryUUID"); assoc_types = sqs.params.getListParm("$AssociationTypes"); + object_type = sqs.params.getListParm("$XDSDocumentEntryType"); + + // the default value of object_type is stable documents + if (object_type == null) { + object_type = new ArrayList(); + object_type.add(MetadataSupport.XDSDocumentEntry_objectType_stable_uuid); + } } /** diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetSubmissionSetAndContents.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetSubmissionSetAndContents.java index 85a96ed..7a71455 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetSubmissionSetAndContents.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/GetSubmissionSetAndContents.java @@ -6,12 +6,16 @@ import gov.nist.registry.common2.exception.XdsException; import gov.nist.registry.common2.exception.XdsInternalException; import gov.nist.registry.common2.registry.Metadata; +import gov.nist.registry.common2.registry.MetadataSupport; import gov.nist.registry.common2.registry.SQCodedTerm; import gov.nist.registry.common2.registry.storedquery.StoredQuerySupport; import org.apache.log4j.Logger; import org.openhealthtools.openxds.log.LoggerException; +import java.util.ArrayList; +import java.util.List; + /** Generic implementation of GetAssociations Stored Query. This class knows how to parse a * GetAssociations Stored Query request producing a collection of instance variables describing @@ -49,7 +53,8 @@ void validateParameters() throws MetadataValidationException { sqs.validate_parm("$XDSSubmissionSetEntryUUID", true, false, true, false, false, "$XDSSubmissionSetUniqueId"); sqs.validate_parm("$XDSSubmissionSetUniqueId", true, false, true, false, false, "$XDSSubmissionSetEntryUUID"); sqs.validate_parm("$XDSDocumentEntryFormatCode", false, true, true, true, false, (String[])null); - sqs.validate_parm("$XDSDocumentEntryConfidentialityCode", false, true, true, true, true, (String[])null); + sqs.validate_parm("$XDSDocumentEntryConfidentialityCode", false, true, true, true, true, (String[])null); + sqs.validate_parm("$XDSDocumentEntryType", false, true, true, false, false, (String[])null); if (sqs.has_validation_errors) throw new MetadataValidationException("Metadata Validation error present"); @@ -59,12 +64,20 @@ void validateParameters() throws MetadataValidationException { protected String ss_uid; protected SQCodedTerm format_code; protected SQCodedTerm conf_code; + protected List object_type; void parseParameters() throws XdsInternalException, XdsException, LoggerException { ss_uuid = sqs.params.getStringParm("$XDSSubmissionSetEntryUUID"); ss_uid = sqs.params.getStringParm("$XDSSubmissionSetUniqueId"); format_code = sqs.params.getCodedParm("$XDSDocumentEntryFormatCode"); conf_code = sqs.params.getCodedParm("$XDSDocumentEntryConfidentialityCode"); + object_type = sqs.params.getListParm("$XDSDocumentEntryType"); + + // the default value of object_type is stable documents + if (object_type == null) { + object_type = new ArrayList(); + object_type.add(MetadataSupport.XDSDocumentEntry_objectType_stable_uuid); + } } diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetAssociations.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetAssociations.java index 555fb80..73994ca 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetAssociations.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetAssociations.java @@ -37,7 +37,7 @@ public EbXML21GetAssociations(StoredQuerySupport sqs) { * @throws XdsException */ public Metadata runImplementation() throws MetadataException, XdsException, LoggerException { - return MetadataParser.parseNonSubmission(eb.getAssociations(uuids, null)); + return MetadataParser.parseNonSubmission(eb.getAssociations(uuids, null, null)); } } diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetDocumentsAndAssociations.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetDocumentsAndAssociations.java index f274dcc..3f7cf7c 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetDocumentsAndAssociations.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetDocumentsAndAssociations.java @@ -66,7 +66,7 @@ public Metadata runImplementation() throws XdsException, LoggerException, if (doc_ids.size() == 0) return metadata; - OMElement ele = eb.getAssociations(doc_ids, null); + OMElement ele = eb.getAssociations(doc_ids, null, null); metadata.addMetadata(ele, true); return metadata; diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetFolderAndContents.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetFolderAndContents.java index aba30d6..51323c6 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetFolderAndContents.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetFolderAndContents.java @@ -80,7 +80,7 @@ public Metadata runImplementation() throws XdsException, LoggerException, SQCodedTerm conf_codes = sqs.params.getCodedParm("$XDSDocumentEntryConfidentialityCode"); SQCodedTerm format_codes = sqs.params.getCodedParm("$XDSDocumentEntryFormatCode"); - OMElement doc_metadata = eb.getFolDocs(fol_uuid, format_codes, conf_codes); + OMElement doc_metadata = eb.getFolDocs(fol_uuid, format_codes, conf_codes, object_type); metadata.addMetadata(doc_metadata); List docIds = eb.getIdsFromAdhocQueryResponse(doc_metadata); content_ids.addAll(docIds); diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetRelatedDocuments.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetRelatedDocuments.java index 0d5c97d..6afc4af 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetRelatedDocuments.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetRelatedDocuments.java @@ -105,7 +105,7 @@ else if (orig_doc_metadata.getObjectRefs().size() > 0) { targetIds.add(originalDocId); sqs.forceLeafClassQueryType(); // fetch LeafClass for Associations - OMElement associations = eb.getAssociations(targetIds, assoc_types); + OMElement associations = eb.getAssociations(targetIds, assoc_types, object_type); sqs.restoreOriginalQueryType(); Metadata association_metadata = MetadataParser.parseNonSubmission(associations); diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetSubmissionSetAndContents.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetSubmissionSetAndContents.java index 29d3219..5d99eab 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetSubmissionSetAndContents.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21GetSubmissionSetAndContents.java @@ -75,7 +75,7 @@ public Metadata runImplementation() throws XdsException, LoggerException, SQCodedTerm conf_codes = sqs.params.getCodedParm("$XDSDocumentEntryConfidentialityCode"); SQCodedTerm format_codes = sqs.params.getCodedParm("$XDSDocumentEntryFormatCode"); - OMElement doc_metadata = eb.getSsDocs(ss_uuid, format_codes, conf_codes); + OMElement doc_metadata = eb.getSsDocs(ss_uuid, format_codes, conf_codes, object_type); metadata.addMetadata(doc_metadata); OMElement fol_metadata = eb.getSsFolders(ss_uuid); diff --git a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21QuerySupport.java b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21QuerySupport.java index d9c4021..e77550a 100644 --- a/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21QuerySupport.java +++ b/openxds/iheos/src/main/java/gov/nist/registry/ws/sq/ebxmlrr21/EbXML21QuerySupport.java @@ -283,7 +283,7 @@ public String getDocIdFromUid(String uid) throws XdsException, } // sql - public OMElement getAssociations(List source_or_target_ids, List assoc_types) throws XdsException, + public OMElement getAssociations(List source_or_target_ids, List assoc_types, List object_types) throws XdsException, LoggerException { List a_types = assoc_types; @@ -302,14 +302,19 @@ public OMElement getAssociations(List source_or_target_ids, List select("a"); - a("FROM Association a"); n(); + a("FROM Association a, ExtrinsicObject doc"); n(); a("WHERE "); n(); a(" (a.sourceObject IN "); a(source_or_target_ids); a(" OR"); n(); - a(" a.targetObject IN "); a(source_or_target_ids); a(" )"); n(); + a(" a.targetObject IN "); a(source_or_target_ids); a(" )"); n(); if (assoc_types != null) { a(" AND a.associationType IN "); a(a_types); n(); } + if (object_types != null && object_types.size() > 0) { + a(" AND (doc.id=a.sourceobject OR doc.id=a.targetobject) AND doc.id NOT IN "); a(source_or_target_ids); n(); + a(" AND doc.objecttype IN "); a(object_types); n(); + } + return query(sqs.return_leaf_class); } @@ -608,7 +613,7 @@ public OMElement getSsByUuid(String uuid) throws XdsException, LoggerException public OMElement getSsByUid(String uid) throws XdsException, LoggerException { return getRpByUid(uid, "urn:uuid:96fdda7c-d067-4183-912e-bf5ee74998a8"); } - public OMElement getRPDocs(String rp_uuid, List format_codes, List conf_codes) + public OMElement getRPDocs(String rp_uuid, List format_codes, List conf_codes, List object_types) throws XdsException, LoggerException { init(); @@ -643,10 +648,12 @@ public OMElement getRPDocs(String rp_uuid, List format_codes, List object_types) throws XdsException, LoggerException { init(); @@ -668,27 +675,29 @@ public OMElement getRPDocs(String rp_uuid, SQCodedTerm format_codes, SQCodedTerm a(" AND (adomain.name='AffinityDomain' AND adomain.parent=doc.id AND adomain.value=$affinitydomain) "); } + a(" AND doc.objecttype IN "); a(object_types); n(); + return query(); } - public OMElement getFolDocs(String fol_uuid, List format_codes, List conf_codes) + public OMElement getFolDocs(String fol_uuid, List format_codes, List conf_codes, List object_types) throws XdsException, LoggerException { - return getRPDocs(fol_uuid, format_codes, conf_codes); + return getRPDocs(fol_uuid, format_codes, conf_codes, object_types); } - public OMElement getFolDocs(String fol_uuid, SQCodedTerm format_codes, SQCodedTerm conf_codes) + public OMElement getFolDocs(String fol_uuid, SQCodedTerm format_codes, SQCodedTerm conf_codes, List object_types) throws XdsException, LoggerException { - return getRPDocs(fol_uuid, format_codes, conf_codes); + return getRPDocs(fol_uuid, format_codes, conf_codes, object_types); } - public OMElement getSsDocs(String fol_uuid, List format_codes, List conf_codes) + public OMElement getSsDocs(String fol_uuid, List format_codes, List conf_codes, List object_types) throws XdsException, LoggerException { - return getRPDocs(fol_uuid, format_codes, conf_codes); + return getRPDocs(fol_uuid, format_codes, conf_codes, object_types); } - public OMElement getSsDocs(String fol_uuid, SQCodedTerm format_codes, SQCodedTerm conf_codes) + public OMElement getSsDocs(String fol_uuid, SQCodedTerm format_codes, SQCodedTerm conf_codes, List object_types) throws XdsException, LoggerException { - return getRPDocs(fol_uuid, format_codes, conf_codes); + return getRPDocs(fol_uuid, format_codes, conf_codes, object_types); } public OMElement getRegistryPackageAssocs(List package_uuids, List content_uuids) throws XdsException,