001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2004, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * This package contains documentation from OpenGIS specifications.
018: * OpenGIS consortium's work is fully acknowledged here.
019: */
020: package org.geotools.metadata.iso.maintenance;
021:
022: // J2SE direct dependencies
023: import java.util.Collection;
024: import java.util.Collections;
025: import java.util.Date;
026:
027: // OpenGIS dependencies
028: import org.opengis.metadata.citation.ResponsibleParty;
029: import org.opengis.metadata.maintenance.MaintenanceInformation;
030: import org.opengis.metadata.maintenance.MaintenanceFrequency;
031: import org.opengis.metadata.maintenance.ScopeCode;
032: import org.opengis.metadata.maintenance.ScopeDescription;
033: import org.opengis.temporal.PeriodDuration;
034: import org.opengis.util.InternationalString;
035:
036: // Geotools dependencies
037: import org.geotools.metadata.iso.MetadataEntity;
038:
039: /**
040: * Information about the scope and frequency of updating.
041: *
042: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/metadata/iso/maintenance/MaintenanceInformationImpl.java $
043: * @version $Id: MaintenanceInformationImpl.java 25189 2007-04-17 13:23:47Z desruisseaux $
044: * @author Martin Desruisseaux
045: * @author Touraïvane
046: *
047: * @since 2.1
048: */
049: public class MaintenanceInformationImpl extends MetadataEntity
050: implements MaintenanceInformation {
051: /**
052: * Serial number for interoperability with different versions.
053: */
054: private static final long serialVersionUID = 8523463344581266776L;
055:
056: /**
057: * Frequency with which changes and additions are made to the resource after the
058: * initial resource is completed.
059: */
060: private MaintenanceFrequency maintenanceAndUpdateFrequency;
061:
062: /**
063: * Scheduled revision date for resource, in milliseconds ellapsed
064: * since January 1st, 1970. If there is no such date, then this field
065: * is set to the special value {@link Long#MIN_VALUE}.
066: */
067: private long dateOfNextUpdate = Long.MIN_VALUE;
068:
069: /**
070: * Maintenance period other than those defined, in milliseconds.
071: */
072: private PeriodDuration userDefinedMaintenanceFrequency;
073:
074: /**
075: * Scope of data to which maintenance is applied.
076: */
077: private Collection/*<ScopeCode>*/updateScopes;
078:
079: /**
080: * Additional information about the range or extent of the resource.
081: */
082: private Collection/*<ScopeDescription>*/updateScopeDescriptions;
083:
084: /**
085: * Information regarding specific requirements for maintaining the resource.
086: */
087: private Collection/*<InternationalString>*/maintenanceNotes;
088:
089: /**
090: * Identification of, and means of communicating with,
091: * person(s) and organization(s) with responsibility for maintaining the metadata
092: */
093: private Collection/*<ResponsibleParty>*/contacts;
094:
095: /**
096: * Creates a an initially empty maintenance information.
097: */
098: public MaintenanceInformationImpl() {
099: }
100:
101: /**
102: * Constructs a metadata entity initialized with the values from the specified metadata.
103: *
104: * @since 2.4
105: */
106: public MaintenanceInformationImpl(
107: final MaintenanceInformation source) {
108: super (source);
109: }
110:
111: /**
112: * Creates a maintenance information.
113: */
114: public MaintenanceInformationImpl(
115: final MaintenanceFrequency maintenanceAndUpdateFrequency) {
116: setMaintenanceAndUpdateFrequency(maintenanceAndUpdateFrequency);
117: }
118:
119: /**
120: * Returns the frequency with which changes and additions are made to the resource
121: * after the initial resource is completed.
122: */
123: public MaintenanceFrequency getMaintenanceAndUpdateFrequency() {
124: return maintenanceAndUpdateFrequency;
125: }
126:
127: /**
128: * Set the frequency with which changes and additions are made to the resource
129: * after the initial resource is completed.
130: */
131: public synchronized void setMaintenanceAndUpdateFrequency(
132: final MaintenanceFrequency newValue) {
133: checkWritePermission();
134: maintenanceAndUpdateFrequency = newValue;
135: }
136:
137: /**
138: * Returns the scheduled revision date for resource.
139: */
140: public synchronized Date getDateOfNextUpdate() {
141: return (dateOfNextUpdate != Long.MIN_VALUE) ? new Date(
142: dateOfNextUpdate) : null;
143: }
144:
145: /**
146: * Set the scheduled revision date for resource.
147: */
148: public synchronized void setDateOfNextUpdate(final Date newValue) {
149: checkWritePermission();
150: dateOfNextUpdate = (newValue != null) ? newValue.getTime()
151: : Long.MIN_VALUE;
152: }
153:
154: /**
155: * Returns the maintenance period other than those defined.
156: *
157: * @return The period, in milliseconds.
158: */
159: public PeriodDuration getUserDefinedMaintenanceFrequency() {
160: return userDefinedMaintenanceFrequency;
161: }
162:
163: /**
164: * Set the maintenance period other than those defined.
165: */
166: public synchronized void setUserDefinedMaintenanceFrequency(
167: final PeriodDuration newValue) {
168: checkWritePermission();
169: userDefinedMaintenanceFrequency = newValue;
170: }
171:
172: /**
173: * Scope of data to which maintenance is applied.
174: *
175: * @deprecated Replaced by {@link #getUpdateScopes}.
176: */
177: public ScopeCode getUpdateScope() {
178: final Collection updateScopes = getUpdateScopes();
179: return updateScopes.isEmpty() ? null : (ScopeCode) updateScopes
180: .iterator().next();
181: }
182:
183: /**
184: * Scope of data to which maintenance is applied.
185: *
186: * @deprecated Replaced by {@link #setUpdateScopes}.
187: */
188: public void setUpdateScope(final ScopeCode newValue) {
189: setUpdateScopes(Collections.singleton(newValue));
190: }
191:
192: /**
193: * Returns the scope of data to which maintenance is applied.
194: *
195: * @since 2.4
196: */
197: public synchronized Collection getUpdateScopes() {
198: return updateScopes = nonNullCollection(updateScopes,
199: ScopeCode.class);
200: }
201:
202: /**
203: * Set the scope of data to which maintenance is applied.
204: *
205: * @since 2.4
206: */
207: public synchronized void setUpdateScopes(final Collection newValues) {
208: updateScopes = copyCollection(newValues, updateScopes,
209: ScopeCode.class);
210: }
211:
212: /**
213: * Additional information about the range or extent of the resource.
214: *
215: * @deprecated Replaced by {@link #getUpdateScopeDescriptions}.
216: */
217: public ScopeDescription getUpdateScopeDescription() {
218: final Collection updateScopeDescriptions = getUpdateScopeDescriptions();
219: return updateScopeDescriptions.isEmpty() ? null
220: : (ScopeDescription) updateScopeDescriptions.iterator()
221: .next();
222: }
223:
224: /**
225: * Additional information about the range or extent of the resource.
226: *
227: * @deprecated Replaced by {@link #setUpdateScopeDescriptions}.
228: */
229: public void setUpdateScopeDescription(
230: final ScopeDescription newValue) {
231: setUpdateScopeDescriptions(Collections.singleton(newValue));
232: }
233:
234: /**
235: * Returns additional information about the range or extent of the resource.
236: *
237: * @since 2.4
238: */
239: public synchronized Collection getUpdateScopeDescriptions() {
240: return updateScopeDescriptions = nonNullCollection(
241: updateScopeDescriptions, ScopeDescription.class);
242: }
243:
244: /**
245: * Set additional information about the range or extent of the resource.
246: *
247: * @since 2.4
248: */
249: public synchronized void setUpdateScopeDescriptions(
250: final Collection newValues) {
251: updateScopeDescriptions = copyCollection(newValues,
252: updateScopeDescriptions, ScopeDescription.class);
253: }
254:
255: /**
256: * Information regarding specific requirements for maintaining the resource.
257: *
258: * @deprecated Replaced by {@link #getMaintenanceNotes}.
259: */
260: public InternationalString getMaintenanceNote() {
261: final Collection maintenanceNotes = getMaintenanceNotes();
262: return maintenanceNotes.isEmpty() ? null
263: : (InternationalString) maintenanceNotes.iterator()
264: .next();
265: }
266:
267: /**
268: * Information regarding specific requirements for maintaining the resource.
269: *
270: * @deprecated Replaced by {@link #setMaintenanceNotes}.
271: */
272: public void setMaintenanceNote(final InternationalString newValue) {
273: setMaintenanceNotes(Collections.singleton(newValue));
274: }
275:
276: /**
277: * Returns information regarding specific requirements for maintaining the resource.
278: *
279: * @since 2.4
280: */
281: public synchronized Collection getMaintenanceNotes() {
282: return maintenanceNotes = nonNullCollection(maintenanceNotes,
283: InternationalString.class);
284: }
285:
286: /**
287: * Set information regarding specific requirements for maintaining the resource.
288: *
289: * @since 2.4
290: */
291: public synchronized void setMaintenanceNotes(
292: final Collection newValues) {
293: maintenanceNotes = copyCollection(newValues, maintenanceNotes,
294: InternationalString.class);
295: }
296:
297: /**
298: * Returns identification of, and means of communicating with,
299: * person(s) and organization(s) with responsibility for maintaining the metadata.
300: *
301: * @since 2.4
302: */
303: public synchronized Collection getContacts() {
304: return contacts = nonNullCollection(contacts,
305: ResponsibleParty.class);
306: }
307:
308: /**
309: * Set identification of, and means of communicating with,
310: * person(s) and organization(s) with responsibility for maintaining the metadata.
311: *
312: * @since 2.4
313: */
314: public synchronized void setContacts(final Collection newValues) {
315: contacts = copyCollection(newValues, contacts,
316: ResponsibleParty.class);
317: }
318: }
|