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

📄 metadataresourceadder.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.common.metadata;

import com.esri.adf.web.data.GISResource;

import com.esri.solutions.jitk.web.tasks.resources.ResourceAdder;

/**
 * {@code MetadataResourceAdder} is a custom extension of {@link ResourceAdder}
 * whose responsibilty is to add {@link GISResource GISResources} to the map and
 * then register them in a {@link GISResourceMetadataRegistry}.
 */
public class MetadataResourceAdder extends ResourceAdder
    implements IMetadataAware {

    /**
     * Metadata Context utilized by this class; cannot be {@code null}
     */
    private IMetadataContext _metadataContext = null;

    /**
     * The ID of the metadata document that describes the GIS Resource being
     * added to the map.
     */
    private IMetadataID _metadataID = null;

    /**
     * Default no-arg constructor
     */
    public MetadataResourceAdder() {
    }

    /*
     * (non-Javadoc)
     *
     * @see com.esri.solutions.jitk.common.metadata.IMetadataAware#setMetadataContext(com.esri.solutions.jitk.common.metadata.IMetadataContext)
     */
    public void setMetadataContext(IMetadataContext metadataContext) {
        if (metadataContext == null) {
            throw new NullPointerException("metadataContext cannot be null");
        }

        _metadataContext = metadataContext;
    }

    /**
     * Sets the Metadata ID of the GIS Resource that is being added to the map.
     * This Metadata ID will be used in the
     * {@link IResourceMetadataRegistry Resource Metadata Registry} as the index
     * for the GISResource that was added.
     *
     * @param metadataID
     *            The {@link IMetadataID} of the metadata representing the
     *            GISResource. Cannot be {@code null}
     */
    public void setMetadataID(IMetadataID metadataID) {
        if (metadataID == null) {
            throw new NullPointerException("metadataID cannot be null");
        }

        _metadataID = metadataID;
    }

    /**
     * {@inheritDoc}
     *
     * @throws IllegalStateException
     *             If no Metadata Context has been set
     * @throws IllegalStateException
     *             If no Metadata ID has been set
     * @see #setMetadataContext(IMetadataContext)
     * @see #setMetadataID(IMetadataID)
     * @see GISResourceMetadataRegistry#register(IMetadataID, GISResource)
     */
    public GISResource addAgsSource(String agsHost, String agsDomain,
        String agsUsername, String agsPassword, boolean passwordEncrypted,
        String agsServerObject, boolean transparent, boolean projectMap,
        boolean zoomMap) {
        if (_metadataContext == null) {
            throw new IllegalStateException(
                "Before invoking this method, a metadata context must be set.");
        }

        if (_metadataID == null) {
            throw new IllegalStateException(
                "Before invoking this method, the metadata id of the GIS Resource that is being added, must be set.");
        }

        GISResource resource = super.addAgsSource(agsHost, agsDomain,
                agsUsername, agsPassword, passwordEncrypted, agsServerObject,
                transparent, projectMap, zoomMap);

        if (resource != null) {
            IResourceMetadataRegistry registry = _metadataContext.getResourceMetadataRegistry();
            registry.register(_metadataID, resource);
        }

        return resource;
    }

    /**
     * {@inheritDoc}
     *
     * @throws IllegalStateException
     *             If no Metadata Context has been set
     * @throws IllegalStateException
     *             If no Metadata ID has been set
     * @see #setMetadataContext(IMetadataContext)
     * @see #setMetadataID(IMetadataID)
     * @see GISResourceMetadataRegistry#register(IMetadataID, GISResource)
     */
    public GISResource addArcWebSource(String awsAuthenticationURL,
        String awsMapURL, String awsDataSource, String awsUserName,
        String awsPassword, boolean transparent, boolean projectMap,
        boolean zoomMap) {
        if (_metadataContext == null) {
            throw new IllegalStateException(
                "Before invoking this method, a metadata context must be set.");
        }

        if (_metadataID == null) {
            throw new IllegalStateException(
                "Before invoking this method, the metadata id of the GIS Resource that is being added, must be set.");
        }

        GISResource resource = super.addArcWebSource(awsAuthenticationURL,
                awsMapURL, awsDataSource, awsUserName, awsPassword,
                transparent, projectMap, zoomMap);

        if (resource != null) {
            IResourceMetadataRegistry registry = _metadataContext.getResourceMetadataRegistry();
            registry.register(_metadataID, resource);
        }

        return resource;
    }

    /**
     * {@inheritDoc}
     *
     * @throws IllegalStateException
     *             If no Metadata Context has been set
     * @throws IllegalStateException
     *             If no Metadata ID has been set
     * @see #setMetadataContext(IMetadataContext)
     * @see #setMetadataID(IMetadataID)
     * @see GISResourceMetadataRegistry#register(IMetadataID, GISResource)
     */
    public GISResource addAGSWSSource(String agswsURL, String agswsName,
        boolean transparent, boolean projectMap, boolean zoomMap) {
        if (_metadataContext == null) {
            throw new IllegalStateException(
                "Before invoking this method, a metadata context must be set.");
        }

        if (_metadataID == null) {
            throw new IllegalStateException(
                "Before invoking this method, the metadata id of the GIS Resource that is being added, must be set.");
        }

        GISResource resource = super.addAGSWSSource(agswsURL, agswsName,
                transparent, projectMap, zoomMap);

        if (resource != null) {
            IResourceMetadataRegistry registry = _metadataContext.getResourceMetadataRegistry();
            registry.register(_metadataID, resource);
        }

        return resource;
    }

    /**
     * {@inheritDoc}
     *
     * @throws IllegalStateException
     *             If no Metadata Context has been set
     * @throws IllegalStateException
     *             If no Metadata ID has been set
     * @see #setMetadataContext(IMetadataContext)
     * @see #setMetadataID(IMetadataID)
     * @see GISResourceMetadataRegistry#register(IMetadataID, GISResource)
     */
    public GISResource addAIMSSource(String aimsHost, String aimsPort,
        String aimsUsername, String aimsPassword, String aimsService,
        boolean transparent, boolean projectMap, boolean zoomMap) {
        if (_metadataContext == null) {
            throw new IllegalStateException(
                "Before invoking this method, a metadata context must be set.");
        }

        if (_metadataID == null) {
            throw new IllegalStateException(
                "Before invoking this method, the metadata id of the GIS Resource that is being added, must be set.");
        }

        GISResource resource = super.addAIMSSource(aimsHost, aimsPort,
                aimsUsername, aimsPassword, aimsService, transparent,
                projectMap, zoomMap);

        if (resource != null) {
            IResourceMetadataRegistry registry = _metadataContext.getResourceMetadataRegistry();
            registry.register(_metadataID, resource);
        }

        return resource;
    }

    /**
     * {@inheritDoc}
     *
     * @throws IllegalStateException
     *             If no Metadata Context has been set
     * @throws IllegalStateException
     *             If no Metadata ID has been set
     * @see #setMetadataContext(IMetadataContext)
     * @see #setMetadataID(IMetadataID)
     * @see GISResourceMetadataRegistry#register(IMetadataID, GISResource)
     */
    public GISResource addWMSSource(String wmsInfo, boolean transparent,
        boolean projectMap, boolean zoomMap) {
        if (_metadataContext == null) {
            throw new IllegalStateException(
                "Before invoking this method, a metadata context must be set.");
        }

        if (_metadataID == null) {
            throw new IllegalStateException(
                "Before invoking this method, the metadata id of the GIS Resource that is being added, must be set.");
        }

        GISResource resource = super.addWMSSource(wmsInfo, transparent,
                projectMap, zoomMap);

        if (resource != null) {
            IResourceMetadataRegistry registry = _metadataContext.getResourceMetadataRegistry();
            registry.register(_metadataID, resource);
        }

        return resource;
    }

    /**
     * {@inheritDoc}
     *
     * @throws IllegalStateException
     *             If no Metadata Context has been set
     * @throws IllegalStateException
     *             If no Metadata ID has been set
     * @see #setMetadataContext(IMetadataContext)
     * @see #setMetadataID(IMetadataID)
     * @see GISResourceMetadataRegistry#register(IMetadataID, GISResource)
     */
    public GISResource addWCSSource(String wcsParam, boolean transparent,
        boolean projectMap, boolean zoomMap) {
        if (_metadataContext == null) {
            throw new IllegalStateException(
                "Before invoking this method, a metadata context must be set.");
        }

        if (_metadataID == null) {
            throw new IllegalStateException(
                "Before invoking this method, the metadata id of the GIS Resource that is being added, must be set.");
        }

        GISResource resource = super.addWCSSource(wcsParam, transparent,
                projectMap, zoomMap);

        if (resource != null) {
            IResourceMetadataRegistry registry = _metadataContext.getResourceMetadataRegistry();
            registry.register(_metadataID, resource);
        }

        return resource;
    }
}

⌨️ 快捷键说明

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