1
package org.hisp.dhis.organisationunit;
4
* Copyright (c) 2004-2007, University of Oslo
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright notice, this
10
* list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
* * Neither the name of the HISP project nor the names of its contributors may
15
* be used to endorse or promote products derived from this software without
16
* specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
import java.io.Serializable;
31
import java.util.Date;
32
import java.util.HashSet;
35
import org.hisp.dhis.common.MetaObject;
36
import org.hisp.dhis.source.Source;
39
* @author Kristian Nordal
40
* @version $Id: OrganisationUnit.java 6251 2008-11-10 14:37:05Z larshelg $
42
public class OrganisationUnit
44
implements Serializable, MetaObject
50
private Set<OrganisationUnit> children = new HashSet<OrganisationUnit>();
52
private OrganisationUnit parent;
54
private String shortName;
58
private Date openingDate;
60
private Date closedDate;
62
private boolean active;
64
private String comment;
66
private String geoCode;
68
private String latitude;
70
private String longitude;
72
private transient int level;
74
// -------------------------------------------------------------------------
76
// -------------------------------------------------------------------------
78
public OrganisationUnit()
85
* @param organisationUnitCode
91
public OrganisationUnit( String name, String shortName, String code, Date openingDate,
92
Date closedDate, boolean active, String comment )
95
this.shortName = shortName;
97
this.openingDate = openingDate;
98
this.closedDate = closedDate;
100
this.comment = comment;
107
* @param organisationUnitCode
113
public OrganisationUnit( String name, OrganisationUnit parent, String shortName, String code,
114
Date openingDate, Date closedDate, boolean active, String comment )
117
this.parent = parent;
118
this.shortName = shortName;
120
this.openingDate = openingDate;
121
this.closedDate = closedDate;
122
this.active = active;
123
this.comment = comment;
126
// -------------------------------------------------------------------------
127
// hashCode, equals and toString
128
// -------------------------------------------------------------------------
131
public int hashCode()
133
return name.hashCode();
137
public boolean equals( Object o )
149
if ( !(o instanceof OrganisationUnit) )
154
final OrganisationUnit other = (OrganisationUnit) o;
156
return name.equals( other.getName() );
160
public String toString()
162
return "[" + name + "]";
165
// -------------------------------------------------------------------------
166
// Getters and setters
167
// -------------------------------------------------------------------------
169
public String getName()
174
public void setName( String name )
179
public String getUuid()
184
public void setUuid( String uuid )
189
public Set<OrganisationUnit> getChildren()
194
public void setChildren( Set<OrganisationUnit> children )
196
this.children = children;
199
public OrganisationUnit getParent()
204
public void setParent( OrganisationUnit parent )
206
this.parent = parent;
209
public String getShortName()
214
public void setShortName( String shortName )
216
this.shortName = shortName;
219
public String getCode()
224
public void setCode( String code )
229
public String getAlternativeName()
231
return getShortName();
234
public void setAlternativeName( String alternativeName )
236
throw new UnsupportedOperationException( "Cannot set alternativename on OrganisationUnit: " + alternativeName );
239
public Date getOpeningDate()
244
public void setOpeningDate( Date openingDate )
246
this.openingDate = openingDate;
249
public Date getClosedDate()
254
public void setClosedDate( Date closedDate )
256
this.closedDate = closedDate;
259
public boolean isActive()
264
public void setActive( boolean active )
266
this.active = active;
269
public String getComment()
274
public void setComment( String comment )
276
this.comment = comment;
279
public String getGeoCode()
284
public void setGeoCode( String geoCode )
286
this.geoCode = geoCode;
289
public String getLatitude()
294
public void setLatitude( String latitude )
296
this.latitude = latitude;
299
public String getLongitude()
304
public void setLongitude( String longitude )
306
this.longitude = longitude;
309
public int getLevel()
314
public void setLevel( int level )