use of org.codice.ddf.spatial.ogc.catalog.MetadataTransformer in project ddf by codice.
the class TestCswSourceBase method setUp.
@Before
public void setUp() {
ServiceReference ref = mock(ServiceReference.class);
ServiceReference[] serviceRefs = new ServiceReference[] { ref };
try {
when(mockContext.getServiceReferences(eq(MetadataTransformer.class.getName()), anyString())).thenReturn(serviceRefs);
} catch (InvalidSyntaxException e) {
LOGGER.error(e.getMessage(), e);
}
MetadataTransformer transformer = mock(MetadataTransformer.class);
// Just return same Metacard that was passed in
when(mockContext.getService(any(ServiceReference.class))).thenReturn(transformer);
try {
when(transformer.transform(any(Metacard.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
} catch (CatalogTransformerException e) {
LOGGER.error(e.getMessage(), e);
}
when(mockAvailabilityTask.isAvailable()).thenReturn(true);
}
use of org.codice.ddf.spatial.ogc.catalog.MetadataTransformer in project ddf by codice.
the class AbstractCswSource method createResults.
protected List<Result> createResults(CswRecordCollection cswRecordCollection) {
List<Result> results = new ArrayList<>();
LOGGER.debug("Found {} metacard(s) in the CswRecordCollection.", cswRecordCollection.getCswRecords().size());
String transformerId = getMetadataTransformerId();
MetadataTransformer transformer = lookupMetadataTransformer(transformerId);
for (Metacard metacard : cswRecordCollection.getCswRecords()) {
MetacardImpl wrappedMetacard = new MetacardImpl(metacard);
wrappedMetacard.setSourceId(getId());
if (wrappedMetacard.getAttribute(Core.RESOURCE_DOWNLOAD_URL) != null && wrappedMetacard.getAttribute(Core.RESOURCE_DOWNLOAD_URL).getValue() != null) {
wrappedMetacard.setAttribute(Core.RESOURCE_URI, wrappedMetacard.getAttribute(Core.RESOURCE_DOWNLOAD_URL).getValue());
}
if (wrappedMetacard.getAttribute(Core.DERIVED_RESOURCE_DOWNLOAD_URL) != null && !wrappedMetacard.getAttribute(Core.DERIVED_RESOURCE_DOWNLOAD_URL).getValues().isEmpty()) {
wrappedMetacard.setAttribute(new AttributeImpl(Core.DERIVED_RESOURCE_URI, wrappedMetacard.getAttribute(Core.DERIVED_RESOURCE_DOWNLOAD_URL).getValues()));
}
Metacard tranformedMetacard = wrappedMetacard;
if (transformer != null) {
tranformedMetacard = transform(metacard, transformer);
}
Result result = new ResultImpl(tranformedMetacard);
results.add(result);
}
return results;
}
Aggregations