Search in sources :

Example 1 with MetacardElement

use of ddf.catalog.transformer.xml.binding.MetacardElement in project ddf by codice.

the class AdaptedSourceResponse method getMetacard.

@XmlElement(namespace = METACARD_URI)
public List<MetacardElement> getMetacard() {
    List<MetacardElement> metacards = new ArrayList<MetacardElement>();
    for (Result r : delegate.getResults()) {
        Metacard metacard = r.getMetacard();
        if (metacard == null) {
            continue;
        }
        MetacardElement element = new MetacardElement();
        element.setId(metacard.getId());
        element.setSource(metacard.getSourceId());
        if (metacard.getMetacardType() != null) {
            String metacardTypeName = MetacardImpl.BASIC_METACARD.getName();
            if (isNotBlank(metacard.getMetacardType().getName())) {
                metacardTypeName = metacard.getMetacardType().getName();
            }
            element.setType(metacardTypeName);
            AttributeAdapter attributeAdapter = new AttributeAdapter(metacard.getMetacardType());
            for (AttributeDescriptor descriptor : metacard.getMetacardType().getAttributeDescriptors()) {
                try {
                    element.getAttributes().add(attributeAdapter.marshal(metacard.getAttribute(descriptor.getName())));
                } catch (CatalogTransformerException e) {
                    LOGGER.info("Marshalling error with attribute", e);
                }
            }
        }
        metacards.add(element);
    }
    return metacards;
}
Also used : Metacard(ddf.catalog.data.Metacard) ArrayList(java.util.ArrayList) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardElement(ddf.catalog.transformer.xml.binding.MetacardElement) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) Result(ddf.catalog.data.Result) XmlElement(javax.xml.bind.annotation.XmlElement)

Aggregations

AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 Metacard (ddf.catalog.data.Metacard)1 Result (ddf.catalog.data.Result)1 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1 MetacardElement (ddf.catalog.transformer.xml.binding.MetacardElement)1 ArrayList (java.util.ArrayList)1 XmlElement (javax.xml.bind.annotation.XmlElement)1