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

      public boolean canConvert(Class clazz)
      Specified by:
      canConvert in interface com.thoughtworks.xstream.converters.ConverterMatcher
    • marshal

      public void marshal(Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
      Specified by:
      marshal in interface com.thoughtworks.xstream.converters.Converter
    • unmarshal

      public Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
      Specified by:
      unmarshal in interface com.thoughtworks.xstream.converters.Converter
    • transform

      public ddf.catalog.data.Metacard transform(InputStream inputStream) throws IOException, ddf.catalog.transform.CatalogTransformerException
      Specified by:
      transform in interface ddf.catalog.transform.InputTransformer
      Throws:
      IOException
      ddf.catalog.transform.CatalogTransformerException
    • transform

      public ddf.catalog.data.Metacard transform(InputStream inputStream, String id) throws IOException, ddf.catalog.transform.CatalogTransformerException
      Specified by:
      transform in interface ddf.catalog.transform.InputTransformer
      Throws:
      IOException
      ddf.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:
      transform in interface ddf.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 converted
      value - the value to be converted
      Returns:
      the value that was extracted from reader and is of the type described by attributeFormat
    • getMetacardAttributeFromCswAttribute

      public ddf.catalog.data.Attribute getMetacardAttributeFromCswAttribute(String cswAttributeName, Serializable cswAttributeValue, String metacardAttributeName)
      Takes a CSW attribute as a name and value and returns an Attribute whose value is cswAttributeValue converted to the type of the attribute metacardAttributeName in a Metacard.
      Parameters:
      cswAttributeName - the name of the CSW attribute
      cswAttributeValue - the value of the CSW attribute
      metacardAttributeName - the name of the Metacard attribute whose type cswAttributeValue will be converted to
      Returns:
      an Attribute with the name metacardAttributeName and the value cswAttributeValue converted to the type of the attribute metacardAttributeName in a Metacard.
    • getCswAttributeFromAttributeName

      public static String getCswAttributeFromAttributeName(String attributeName)
      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