本文整理匯總了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;
}
示例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);
}
示例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);
}
}
示例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"));
}
}
示例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);
}
}
示例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();
}