use of ddf.catalog.data.MetacardType in project ddf by codice.
the class WfsSource method registerFeatureMetacardTypes.
private void registerFeatureMetacardTypes(Map<String, MetacardTypeRegistration> mcTypeRegs) {
// Unregister all MetacardType services - the DescribeFeatureTypeRequest should
// have returned all of the most current metacard types that will now be registered.
// As Source(s) are added/removed from this instance or to other Source(s)
// that this instance is federated to, the list of metacard types will change.
// This is done here vs. inside the above loop so that minimal time is spent clearing and
// registering the MetacardTypes - the concern is that if this registration is too lengthy
// a query could come in that is handled while the MetacardType registrations are
// in a state of flux.
unregisterAllMetacardTypes();
if (!mcTypeRegs.isEmpty()) {
for (MetacardTypeRegistration registration : mcTypeRegs.values()) {
FeatureMetacardType ftMetacard = registration.getFtMetacard();
String simpleName = ftMetacard.getFeatureType().getLocalPart();
ServiceRegistration serviceRegistration = context.registerService(MetacardType.class.getName(), ftMetacard, registration.getProps());
this.metacardTypeServiceRegistrations.put(simpleName, serviceRegistration);
}
}
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class MetacardVersionImpl method toMetacard.
public static Metacard toMetacard(Metacard source, List<MetacardType> types) {
String id = (String) source.getAttribute(MetacardVersion.VERSION_OF_ID).getValue();
if (isNullOrEmpty(id)) {
throw new IllegalStateException("Cannot convert history metacard without the original metacard id");
}
String typeString = (String) source.getAttribute(VERSION_TYPE).getValue();
Optional<MetacardType> typeFromExisting = types.stream().filter(mt -> mt.getName().equals(typeString)).findFirst();
MetacardImpl result = new MetacardImpl(source, typeFromExisting.orElseGet(() -> getMetacardTypeBinary(source).orElseThrow(cannotDeserializeException)));
result.setId(id);
result.setTags(getVersionTags(source));
try {
result.setResourceURI(new URI(String.valueOf(source.getAttribute(VERSIONED_RESOURCE_URI).getValue())));
} catch (URISyntaxException e) {
LOGGER.debug("Could not replace the versioned resource URI, It might not be valid", e);
}
sanitizeVersionAttributes(result);
return result;
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class MetacardServicesTest method testApplyNewAttributesWithEmptyMap.
@Test
public void testApplyNewAttributesWithEmptyMap() throws Exception {
Metacard metacard = createMetacard();
List<Metacard> metacards = ImmutableList.of(metacard);
Map<String, String> attributeMap = ImmutableMap.of();
List<MetacardType> mockMetacardTypes = mock(List.class);
metacardServices = new MetacardServices(mockMetacardTypes);
AttributeFactory mockAttributeFactory = mock(AttributeFactory.class);
List<Metacard> newMetacards = metacardServices.setAttributesIfAbsent(metacards, attributeMap, mockAttributeFactory);
assertThat(newMetacards, hasSize(1));
verifyZeroInteractions(mockMetacardTypes, mockAttributeFactory);
assertThatMetacardHasExpectedTitleAndDescription(newMetacards.get(0));
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class ResourceUriPolicyTest method getMockMetacard.
private Metacard getMockMetacard(String inputResourceUri) throws URISyntaxException {
MetacardType metacardType = mock(MetacardType.class);
when(metacardType.getName()).thenReturn("ddf.metacard");
Metacard inputMetacard = mock(Metacard.class);
when(inputMetacard.getId()).thenReturn("id");
when(inputMetacard.getResourceURI()).thenReturn(new URI(inputResourceUri));
when(inputMetacard.getMetacardType()).thenReturn(metacardType);
return inputMetacard;
}
use of ddf.catalog.data.MetacardType in project ddf by codice.
the class TestMetacardValueResolver method testResolveType.
@Test
public void testResolveType() {
MetacardImpl mc = new MetacardImpl();
String expected = "feature";
MetacardType expectedType = new MetacardTypeImpl(expected, (Set<AttributeDescriptor>) null);
mc.setType(expectedType);
MetacardValueResolver mvr = new MetacardValueResolver();
Object props = mvr.resolve(mc, "properties");
Object actual = mvr.resolve(props, "type");
assertEquals(expected, actual);
}
Aggregations