1 /**
2 * Copyright 2005-2007 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.businessobjects.environment;
16
17 import java.util.List;
18 import java.util.ArrayList;
19 /**
20 * A Resource implementation that provide access to some other Enterprise
21 * Information Systems ({@link EIS}).
22 * <br/>
23 * It represents an access point to EIS that may be connected to the main
24 * Software project you want to use Join for. A Gateway will be typically
25 * used by Enterprise Portal type projects.
26 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
27 * @version $Revision: 1.4 $
28 *
29 * @hibernate.subclass table="join_resources" discriminator-value="GATEWAY"
30 */
31 public class Gateway extends AbstractResource{
32
33
34
35 /** The category information of the Gateway implementation of AbstractResource */
36 public static final String CATEGORY = "Gateway";
37
38
39
40
41 /** The list of active EIS mappings (many EIS bound at same time) */
42 private List activeEISMappings = new ArrayList();
43
44
45
46
47 /** Creates a new instance of Gateway */
48 public Gateway(){
49 super();
50 }
51
52 /**
53 * Creates a new instance of Gateway with mandatory attributes
54 * @param name This gateway name
55 */
56 public Gateway(String name, GatewayType type){
57 super(name, type);
58 }
59
60
61
62
63 /**
64 * @hibernate.bag cascade="save-update" lazy="true" inverse="true"
65 * where="d_end is null" order-by="d_start desc"
66 * @hibernate.collection-key column="n_gateway_fk"
67 * @hibernate.collection-one-to-many class="org.figure8.join.businessobjects.environment.EISMapping"
68 * @return A set of {@code EISMapping}s that are active now
69 */
70 public List getActiveEISMappings(){
71 return activeEISMappings;
72 }
73 /** @param mappings The set of {@code ResourceMapping}s that are active now */
74 public void setActiveEISMappings(List mappings){
75 this.activeEISMappings = mappings;
76 }
77
78 /**
79 * Convenient method for adding a mapped resource into mapping list
80 * This method closes the previously existing mapping for this kind of resource.
81 * @param mapping The mapping to an infratructure resource to add
82 */
83 public void addActiveEISMapping(EISMapping mapping){
84 closeActiveEISMapping(mapping.getEIS().getResourceType());
85 activeEISMappings.add(mapping);
86 }
87
88
89
90
91 /**
92 * Return the category information on this resource.
93 * @return The category information as character string
94 */
95 public String getCategory(){
96 return CATEGORY;
97 }
98
99
100
101
102 /** Close the active eis mappings for this kind of resource type */
103 private void closeActiveEISMapping(ResourceType type){
104
105 for (int i=0; i<activeEISMappings.size(); i++){
106 EISMapping mapping = (EISMapping)activeEISMappings.get(i);
107 if (mapping.getEIS().getResourceType().equals(type))
108 mapping.close();
109 }
110 }
111 }
112