001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.global.dto;
006:
007: import org.geotools.geometry.GeneralEnvelope;
008: import org.opengis.coverage.grid.GridGeometry;
009: import org.opengis.referencing.crs.CoordinateReferenceSystem;
010: import org.opengis.util.InternationalString;
011: import org.vfny.geoserver.config.DataConfig;
012: import org.vfny.geoserver.global.CoverageDimension;
013: import org.vfny.geoserver.global.MetaDataLink;
014: import java.util.ArrayList;
015: import java.util.LinkedList;
016: import java.util.List;
017: import java.util.Map;
018:
019: /**
020: * DOCUMENT ME!
021: *
022: * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last
023: * modification)
024: * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last
025: * modification)
026: */
027: public final class CoverageInfoDTO implements DataTransferObject {
028: /**
029: *
030: */
031: private String formatId;
032:
033: /**
034: *
035: */
036: private String name;
037:
038: /**
039: *
040: */
041: private String wmsPath;
042:
043: /**
044: *
045: */
046: private String label;
047:
048: /**
049: *
050: */
051: private String description;
052:
053: /**
054: *
055: */
056: private MetaDataLink metadataLink;
057:
058: /**
059: *
060: */
061: private String dirName;
062:
063: /**
064: *
065: */
066: private List keywords;
067:
068: /**
069: *
070: */
071: private GeneralEnvelope envelope;
072:
073: /**
074: *
075: */
076: private GeneralEnvelope lonLatWGS84Envelope;
077:
078: /**
079: *
080: */
081: private GridGeometry grid;
082:
083: /**
084: *
085: */
086: private CoverageDimension[] dimensions;
087:
088: /**
089: *
090: */
091: private InternationalString[] dimensionNames;
092:
093: /**
094: *
095: */
096: private List requestCRSs;
097:
098: /**
099: *
100: */
101: private List responseCRSs;
102:
103: /**
104: *
105: */
106: private String nativeFormat;
107:
108: /**
109: *
110: */
111: private List supportedFormats;
112:
113: /**
114: *
115: */
116: private String defaultInterpolationMethod;
117:
118: /**
119: *
120: */
121: private List interpolationMethods;
122:
123: /**
124: *
125: */
126: private String srsName;
127:
128: /**
129: *
130: */
131: private String srsWKT;
132:
133: /**
134: *
135: */
136: private CoordinateReferenceSystem crs;
137:
138: /**
139: * Default style used to render this Coverage with WMS
140: */
141: private String defaultStyle;
142:
143: /** Other Style Names. */
144: private ArrayList styles = new ArrayList();
145:
146: /**
147: * String representation of connection parameter values
148: */
149: private Map parameters;
150:
151: public CoverageInfoDTO() {
152: }
153:
154: public CoverageInfoDTO(CoverageInfoDTO dto) {
155: if (dto == null) {
156: throw new NullPointerException(
157: "Non null CoverageInfoDTO required");
158: }
159:
160: formatId = dto.getFormatId();
161: name = dto.getName();
162: wmsPath = dto.getWmsPath();
163: label = dto.getLabel();
164: description = dto.getDescription();
165: metadataLink = dto.getMetadataLink();
166: dirName = dto.getDirName();
167:
168: try {
169: keywords = CloneLibrary.clone(dto.getKeywords()); // clone?
170: } catch (Exception e) {
171: keywords = new LinkedList();
172: }
173:
174: crs = dto.getCrs();
175: srsName = dto.getSrsName();
176: srsWKT = dto.getSrsWKT();
177: envelope = dto.getEnvelope();
178: lonLatWGS84Envelope = dto.getLonLatWGS84Envelope();
179: grid = dto.getGrid();
180: dimensions = dto.getDimensions();
181: dimensionNames = dto.getDimensionNames();
182:
183: try {
184: requestCRSs = CloneLibrary.clone(dto.getRequestCRSs());
185: } catch (CloneNotSupportedException e1) {
186: requestCRSs = new LinkedList();
187: }
188:
189: try {
190: responseCRSs = CloneLibrary.clone(dto.getResponseCRSs());
191: } catch (CloneNotSupportedException e2) {
192: responseCRSs = new LinkedList();
193: }
194:
195: nativeFormat = dto.getNativeFormat();
196:
197: try {
198: supportedFormats = CloneLibrary.clone(dto
199: .getSupportedFormats());
200: } catch (CloneNotSupportedException e3) {
201: supportedFormats = new LinkedList();
202: }
203:
204: defaultInterpolationMethod = dto
205: .getDefaultInterpolationMethod();
206:
207: try {
208: interpolationMethods = CloneLibrary.clone(dto
209: .getInterpolationMethods());
210: } catch (CloneNotSupportedException e4) {
211: interpolationMethods = new LinkedList();
212: }
213:
214: defaultStyle = dto.getDefaultStyle();
215: styles = dto.getStyles();
216: parameters = dto.getParameters();
217: }
218:
219: public Object clone() {
220: return new CoverageInfoDTO(this );
221: }
222:
223: public boolean equals(Object obj) {
224: if ((obj == null) || !(obj instanceof CoverageInfoDTO)) {
225: return false;
226: }
227:
228: CoverageInfoDTO f = (CoverageInfoDTO) obj;
229: boolean r = true;
230: r = r && (formatId == f.getFormatId());
231:
232: if (envelope != null) {
233: r = r && envelope.equals(f.getEnvelope());
234: } else if (f.getEnvelope() != null) {
235: return false;
236: }
237:
238: r = r && (srsName == f.getSrsName());
239: r = r && (srsWKT == f.getSrsWKT());
240: r = r && (crs == f.getCrs());
241: r = r && (name == f.getName());
242: r = r && (wmsPath == f.getWmsPath());
243: r = r && (description == f.getDescription());
244: r = r && (label == f.getLabel());
245: r = r && (metadataLink == f.getMetadataLink());
246:
247: if (keywords != null) {
248: r = r && EqualsLibrary.equals(keywords, f.getKeywords());
249: } else if (f.getKeywords() != null) {
250: return false;
251: }
252:
253: r = r && (defaultStyle == f.getDefaultStyle());
254: r = r && (styles == f.getStyles());
255: r = r && (dirName == f.getDirName());
256: r = r && (envelope == f.getEnvelope());
257: r = r && (grid == f.getGrid());
258:
259: return r;
260: }
261:
262: public int hashCode() {
263: int r = 1;
264:
265: if (name != null) {
266: r *= name.hashCode();
267: }
268:
269: if (formatId != null) {
270: r *= formatId.hashCode();
271: }
272:
273: if (label != null) {
274: r *= label.hashCode();
275: }
276:
277: if (envelope != null) {
278: r *= envelope.hashCode();
279: }
280:
281: if (grid != null) {
282: r *= grid.hashCode();
283: }
284:
285: if (srsName != null) {
286: r *= srsName.hashCode();
287: }
288:
289: if (srsWKT != null) {
290: r *= srsWKT.hashCode();
291: }
292:
293: if (crs != null) {
294: r *= crs.hashCode();
295: }
296:
297: return r;
298: }
299:
300: /**
301: * List of keywords (limitied to text).
302: *
303: * @return List of Keywords about this FeatureType
304: *
305: * @uml.property name="keywords"
306: */
307: public List getKeywords() {
308: return keywords;
309: }
310:
311: /**
312: * Convience method for dataStoreId.typeName.
313: *
314: * <p>
315: * This key may be used to store this FeatureType in a Map for later.
316: * </p>
317: *
318: * @return dataStoreId.typeName
319: */
320: public String getKey() {
321: return getFormatId() + DataConfig.SEPARATOR + getName();
322: }
323:
324: /**
325: * Name of featureType, must match typeName provided by DataStore.
326: *
327: * @return typeName of FeatureType
328: *
329: * @uml.property name="name"
330: */
331: public String getName() {
332: return name;
333: }
334:
335: /**
336: * setKeywords purpose.
337: *
338: * <p>
339: * Description ...
340: * </p>
341: *
342: * @param list
343: *
344: * @uml.property name="keywords"
345: */
346: public void setKeywords(List list) {
347: keywords = list;
348: }
349:
350: /**
351: * setKeywords purpose.
352: *
353: * <p>
354: * Description ...
355: * </p>
356: *
357: * @param key
358: *
359: * @return boolean true when added.
360: */
361: public boolean addKeyword(String key) {
362: if (keywords == null) {
363: keywords = new LinkedList();
364: }
365:
366: return keywords.add(key);
367: }
368:
369: /**
370: * setKeywords purpose.
371: *
372: * <p>
373: * Description ...
374: * </p>
375: *
376: * @param key
377: *
378: * @return true whwn removed
379: */
380: public boolean removeKeyword(String key) {
381: return keywords.remove(key);
382: }
383:
384: /**
385: * setName purpose.
386: *
387: * <p>
388: * Description ...
389: * </p>
390: *
391: * @param string
392: *
393: * @uml.property name="name"
394: */
395: public void setName(String string) {
396: name = string;
397: }
398:
399: /**
400: * getDirName purpose.
401: *
402: * <p>
403: * Description ...
404: * </p>
405: *
406: * @return
407: *
408: * @uml.property name="dirName"
409: */
410: public String getDirName() {
411: return dirName;
412: }
413:
414: /**
415: * setDirName purpose.
416: *
417: * <p>
418: * Description ...
419: * </p>
420: *
421: * @param string
422: *
423: * @uml.property name="dirName"
424: */
425: public void setDirName(String string) {
426: dirName = string;
427: }
428:
429: public String toString() {
430: return "[CoverageInfoDTO: " + name + ", formatId: " + formatId
431: + ", envelope: " + envelope + "\n SRS: " + srsName
432: + ", dirName: " + dirName + ", label: " + label
433: + "\n description: " + description;
434: }
435:
436: /**
437: * @return Returns the description.
438: *
439: * @uml.property name="description"
440: */
441: public String getDescription() {
442: return description;
443: }
444:
445: /**
446: * @param description
447: * The description to set.
448: *
449: * @uml.property name="description"
450: */
451: public void setDescription(String description) {
452: this .description = description;
453: }
454:
455: /**
456: * @return Returns the formatId.
457: *
458: * @uml.property name="formatId"
459: */
460: public String getFormatId() {
461: return formatId;
462: }
463:
464: /**
465: * @param formatId
466: * The formatId to set.
467: *
468: * @uml.property name="formatId"
469: */
470: public void setFormatId(String formatId) {
471: this .formatId = formatId;
472: }
473:
474: /**
475: * @return Returns the label.
476: *
477: * @uml.property name="label"
478: */
479: public String getLabel() {
480: return label;
481: }
482:
483: /**
484: * @param label
485: * The label to set.
486: *
487: * @uml.property name="label"
488: */
489: public void setLabel(String label) {
490: this .label = label;
491: }
492:
493: /**
494: * @return Returns the metadataLink.
495: *
496: * @uml.property name="metadataLink"
497: */
498: public MetaDataLink getMetadataLink() {
499: return metadataLink;
500: }
501:
502: /**
503: * @param metadataLink
504: * The metadataLink to set.
505: *
506: * @uml.property name="metadataLink"
507: */
508: public void setMetadataLink(MetaDataLink metadataLink) {
509: this .metadataLink = metadataLink;
510: }
511:
512: /**
513: * @return Returns the defaultInterpolationMethod.
514: *
515: * @uml.property name="defaultInterpolationMethod"
516: */
517: public String getDefaultInterpolationMethod() {
518: return defaultInterpolationMethod;
519: }
520:
521: /**
522: * @param defaultInterpolationMethod
523: * The defaultInterpolationMethod to set.
524: *
525: * @uml.property name="defaultInterpolationMethod"
526: */
527: public void setDefaultInterpolationMethod(
528: String defaultInterpolationMethod) {
529: this .defaultInterpolationMethod = defaultInterpolationMethod;
530: }
531:
532: /**
533: * @return Returns the envelope.
534: *
535: * @uml.property name="envelope"
536: */
537: public GeneralEnvelope getEnvelope() {
538: return envelope;
539: }
540:
541: /**
542: * @param envelope
543: * The envelope to set.
544: *
545: * @uml.property name="envelope"
546: */
547: public void setEnvelope(GeneralEnvelope envelope) {
548: this .envelope = envelope;
549: }
550:
551: /**
552: * @return Returns the interpolationMethods.
553: *
554: * @uml.property name="interpolationMethods"
555: */
556: public List getInterpolationMethods() {
557: return interpolationMethods;
558: }
559:
560: /**
561: * @param interpolationMethods
562: * The interpolationMethods to set.
563: *
564: * @uml.property name="interpolationMethods"
565: */
566: public void setInterpolationMethods(List interpolationMethods) {
567: this .interpolationMethods = interpolationMethods;
568: }
569:
570: /**
571: * @return Returns the nativeFormat.
572: *
573: * @uml.property name="nativeFormat"
574: */
575: public String getNativeFormat() {
576: return nativeFormat;
577: }
578:
579: /**
580: * @param nativeFormat
581: * The nativeFormat to set.
582: *
583: * @uml.property name="nativeFormat"
584: */
585: public void setNativeFormat(String nativeFormat) {
586: this .nativeFormat = nativeFormat;
587: }
588:
589: /**
590: * @return Returns the requestCRSs.
591: *
592: * @uml.property name="requestCRSs"
593: */
594: public List getRequestCRSs() {
595: return requestCRSs;
596: }
597:
598: /**
599: * @param requestCRSs
600: * The requestCRSs to set.
601: *
602: * @uml.property name="requestCRSs"
603: */
604: public void setRequestCRSs(List requestCRSs) {
605: this .requestCRSs = requestCRSs;
606: }
607:
608: /**
609: * @return Returns the responseCRSs.
610: *
611: * @uml.property name="responseCRSs"
612: */
613: public List getResponseCRSs() {
614: return responseCRSs;
615: }
616:
617: /**
618: * @param responseCRSs
619: * The responseCRSs to set.
620: *
621: * @uml.property name="responseCRSs"
622: */
623: public void setResponseCRSs(List responseCRSs) {
624: this .responseCRSs = responseCRSs;
625: }
626:
627: /**
628: * @return Returns the srsName.
629: *
630: * @uml.property name="srsName"
631: */
632: public String getSrsName() {
633: return srsName;
634: }
635:
636: /**
637: * @param srsName
638: * The srsName to set.
639: *
640: * @uml.property name="srsName"
641: */
642: public void setSrsName(String srsName) {
643: this .srsName = srsName;
644: }
645:
646: /**
647: * @return Returns the supportedFormats.
648: *
649: * @uml.property name="supportedFormats"
650: */
651: public List getSupportedFormats() {
652: return supportedFormats;
653: }
654:
655: /**
656: * @param supportedFormats
657: * The supportedFormats to set.
658: *
659: * @uml.property name="supportedFormats"
660: */
661: public void setSupportedFormats(List supportedFormats) {
662: this .supportedFormats = supportedFormats;
663: }
664:
665: /**
666: * getDefaultStyle purpose.
667: *
668: * <p>
669: * Description ...
670: * </p>
671: *
672: * @return
673: *
674: * @uml.property name="defaultStyle"
675: */
676: public String getDefaultStyle() {
677: // HACK: So our UI doesn't seem to allow the setting of styles or
678: // default styles or anything, despite the fact that shit chokes when
679: // none
680: // is present. This is making it so the beta release can not have any
681: // data
682: // stores added to it. This is a hacky ass way to get around it, just
683: // write out a normal style if it is null. This can obviously be done
684: // better, and I have no idea why this default style shit is required -
685: // wfs
686: // does not care about a style. Should be able to seamlessly at least do
687: // something for wms.
688: if ((defaultStyle == null) || defaultStyle.equals("")) {
689: defaultStyle = "raster";
690: }
691:
692: return defaultStyle;
693: }
694:
695: /**
696: * setDefaultStyle purpose.
697: *
698: * <p>
699: * Description ...
700: * </p>
701: *
702: * @param string
703: *
704: * @uml.property name="defaultStyle"
705: */
706: public void setDefaultStyle(String string) {
707: defaultStyle = string;
708: }
709:
710: /**
711: *
712: * @uml.property name="crs"
713: */
714: public CoordinateReferenceSystem getCrs() {
715: return crs;
716: }
717:
718: /**
719: *
720: * @uml.property name="crs"
721: */
722: public void setCrs(CoordinateReferenceSystem crs) {
723: this .crs = crs;
724: }
725:
726: /**
727: *
728: * @uml.property name="grid"
729: */
730: public GridGeometry getGrid() {
731: return grid;
732: }
733:
734: /**
735: *
736: * @uml.property name="grid"
737: */
738: public void setGrid(GridGeometry grid) {
739: this .grid = grid;
740: }
741:
742: /**
743: *
744: * @uml.property name="dimensionNames"
745: */
746: public InternationalString[] getDimensionNames() {
747: return dimensionNames;
748: }
749:
750: /**
751: *
752: * @uml.property name="dimensionNames"
753: */
754: public void setDimensionNames(InternationalString[] dimentionNames) {
755: this .dimensionNames = dimentionNames;
756: }
757:
758: /**
759: * @return Returns the dimensions.
760: *
761: * @uml.property name="dimensions"
762: */
763: public CoverageDimension[] getDimensions() {
764: return dimensions;
765: }
766:
767: /**
768: * @param dimensions
769: * The dimensions to set.
770: *
771: * @uml.property name="dimensions"
772: */
773: public void setDimensions(CoverageDimension[] dimensions) {
774: this .dimensions = dimensions;
775: }
776:
777: public String getSrsWKT() {
778: return srsWKT;
779: }
780:
781: public void setSrsWKT(String srsWKT) {
782: this .srsWKT = srsWKT;
783: }
784:
785: public GeneralEnvelope getLonLatWGS84Envelope() {
786: return lonLatWGS84Envelope;
787: }
788:
789: public void setLonLatWGS84Envelope(GeneralEnvelope latLonEnvelope) {
790: this .lonLatWGS84Envelope = latLonEnvelope;
791: }
792:
793: public String getWmsPath() {
794: return wmsPath;
795: }
796:
797: public void setWmsPath(String wmsPath) {
798: this .wmsPath = wmsPath;
799: }
800:
801: /**
802: * Handling multiple styles
803: */
804: public ArrayList getStyles() {
805: return styles;
806: }
807:
808: public void addStyle(String styleName) {
809: if (!styles.contains(styleName)) {
810: styles.add(styleName);
811: }
812: }
813:
814: public void setStyles(ArrayList styles) {
815: this .styles = styles;
816: }
817:
818: public Map getParameters() {
819: return parameters;
820: }
821:
822: public synchronized void setParameters(Map parameters) {
823: this.parameters = parameters;
824: }
825: }
|