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

📄 cswsearchtaskbean.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * in the advanced search options of the CS/W get records request.
     *
     * @param culturalDC True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public void setCulturalDC(boolean culturalDC) {
        m_culturalDC = culturalDC;
    }

    /**
     * Gets the Facilities data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @return True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public boolean getFacilitiesDC() {
        return m_facilitiesDC;
    }

    /**
     * Sets the Facilities data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @param facilitiesDC True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public void setFacilitiesDC(boolean facilitiesDC) {
        m_facilitiesDC = facilitiesDC;
    }

    /**
     * Gets the Transportation data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @return True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public boolean getTransportationDC() {
        return m_transportationDC;
    }

    /**
     * Sets the Transportation data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @param transportationDC True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public void setTransportationDC(boolean transportationDC) {
        m_transportationDC = transportationDC;
    }

    /**
     * Gets the Utilities data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @return True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public boolean getUtilitiesDC() {
        return m_utilitiesDC;
    }

    /**
     * Sets the Utilities data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @param utilitiesDC True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public void setUtilitiesDC(boolean utilitiesDC) {
        m_utilitiesDC = utilitiesDC;
    }

    /**
     * Gets the Environmental data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @return True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public boolean getEnvironmentDC() {
        return m_environmentDC;
    }

    /**
     * Sets the Environmental data category value.  This is used
     * in the advanced search options of the CS/W get records request.
     *
     * @param environmentDC True if the client wants to see CS/W records marked as such,
     *                         false otherwise.
     */
    public void setEnvironmentDC(boolean environmentDC) {
        m_environmentDC = environmentDC;
    }

    /**
     * Gets the ID of the selected query.
     *
     * @return {@link String} ID of the selected query.
     */
    public String getSelectedQuery() {
        return m_selectedQuery;
    }

    /**
     * Sets the ID of the selected query.
     *
     * @param query {@link String} ID of the selected query.
     */
    public void setSelectedQuery(String query) {
        m_selectedQuery = query;
    }

    /**
     * Delegates to the {@link #getSavedQueries()} method to retrieve
     * stored queries.
     *
     * @return {@link Map} of stored queries.
     */
    public Map<String, String> getQueries() {
        List<CswPersistenceObject> queries = null;

        m_queries.clear();

        queries = getSavedQueries();

        if (queries == null) {
            _logger.warn("Problem retrieving saved CS/W queries");

            return new HashMap<String, String>();
        }

        for (CswPersistenceObject q : queries) {
            m_queries.put(q.getAttribute(CswPersistenceObject.QUERY_ID_KEY),
                q.getAttribute(CswPersistenceObject.QUERY_NAME_KEY));
        }

        return m_queries;
    }

    /**
     * Gets the max number of records that will be returned
     * from the CS/W service get records request.
     *
     * @return Max number of records per CS/W service request.
     */
    public int getMaxFeaturesPerSearch() {
        return m_maxFeaturesPerSearch;
    }

    /**
     * Sets the max number of records that will be returned
     * from the CS/W service get records request.
     *
     * @param maxFeatures Max number of records per CS/W service request.
     */
    public void setMaxFeaturesPerSearch(int maxFeatures) {
        m_maxFeaturesPerSearch = maxFeatures;
    }

    /**
     * Saves the configured CS/W query to it's XML representation by delegating to
     * {@link CswPersistenceService#saveToXml(CswPersistenceObject)}.
     *
     * @param context Reference to the ADF {@link WebContext} object that is used
     *                         for getting the current map extent.
     * @return {@link String} XML representation of the saved query.
     * @throws NullPointerException Thrown if the <code>context</code> argument is
     *                         <code>null</code>.
     * @throws IllegalStateException Thrown if the {@link CswPersistenceService} member
     *                         has not been set.
     */
    public String saveQueryToString(WebContext context) {
        String strQuery = null;
        CswPersistenceObject obj = null;

        if (context == null) {
            throw new NullPointerException(
                "web context cannot be null - unable to export query");
        }

        if (m_persistenceService == null) {
            throw new IllegalStateException(
                "persistence service cannot be null - unable to load saved queries");
        }

        try {
            obj = createPersistenceObject(context);

            strQuery = m_persistenceService.saveToXml(obj);
        } catch (PersonalizationException ex) {
            _logger.warn("PersonalizationException occurred saving query - unable to export query",
                ex);
        }

        return strQuery;
    }

    /**
     * Gets the {@link List} of result columns that will be added
     * to the {@link WebResults}.
     *
     * @return {@link List} of columns to be added to the {@link WebResults}.
     */
    public List<String> getResultColumns() {
        return m_resultColumns;
    }

    /**
     * Sets the {@link List} of result columns that will be added
     * to the {@link WebResults}.
     *
     * @param columns {@link List} of columns to be added to the {@link WebResults}.
     */
    public void setResultColumns(List<String> columns) {
        m_resultColumns = columns;
    }

    /**
     * Retrieves the {@link List} of stored CS/W queries from the data store
     * by delegating to {@link CswPersistenceService#retrieveAll()}.
     *
     * @return {@link List} of {@link CswPersistenceObject}.
     * @throws IllegalStateException Thrown if the {@link CswPersistenceService} has
     *                         not been set.
     */
    private List<CswPersistenceObject> getSavedQueries() {
        if (m_persistenceService == null) {
            throw new IllegalStateException(
                "persistence service cannot be null - unable to load saved queries");
        }

        try {
            if (m_refreshAvailableQueries) {
                _logger.debug("refreshing available queries.");

                m_availableQueries = m_persistenceService.retrieveAll();

                m_refreshAvailableQueries = false;

                if (m_availableQueries.size() > 0) {
                    m_savedQueriesAvailable = true;
                } else {
                    m_savedQueriesAvailable = false;
                }
            }
        } catch (PersonalizationException ex) {
            _logger.warn("PersonalizationException occurred retrieving saved queries",
                ex);
        }

        return m_availableQueries;
    }

    /**
     * Loads the <code>obj</code> into the task's getter and
     * setters.
     *
     * @param context Reference to the ADF {@link WebContext}.
     * @param obj {@link CswPersistenceObject} to load.
     *
     * @throws NullPointerException Thrown if the <code>context</code> argument
     *                         is <code>null</code>.
     */
    private void loadQuery(WebContext context, CswPersistenceObject obj) {
        IMetadataCatalog mdCatalog = null;
        WebExtent extent = null;

        if (obj == null) {
            throw new NullPointerException("persistence object cannot be null");
        }

        mdCatalog = m_metadataContext.getCatalogById(obj.getAttribute(
                    CswPersistenceObject.CATALOG_ID_KEY));

        if (mdCatalog == null) {
            _logger.info("Unable to load selected query - catalog not found");
            _logger.debug(
                "Unable to load selected query - catalog not found ID: " +
                obj.getAttribute(CswPersistenceObject.CATALOG_ID_KEY));

            return;
        }

        setSelectCatalog(mdCatalog.getId());

        setSaveQueryName(obj.getAttribute(CswPersistenceObject.QUERY_NAME_KEY));
        setSaveQueryDescription(obj.getAttribute(
                CswPersistenceObject.QUERY_DESCRIPTION_KEY));
        setSearchTerm(obj.getAttribute(CswPersistenceObject.SEARCH_TERM_KEY));
        setUseAdvancedQuery(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.ADVANCED_QUERY_KEY)));
        this.setUseDataCategories(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.USE_DATA_CATEGORIES)));
        setLiveDataOrMaps(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.LIVE_DATA_KEY)));
        setAgricultureDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.AGRICULTURE_KEY)));
        setBiologyDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.BIOLOGY_KEY)));
        setAdminDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.ADMIN_KEY)));
        setAtmosphericDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.ATMOSPHERIC_KEY)));
        setBusinessDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.BUSINESS_KEY)));
        setElevationDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.ELEVATION_KEY)));
        setEnvironmentDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.ENVIRONMENT_KEY)));
        setGeologicalDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.GEOLOGICAL_KEY)));
        setHumanDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.HUMAN_KEY)));
        setImageryDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.IMAGERY_KEY)));
        setMilitaryDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.MILITARY_KEY)));
        setInlandWaterDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.INLAND_KEY)));
        setLocationsDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.LOCATIONS_KEY)));
        setOceansDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.OCEANS_KEY)));
        setCadastralDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.CADASTRAL_KEY)));
        setCulturalDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.CULTURAL_KEY)));
        setFacilitiesDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.FACILITIES_KEY)));
        setTransportationDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.TRANSPORTATION_KEY)));
        setUtilitiesDC(Boolean.parseBoolean(obj.getAttribute(
                    CswPersistenceObject.UTILITIES_KEY)));

        setQueryOverlappingView(Boolean.valueOf(obj.getAttribute(
                    CswPersistenceObject.QUERY_OVERLAP_EXTENT_KEY)));

        if (obj.contains(CswPersistenceObject.QUERY_EXTENT_XMIN) &&
                obj.contains(CswPersistenceObject.QUERY_EXTENT_YMIN) &&
                obj.contains(CswPersistenceObject.QUERY_EXTENT_XMAX) &&
                obj.contains(CswPersistenceObject.QUERY_EXTENT_YMAX)) {
            if (getUseAdvancedQuery()) {
                if (getQueryOverlappingView()) {
                    double minx = Double.valueOf(obj.getAttribute(
                                CswPersistenceObject.QUERY_EXTENT_XMIN));
                    double miny = Double.valueOf(obj.getAttribute(
                                CswPersistenceObject.QUERY_EXTENT_YMIN));
                    double maxx = Double.valueOf(obj.getAttribute(
                                CswPersistenceObject.QUERY_EXTENT_XMAX));
                    double maxy = Double.valueOf(obj.getAttribute(
                                CswPersistenceObject.QUERY_EXTENT_YMAX));

                    extent = new WebExtent(minx, miny, maxx, maxy);

                    context.getWebMap().setCurrentExtent(extent);
                    context.refresh();
                }
            }
        }
    }

    /**
     * Utility method to create a {@link CswPersistenceObject} from the task's
     * getters and setters.
     *
     * @param context Reference to the ADF {@link WebContext}.
     * @return {@link CswPersistenceObject} created from the task's getters and setters.
     */
    private CswPersistenceObject createPersistenceObject(WebContext context) {
        CswPersistenceObject obj = null;
        WebExtent currExt = null;

        if (context == null) {
            throw new NullPointerException("context cannot be null");
        }

        obj = new CswPersistenceObject();

        obj.setAttribute(CswPersistenceObject.SEARCH_TERM_KEY, getSearchTerm());
        obj.setAttribute(CswPersistenceObject.LIVE_DATA_KEY,
            String.valueOf(getLiveDataOrMaps()));
        obj.setAttribute(CswPersistenceObject.ADVANCED_QUERY_KEY,
            String.valueOf(getUseAdvancedQuery()));
        obj.setAttribute(CswPersistenceObject.USE_DATA_CATEGORIES,
            String.valueOf(getUseDataCategories()));
        obj.setAttribute(CswPersistenceObject.AGRICULTURE_KEY,
            String.valueOf(getAgricultureDC()));
 

⌨️ 快捷键说明

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