AdapterComponentDocRegistryOrchImpl { public AdhocQueryResponse registryStoredQuery(AdhocQueryRequest request) { LOG.debug("Begin AdapterComponentDocRegistryOrchImpl.registryStoredQuery(...)"); AdhocQueryResponse response; boolean registryIdPresent = false; DocumentQueryParams params = new DocumentQueryParams(); if (request != null && getRegistryQueryId().contains(request.getAdhocQuery().getId())) { registryIdPresent = true; } boolean patientIdSlotPresent = false; if (registryIdPresent) { ObjectFactory queryObjFact = new ObjectFactory(); response = queryObjFact.createAdhocQueryResponse(); if (request != null) { List<SlotType1> slots = getSlotsFromAdhocQueryRequest(request); int patientIdSlotCount = 0; for (SlotType1 slot : slots) { if (slot.getName().equals(EBXML_DOCENTRY_PATIENT_ID)) { patientIdSlotCount++; } } if (patientIdSlotCount > 1) { response = createErrorResponse(EBXML_DOCQUERY_MULTIPLE_PATIENTID_SLOTS_ERROR, "Multiple $XDSDocumentEntryPatientId Present in the Request"); return response; } else { if (request.getAdhocQuery().getId().equals(FINDDOCUMENTSQUERYID)) { List<String> slotValues; for (SlotType1 slot : slots) { if (slot.getName().equals(EBXML_DOCENTRY_PATIENT_ID)) { patientIdSlotPresent = true; slotValues = extractSlotValues(slots, EBXML_DOCENTRY_PATIENT_ID); if (slotValues == null || slotValues.isEmpty()) { response = createErrorResponse(EBXML_DOCQUERY_STORED_QUERY_MISSIN_PARAM, "Required parameter XDSDocumentEntryPatientId, not present in query request"); return response; } } } if (!patientIdSlotPresent) { response = createErrorResponse(EBXML_DOCQUERY_STORED_QUERY_MISSIN_PARAM, "Required parameter XDSDocumentEntryPatientId, not present in query request"); return response; } } params = generateDocumentQueryParamsFromSlots(slots); } } DocumentService service = getDocumentService(); List<DocumentMetadata> docs = new ArrayList<>(); Boolean isOnDemand = params.getOnDemand(); if (isOnDemand == null || !isOnDemand) { params.setOnDemandParams(Boolean.FALSE); docs.addAll(service.documentQuery(params)); } if (isOnDemand == null || isOnDemand != null && isOnDemand) { params.setCreationTimeFrom(null); params.setCreationTimeTo(null); params.setOnDemandParams(Boolean.TRUE); docs.addAll(service.documentQuery(params)); } LOG.debug("registryStoredQuery- docs.size: " + docs.size()); loadResponseMessage(response, docs); LOG.debug("End AdapterComponentDocRegistryOrchImpl.registryStoredQuery(...)"); } else { response = createErrorResponse(EBXML_DOCQUERY_STORED_QUERY_ERROR, "Unknown Stored Query query id =" + request.getAdhocQuery().getId()); } return response; } AdapterComponentDocRegistryOrchImpl(); AdhocQueryResponse registryStoredQuery(AdhocQueryRequest request); void loadResponseMessage(oasis.names.tc.ebxml_regrep.xsd.query._3.AdhocQueryResponse response,
        List<DocumentMetadata> docs); void parseParamFormattedString(String paramFormattedString, List<String> resultCollection);  }
@Test public void testRegistryStoredQuery_OnDemandDocs() { AdapterComponentDocRegistryOrchImpl orchImpl = createAdapterComponentDocRegistryOrchImpl(); AdhocQueryRequest request = createAdhocQueryRequestForOnDemandDocuments(); AdhocQueryResponse response = orchImpl.registryStoredQuery(request); List<JAXBElement<? extends IdentifiableType>> objectList = response.getRegistryObjectList().getIdentifiable(); assertEquals(1, objectList.size()); ExtrinsicObjectType docExtrinsic = (ExtrinsicObjectType) objectList.get(0).getValue(); List<ExternalIdentifierType> externalIdentifierList = docExtrinsic.getExternalIdentifier(); assertEquals(1, externalIdentifierList.size()); assertEquals("12345.11111", externalIdentifierList.get(0).getValue()); }
@Test public void testRegistryStoredQuery_StableDocs() { AdapterComponentDocRegistryOrchImpl orchImpl = createAdapterComponentDocRegistryOrchImpl(); AdhocQueryRequest request = createAdhocQueryRequestForStableDocuments(); AdhocQueryResponse response = orchImpl.registryStoredQuery(request); List<JAXBElement<? extends IdentifiableType>> objectList = response.getRegistryObjectList().getIdentifiable(); assertEquals(2, objectList.size()); ExtrinsicObjectType docExtrinsic = (ExtrinsicObjectType) objectList.get(0).getValue(); List<ExternalIdentifierType> externalIdentifierList = docExtrinsic.getExternalIdentifier(); assertEquals(1, externalIdentifierList.size()); assertEquals("12345.22222", externalIdentifierList.get(0).getValue()); docExtrinsic = (ExtrinsicObjectType) objectList.get(1).getValue(); externalIdentifierList = docExtrinsic.getExternalIdentifier(); assertEquals(1, externalIdentifierList.size()); assertEquals("12345.33333", externalIdentifierList.get(0).getValue()); }
@Test public void testRegistryStoredQuery_StableAndOnDemandDocs() { AdapterComponentDocRegistryOrchImpl orchImpl = createAdapterComponentDocRegistryOrchImpl(); AdhocQueryRequest request = createAdhocQueryRequestForStableAndOnDemandDocuments(); AdhocQueryResponse response = orchImpl.registryStoredQuery(request); List<JAXBElement<? extends IdentifiableType>> objectList = response.getRegistryObjectList().getIdentifiable(); assertEquals(3, objectList.size()); }
@Test public void testRegistryStoredQuery_unknownRegistryQueryId() { AdapterComponentDocRegistryOrchImpl orchImpl = createAdapterComponentDocRegistryOrchImpl(); AdhocQueryRequest request = createAdhocQueryRequestForunknownStoredQuery(); AdhocQueryResponse response = orchImpl.registryStoredQuery(request); assertSame(response.getStatus(), DocumentConstants.XDS_QUERY_RESPONSE_STATUS_FAILURE); }
@Test public void testRegistryStoredQuery_RegistryQueryIdMissingParam() { AdapterComponentDocRegistryOrchImpl orchImpl = createAdapterComponentDocRegistryOrchImpl(); AdhocQueryRequest request = createAdhocQueryRequestforMissingParam(); AdhocQueryResponse response = orchImpl.registryStoredQuery(request); assertSame(response.getRegistryErrorList().getRegistryError().get(0).getErrorCode(), "XDSStoredQueryMissingParam"); }
@Test public void testRegistryStoredQuery_XDSStoredQueryParamNumberError() { AdapterComponentDocRegistryOrchImpl orchImpl = createAdapterComponentDocRegistryOrchImpl(); AdhocQueryRequest request = createAdhocQueryRequestForXDSStoredQueryParamNumberError(); AdhocQueryResponse response = orchImpl.registryStoredQuery(request); assertSame(response.getRegistryErrorList().getRegistryError().get(0).getErrorCode(), "XDSStoredQueryParamNumber"); }