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.EbXMLAssociation;
19  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLObjectLibrary;
20  import org.openehealth.ipf.commons.ihe.xds.core.metadata.AssociationType;
21  import org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus;
22  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.AssociationType1;
23  
24  import java.util.List;
25  import java.util.Map;
26  
27  import static org.openehealth.ipf.commons.ihe.xds.core.metadata.Vocabulary.SLOT_NAME_ORIGINAL_STATUS;
28  import static org.openehealth.ipf.commons.ihe.xds.core.metadata.Vocabulary.SLOT_NAME_NEW_STATUS;
29  import static org.openehealth.ipf.commons.ihe.xds.core.metadata.Vocabulary.SLOT_NAME_PREVIOUS_VERSION;
30  
31  /**
32   * Encapsulation of {@link AssociationType1}.
33   * @author Jens Riemschneider
34   */
35  public class EbXMLAssociation30 extends EbXMLRegistryObject30<AssociationType1> implements EbXMLAssociation {
36      /**
37       * Constructs an association by wrapping the given ebXML 3.0 object.
38       * @param association
39       *          the object to wrap.
40       * @param objectLibrary
41       *          the object library to use.
42       */
43      public EbXMLAssociation30(AssociationType1 association, EbXMLObjectLibrary objectLibrary) {
44          super(association, objectLibrary);
45      }
46  
47      @Override
48      public String getSource() {
49          return getInternal().getSourceObject();
50      }
51  
52      @Override
53      public String getTarget() {
54          return getInternal().getTargetObject();
55      }
56  
57      @Override
58      public void setSource(String source) {
59          getInternal().setSourceObject(source);
60      }
61  
62      @Override
63      public void setTarget(String target) {
64          getInternal().setTargetObject(target);
65      }
66  
67      @Override
68      public AssociationType getAssociationType() {
69          return AssociationType.valueOfOpcode30(getInternal().getAssociationType());
70      }
71  
72      @Override
73      public void setAssociationType(AssociationType associationType) {
74          getInternal().setAssociationType(AssociationType.getOpcode30(associationType));
75      }
76  
77      @Override
78      public AvailabilityStatus getStatus() {
79          return AvailabilityStatus.valueOfOpcode(getInternal().getStatus());
80      }
81  
82      @Override
83      public void setStatus(AvailabilityStatus availabilityStatus) {
84          getInternal().setStatus(AvailabilityStatus.toQueryOpcode(availabilityStatus));
85      }
86  
87      @Override
88      public AvailabilityStatus getOriginalStatus() {
89          return AvailabilityStatus.valueOfOpcode(getSingleSlotValue(SLOT_NAME_ORIGINAL_STATUS));
90      }
91  
92      @Override
93      public void setOriginalStatus(AvailabilityStatus status) {
94          if (status != null) {
95              addSlot(SLOT_NAME_ORIGINAL_STATUS, status.getOpcode());
96          }
97      }
98  
99      @Override
100     public AvailabilityStatus getNewStatus() {
101         return AvailabilityStatus.valueOfOpcode(getSingleSlotValue(SLOT_NAME_NEW_STATUS));
102     }
103 
104     @Override
105     public void setNewStatus(AvailabilityStatus status) {
106         if (status != null) {
107             addSlot(SLOT_NAME_NEW_STATUS, status.getOpcode());
108         }
109     }
110 
111     @Override
112     public String getPreviousVersion() {
113         return getSingleSlotValue(SLOT_NAME_PREVIOUS_VERSION);
114     }
115 
116     @Override
117     public void setPreviousVersion(String version) {
118         addSlot(SLOT_NAME_PREVIOUS_VERSION, version);
119     }
120 
121     @Override
122     public Map<String, List<String>> getExtraMetadata() {
123         return getInternal().getExtraMetadata();
124     }
125 
126     @Override
127     public void setExtraMetadata(Map<String, List<String>> map) {
128         getInternal().setExtraMetadata(map);
129     }
130 }