當前位置: 首頁>>代碼示例>>Java>>正文


Java Objectify.put方法代碼示例

本文整理匯總了Java中com.googlecode.objectify.Objectify.put方法的典型用法代碼示例。如果您正苦於以下問題:Java Objectify.put方法的具體用法?Java Objectify.put怎麽用?Java Objectify.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.googlecode.objectify.Objectify的用法示例。


在下文中一共展示了Objectify.put方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createUser

import com.googlecode.objectify.Objectify; //導入方法依賴的package包/類
private UserData createUser(Objectify datastore, String userId, String email) {
  String emaillower = null;
  if (email != null) {
    emaillower = email.toLowerCase();
  }
  UserData userData = new UserData();
  userData.id = userId;
  userData.tosAccepted = false;
  userData.settings = "";
  userData.email = email == null ? "" : email;
  userData.name = User.getDefaultName(email);
  userData.type = User.USER;
  userData.link = "";
  userData.emaillower = email == null ? "" : emaillower;
  userData.emailFrequency = User.DEFAULT_EMAIL_NOTIFICATION_FREQUENCY;
  datastore.put(userData);
  return userData;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:19,代碼來源:ObjectifyStorageIo.java

示例2: addUserFileContents

import com.googlecode.objectify.Objectify; //導入方法依賴的package包/類
private void addUserFileContents(Objectify datastore, String userId, String fileName, byte[] content) {
  UserFileData ufd = datastore.find(userFileKey(userKey(userId), fileName));
  byte [] empty = new byte[] { (byte)0x5b, (byte)0x5d }; // "[]" in bytes
  if (ufd == null) {          // File doesn't exist
    if (fileName.equals(StorageUtil.USER_BACKPACK_FILENAME) &&
      Arrays.equals(empty, content)) {
      return;                 // Nothing to do
    }
    ufd = new UserFileData();
    ufd.fileName = fileName;
    ufd.userKey = userKey(userId);
  } else {
    if (fileName.equals(StorageUtil.USER_BACKPACK_FILENAME) &&
      Arrays.equals(empty, content)) {
      // Storing an empty backback, just delete the file
      datastore.delete(userFileKey(userKey(userId), fileName));
      return;
    }
  }
  ufd.content = content;
  datastore.put(ufd);
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:23,代碼來源:ObjectifyStorageIo.java

示例3: addFilesToProject

import com.googlecode.objectify.Objectify; //導入方法依賴的package包/類
private void addFilesToProject(Objectify datastore, long projectId, FileData.RoleEnum role,
  boolean changeModDate, String userId, String... fileNames) {
  List<FileData> addedFiles = new ArrayList<FileData>();
  Key<ProjectData> projectKey = projectKey(projectId);
  for (String fileName : fileNames) {
    FileData fd = createProjectFile(datastore, projectKey, role, fileName);
    if (fd != null) {
      fd.userId = userId;
      addedFiles.add(fd);
    }
  }
  datastore.put(addedFiles); // batch put
  if (changeModDate) {
    updateProjectModDate(datastore, projectId, false);
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:17,代碼來源:ObjectifyStorageIo.java

示例4: updateProjectModDate

import com.googlecode.objectify.Objectify; //導入方法依賴的package包/類
private long updateProjectModDate(Objectify datastore, long projectId, boolean doingConversion) {
  long modDate = System.currentTimeMillis();
  ProjectData pd = datastore.find(projectKey(projectId));
  if (pd != null) {
    // Only update the ProjectData dateModified if it is more then a minute
    // in the future. Do this to avoid unnecessary datastore puts.
    // Also do not update modification time when doing conversion from
    // blobstore to GCS
    if ((modDate > (pd.dateModified + 1000*60)) && !doingConversion) {
      pd.dateModified = modDate;
      datastore.put(pd);
    } else {
      // return the (old) dateModified
      modDate = pd.dateModified;
    }
    return modDate;
  } else {
    throw CrashReport.createAndLogError(LOG, null, null,
        new IllegalArgumentException("project " + projectId + " doesn't exist"));
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:22,代碼來源:ObjectifyStorageIo.java

示例5: createRawUserFile

import com.googlecode.objectify.Objectify; //導入方法依賴的package包/類
@VisibleForTesting
void createRawUserFile(String userId, String fileName, byte[] content) {
  Objectify datastore = ObjectifyService.begin();
  UserFileData ufd = createUserFile(datastore, userKey(userId), fileName);
  if (ufd != null) {
    ufd.content = content;
    datastore.put(ufd);
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:10,代碼來源:ObjectifyStorageIo.java

示例6: doUpgrade

import com.googlecode.objectify.Objectify; //導入方法依賴的package包/類
public void doUpgrade(String userId) {
  if (!conversionEnabled)     // Unless conversion is enabled...
    return;                   // shouldn't really ever happen but...
  Objectify datastore = ObjectifyService.begin();
  UserData userData = datastore.find(userKey(userId));
  if ((userData.upgradedGCS && useGcs) ||
    (!userData.upgradedGCS && !useGcs))
    return;                   // All done, another task did it!
  List<Long> projectIds = getProjects(userId);
  boolean anyFailed = false;
  for (long projectId : projectIds) {
    for (FileData fd : datastore.query(FileData.class).ancestor(projectKey(projectId))) {
      if (fd.isBlob) {
        if (useGcs) {         // Let's convert by just reading it!
          downloadRawFile(userId, projectId, fd.fileName);
        }
      } else if (isTrue(fd.isGCS)) {
        if (!useGcs) {        // Let's downgrade by just reading it!
          downloadRawFile(userId, projectId, fd.fileName);
        }
      }
    }
  }

  /*
   * If we are running low on time, we may have not moved all files
   * so exit now without marking the user as having been finished
   */
  if (ApiProxy.getCurrentEnvironment().getRemainingMillis() <= 5000)
    return;

  /* If anything failed, also return without marking user */
  if (anyFailed)
    return;

  datastore = ObjectifyService.beginTransaction();
  userData = datastore.find(userKey(userId));
  userData.upgradedGCS = useGcs;
  datastore.put(userData);
  datastore.getTxn().commit();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:42,代碼來源:ObjectifyStorageIo.java


注:本文中的com.googlecode.objectify.Objectify.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。