Class CswRecordConverter
java.lang.Object
org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter
- All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter,com.thoughtworks.xstream.converters.ConverterMatcher,ddf.catalog.transform.InputTransformer,ddf.catalog.transform.MetacardTransformer
public class CswRecordConverter
extends Object
implements com.thoughtworks.xstream.converters.Converter, ddf.catalog.transform.MetacardTransformer, ddf.catalog.transform.InputTransformer
Converts CSW Record to a Metacard.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanConvert(Class clazz) static SerializableconvertStringValueToMetacardValue(ddf.catalog.data.AttributeType.AttributeFormat attributeFormat, String value) Converts properties in CSW records that overlap with same name as a basic Metacard attribute, e.g., title.static StringgetCswAttributeFromAttributeName(String attributeName) Converts an attribute name to the csw:Record attribute it corresponds to.ddf.catalog.data.AttributegetMetacardAttributeFromCswAttribute(String cswAttributeName, Serializable cswAttributeValue, String metacardAttributeName) Takes a CSW attribute as a name and value and returns anAttributewhose value iscswAttributeValueconverted to the type of the attributemetacardAttributeNamein aMetacard.voidmarshal(Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context) ddf.catalog.data.BinaryContenttransform(ddf.catalog.data.Metacard metacard, Map<String, Serializable> arguments) ddf.catalog.data.Metacardtransform(InputStream inputStream) ddf.catalog.data.Metacardtransform(InputStream inputStream, String id) unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
-
Field Details
-
XML_MIME_TYPE
public static final javax.activation.MimeType XML_MIME_TYPE
-
-
Constructor Details
-
CswRecordConverter
public CswRecordConverter(ddf.catalog.data.MetacardType metacardType)
-
-
Method Details
-
canConvert
- Specified by:
canConvertin interfacecom.thoughtworks.xstream.converters.ConverterMatcher
-
marshal
public void marshal(Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context) - Specified by:
marshalin interfacecom.thoughtworks.xstream.converters.Converter
-
unmarshal
public Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context) - Specified by:
unmarshalin interfacecom.thoughtworks.xstream.converters.Converter
-
transform
public ddf.catalog.data.Metacard transform(InputStream inputStream) throws IOException, ddf.catalog.transform.CatalogTransformerException - Specified by:
transformin interfaceddf.catalog.transform.InputTransformer- Throws:
IOExceptionddf.catalog.transform.CatalogTransformerException
-
transform
public ddf.catalog.data.Metacard transform(InputStream inputStream, String id) throws IOException, ddf.catalog.transform.CatalogTransformerException - Specified by:
transformin interfaceddf.catalog.transform.InputTransformer- Throws:
IOExceptionddf.catalog.transform.CatalogTransformerException
-
transform
public ddf.catalog.data.BinaryContent transform(ddf.catalog.data.Metacard metacard, Map<String, Serializable> arguments) throws ddf.catalog.transform.CatalogTransformerException- Specified by:
transformin interfaceddf.catalog.transform.MetacardTransformer- Throws:
ddf.catalog.transform.CatalogTransformerException
-
convertStringValueToMetacardValue
public static Serializable convertStringValueToMetacardValue(ddf.catalog.data.AttributeType.AttributeFormat attributeFormat, String value) Converts properties in CSW records that overlap with same name as a basic Metacard attribute, e.g., title. This conversion method is needed mainly because CSW records express all dates as strings, whereas MetacardImpl expresses them as java.util.Date types.- Parameters:
attributeFormat- the format of the attribute to be convertedvalue- the value to be converted- Returns:
- the value that was extracted from
readerand is of the type described byattributeFormat
-
getMetacardAttributeFromCswAttribute
public ddf.catalog.data.Attribute getMetacardAttributeFromCswAttribute(String cswAttributeName, Serializable cswAttributeValue, String metacardAttributeName) Takes a CSW attribute as a name and value and returns anAttributewhose value iscswAttributeValueconverted to the type of the attributemetacardAttributeNamein aMetacard.- Parameters:
cswAttributeName- the name of the CSW attributecswAttributeValue- the value of the CSW attributemetacardAttributeName- the name of theMetacardattribute whose typecswAttributeValuewill be converted to- Returns:
- an
Attributewith the namemetacardAttributeNameand the valuecswAttributeValueconverted to the type of the attributemetacardAttributeNamein aMetacard.
-
getCswAttributeFromAttributeName
Converts an attribute name to the csw:Record attribute it corresponds to.- Parameters:
attributeName- the name of the attribute- Returns:
- the name of the csw:Record attribute that this attribute name corresponds to
-