congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
QueryOptions.parse
Code IndexAdd Tabnine to your IDE (free)

How to use
parse
method
in
io.yawp.repository.query.QueryOptions

Best Java code snippets using io.yawp.repository.query.QueryOptions.parse (Showing top 9 results out of 315)

origin: feroult/yawp

@Override
public Object action() {
  QueryBuilder<?> query = query();
  if (id != null) {
    query.from(id);
  }
  boolean returnCursor = false;
  if (params.containsKey(QUERY_OPTIONS)) {
    QueryOptions options = QueryOptions.parse(params.get(QUERY_OPTIONS));
    query.options(options);
    returnCursor = options.returnCursor();
  }
  if (hasShieldCondition()) {
    query.and(shield.getWhere());
  }
  List<?> objects = list(query);
  if (returnCursor) {
    Map<String, Object> result = new HashMap<>();
    result.put("results", objects);
    result.put("cursor", query.getCursor());
    return result;
  }
  
  return objects;
}
origin: feroult/yawp

@Test
public void testWhereWithIn() {
  String q = "{ where: [ 'id', 'in', ['1', '3', '5'] ] }";
  QueryOptions options = QueryOptions.parse(q);
  assertSimpleCondition(options.getCondition(), "id", WhereOperator.IN, Arrays.asList("1", "3", "5"));
}
origin: feroult/yawp

@Test
public void testWhereSimpleCondition() {
  String q = "{where: {p: 'longValue', op: '=', v: 1}}";
  QueryOptions options = QueryOptions.parse(q);
  assertSimpleCondition(options.getCondition(), "longValue", WhereOperator.EQUAL, 1l);
}
origin: feroult/yawp

@Test
public void testBooleanCodition() {
  String q = "{where: {p: 'booleanValue', op: '=', v: true}}";
  QueryOptions options = QueryOptions.parse(q);
  assertSimpleCondition(options.getCondition(), "booleanValue", WhereOperator.EQUAL, true);
}
origin: feroult/yawp

@Test
public void testQueryFromOptions() {
  saveManyBasicObjects(3);
  QueryOptions options = QueryOptions
      .parse("{where: ['stringValue', '=', 'xpto'], order: [{p: 'intValue', d: 'desc'}], limit: 2}");
  List<BasicObject> objects = yawp(BasicObject.class).options(options).list();
  assertEquals(2, objects.size());
  assertEquals(3, objects.get(0).getIntValue());
  assertEquals(2, objects.get(1).getIntValue());
}
origin: feroult/yawp

@Test
public void testQueryOptions() {
  String q = "{where: ['longValue', '=', 1, 'intValue', '=', 3, 'doubleValue', '=', 4.3], order: [{p:'stringValue', d:'desc'}], sort: [{p:'longValue', d:'desc'}], limit: 2}";
  QueryOptions options = QueryOptions.parse(q);
  JoinedCondition conditions = assertJoinedCondition(options.getCondition(), LogicalOperator.AND, 3);
  assertSimpleCondition(conditions.getConditions()[0], "longValue", WhereOperator.EQUAL, 1l);
  assertSimpleCondition(conditions.getConditions()[1], "intValue", WhereOperator.EQUAL, 3l);
  assertSimpleCondition(conditions.getConditions()[2], "doubleValue", WhereOperator.EQUAL, 4.3);
  List<QueryOrder> order = options.getPreOrders();
  assertEquals(1, order.size());
  assertOrderEquals("stringValue", "desc", order.get(0));
  List<QueryOrder> sort = options.getPostOrders();
  assertEquals(1, sort.size());
  assertOrderEquals("longValue", "desc", sort.get(0));
  assertEquals(new Integer(2), options.getLimit());
}
origin: feroult/yawp

@Test
public void testWhereJoinedConditions() {
  String q = "{where: {op: 'and', c: [{p: 'longValue', op: '=', v: 1}, {p: 'intValue', op: '=', v: 3}]}}";
  QueryOptions options = QueryOptions.parse(q);
  JoinedCondition condition = assertJoinedCondition(options.getCondition(), LogicalOperator.AND, 2);
  assertSimpleCondition(condition.getConditions()[0], "longValue", WhereOperator.EQUAL, 1l);
  assertSimpleCondition(condition.getConditions()[1], "intValue", WhereOperator.EQUAL, 3l);
}
origin: feroult/yawp

@Test
public void testEmpty() {
  String q = "{}";
  QueryOptions options = QueryOptions.parse(q);
  assertNull(options.getPreOrders());
  assertNull(options.getPostOrders());
  assertNull(options.getLimit());
}
origin: feroult/yawp

@Test
public void testWhereJoinedConditionsWithPrecedence() {
  String q = "{where: {op: 'and', c: [{p: 'longValue', op: '=', v: 1}, {op: 'or', c: [{p: 'intValue', op: '=', v: 3}, {p: 'doubleValue', op: '=', v: 4.3}]}]}}";
  QueryOptions options = QueryOptions.parse(q);
  JoinedCondition condition1 = assertJoinedCondition(options.getCondition(), LogicalOperator.AND, 2);
  assertSimpleCondition(condition1.getConditions()[0], "longValue", WhereOperator.EQUAL, 1l);
  JoinedCondition condition2 = assertJoinedCondition(condition1.getConditions()[1], LogicalOperator.OR, 2);
  assertSimpleCondition(condition2.getConditions()[0], "intValue", WhereOperator.EQUAL, 3l);
  assertSimpleCondition(condition2.getConditions()[1], "doubleValue", WhereOperator.EQUAL, 4.3);
}
io.yawp.repository.queryQueryOptionsparse

Popular methods of QueryOptions

  • getCondition
  • getLimit
  • getPostOrders
  • getPreOrders
  • <init>
  • getCursor
  • getJsonObjectValue
  • getJsonObjectValueForArrays
  • getJsonStringValue
  • parseCondition
  • parseConditionObject
  • parseCursor
  • parseConditionObject,
  • parseCursor,
  • parseJoinedCondition,
  • parseLimit,
  • parseOrders,
  • parseReturnCursor,
  • parseSimpleCondition,
  • returnCursor

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • putExtra (Intent)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Collectors (java.util.stream)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now