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));
}
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;
}
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)));
}
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);
}
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);
}
Aggregations