📄 cswmetadatacatalog.java
字号:
package com.esri.solutions.jitk.common.metadata.csw;
import com.esri.solutions.jitk.common.metadata.IMetadataCatalog;
import com.esri.solutions.jitk.common.metadata.IMetadataDAO;
import com.esri.solutions.jitk.common.metadata.IMetadataDocument;
import com.esri.solutions.jitk.common.metadata.IMetadataID;
import com.esri.solutions.jitk.common.metadata.InvalidMetadataOperationException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* {@code CSWMetadataCatalog} is a custom {@link IMetadataCatalog} that retrieves metadata from
* an Open Geospatial Consortium (OGC) Catalog Service for the Web (CSW).
*/
public class CSWMetadataCatalog implements IMetadataCatalog {
/**
* Id of the CS/W metadata catalog.
*/
private String _id = null;
/**
* Reference to a {@link IMetadataDAO} object that will access metadata
* from the CS/W service.
*/
private IMetadataDAO _dao = null;
/**
* Reference to the {@link CSWMetadataProfile} that contains information
* on how to create requests and parse responses.
*/
private CSWMetadataProfile _profile = null;
/**
* Name of the CS/W metadata catalog.
*/
private String _name = null;
/**
* Url to the CS/W metadata catalog.
*/
private String _serviceURL = null;
/**
* {@link Map} of configuration parameters.
*/
private Map<String, Object> _attributes = new HashMap<String, Object>();
/**
* Default constructor; does nothing other than instantiate
* a new, unconfigured instance of the class
*/
public CSWMetadataCatalog() {
}
/* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#getAttribute(java.lang.String)
*/
public Object getAttribute(String key) {
if (key == null) {
throw new NullPointerException("key cannot be null");
}
return _attributes.get(key);
}
/* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#getAttributes()
*/
public Map<String, Object> getAttributes() {
// TODO Auto-generated method stub
return _attributes;
}
/* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#setAttribute(java.lang.String, java.lang.Object)
*/
public void setAttribute(String key, Object value) {
if (key == null) {
throw new NullPointerException("key cannot be null");
}
_attributes.put(key, value);
}
/* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#setAttributes(java.util.Map)
*/
public void setAttributes(Map<?extends String, ?extends Object> attrs) {
if (attrs == null) {
throw new NullPointerException("attrs cannot be null");
}
_attributes.putAll(attrs);
}
/**
* Sets an ID by which this catalog can be reference.
* @param id {@link String} containing the ID; cannot be {@code null}
*/
public void setId(String id) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
_id = id;
}
/* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#getId()
*/
public String getId() {
return _id;
}
/**
* Sets the common name by which this CS/W Metadata Catalog can be referred. This
* name will be useful in applications where a reference to this catalog will be
* displayed in a GUI.
* @param name {@link String} containing the name; cannot be {@code null}
*/
public void setName(String name) {
if (name == null) {
throw new NullPointerException("name cannot be null");
}
_name = name;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#getName()
*/
public String getName() {
return _name;
}
/**
* Sets the URL of the CS/W endpoint to which this catalog will connect to retrieve metadata.
* @param serviceURL {@link String} containing the Service URL; cannot be {@code null}
*/
public void setServiceURL(String serviceURL) {
if (serviceURL == null) {
throw new NullPointerException("serviceURL cannot be null");
}
_serviceURL = serviceURL;
}
/**
* Retrieves the URL of the CS/W endpoint to which this catalog will connect to retrieve metadata.
* @return {@link String} containing the service URL.
*/
public String getServiceURL() {
return _serviceURL;
}
/**
* Sets the Metadata Profile used by this catalog to access and parse metadata.
* @param profile cannot be {@code null}
*/
public void setMetadataProfile(CSWMetadataProfile profile) {
if (profile == null) {
throw new NullPointerException("profile cannot be null");
}
_profile = profile;
}
/**
* Sets the Metadata Profile used by this catalog to access and parse metadata.
* @param profile cannot be {@code null}
*/
public void setMetadataProfile2(CSWMetadataProfile profile) {
if (profile == null) {
throw new NullPointerException("profile cannot be null");
}
_profile = profile;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#setMetadataDAO(com.esri.solutions.jitk.common.metadata.IMetadataDAO)
*/
public void setMetadataDAO(IMetadataDAO dao) {
Map<String, Object> props = null;
if (dao == null) {
throw new NullPointerException("dao cannot be null");
}
_dao = dao;
props = new HashMap<String, Object>();
props.put("catalog", this);
_dao.setProperties(props);
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#getMetadataProfile()
*/
public CSWMetadataProfile getMetadataProfile() {
return _profile;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#lookup(com.esri.solutions.jitk.common.metadata.IMetadataID)
*/
public IMetadataDocument lookup(IMetadataID id) {
IMetadataDocument doc = _dao.getDocumentByID(id);
return doc;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#lookupRepositoryItem(com.esri.solutions.jitk.common.metadata.IMetadataID)
*/
public IMetadataDocument lookupRepositoryItem(IMetadataID id)
throws InvalidMetadataOperationException {
IMetadataDocument doc = _dao.getRepositoryItemByID(id);
return doc;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.metadata.IMetadataCatalog#lookup(java.util.Map)
*/
public List<IMetadataDocument> lookup(Map<String, Object> criteria) {
List<IMetadataDocument> results = null;
results = _dao.findDocuments(criteria);
return results;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -