Search in sources :

Example 1 with Entity

use of com.google.cloud.datastore.Entity in project jetty.project by eclipse.

the class GCloudSessionTestSupport method listSessions.

public void listSessions() throws Exception {
    GqlQuery.Builder builder = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from " + GCloudSessionDataStore.EntityDataModel.KIND);
    Query<Entity> query = builder.build();
    QueryResults<Entity> results = _ds.run(query);
    assertNotNull(results);
    System.err.println("SESSIONS::::::::");
    while (results.hasNext()) {
        Entity e = results.next();
        System.err.println(e.getString("clusterId") + " expires at " + e.getLong("expiry"));
    }
    System.err.println("END OF SESSIONS::::::::");
}
Also used : Entity(com.google.cloud.datastore.Entity) GqlQuery(com.google.cloud.datastore.GqlQuery)

Example 2 with Entity

use of com.google.cloud.datastore.Entity in project google-cloud-java by GoogleCloudPlatform.

the class ITDatastoreSnippets method testEntityAddGet.

@Test
public void testEntityAddGet() {
    String key = registerKey("my_single_key_add");
    datastoreSnippets.addSingleEntity(key);
    Entity entity = datastoreSnippets.getEntityWithKey(key);
    assertEquals("value", entity.getString("propertyName"));
}
Also used : Entity(com.google.cloud.datastore.Entity) Test(org.junit.Test)

Example 3 with Entity

use of com.google.cloud.datastore.Entity in project google-cloud-java by GoogleCloudPlatform.

the class ITDatastoreSnippets method addEntity.

private void addEntity(String keyName, String keyClass, String property, String value) {
    Key key = datastore.newKeyFactory().setKind(keyClass).newKey(keyName);
    Entity.Builder entityBuilder = Entity.newBuilder(key);
    entityBuilder.set(property, value);
    Entity entity = entityBuilder.build();
    datastore.put(entity);
}
Also used : Entity(com.google.cloud.datastore.Entity) Key(com.google.cloud.datastore.Key)

Example 4 with Entity

use of com.google.cloud.datastore.Entity in project google-cloud-java by GoogleCloudPlatform.

the class ITDatastoreSnippets method testEntityPutGet.

@Test
public void testEntityPutGet() {
    String key = registerKey("my_single_key_put");
    datastoreSnippets.putSingleEntity(key);
    Entity entity = datastoreSnippets.getEntityWithKey(key);
    assertEquals("value", entity.getString("propertyName"));
}
Also used : Entity(com.google.cloud.datastore.Entity) Test(org.junit.Test)

Example 5 with Entity

use of com.google.cloud.datastore.Entity in project google-cloud-java by GoogleCloudPlatform.

the class ITTransactionSnippets method testIsActive.

@Test
public void testIsActive() {
    Transaction transaction = datastore.newTransaction();
    TransactionSnippets transactionSnippets = new TransactionSnippets(transaction);
    Key key = transactionSnippets.isActive();
    Entity result = datastore.get(key);
    assertNotNull(result);
    datastore.delete(key);
}
Also used : Entity(com.google.cloud.datastore.Entity) Transaction(com.google.cloud.datastore.Transaction) Key(com.google.cloud.datastore.Key) Test(org.junit.Test)

Aggregations

Entity (com.google.cloud.datastore.Entity)59 Key (com.google.cloud.datastore.Key)37 IncompleteKey (com.google.cloud.datastore.IncompleteKey)27 Test (org.junit.Test)25 FullEntity (com.google.cloud.datastore.FullEntity)24 Datastore (com.google.cloud.datastore.Datastore)16 ProjectionEntity (com.google.cloud.datastore.ProjectionEntity)15 Transaction (com.google.cloud.datastore.Transaction)15 KeyFactory (com.google.cloud.datastore.KeyFactory)12 DatastoreException (com.google.cloud.datastore.DatastoreException)11 Batch (com.google.cloud.datastore.Batch)2 GqlQuery (com.google.cloud.datastore.GqlQuery)2 NullValue (com.google.cloud.datastore.NullValue)2 HashSet (java.util.HashSet)2 BooleanValue (com.google.cloud.datastore.BooleanValue)1 LatLngValue (com.google.cloud.datastore.LatLngValue)1 ListValue (com.google.cloud.datastore.ListValue)1 StringValue (com.google.cloud.datastore.StringValue)1 TimestampValue (com.google.cloud.datastore.TimestampValue)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1