View Javadoc

1   package net.sf.mmapps.modules.config.implementation;
2   
3   import net.sf.mmapps.modules.config.*;
4   
5   /***
6    * implementation of ApplicationConfiguration
7    * @author Kees Jongenburger
8    * @version $Id: BasicApplicationConfiguration.java,v 1.2 2004/05/18 13:53:51 keesj Exp $
9    */
10  public class BasicApplicationConfiguration implements net.sf.mmapps.modules.config.ApplicationConfiguration {
11      String name = "Default";
12      String maintainer = "mmbase.org";
13      String version = "1";
14      NodeManagerConfigurations nodeManagerConfigurations;
15      RelationManagerConfigurations relationManagerConfigurations;
16      RelationTypes relationTypes;
17      Strings requiredNodeManagers;
18  
19      Strings depends;
20      /*** Creates a new instance of BasicApplicationConfiguration */
21      protected BasicApplicationConfiguration() {
22          nodeManagerConfigurations = new NodeManagerConfigurations();
23          relationManagerConfigurations = new RelationManagerConfigurations();
24          relationTypes = new RelationTypes();
25          requiredNodeManagers = new Strings();
26          depends = new Strings();
27      }
28  
29      /***
30       * set the name of the application
31       * @param name the name of the application
32       **/
33      public void setName(String name) {
34          this.name = name;
35      }
36  
37      public String getName() {
38          return name;
39      }
40  
41      public void setMaintainer(String maintainer) {
42          this.maintainer = maintainer;
43      }
44  
45      public String getMaintainer() {
46          return maintainer;
47      }
48  
49      public void setVersion(String version) {
50          this.version = version;
51      }
52  
53      public String getVersion() {
54          return version;
55      }
56  
57      /***
58       * add a nodemanager configuration to the application
59       * @param nodeManagerConfiguration the nodemanagerconfiguration to add
60       **/
61      public void addNodeManagerConfiguration(NodeManagerConfiguration nodeManagerConfiguration) {
62          nodeManagerConfigurations.add(nodeManagerConfiguration);
63      }
64  
65      public void addRequiredNodeManager(String name) {
66          requiredNodeManagers.add(name);
67      }
68  
69      public Strings getRequiredNodeManagers() {
70          return requiredNodeManagers;
71      }
72      /***
73       * add a relation manager configuration to the application
74       * @param relationManagerConfiguration the relation manager configuration to add
75       *
76       **/
77      public void addRelationManagerConfiguration(RelationManagerConfiguration relationManagerConfiguration) {
78          relationManagerConfigurations.add(relationManagerConfiguration);
79      }
80  
81      public NodeManagerConfigurations getNodeManagerConfigurations() {
82          return nodeManagerConfigurations;
83      }
84  
85      public RelationManagerConfigurations getRelationManagerConfigurations() {
86          return relationManagerConfigurations;
87      }
88      public void addRelationType(RelationType relationType) {
89          relationTypes.add(relationType);
90      }
91  
92      public RelationTypes getRelationTypes() {
93          return relationTypes;
94      }
95      public RelationType getRelationType(String name) {
96          for (int x = 0; x < relationTypes.size(); x++) {
97              RelationType reltype = relationTypes.getRelationType(x);
98              if (reltype.getName().equals(name)) {
99                  return reltype;
100             }
101         }
102         return null;
103     }
104 
105     public void addDepends(String name) {
106         depends.add(name);
107     }
108 
109     public Strings getDepends() {
110         return depends;
111     }
112 
113     public void add(ApplicationConfiguration applicationConfiguration) {
114         ApplicationConfiguration c = applicationConfiguration;
115 
116         //depends 
117         Strings dep = c.getDepends();
118         Strings localdep = getDepends();
119         for (int x = 0; x < dep.size(); x++) {
120             if (!localdep.contains(dep.getString(x))) {
121                 addDepends(dep.getString(x));
122             }
123         }
124         System.err.println(getDepends());
125 
126         //required node managers
127         Strings rnm = c.getRequiredNodeManagers();
128         Strings localrnm = getRequiredNodeManagers();
129         for (int x = 0; x < rnm.size(); x++) {
130             if (!localrnm.contains(rnm.getString(x))) {
131                 addRequiredNodeManager(rnm.getString(x));
132             }
133         }
134         System.err.println(getRequiredNodeManagers());
135 
136         //defined node managers
137         NodeManagerConfigurations nmc = c.getNodeManagerConfigurations();
138         NodeManagerConfigurations localnmc = getNodeManagerConfigurations();
139         for (int x = 0; x < nmc.size(); x++) {
140             if (localnmc.getNodeManagerConfiguration(nmc.getNodeManagerConfiguration(x).getName()) == null) {
141                 addNodeManagerConfiguration(nmc.getNodeManagerConfiguration(x));
142             }
143         }
144 
145         //defined node managers
146         RelationManagerConfigurations r = c.getRelationManagerConfigurations();
147         RelationManagerConfigurations localr = getRelationManagerConfigurations();
148         for (int x = 0; x < r.size(); x++) {
149             if (localr.getRelationManagerConfiguration(r.getRelationManagerConfiguration(x).getName()) == null) {
150                 addRelationManagerConfiguration(r.getRelationManagerConfiguration(x));
151             }
152         }
153         //relation types
154         RelationTypes rtypes = c.getRelationTypes();
155         RelationTypes ltypes = getRelationTypes();
156         for (int x = 0; x < rtypes.size(); x++) {
157             if (ltypes.getRelationType(rtypes.getRelationType(x).getName()) == null) {
158                 addRelationType(rtypes.getRelationType(x));
159             }
160         }
161     }
162 }