Skip to content

Commit

Permalink
#421: add XDS query types and ebxml transformation. Refactor to insta…
Browse files Browse the repository at this point in the history
…ntiate less objects by using singletons
  • Loading branch information
Christian Ohr committed Mar 12, 2024
1 parent ecb73d1 commit 7254b49
Show file tree
Hide file tree
Showing 186 changed files with 2,437 additions and 2,588 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public XdsAuditStrategy(boolean serverSide) {
* @param response registry to analyze.
* @return outcome code.
*/
private static EventOutcomeIndicator getEventOutcomeCodeFromRegistryResponse(EbXMLRegistryResponse response) {
private static EventOutcomeIndicator getEventOutcomeCodeFromRegistryResponse(EbXMLRegistryResponse<RegistryResponseType> response) {
try {
if (response.getStatus() == Status.SUCCESS) {
return EventOutcomeIndicator.Success;
Expand All @@ -67,7 +67,7 @@ private static EventOutcomeIndicator getEventOutcomeCodeFromRegistryResponse(EbX
}
}

private static String getEventOutcomeDescriptionFromRegistryResponse(EbXMLRegistryResponse response) {
private static String getEventOutcomeDescriptionFromRegistryResponse(EbXMLRegistryResponse<RegistryResponseType> response) {
if (response.getErrors().isEmpty()) {
return null;
}
Expand All @@ -83,14 +83,14 @@ private static String getEventOutcomeDescriptionFromRegistryResponse(EbXMLRegist
@Override
public EventOutcomeIndicator getEventOutcomeIndicator(T auditDataset, Object pojo) {
var response = (RegistryResponseType) pojo;
EbXMLRegistryResponse ebXML = new EbXMLRegistryResponse30(response);
EbXMLRegistryResponse<RegistryResponseType> ebXML = new EbXMLRegistryResponse30(response);
return getEventOutcomeCodeFromRegistryResponse(ebXML);
}

@Override
public String getEventOutcomeDescription(T auditDataset, Object pojo) {
var response = (RegistryResponseType) pojo;
EbXMLRegistryResponse ebXML = new EbXMLRegistryResponse30(response);
EbXMLRegistryResponse<RegistryResponseType> ebXML = new EbXMLRegistryResponse30(response);
return getEventOutcomeDescriptionFromRegistryResponse(ebXML);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public XdsSubmitAuditStrategy30(boolean serverSide) {
super(serverSide);
}

protected static void enrichDatasetFromSubmitObjectsRequest(XdsSubmitAuditDataset auditDataset, EbXMLSubmitObjectsRequest ebXML) {
protected static void enrichDatasetFromSubmitObjectsRequest(XdsSubmitAuditDataset auditDataset, EbXMLSubmitObjectsRequest<SubmitObjectsRequest> ebXML) {
var submissionSets = ebXML.getRegistryPackages(Vocabulary.SUBMISSION_SET_CLASS_NODE);
auditDataset.setHomeCommunityId(ebXML.getSingleSlotValue(Vocabulary.SLOT_NAME_HOME_COMMUNITY_ID));

Expand All @@ -59,7 +59,7 @@ protected static void enrichDatasetFromSubmitObjectsRequest(XdsSubmitAuditDatase
public XdsSubmitAuditDataset enrichAuditDatasetFromRequest(XdsSubmitAuditDataset auditDataset, Object pojo, Map<String, Object> parameters) {
if (pojo instanceof SubmitObjectsRequest) {
var submitObjectsRequest = (SubmitObjectsRequest) pojo;
EbXMLSubmitObjectsRequest ebXML = new EbXMLSubmitObjectsRequest30(submitObjectsRequest);
EbXMLSubmitObjectsRequest<SubmitObjectsRequest> ebXML = new EbXMLSubmitObjectsRequest30(submitObjectsRequest);
enrichDatasetFromSubmitObjectsRequest(auditDataset, ebXML);
}
return auditDataset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* abstraction of the ebXML data structure.
* @author Jens Riemschneider
*/
public interface EbXMLAdhocQueryRequest extends EbXMLSlotList {
public interface EbXMLAdhocQueryRequest<E> extends EbXMLSlotList {

/**
* @param returnType
Expand Down Expand Up @@ -60,5 +60,5 @@ public interface EbXMLAdhocQueryRequest extends EbXMLSlotList {
/**
* @return the ebXML object wrapped by this object.
*/
Object getInternal();
E getInternal();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
package org.openehealth.ipf.commons.ihe.xds.core.ebxml;


import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.ProvideAndRegisterDocumentSetRequestType;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RemoveDocumentsRequestType;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetRequestType;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetResponseType;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.RemoveObjectsRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryResponse;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryResponseType;
import org.openehealth.ipf.commons.ihe.xds.core.stub.xdsi.RetrieveImagingDocumentSetRequestType;

/**
* Serves as a factory for ebXML objects.
* <p>
Expand Down Expand Up @@ -72,39 +83,39 @@ public interface EbXMLFactory {
* Creates a new request to submit objects.
* @return the created object.
*/
EbXMLSubmitObjectsRequest createSubmitObjectsRequest();
EbXMLSubmitObjectsRequest<SubmitObjectsRequest> createSubmitObjectsRequest();

/**
* Creates a new request to provide and register documents.
* @param library
* the object library to use.
* @return the created object.
*/
EbXMLProvideAndRegisterDocumentSetRequest createProvideAndRegisterDocumentSetRequest(EbXMLObjectLibrary library);
EbXMLProvideAndRegisterDocumentSetRequest<ProvideAndRegisterDocumentSetRequestType> createProvideAndRegisterDocumentSetRequest(EbXMLObjectLibrary library);

/**
* Creates a new request to retrieve documents.
* @return the created object.
*/
EbXMLNonconstructiveDocumentSetRequest createRetrieveDocumentSetRequest();
EbXMLNonconstructiveDocumentSetRequest<RetrieveDocumentSetRequestType> createRetrieveDocumentSetRequest();

/**
* Creates a new request to remove documents.
* @return the created object.
*/
EbXMLNonconstructiveDocumentSetRequest createRemoveDocumentsRequest();
EbXMLNonconstructiveDocumentSetRequest<RemoveDocumentsRequestType> createRemoveDocumentsRequest();

/**
* Creates a new request to retrieve imaging documents.
* @return the created object.
*/
EbXMLRetrieveImagingDocumentSetRequest createRetrieveImagingDocumentSetRequest();
EbXMLRetrieveImagingDocumentSetRequest<RetrieveImagingDocumentSetRequestType> createRetrieveImagingDocumentSetRequest();

/**
* Creates a new request to query a registry.
* @return the created object.
*/
EbXMLAdhocQueryRequest createAdhocQueryRequest();
EbXMLAdhocQueryRequest<AdhocQueryRequest> createAdhocQueryRequest();

/**
* Creates a new response for a query request.
Expand All @@ -119,19 +130,19 @@ public interface EbXMLFactory {
* therefore the object library would produce unwanted query results.
* @return the created object.
*/
EbXMLQueryResponse createAdhocQueryResponse(EbXMLObjectLibrary objectLibrary, boolean returnsObjectRefs);
EbXMLQueryResponse<AdhocQueryResponse> createAdhocQueryResponse(EbXMLObjectLibrary objectLibrary, boolean returnsObjectRefs);

/**
* Creates a new response for a registry request.
* @return the created object.
*/
EbXMLRegistryResponse createRegistryResponse();
EbXMLRegistryResponse<RegistryResponseType> createRegistryResponse();

/**
* Creates a new response for a retrieve document request.
* @return the created object.
*/
EbXMLRetrieveDocumentSetResponse createRetrieveDocumentSetResponse();
EbXMLRetrieveDocumentSetResponse<RetrieveDocumentSetResponseType> createRetrieveDocumentSetResponse();

/**
* Creates a new registry error object.
Expand All @@ -143,5 +154,5 @@ public interface EbXMLFactory {
* Creates a new remove metadata request.
* @return the created object.
*/
EbXMLRemoveMetadataRequest createRemoveMetadataRequest();
EbXMLRemoveMetadataRequest<RemoveObjectsRequest> createRemoveMetadataRequest();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* abstraction of the ebXML data structure.
* @author Jens Riemschneider
*/
public interface EbXMLNonconstructiveDocumentSetRequest {
public interface EbXMLNonconstructiveDocumentSetRequest<E> {
/**
* Sets the documents of the request.
* @param documents
Expand All @@ -42,5 +42,5 @@ public interface EbXMLNonconstructiveDocumentSetRequest {
/**
* @return the ebXML object being wrapped by this class.
*/
Object getInternal();
E getInternal();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* abstraction of the ebXML data structure.
* @author Jens Riemschneider
*/
public interface EbXMLProvideAndRegisterDocumentSetRequest extends EbXMLSubmitObjectsRequest {
public interface EbXMLProvideAndRegisterDocumentSetRequest<E> extends EbXMLSubmitObjectsRequest<E> {
/**
* @return the documents contained in the request. This map is read-only.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* abstraction of the ebXML data structure.
* @author Jens Riemschneider
*/
public interface EbXMLQueryResponse extends EbXMLObjectContainer, EbXMLRegistryResponse {
public interface EbXMLQueryResponse<E> extends EbXMLObjectContainer, EbXMLRegistryResponse<E> {
/**
* Adds an object reference to the response.
* @param ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Represents a ebXML {@code RegistryResponseType}.
* @author Jens Riemschneider
*/
public interface EbXMLRegistryResponse {
public interface EbXMLRegistryResponse<E> {
/**
* @param status
* the status result.
Expand All @@ -49,5 +49,5 @@ public interface EbXMLRegistryResponse {
/**
* @return the ebXML object being wrapped by this class.
*/
Object getInternal();
E getInternal();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* abstraction of the ebXML data structure.
* @author Jens Riemschneider
*/
public interface EbXMLRemoveMetadataRequest extends EbXMLAdhocQueryRequest {
public interface EbXMLRemoveMetadataRequest<E> extends EbXMLAdhocQueryRequest<E> {

/**
* Sets the object references of the remove request.
Expand All @@ -52,9 +52,4 @@ public interface EbXMLRemoveMetadataRequest extends EbXMLAdhocQueryRequest {
*/
void setDeletionScope(String deletionScope);

/**
* @return the wrapped ebXML representation of this request.
*/
@Override
Object getInternal();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* abstraction of the ebXML data structure.
* @author Jens Riemschneider
*/
public interface EbXMLRetrieveDocumentSetResponse extends EbXMLRegistryResponse {
public interface EbXMLRetrieveDocumentSetResponse<E> extends EbXMLRegistryResponse<E> {
/**
* Sets the documents returned by the response.
* @param documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @author Clay Sebourn
*/
public interface EbXMLRetrieveImagingDocumentSetRequest
public interface EbXMLRetrieveImagingDocumentSetRequest<E>
{
/**
* Sets the retrieveStudies of the request.
Expand All @@ -54,5 +54,5 @@ public interface EbXMLRetrieveImagingDocumentSetRequest
/**
* @return the ebXML object being wrapped by this class.
*/
Object getInternal();
E getInternal();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
* abstraction of the ebXML data structure.
* @author Jens Riemschneider
*/
public interface EbXMLSubmitObjectsRequest extends EbXMLObjectContainer, EbXMLSlotList {
public interface EbXMLSubmitObjectsRequest<E> extends EbXMLObjectContainer, EbXMLSlotList {
/**
* @return the wrapped ebXML representation of this request.
*/
Object getInternal();
E getInternal();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Encapsulation of {@link AdhocQueryRequest}.
* @author Jens Riemschneider
*/
public class EbXMLAdhocQueryRequest30 implements EbXMLAdhocQueryRequest {
public class EbXMLAdhocQueryRequest30 implements EbXMLAdhocQueryRequest<AdhocQueryRequest> {
private final AdhocQueryRequest request;

/**
Expand All @@ -34,7 +34,7 @@ public class EbXMLAdhocQueryRequest30 implements EbXMLAdhocQueryRequest {
* the ebXML 3.0 object.
*/
public EbXMLAdhocQueryRequest30(AdhocQueryRequest request) {
this.request = requireNonNull(request, "request cannot be null");;
this.request = requireNonNull(request, "request cannot be null");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLRetrieveDocumentSetResponse;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLRetrieveImagingDocumentSetRequest;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLSubmitObjectsRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.RemoveObjectsRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryResponse;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryResponseType;
import org.openehealth.ipf.commons.ihe.xds.core.stub.xdsi.RetrieveImagingDocumentSetRequestType;


Expand Down Expand Up @@ -95,32 +99,32 @@ public EbXMLAssociation createAssociation(String id, EbXMLObjectLibrary objectLi
}

@Override
public EbXMLSubmitObjectsRequest createSubmitObjectsRequest() {
public EbXMLSubmitObjectsRequest<SubmitObjectsRequest> createSubmitObjectsRequest() {
var request = LCM_FACTORY.createSubmitObjectsRequest();
request.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
request.setRequestSlotList(RIM_FACTORY.createSlotListType());
return new EbXMLSubmitObjectsRequest30(request, createObjectLibrary());
}

@Override
public EbXMLProvideAndRegisterDocumentSetRequest createProvideAndRegisterDocumentSetRequest(EbXMLObjectLibrary objectLibrary) {
public EbXMLProvideAndRegisterDocumentSetRequest<ProvideAndRegisterDocumentSetRequestType> createProvideAndRegisterDocumentSetRequest(EbXMLObjectLibrary objectLibrary) {
var request = new ProvideAndRegisterDocumentSetRequestType();
request.setSubmitObjectsRequest((SubmitObjectsRequest) createSubmitObjectsRequest().getInternal());
request.setSubmitObjectsRequest(createSubmitObjectsRequest().getInternal());
return new EbXMLProvideAndRegisterDocumentSetRequest30(request, objectLibrary);
}

@Override
public EbXMLNonconstructiveDocumentSetRequest createRetrieveDocumentSetRequest() {
public EbXMLNonconstructiveDocumentSetRequest<RetrieveDocumentSetRequestType> createRetrieveDocumentSetRequest() {
return new EbXMLNonconstructiveDocumentSetRequest30<>(new RetrieveDocumentSetRequestType());
}

@Override
public EbXMLNonconstructiveDocumentSetRequest createRemoveDocumentsRequest() {
public EbXMLNonconstructiveDocumentSetRequest<RemoveDocumentsRequestType> createRemoveDocumentsRequest() {
return new EbXMLNonconstructiveDocumentSetRequest30<>(new RemoveDocumentsRequestType());
}

@Override
public EbXMLRetrieveImagingDocumentSetRequest createRetrieveImagingDocumentSetRequest() {
public EbXMLRetrieveImagingDocumentSetRequest<RetrieveImagingDocumentSetRequestType> createRetrieveImagingDocumentSetRequest() {
return new EbXMLRetrieveImagingDocumentSetRequest30(new RetrieveImagingDocumentSetRequestType());
}

Expand All @@ -130,19 +134,19 @@ public EbXMLObjectLibrary createObjectLibrary() {
}

@Override
public EbXMLRegistryResponse createRegistryResponse() {
public EbXMLRegistryResponse<RegistryResponseType> createRegistryResponse() {
return new EbXMLRegistryResponse30(RS_FACTORY.createRegistryResponseType());
}

@Override
public EbXMLRetrieveDocumentSetResponse createRetrieveDocumentSetResponse() {
public EbXMLRetrieveDocumentSetResponse<RetrieveDocumentSetResponseType> createRetrieveDocumentSetResponse() {
var response = new RetrieveDocumentSetResponseType();
response.setRegistryResponse(RS_FACTORY.createRegistryResponseType());
return new EbXMLRetrieveDocumentSetResponse30(response);
}

@Override
public EbXMLAdhocQueryRequest createAdhocQueryRequest() {
public EbXMLAdhocQueryRequest<AdhocQueryRequest> createAdhocQueryRequest() {
var request = QUERY_FACTORY.createAdhocQueryRequest();

var responseOption = QUERY_FACTORY.createResponseOptionType();
Expand All @@ -156,7 +160,7 @@ public EbXMLAdhocQueryRequest createAdhocQueryRequest() {
}

@Override
public EbXMLQueryResponse createAdhocQueryResponse(EbXMLObjectLibrary objectLibrary, boolean returnsObjectRefs) {
public EbXMLQueryResponse<AdhocQueryResponse> createAdhocQueryResponse(EbXMLObjectLibrary objectLibrary, boolean returnsObjectRefs) {
var response = QUERY_FACTORY.createAdhocQueryResponse();
response.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
return new EbXMLQueryResponse30(response, objectLibrary);
Expand All @@ -169,7 +173,7 @@ public EbXMLRegistryError createRegistryError() {
}

@Override
public EbXMLRemoveMetadataRequest createRemoveMetadataRequest() {
public EbXMLRemoveMetadataRequest<RemoveObjectsRequest> createRemoveMetadataRequest() {
var removeObjectsRequest = LCM_FACTORY.createRemoveObjectsRequest();
return new EbXMLRemoveMetadataRequest30(removeObjectsRequest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,8 @@ public LocalizedString getSingleLocalizedString() {
}

var locals = international.getLocalizedString();
if (locals == null || locals.isEmpty()) {
return null;
}
return locals == null || locals.isEmpty() ? null : createLocalizedString(locals.get(0));

return createLocalizedString(locals.get(0));
}

private LocalizedString createLocalizedString(LocalizedStringType localizedEbRS30) {
Expand Down
Loading

0 comments on commit 7254b49

Please sign in to comment.