Search in sources :

Example 21 with Attribute

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;
}
Also used : Metacard(ddf.catalog.data.Metacard) Attribute(ddf.catalog.data.Attribute) HashMap(java.util.HashMap) AttributeImpl(ddf.catalog.data.impl.AttributeImpl)

Example 22 with Attribute

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));
}
Also used : Serializable(java.io.Serializable) Attribute(ddf.catalog.data.Attribute) Test(org.junit.Test)

Example 23 with Attribute

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;
}
Also used : Attribute(ddf.catalog.data.Attribute) TreeSet(java.util.TreeSet) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardType(ddf.catalog.data.MetacardType)

Example 24 with Attribute

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();
}
Also used : HierarchicalStreamWriter(com.thoughtworks.xstream.io.HierarchicalStreamWriter) Attribute(ddf.catalog.data.Attribute) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) MetacardType(ddf.catalog.data.MetacardType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 25 with Attribute

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);
}
Also used : ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) PreIngestPlugin(ddf.catalog.plugin.PreIngestPlugin) StringUtils(org.apache.commons.lang.StringUtils) CatalogStore(ddf.catalog.source.CatalogStore) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl) LoggerFactory(org.slf4j.LoggerFactory) UpdateStorageRequestImpl(ddf.catalog.content.operation.impl.UpdateStorageRequestImpl) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException) UpdateStorageRequest(ddf.catalog.content.operation.UpdateStorageRequest) Map(java.util.Map) UpdateStorageResponse(ddf.catalog.content.operation.UpdateStorageResponse) Path(java.nio.file.Path) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) Set(java.util.Set) Collectors(java.util.stream.Collectors) PostUpdateStoragePlugin(ddf.catalog.content.plugin.PostUpdateStoragePlugin) Serializable(java.io.Serializable) Objects(java.util.Objects) StorageException(ddf.catalog.content.StorageException) QueryResponse(ddf.catalog.operation.QueryResponse) List(java.util.List) Operation(ddf.catalog.operation.Operation) Attribute(ddf.catalog.data.Attribute) PreAuthorizationPlugin(ddf.catalog.plugin.PreAuthorizationPlugin) Optional(java.util.Optional) UpdateResponse(ddf.catalog.operation.UpdateResponse) CONTENT_PATHS(ddf.catalog.Constants.CONTENT_PATHS) AccessPlugin(ddf.catalog.plugin.AccessPlugin) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Iterables(com.google.common.collect.Iterables) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) HashMap(java.util.HashMap) OperationTransaction(ddf.catalog.operation.OperationTransaction) Function(java.util.function.Function) Update(ddf.catalog.operation.Update) InternalIngestException(ddf.catalog.source.InternalIngestException) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PostIngestPlugin(ddf.catalog.plugin.PostIngestPlugin) UpdateResponseImpl(ddf.catalog.operation.impl.UpdateResponseImpl) ContentItem(ddf.catalog.content.data.ContentItem) PreUpdateStoragePlugin(ddf.catalog.content.plugin.PreUpdateStoragePlugin) Requests(ddf.catalog.util.impl.Requests) CollectionUtils(org.apache.commons.collections.CollectionUtils) Constants(ddf.catalog.Constants) Metacard(ddf.catalog.data.Metacard) SecurityConstants(ddf.security.SecurityConstants) UpdateRequest(ddf.catalog.operation.UpdateRequest) Result(ddf.catalog.data.Result) QueryImpl(ddf.catalog.operation.impl.QueryImpl) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Logger(org.slf4j.Logger) Historian(ddf.catalog.history.Historian) IngestException(ddf.catalog.source.IngestException) StopProcessingException(ddf.catalog.plugin.StopProcessingException) FederationException(ddf.catalog.federation.FederationException) FrameworkProperties(ddf.catalog.impl.FrameworkProperties) AbstractMap(java.util.AbstractMap) OperationTransactionImpl(ddf.catalog.operation.impl.OperationTransactionImpl) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) Filter(org.opengis.filter.Filter) Collections(java.util.Collections) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Serializable(java.io.Serializable) Filter(org.opengis.filter.Filter) HashMap(java.util.HashMap) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl)

Aggregations

Attribute (ddf.catalog.data.Attribute)103 Metacard (ddf.catalog.data.Metacard)39 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)30 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)29 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)26 Serializable (java.io.Serializable)23 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)15 HashMap (java.util.HashMap)15 Result (ddf.catalog.data.Result)14 List (java.util.List)14 MetacardType (ddf.catalog.data.MetacardType)11 QueryResponse (ddf.catalog.operation.QueryResponse)11 Date (java.util.Date)11 Map (java.util.Map)11 HashSet (java.util.HashSet)10 Optional (java.util.Optional)8 Set (java.util.Set)8 Filter (org.opengis.filter.Filter)8 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)7