Entity loginEntity = new Entity("login", id); loginEntity.setProperty("password", "admin@123"); datastore.put(loginEntity);
protected Entity toProtoEntity() { Entity entity = new Entity(key); entity.setProperty(ROOT_JOB_KEY_PROPERTY, rootJobKey); if (generatorJobKey != null) { entity.setProperty(GENERATOR_JOB_PROPERTY, generatorJobKey); } if (graphGUID != null) { entity.setUnindexedProperty(GRAPH_GUID_PROPERTY, graphGUID); } return entity; }
private static void setProperty(Entity entity, String name, Object value, boolean unindexed) { if (unindexed) { entity.setUnindexedProperty(name, value); } else { entity.setProperty(name, value); } }
public void setObject(Object datastoreEntity, int paramIndex, Object value) { if (paramIndex != StoreFieldManager.IS_FK_VALUE) { // Most of the time we want to just set the given value on the entity, but if this is a foreign key value we // want to just swallow the update. The reason is that we only maintain fks as parents in the key itself. // The updates we'll swallow are DataNucleus adding "hidden" back pointers to parent objects. // We don't want these. The back pointer is the parent of the key itself. ((Entity) datastoreEntity).setProperty(getPropertyName(), value); } }
static public void copyProperties(Entity src, Entity dest) { for (Map.Entry<String, Object> entry : getPropertyMap(src).entrySet()) { // barf if (entry.getValue() != null && entry.getValue().getClass().getName().equals("com.google.appengine.api.datastore.Entity$UnindexedValue")) { dest.setUnindexedProperty(entry.getKey(), src.getProperty(entry.getKey())); } else { dest.setProperty(entry.getKey(), entry.getValue()); } } }
@Override public Entity toEntity() { Entity entity = toProtoEntity(); entity.setProperty(JOB_KEY_PROPERTY, jobKey); entity.setProperty(JOB_CLASS_NAME_PROPERTY, jobClassName); entity.setUnindexedProperty(INSTANCE_VALUE_PROPERTY, value); entity.setUnindexedProperty(JOB_DISPLAY_NAME_PROPERTY, jobDisplayName); return entity; }
public static void saveSettings(Map<String, Object> newSettings) { // there is only one instance of LeanEngineSettings so the same ID=1 is always used Entity leanEntity = new Entity("_settings", 1); for (String propName : newSettings.keySet()) { leanEntity.setProperty(propName, newSettings.get(propName)); } DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); datastore.put(leanEntity); LeanEngineSettings.settings = newSettings; }
@Override public void store(String userId, Credential credential) { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Entity entity = new Entity(KIND, userId); entity.setProperty("accessToken", credential.getAccessToken()); entity.setProperty("refreshToken", credential.getRefreshToken()); entity.setProperty("expirationTimeMillis", credential.getExpirationTimeMilliseconds()); datastore.put(entity); }
@Override public void set(Entity r, String column, Object value) { if (r.isUnindexedProperty(column)) { r.setUnindexedProperty(column, value); } else { r.setProperty(column, value); } }
public void putMarker(String marker) { Entity entity = new Entity(entityName); entity.setProperty(TEST_RUN_ID, testRunId); entity.setProperty(EXECUTED_AT, System.currentTimeMillis()); entity.setProperty(MARKER, marker); saveEntity(entity); }
public Entity toEntity(T pojo, Objectify ofy) { SubclassInfo<T> info = this.getConcrete(pojo); Entity ent = info.metadata.toEntity(pojo, ofy); // Now put the discriminator value in entity if (info.discriminator != null) ent.setUnindexedProperty(DISCRIMINATOR_PROPERTY, info.discriminator); if (!info.indexedDiscriminators.isEmpty()) ent.setProperty(DISCRIMINATOR_INDEX_PROPERTY, info.indexedDiscriminators); return ent; }
@Override public Entity update(Entity blockEntity, int recordOffset, @Nullable FieldValue fieldValue) { Blob strings = (Blob) blockEntity.getProperty("ids"); int length = StringPools.size(strings); // since we only ever update when adding a new record, we should be able to simply append to the string pool if(recordOffset != length) { throw new IllegalStateException("length = " + length + ", recordOffset = " + recordOffset); } blockEntity.setProperty("ids", StringPools.appendString(strings, ((TextValue) fieldValue).asString())); return blockEntity; }
protected Entity createTestEntity(String kind) { Entity entity = new Entity(kind); entity.setProperty("text", "Some text."); return entity; }
protected Entity createTestEntity(String kind, Key key) { Entity entity = new Entity(kind, key); entity.setProperty("text", "Some text."); return entity; }
private Entity updateDouble(Entity blockEntity, int recordOffset, double doubleValue) { Blob valueArray = (Blob) blockEntity.getProperty(valuesProperty); valueArray = DoubleValueArray.update(valueArray, recordOffset, doubleValue); blockEntity.setUnindexedProperty(formatProperty, REAL64_STORAGE); blockEntity.setProperty(valuesProperty, valueArray); return blockEntity; }
protected Entity createTestEntity(String kind, long id) { Key key = KeyFactory.createKey(kind, id); Entity entity = new Entity(key); entity.setProperty("text", "Some text."); return entity; }
@Override public Entity toEntity() { Entity entity = toProtoEntity(); entity.setProperty(JOB_KEY_PROPERTY, jobKey); entity.setUnindexedProperty(TYPE_PROPERTY, type.toString()); entity.setUnindexedProperty(RELEASED_PROPERTY, released); entity.setUnindexedProperty(WAITING_ON_KEYS_PROPERTY, waitingOnKeys); entity.setUnindexedProperty(WAITING_ON_GROUP_SIZES_PROPERTY, waitingOnGroupSizes); return entity; }
@Test(expected = IllegalStateException.class) public void testClosedTx() throws InterruptedException { clearData(kindName); Transaction tx = service.beginTransaction(); Entity newRec = new Entity(kindName); newRec.setProperty("check", "4100331"); newRec.setProperty("stamp", new Date()); service.put(newRec); tx.commit(); service.put(tx, new Entity(kindName)); }
@Test(expected = ApiDeadlineExceededException.class) public void testDeadlineConfig() { DatastoreServiceConfig config = DatastoreServiceConfig.Builder.withDeadline(0.00001); DatastoreService ds = DatastoreServiceFactory.getDatastoreService(config); assertNotNull(ds); Entity g1 = new Entity("test"); g1.setProperty("deadline", "0.00001"); ds.put(g1); }
@Test public void testAllocateChild() { Entity parent = new Entity(ALLOCATE_IDS_ENTITY); parent.setProperty("name", "parent-" + System.currentTimeMillis()); Key parentKey = service.put(parent); final int allocateSize = 10; KeyRange range = service.allocateIds(parentKey, ALLOCATE_IDS_ENTITY, allocateSize); Entity child = new Entity(range.getStart()); Key key = service.put(child); // child with allocated key should have correct parent. Assert.assertEquals(parentKey, key.getParent()); }