Search in sources :

Example 1 with AttributeDescriptorImpl

use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.

the class TestGenericXmlLib method testDynamicMetacardType.

@Test
public void testDynamicMetacardType() {
    Set<AttributeDescriptor> attributeDescriptors = new HashSet<>();
    attributeDescriptors.add(new AttributeDescriptorImpl(Metacard.TITLE, false, false, false, false, BasicTypes.STRING_TYPE));
    DynamicMetacardType dynamicMetacardType = new DynamicMetacardType(attributeDescriptors, "Foo");
    assertThat(dynamicMetacardType.getName(), is("Foo.metacard"));
    assertThat(dynamicMetacardType.getAttributeDescriptor(Metacard.TITLE), notNullValue());
    assertThat(dynamicMetacardType.getAttributeDescriptors().equals(attributeDescriptors), is(true));
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with AttributeDescriptorImpl

use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.

the class TestGetRecordsResponseConverter method createMetacardList.

private List<Metacard> createMetacardList(int start, int finish) {
    List<Metacard> list = new LinkedList<>();
    for (int i = start; i <= finish; i++) {
        MetacardImpl metacard = new MetacardImpl();
        metacard.setId(ID_PREFIX + i);
        metacard.setSourceId(SOURCE_PREFIX + i);
        metacard.setTitle(TITLE_PREFIX + i);
        // for testing an attribute with multiple values
        AttributeDescriptor ad = new AttributeDescriptorImpl(FORMAT, true, true, true, true, BasicTypes.STRING_TYPE);
        Set<AttributeDescriptor> ads = new HashSet<>(metacard.getMetacardType().getAttributeDescriptors());
        ads.add(ad);
        metacard.setType(new MetacardTypeImpl("test", ads));
        metacard.setLocation(WKT);
        AttributeImpl attr = new AttributeImpl(FORMAT, FORMAT);
        attr.addValue(FORMAT);
        metacard.setAttribute(attr);
        // for testing an attribute with no attribute descriptor
        metacard.setAttribute(RELATION, RELATION);
        list.add(metacard);
    }
    return list;
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) LinkedList(java.util.LinkedList) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 3 with AttributeDescriptorImpl

use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.

the class SolrProviderTest method spatialDistanceCalculationBetweenTwoPoints.

private void spatialDistanceCalculationBetweenTwoPoints(String attribute, String sortBy) throws Exception {
    deleteAllIn(provider);
    // given
    double radiusInKilometers = 500;
    double radiusInMeters = radiusInKilometers * METERS_PER_KM;
    Filter positiveFilter = filterBuilder.attribute(attribute).withinBuffer().wkt(PHOENIX_POINT_WKT, radiusInMeters);
    MetacardImpl metacard;
    if (attribute.equals(Metacard.GEOGRAPHY)) {
        metacard = new MockMetacard(Library.getFlagstaffRecord());
    } else {
        metacard = new MockMetacard(Library.getFlagstaffRecord(), new MetacardTypeImpl("distanceTest", BasicTypes.BASIC_METACARD, Sets.newSet(new AttributeDescriptorImpl(attribute, true, true, true, true, BasicTypes.GEO_TYPE))));
    }
    metacard.setAttribute(attribute, LAS_VEGAS_POINT_WKT);
    List<Metacard> list = Arrays.asList((Metacard) metacard);
    create(list);
    QueryImpl query = new QueryImpl(positiveFilter);
    query.setSortBy(new ddf.catalog.filter.impl.SortByImpl(sortBy, SortOrder.ASCENDING));
    // when
    SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
    // then
    assertEquals("Failed to find metacard WKT with filter", 1, sourceResponse.getResults().size());
    Result result = sourceResponse.getResults().get(0);
    assertThat(result.getDistanceInMeters(), is(notNullValue()));
    assertThat("Point radius search should be less than the radius given.", result.getDistanceInMeters(), is(lessThanOrEqualTo(radiusInMeters)));
    // expected distance calculated from
    // http://www.movable-type.co.uk/scripts/latlong.html
    double expectedDistanceBetweenCitiesInMeters = 412700;
    // +/-0.1%
    double precisionPercentage = .001;
    double lowerBound = expectedDistanceBetweenCitiesInMeters * (1 - precisionPercentage);
    double upperBound = expectedDistanceBetweenCitiesInMeters * (1 + precisionPercentage);
    assertThat("The distance returned should at least be above the lower bound of error.", result.getDistanceInMeters(), is(greaterThanOrEqualTo(lowerBound)));
    assertThat("The distance returned should at least be below the upper bound of error.", result.getDistanceInMeters(), is(lessThanOrEqualTo(upperBound)));
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) 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)

Example 4 with AttributeDescriptorImpl

use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.

the class TestGeoJsonExtensible method sampleMetacardTypeA.

private MetacardType sampleMetacardTypeA() {
    Set<AttributeDescriptor> descriptors = new HashSet<AttributeDescriptor>();
    descriptors.add(new AttributeDescriptorImpl("frequency", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.LONG_TYPE));
    descriptors.add(new AttributeDescriptorImpl("min-frequency", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.LONG_TYPE));
    descriptors.add(new AttributeDescriptorImpl("max-frequency", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.LONG_TYPE));
    descriptors.add(new AttributeDescriptorImpl("angle", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl("multi-string", true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    true, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.ID, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.TITLE, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    return new MetacardTypeImpl(SAMPLE_A_METACARD_TYPE_NAME, descriptors);
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet)

Example 5 with AttributeDescriptorImpl

use of ddf.catalog.data.impl.AttributeDescriptorImpl in project ddf by codice.

the class TestGeoJsonExtensible method sampleMetacardTypeB.

private MetacardType sampleMetacardTypeB() {
    Set<AttributeDescriptor> descriptors = new HashSet<AttributeDescriptor>();
    descriptors.add(new AttributeDescriptorImpl(COLUMNS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl(ROWS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.INTEGER_TYPE));
    descriptors.add(new AttributeDescriptorImpl(DESCRIPTION_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.ID, true, /* indexed */
    true, /* stored */
    false, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(Metacard.TITLE, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.STRING_TYPE));
    descriptors.add(new AttributeDescriptorImpl(REVIEWED_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.BOOLEAN_TYPE));
    descriptors.add(new AttributeDescriptorImpl(PRECISE_LENGTH_METERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.DOUBLE_TYPE));
    descriptors.add(new AttributeDescriptorImpl(PRECISE_HEIGHT_METERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.FLOAT_TYPE));
    descriptors.add(new AttributeDescriptorImpl(NUMBER_REVIEWERS_ATTRIBUTE_KEY, true, /* indexed */
    true, /* stored */
    true, /* tokenized */
    false, /* multivalued */
    BasicTypes.SHORT_TYPE));
    return new MetacardTypeImpl("MetacardTypeB", descriptors);
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) HashSet(java.util.HashSet)

Aggregations

AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)44 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)34 HashSet (java.util.HashSet)26 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)24 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)19 Test (org.junit.Test)19 Metacard (ddf.catalog.data.Metacard)17 MetacardType (ddf.catalog.data.MetacardType)11 ArrayList (java.util.ArrayList)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 SourceResponse (ddf.catalog.operation.SourceResponse)6 QueryImpl (ddf.catalog.operation.impl.QueryImpl)6 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)6 Before (org.junit.Before)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Metadata (org.apache.tika.metadata.Metadata)5 Filter (org.opengis.filter.Filter)5 ByteSource (com.google.common.io.ByteSource)4