use of com.googlecode.objectify.Work in project blogwt by billy1380.
the class ArchiveEntryService method updateArchiveEntryPost.
@Override
public ArchiveEntry updateArchiveEntryPost(final ArchiveEntry archiveEntry, final Post post) {
ArchiveEntry updated = null;
if (Boolean.TRUE.equals(post.listed) && post.published != null) {
updated = provide().transact(new Work<ArchiveEntry>() {
@Override
public ArchiveEntry run() {
ArchiveEntry latest = getArchiveEntry(archiveEntry.id);
if (latest.postKeys == null) {
latest.postKeys = new ArrayList<Key<Post>>();
}
boolean found = false;
for (Key<Post> key : latest.postKeys) {
if (DataTypeHelper.<Post>same(key, post)) {
found = true;
break;
}
}
if (!found) {
latest.postKeys.add(Key.create(post));
}
provide().save().entity(latest).now();
return latest;
}
});
}
return updated;
}
Aggregations