use of ddf.catalog.data.InjectableAttribute in project ddf by codice.
the class EndpointUtil method getMetacardTypeMap.
@SuppressWarnings("unchecked")
public Map<String, Object> getMetacardTypeMap() {
Map<String, Object> resultTypes = new HashMap<>();
for (MetacardType metacardType : metacardTypes) {
Map<String, Object> attributes = new HashMap<>();
for (AttributeDescriptor descriptor : metacardType.getAttributeDescriptors()) {
Map<String, Object> attributeProperties = new HashMap<>();
attributeProperties.put("type", descriptor.getType().getAttributeFormat().name());
attributeProperties.put("multivalued", descriptor.isMultiValued());
attributeProperties.put("id", descriptor.getName());
attributes.put(descriptor.getName(), attributeProperties);
}
resultTypes.put(metacardType.getName(), attributes);
}
for (InjectableAttribute attribute : injectableAttributes) {
Optional<AttributeDescriptor> lookup = attributeRegistry.lookup(attribute.attribute());
if (!lookup.isPresent()) {
continue;
}
AttributeDescriptor descriptor = lookup.get();
Map<String, Object> attributeProperties = new HashMap<>();
attributeProperties.put("type", descriptor.getType().getAttributeFormat().name());
attributeProperties.put("multivalued", descriptor.isMultiValued());
attributeProperties.put("id", descriptor.getName());
Set<String> types = attribute.metacardTypes().isEmpty() ? resultTypes.keySet() : attribute.metacardTypes();
for (String type : types) {
Map<String, Object> attributes = (Map) resultTypes.getOrDefault(type, new HashMap<String, Object>());
attributes.put(attribute.attribute(), attributeProperties);
resultTypes.put(type, attributes);
}
}
return resultTypes;
}
use of ddf.catalog.data.InjectableAttribute in project ddf by codice.
the class ValidationParser method parseInjections.
private List<Callable<Boolean>> parseInjections(Changeset changeset, List<Outer.Injection> injections) {
BundleContext context = getBundleContext();
return injections.stream().map(injection -> (Callable<Boolean>) () -> {
String attribute = injection.attribute;
InjectableAttribute injectableAttribute = new InjectableAttributeImpl(attribute, injection.metacardTypes);
ServiceRegistration<InjectableAttribute> injectableAttributeService = context.registerService(InjectableAttribute.class, injectableAttribute, null);
changeset.injectableAttributeServices.add(injectableAttributeService);
return true;
}).collect(toList());
}
use of ddf.catalog.data.InjectableAttribute in project ddf by codice.
the class InjectableAttributeImplTest method testSpecificMetacardTypes.
@Test
public void testSpecificMetacardTypes() {
final String attribute = "attribute";
final Set<String> metacardTypes = Sets.newHashSet("type1", "type2", "type3");
InjectableAttribute injectableAttribute = new InjectableAttributeImpl(attribute, metacardTypes);
assertThat(injectableAttribute.attribute(), is(attribute));
assertThat(injectableAttribute.metacardTypes(), is(metacardTypes));
}
use of ddf.catalog.data.InjectableAttribute in project ddf by codice.
the class InjectableAttributeImplTest method testNullMetacardTypeCollection.
@Test
public void testNullMetacardTypeCollection() {
final String attribute = "attribute";
InjectableAttribute injectableAttribute = new InjectableAttributeImpl(attribute, null);
assertThat(injectableAttribute.attribute(), is(attribute));
assertThat(injectableAttribute.metacardTypes(), is(empty()));
}
Aggregations