~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.hisp.dhis.organisationunit;
 
2
 
 
3
/*
 
4
 * Copyright (c) 2004-2007, University of Oslo
 
5
 * All rights reserved.
 
6
 *
 
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.
 
17
 *
 
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.
 
28
 */
 
29
 
 
30
import java.io.Serializable;
 
31
import java.util.Date;
 
32
import java.util.HashSet;
 
33
import java.util.Set;
 
34
 
 
35
import org.hisp.dhis.common.MetaObject;
 
36
import org.hisp.dhis.source.Source;
 
37
 
 
38
/**
 
39
 * @author Kristian Nordal
 
40
 * @version $Id: OrganisationUnit.java 6251 2008-11-10 14:37:05Z larshelg $
 
41
 */
 
42
public class OrganisationUnit
 
43
    extends Source
 
44
    implements Serializable, MetaObject
 
45
{
 
46
    private String name;
 
47
    
 
48
    private String uuid;
 
49
 
 
50
    private Set<OrganisationUnit> children = new HashSet<OrganisationUnit>();
 
51
 
 
52
    private OrganisationUnit parent;
 
53
 
 
54
    private String shortName;
 
55
 
 
56
    private String code;
 
57
    
 
58
    private Date openingDate;
 
59
 
 
60
    private Date closedDate;
 
61
 
 
62
    private boolean active;
 
63
 
 
64
    private String comment;
 
65
    
 
66
    private String geoCode;
 
67
    
 
68
    private String latitude;
 
69
    
 
70
    private String longitude;
 
71
    
 
72
    private transient int level;
 
73
    
 
74
    // -------------------------------------------------------------------------
 
75
    // Constructors
 
76
    // -------------------------------------------------------------------------
 
77
 
 
78
    public OrganisationUnit()
 
79
    {
 
80
    }
 
81
 
 
82
    /**
 
83
     * @param name
 
84
     * @param shortName
 
85
     * @param organisationUnitCode
 
86
     * @param openingDate
 
87
     * @param closedDate
 
88
     * @param active
 
89
     * @param comment
 
90
     */
 
91
    public OrganisationUnit( String name, String shortName, String code, Date openingDate,
 
92
        Date closedDate, boolean active, String comment )
 
93
    {
 
94
        this.name = name;
 
95
        this.shortName = shortName;
 
96
        this.code = code;
 
97
        this.openingDate = openingDate;
 
98
        this.closedDate = closedDate;
 
99
        this.active = active;
 
100
        this.comment = comment;
 
101
    }
 
102
 
 
103
    /**
 
104
     * @param name
 
105
     * @param parent
 
106
     * @param shortName
 
107
     * @param organisationUnitCode
 
108
     * @param openingDate
 
109
     * @param closedDate
 
110
     * @param active
 
111
     * @param comment
 
112
     */
 
113
    public OrganisationUnit( String name, OrganisationUnit parent, String shortName, String code,
 
114
        Date openingDate, Date closedDate, boolean active, String comment )
 
115
    {
 
116
        this.name = name;
 
117
        this.parent = parent;
 
118
        this.shortName = shortName;
 
119
        this.code = code;
 
120
        this.openingDate = openingDate;
 
121
        this.closedDate = closedDate;
 
122
        this.active = active;
 
123
        this.comment = comment;
 
124
    }
 
125
 
 
126
    // -------------------------------------------------------------------------
 
127
    // hashCode, equals and toString
 
128
    // -------------------------------------------------------------------------
 
129
 
 
130
    @Override
 
131
    public int hashCode()
 
132
    {
 
133
        return name.hashCode();
 
134
    }
 
135
 
 
136
    @Override
 
137
    public boolean equals( Object o )
 
138
    {
 
139
        if ( this == o )
 
140
        {
 
141
            return true;
 
142
        }
 
143
 
 
144
        if ( o == null )
 
145
        {
 
146
            return false;
 
147
        }
 
148
 
 
149
        if ( !(o instanceof OrganisationUnit) )
 
150
        {
 
151
            return false;
 
152
        }
 
153
 
 
154
        final OrganisationUnit other = (OrganisationUnit) o;
 
155
 
 
156
        return name.equals( other.getName() );
 
157
    }
 
158
 
 
159
    @Override
 
160
    public String toString()
 
161
    {
 
162
        return "[" + name + "]";
 
163
    }
 
164
 
 
165
    // -------------------------------------------------------------------------
 
166
    // Getters and setters
 
167
    // -------------------------------------------------------------------------
 
168
 
 
169
    public String getName()
 
170
    {
 
171
        return name;
 
172
    }
 
173
 
 
174
    public void setName( String name )
 
175
    {
 
176
        this.name = name;
 
177
    }
 
178
 
 
179
    public String getUuid()
 
180
    {
 
181
        return uuid;
 
182
    }
 
183
 
 
184
    public void setUuid( String uuid )
 
185
    {
 
186
        this.uuid = uuid;
 
187
    }
 
188
 
 
189
    public Set<OrganisationUnit> getChildren()
 
190
    {
 
191
        return children;
 
192
    }
 
193
 
 
194
    public void setChildren( Set<OrganisationUnit> children )
 
195
    {
 
196
        this.children = children;
 
197
    }
 
198
 
 
199
    public OrganisationUnit getParent()
 
200
    {
 
201
        return parent;
 
202
    }
 
203
 
 
204
    public void setParent( OrganisationUnit parent )
 
205
    {
 
206
        this.parent = parent;
 
207
    }
 
208
 
 
209
    public String getShortName()
 
210
    {
 
211
        return shortName;
 
212
    }
 
213
 
 
214
    public void setShortName( String shortName )
 
215
    {
 
216
        this.shortName = shortName;
 
217
    }
 
218
 
 
219
    public String getCode()
 
220
    {
 
221
        return code;
 
222
    }
 
223
 
 
224
    public void setCode( String code )
 
225
    {
 
226
        this.code = code;
 
227
    }
 
228
    
 
229
    public String getAlternativeName()
 
230
    {
 
231
        return getShortName();
 
232
    }
 
233
    
 
234
    public void setAlternativeName( String alternativeName )
 
235
    {
 
236
        throw new UnsupportedOperationException( "Cannot set alternativename on OrganisationUnit: " + alternativeName );
 
237
    }
 
238
    
 
239
    public Date getOpeningDate()
 
240
    {
 
241
        return openingDate;
 
242
    }
 
243
 
 
244
    public void setOpeningDate( Date openingDate )
 
245
    {
 
246
        this.openingDate = openingDate;
 
247
    }
 
248
 
 
249
    public Date getClosedDate()
 
250
    {
 
251
        return closedDate;
 
252
    }
 
253
 
 
254
    public void setClosedDate( Date closedDate )
 
255
    {
 
256
        this.closedDate = closedDate;
 
257
    }
 
258
 
 
259
    public boolean isActive()
 
260
    {
 
261
        return active;
 
262
    }
 
263
 
 
264
    public void setActive( boolean active )
 
265
    {
 
266
        this.active = active;
 
267
    }
 
268
 
 
269
    public String getComment()
 
270
    {
 
271
        return comment;
 
272
    }
 
273
 
 
274
    public void setComment( String comment )
 
275
    {
 
276
        this.comment = comment;
 
277
    }
 
278
 
 
279
    public String getGeoCode()
 
280
    {
 
281
        return geoCode;
 
282
    }
 
283
 
 
284
    public void setGeoCode( String geoCode )
 
285
    {
 
286
        this.geoCode = geoCode;
 
287
    }
 
288
 
 
289
    public String getLatitude()
 
290
    {
 
291
        return latitude;
 
292
    }
 
293
 
 
294
    public void setLatitude( String latitude )
 
295
    {
 
296
        this.latitude = latitude;
 
297
    }
 
298
 
 
299
    public String getLongitude()
 
300
    {
 
301
        return longitude;
 
302
    }
 
303
 
 
304
    public void setLongitude( String longitude )
 
305
    {
 
306
        this.longitude = longitude;
 
307
    }
 
308
 
 
309
    public int getLevel()
 
310
    {
 
311
        return level;
 
312
    }
 
313
 
 
314
    public void setLevel( int level )
 
315
    {
 
316
        this.level = level;
 
317
    }
 
318
}