当前位置: 首页>>代码示例>>Java>>正文


Java EqualsPredicate类代码示例

本文整理汇总了Java中org.gbif.api.model.occurrence.predicate.EqualsPredicate的典型用法代码示例。如果您正苦于以下问题:Java EqualsPredicate类的具体用法?Java EqualsPredicate怎么用?Java EqualsPredicate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EqualsPredicate类属于org.gbif.api.model.occurrence.predicate包,在下文中一共展示了EqualsPredicate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSerde

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testSerde() throws IOException {
  ObjectMapper mapper = new ObjectMapper();
  DownloadRequest d = newDownload(new EqualsPredicate(OccurrenceSearchParameter.CATALOG_NUMBER, "b"));

  Closer closer = Closer.create();
  try {
    ByteArrayOutputStream baos = closer.register(new ByteArrayOutputStream());
    mapper.writeValue(baos, d);
    baos.flush();
    DownloadRequest d2 = mapper.readValue(baos.toByteArray(), DownloadRequest.class);
    assertEquals(d, d2);

  } catch (Throwable e) { // closer must catch Throwable
    fail(e.getMessage());
    throw closer.rethrow(e);

  } finally {
    closer.close();
  }
}
 
开发者ID:gbif,项目名称:gbif-api,代码行数:22,代码来源:DownloadRequestTest.java

示例2: testPartialDate

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
/**
 * Reusable method to test partial dates, i.e., dates with the format: yyyy, yyyy-MM.
 */
private void testPartialDate(String value) throws QueryBuildingException {
  Range<Date> range = null;
  if(SearchTypeValidator.isRange(value)){
    range = IsoDateParsingUtils.parseDateRange(value);
  } else {
    Date lowerDate = IsoDateParsingUtils.parseDate(value);
    Date upperDate = null;
    IsoDateFormat isoDateFormat = IsoDateParsingUtils.getFirstDateFormatMatch(value);
    if(IsoDateFormat.YEAR == isoDateFormat) {
      upperDate = IsoDateParsingUtils.toLastDayOfYear(lowerDate);
    } else if(IsoDateFormat.YEAR_MONTH == isoDateFormat){
      upperDate = IsoDateParsingUtils.toLastDayOfMonth(lowerDate);
    }
    range = Range.closed(lowerDate,upperDate);
  }

  Predicate p = new EqualsPredicate(OccurrenceSearchParameter.LAST_INTERPRETED,value);

  String query = visitor.getHiveQuery(p);
  assertThat(query, equalTo(String.format("((lastinterpreted >= %s) AND (lastinterpreted <= %s))",
                                          String.valueOf(range.lowerEndpoint().getTime()),
                                          String.valueOf(range.upperEndpoint().getTime()))));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:27,代码来源:HiveQueryVisitorTest.java

示例3: testCreate

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
@Ignore("manual test class to verify a local download webservice")
public void testCreate() throws Exception {
  final String USER = "nagios";

  Properties props = new Properties();
  // props.setProperty("occurrencedownload.ws.url", "http://apidev.gbif.org/");
  // props.setProperty("occurrencedownload.ws.url", "http://localhost:8080/");
  // props.setProperty("occurrencedownload.ws.url", "http://jawa.gbif.org:8080/occurrence-download-ws/");
  props.setProperty("occurrencedownload.ws.url", "http://localhost:8080/occurrence-download-ws/");
  OccurrenceWsClientModule mod = new OccurrenceWsClientModule(props);
  SingleUserAuthModule authMod = new SingleUserAuthModule(USER, USER);
  Injector inj = Guice.createInjector(authMod, mod);

  DownloadRequestService client = inj.getInstance(DownloadRequestService.class);

  DownloadRequest d =
    new DownloadRequest(new EqualsPredicate(OccurrenceSearchParameter.TAXON_KEY, "5219426"), USER, null, true,
                        DownloadFormat.DWCA);

  client.create(d);

  System.out.print(d);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:25,代码来源:OccurrenceWsClientModuleTest.java

示例4: visit

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
/**
 * Supports all parameters incl taxonKey expansion for higher taxa.
 */
public void visit(EqualsPredicate predicate) throws QueryBuildingException {
  if (OccurrenceSearchParameter.TAXON_KEY == predicate.getKey()) {
    appendTaxonKeyFilter(predicate.getValue());
  } else if (OccurrenceSearchParameter.MEDIA_TYPE == predicate.getKey()) {
    builder.append(String.format(MEDIATYPE_CONTAINS_FMT, predicate.getValue().toUpperCase()));
  } else if (OccurrenceSearchParameter.ISSUE == predicate.getKey()) {
    builder.append(String.format(ISSUE_CONTAINS_FMT, predicate.getValue().toUpperCase()));
  } else {
    visitSimplePredicate(predicate, EQUALS_OPERATOR);
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:15,代码来源:HiveQueryVisitor.java

示例5: testComplexQuery

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testComplexQuery() throws QueryBuildingException {
  Predicate aves = new EqualsPredicate(OccurrenceSearchParameter.TAXON_KEY, "212");
  Predicate passer = new LikePredicate(OccurrenceSearchParameter.SCIENTIFIC_NAME, "Passer%");
  Predicate UK = new EqualsPredicate(OccurrenceSearchParameter.COUNTRY, "GB");
  Predicate before1989 = new LessThanOrEqualsPredicate(OccurrenceSearchParameter.YEAR, "1989");
  Predicate georeferencedPredicate = new EqualsPredicate(OccurrenceSearchParameter.HAS_COORDINATE, "true");

  ConjunctionPredicate p =
    new ConjunctionPredicate(Lists.newArrayList(aves, UK, passer, before1989, georeferencedPredicate));
  String where = visitor.getHiveQuery(p);
  assertEquals(
    "(((taxonkey = 212 OR kingdomkey = 212 OR phylumkey = 212 OR classkey = 212 OR orderkey = 212 OR familykey = 212 OR genuskey = 212 OR subgenuskey = 212 OR specieskey = 212)) AND (countrycode = \'GB\') AND (lower(scientificname) LIKE lower(\'Passer%\')) AND (year <= 1989) AND (hascoordinate = true))",
    where);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:16,代码来源:HiveQueryVisitorTest.java

示例6: testConjunctionPredicate

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testConjunctionPredicate() throws QueryBuildingException {
  Predicate p1 = new EqualsPredicate(PARAM, "value_1");
  Predicate p2 = new EqualsPredicate(PARAM2, "value_2");

  ConjunctionPredicate p = new ConjunctionPredicate(Lists.newArrayList(p1, p2));
  String query = visitor.getHiveQuery(p);
  assertThat(query, equalTo("((lower(catalognumber) = lower(\'value_1\')) AND (lower(institutioncode) = lower(\'value_2\')))"));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:10,代码来源:HiveQueryVisitorTest.java

示例7: testDisjunctionPredicate

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testDisjunctionPredicate() throws QueryBuildingException {
  Predicate p1 = new EqualsPredicate(PARAM, "value_1");
  Predicate p2 = new EqualsPredicate(PARAM2, "value_2");

  DisjunctionPredicate p = new DisjunctionPredicate(Lists.newArrayList(p1, p2));
  String query = visitor.getHiveQuery(p);
  assertThat(query, equalTo("((lower(catalognumber) = lower(\'value_1\')) OR (lower(institutioncode) = lower(\'value_2\')))"));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:10,代码来源:HiveQueryVisitorTest.java

示例8: testNotPredicateComplex

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testNotPredicateComplex() throws QueryBuildingException {
  Predicate p1 = new EqualsPredicate(PARAM, "value_1");
  Predicate p2 = new EqualsPredicate(PARAM2, "value_2");

  ConjunctionPredicate cp = new ConjunctionPredicate(Lists.newArrayList(p1, p2));

  Predicate p = new NotPredicate(cp);
  String query = visitor.getHiveQuery(p);
  assertThat(query, equalTo("NOT ((lower(catalognumber) = lower(\'value_1\')) AND (lower(institutioncode) = lower(\'value_2\')))"));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:12,代码来源:HiveQueryVisitorTest.java

示例9: testQuotes

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testQuotes() throws QueryBuildingException {
  Predicate p = new EqualsPredicate(PARAM, "my \'pleasure\'");
  String query = visitor.getHiveQuery(p);
  assertThat(query, equalTo("lower(catalognumber) = lower(\'my \\\'pleasure\\\'\')"));

  p = new LessThanOrEqualsPredicate(OccurrenceSearchParameter.ELEVATION, "101");
  query = visitor.getHiveQuery(p);
  assertThat(query, equalTo("elevation <= 101"));

  p = new GreaterThanPredicate(OccurrenceSearchParameter.YEAR, "1998");
  query = visitor.getHiveQuery(p);
  assertThat(query, equalTo("year > 1998"));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:15,代码来源:HiveQueryVisitorTest.java

示例10: testComplexQuery

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testComplexQuery() throws QueryBuildingException {
  Predicate aves = new EqualsPredicate(OccurrenceSearchParameter.TAXON_KEY, "212");
  Predicate UK = new EqualsPredicate(OccurrenceSearchParameter.COUNTRY, "GB");
  Predicate before1989 = new LessThanOrEqualsPredicate(OccurrenceSearchParameter.YEAR, "1989");

  ConjunctionPredicate p = new ConjunctionPredicate(Lists.newArrayList(aves, UK, before1989));
  String where = visitor.getQuery(p);
  assertEquals("((taxon_key:212) AND (country:GB) AND (year:[* TO 1989]))", where);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:11,代码来源:SolrQueryVisitorTest.java

示例11: testConjunctionPredicate

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testConjunctionPredicate() throws QueryBuildingException {
  Predicate p1 = new EqualsPredicate(PARAM, "value_1");
  Predicate p2 = new EqualsPredicate(PARAM2, "value_2");

  ConjunctionPredicate p = new ConjunctionPredicate(Lists.newArrayList(p1, p2));
  String query = visitor.getQuery(p);
  assertThat(query, equalTo("((catalog_number:value_1) AND (institution_code:value_2))"));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:10,代码来源:SolrQueryVisitorTest.java

示例12: testDisjunctionPredicate

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testDisjunctionPredicate() throws QueryBuildingException {
  Predicate p1 = new EqualsPredicate(PARAM, "value_1");
  Predicate p2 = new EqualsPredicate(PARAM2, "value_2");

  DisjunctionPredicate p = new DisjunctionPredicate(Lists.newArrayList(p1, p2));
  String query = visitor.getQuery(p);
  assertThat(query, equalTo("((catalog_number:value_1) OR (institution_code:value_2))"));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:10,代码来源:SolrQueryVisitorTest.java

示例13: testQuotes

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
@Test
public void testQuotes() throws QueryBuildingException {
  Predicate p = new EqualsPredicate(PARAM, "my 'pleasure'");
  String query = visitor.getQuery(p);
  assertThat(query, equalTo("catalog_number:\"my\\ 'pleasure'\""));

  p = new LessThanOrEqualsPredicate(OccurrenceSearchParameter.ELEVATION, "101");
  query = visitor.getQuery(p);
  assertThat(query, equalTo("elevation:[* TO 101]"));

  p = new GreaterThanPredicate(OccurrenceSearchParameter.YEAR, "1998");
  query = visitor.getQuery(p);
  assertThat(query, equalTo("year:{1998 TO *]"));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:15,代码来源:SolrQueryVisitorTest.java

示例14: prepareMocks

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
private void prepareMocks(String user) {
  CallbackService callbackService = mock(CallbackService.class);
  DownloadRequestService service = mock(DownloadRequestService.class);
  OccurrenceDownloadService downloadService = mock(OccurrenceDownloadService.class);
  sec = mock(SecurityContext.class);
  GbifUserPrincipal userP = mock(GbifUserPrincipal.class);
  when(userP.getName()).thenReturn(user);
  when(sec.getUserPrincipal()).thenReturn(userP);

  resource = new DownloadResource(service, callbackService, downloadService);
  dl = new DownloadRequest(new EqualsPredicate(OccurrenceSearchParameter.TAXON_KEY, "1"), USER, null, true,
    DownloadFormat.DWCA);
  when(service.create(dl)).thenReturn(JOB_ID);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:15,代码来源:DownloadResourceTest.java

示例15: visit

import org.gbif.api.model.occurrence.predicate.EqualsPredicate; //导入依赖的package包/类
/**
 * Supports all parameters incl taxonKey expansion for higher taxa.
 */
public void visit(EqualsPredicate predicate) throws QueryBuildingException {
  visitSimplePredicate(predicate, EQUALS_OPERATOR);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:7,代码来源:SolrQueryVisitor.java


注:本文中的org.gbif.api.model.occurrence.predicate.EqualsPredicate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。