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;
}
Aggregations