use of ddf.catalog.data.Attribute in project ddf by codice.
the class PointOfContactUpdatePluginTest method getPreviousMetacardsWithPointOfContact.
private Map<String, Metacard> getPreviousMetacardsWithPointOfContact() {
Attribute pocAttribute = new AttributeImpl(Metacard.POINT_OF_CONTACT, ADMIN_EMAIL);
Metacard resourceMetacard1 = getMetacardWithIdAndTag(RESOURCE_ID1, "resource");
resourceMetacard1.setAttribute(pocAttribute);
Metacard resourceMetacard2 = getMetacardWithIdAndTag(RESOURCE_ID2, null);
resourceMetacard2.setAttribute(pocAttribute);
Metacard registryMetacard = getMetacardWithIdAndTag(REGISTRY_ID, "registry");
registryMetacard.setAttribute(pocAttribute);
Map<String, Metacard> existingMetacards = new HashMap<String, Metacard>();
existingMetacards.put(RESOURCE_ID1, resourceMetacard1);
existingMetacards.put(RESOURCE_ID2, resourceMetacard2);
existingMetacards.put(REGISTRY_ID, registryMetacard);
return existingMetacards;
}
use of ddf.catalog.data.Attribute in project ddf by codice.
the class AttributeFactoryTest method testCreateMultiValuedAttributeFromCommaSeparatedList.
@Test
public void testCreateMultiValuedAttributeFromCommaSeparatedList() throws Exception {
when(mockDescriptor.isMultiValued()).thenReturn(true);
when(mockDescriptor.getName()).thenReturn(LANGUAGE);
when(mockType.getAttributeFormat()).thenReturn(STRING);
Attribute attribute = attributeFactory.createAttribute(mockDescriptor, COMMA_SEPARATED_LANGUAGES);
List<Serializable> languages = attribute.getValues();
assertThat(languages, hasSize(3));
assertThat(languages, containsInAnyOrder(ENGLISH, FRENCH, GERMAN));
}
use of ddf.catalog.data.Attribute in project ddf by codice.
the class HandlebarsMetacard method getAttributes.
public Set<AttributeEntry> getAttributes() {
MetacardType metacardType = this.getMetacardType();
Set<AttributeEntry> attributes = new TreeSet<>();
for (AttributeDescriptor descriptor : metacardType.getAttributeDescriptors()) {
Attribute attr = this.getAttribute(descriptor.getName());
if (attr != null) {
attributes.add(new AttributeEntry(attr, descriptor.getType().getAttributeFormat()));
}
}
return attributes;
}
use of ddf.catalog.data.Attribute in project ddf by codice.
the class TestCswMarshallHelper method testWriteAllFields.
@Test
public void testWriteAllFields() {
HierarchicalStreamWriter writer = mock(HierarchicalStreamWriter.class);
MarshallingContext context = mock(MarshallingContext.class);
Attribute attribute = mock(Attribute.class);
when(attribute.getValues()).thenReturn(Arrays.asList(new String[] { "TEST1", "TEST2", "TEST3" }));
MetacardImpl metacard = mock(MetacardImpl.class);
MetacardType metacardType = mock(MetacardType.class);
when(metacard.getMetacardType()).thenReturn(metacardType);
when(metacard.getAttribute(any(String.class))).thenReturn(attribute);
Set<AttributeDescriptor> attributeDescriptors = new HashSet<>();
AttributeDescriptor ad = mock(AttributeDescriptor.class);
when(ad.isMultiValued()).thenReturn(true);
when(ad.getName()).thenReturn(CswConstants.CSW_SOURCE_QNAME.toString());
attributeDescriptors.add(ad);
when(metacardType.getAttributeDescriptors()).thenReturn(attributeDescriptors);
CswMarshallHelper.writeAllFields(writer, context, metacard);
verify(writer, times(3)).startNode(any(String.class));
verify(writer, times(3)).setValue(any(String.class));
verify(writer, times(3)).endNode();
}
use of ddf.catalog.data.Attribute in project ddf by codice.
the class UpdateOperations method createQueryRequest.
private QueryRequestImpl createQueryRequest(UpdateRequest updateRequest) {
List<Filter> idFilters = updateRequest.getUpdates().stream().map(update -> frameworkProperties.getFilterBuilder().attribute(updateRequest.getAttributeName()).is().equalTo().text(update.getKey().toString())).collect(Collectors.toList());
QueryImpl queryImpl = new QueryImpl(queryOperations.getFilterWithAdditionalFilters(idFilters), 1, /* start index */
0, /* page size */
null, false, /* total result count */
0);
Map<String, Serializable> properties = new HashMap<>();
properties.put(SecurityConstants.SECURITY_SUBJECT, opsSecuritySupport.getSubject(updateRequest));
return new QueryRequestImpl(queryImpl, false, updateRequest.getStoreIds(), properties);
}
Aggregations