当前位置: 首页>>代码示例>>Java>>正文


Java Entity.setProperty方法代码示例

本文整理汇总了Java中com.google.appengine.api.datastore.Entity.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.setProperty方法的具体用法?Java Entity.setProperty怎么用?Java Entity.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.datastore.Entity的用法示例。


在下文中一共展示了Entity.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@Override
public void process() {
    UserService userService = UserServiceFactory.getUserService();
    // Step 1: Add Text into DB.
    Entity textEntity = getNewEntity();
    textEntity.setProperty("rawText", new Text(text));
    textEntity.setProperty("user",
            userService.getCurrentUser().getNickname());
    textEntity.setProperty("date", new Date());
    putIntoDatabase(textEntity);
    Key parentKey = textEntity.getKey();
    factory.setParentKey(parentKey);
    // Step 2: Call other processors.
    factory.createTypePredictor().process();
    factory.createKnowledgeGraphBuilder().process();
    factory.createSummaryGenerator().process();
}
 
开发者ID:SamChou19815,项目名称:chunk-reader,代码行数:18,代码来源:MainProcessor.java

示例2: logUpdateRun

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
public void logUpdateRun(int majorVersion, int minorVersion, String filename, byte[] hash,
    JsonObject data, boolean forced) {
  Entity updateRun = new Entity(UPDATERUN_ENTITY_KIND);
  updateRun.setProperty("date", new Date());
  updateRun.setProperty("hash", new ShortBlob(hash));
  updateRun.setProperty("forced", forced);
  updateRun.setProperty("majorVersion", majorVersion);
  updateRun.setProperty("minorVersion", minorVersion);
  for (Entry<String, Long> performanceItem: timers.entrySet()) {
    updateRun.setProperty("time_"+performanceItem.getKey(), performanceItem.getValue());
  }
  updateRun.setProperty("filename", filename);
  StringBuilder sb = new StringBuilder();
  for (Entry<String, JsonElement> el: data.entrySet()) {
    if (el.getValue().isJsonArray()) {
      sb.append(el.getKey()).append("=").append(el.getValue().getAsJsonArray().size()).append(" ");
    }
  }
  if (sb.length()>0) {
    // remove trailing space
    sb.deleteCharAt(sb.length()-1);
  }
  updateRun.setProperty("summary", sb.toString());
  datastore.put(updateRun);
  timers.clear();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:27,代码来源:UpdateRunLogger.java

示例3: newSharedProduct

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void newSharedProduct(@FormParam("productID") String productID,
		@FormParam("productName") String productName,
		@Context HttpServletResponse servletResponse) throws Exception {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return;
	}

	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	Entity entity = new Entity("SharedList", productID);
	entity.setProperty("email", user.getEmail());
	entity.setProperty("productName", productName);
	entity.setProperty("sharedDate", new Date());
	datastore.put(entity);
	servletResponse.getWriter().println(productName + " has been added.");
	servletResponse.flushBuffer();
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:24,代码来源:Sharedlist.java

示例4: addEntityProto

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
/**
 * Adds a record containing a new entity protobuf to the file.
 *
 * <p>Returns the ComparableEntity object rather than "this" so that we can check for the presence
 * of the entity in the result set.
 */
ComparableEntity addEntityProto(int id, Property... properties) throws IOException {
  Entity entity = new Entity(TEST_ENTITY_KIND, id);
  for (Property prop : properties) {
    entity.setProperty(prop.name(), prop.value());
  }
  EntityProto proto = EntityTranslator.convertToPb(entity);
  byte[] protoBytes = proto.toByteArray();
  if (protoBytes.length > BLOCK_SIZE - (currentPos + HEADER_SIZE)) {
    out.write(currentBlock);
    currentBlock = new byte[BLOCK_SIZE];
    currentPos = 0;
  }

  currentPos = LevelDbUtil.addRecord(currentBlock, currentPos, ChunkType.FULL, protoBytes);
  return new ComparableEntity(entity);
}
 
开发者ID:google,项目名称:nomulus,代码行数:23,代码来源:LevelDbFileBuilder.java

示例5: testDifferentPropertiesNotEqual

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@Test
public void testDifferentPropertiesNotEqual() {
  Entity entity = new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID);
  // Note that we need to specify these as long for property comparisons to work because that's
  // how they are deserialized from protos.
  entity.setProperty("eeny", 100L);
  entity.setProperty("meeny", 200L);
  entity.setProperty("miney", 300L);

  EntityProto proto1 = EntityTranslator.convertToPb(entity);

  entity.setProperty("moe!", 400);
  EntityProto proto2 = EntityTranslator.convertToPb(entity);

  // Construct entity objects from the two protos.
  Entity e1 = EntityTranslator.createFromPb(proto1);
  Entity e2 = EntityTranslator.createFromPb(proto2);

  ComparableEntity ce1 = new ComparableEntity(e1);
  ComparableEntity ce2 = new ComparableEntity(e2);
  assertThat(e1).isEqualTo(e2); // The keys should still be the same.
  assertThat(ce1).isNotEqualTo(ce2);
  assertThat(ce1.hashCode()).isNotEqualTo(ce2.hashCode());
}
 
开发者ID:google,项目名称:nomulus,代码行数:25,代码来源:ComparableEntityTest.java

示例6: putIntoDatabase

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
public void putIntoDatabase() {
    Entity textSummaryEntity = getNewEntity();
    textSummaryEntity.setProperty("sentence", new Text(sentence));
    textSummaryEntity.setProperty("position", position);
    textSummaryEntity.setProperty("salience", salience);
    putIntoDatabase(textSummaryEntity);
}
 
开发者ID:SamChou19815,项目名称:chunk-reader,代码行数:8,代码来源:AnnotatedSentence.java

示例7: KnowledgeNodeDataStore

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
public KnowledgeNodeDataStore(Key parentKey, KnowledgeNode node) {
    super("TextKnowledgeGraph");
    setParentKey(parentKey);
    Entity knowledgeGraphEntity = getNewEntity();
    knowledgeGraphEntity.setProperty("name", node.getName());
    knowledgeGraphEntity.setProperty("type", node.getType());
    knowledgeGraphEntity.setProperty("URL", node.getMetadataURL());
    knowledgeGraphEntity.setProperty("salience", node.getSalience());
    knowledgeGraphEntity.setProperty("sentimentScore",
            node.getSentimentScore());
    putIntoDatabase(knowledgeGraphEntity);
}
 
开发者ID:SamChou19815,项目名称:chunk-reader,代码行数:13,代码来源:KnowledgeNodeDataStore.java

示例8: setNonNullIndexedProperty

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
/** For Blob and Text, this doesn't really make the property indexed.
 * TODO(ohler): disallow Blob and Text? */
public static void setNonNullIndexedProperty(Entity e, String propertyName, Object value) {
  Preconditions.checkNotNull(e, "Null entity");
  Preconditions.checkNotNull(propertyName, "Null propertyName");
  Preconditions.checkNotNull(value, "Null value");
  e.setProperty(propertyName, value);
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:9,代码来源:DatastoreUtil.java

示例9: setOrRemoveIndexedProperty

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
/** For Blob and Text, this doesn't really make the property indexed.
 * TODO(ohler): disallow Blob and Text? */
public static void setOrRemoveIndexedProperty(
    Entity e, String propertyName, @Nullable Object value) {
  Preconditions.checkNotNull(e, "Null entity");
  Preconditions.checkNotNull(propertyName, "Null propertyName");
  if (value == null) {
    e.removeProperty(propertyName);
  } else {
    e.setProperty(propertyName, value);
  }
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:13,代码来源:DatastoreUtil.java

示例10: newWishlistProductJson

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_JSON)
public void newWishlistProductJson(WishlistProduct product,
		@Context HttpServletResponse servletResponse) throws Exception {
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
		System.out.println("Login first");
		return;
	}

	DatastoreService datastore = DatastoreServiceFactory
			.getDatastoreService();
	MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
	Entity entity = new Entity(user.getEmail(), product.getProductID());
	entity.setProperty("productName", product.getProductName());
	entity.setProperty("currentPrice", product.getCurrentPrice());
	entity.setProperty("lowestPrice", product.getLowestPrice());
	entity.setProperty("lowestDate", new Date());
	datastore.put(entity);
	syncCache.put(product.getProductID(), product.getCurrentPrice());
	servletResponse.getWriter().println("<html><head>");
	servletResponse
			.getWriter()
			.println(
					"<meta http-equiv=\"refresh\" content=\"3;url=/wishlist.jsp\" />");
	servletResponse.getWriter().println("</head><body>");
	servletResponse.getWriter()
			.println(
					"<h1>" + product.getProductName()
							+ " has been added.</h1><br>");
	servletResponse
			.getWriter()
			.println(
					"<h2>Redirecting in 3 seconds...</h2> <a href=\"/wishlist.jsp\">Go back now</a>");
	servletResponse.getWriter().println("</body></html>");
	servletResponse.flushBuffer();
	return;
}
 
开发者ID:fasthall,项目名称:amazon-price-tracker,代码行数:41,代码来源:Wishlist.java

示例11: test_mapreduceSuccessfullyResavesEntity

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@Test
public void test_mapreduceSuccessfullyResavesEntity() throws Exception {
  createTld("tld");
  DomainResource domain = persistActiveDomain("test.tld");
  ContactResource contact = persistActiveContact("humanBeing");
  Entity domainEntry =
      ofy().save().toEntity(new HistoryEntry.Builder().setParent(domain).build());
  Entity contactEntry =
      ofy().save().toEntity(new HistoryEntry.Builder().setParent(contact).build());

  // Set raw properties outside the Objectify schema, which will be deleted upon re-save.
  domainEntry.setProperty("clientId", "validId");
  contactEntry.setProperty("otherClientId", "anotherId");
  domainEntry.setProperty("propertyToBeDeleted", "123blah");
  contactEntry.setProperty("alsoShouldBeDeleted", "456nah");
  datastoreService.put(domainEntry);
  datastoreService.put(contactEntry);
  ofy().clearSessionCache();
  runMapreduce();

  Entity updatedDomainEntry = datastoreService.get(domainEntry.getKey());
  Entity updatedContactEntry = datastoreService.get(contactEntry.getKey());
  assertThat(updatedDomainEntry.getProperty("clientId")).isEqualTo("validId");
  assertThat(updatedDomainEntry.getProperty("propertyToBeDeleted")).isNull();
  assertThat(updatedContactEntry.getProperty("otherClientId")).isEqualTo("anotherId");
  assertThat(updatedContactEntry.getProperty("alsoShouldBeDeleted")).isNull();
}
 
开发者ID:google,项目名称:nomulus,代码行数:28,代码来源:ResaveAllHistoryEntriesActionTest.java

示例12: testEquals

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@Test
public void testEquals() {
  // Create an entity with a key and some properties.
  Entity entity = new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID);
  // Note that we need to specify these as long for property comparisons to work because that's
  // how they are deserialized from protos.
  entity.setProperty("eeny", 100L);
  entity.setProperty("meeny", 200L);
  entity.setProperty("miney", 300L);

  EntityProto proto1 = EntityTranslator.convertToPb(entity);
  EntityProto proto2 = EntityTranslator.convertToPb(entity);

  // Reorder the property list of proto2 (the protobuf stores this as a repeated field, so
  // we just have to clear and re-add them in a different order).
  ImmutableList<Property> properties =
      ImmutableList.of(proto2.getProperty(2), proto2.getProperty(0), proto2.getProperty(1));
  proto2.clearProperty();
  for (Property property : properties) {
    proto2.addProperty(property);
  }

  // Construct entity objects from the two protos.
  Entity e1 = EntityTranslator.createFromPb(proto1);
  Entity e2 = EntityTranslator.createFromPb(proto2);

  // Ensure that we have a normalized representation.
  ComparableEntity ce1 = new ComparableEntity(e1);
  ComparableEntity ce2 = new ComparableEntity(e2);
  assertThat(ce1).isEqualTo(ce2);
  assertThat(ce1.hashCode()).isEqualTo(ce2.hashCode());

  // Ensure that the original entity is equal.
  assertThat(new ComparableEntity(entity)).isEqualTo(ce1);
}
 
开发者ID:google,项目名称:nomulus,代码行数:36,代码来源:ComparableEntityTest.java

示例13: before

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@Before
public void before() throws Exception {
  inject.setStaticField(DatastoreBackupInfo.class, "clock", clock);
  backupEntity = new Entity("_unused_");
  backupEntity.setProperty("name", "backup1");
  backupEntity.setProperty("kinds", ImmutableList.of("one", "two", "three"));
  backupEntity.setProperty("start_time", new Date(startTime.getMillis()));
}
 
开发者ID:google,项目名称:nomulus,代码行数:9,代码来源:DatastoreBackupInfoTest.java

示例14: persistBackupEntityWithName

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
private static void persistBackupEntityWithName(String name) {
  Entity entity = new Entity(DatastoreBackupService.BACKUP_INFO_KIND);
  entity.setProperty("name", name);
  entity.setProperty("kinds", ImmutableList.of("one", "two", "three"));
  entity.setProperty("start_time", new Date(START_TIME.getMillis()));
  getDatastoreService().put(entity);
}
 
开发者ID:google,项目名称:nomulus,代码行数:8,代码来源:DatastoreBackupServiceTest.java

示例15: process

import com.google.appengine.api.datastore.Entity; //导入方法依赖的package包/类
@Override
public void process() {
    Entity textEntity = getEntityByKey(parentKey);
    textEntity.setProperty("type", sentimentScore);
    putIntoDatabase(textEntity);
}
 
开发者ID:SamChou19815,项目名称:chunk-reader,代码行数:7,代码来源:TypePredictorClass.java


注:本文中的com.google.appengine.api.datastore.Entity.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。