本文整理汇总了Java中com.googlecode.objectify.Objectify类的典型用法代码示例。如果您正苦于以下问题:Java Objectify类的具体用法?Java Objectify怎么用?Java Objectify使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Objectify类属于com.googlecode.objectify包,在下文中一共展示了Objectify类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: searchUsers
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
@Override
public List<AdminUser> searchUsers(final String partialEmail) {
final List<AdminUser> retval = new ArrayList();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
Query<UserData> userDataQuery = datastore.query(UserData.class).filter("email >=", partialEmail);
int count = 0;
for (UserData user : userDataQuery) {
boolean isModerator = (user.type == 1);
retval.add(new AdminUser(user.id, user.name, user.email, user.tosAccepted,
user.isAdmin, isModerator, user.visited));
count++;
if (count > 20) {
break;
}
}
}
}, false);
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, null, e);
}
return retval;
}
示例2: getRecentGalleryApps
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* Returns a wrapped class which contains list of most recently
* updated galleryApps and total number of results in database
* @param start starting index of apps you want
* @param count number of apps you want
* @return list of {@link GalleryApp}
*/
@Override
public GalleryAppListResult getRecentGalleryApps(int start, final int count) {
final List<GalleryApp> apps = new ArrayList<GalleryApp>();
// If I try to run this in runjobwithretries, it tells me can't run
// non-ancestor query as a transaction. ObjectifyStorageio has some samples
// of not using transactions (run with) so I grabbed.
Objectify datastore = ObjectifyService.begin();
for (GalleryAppData appData:datastore.query(GalleryAppData.class).order("-dateModified").filter("active", true).offset(start).limit(count)) {
GalleryApp gApp = new GalleryApp();
makeGalleryApp(appData, gApp);
apps.add(gApp);
}
int totalCount = datastore.query(GalleryAppData.class).order("-dateModified").filter("active", true).count();
return new GalleryAppListResult(apps, totalCount);
}
示例3: getMostDownloadedApps
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* Returns a wrapped class which contains a list of most downloaded
* gallery apps and total number of results in database
* @param start starting index of apps you want
* @param count number of apps you want
* @return list of {@link GalleryApp}
*/
@Override
public GalleryAppListResult getMostDownloadedApps(int start, final int count) {
final List<GalleryApp> apps = new ArrayList<GalleryApp>();
// If I try to run this in runjobwithretries, it tells me can't run
// non-ancestor query as a transaction. ObjectifyStorageio has some samples
// of not using transactions (run with) so I grabbed.
Objectify datastore = ObjectifyService.begin();
for (GalleryAppData appData:datastore.query(GalleryAppData.class).order("-numDownloads").filter("active", true).offset(start).limit(count)) {
GalleryApp gApp = new GalleryApp();
makeGalleryApp(appData, gApp);
apps.add(gApp);
}
int totalCount = datastore.query(GalleryAppData.class).order("-numDownloads").filter("active", true).count();
return new GalleryAppListResult(apps, totalCount);
}
示例4: getDeveloperApps
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* Returns a wrapped class which contains a list of galleryApps
* by a particular developer and total number of results in database
* @param userId id of developer
* @param start starting index of apps you want
* @param count number of apps you want
* @return list of {@link GalleryApp}
*/ @Override
public GalleryAppListResult getDeveloperApps(String userId, int start, final int count) {
final List<GalleryApp> apps = new ArrayList<GalleryApp>();
// if i try to run this in runjobwithretries it tells me can't run
// non-ancestor query as a transaction. ObjectifyStorageio has some samples
// of not using transactions (run with) so i grabbed
Objectify datastore = ObjectifyService.begin();
for (GalleryAppData appData:datastore.query(GalleryAppData.class).filter("userId",userId).filter("active", true).offset(start).limit(count)) {
GalleryApp gApp = new GalleryApp();
makeGalleryApp(appData, gApp);
apps.add(gApp);
}
int totalCount = datastore.query(GalleryAppData.class).filter("userId",userId).filter("active", true).count();
return new GalleryAppListResult(apps, totalCount);
}
示例5: incrementDownloads
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* Records that an app has been downloaded
* @param galleryId the id of gallery app that was downloaded
*/
@Override
public void incrementDownloads(final long galleryId) {
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
GalleryAppData galleryAppData = datastore.find(galleryKey(galleryId));
if (galleryAppData != null) {
galleryAppData.numDownloads = galleryAppData.numDownloads + 1;
galleryAppData.unreadDownloads = galleryAppData.unreadDownloads + 1;
datastore.put(galleryAppData);
}
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo", e);
}
}
示例6: updateGalleryApp
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* updates gallery app
* @param galleryId id of app being updated
* @param title new title of app
* @param description new description of app
* @param userId if of user publishing this app
*/
@Override
public void updateGalleryApp(final long galleryId, final String title,
final String description, final String moreInfo, final String credit,
final String userId) {
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
GalleryAppData galleryAppData = datastore.find(galleryKey(galleryId));
if (galleryAppData != null) {
long date = System.currentTimeMillis();
galleryAppData.title = title;
galleryAppData.description = description;
galleryAppData.moreInfo = moreInfo;
galleryAppData.credit = credit;
galleryAppData.dateModified = date;
datastore.put(galleryAppData);
}
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo", e);
}
}
示例7: addComment
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* adds a comment to a gallery app
* @param galleryId id of gallery app that was commented on
* @param userId id of user who commented
* @param comment comment
* @return the id of the new comment
*/
@Override
public long addComment(final long galleryId, final String userId, final String comment) {
final Result<Long> theDate = new Result<Long>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
GalleryCommentData commentData = new GalleryCommentData();
long date = System.currentTimeMillis();
commentData.comment = comment;
commentData.userId = userId;
commentData.galleryKey = galleryKey(galleryId);
commentData.dateCreated = date;
theDate.t = date;
datastore.put(commentData);
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.addComment", e);
}
return theDate.t;
}
示例8: getNumLikes
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* get num likes of a gallery app
*
* @param galleryId
* id of gallery app
* @return the num of like
*/
public int getNumLikes(final long galleryId) {
final Result<Integer> num = new Result<Integer>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
Key<GalleryAppData> galleryKey = galleryKey(galleryId);
//num.t = datastore.query(GalleryAppLikeData.class).ancestor(galleryKey).count();
GalleryAppData galleryAppData = datastore.find(galleryKey);
num.t = galleryAppData.numLikes;
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null,
"error in galleryStorageIo.getNumLike", e);
}
return num.t;
}
示例9: remixedTo
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* get the list of children Gallery Apps
*
* @param galleryId
* id of gallery app
* @return the list of children Gallery Apps
*/
public List<GalleryApp> remixedTo(final long galleryId) {
final List<GalleryApp> apps = new ArrayList<GalleryApp>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
datastore = ObjectifyService.begin();
for (GalleryAppAttributionData attributionData:datastore.query(GalleryAppAttributionData.class).filter("attributionId",galleryId)) {
GalleryAppData galleryAppData = datastore.find(galleryKey(attributionData.galleryId));
if(!galleryAppData.active) continue;
GalleryApp gApp = new GalleryApp();
makeGalleryApp(galleryAppData, gApp);
apps.add(gApp);
}
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null,
"error in galleryStorageIo.saveAttribution", e);
}
return apps;
}
示例10: addAppReport
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* adds a report (flag) to a gallery app
* @param galleryId id of gallery app that was commented on
* @param offenderId id of user who commented
* @param reporterId report
* @return the id of the new report
*/
@Override
public long addAppReport(final String reportText, final long galleryId,final String offenderId, final String reporterId) {
final Result<Long> theDate = new Result<Long>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
GalleryAppReportData reportData = new GalleryAppReportData();
long date = System.currentTimeMillis();
reportData.id = null; // let Objectify auto-generate the GalleryAppReportData id
reportData.reportText = reportText;
reportData.reporterId = reporterId;
reportData.offenderId = offenderId;
reportData.galleryKey = galleryKey(galleryId);
reportData.dateCreated=date;
reportData.resolved = false;
theDate.t=date;
datastore.put(reportData);
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.addAppReport", e);
}
return theDate.t;
}
示例11: getAppReports
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* Returns a list of reports (flags) for an app
* @param galleryId id of gallery app
* @param start start index
* @param count number to return
* @return list of {@link GalleryAppReport}
*/
@Override
public List<GalleryAppReport> getAppReports(final long galleryId, final int start, final int count) {
final List<GalleryAppReport> reports = new ArrayList<GalleryAppReport>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
Key<GalleryAppData> galleryKey = galleryKey(galleryId);
for (GalleryAppReportData reportData : datastore.query(GalleryAppReportData.class).filter("resolved", false).order("-dateCreated").offset(start).limit(count)) {
User reporter = storageIo.getUser(reportData.reporterId);
User offender = storageIo.getUser(reportData.offenderId);
GalleryApp app = getGalleryApp(galleryId);
GalleryAppReport galleryReport = new GalleryAppReport(reportData.id,reportData.reportText, app, offender, reporter,
reportData.dateCreated, reportData.resolved);
reports.add(galleryReport);
}
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.getAppReports", e);
}
return reports;
}
示例12: markReportAsResolved
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* mark an report as resolved
* @param reportId the id of the app
*/
@Override
public boolean markReportAsResolved(final long reportId, final long galleryId){
final Result<Boolean> success = new Result<Boolean>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
datastore = ObjectifyService.begin();
success.t = false;
Key<GalleryAppData> galleryKey = galleryKey(galleryId);
for (GalleryAppReportData reportData : datastore.query(GalleryAppReportData.class).ancestor(galleryKey)) {
if(reportData.id == reportId){
reportData.resolved = !reportData.resolved;
datastore.put(reportData);
success.t = true;
break;
}
}
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.markReportAsResolved", e);
}
return success.t;
}
示例13: isGalleryAppActivated
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* check if gallery app is activated
* @param galleryId the id of the gallery app
*/
@Override
public boolean isGalleryAppActivated(final long galleryId){
final Result<Boolean> success = new Result<Boolean>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
datastore = ObjectifyService.begin();
success.t = false;
Key<GalleryAppData> galleryKey = galleryKey(galleryId);
GalleryAppData appData = datastore.find(galleryKey);
if(appData != null){
if(appData.active){
success.t = true;
}
}
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.markReportAsResolved", e);
}
return success.t;
}
示例14: addCommentReport
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* adds a report (flag) to a gallery app comment
* @param commentId id of comment that was reported
* @param userId id of user who commented
* @param report report
* @return the id of the new report
*/
@Override
public long addCommentReport(final long commentId, final String userId, final String report) {
final Result<Long> theDate = new Result<Long>();
try {
runJobWithRetries(new JobRetryHelper() {
@Override
public void run(Objectify datastore) {
GalleryCommentReportData reportData = new GalleryCommentReportData();
long date = System.currentTimeMillis();
reportData.report = report;
reportData.userId = userId;
reportData.galleryCommentKey = galleryCommentKey(commentId);
reportData.dateCreated=date;
theDate.t=date;
datastore.put(reportData);
}
});
} catch (ObjectifyException e) {
throw CrashReport.createAndLogError(LOG, null, "error in galleryStorageIo.addCommentReport", e);
}
return theDate.t;
}
示例15: getCommentReports
import com.googlecode.objectify.Objectify; //导入依赖的package包/类
/**
* Returns a list of reports (flags) for all comments
* @return list of {@link GalleryCommentReport}
*/
@Override
public List<GalleryCommentReport> getCommentReports() {
final List<GalleryCommentReport> reports = new ArrayList<GalleryCommentReport>();
Objectify datastore = ObjectifyService.begin();
for (GalleryCommentReportData reportData : datastore.query(GalleryCommentReportData.class).order("-dateCreated")) {
User commenter = storageIo.getUser(reportData.userId);
String name="unknown";
if (commenter!= null) {
name = commenter.getUserName();
}
GalleryCommentReport galleryCommentReport = new GalleryCommentReport(reportData.galleryCommentKey.getId(),
reportData.userId,reportData.report,reportData.dateCreated);
galleryCommentReport.setUserName(name);
reports.add(galleryCommentReport);
}
return reports;
}