Package org.structr.core

Examples of org.structr.core.Result


        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = AbstractNode.name;
        boolean sortDesc    = true;
        int pageSize        = 10;
        int page            = 1;

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).page(page).pageSize(pageSize).getResult();

  //                      for (GraphObject obj : result.getResults()) {
  //                             
  //                              System.out.println(obj.getProperty(AbstractNode.name));
  //                             
  //                      }
        logger.log(Level.INFO, "Raw result size: {0}, expected: {1}", new Object[] { result.getRawResultCount(), number });
        assertTrue(result.getRawResultCount() == number);
        logger.log(Level.INFO, "Result size: {0}, expected: {1}", new Object[] { result.size(), Math.min(number, pageSize) });
        assertTrue(result.size() == Math.min(number, pageSize));

        for (int j = 0; j < Math.min(result.size(), pageSize); j++) {

          int expectedNumber = number + offset - 1 - j;
          String gotName     = result.get(j).getProperty(AbstractNode.name);

          System.out.println(expectedNumber + ", got: " + gotName);
          assertEquals(Integer.toString(expectedNumber), gotName);

        }
View Full Code Here


        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = TestOne.aDate;
        boolean sortDesc    = false;
        int pageSize        = 10;
        int page            = 1;

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).page(page).pageSize(pageSize).getResult();

  //                      for (GraphObject obj : result.getResults()) {
  //
  //                              System.out.println(obj.getProperty(AbstractNode.name) + ", " + obj.getProperty(TestOne.Key.aDate.name()));
  //                      }
        logger.log(Level.INFO, "Raw result size: {0}, expected: {1}", new Object[] { result.getRawResultCount(), number });
        assertTrue(result.getRawResultCount() == number);
        logger.log(Level.INFO, "Result size: {0}, expected: {1}", new Object[] { result.size(), pageSize });
        assertTrue(result.size() == Math.min(number, pageSize));

        for (int j = 0; j < Math.min(result.size(), pageSize); j++) {

          String expectedName = "TestOne-" + (offset + j);
          String gotName     = result.get(j).getProperty(AbstractNode.name);

          System.out.println(expectedName + ", got: " + gotName);
          assertEquals(expectedName, gotName);

        }
View Full Code Here

        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = AbstractNode.lastModifiedDate;
        boolean sortDesc    = true;
        int pageSize        = 10;
        int page            = 1;

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).page(page).pageSize(pageSize).getResult();

        logger.log(Level.INFO, "Raw result size: {0}, expected: {1}", new Object[] { result.getRawResultCount(), number });
        assertTrue(result.getRawResultCount() == number);
        logger.log(Level.INFO, "Result size: {0}, expected: {1}", new Object[] { result.size(), pageSize });
        assertTrue(result.size() == Math.min(number, pageSize));

        for (int j = 0; j < pageSize; j++) {

          int expectedNumber = number + offset - 1 - j;
          String gotName     = result.get(j).getProperty(AbstractNode.name);

          System.out.println(expectedNumber + ", got: " + gotName);
          assertEquals(Integer.toString(expectedNumber), gotName);

        }
View Full Code Here

        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = key;
        boolean sortDesc    = false;
        int pageSize        = 5;
        int page            = 1;

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).page(page).pageSize(pageSize).getResult();

  //                      for (GraphObject obj : result.getResults()) {
  //
  //                              System.out.println(obj.getProperty(AbstractNode.name) + ": " + obj.getProperty(key));
  //                      }
        logger.log(Level.INFO, "Raw result size: {0}, expected: {1}", new Object[] { result.getRawResultCount(), number });
        assertTrue(result.getRawResultCount() == number);
        logger.log(Level.INFO, "Result size: {0}, expected: {1}", new Object[] { result.size(), pageSize });
        assertTrue(result.size() == Math.min(number, pageSize));

        for (int j = 0; j < pageSize; j++) {

          int expectedNumber = offset + j;
          int gotNumber      = (Integer) result.get(j).getProperty(key);

          System.out.println("expected: " + expectedNumber + ", got: " + gotNumber);
          assertEquals(expectedNumber, gotNumber);

        }
View Full Code Here

        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = TestOne.aDate;
        boolean sortDesc    = true;
        int pageSize        = 10;
        int page            = 1;

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).page(page).pageSize(pageSize).getResult();

        logger.log(Level.INFO, "Raw result size: {0}, expected: {1}", new Object[] { result.getRawResultCount(), number });
        assertTrue(result.getRawResultCount() == number);
        logger.log(Level.INFO, "Result size: {0}, expected: {1}", new Object[] { result.size(), pageSize });
        assertTrue(result.size() == Math.min(number, pageSize));

        for (int j = 0; j < Math.min(result.size(), pageSize); j++) {

          String expectedName = "TestOne-" + (30 - (j+1)*2);
          String gotName     = result.get(j).getProperty(AbstractNode.name);

          System.out.println(j + ": " +  expectedName + ", got: " + gotName);
          assertEquals(expectedName, gotName);

        }
View Full Code Here

        }
        tx.success();
      }

      try (final Tx tx = app.tx()) {
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = AbstractNode.name;
        boolean sortDesc    = false;
        int pageSize        = 10;
        int page            = 1;

        // now with offsetId

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).pageSize(pageSize).page(page).offsetId(nodes.get(3).getUuid()).getResult();

        assertEquals(7, result.size());
        assertEquals("TestOne-3", result.get(0).getProperty(AbstractNode.name));
        assertEquals("TestOne-4", result.get(1).getProperty(AbstractNode.name));
        assertEquals("TestOne-5", result.get(2).getProperty(AbstractNode.name));
        assertEquals("TestOne-6", result.get(3).getProperty(AbstractNode.name));
        assertEquals("TestOne-7", result.get(4).getProperty(AbstractNode.name));
        assertEquals("TestOne-8", result.get(5).getProperty(AbstractNode.name));
        assertEquals("TestOne-9", result.get(6).getProperty(AbstractNode.name));
      }
     
    } catch (FrameworkException ex) {

      ex.printStackTrace();
View Full Code Here

        }
        tx.success();
      }

      try (final Tx tx = app.tx()) {
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = AbstractNode.name;
        boolean sortDesc    = false;
        int pageSize        = 2;
        int page            = -5;

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).pageSize(pageSize).page(page).getResult();

        assertEquals(2, result.size());
        assertEquals("TestOne-0", result.get(0).getProperty(AbstractNode.name));
        assertEquals("TestOne-1", result.get(1).getProperty(AbstractNode.name));

        // unknown offsetId

        page = 1;
View Full Code Here

        tx.success();
      }

      try (final Tx tx = app.tx()) {

        Result result = app.nodeQuery(type).and(TestOne.name, "TestOne", false).getResult();

        assertEquals(4, result.size());

        tx.success();

      }
View Full Code Here


    try {

      // do search
      Result result = query.getResult();

      // save raw result count
      int resultCountBeforePaging = result.size();

      // set full result list
      webSocketData.setResult(PagingHelper.subList(result.getResults(), pageSize, page, null));
      webSocketData.setRawResultCount(resultCountBeforePaging);

      // send only over local connection
      getWebSocket().send(webSocketData, true);
View Full Code Here

    }

    try {

      // do search
      final Result result = query.getResult();

      // set full result list
      webSocketData.setResult(result.getResults());

      // send only over local connection
      getWebSocket().send(webSocketData, true);

    } catch (FrameworkException fex) {
View Full Code Here

TOP

Related Classes of org.structr.core.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.