1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 | package gov.hhs.fha.nhinc.subscription.dte;
|
---|
6 |
|
---|
7 | import gov.hhs.fha.nhinc.common.subscription.SubscriptionItemType;
|
---|
8 | import gov.hhs.fha.nhinc.common.subscription.SubscriptionReferenceType;
|
---|
9 | import gov.hhs.fha.nhinc.subscription.*;
|
---|
10 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType;
|
---|
11 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType.DocumentRequest;
|
---|
12 | import javax.xml.bind.JAXBElement;
|
---|
13 | import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
---|
14 | import org.oasis_open.docs.wsn.b_2.*;
|
---|
15 | import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType.Message;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | *
|
---|
19 | * @author rayj
|
---|
20 | */
|
---|
21 | public class NotifyHelper {
|
---|
22 |
|
---|
23 | public static SubscriptionReferenceType transformNhinNotifyToInternalSubscriptionReference(Notify notify) {
|
---|
24 | return SubscriptionReferenceHelper.transformNhinSubscriptionReferenceToInternalSubscriptionReference(NotifyHelper.getSubscriptionReference(notify));
|
---|
25 | }
|
---|
26 |
|
---|
27 | public static NotificationMessageHolderType getNotificationMessageHolder(Notify notify) {
|
---|
28 | NotificationMessageHolderType notificationMessageHolder = null;
|
---|
29 | if ((notify != null) && (notify.getNotificationMessage() != null) && (notify.getNotificationMessage().size() >= 1)) {
|
---|
30 | notificationMessageHolder = notify.getNotificationMessage().get(0);
|
---|
31 | }
|
---|
32 | return notificationMessageHolder;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public static Message getMessage(Notify notify) {
|
---|
36 | NotificationMessageHolderType notificationMessageHolder = getNotificationMessageHolder(notify);
|
---|
37 | Message message = null;
|
---|
38 | if (notificationMessageHolder != null) {
|
---|
39 | message = notificationMessageHolder.getMessage();
|
---|
40 | }
|
---|
41 | return message;
|
---|
42 | }
|
---|
43 |
|
---|
44 | public static W3CEndpointReference getSubscriptionReference(Notify notify) {
|
---|
45 | W3CEndpointReference subscriptionReference = null;
|
---|
46 |
|
---|
47 | //assume that we only have one notification per notify
|
---|
48 | NotificationMessageHolderType notificationMessageHolder = getNotificationMessageHolder(notify);
|
---|
49 | if (notificationMessageHolder != null) {
|
---|
50 | subscriptionReference = notificationMessageHolder.getSubscriptionReference();
|
---|
51 | }
|
---|
52 | return subscriptionReference;
|
---|
53 | }
|
---|
54 |
|
---|
55 | public static org.oasis_open.docs.wsn.b_2.Notify transformInternalSubscriptionItemToNhinNotify(SubscriptionItemType subscriptionItem) {
|
---|
56 | Notify nhinNotify = new Notify();
|
---|
57 |
|
---|
58 | if (subscriptionItem != null) {
|
---|
59 | NotificationMessageHolderType notificationMessageHolder = new NotificationMessageHolderType();
|
---|
60 | nhinNotify.getNotificationMessage().add(notificationMessageHolder);
|
---|
61 |
|
---|
62 | if (subscriptionItem.getSubscriptionReference() != null) {
|
---|
63 | W3CEndpointReference subscriptionReference = SubscriptionReferenceHelper.createNhinSubscriptionReference(subscriptionItem.getSubscriptionReference());
|
---|
64 | notificationMessageHolder.setSubscriptionReference(subscriptionReference);
|
---|
65 | }
|
---|
66 |
|
---|
67 | Message notificationMessage = new Message();
|
---|
68 | notificationMessageHolder.setMessage(notificationMessage);
|
---|
69 |
|
---|
70 | if ((subscriptionItem.getSubscriptionCriteria() != null)) {
|
---|
71 | gov.hhs.fha.nhinc.common.subscription.TopicExpressionType internalTopicExpression = subscriptionItem.getSubscriptionCriteria().getTopicExpression();
|
---|
72 | if (internalTopicExpression != null) {
|
---|
73 | org.oasis_open.docs.wsn.b_2.TopicExpressionType nhinTopicExpression = new org.oasis_open.docs.wsn.b_2.TopicExpressionType();
|
---|
74 |
|
---|
75 | //nhinTopicExpression.setValue(internalTopicExpression.getValue());
|
---|
76 | nhinTopicExpression.getContent().add(internalTopicExpression.getValue());
|
---|
77 | nhinTopicExpression.setDialect(internalTopicExpression.getDialect());
|
---|
78 |
|
---|
79 | notificationMessageHolder.setTopic(nhinTopicExpression);
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | // RetrieveDocumentSetRequestType retrieveDocumentSetRequest = CreateRetrieveDocumentSetRequest(subscriptionItem);
|
---|
84 | // AppendRetrieveDocumentSetRequest(notificationMessage, retrieveDocumentSetRequest);
|
---|
85 | }
|
---|
86 |
|
---|
87 | return nhinNotify;
|
---|
88 | }
|
---|
89 |
|
---|
90 | public static void AppendRetrieveDocumentSetRequest(Message notifyMessage, RetrieveDocumentSetRequestType retrieveDocumentSetRequest) {
|
---|
91 | ihe.iti.xds_b._2007.ObjectFactory factory = new ihe.iti.xds_b._2007.ObjectFactory();
|
---|
92 | JAXBElement<RetrieveDocumentSetRequestType> retrieveDocumentSetRequestTypeElem = factory.createRetrieveDocumentSetRequest(retrieveDocumentSetRequest);
|
---|
93 | notifyMessage.setAny(retrieveDocumentSetRequestTypeElem);
|
---|
94 |
|
---|
95 | }
|
---|
96 |
|
---|
97 | public static void AppendCdcBioPackage(Message notifyMessage, JAXBElement<byte[]> cdcBioPackageElement) {
|
---|
98 | if ((cdcBioPackageElement != null) && (cdcBioPackageElement instanceof JAXBElement)) {
|
---|
99 | Object anyvalue = cdcBioPackageElement.getValue();
|
---|
100 | if (anyvalue instanceof byte[]) {
|
---|
101 | byte[] bytearray = (byte[]) anyvalue;
|
---|
102 | AppendCdcBioPackage(notifyMessage, bytearray);
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|
106 |
|
---|
107 | public static void AppendCdcBioPackage(Message notifyMessage, byte[] cdcBioPackage) {
|
---|
108 | gov.hhs.healthit.nhin.cdc.ObjectFactory factory = new gov.hhs.healthit.nhin.cdc.ObjectFactory();
|
---|
109 | JAXBElement<byte[]> cdcBioPackageElement = factory.createCdcBioPackagePayload(cdcBioPackage);
|
---|
110 | notifyMessage.setAny(cdcBioPackageElement);
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | //todo: will probably need to pass in additional data on the wsdl interface to fulfill this
|
---|
115 | // public static RetrieveDocumentSetRequestType CreateRetrieveDocumentSetRequest(SubscriptionItemType subscriptionItem) {
|
---|
116 | // RetrieveDocumentSetRequestType retrieveDocumentSetRequest = new RetrieveDocumentSetRequestType();
|
---|
117 | //
|
---|
118 | // DocumentRequest documentRequest = new RetrieveDocumentSetRequestType.DocumentRequest();
|
---|
119 | // retrieveDocumentSetRequest.getDocumentRequest().add(documentRequest);
|
---|
120 | //
|
---|
121 | // documentRequest.setDocumentUniqueId("docid");
|
---|
122 | // documentRequest.setHomeCommunityId("homecommunity");
|
---|
123 | // documentRequest.setRepositoryUniqueId("repositoryid");
|
---|
124 | //
|
---|
125 | // return null;
|
---|
126 | // }
|
---|
127 | }
|
---|