Package org.vfny.geoserver.global.dto

Examples of org.vfny.geoserver.global.dto.FeatureTypeInfoDTO


        Map map = new HashMap();

SCHEMA:
        for (Iterator i = dto.getFeaturesTypes().values().iterator();
                i.hasNext();) {
            FeatureTypeInfoDTO featureTypeDTO = (FeatureTypeInfoDTO) i.next();

            if (featureTypeDTO == null) {
                LOGGER.warning("Ignore null FeatureTypeInfo DTO!");

                continue;
            }

            String key = featureTypeDTO.getKey(); // dataStoreId:typeName

            LOGGER.finer("FeatureType " + key
                + ": loading feature type info dto:" + featureTypeDTO);

            String dataStoreId = featureTypeDTO.getDataStoreId();
            LOGGER.finest("FeatureType " + key + " looking up :" + dataStoreId);

            DataStoreInfo dataStoreInfo = (DataStoreInfo) dataStores.get(dataStoreId);

            if (dataStoreInfo == null) {
                LOGGER.severe("FeatureTypeInfo " + key
                    + " could not be used - DataStore " + dataStoreId
                    + " is not defined!");

                DataStoreInfoDTO tmp = (DataStoreInfoDTO) dto.getDataStores()
                                                             .get(dataStoreId);

                if ((tmp != null) && (!tmp.isEnabled())) {
                    errors.put(featureTypeDTO, Boolean.FALSE);
                } else {
                    errors.put(featureTypeDTO,
                        new ConfigurationException("FeatureTypeInfo " + key
                            + " could not be used - DataStore " + dataStoreId
                            + " is not defined!"));
                }

                continue;
            } else {
                LOGGER.finest(key + " datastore found :" + dataStoreInfo);
            }

            Style s = getStyle(featureTypeDTO.getDefaultStyle());
           
            if (s == null) {
                LOGGER.severe("FeatureTypeInfo " + key + " ignored - Style '"
                    + featureTypeDTO.getDefaultStyle() + "' not found!");

                errors.put(featureTypeDTO,
                    new ConfigurationException("FeatureTypeInfo " + key
                        + " ignored - Style '"
                        + featureTypeDTO.getDefaultStyle() + "' not found!"));

                continue SCHEMA;
            }

            // Check attributes configured correctly against schema
            String typeName = featureTypeDTO.getName();

            try {
                DataStore dataStore = dataStoreInfo.getDataStore();
                FeatureType featureType = dataStore.getSchema(typeName);

                Set attributeNames = new HashSet();
                Set ATTRIBUTENames = new HashSet();

                //as far as I can tell an emtpy list indicates that no
                //schema.xml file was found.  I may be approaching this
                //all wrong, is this logic contained elsewhere?
                //CH: Yeah, this shit was super messed up.  It was causing null pointer
                //exceptions, and then it created this createAttrDTO flag that wasn't
                //then used by anyone.  So I fixed the null and made it so it creates
                //AttributeTypeInfoDTO's (once again, I hate these) from the FeatureType
                //of the real datastore.
                //boolean createAttrDTO = (featureTypeDTO.getSchemaAttributes().size() == 0);
                LOGGER.fine("loading datastore " + typeName);

                boolean createAttrDTO;

                if (featureTypeDTO.getSchemaAttributes() == null) {
                    createAttrDTO = true;
                } else {
                    createAttrDTO = featureTypeDTO.getSchemaAttributes().size() == 0;
                }

                if (createAttrDTO) {
                    List attributeDTOs = createAttrDTOsFromSchema(featureType);
                    featureTypeDTO.setSchemaAttributes(attributeDTOs);
                    LOGGER.finer(
                        "No schema found, setting featureTypeDTO with "
                        + attributeDTOs);
                } else {
                    for (int index = 0;
                            index < featureType.getAttributeCount(); index++) {
                        AttributeType attrib = featureType.getAttributeType(index);
                        attributeNames.add(attrib.getName());
                        ATTRIBUTENames.add(attrib.getName().toUpperCase());
                    }

                    if (featureTypeDTO.getSchemaAttributes() != null) {
                        for (Iterator a = featureTypeDTO.getSchemaAttributes()
                                                        .iterator();
                                a.hasNext();) {
                            AttributeTypeInfoDTO attribDTO = (AttributeTypeInfoDTO) a
                                .next();
                            String attributeName = attribDTO.getName();
View Full Code Here


        Map m = new HashMap();
        Iterator i = errors.entrySet().iterator();

        while (i.hasNext()) {
            Map.Entry e = (Map.Entry) i.next();
            FeatureTypeInfoDTO ftdto = (FeatureTypeInfoDTO) e.getKey();
            m.put(ftdto.getDataStoreId() + ":" + ftdto.getName(), e.getValue());
        }

        return m;
    }
View Full Code Here

        Map m = new HashMap();
        Iterator i = errors.entrySet().iterator();

        while (i.hasNext()) {
            Map.Entry e = (Map.Entry) i.next();
            FeatureTypeInfoDTO ftdto = (FeatureTypeInfoDTO) e.getKey();
            DataStoreInfo dsdto = (DataStoreInfo) dataStores.get(ftdto
                    .getDataStoreId());

            if (dsdto != null) {
                m.put(dsdto.getNamesSpacePrefix() + ":" + ftdto.getName(),
                    e.getValue());
            }
        }

        return m;
View Full Code Here

        tmp = new HashMap();
        i = errors.keySet().iterator();

        while (i.hasNext()) {
            FeatureTypeInfoDTO fti = (FeatureTypeInfoDTO) i.next();
            tmp.put(fti.getKey(), fti.clone());   //DJB:  changed to getKey() from getName() which was NOT unique!
        }

        dto.setFeaturesTypes(tmp);

        return dto;
View Full Code Here

        featuresTypes = new HashMap();

        while (i.hasNext()) {
            Object key = i.next();

            FeatureTypeInfoDTO f = (FeatureTypeInfoDTO) data.getFeaturesTypes()
                                                            .get(key);
            featuresTypes.put(f.getDataStoreId() +":"+ f.getName(),
                new FeatureTypeConfig(f));
        }

        i = data.getStyles().keySet().iterator();
        styles = new HashMap();
View Full Code Here

     * </p>
     *
     * @return FeatureTypeInfoDTO the generated object
     */
    Object toDTO() {
        FeatureTypeInfoDTO dto = new FeatureTypeInfoDTO();
        dto.setAbstract(_abstract);
        dto.setDataStoreId(dataStoreId);
        dto.setDefaultStyle(defaultStyle);
       
        // Modif C. Kolbowicz - 07/10/2004
        if (legendURL != null) {
            dto.setLegendURL((LegendURLDTO)legendURL.toDTO());
        } //-- Modif C. Kolbowicz - 07/10/2004
       
        dto.setDefinitionQuery(definitionQuery);
        dto.setDirName(dirName);
        dto.setKeywords(keywords);
        dto.setLatLongBBox(latLongBBox);
        dto.setName(typeName);
        dto.setNumDecimals(numDecimals);

        List tmp = new LinkedList();
        Iterator i = schema.iterator();

        while (i.hasNext()) {
            tmp.add(((AttributeTypeInfo) i.next()).toDTO());
        }

        dto.setSchemaAttributes(tmp);
        dto.setSchemaBase(schemaBase);
        dto.setSchemaName( getSchemaName() );       
        dto.setSRS(SRS);
        dto.setTitle(title);

        return dto;
    }
View Full Code Here

     * @return a representation of this object as a FeatureTypeInfoDTO
     *
     * @see org.vfny.geoserver.config.DataStructure#toDTO()
     */
    public FeatureTypeInfoDTO toDTO() {
        FeatureTypeInfoDTO f = new FeatureTypeInfoDTO();
        f.setDataStoreId(dataStoreId);
        f.setLatLongBBox(new Envelope(latLongBBox));
        f.setSRS(SRS);

        if( schemaAttributes == null ){
            // Use generated default attributes
            f.setSchemaAttributes( null );           
        }
        else {
            // Use user provided attribtue + schemaBase attribtues
            List s = new ArrayList();
            for (int i = 0; i < schemaAttributes.size(); i++){
                s.add(((AttributeTypeInfoConfig)schemaAttributes.get(i)).toDTO());
            }
            f.setSchemaAttributes(s);           
        }       
        f.setName(name);
        f.setTitle(title);
        f.setAbstract(_abstract);
        f.setNumDecimals(numDecimals);
        f.setDefinitionQuery(definitionQuery);

        try {
            f.setKeywords(new ArrayList(keywords));
        } catch (Exception e) {
            // do nothing, defaults already exist.
        }

        f.setDefaultStyle(defaultStyle);
        f.setDirName(dirName);
        f.setSchemaBase(schemaBase);
        f.setSchemaName(schemaName);
        return f;
    }
View Full Code Here

        // write them
        Iterator i = data.getFeaturesTypes().keySet().iterator();

        while (i.hasNext()) {
            String s = (String) i.next();
            FeatureTypeInfoDTO ft = (FeatureTypeInfoDTO) data.getFeaturesTypes()
                                                             .get(s);

            if (ft != null) {
                File dir2 = WriterUtils.initWriteFile(new File(dir,
                            ft.getDirName()), true);

                storeFeature(ft, dir2);

                if (ft.getSchemaAttributes() != null) {
                    LOGGER.finer(ft.getKey() + " writing schema.xml w/ "
                        + ft.getSchemaAttributes().size());
                    storeFeatureSchema(ft, dir2);
                }
            }
        }

        // delete old ones that are not overwritten
        //I'm changing this action, as it is directly leading to users not
        //being able to create their own shapefiles in the web admin tool.
        //since their shit always gets deleted.  The behaviour has now changed
        //to just getting rid of the geoserver config files, info.xml and
        //schema.xml and leaving any others.  We should revisit this, I
        //do think getting rid of stale featureTypes is a good thing.  For 1.3
        //I want to look into directly uploading shapefiles, and perhaps they
        //would then go in a 'shapefile' directory, next to featureTypes or
        //or something, so that the featureTypes directory only contains
        //the info, and schema and those sorts of files.  But I do kind of like
        //being able to access the shapefiles directly from the web app, and
        //indeed have had thoughts of expanding that, so that users could
        //always download the full shape for a layer, generated automatically
        //if it's from another datastore.  Though I suppose that is not
        //mutually exclusive, just a little wasting of space, for shapefiles
        //would be held twice.
        File[] fa = dir.listFiles();

        for (int j = 0; j < fa.length; j++) {
            // find dir name
            i = data.getFeaturesTypes().values().iterator();

            FeatureTypeInfoDTO fti = null;

            while ((fti == null) && i.hasNext()) {
                FeatureTypeInfoDTO ft = (FeatureTypeInfoDTO) i.next();

                if (ft.getDirName().equals(fa[j].getName())) {
                    fti = ft;
                }
            }

            if (fti == null) {
View Full Code Here

            File info = new File(directories[i], "info.xml");

            if (info.exists() && info.isFile()) {
                LOGGER.finer("Info dir:" + info);

                FeatureTypeInfoDTO dto = loadFeature(info);
                map.put(dto.getKey(), dto);
            }
        }

        return map;
    }
View Full Code Here

        } catch (Exception erk) {
            throw new ConfigurationException("Could not parse info file:"
                + infoFile, erk);
        }

        FeatureTypeInfoDTO dto = loadFeaturePt2(featureElem);

        File parentDir = infoFile.getParentFile();
        dto.setDirName(parentDir.getName());

        List attributeList;

        File schemaFile = new File(parentDir, "schema.xml");

        if (schemaFile.exists() && schemaFile.isFile()) {
            // attempt to load optional schema information
            //
            LOGGER.finest("process schema file " + infoFile);

            try {
                loadSchema(schemaFile, dto);
            } catch (Exception badDog) {
                badDog.printStackTrace();
                attributeList = Collections.EMPTY_LIST;
            }
        } else {
            dto.setSchemaAttributes(Collections.EMPTY_LIST);
        }

        LOGGER.config("added featureType " + dto.getName());

        return dto;
    }
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.global.dto.FeatureTypeInfoDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.