Skip to content

Commit

Permalink
Added (initial not fully tested) ODD query support for GetAssociation…
Browse files Browse the repository at this point in the history
…s, GetFolderAndContents and GetSubmissionSetAndContents queries.
  • Loading branch information
rcrichton committed Jul 30, 2015
1 parent 3d087dc commit e6cea8d
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -54,10 +59,18 @@ void validateParameters() throws MetadataValidationException {

protected String fol_uuid;
protected String fol_uid;
protected List<String> 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<String>();
object_type.add(MetadataSupport.XDSDocumentEntry_objectType_stable_uuid);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -54,11 +57,19 @@ void validateParameters() throws MetadataValidationException {
protected String uid;
protected String uuid;
protected List<String> assoc_types;
protected List<String> 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<String>();
object_type.add(MetadataSupport.XDSDocumentEntry_objectType_stable_uuid);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -59,12 +64,20 @@ void validateParameters() throws MetadataValidationException {
protected String ss_uid;
protected SQCodedTerm format_code;
protected SQCodedTerm conf_code;
protected List<String> 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<String>();
object_type.add(MetadataSupport.XDSDocumentEntry_objectType_stable_uuid);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> docIds = eb.getIdsFromAdhocQueryResponse(doc_metadata);
content_ids.addAll(docIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public String getDocIdFromUid(String uid) throws XdsException,
}

// sql
public OMElement getAssociations(List<String> source_or_target_ids, List<String> assoc_types) throws XdsException,
public OMElement getAssociations(List<String> source_or_target_ids, List<String> assoc_types, List<String> object_types) throws XdsException,
LoggerException {

List<String> a_types = assoc_types;
Expand All @@ -302,14 +302,19 @@ public OMElement getAssociations(List<String> source_or_target_ids, List<String>

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);
}

Expand Down Expand Up @@ -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<String> format_codes, List<String> conf_codes)
public OMElement getRPDocs(String rp_uuid, List<String> format_codes, List<String> conf_codes, List<String> object_types)
throws XdsException, LoggerException {
init();

Expand Down Expand Up @@ -643,10 +648,12 @@ public OMElement getRPDocs(String rp_uuid, List<String> format_codes, List<Strin
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 getRPDocs(String rp_uuid, SQCodedTerm format_codes, SQCodedTerm conf_codes)
public OMElement getRPDocs(String rp_uuid, SQCodedTerm format_codes, SQCodedTerm conf_codes, List<String> object_types)
throws XdsException, LoggerException {
init();

Expand All @@ -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<String> format_codes, List<String> conf_codes)
public OMElement getFolDocs(String fol_uuid, List<String> format_codes, List<String> conf_codes, List<String> 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<String> 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<String> format_codes, List<String> conf_codes)
public OMElement getSsDocs(String fol_uuid, List<String> format_codes, List<String> conf_codes, List<String> 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<String> 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<String> package_uuids, List<String> content_uuids) throws XdsException,
Expand Down

0 comments on commit e6cea8d

Please sign in to comment.