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 lombok.experimental.Delegate;
19  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLClassification;
20  import org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString;
21  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.ClassificationType;
22  
23  import java.util.UUID;
24  
25  import static org.apache.commons.lang3.Validate.notNull;
26  
27  /**
28   * Encapsulation of {@link ClassificationType}.
29   * @author Jens Riemschneider
30   */
31  public class EbXMLClassification30 implements EbXMLClassification {
32      private final ClassificationType classification;
33      
34      /**
35       * Constructs a classification by wrapping the given ebXML 3.0 object.
36       * @param classification
37       *          the object to wrap.
38       */
39      public EbXMLClassification30(ClassificationType classification) {
40          notNull(classification, "classification cannot be null");        
41          this.classification = classification;
42      }
43      
44      @Override
45      public String getClassificationScheme() {
46          return classification.getClassificationScheme();
47      }
48  
49      @Override
50      public String getClassifiedObject() {
51          return classification.getClassifiedObject();
52      }
53  
54      @Override
55      public void setClassificationScheme(String classificationScheme) {
56          classification.setClassificationScheme(classificationScheme);
57      }
58  
59      @Override
60      public void setClassifiedObject(String classifiedObject) {
61          classification.setClassifiedObject(classifiedObject);
62      }
63  
64      @Override
65      public String getNodeRepresentation() {
66          return classification.getNodeRepresentation();
67      }
68  
69      @Override
70      public void setNodeRepresentation(String nodeRepresentation) {
71          classification.setNodeRepresentation(nodeRepresentation);        
72      }
73  
74      @Override
75      public LocalizedString getName() {
76          return getNameAsInternationalString().getSingleLocalizedString();
77      }
78  
79      @Override
80      public EbXMLInternationalString30 getNameAsInternationalString() {
81          return new EbXMLInternationalString30(classification.getName());
82      }
83  
84      @Override
85      public void setName(LocalizedString name) {
86          classification.setName(new EbXMLInternationalString30(name).getInternal());
87      }
88      
89      @Override
90      public void setClassificationNode(String classificationNode) {
91          classification.setClassificationNode(classificationNode);
92      }
93      
94      @Override
95      public String getClassificationNode() {
96          return classification.getClassificationNode();
97      }
98  
99      /**
100      * @return the ebXML 3.0 object being wrapped by this class.
101      */
102     ClassificationType getInternal() {
103         return classification;
104     }
105 
106     /**
107      * Implements the {@link org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLSlotList} interface
108      * by delegating the calls to a "proper" slot list.
109      */
110     @Delegate
111     private EbXMLSlotList30 getSlotList() {
112         return new EbXMLSlotList30(classification.getSlot());
113     }
114 
115     @Override
116     public void assignUniqueId() {
117         classification.setId("urn:uuid:" + UUID.randomUUID().toString());
118     }
119 }