0001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
0002: * This code is licensed under the GPL 2.0 license, availible at the root
0003: * application directory.
0004: */
0005: package org.vfny.geoserver.form.data;
0006:
0007: import com.vividsolutions.jts.geom.Envelope;
0008: import org.apache.struts.Globals;
0009: import org.apache.struts.action.ActionError;
0010: import org.apache.struts.action.ActionErrors;
0011: import org.apache.struts.action.ActionForm;
0012: import org.apache.struts.action.ActionMapping;
0013: import org.apache.struts.util.MessageResources;
0014: import org.geotools.data.DataStore;
0015: import org.geotools.feature.FeatureType;
0016: import org.geotools.feature.GeometryAttributeType;
0017: import org.geotools.referencing.CRS;
0018: import org.opengis.referencing.FactoryException;
0019: import org.opengis.referencing.crs.CoordinateReferenceSystem;
0020: import org.opengis.referencing.NoSuchAuthorityCodeException;
0021: import org.vfny.geoserver.action.HTMLEncoder;
0022: import org.vfny.geoserver.config.AttributeTypeInfoConfig;
0023: import org.vfny.geoserver.config.ConfigRequests;
0024: import org.vfny.geoserver.config.DataConfig;
0025: import org.vfny.geoserver.config.DataStoreConfig;
0026: import org.vfny.geoserver.config.FeatureTypeConfig;
0027: import org.vfny.geoserver.config.StyleConfig;
0028: import org.vfny.geoserver.global.FeatureTypeInfo;
0029: import org.vfny.geoserver.global.MetaDataLink;
0030: import org.vfny.geoserver.global.UserContainer;
0031: import org.vfny.geoserver.global.dto.AttributeTypeInfoDTO;
0032: import org.vfny.geoserver.global.dto.DataTransferObjectFactory;
0033: import org.vfny.geoserver.util.Requests;
0034: import java.io.IOException;
0035: import java.util.ArrayList;
0036: import java.util.Arrays;
0037: import java.util.Collections;
0038: import java.util.Iterator;
0039: import java.util.LinkedList;
0040: import java.util.List;
0041: import java.util.Locale;
0042: import java.util.SortedSet;
0043: import java.util.TreeSet;
0044: import javax.servlet.ServletContext;
0045: import javax.servlet.http.HttpServletRequest;
0046:
0047: /**
0048: * Form used to work with FeatureType information.
0049: *
0050: * @author jgarnett, Refractions Research, Inc.
0051: * @author $Author: cholmesny $ (last modification)
0052: * @version $Id: TypesEditorForm.java 8391 2008-02-13 16:44:23Z aaime $
0053: */
0054: public class TypesEditorForm extends ActionForm {
0055: static final List schemaBases;
0056: static final List allMetadataURLTypes;
0057:
0058: static {
0059: List bases = new ArrayList();
0060: bases.add("--");
0061: bases.addAll(DataTransferObjectFactory.schemaBaseMap.keySet());
0062: schemaBases = Collections.unmodifiableList(bases);
0063: allMetadataURLTypes = Arrays.asList(new String[] { "FGDC",
0064: "TC211" });
0065: }
0066:
0067: /** Identiy DataStore responsible for this FeatureType */
0068: private String dataStoreId;
0069:
0070: /** Identify Style used to render this feature type */
0071: private String styleId;
0072:
0073: /** Sorted Set of available styles */
0074: private SortedSet panelStyleIds;
0075: private SortedSet typeStyles;
0076: private String[] otherSelectedStyles;
0077:
0078: /**
0079: * Name of featureType.
0080: *
0081: * <p>
0082: * An exact match for typeName provided by a DataStore.
0083: * </p>
0084: */
0085: private String typeName;
0086:
0087: /**
0088: * The alternate name for this feauture type
0089: */
0090: private String alias;
0091:
0092: /**
0093: *
0094: */
0095: private String wmsPath;
0096:
0097: /**
0098: * Representation of the Spatial Reference System.
0099: *
0100: * <p>
0101: * Empty represents unknown, usually assumed to be Cartisian Coordinates.
0102: * </p>
0103: */
0104: private String SRS;
0105:
0106: /**
0107: * WKT representation of the SRS
0108: * This is read-only since it gets generated from the SRS id.
0109: * Everytime SRS is updates (#setSRS()), this will also be re-set.
0110: * If there's a problem with the SRS, this will try to give some info about the error.
0111: */
0112: private String SRSWKT;
0113:
0114: /**
0115: * WKT representation of the native SRS
0116: */
0117: private String nativeSRSWKT;
0118:
0119: private List allSrsHandling;
0120: private int srsHandling = FeatureTypeInfo.FORCE;
0121:
0122: /** Title of this FeatureType */
0123: private String title;
0124:
0125: /** Representation of bounds info as parseable by Double */
0126: private String minX;
0127:
0128: /** Representation of bounds info as parseable by Double */
0129: private String minY;
0130:
0131: /** Representation of bounds info as parseable by Double */
0132: private String maxX;
0133:
0134: /** Representation of bounds info as parseable by Double */
0135: private String maxY;
0136:
0137: /** List of keywords, often grouped with brackets */
0138: private String keywords;
0139:
0140: /** Metadata URL
0141: * This is a quick hack, the user interface and configuration code is really too broken
0142: * to waste time on it...
0143: **/
0144: private MetaDataLink[] metadataLinks;
0145:
0146: /** Metadata URL types **/
0147: private String[] metadataURLTypes;
0148:
0149: /** FeatureType abstract */
0150: private String description;
0151:
0152: /** The amount of time to use for the CacheControl: max-age parameter in maps generated from this featuretype **/
0153: private String cacheMaxAge;
0154:
0155: /** The optional max amount of features to be served over wfs */
0156: private String maxFeatures = "";
0157:
0158: /** Should we add the CacheControl: max-age header to maps generated from this featureType? **/
0159: private boolean cachingEnabled;
0160: private boolean cachingEnabledChecked = false;
0161:
0162: /**
0163: * One of a select list - simplest is AbstractBaseClass.
0164: *
0165: * <p>
0166: * The value "--" will be used to indicate default schema completly
0167: * generated from FeatureType information at runtime.
0168: * </p>
0169: *
0170: * <p>
0171: * When generated the schema will make use a schemaBase of
0172: * "AbstractFeatureType".
0173: * </p>
0174: */
0175: private String schemaBase;
0176:
0177: /**
0178: * The name of the complex element of type schemaBase.
0179: *
0180: * <p>
0181: * We only need this for non generated schemaBase.
0182: * </p>
0183: */
0184: private String schemaName;
0185:
0186: /** List of AttributeDisplay and AttributeForm */
0187: private List attributes;
0188:
0189: /** List of attributes available for addition */
0190: private List addList;
0191:
0192: /** Action requested by user */
0193: private String action;
0194:
0195: /** Sorted Set of available styles */
0196: private SortedSet styles;
0197:
0198: /** A hidden field to enable autogeneration of extents (for SRS and BoundingBox values) **/
0199: private String autoGenerateExtent;
0200:
0201: /** Stores the name of the new attribute they wish to create */
0202: private String newAttribute;
0203:
0204: /** these store the bounding box of DATASET - in it coordinate system.
0205: * normally, you'll have these set to "" or null.
0206: * They're only for information purposes (presentation), they are never persisted or used in any calculations.
0207: */
0208: private String dataMinX;
0209: private String dataMinY;
0210: private String dataMaxX;
0211: private String dataMaxY;
0212: private CoordinateReferenceSystem declaredCRS;
0213: private CoordinateReferenceSystem nativeCRS;
0214:
0215: /**
0216: * Set up FeatureTypeEditor from from Web Container.
0217: *
0218: * <p>
0219: * The key DataConfig.SELECTED_FEATURE_TYPE is used to look up the selected
0220: * from the web container.
0221: * </p>
0222: *
0223: * @param mapping
0224: * @param request
0225: */
0226: public void reset(ActionMapping mapping, HttpServletRequest request) {
0227: super .reset(mapping, request);
0228:
0229: action = "";
0230:
0231: ServletContext servletContext = getServlet()
0232: .getServletContext();
0233: ServletContext context = servletContext;
0234:
0235: DataConfig config = ConfigRequests.getDataConfig(request);
0236: UserContainer user = Requests.getUserContainer(request);
0237:
0238: FeatureTypeConfig type = user.getFeatureTypeConfig();
0239:
0240: if (type == null) {
0241: System.out.println("Type is not there");
0242:
0243: // Not sure what to do, user must have bookmarked?
0244: return; // Action should redirect to Select screen?
0245: }
0246:
0247: this .dataStoreId = type.getDataStoreId();
0248: this .styleId = type.getDefaultStyle();
0249:
0250: description = type.getAbstract();
0251:
0252: this .maxFeatures = type.getMaxFeatures() == 0 ? String
0253: .valueOf(type.getMaxFeatures()) : "";
0254:
0255: this .cacheMaxAge = type.getCacheMaxAge();
0256: this .cachingEnabled = type.isCachingEnabled();
0257: cachingEnabledChecked = false;
0258: this .maxFeatures = String.valueOf(type.getMaxFeatures());
0259:
0260: Envelope bounds = type.getLatLongBBox();
0261:
0262: if ((bounds == null) || bounds.isNull()) {
0263: minX = "";
0264: minY = "";
0265: maxY = "";
0266: maxX = "";
0267: } else {
0268: minX = Double.toString(bounds.getMinX());
0269: minY = Double.toString(bounds.getMinY());
0270: maxX = Double.toString(bounds.getMaxX());
0271: maxY = Double.toString(bounds.getMaxY());
0272: }
0273:
0274: Envelope nativeBounds = type.getNativeBBox();
0275:
0276: if ((nativeBounds == null) || nativeBounds.isNull()) {
0277: dataMinX = "";
0278: dataMinY = "";
0279: dataMaxX = "";
0280: dataMaxY = "";
0281: } else {
0282: dataMinX = Double.toString(nativeBounds.getMinX());
0283: dataMinY = Double.toString(nativeBounds.getMinY());
0284: dataMaxX = Double.toString(nativeBounds.getMaxX());
0285: dataMaxY = Double.toString(nativeBounds.getMaxY());
0286: }
0287:
0288: typeName = type.getName();
0289: alias = type.getAlias();
0290: setSRS(Integer.toString(type.getSRS())); // doing it this way also sets SRSWKT
0291: srsHandling = type.getSRSHandling();
0292:
0293: nativeSRSWKT = "-";
0294: DataStore dataStore = null;
0295: try {
0296: DataConfig dataConfig = (DataConfig) servletContext
0297: .getAttribute(DataConfig.CONFIG_KEY);
0298: DataStoreConfig dsConfig = dataConfig.getDataStore(type
0299: .getDataStoreId());
0300: dataStore = dsConfig.findDataStore(servletContext);
0301: FeatureType featureType = dataStore.getSchema(type
0302: .getName());
0303: GeometryAttributeType dg = featureType.getDefaultGeometry();
0304: if (dg != null && dg.getCoordinateSystem() != null) {
0305: nativeCRS = dg.getCoordinateSystem();
0306: nativeSRSWKT = dg.getCoordinateSystem().toString();
0307: }
0308: } catch (Exception e) {
0309: // never mind
0310: } finally {
0311: if (dataStore != null)
0312: dataStore.dispose();
0313: }
0314:
0315: // load localized
0316: MessageResources resources = ((MessageResources) request
0317: .getAttribute(Globals.MESSAGES_KEY));
0318: if (nativeSRSWKT == "-")
0319: allSrsHandling = Arrays.asList(new String[] { resources
0320: .getMessage("label.type.forceSRS") });
0321: else
0322: allSrsHandling = Arrays.asList(new String[] {
0323: resources.getMessage("label.type.forceSRS"),
0324: resources.getMessage("label.type.reprojectSRS"),
0325: resources.getMessage("label.type.leaveSRS") });
0326:
0327: title = type.getTitle();
0328: wmsPath = type.getWmsPath();
0329:
0330: System.out.println("rest based on schemaBase: "
0331: + type.getSchemaBase());
0332:
0333: // Generate ReadOnly list of Attributes
0334: //
0335: DataStoreConfig dataStoreConfig = config
0336: .getDataStore(dataStoreId);
0337: FeatureType featureType = null;
0338:
0339: try {
0340: dataStore = dataStoreConfig.findDataStore(servletContext);
0341: featureType = dataStore.getSchema(typeName);
0342: } catch (IOException e) {
0343: // DataStore unavailable!
0344: } finally {
0345: if (dataStore != null)
0346: dataStore.dispose();
0347: }
0348:
0349: if (((type.getSchemaBase() == null) || "--".equals(type
0350: .getSchemaBase()))
0351: || (type.getSchemaAttributes() == null)) {
0352: //We are using the generated attributes
0353: this .schemaBase = "--";
0354: this .schemaName = typeName + "_Type";
0355: this .attributes = new LinkedList();
0356:
0357: // Generate ReadOnly list of Attributes
0358: //
0359: List generated = DataTransferObjectFactory
0360: .generateAttributes(featureType);
0361: this .attributes = attributesDisplayList(generated);
0362: addList = Collections.EMPTY_LIST;
0363: } else {
0364: this .schemaBase = type.getSchemaBase();
0365: this .schemaName = type.getSchemaName();
0366: this .attributes = new LinkedList();
0367:
0368: //
0369: // Need to add read only AttributeDisplay for each required attribute
0370: // defined by schemaBase
0371: //
0372: List schemaAttributes = DataTransferObjectFactory
0373: .generateRequiredAttributes(schemaBase);
0374: attributes.addAll(attributesDisplayList(schemaAttributes));
0375: attributes.addAll(attributesFormList(type
0376: .getSchemaAttributes(), featureType));
0377: addList = new ArrayList(featureType.getAttributeCount());
0378:
0379: for (int i = 0; i < featureType.getAttributeCount(); i++) {
0380: String attributeName = featureType.getAttributeType(i)
0381: .getName();
0382:
0383: if (lookUpAttribute(attributeName) == null) {
0384: addList.add(attributeName);
0385: }
0386: }
0387: }
0388:
0389: StringBuffer buf = new StringBuffer();
0390:
0391: for (Iterator i = type.getKeywords().iterator(); i.hasNext();) {
0392: String keyword = (String) i.next();
0393: buf.append(keyword);
0394:
0395: if (i.hasNext()) {
0396: buf.append(", ");
0397: }
0398: }
0399:
0400: this .keywords = buf.toString();
0401:
0402: metadataLinks = new MetaDataLink[2];
0403: metadataLinks[0] = new MetaDataLink();
0404: metadataLinks[0].setType("text/plain");
0405: metadataLinks[1] = new MetaDataLink();
0406: metadataLinks[1].setType("text/plain");
0407:
0408: if ((type.getMetadataLinks() != null)
0409: && (type.getMetadataLinks().size() > 0)) {
0410: List links = new ArrayList(type.getMetadataLinks());
0411: MetaDataLink link = (MetaDataLink) links.get(0);
0412: metadataLinks[0] = new MetaDataLink(link);
0413:
0414: if (links.size() > 1) {
0415: link = (MetaDataLink) links.get(1);
0416: metadataLinks[1] = new MetaDataLink(link);
0417: }
0418: }
0419:
0420: styles = new TreeSet();
0421:
0422: for (Iterator i = config.getStyles().values().iterator(); i
0423: .hasNext();) {
0424: StyleConfig sc = (StyleConfig) i.next();
0425: styles.add(sc.getId());
0426:
0427: if (sc.isDefault()) {
0428: if ((styleId == null) || styleId.equals("")) {
0429: styleId.equals(sc.getId());
0430: }
0431: }
0432: }
0433:
0434: typeStyles = new TreeSet();
0435:
0436: for (Iterator i = type.getStyles().iterator(); i.hasNext();) {
0437: String styleName = (String) i.next();
0438: typeStyles.add(styleName);
0439: }
0440:
0441: Object attribute = styles;
0442:
0443: if (attribute instanceof org.vfny.geoserver.form.data.AttributeDisplay) {
0444: ;
0445: }
0446: }
0447:
0448: private Object lookUpAttribute(String name) {
0449: for (Iterator i = attributes.iterator(); i.hasNext();) {
0450: Object attribute = i.next();
0451:
0452: if (attribute instanceof AttributeDisplay
0453: && name.equals(((AttributeDisplay) attribute)
0454: .getName())) {
0455: return attribute;
0456: }
0457:
0458: if (attribute instanceof AttributeForm
0459: && name.equals(((AttributeForm) attribute)
0460: .getName())) {
0461: return attribute;
0462: }
0463: }
0464:
0465: return null;
0466: }
0467:
0468: /**
0469: * Create a List of AttributeDisplay based on AttributeTypeInfoDTO.
0470: *
0471: * @param dtoList
0472: *
0473: * @return
0474: */
0475: private List attributesDisplayList(List dtoList) {
0476: List list = new ArrayList();
0477: int index = 0;
0478:
0479: for (Iterator i = dtoList.iterator(); i.hasNext(); index++) {
0480: Object next = i.next();
0481: //System.out.println(index + " attribute: " + next);
0482: list.add(new AttributeDisplay(new AttributeTypeInfoConfig(
0483: (AttributeTypeInfoDTO) next)));
0484: }
0485:
0486: return list;
0487: }
0488:
0489: /**
0490: * Create a List of AttributeForm based on AttributeTypeInfoDTO.
0491: *
0492: * @param dtoList
0493: * @param schema DOCUMENT ME!
0494: *
0495: * @return
0496: */
0497: private List attributesFormList(List dtoList, FeatureType schema) {
0498: List list = new ArrayList();
0499:
0500: for (Iterator i = dtoList.iterator(); i.hasNext();) {
0501: AttributeTypeInfoConfig config = (AttributeTypeInfoConfig) i
0502: .next();
0503: list.add(new AttributeForm(config, schema
0504: .getAttributeType(config.getName())));
0505: }
0506:
0507: return list;
0508: }
0509:
0510: /**
0511: * Generate DTO attributes List for the TypesEditorAction.
0512: *
0513: * <p>
0514: * This list only includes entries defined by the user, not those generated
0515: * by the schemaBase.
0516: * </p>
0517: *
0518: * <p>
0519: * If the user has chosen -- then this list will be <code>null</code>.
0520: * </p>
0521: *
0522: * @return List of user supplied AttributeTypeInfoConfig, or
0523: * <code>null</code>
0524: */
0525: public List toSchemaAttributes() {
0526: if ((schemaBase == null) || schemaBase.equals("--")) {
0527: return null;
0528: }
0529:
0530: List list = new ArrayList();
0531:
0532: for (Iterator i = attributes.iterator(); i.hasNext();) {
0533: Object obj = i.next();
0534:
0535: if (obj instanceof AttributeForm) {
0536: AttributeForm form = (AttributeForm) obj;
0537: list.add(form.toConfig());
0538: }
0539: }
0540:
0541: return list;
0542: }
0543:
0544: public ActionErrors validate(ActionMapping mapping,
0545: HttpServletRequest request) {
0546: ActionErrors errors = new ActionErrors();
0547:
0548: Locale locale = (Locale) request.getLocale();
0549:
0550: //MessageResources messages = servlet.getResources();
0551: //TODO: not sure about this, changed for struts 1.2.8 upgrade
0552: MessageResources messages = (MessageResources) request
0553: .getAttribute(Globals.MESSAGES_KEY);
0554: final String BBOX = HTMLEncoder.decode(messages.getMessage(
0555: locale, "config.data.calculateBoundingBox.label"));
0556: final String SLDWIZARD = HTMLEncoder.decode(messages
0557: .getMessage(locale, "config.data.sldWizard.label"));
0558: final String LOOKUP_SRS = HTMLEncoder.decode(messages
0559: .getMessage(locale, "config.data.lookupSRS.label"));
0560:
0561: // If autoGenerateExtent flag is not set, don't break.
0562: if (autoGenerateExtent == null) {
0563: autoGenerateExtent = "false";
0564: }
0565:
0566: // Pass Attribute Management Actions through without
0567: // much validation.
0568: if (action.startsWith("Up") || action.startsWith("Down")
0569: || action.startsWith("Remove") || action.equals(BBOX)
0570: || action.equals(SLDWIZARD)
0571: || action.equals(LOOKUP_SRS)) {
0572: return errors;
0573: }
0574:
0575: // Check selected style exists
0576: DataConfig data = ConfigRequests.getDataConfig(request);
0577:
0578: if (!(data.getStyles().containsKey(styleId) || ""
0579: .equals(styleId))) {
0580: errors.add("styleId", new ActionError(
0581: "error.styleId.notFound", styleId));
0582: }
0583:
0584: // check name exists in current DataStore?
0585: if (!autoGenerateExtent.equals("true")) {
0586: if (("".equals(minX) || "".equals(minY) || "".equals(maxX) || ""
0587: .equals(maxY))) {
0588: errors.add("latlongBoundingBox", new ActionError(
0589: "error.latLonBoundingBox.required"));
0590: } else {
0591: try {
0592: Double.parseDouble(minX);
0593: Double.parseDouble(minY);
0594: Double.parseDouble(maxX);
0595: Double.parseDouble(maxY);
0596: } catch (NumberFormatException badNumber) {
0597: errors.add("latlongBoundingBox", new ActionError(
0598: "error.latLonBoundingBox.invalid",
0599: badNumber));
0600: }
0601: }
0602: }
0603:
0604: if (isCachingEnabled()) {
0605: try {
0606: Integer.parseInt(cacheMaxAge);
0607: } catch (NumberFormatException nfe) {
0608: errors.add("cacheMaxAge", new ActionError(
0609: "error.cacheMaxAge.malformed", nfe));
0610: } catch (Throwable t) {
0611: errors.add("cacheMaxAge", new ActionError(
0612: "error.cacheMaxAge.error", t));
0613: }
0614: }
0615:
0616: // check number of features
0617: try {
0618: int maxFeatures = Integer.parseInt(this .maxFeatures);
0619: if (maxFeatures < 0)
0620: errors.add("maxFeaturews", new ActionError(
0621: "error.global.maxFeatures"));
0622: } catch (NumberFormatException nfe) {
0623: errors.add("maxFeaturews", new ActionError(
0624: "error.global.maxFeatures", nfe));
0625: }
0626:
0627: // check configured SRS actually exists
0628: try {
0629: Integer.valueOf(SRS);
0630: CRS.decode("EPSG:" + SRS);
0631: } catch (NumberFormatException badNumber) {
0632: errors.add("SRS", new ActionError("error.srs.invalid",
0633: badNumber));
0634: } catch (NoSuchAuthorityCodeException nsace) {
0635: errors.add("SRS", new ActionError("error.srs.unknown"));
0636: } catch (FactoryException fe) {
0637: errors.add("SRS", new ActionError("error.srs.unknown"));
0638: }
0639:
0640: return errors;
0641: }
0642:
0643: /**
0644: * Are belong to us.
0645: *
0646: * <p>
0647: * What can I say it is near a deadline! Easy access for
0648: * <code>Editor.jsp</code>.
0649: * </p>
0650: *
0651: * @return Possible schemaBase options
0652: */
0653: public List getAllYourBase() {
0654: return schemaBases;
0655: }
0656:
0657: public List getAllMetadataURLTypes() {
0658: return allMetadataURLTypes;
0659: }
0660:
0661: //
0662: // Generated Accessors for Editor.jsp
0663: //
0664:
0665: /**
0666: * Access attributes property.
0667: *
0668: * @return Returns the attributes.
0669: */
0670: public List getAttributes() {
0671: return attributes;
0672: }
0673:
0674: /**
0675: * Set attributes to attributes.
0676: *
0677: * @param attributes The attributes to set.
0678: */
0679: public void setAttributes(List attributes) {
0680: this .attributes = attributes;
0681: }
0682:
0683: /**
0684: * Access dataStoreId property.
0685: *
0686: * @return Returns the dataStoreId.
0687: */
0688: public String getDataStoreId() {
0689: return dataStoreId;
0690: }
0691:
0692: /**
0693: * Set dataStoreId to dataStoreId.
0694: *
0695: * @param dataStoreId The dataStoreId to set.
0696: */
0697: public void setDataStoreId(String dataStoreId) {
0698: this .dataStoreId = dataStoreId;
0699: }
0700:
0701: /**
0702: * Access abstact (or description) property.
0703: *
0704: * @return Returns the description.
0705: */
0706: public String getAbstract() {
0707: return description;
0708: }
0709:
0710: /**
0711: * Set abstact (or description) to description.
0712: *
0713: * @param description The description to set.
0714: */
0715: public void setAbstract(String description) {
0716: this .description = description;
0717: }
0718:
0719: /**
0720: * Access keywords property.
0721: *
0722: * @return Returns the keywords.
0723: */
0724: public String getKeywords() {
0725: return keywords;
0726: }
0727:
0728: /**
0729: * Set keywords to keywords.
0730: *
0731: * @param keywords The keywords to set.
0732: */
0733: public void setKeywords(String keywords) {
0734: this .keywords = keywords;
0735: }
0736:
0737: public MetaDataLink getMetadataLink(int index) {
0738: return metadataLinks[index];
0739: }
0740:
0741: /**
0742: * Access name property.
0743: *
0744: * @return Returns the name.
0745: */
0746: public String getTypeName() {
0747: return typeName;
0748: }
0749:
0750: /**
0751: * Set name to name.
0752: *
0753: * @param name The name to set.
0754: */
0755: public void setTypeName(String name) {
0756: this .typeName = name;
0757: }
0758:
0759: /**
0760: * Access schemaBase property.
0761: *
0762: * @return Returns the schemaBase.
0763: */
0764: public String getSchemaBase() {
0765: return schemaBase;
0766: }
0767:
0768: /**
0769: * Set schemaBase to schemaBase.
0770: *
0771: * @param schemaBase The schemaBase to set.
0772: */
0773: public void setSchemaBase(String schemaBase) {
0774: this .schemaBase = schemaBase;
0775: }
0776:
0777: /**
0778: * Access sRS property.
0779: *
0780: * @return Returns the sRS.
0781: */
0782: public String getSRS() {
0783: return SRS;
0784: }
0785:
0786: /**
0787: * Access SRSWKT property. There is no setSRSWKT() because its derived from the SRS id.
0788: *
0789: * @return Returns the sRS.
0790: */
0791: public String getSRSWKT() {
0792: return SRSWKT;
0793: }
0794:
0795: /**
0796: * Access SRSWKT property. There is no setSRSWKT() because its derived from the SRS id.
0797: *
0798: * @return Returns the sRS.
0799: */
0800: public String getNativeSRSWKT() {
0801: return nativeSRSWKT;
0802: }
0803:
0804: /**
0805: * Set sRS to srs.
0806: *
0807: * Also sets WKTSRS.
0808: * srs should be an Integer (in string form) - according to FeatureTypeConfig
0809: *
0810: * @param srs The sRS to set.
0811: */
0812: public void setSRS(String srs) {
0813: SRS = srs;
0814:
0815: try {
0816: // srs should be an Integer - according to FeatureTypeConfig
0817: // TODO: make everything consistent for SRS - either its an int or a
0818: // string.
0819: String newSrs = srs;
0820:
0821: if (newSrs.indexOf(':') == -1) {
0822: newSrs = "EPSG:" + srs;
0823: }
0824:
0825: declaredCRS = CRS.decode(newSrs);
0826: SRSWKT = declaredCRS.toString();
0827: } catch (FactoryException e) // couldnt decode their code
0828: {
0829: // DJB:
0830: // dont know how to internationize this inside a set() method!!!
0831: // I think I need the request to get the local, then I can get MessageResources
0832: // from the servlet and call an appropriate method.
0833: // Unforutunately, I dont know how to get the local!
0834: SRSWKT = "Could not find a definition for: EPSG:" + srs;
0835: }
0836: }
0837:
0838: /**
0839: * Access title property.
0840: *
0841: * @return Returns the title.
0842: */
0843: public String getTitle() {
0844: return title;
0845: }
0846:
0847: /**
0848: * Set title to title.
0849: *
0850: * @param title The title to set.
0851: */
0852: public void setTitle(String title) {
0853: this .title = title;
0854: }
0855:
0856: /**
0857: * DOCUMENT ME!
0858: *
0859: * @return Returns the action.
0860: */
0861: public String getAction() {
0862: return action;
0863: }
0864:
0865: /**
0866: * DOCUMENT ME!
0867: *
0868: * @param action The action to set.
0869: */
0870: public void setAction(String action) {
0871: this .action = action;
0872: }
0873:
0874: /**
0875: * DOCUMENT ME!
0876: *
0877: * @return Returns the maxX.
0878: */
0879: public String getMaxX() {
0880: return maxX;
0881: }
0882:
0883: /**
0884: * DOCUMENT ME!
0885: *
0886: * @param maxX The maxX to set.
0887: */
0888: public void setMaxX(String maxX) {
0889: this .maxX = maxX;
0890: }
0891:
0892: /**
0893: * DOCUMENT ME!
0894: *
0895: * @return Returns the maxY.
0896: */
0897: public String getMaxY() {
0898: return maxY;
0899: }
0900:
0901: /**
0902: * DOCUMENT ME!
0903: *
0904: * @param maxY The maxY to set.
0905: */
0906: public void setMaxY(String maxY) {
0907: this .maxY = maxY;
0908: }
0909:
0910: /**
0911: * DOCUMENT ME!
0912: *
0913: * @return Returns the minX.
0914: */
0915: public String getMinX() {
0916: return minX;
0917: }
0918:
0919: /**
0920: * DOCUMENT ME!
0921: *
0922: * @param minX The minX to set.
0923: */
0924: public void setMinX(String minX) {
0925: this .minX = minX;
0926: }
0927:
0928: /**
0929: * DOCUMENT ME!
0930: *
0931: * @return Returns the minY.
0932: */
0933: public String getMinY() {
0934: return minY;
0935: }
0936:
0937: /**
0938: * DOCUMENT ME!
0939: *
0940: * @param minY The minY to set.
0941: */
0942: public void setMinY(String minY) {
0943: this .minY = minY;
0944: }
0945:
0946: /**
0947: * DOCUMENT ME!
0948: *
0949: * @return Returns the styleId.
0950: */
0951: public String getStyleId() {
0952: return styleId;
0953: }
0954:
0955: /**
0956: * DOCUMENT ME!
0957: *
0958: * @param styleId The styleId to set.
0959: */
0960: public void setStyleId(String styleId) {
0961: this .styleId = styleId;
0962: }
0963:
0964: /**
0965: * DOCUMENT ME!
0966: *
0967: * @return Returns the styles.
0968: */
0969: public SortedSet getStyles() {
0970: return styles;
0971: }
0972:
0973: /**
0974: * DOCUMENT ME!
0975: *
0976: * @param styles The styles to set.
0977: */
0978: public void setStyles(SortedSet styles) {
0979: this .styles = styles;
0980: }
0981:
0982: public Object getAttribute(int index) {
0983: return attributes.get(index);
0984: }
0985:
0986: public void setAttribute(int index, Object attribute) {
0987: attributes.set(index, attribute);
0988: }
0989:
0990: /**
0991: * Access newAttribute property.
0992: *
0993: * @return Returns the newAttribute.
0994: */
0995: public String getNewAttribute() {
0996: return newAttribute;
0997: }
0998:
0999: /**
1000: * Set newAttribute to newAttribute.
1001: *
1002: * @param newAttribute The newAttribute to set.
1003: */
1004: public void setNewAttribute(String newAttribute) {
1005: this .newAttribute = newAttribute;
1006: }
1007:
1008: /**
1009: * Access the autoGenerateExtent attribute.
1010: *
1011: */
1012: public String getAutoGenerateExtent() {
1013: if (this .autoGenerateExtent == null) {
1014: this .autoGenerateExtent = "false";
1015: }
1016:
1017: return this .autoGenerateExtent;
1018: }
1019:
1020: /**
1021: * Set autoGenerateExtent to autoGenerateExtent.
1022: * @param autoGenerateExtent The autoGenerateExtent to set.
1023: */
1024: public void setAutoGenerateExtent(String autoGenerateExtent) {
1025: this .autoGenerateExtent = autoGenerateExtent;
1026: }
1027:
1028: /**
1029: * DOCUMENT ME!
1030: *
1031: * @return List of attributes available for addition
1032: */
1033: public List getCreateableAttributes() {
1034: return addList;
1035: }
1036:
1037: /**
1038: * DOCUMENT ME!
1039: *
1040: * @return Returns the schemaName.
1041: */
1042: public String getSchemaName() {
1043: return schemaName;
1044: }
1045:
1046: /**
1047: * DOCUMENT ME!
1048: *
1049: * @param schemaName The schemaName to set.
1050: */
1051: public void setSchemaName(String schemaName) {
1052: this .schemaName = schemaName;
1053: }
1054:
1055: public void setDataMinX(String x) {
1056: dataMinX = x;
1057: }
1058:
1059: public void setDataMinY(String x) {
1060: dataMinY = x;
1061: }
1062:
1063: public void setDataMaxX(String x) {
1064: dataMaxX = x;
1065: }
1066:
1067: public void setDataMaxY(String x) {
1068: dataMaxY = x;
1069: }
1070:
1071: public String getDataMinX() {
1072: return dataMinX;
1073: }
1074:
1075: public String getDataMinY() {
1076: return dataMinY;
1077: }
1078:
1079: public String getDataMaxX() {
1080: return dataMaxX;
1081: }
1082:
1083: public String getDataMaxY() {
1084: return dataMaxY;
1085: }
1086:
1087: public String getWmsPath() {
1088: return wmsPath;
1089: }
1090:
1091: public void setWmsPath(String wmsPath) {
1092: this .wmsPath = wmsPath;
1093: }
1094:
1095: public String getCacheMaxAge() {
1096: return cacheMaxAge;
1097: }
1098:
1099: public void setCacheMaxAge(String cacheMaxAge) {
1100: this .cacheMaxAge = cacheMaxAge;
1101: }
1102:
1103: public boolean isCachingEnabled() {
1104: return cachingEnabled;
1105: }
1106:
1107: public void setCachingEnabled(boolean cachingEnabled) {
1108: cachingEnabledChecked = true;
1109: this .cachingEnabled = cachingEnabled;
1110: }
1111:
1112: public boolean isCachingEnabledChecked() {
1113: return cachingEnabledChecked;
1114: }
1115:
1116: public String[] getOtherSelectedStyles() {
1117: return otherSelectedStyles;
1118: }
1119:
1120: public void setOtherSelectedStyles(String[] otherSelectedStyles) {
1121: this .otherSelectedStyles = otherSelectedStyles;
1122: }
1123:
1124: public SortedSet getPanelStyleIds() {
1125: return panelStyleIds;
1126: }
1127:
1128: public SortedSet getTypeStyles() {
1129: return typeStyles;
1130: }
1131:
1132: public List getAllSrsHandling() {
1133: return allSrsHandling;
1134: }
1135:
1136: /**
1137: * This methods are used by the form, where the "leave" option cannot be offered, if
1138: * they are equal the drop down list won't be shown, that's all
1139: * @return
1140: */
1141: public String getSrsHandling() {
1142: if (srsHandling >= 0 && srsHandling < allSrsHandling.size())
1143: return (String) allSrsHandling.get(srsHandling);
1144: else
1145: return (String) allSrsHandling.get(0);
1146: }
1147:
1148: public void setSrsHandling(String handling) {
1149: srsHandling = allSrsHandling.indexOf(handling);
1150: if (srsHandling == -1)
1151: srsHandling = FeatureTypeInfo.FORCE;
1152: }
1153:
1154: public int getSrsHandlingCode() {
1155: return srsHandling;
1156: }
1157:
1158: public void setSrsHandlingCode(int code) {
1159: this .srsHandling = code;
1160: }
1161:
1162: public boolean isDeclaredCRSDifferent() {
1163: return nativeCRS == null
1164: || (declaredCRS != null && !CRS.equalsIgnoreMetadata(
1165: declaredCRS, nativeCRS));
1166: }
1167:
1168: public String getMaxFeatures() {
1169: return maxFeatures;
1170: }
1171:
1172: public void setMaxFeatures(String maxFeatures) {
1173: this .maxFeatures = maxFeatures;
1174: }
1175:
1176: public String getAlias() {
1177: return alias;
1178: }
1179:
1180: public void setAlias(String alias) {
1181: this.alias = alias != null ? alias.trim() : alias;
1182: }
1183:
1184: }
|