1 | |
package com.aurea.maven.plugins.sonic.topology.utils; |
2 | |
|
3 | |
import java.util.SortedSet; |
4 | |
|
5 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
6 | |
|
7 | |
|
8 | |
public class TopologyHolder implements java.io.Serializable{ |
9 | |
|
10 | |
|
11 | |
|
12 | |
private static final long serialVersionUID = 1L; |
13 | |
|
14 | |
String topologyId; |
15 | |
String topoEnvId; |
16 | |
MachineHolder machineHolder; |
17 | |
Environment env; |
18 | |
ParameterHolder pholder; |
19 | |
|
20 | |
|
21 | 0 | public TopologyHolder(String topoId){ |
22 | 0 | this.topologyId = topoId; |
23 | 0 | machineHolder = new MachineHolder(); |
24 | 0 | } |
25 | |
|
26 | |
public String getTopologyId() { |
27 | 0 | return topologyId; |
28 | |
} |
29 | |
|
30 | |
public void setTopologyId(String topologyId) { |
31 | 0 | this.topologyId = topologyId; |
32 | 0 | } |
33 | |
|
34 | |
public String getTopoEnvId() { |
35 | 0 | return topoEnvId; |
36 | |
} |
37 | |
|
38 | |
public void setTopoEnvId(String topoEnvId) { |
39 | 0 | this.topoEnvId = topoEnvId; |
40 | 0 | } |
41 | |
|
42 | |
public MachineHolder getMachineHolder() { |
43 | 0 | return machineHolder; |
44 | |
} |
45 | |
|
46 | |
public void setMachineHolder(MachineHolder machineHolder) { |
47 | 0 | this.machineHolder = machineHolder; |
48 | 0 | } |
49 | |
|
50 | |
public Environment getEnv() { |
51 | 0 | return env; |
52 | |
} |
53 | |
|
54 | |
public void setEnv(Environment env) { |
55 | 0 | this.env = env; |
56 | 0 | } |
57 | |
|
58 | |
public ParameterHolder getPholder() { |
59 | 0 | return pholder; |
60 | |
} |
61 | |
|
62 | |
public void setPholder(ParameterHolder pholder) { |
63 | 0 | this.pholder = pholder; |
64 | 0 | } |
65 | |
|
66 | |
public String toString(){ |
67 | 0 | StringBuffer sb = new StringBuffer(); |
68 | 0 | sb.append("\n-------------------------------\n" + getTopologyId() + "\n" + getTopoEnvId() + "\n"); |
69 | 0 | for(int i = 0; i < getMachineHolder().getMachineConfigs().size(); i++){ |
70 | 0 | sb.append(getMachineHolder().getMachineConfigs().get(i).toString()); |
71 | |
} |
72 | 0 | sb.append("\n-------------------------------\n"); |
73 | 0 | sb.append("Environment"); |
74 | 0 | sb.append(this.env.toString()); |
75 | 0 | sb.append("\n-------------------------------\n"); |
76 | 0 | sb.append("Parameters"); |
77 | 0 | sb.append(this.pholder.toString()); |
78 | 0 | sb.append("\n-------------------------------\n"); |
79 | |
|
80 | 0 | return sb.toString(); |
81 | |
} |
82 | |
|
83 | |
public String createEnvironmentTopology(TopologyHolder tHolder, SortedSet<String> propNames) { |
84 | 0 | final Xpp3Dom topology = new Xpp3Dom("Environment"); |
85 | 0 | final Xpp3Dom id = new Xpp3Dom("Id"); |
86 | |
|
87 | 0 | id.setValue(this.getTopologyId()); |
88 | 0 | topology.addChild(id); |
89 | 0 | this.machineHolder.createMachineXmlContent(topology); |
90 | 0 | this.env.createEnvironmentXmlContent(topology); |
91 | 0 | this.getPholder().createParameterXmlContent(topology, tHolder, propNames); |
92 | 0 | return topology.toString(); |
93 | |
} |
94 | |
|
95 | |
} |