001: /**
002: *
003: * Copyright 2004 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.ws.scout.registry.infomodel;
017:
018: import javax.xml.registry.JAXRException;
019: import javax.xml.registry.LifeCycleManager;
020: import javax.xml.registry.infomodel.Association;
021: import javax.xml.registry.infomodel.Concept;
022: import javax.xml.registry.infomodel.InternationalString;
023: import javax.xml.registry.infomodel.Key;
024: import javax.xml.registry.infomodel.RegistryObject;
025:
026: /**
027: * Implements JAXR Association Interface.
028: * For futher details, look into the JAXR API Javadoc.
029: *
030: * @author Anil Saldhana <anil@apache.org>
031: */
032: public class AssociationImpl extends RegistryObjectImpl implements
033: Association {
034: private Concept type = null;
035: private RegistryObject source = null;
036: private RegistryObject target = null;
037: private boolean isConfirmed = true;
038: private boolean isConfirmedBySourceOwner = true;
039: private boolean isConfirmedByTargetOwner = true;
040: private boolean isExtramural = true;
041:
042: public AssociationImpl(LifeCycleManager lifeCycleManager) {
043: super (lifeCycleManager);
044: }
045:
046: public AssociationImpl(LifeCycleManager lifeCycleManager,
047: InternationalString n) {
048: super (lifeCycleManager, n);
049: }
050:
051: public Concept getAssociationType() throws JAXRException {
052: return type;
053: }
054:
055: public RegistryObject getSourceObject() throws JAXRException {
056: return source;
057: }
058:
059: public RegistryObject getTargetObject() throws JAXRException {
060: return target;
061: }
062:
063: public boolean isConfirmed() throws JAXRException {
064: return isConfirmed;
065: }
066:
067: public boolean isConfirmedBySourceOwner() throws JAXRException {
068: return isConfirmedBySourceOwner;
069: }
070:
071: public boolean isConfirmedByTargetOwner() throws JAXRException {
072: return isConfirmedByTargetOwner;
073: }
074:
075: public boolean isExtramural() throws JAXRException {
076: return isExtramural;
077: }
078:
079: public void setAssociationType(Concept concept)
080: throws JAXRException {
081: type = concept;
082: }
083:
084: public void setSourceObject(RegistryObject ro) throws JAXRException {
085: source = ro;
086: }
087:
088: public void setTargetObject(RegistryObject ro) throws JAXRException {
089: target = ro;
090: }
091:
092: /**
093: * There is an impedance mismatch as specified in the JAXR specification
094: * Section D-11
095: */
096: public Key getKey() {
097: String id = null;
098: Key key = null;
099: try {
100: id = source.getKey().getId();
101: id += ":" + target.getKey().getId();
102: Key k = null;
103: if (type != null)
104: k = type.getKey();
105: if (k == null || k.getId() == "")
106: id += ":NULL";
107: else
108: id += ":" + k.getId();
109: id += ":" + "Concept"; //UDDI: KeyedReference->Key Name
110: //String val = "NULL"; KS unused
111: if (type != null)
112: id += ":" + type.getValue();
113: else
114: id += ":NULL";
115:
116: } catch (JAXRException e) {
117: e.printStackTrace();
118: }
119:
120: if (id != null)
121: key = new KeyImpl(id);
122: return key;
123: }
124:
125: public void setConfirmed(boolean b) {
126: this .isConfirmed = b;
127: }
128:
129: public void setConfirmedBySourceOwner(boolean b) {
130: isConfirmedBySourceOwner = b;
131: }
132:
133: public void setConfirmedByTargetOwner(boolean b) {
134: isConfirmedByTargetOwner = b;
135: }
136:
137: public void setExtramural(boolean b) {
138: isExtramural = b;
139: }
140:
141: }
|