Search in sources :

Example 26 with AttributeDescriptor

use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.

the class SolrProviderTest method testNumericSort.

@Test
public void testNumericSort() throws Exception {
    deleteAllIn(provider);
    /* SETUP */
    String doubleField = "hertz";
    double doubleFieldValue = 16065.435;
    String floatField = "inches";
    float floatFieldValue = 4.435f;
    String intField = "count";
    int intFieldValue = 4;
    String longField = "milliseconds";
    long longFieldValue = 9876543293L;
    String shortField = "daysOfTheWeek";
    short shortFieldValue = 1;
    int factor = 5;
    List<Metacard> list = new ArrayList<Metacard>();
    DateTime now = new DateTime();
    for (int i = 0; i < 5; i++) {
        Set<AttributeDescriptor> descriptors = numericalDescriptors(doubleField, floatField, intField, longField, shortField);
        MetacardTypeImpl mType = new MetacardTypeImpl("numberMetacardType", descriptors);
        MetacardImpl customMetacard1 = new MetacardImpl(mType);
        customMetacard1.setAttribute(Metacard.ID, "");
        customMetacard1.setAttribute(doubleField, doubleFieldValue + factor * i);
        customMetacard1.setAttribute(floatField, floatFieldValue + factor * i);
        customMetacard1.setAttribute(intField, intFieldValue + factor * i);
        customMetacard1.setAttribute(longField, longFieldValue + factor * i);
        customMetacard1.setAttribute(shortField, shortFieldValue + factor * i);
        list.add(customMetacard1);
    }
    create(list);
    Filter filter = null;
    QueryImpl query = null;
    SourceResponse sourceResponse = null;
    // Sort all Double ASCENDING
    filter = filterBuilder.attribute(Metacard.ANY_TEXT).like().text("*");
    query = new QueryImpl(filter);
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(doubleField, SortOrder.ASCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    for (int i = 0; i < list.size(); i++) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(doubleFieldValue + factor * i, r.getMetacard().getAttribute(doubleField).getValue());
    }
    // Sort all double DESCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(doubleField, SortOrder.DESCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    int counter = 0;
    for (int i = (list.size() - 1); i >= 0; i--) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(doubleFieldValue + factor * counter, r.getMetacard().getAttribute(doubleField).getValue());
        counter++;
    }
    // Sort all Float ASCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(floatField, SortOrder.ASCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    for (int i = 0; i < list.size(); i++) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(floatFieldValue + factor * i, r.getMetacard().getAttribute(floatField).getValue());
    }
    // Sort all Float DESCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(floatField, SortOrder.DESCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    counter = 0;
    for (int i = (list.size() - 1); i >= 0; i--) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(floatFieldValue + factor * counter, r.getMetacard().getAttribute(floatField).getValue());
        counter++;
    }
    // Sort all int ASCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(intField, SortOrder.ASCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    for (int i = 0; i < list.size(); i++) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(intFieldValue + factor * i, r.getMetacard().getAttribute(intField).getValue());
    }
    // Sort all int DESCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(intField, SortOrder.DESCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    counter = 0;
    for (int i = (list.size() - 1); i >= 0; i--) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(intFieldValue + factor * counter, r.getMetacard().getAttribute(intField).getValue());
        counter++;
    }
    // Sort all long ASCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(longField, SortOrder.ASCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    for (int i = 0; i < list.size(); i++) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(longFieldValue + factor * i, r.getMetacard().getAttribute(longField).getValue());
    }
    // Sort all long DESCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(longField, SortOrder.DESCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    counter = 0;
    for (int i = (list.size() - 1); i >= 0; i--) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals(longFieldValue + factor * counter, r.getMetacard().getAttribute(longField).getValue());
        counter++;
    }
    // Sort all short ASCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(shortField, SortOrder.ASCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    for (int i = 0; i < list.size(); i++) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals((short) (shortFieldValue + factor * i), r.getMetacard().getAttribute(shortField).getValue());
    }
    // Sort all short DESCENDING
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(shortField, SortOrder.DESCENDING.name()));
    sourceResponse = provider.query(new QueryRequestImpl(query));
    assertEquals(list.size(), sourceResponse.getResults().size());
    counter = 0;
    for (int i = (list.size() - 1); i >= 0; i--) {
        Result r = sourceResponse.getResults().get(i);
        assertEquals((short) (shortFieldValue + factor * counter), r.getMetacard().getAttribute(shortField).getValue());
        counter++;
    }
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) ArrayList(java.util.ArrayList) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) Matchers.containsString(org.hamcrest.Matchers.containsString) DateTime(org.joda.time.DateTime) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Metacard(ddf.catalog.data.Metacard) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Test(org.junit.Test)

Example 27 with AttributeDescriptor

use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.

the class CachedResourceMetacardComparator method allMetacardAttributesEqual.

private static boolean allMetacardAttributesEqual(Metacard cachedMetacard, Metacard updatedMetacard) {
    MetacardType cachedMetacardType = cachedMetacard.getMetacardType();
    MetacardType updatedMetacardType = updatedMetacard.getMetacardType();
    if (!Objects.equals(cachedMetacardType, updatedMetacardType)) {
        return false;
    }
    // attributes need to be compared so we can return true.
    if (cachedMetacardType == null) {
        return true;
    }
    Set<AttributeDescriptor> cachedDescriptors = cachedMetacardType.getAttributeDescriptors();
    // as well and no attributes need to be compared so we can return true.
    if (cachedDescriptors == null) {
        return true;
    }
    Optional<String> difference = cachedDescriptors.stream().map(AttributeDescriptor::getName).filter(attributeName -> !ATTRIBUTES_TO_IGNORE.contains(attributeName)).filter(attributeName -> !Objects.equals(cachedMetacard.getAttribute(attributeName), updatedMetacard.getAttribute(attributeName))).findFirst();
    if (LOGGER.isDebugEnabled() && difference.isPresent()) {
        String attributeName = difference.get();
        LOGGER.debug("Metacard updated. Attribute changed: {}, cached value: {}, updated value: {}", attributeName, cachedMetacard.getAttribute(attributeName), updatedMetacard.getAttribute(attributeName));
    }
    return !difference.isPresent();
}
Also used : Logger(org.slf4j.Logger) ImmutableSet(com.google.common.collect.ImmutableSet) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Function(java.util.function.Function) MetacardType(ddf.catalog.data.MetacardType) Objects(java.util.Objects) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Metacard(ddf.catalog.data.Metacard) Optional(java.util.Optional) Nullable(javax.annotation.Nullable) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardType(ddf.catalog.data.MetacardType)

Example 28 with AttributeDescriptor

use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.

the class SolrProviderTest method testNumericalOperations.

@Test()
public void testNumericalOperations() throws Exception {
    deleteAllIn(provider);
    /* SETUP */
    String doubleField = "hertz";
    double doubleFieldValue = 16065.435;
    String floatField = "inches";
    float floatFieldValue = 4.435f;
    String intField = "count";
    int intFieldValue = 4;
    String longField = "milliseconds";
    long longFieldValue = 9876543293L;
    String shortField = "daysOfTheWeek";
    short shortFieldValue = 1;
    Set<AttributeDescriptor> descriptors = numericalDescriptors(doubleField, floatField, intField, longField, shortField);
    MetacardTypeImpl mType = new MetacardTypeImpl("anotherCustom", descriptors);
    MetacardImpl customMetacard1 = new MetacardImpl(mType);
    customMetacard1.setAttribute(Metacard.ID, "");
    customMetacard1.setAttribute(doubleField, doubleFieldValue);
    customMetacard1.setAttribute(floatField, floatFieldValue);
    customMetacard1.setAttribute(intField, intFieldValue);
    customMetacard1.setAttribute(longField, longFieldValue);
    customMetacard1.setAttribute(shortField, shortFieldValue);
    MetacardImpl customMetacard2 = new MetacardImpl(mType);
    customMetacard2.setAttribute(Metacard.ID, "");
    customMetacard2.setAttribute(doubleField, doubleFieldValue + 10.0);
    customMetacard2.setAttribute(floatField, (floatFieldValue + 10.0f));
    customMetacard2.setAttribute(intField, intFieldValue + 1);
    customMetacard2.setAttribute(longField, longFieldValue + 10L);
    customMetacard2.setAttribute(shortField, (shortFieldValue + 1));
    create(Arrays.asList((Metacard) customMetacard1, customMetacard2));
    // on exact DOUBLE
    greaterThanQueryAssertion(doubleField, doubleFieldValue, 1);
    greaterThanOrEqualToQueryAssertion(doubleField, doubleFieldValue, 2);
    // beyond the DOUBLE
    greaterThanQueryAssertion(doubleField, doubleFieldValue - 0.00000001, 2);
    greaterThanOrEqualToQueryAssertion(doubleField, doubleFieldValue - 0.00000001, 2);
    greaterThanQueryAssertion(doubleField, doubleFieldValue + 12.0, 0);
    greaterThanOrEqualToQueryAssertion(doubleField, doubleFieldValue + 12.0, 0);
    // on exact FLOAT
    greaterThanQueryAssertion(floatField, floatFieldValue, 1);
    greaterThanOrEqualToQueryAssertion(floatField, floatFieldValue, 2);
    // beyond the FLOAT
    greaterThanQueryAssertion(floatField, floatFieldValue - 0.00001f, 2);
    greaterThanOrEqualToQueryAssertion(floatField, floatFieldValue - 0.00001f, 2);
    greaterThanQueryAssertion(floatField, floatFieldValue + 12.0f, 0);
    greaterThanOrEqualToQueryAssertion(floatField, floatFieldValue + 12.0f, 0);
    // on exact LONG
    greaterThanQueryAssertion(longField, longFieldValue, 1);
    greaterThanOrEqualToQueryAssertion(longField, longFieldValue, 2);
    // beyond the LONG
    greaterThanQueryAssertion(longField, longFieldValue - 1L, 2);
    greaterThanOrEqualToQueryAssertion(longField, longFieldValue - 1L, 2);
    greaterThanQueryAssertion(longField, longFieldValue + 12L, 0);
    greaterThanOrEqualToQueryAssertion(longField, longFieldValue + 12L, 0);
    // on exact INT
    greaterThanQueryAssertion(intField, intFieldValue, 1);
    greaterThanOrEqualToQueryAssertion(intField, intFieldValue, 2);
    // beyond the INT
    greaterThanQueryAssertion(intField, intFieldValue - 1, 2);
    greaterThanOrEqualToQueryAssertion(intField, intFieldValue - 1, 2);
    greaterThanQueryAssertion(intField, intFieldValue + 2, 0);
    greaterThanOrEqualToQueryAssertion(intField, intFieldValue + 2, 0);
    // on exact SHORT
    greaterThanQueryAssertion(shortField, shortFieldValue, 1);
    greaterThanOrEqualToQueryAssertion(shortField, shortFieldValue, 2);
    // beyond the SHORT
    greaterThanQueryAssertion(shortField, (short) (shortFieldValue - 1), 2);
    greaterThanOrEqualToQueryAssertion(shortField, (short) (shortFieldValue - 1), 2);
    greaterThanQueryAssertion(shortField, (short) (shortFieldValue + 2), 0);
    greaterThanOrEqualToQueryAssertion(shortField, (short) (shortFieldValue + 2), 0);
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) Matchers.containsString(org.hamcrest.Matchers.containsString) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 29 with AttributeDescriptor

use of ddf.catalog.data.AttributeDescriptor in project ddf by codice.

the class CatalogFrameworkImplTest method testInjectsAttributesOnDelete.

@Test
public void testInjectsAttributesOnDelete() throws Exception {
    final String title = "Delete this";
    final String injectAttributeName = "new attribute";
    final double injectAttributeValue = 11.1;
    final MetacardImpl metacard = new MetacardImpl();
    metacard.setTitle(title);
    metacard.setAttribute(injectAttributeName, injectAttributeValue);
    final String id = framework.create(new CreateRequestImpl(Collections.singletonList(metacard), null)).getCreatedMetacards().get(0).getId();
    final DeleteRequest request = new DeleteRequestImpl(id);
    final AttributeDescriptor injectAttribute = new AttributeDescriptorImpl(injectAttributeName, true, true, false, false, BasicTypes.DOUBLE_TYPE);
    stubMetacardInjection(injectAttribute);
    List<Result> mockFederationResults = Stream.of(metacard).map(m -> {
        Result mockResult = mock(Result.class);
        when(mockResult.getMetacard()).thenReturn(m);
        return mockResult;
    }).collect(Collectors.toList());
    QueryResponseImpl queryResponse = new QueryResponseImpl(mock(QueryRequest.class), mockFederationResults, 1);
    when(mockFederationStrategy.federate(anyList(), anyObject())).thenReturn(queryResponse);
    when(mockRemoteDeleteOperations.performRemoteDelete(any(), any())).then(returnsSecondArg());
    deleteOperations.setRemoteDeleteOperations(mockRemoteDeleteOperations);
    final DeleteResponse response = framework.delete(request);
    final Metacard deletedMetacard = response.getDeletedMetacards().get(0);
    final MetacardType originalMetacardType = metacard.getMetacardType();
    final MetacardType deletedMetacardType = deletedMetacard.getMetacardType();
    assertThat(deletedMetacardType.getName(), is(originalMetacardType.getName()));
    final Set<AttributeDescriptor> expectedAttributeDescriptors = new HashSet<>(originalMetacardType.getAttributeDescriptors());
    expectedAttributeDescriptors.add(injectAttribute);
    assertThat(deletedMetacardType.getAttributeDescriptors(), is(expectedAttributeDescriptors));
    assertThat(deletedMetacard.getTitle(), is(title));
    assertThat(deletedMetacard.getAttribute(injectAttributeName).getValue(), is(injectAttributeValue));
}
Also used : Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) AttributeRegistryImpl(ddf.catalog.data.impl.AttributeRegistryImpl) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) CreateRequest(ddf.catalog.operation.CreateRequest) BinaryContent(ddf.catalog.data.BinaryContent) UpdateStorageRequestImpl(ddf.catalog.content.operation.impl.UpdateStorageRequestImpl) AttributeType(ddf.catalog.data.AttributeType) FilterFactory(org.opengis.filter.FilterFactory) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException) UpdateOperations(ddf.catalog.impl.operations.UpdateOperations) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) CreateOperations(ddf.catalog.impl.operations.CreateOperations) RemoteDeleteOperations(ddf.catalog.impl.operations.RemoteDeleteOperations) ServiceReference(org.osgi.framework.ServiceReference) InputTransformer(ddf.catalog.transform.InputTransformer) PostResourcePlugin(ddf.catalog.plugin.PostResourcePlugin) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Set(java.util.Set) SourceOperations(ddf.catalog.impl.operations.SourceOperations) MimeTypeResolver(ddf.mime.MimeTypeResolver) Serializable(java.io.Serializable) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) Matchers.any(org.mockito.Matchers.any) SourceInfoRequest(ddf.catalog.operation.SourceInfoRequest) BASIC_METACARD(ddf.catalog.data.impl.BasicTypes.BASIC_METACARD) Stream(java.util.stream.Stream) BinaryContentImpl(ddf.catalog.data.impl.BinaryContentImpl) Assert.assertFalse(org.junit.Assert.assertFalse) QueryResponseTransformer(ddf.catalog.transform.QueryResponseTransformer) Matchers.is(org.hamcrest.Matchers.is) UpdateResponse(ddf.catalog.operation.UpdateResponse) BasicTypes(ddf.catalog.data.impl.BasicTypes) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) Mockito.mock(org.mockito.Mockito.mock) ResourceResponse(ddf.catalog.operation.ResourceResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) PostQueryPlugin(ddf.catalog.plugin.PostQueryPlugin) AdditionalAnswers.returnsSecondArg(org.mockito.AdditionalAnswers.returnsSecondArg) ContentItemImpl(ddf.catalog.content.data.impl.ContentItemImpl) CatalogFramework(ddf.catalog.CatalogFramework) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) DeleteResponse(ddf.catalog.operation.DeleteResponse) Mockito.spy(org.mockito.Mockito.spy) Matchers.anyString(org.mockito.Matchers.anyString) ArrayList(java.util.ArrayList) DefaultAttributeValueRegistryImpl(ddf.catalog.data.defaultvalues.DefaultAttributeValueRegistryImpl) Resource(ddf.catalog.resource.Resource) PostIngestPlugin(ddf.catalog.plugin.PostIngestPlugin) Source(ddf.catalog.source.Source) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) TestWatchman(org.junit.rules.TestWatchman) ContentItem(ddf.catalog.content.data.ContentItem) OperationsStorageSupport(ddf.catalog.impl.operations.OperationsStorageSupport) SourcePollerRunner(ddf.catalog.util.impl.SourcePollerRunner) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) ResourceRequest(ddf.catalog.operation.ResourceRequest) QueryRequest(ddf.catalog.operation.QueryRequest) SourceInfoRequestSources(ddf.catalog.operation.impl.SourceInfoRequestSources) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ByteSource(com.google.common.io.ByteSource) Result(ddf.catalog.data.Result) TransformOperations(ddf.catalog.impl.operations.TransformOperations) Before(org.junit.Before) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) CreateStorageRequestImpl(ddf.catalog.content.operation.impl.CreateStorageRequestImpl) ContentType(ddf.catalog.data.ContentType) ResourceOperations(ddf.catalog.impl.operations.ResourceOperations) Historian(ddf.catalog.history.Historian) IngestException(ddf.catalog.source.IngestException) Assert.assertTrue(org.junit.Assert.assertTrue) StopProcessingException(ddf.catalog.plugin.StopProcessingException) IOException(java.io.IOException) Test(org.junit.Test) Subject(ddf.security.Subject) AttributeInjector(ddf.catalog.data.AttributeInjector) FederationException(ddf.catalog.federation.FederationException) AttributeInjectorImpl(ddf.catalog.data.inject.AttributeInjectorImpl) DAYS(java.time.temporal.ChronoUnit.DAYS) Query(ddf.catalog.operation.Query) ValidationQueryFactory(ddf.catalog.cache.solr.impl.ValidationQueryFactory) KeyValueCollectionPermission(ddf.security.permission.KeyValueCollectionPermission) Assert.assertEquals(org.junit.Assert.assertEquals) UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) PreQueryPlugin(ddf.catalog.plugin.PreQueryPlugin) CatalogStore(ddf.catalog.source.CatalogStore) DeleteOperations(ddf.catalog.impl.operations.DeleteOperations) Date(java.util.Date) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl) URISyntaxException(java.net.URISyntaxException) MethodRule(org.junit.rules.MethodRule) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) LoggerFactory(org.slf4j.LoggerFactory) ResourceCacheImpl(ddf.catalog.cache.impl.ResourceCacheImpl) SourceDescriptor(ddf.catalog.source.SourceDescriptor) MetacardTransformer(ddf.catalog.transform.MetacardTransformer) UpdateStorageRequest(ddf.catalog.content.operation.UpdateStorageRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) Assert.fail(org.junit.Assert.fail) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) URI(java.net.URI) CachedSource(ddf.catalog.util.impl.CachedSource) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) MetacardFactory(ddf.catalog.impl.operations.MetacardFactory) Matchers.isA(org.mockito.Matchers.isA) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) FederatedSource(ddf.catalog.source.FederatedSource) MimeTypeToTransformerMapper(ddf.mime.MimeTypeToTransformerMapper) ResultImpl(ddf.catalog.data.impl.ResultImpl) SourceInfoRequestEnterprise(ddf.catalog.operation.impl.SourceInfoRequestEnterprise) ResourceReader(ddf.catalog.resource.ResourceReader) UUID(java.util.UUID) SourceMonitor(ddf.catalog.source.SourceMonitor) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) BundleContext(org.osgi.framework.BundleContext) Sets(com.google.common.collect.Sets) MetacardType(ddf.catalog.data.MetacardType) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) DeleteRequest(ddf.catalog.operation.DeleteRequest) QueryResponse(ddf.catalog.operation.QueryResponse) List(java.util.List) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) MimeTypeMapperImpl(ddf.mime.mapper.MimeTypeMapperImpl) Matchers.anyMap(org.mockito.Matchers.anyMap) Entry(java.util.Map.Entry) FederationStrategy(ddf.catalog.federation.FederationStrategy) FilterBuilder(ddf.catalog.filter.FilterBuilder) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) HashMap(java.util.HashMap) Update(ddf.catalog.operation.Update) DefaultAttributeValueRegistry(ddf.catalog.data.DefaultAttributeValueRegistry) HashSet(java.util.HashSet) ArgumentCaptor(org.mockito.ArgumentCaptor) CreateResponse(ddf.catalog.operation.CreateResponse) CollectionUtils(org.apache.commons.collections.CollectionUtils) Constants(ddf.catalog.Constants) Metacard(ddf.catalog.data.Metacard) Matchers.anyObject(org.mockito.Matchers.anyObject) MimeType(javax.activation.MimeType) SourcePoller(ddf.catalog.util.impl.SourcePoller) SecurityConstants(ddf.security.SecurityConstants) StorageProvider(ddf.catalog.content.StorageProvider) OperationsCatalogStoreSupport(ddf.catalog.impl.operations.OperationsCatalogStoreSupport) UpdateRequest(ddf.catalog.operation.UpdateRequest) SimpleEntry(java.util.AbstractMap.SimpleEntry) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) QueryImpl(ddf.catalog.operation.impl.QueryImpl) FrameworkMethod(org.junit.runners.model.FrameworkMethod) Logger(org.slf4j.Logger) Assert.assertNotNull(org.junit.Assert.assertNotNull) OperationsMetacardSupport(ddf.catalog.impl.operations.OperationsMetacardSupport) Mockito.when(org.mockito.Mockito.when) OperationsSecuritySupport(ddf.catalog.impl.operations.OperationsSecuritySupport) Mockito.verify(org.mockito.Mockito.verify) ResourceNotSupportedException(ddf.catalog.resource.ResourceNotSupportedException) MockMemoryStorageProvider(ddf.catalog.content.impl.MockMemoryStorageProvider) SourceResponse(ddf.catalog.operation.SourceResponse) Rule(org.junit.Rule) Ignore(org.junit.Ignore) CatalogProvider(ddf.catalog.source.CatalogProvider) ThreadContext(org.apache.shiro.util.ThreadContext) QueryOperations(ddf.catalog.impl.operations.QueryOperations) Filter(org.opengis.filter.Filter) Matchers.anyList(org.mockito.Matchers.anyList) Collections(java.util.Collections) InputStream(java.io.InputStream) QueryRequest(ddf.catalog.operation.QueryRequest) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) Matchers.anyString(org.mockito.Matchers.anyString) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) MetacardType(ddf.catalog.data.MetacardType) Result(ddf.catalog.data.Result) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) DeleteRequest(ddf.catalog.operation.DeleteRequest) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 30 with AttributeDescriptor

use of ddf.catalog.data.AttributeDescriptor 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)

Aggregations

AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)111 Test (org.junit.Test)51 MetacardType (ddf.catalog.data.MetacardType)40 Metacard (ddf.catalog.data.Metacard)38 HashSet (java.util.HashSet)29 Attribute (ddf.catalog.data.Attribute)26 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)24 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)24 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)24 ArrayList (java.util.ArrayList)23 Serializable (java.io.Serializable)16 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)9 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)7 IOException (java.io.IOException)7 Date (java.util.Date)7 List (java.util.List)7 QName (javax.xml.namespace.QName)7