1 /**
2 * Copyright 2005-2006 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 org.figure8.join.core.EntityObject;
18
19 import java.util.List;
20 import java.util.ArrayList;
21 /**
22 * This is an entity object representing a physical machine managed by
23 * the software project integration team. Such a machine can host <code>Service</code>s.
24 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
25 * @version $Revision: 1.1 $
26 *
27 * @hibernate.class table="join_machines"
28 * @hibernate.cache usage="read-write"
29 *
30 * @hibernate.query name="join.machine_findByName" query="from Machine mach where mach.name = :machineName"
31 */
32 public class Machine extends EntityObject{
33
34
35
36 /** This machine full network name */
37 private String name;
38 /** This machine IP address */
39 private String ipAddress;
40 /** This machine Operating System info */
41 private String osInfo;
42 /** This machine CPU info */
43 private String cpuInfo;
44 /** This machine RAM amount */
45 private int ramAmount;
46 /** This machine ROM amount */
47 private int romAmount;
48 /** The resources hosted onto this machine */
49 private List resources = new ArrayList();
50
51
52
53
54 /** Creates a new Machine */
55 public Machine(){
56 }
57
58 /**
59 * Creates a new Machine with mandatory attributes
60 * @param name
61 * @param ipAddress
62 */
63 public Machine(String name, String ipAddress){
64 this.name = name;
65 this.ipAddress = ipAddress;
66 }
67
68
69
70
71 /**
72 * @hibernate.property column="s_name"
73 * not-null="true" unique="true"
74 * length="200" update="false"
75 * @return This machine full network name
76 */
77 public String getName(){
78 return name;
79 }
80 /** @param name This machine full network name */
81 public void setName(String name){
82 this.name = name;
83 }
84
85 /**
86 * @hibernate.property column="s_ip"
87 * not-null="true" length="15"
88 * @return This machine IP address
89 */
90 public String getIpAddress(){
91 return ipAddress;
92 }
93 /** @param ipAddress This machine IP address */
94 public void setIpAddress(String ipAddress){
95 this.ipAddress = ipAddress;
96 }
97
98 /**
99 * @hibernate.property column="s_os" length="100"
100 * @return Information on machine OS
101 */
102 public String getOsInfo(){
103 return osInfo;
104 }
105 /** @param osInfo Information on machine OS */
106 public void setOsInfo(String osInfo){
107 this.osInfo = osInfo;
108 }
109
110 /**
111 * @hibernate.property column="s_cpu" length="100"
112 * @return Information on machine CPU
113 */
114 public String getCpuInfo(){
115 return cpuInfo;
116 }
117 /** @param cpuInfo Information on machine CPU */
118 public void setCpuInfo(String cpuInfo){
119 this.cpuInfo = cpuInfo;
120 }
121
122 /**
123 * @hibernate.property column="n_ram"
124 * @return This machine RAM amount
125 */
126 public int getRamAmount(){
127 return ramAmount;
128 }
129 /** @param ramAmount This machine RAM amount */
130 public void setRamAmount(int ramAmount){
131 this.ramAmount = ramAmount;
132 }
133
134 /**
135 * @hibernate.property column="n_rom"
136 * @return This machine ROM amount
137 */
138 public int getRomAmount(){
139 return romAmount;
140 }
141 /** @param romAmount This machine ROM amount */
142 public void setRomAmount(int romAmount){
143 this.romAmount = romAmount;
144 }
145
146 /**
147 * @hibernate.bag cascade="save-update" lazy="true" order-by="s_name asc" inverse="false"
148 * @hibernate.collection-key column="n_machine_fk"
149 * @hibernate.collection-one-to-many class="org.figure8.join.businessobjects.environment.AbstractResource"
150 * @return A set of {@code AbstractResource}s hosted on this machine
151 */
152 public List getResources(){
153 return resources;
154 }
155 /** @param resources The list of resources hosted by this machine */
156 public void setResources(List resources){
157 this.resources = resources;
158 }
159
160 /**
161 * Convenient method for adding an hosted resource to this machine
162 * and managing the 2 sides of the bidirectionnal relationship.
163 * @param resource The resource to host on this machine
164 */
165 public void addHostedResource(AbstractResource resource){
166 if (!resources.contains(resource)) resources.add(resource);
167 resource.setMachine(this);
168 }
169 }