This project has retired. For details please refer to its Attic page.
AssociationImpl xref
View Javadoc
1   /**
2    *
3    * Copyright 2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.ws.scout.registry.infomodel;
18  
19  import javax.xml.registry.JAXRException;
20  import javax.xml.registry.LifeCycleManager;
21  import javax.xml.registry.infomodel.Association;
22  import javax.xml.registry.infomodel.Concept;
23  import javax.xml.registry.infomodel.InternationalString;
24  import javax.xml.registry.infomodel.Key;
25  import javax.xml.registry.infomodel.RegistryObject;
26  
27  /**
28   * Implements JAXR Association Interface.
29   * For futher details, look into the JAXR API Javadoc.
30   *
31   * @author Anil Saldhana  <anil@apache.org>
32   */
33  public class AssociationImpl extends RegistryObjectImpl implements Association
34  {
35      private Concept type = null;
36      private RegistryObject source = null;
37      private RegistryObject target = null;
38      private boolean isConfirmed = true;
39      private boolean isConfirmedBySourceOwner = true;
40      private boolean isConfirmedByTargetOwner = true;
41      private boolean isExtramural = true;
42  
43      public AssociationImpl(LifeCycleManager lifeCycleManager)
44      {
45          super(lifeCycleManager);
46      }
47  
48      public AssociationImpl(LifeCycleManager lifeCycleManager, InternationalString n)
49      {
50          super(lifeCycleManager, n);
51      }
52  
53      public Concept getAssociationType() throws JAXRException
54      {
55          return type;
56      }
57  
58      public RegistryObject getSourceObject() throws JAXRException
59      {
60          return source;
61      }
62  
63      public RegistryObject getTargetObject() throws JAXRException
64      {
65          return target;
66      }
67  
68      public boolean isConfirmed() throws JAXRException
69      {
70          return isConfirmed;
71      }
72  
73      public boolean isConfirmedBySourceOwner() throws JAXRException
74      {
75          return isConfirmedBySourceOwner;
76      }
77  
78      public boolean isConfirmedByTargetOwner() throws JAXRException
79      {
80          return isConfirmedByTargetOwner;
81      }
82  
83      public boolean isExtramural() throws JAXRException
84      {
85          return isExtramural;
86      }
87  
88      public void setAssociationType(Concept concept) throws JAXRException
89      {
90          type = concept;
91      }
92  
93      public void setSourceObject(RegistryObject ro) throws JAXRException
94      {
95          source = ro;
96      }
97  
98      public void setTargetObject(RegistryObject ro) throws JAXRException
99      {
100         target = ro;
101     }
102 
103    /**
104     * There is an impedance mismatch as specified in the JAXR specification
105     * Section D-11
106     */
107    public Key getKey()
108    {
109       String id = null;
110       Key key = null;
111       try
112       {
113          id = source.getKey().getId();
114          id += "|" + target.getKey().getId();
115          Key k = null;
116          if(type != null ) k = type.getKey();
117          if(k == null || k.getId() == "" ) id +="|NULL";
118          else
119           id+="|"+k.getId();
120          id += "|" + "Concept";  //UDDI: KeyedReference->Key Name
121          //String val = "NULL"; KS unused
122          if(type!= null)  id += "|" + type.getValue();
123          else  id +="|NULL";
124 
125       }
126       catch (JAXRException e)
127       {
128         throw new RuntimeException(e);
129       }
130 
131       if(id != null) key = new KeyImpl(id);
132       return key;
133    }
134 
135    public void setConfirmed(boolean b)
136    {
137       this.isConfirmed = b;
138    }
139 
140    public void setConfirmedBySourceOwner(boolean b)
141    {
142       isConfirmedBySourceOwner = b;
143    }
144 
145    public void setConfirmedByTargetOwner(boolean b)
146    {
147       isConfirmedByTargetOwner = b;
148    }
149 
150    public void setExtramural(boolean b)
151    {
152       isExtramural = b;
153    } 
154 
155 }