use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class TestPubSubOgcFilter method testContextualEvaluate.
@Test
@Ignore
public void testContextualEvaluate() throws TransformerException {
FilterFactory filterFactory = new FilterFactoryImpl();
Filter filter = filterFactory.like(filterFactory.literal("abcdef"), "abcdef");
printFilter(filter);
assertTrue(filter.evaluate(null));
Filter filter2 = filterFactory.like(filterFactory.literal("123456"), "123456abc");
assertFalse(filter2.evaluate(null));
}
use of org.geotools.filter.FilterFactoryImpl in project incubator-rya by apache.
the class GeoWaveFeatureReaderTest method testBBOX.
@Test
public void testBBOX() throws IllegalArgumentException, NoSuchElementException, IOException {
final FilterFactoryImpl factory = new FilterFactoryImpl();
final Query query = new Query("GeoWaveFeatureReaderTest", factory.bbox("", -180, -90, 180, 90, "EPSG:4326"), new String[] { "geometry", "pid" });
final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
int count = 0;
while (reader.hasNext()) {
final SimpleFeature feature = reader.next();
assertTrue(fids.contains(feature.getID()));
count++;
}
assertTrue(count > 0);
}
use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class CswRecordMapperFilterVisitorTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
factory = new FilterFactoryImpl();
attrExpr = factory.property(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, UNMAPPED_PROPERTY, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
created = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, Core.CREATED, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
attributeRegistry = new AttributeRegistryImpl();
attributeRegistry.registerMetacardType(CswQueryFactoryTest.getCswMetacardType());
visitor = new CswRecordMapperFilterVisitor(DEFAULT_CSW_RECORD_MAP, attributeRegistry);
}
use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class SolrProviderSorting method testStartIndexWithSorting.
@Test
public void testStartIndexWithSorting() throws Exception {
deleteAll(provider);
List<Metacard> metacards = new ArrayList<>();
DateTime dt = new DateTime(1985, 1, 1, 1, 1, 1, 1, DateTimeZone.UTC);
TreeSet<Date> calculatedDates = new TreeSet<>();
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 100; i = i + 10) {
MetacardImpl metacard = new MockMetacard(Library.getFlagstaffRecord());
// ingest sporadically the effective dates so the default return
// order won't be ordered
Date calculatedDate = dt.plusDays(100 - i + 10 - j).toDate();
calculatedDates.add(calculatedDate);
metacard.setEffectiveDate(calculatedDate);
metacards.add(metacard);
}
}
// The TreeSet will sort them, the array will give me access to everyone
// without an iterator
Date[] dates = new Date[calculatedDates.size()];
calculatedDates.toArray(dates);
// CREATE
CreateResponse response = create(metacards, provider);
LOGGER.info("CREATED {} records.", response.getCreatedMetacards().size());
FilterFactory filterFactory = new FilterFactoryImpl();
// STARTINDEX=2, MAXSIZE=20
int maxSize = 20;
int startIndex = 2;
SortByImpl sortBy = new SortByImpl(filterFactory.property(Metacard.EFFECTIVE), org.opengis.filter.sort.SortOrder.ASCENDING);
QueryImpl query = query(Metacard.CONTENT_TYPE, MockMetacard.DEFAULT_TYPE, startIndex, maxSize, sortBy);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(maxSize, sourceResponse.getResults().size());
assertSorting(dates, startIndex, sourceResponse);
// STARTINDEX=20, MAXSIZE=5
// a match-all queryByProperty
maxSize = 5;
startIndex = 20;
sortBy = new SortByImpl(filterFactory.property(Metacard.EFFECTIVE), org.opengis.filter.sort.SortOrder.ASCENDING);
query = query(Metacard.CONTENT_TYPE, MockMetacard.DEFAULT_TYPE, startIndex, maxSize, sortBy);
sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(maxSize, sourceResponse.getResults().size());
assertSorting(dates, startIndex, sourceResponse);
// STARTINDEX=80, MAXSIZE=20
// a match-all queryByProperty
maxSize = 20;
startIndex = 80;
sortBy = new SortByImpl(filterFactory.property(Metacard.EFFECTIVE), org.opengis.filter.sort.SortOrder.ASCENDING);
query = query(Metacard.CONTENT_TYPE, MockMetacard.DEFAULT_TYPE, startIndex, maxSize, sortBy);
sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(maxSize, sourceResponse.getResults().size());
assertSorting(dates, startIndex, sourceResponse);
// STARTINDEX=1, MAXSIZE=100
// a match-all queryByProperty
maxSize = 100;
startIndex = 1;
sortBy = new SortByImpl(filterFactory.property(Metacard.EFFECTIVE), org.opengis.filter.sort.SortOrder.ASCENDING);
query = query(Metacard.CONTENT_TYPE, MockMetacard.DEFAULT_TYPE, startIndex, maxSize, sortBy);
sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(maxSize, sourceResponse.getResults().size());
assertSorting(dates, startIndex, sourceResponse);
}
use of org.geotools.filter.FilterFactoryImpl in project ddf by codice.
the class SolrProviderCreate method testCreateOperationWithSourceId.
@Test
public void testCreateOperationWithSourceId() throws IngestException, UnsupportedQueryException {
deleteAll(provider);
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
String id = UUID.randomUUID().toString();
metacard.setId(id);
metacard.setSourceId("ddfChild");
Date oneDayAgo = new DateTime().minusDays(1).toDate();
metacard.setCreatedDate(oneDayAgo);
metacard.setExpirationDate(oneDayAgo);
metacard.setEffectiveDate(oneDayAgo);
metacard.setModifiedDate(oneDayAgo);
CreateResponse createResponse = create(metacard, provider);
Metacard createdMetacard = createResponse.getCreatedMetacards().get(0);
assertNotNull(createdMetacard.getId());
assertEquals(MockMetacard.DEFAULT_TITLE, createdMetacard.getTitle());
assertEquals(MockMetacard.DEFAULT_LOCATION, createdMetacard.getLocation());
assertEquals(MockMetacard.DEFAULT_TYPE, createdMetacard.getContentTypeName());
assertEquals(MockMetacard.DEFAULT_VERSION, createdMetacard.getContentTypeVersion());
assertNotNull(createdMetacard.getMetadata());
assertThat(createdMetacard.getMetadata(), containsString("<title>Flagstaff Chamber of Commerce</title>"));
assertThat(createdMetacard.getMetadata().isEmpty(), is(not(true)));
assertThat(createdMetacard.getCreatedDate(), is(oneDayAgo));
assertThat(createdMetacard.getModifiedDate(), is(oneDayAgo));
assertThat(createdMetacard.getEffectiveDate(), is(oneDayAgo));
assertThat(createdMetacard.getExpirationDate(), is(oneDayAgo));
assertTrue(Arrays.equals(metacard.getThumbnail(), createdMetacard.getThumbnail()));
assertEquals(metacard.getLocation(), createdMetacard.getLocation());
assertThat(createdMetacard.getSourceId(), is(metacard.getSourceId()));
// --------------------
FilterFactory filterFactory = new FilterFactoryImpl();
// SIMPLE TITLE SEARCH
Filter filter = filterFactory.like(filterFactory.property(Metacard.TITLE), MockMetacard.DEFAULT_TITLE, DEFAULT_TEST_WILDCARD, DEFAULT_TEST_SINGLE_WILDCARD, DEFAULT_TEST_ESCAPE, false);
QueryImpl query = new QueryImpl(filter);
query.setStartIndex(1);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
List<Result> results = sourceResponse.getResults();
Metacard mResult = results.get(0).getMetacard();
assertEquals(1, results.size());
assertNotNull(mResult.getId());
assertEquals(MockMetacard.DEFAULT_TITLE, mResult.getTitle());
assertEquals(MockMetacard.DEFAULT_LOCATION, mResult.getLocation());
assertEquals(MockMetacard.DEFAULT_TYPE, mResult.getContentTypeName());
assertEquals(MockMetacard.DEFAULT_VERSION, mResult.getContentTypeVersion());
assertNotNull(mResult.getMetadata());
assertThat(mResult.getMetadata(), containsString("<title>Flagstaff Chamber of Commerce</title>"));
assertThat(mResult.getMetadata().isEmpty(), is(not(true)));
assertThat(mResult.getCreatedDate(), is(oneDayAgo));
assertThat(mResult.getModifiedDate(), is(oneDayAgo));
assertThat(mResult.getEffectiveDate(), is(oneDayAgo));
assertThat(mResult.getExpirationDate(), is(oneDayAgo));
assertTrue(Arrays.equals(metacard.getThumbnail(), mResult.getThumbnail()));
assertEquals(metacard.getLocation(), mResult.getLocation());
// assertThat(mResult.getSourceId(), is("ddf"));
}
Aggregations