Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.DatastoreService


    tester.request.setHeader("X-AppEngine-TaskRetryCount", "11");
    tester.request.setParameter("controlKey", KeyFactory.keyToString(controlKey));
    String run = tester.start("/tasks/dump");
    assertNull(run);

    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    ds.get(controlKey);
 
View Full Code Here


    ControllerTester tester = new ControllerTester();
    HttpSession session = tester.request.getSession(true);
    session.setAttribute("token", authSubToken);

    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    Entity entity = new Entity(KeyFactory.createKey("TestKind", 1));
    ds.put(entity);

    String run = tester.start("/dump/index");
    assertNotNull(run);
    List<Map<String, Object>> list = (List) tester.request.getAttribute("list");
    assertThat(list.size(), is(1));
View Full Code Here

    // Preapre Data
    final int COUNT = 10;
    final String KIND_NAME = "TestKind";
    final List<Entity> orgData = TestDataUtil.bulkData(KIND_NAME, COUNT);
    final DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    ds.put(orgData);

    final String[] kinds = { KIND_NAME };

    // Create Spreadsheet
    GbSpreadsheetService gss = new GbSpreadsheetService(authSubToken);
View Full Code Here

    }
  }

  public static Key prepareDropControlKey(String kindName) {

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Key controlId = datastore.allocateIds("drop", 1).getStart();
    Key childKey = KeyFactory.createKey(controlId, GbControl.NAME, kindName);
    Entity control = new Entity(childKey);
    control.setProperty(GbControl.KIND_NAME, kindName);
    control.setProperty(GbControl.REPORT_TO, new Email("test@example.com"));
    control.setProperty(GbControl.COUNT, 0);
    control.setProperty(GbControl.UPDATE_DATE, new Date());
    datastore.put(control);

    return childKey;
  }
View Full Code Here

    return childKey;
  }
 
  public static Key prepareDumpControlKey(String kindName, String ssKey, String token) {
   
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Key controlId = datastore.allocateIds("dump", 1).getStart();
    Key childKey = KeyFactory.createKey(controlId, GbControl.NAME, kindName);
    Entity control = new Entity(childKey);
    control.setProperty(GbControl.KIND_NAME, kindName);
    control.setProperty(GbControl.COUNT, 0);
    control.setProperty(GbControl.UPDATE_DATE, new Date());
    control.setProperty(GbControl.AUTH_SUB_TOKEN, token);
    control.setProperty(GbControl.SPREADSHEET_KEY, ssKey);
   
    datastore.put(control);
    return childKey;
  }
View Full Code Here

    return childKey;
  }

  public static Key prepareRestoreControlKey(String kindName, String ssKey, String token) {
   
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Key controlId = datastore.allocateIds("restore", 1).getStart();
    Key childKey = KeyFactory.createKey(controlId, GbControl.NAME, kindName);
    Entity control = new Entity(childKey);
    control.setProperty(GbControl.KIND_NAME, kindName);
    control.setProperty(GbControl.COUNT, 2); // NOT FROM 0
    control.setProperty(GbControl.UPDATE_DATE, new Date());
    control.setProperty(GbControl.AUTH_SUB_TOKEN, token);
    control.setProperty(GbControl.SPREADSHEET_KEY, ssKey);
   
    datastore.put(control);
    return childKey;
  }
View Full Code Here

    coll2.add(new Integer(RandomStringUtils.randomNumeric(5)));
    coll2.add(new Integer(RandomStringUtils.randomNumeric(5)));
    coll2.add(new Integer(RandomStringUtils.randomNumeric(5)));
    entity.setProperty(GbProperty.LIST + "Integer", coll2);

    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    ds.put(entity);

    DatastoreService ds2 = DatastoreServiceFactory.getDatastoreService();
    try {
      getEntity = ds2.get(testKey);
    } catch (EntityNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
View Full Code Here

  public void restoreOnce() {

    List<GbEntity> list = TestDataUtil.entities();
    GbDatastoreService.restoreData(TestDataUtil.TEST_KIND, list);

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    List<Entity> asList =
      datastore.prepare(new Query(TestDataUtil.TEST_KIND)).asList(
        FetchOptions.Builder.withDefaults());

    assertThat(asList.size(), is(5));

    assertThat(asList.get(0).getProperties().size(), is(2));
View Full Code Here

    GbDatastoreService.restoreData(TestDataUtil.TEST_KIND, list);

    List<GbEntity> list2 = TestDataUtil.entitiesWidhDiffKeys();
    GbDatastoreService.restoreData(TestDataUtil.TEST_KIND, list2);

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    List<Entity> asList =
      datastore.prepare(new Query(TestDataUtil.TEST_KIND)).asList(
        FetchOptions.Builder.withDefaults());
    assertThat(asList.size(), is(8));

    assertThat(asList.get(0).getProperties().size(), is(2));
    assertThat(asList.get(0).getProperty("prop1").toString(), is("prepare1_1"));
View Full Code Here

    GbDatastoreService.restoreData(TestDataUtil.TEST_KIND, list1);

    List<GbEntity> list3 = TestDataUtil.entitiesWithDiffProp();
    GbDatastoreService.restoreData(TestDataUtil.TEST_KIND, list3);

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    List<Entity> asList =
      datastore.prepare(new Query(TestDataUtil.TEST_KIND)).asList(
        FetchOptions.Builder.withDefaults());

    assertThat(asList.size(), is(5));
    assertThat(asList.get(0).getProperties().size(), is(3));
    assertThat(asList.get(0).getProperty("prop1").toString(), is("prepare1_1"));
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.DatastoreService

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.