View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30;
17  
18  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.*;
19  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.RemoveObjectsRequest;
20  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest;
21  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryRequest;
22  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryResponse;
23  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.ResponseOptionType;
24  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.*;
25  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryError;
26  
27  /**
28   * Factory for EbXML 3.0 objects.
29   * @author Jens Riemschneider
30   */
31  public class EbXMLFactory30 implements EbXMLFactory {
32      /**
33       * The factory to create objects of the query namespace.
34       */
35      public final static org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.ObjectFactory QUERY_FACTORY =
36          new org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.ObjectFactory();
37  
38      /**
39       * The factory to create objects of the rim namespace.
40       */
41      public final static org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.ObjectFactory RIM_FACTORY =
42          new org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.ObjectFactory();
43  
44      /**
45       * The factory to create objects of the rs namespace.
46       */
47      public final static org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.ObjectFactory RS_FACTORY =
48          new org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.ObjectFactory();
49  
50      /**
51       * The factory to create objects of the lcm namespace.
52       */
53      public final static org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.ObjectFactory LCM_FACTORY =
54          new org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.ObjectFactory();
55  
56      @Override
57      public EbXMLClassification createClassification(EbXMLObjectLibrary objectLibrary) {
58          return new EbXMLClassification30(RIM_FACTORY.createClassificationType());
59      }
60  
61      @Override
62      public EbXMLExtrinsicObject createExtrinsic(String id, EbXMLObjectLibrary objectLibrary) {
63          ExtrinsicObjectType extrinsicObjectType = RIM_FACTORY.createExtrinsicObjectType();
64          extrinsicObjectType.setId(id);
65          objectLibrary.put(id, extrinsicObjectType);
66          return new EbXMLExtrinsicObject30(extrinsicObjectType, objectLibrary);
67      }
68  
69      @Override
70      public EbXMLRegistryPackage createRegistryPackage(String id, EbXMLObjectLibrary objectLibrary) {
71          RegistryPackageType registryPackageType = RIM_FACTORY.createRegistryPackageType();
72          registryPackageType.setId(id);
73          objectLibrary.put(id, registryPackageType);
74          return new EbXMLRegistryPackage30(registryPackageType, objectLibrary);
75      }
76  
77      @Override
78      public EbXMLAssociation createAssociation(String id, EbXMLObjectLibrary objectLibrary) {
79          AssociationType1 association = RIM_FACTORY.createAssociationType1();
80          association.setId(id);
81          objectLibrary.put(id, association);
82          return new EbXMLAssociation30(association, objectLibrary);
83      }
84      
85      @Override
86      public EbXMLSubmitObjectsRequest createSubmitObjectsRequest() {
87          SubmitObjectsRequest request = LCM_FACTORY.createSubmitObjectsRequest();
88          request.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
89          request.setRequestSlotList(RIM_FACTORY.createSlotListType());
90          return new EbXMLSubmitObjectsRequest30(request, createObjectLibrary());
91      }
92  
93      @Override
94      public EbXMLProvideAndRegisterDocumentSetRequest createProvideAndRegisterDocumentSetRequest(EbXMLObjectLibrary objectLibrary) {
95          ProvideAndRegisterDocumentSetRequestType request = new ProvideAndRegisterDocumentSetRequestType();
96          request.setSubmitObjectsRequest((SubmitObjectsRequest) createSubmitObjectsRequest().getInternal());
97          return new EbXMLProvideAndRegisterDocumentSetRequest30(request, objectLibrary);
98      }
99  
100     @Override
101     public EbXMLNonconstructiveDocumentSetRequest createRetrieveDocumentSetRequest() {
102         return new EbXMLNonconstructiveDocumentSetRequest30<>(new RetrieveDocumentSetRequestType());
103     }
104 
105     @Override
106     public EbXMLNonconstructiveDocumentSetRequest createRemoveDocumentsRequest() {
107         return new EbXMLNonconstructiveDocumentSetRequest30<>(new RemoveDocumentsRequestType());
108     }
109 
110     @Override
111     public EbXMLRetrieveImagingDocumentSetRequest createRetrieveImagingDocumentSetRequest() {
112         return new EbXMLRetrieveImagingDocumentSetRequest30(new RetrieveImagingDocumentSetRequestType());
113     }
114 
115     @Override
116     public EbXMLObjectLibrary createObjectLibrary() {
117         return new EbXMLObjectLibrary();
118     }
119 
120     @Override
121     public EbXMLRegistryResponse createRegistryResponse() {
122         return new EbXMLRegistryResponse30(RS_FACTORY.createRegistryResponseType());
123     }
124 
125     @Override
126     public EbXMLRetrieveDocumentSetResponse createRetrieveDocumentSetResponse() {
127         RetrieveDocumentSetResponseType response = new RetrieveDocumentSetResponseType();
128         response.setRegistryResponse(RS_FACTORY.createRegistryResponseType());
129         return new EbXMLRetrieveDocumentSetResponse30(response);
130     }
131     
132     @Override
133     public EbXMLAdhocQueryRequest createAdhocQueryRequest() {
134         AdhocQueryRequest request = QUERY_FACTORY.createAdhocQueryRequest();
135         
136         ResponseOptionType responseOption = QUERY_FACTORY.createResponseOptionType();
137         responseOption.setReturnComposedObjects(true);
138         request.setResponseOption(responseOption);
139 
140         AdhocQueryType query = RIM_FACTORY.createAdhocQueryType();
141         request.setAdhocQuery(query);
142         
143         return new EbXMLAdhocQueryRequest30(request);        
144     }
145     
146     @Override
147     public EbXMLQueryResponse createAdhocQueryResponse(EbXMLObjectLibrary objectLibrary, boolean returnsObjectRefs) {
148         AdhocQueryResponse response = QUERY_FACTORY.createAdhocQueryResponse();
149         response.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
150         return new EbXMLQueryResponse30(response, objectLibrary);
151     }
152 
153     @Override
154     public EbXMLRegistryError createRegistryError() {
155         RegistryError registryError = RS_FACTORY.createRegistryError();
156         return new EbXMLRegistryError30(registryError);
157     }
158 
159     @Override
160     public EbXMLRemoveMetadataRequest createRemoveMetadataRequest() {
161         RemoveObjectsRequest removeObjectsRequest = LCM_FACTORY.createRemoveObjectsRequest();
162         removeObjectsRequest.setAdhocQuery(RIM_FACTORY.createAdhocQueryType());
163         return new EbXMLRemoveMetadataRequest30(removeObjectsRequest);
164     }
165 }