⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data.java

📁 电子地图服务器,搭建自己的地图服务
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                errors.put(featureTypeDTO, configException);

                continue;
            }

            String key2 = prefix + ":" + typeName;

            if (map.containsKey(key2)) {
                if (LOGGER.isLoggable(Level.SEVERE)) {
                    LOGGER.severe(new StringBuffer("FeatureTypeInfo '").append(key2)
                                                                       .append("' already defined - you must have duplicate defined?")
                                                                       .toString());
                }

                errors.put(featureTypeDTO,
                    new ConfigurationException("FeatureTypeInfo '" + key2
                        + "' already defined - you must have duplicate defined?"));
            } else {
                if (LOGGER.isLoggable(Level.FINEST)) {
                    LOGGER.finest(new StringBuffer("FeatureTypeInfo ").append(key2)
                                                                      .append(" has been created...")
                                                                      .toString());
                }

                map.put(key2, featureTypeInfo);
                // set layer name, type vector (0)
                layerNames.put(key2, TYPE_VECTOR);

                if (LOGGER.isLoggable(Level.FINEST)) {
                    LOGGER.finest(new StringBuffer("FeatureTypeInfo '").append(key2)
                                                                       .append("' is registered:")
                                                                       .append(dataStoreInfo)
                                                                       .toString());
                }

                errors.put(featureTypeDTO, Boolean.TRUE);
            }
        }

        return map;
    }

    private List createAttrDTOsFromSchema(FeatureType featureType) {
        List attrList = DataTransferObjectFactory.generateAttributes(featureType);

        /*
         * new ArrayList(featureType.getAttributeCount()); for (int index = 0;
         * index < featureType.getAttributeCount(); index++) { AttributeType
         * attrib = featureType.getAttributeType(index); attrList.add(new
         * AttributeTypeInfoDTO(attrib)); }
         */
        return attrList;
    }

    /**
     * Generate map of geotools2 Styles by id.
     *
     * <p>
     * The filename specified by the StyleDTO will be used to generate the
     * resulting Styles.
     * </p>
     *
     * @param dto
     *            requested configuration
     *
     * @return Map of Style by id
     *
     * @throws NullPointerException
     *             If the style could not be loaded from the filename
     *
     * @see Data.loadStyle() for more information
     */
    private final Map loadStyles(DataDTO dto) {
        Map map = new HashMap();
        stFiles = new HashMap();

        if ((dto == null) || (dto.getStyles() == null)) {
            return Collections.EMPTY_MAP; // we *are* allowed no datasets
        }

        for (Iterator i = dto.getStyles().values().iterator(); i.hasNext();) {
            StyleDTO styleDTO = (StyleDTO) i.next();
            String id = styleDTO.getId();
            Style style;

            try {
                style = loadStyle(styleDTO.getFilename());
                // HACK: due to our crappy weird id shit we rename the style's
                // specified
                // name with the id we (and our clients) refer to the style as.
                // Should redo style management to not make use of our weird
                // ids, just
                // use the style's name out of the styles directory.
                style.setName(id);
            } catch (Exception ioException) { // was IOException

                if (LOGGER.isLoggable(Level.SEVERE)) {
                    LOGGER.log(Level.SEVERE,
                        new StringBuffer("Could not load style ").append(id).toString(), ioException);
                }

                continue;
            }

            stFiles.put(id, styleDTO.getFilename());
            map.put(id, style);
        }

        if (LOGGER.isLoggable(Level.FINER)) {
            LOGGER.finer(new StringBuffer("returning styles ").append(map).append("\n and set map ")
                                                              .append(stFiles).toString());
        }

        return map;
    }

    /**
     * Status output
     *
     * @param title
     *            DOCUMENT ME!
     * @param status
     *            DOCUMENT ME!
     */
    static final void outputStatus(String title, Map status) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info(title);
        }

        for (Iterator i = status.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            String key = (String) entry.getKey();
            Object value = entry.getValue();

            if (value == Boolean.TRUE) {
                if (LOGGER.isLoggable(Level.FINE)) {
                    LOGGER.fine(new StringBuffer(key).append(": ready").toString());
                }
            } else if (value instanceof Throwable) {
                Throwable t = (Throwable) value;

                if (LOGGER.isLoggable(Level.SEVERE)) {
                    LOGGER.log(Level.SEVERE, new StringBuffer(key).append(" not ready").toString(),
                        t);
                }
            } else {
                if (LOGGER.isLoggable(Level.WARNING)) {
                    LOGGER.warning(new StringBuffer(key).append(": '").append(value).append("'")
                                                        .toString());
                }
            }
        }
    }

    /**
     * Dynamically tries to connect to every DataStore!
     *
     * <p>
     * Returns a map of Exception by dataStoreId:typeName. If by some marvel the
     * we could connect to a FeatureSource we will record Boolean.TRUE.
     * </p>
     *
     * @return Map of Exception by dataStoreId:typeName
     */
    public synchronized Map statusDataStores() {
        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;
    }

    /**
     * Dynamically tries to connect to every Namespace!
     *
     * <p>
     * Returns a map of Exception by prefix:typeName. If by some marvel the we
     * could connect to a FeatureSource we will record Boolean.TRUE.
     * </p>
     *
     * @return Map of Exception by prefix:typeName
     */
    public synchronized Map statusNamespaces() {
        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;
    }

    /**
     * toDTO purpose.
     *
     * <p>
     * This method is package visible only, and returns a reference to the
     * GeoServerDTO. This method is unsafe, and should only be used with extreme
     * caution.
     * </p>
     *
     * @return DataDTO the generated object
     */
    public synchronized Object toDTO() {
        DataDTO dto = new DataDTO();

        HashMap tmp;
        Iterator i;
        tmp = new HashMap();
        i = nameSpaces.keySet().iterator();

        while (i.hasNext()) {
            NameSpaceInfo nsi = (NameSpaceInfo) nameSpaces.get(i.next());
            tmp.put(nsi.getPrefix(), nsi.toDTO());
        }

        dto.setNameSpaces(tmp);

        if (defaultNameSpace != null) {
            dto.setDefaultNameSpacePrefix(defaultNameSpace.getPrefix());
        }

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

        while (i.hasNext()) {
            String id = (String) i.next();
            Style st = (Style) styles.get(id);
            StyleDTO sdto = new StyleDTO();
            sdto.setDefault(st.isDefault());
            sdto.setFilename((File) stFiles.get(id));
            sdto.setId(id);
            tmp.put(id, sdto);
        }

        if (LOGGER.isLoggable(Level.FINER)) {
            LOGGER.finer(new StringBuffer("setting styles to: ").append(tmp).toString());
        }

        dto.setStyles(tmp);

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

        while (i.hasNext()) {
            CoverageStoreInfo fmi = (CoverageStoreInfo) formats.get(i.next());
            tmp.put(fmi.getId(), fmi.toDTO());
        }

        dto.setFormats(tmp);

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

        while (i.hasNext()) {
            DataStoreInfo dsi = (DataStoreInfo) dataStores.get(i.next());
            tmp.put(dsi.getId(), dsi.toDTO());
        }

        dto.setDataStores(tmp);

        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);

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

        while (i.hasNext()) {
            CoverageInfo cvi = (CoverageInfo) coverages.get(i.next());
            tmp.put(cvi.getName(), cvi.toDTO());
        }

        dto.setCoverages(tmp);

        return dto;
    }

    /**
     * Locate a DataStoreInfo by its id attribute.
     *
     * @param id
     *            the DataStoreInfo id looked for
     *
     * @return the DataStoreInfo with id attribute equals to <code>id</code>
     *         or null if there no exists
     */
    public synchronized DataStoreInfo getDataStoreInfo(String id) {
        DataStoreInfo dsi = (DataStoreInfo) dataStores.get(id);

        if ((dsi != null) && dsi.isEnabled()) {
            return dsi;
        }

        return null;
    }

    /**
     * Locate a CoverageStoreInfo by its id attribute.
     *
     * @param id
     *            the CoverageStoreInfo id looked for
     *
     * @return the CoverageStoreInfo with id attribute equals to <code>id</code>
     *         or null if there no exists
     */
    public synchronized CoverageStoreInfo getFormatInfo(String id) {
        CoverageStoreInfo dfi = (CoverageStoreInfo) formats.get(id);

        if ((dfi != null) && dfi.isEnabled()) {
            return dfi;
        }

        return null;
    }

    /**
     * getNameSpaces purpose.
     *
     * <p>
     * List of all relevant namespaces
     * </p>
     *
     * @return NameSpaceInfo[]
     */
    public synchronized NameSpaceInfo[] getNameSpaces() {
        NameSpaceInfo[] ns = new NameSpaceInfo[nameSpaces.values().size()];

        return (NameSpaceInfo[]) new ArrayList(nameSpaces.values()).toArray(ns);
    }

    /**
     * getNameSpace purpose.
     *
     * <p>
     * The NameSpaceInfo from the specified prefix
     * </p>
     *
     * @param prefix
     *
     * @return NameSpaceInfo resulting from the specified prefix
     */
    public synchronized NameSpaceInfo getNameSpace(String prefix) {
        NameSpaceInfo retNS = (NameSpaceInfo) nameSpaces.get(prefix);

        return retNS;
    }

    /**
     * Returns the NamespaceINfo object corresponding to a particular
     * namespace uri.
     * <p>
     * If a namespace info object could not be found with mathces <param>uri</param>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -