View Javadoc

1   /*
2    wsmo4j - a WSMO API and Reference Implementation
3   
4    Copyright (c) 2004-2005, OntoText Lab. / SIRMA
5   
6    This library is free software; you can redistribute it and/or modify it under
7    the terms of the GNU Lesser General Public License as published by the Free
8    Software Foundation; either version 2.1 of the License, or (at your option)
9    any later version.
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13   details.
14   You should have received a copy of the GNU Lesser General Public License along
15   with this library; if not, write to the Free Software Foundation, Inc.,
16   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17   */
18  
19  package com.ontotext.wsmo4j.mediator;
20  
21  /**
22   * <p>Title: WSMO4J</p>
23   * <p>Description: WSMO API and a Reference Implementation</p>
24   * <p>Copyright:  Copyright (c) 2004-2005</p>
25   * <p>Company: OntoText Lab. / SIRMA </p>
26   * @author not attributable
27   * @version 1.0
28   *
29   */ 
30  import java.util.*;
31  
32  import org.wsmo.common.*;
33  import org.wsmo.common.exception.InvalidModelException;
34  import org.wsmo.common.exception.SynchronisationException;
35  import org.wsmo.mediator.Mediator;
36  
37  import com.ontotext.wsmo4j.common.TopEntityImpl;
38  
39  
40  public class MediatorImpl extends TopEntityImpl
41          implements Mediator {
42  
43      protected LinkedHashSet <IRI> sources;
44      private IRI target;
45      private IRI mediationService;
46  
47  
48      public MediatorImpl(IRI mediatorIRI) {
49          super(mediatorIRI);
50          sources = new LinkedHashSet <IRI> ();
51      }
52  
53      public Set <IRI> listSources() throws SynchronisationException {
54          return Collections.unmodifiableSet(sources);
55      }
56  
57      public void addSource(IRI iri)
58              throws SynchronisationException, InvalidModelException {
59          if (iri == null) {
60              throw new IllegalArgumentException();
61          }
62          if (sources.contains(iri)){
63              return;
64          }
65          if (!sources.isEmpty()){
66              throw new InvalidModelException("Only OO Mediators have multiple source");
67          }
68          sources.add(iri);
69      }
70  
71      public void removeSource(IRI iri)
72              throws SynchronisationException, InvalidModelException {
73          if (iri == null) {
74              throw new IllegalArgumentException();
75          }
76          sources.remove(iri);
77      }
78  
79      public IRI getTarget() {
80          return target;
81      }
82  
83      public void setTarget(IRI target) {
84          this.target = target;
85      }
86  
87      public IRI getMediationService() {
88          return mediationService;
89      }
90  
91      public void setMediationService(IRI newServiceID) {
92          mediationService = newServiceID;
93      }
94  
95      public boolean equals(Object object) {
96          if (object == null
97                  || object instanceof Mediator == false) {
98              return false;
99          }
100         return super.equals(object);
101     }
102 }
103 
104 /*
105  * $Log$
106  * Revision 1.28  2007/04/02 12:13:24  morcen
107  * Generics support added to wsmo-api, wsmo4j and wsmo-test
108  *
109  * Revision 1.27  2006/03/29 08:51:04  vassil_momtchev
110  * mediator reference source/target by IRI (changed from TopEntity); mediator reference mediationService by IRI (changed from Identifier)
111  *
112  * Revision 1.26  2006/02/13 10:41:04  vassil_momtchev
113  * the constructors of the topentities to disallow Identifier; see WsmoFactoryImpl
114  *
115  * Revision 1.25  2005/12/02 14:33:44  holgerlausen
116  * fixed parsing bug due to type when overwriting method, fixed but related to multiple source of mediators during reparsing
117  *
118  * Revision 1.24  2005/11/29 15:53:29  holgerlausen
119  * fixing unit test for checking multiple sources
120  *
121  * Revision 1.23  2005/11/08 13:54:17  alex_simov
122  * mistyping: setMediationSerivice() -> setMediationService()
123  *
124  * Revision 1.22  2005/06/22 09:16:05  alex_simov
125  * Simplified equals() method. Identity strongly relies on identifier string
126  *
127  * Revision 1.21  2005/06/01 12:07:31  marin_dimitrov
128  * v0.4.0
129  *
130  * Revision 1.1  2005/05/13 14:05:49  alex
131  * initial commit
132  *
133  */