Java Code Examples for se.emilsjolander.sprinkles.Transaction#finish()
The following examples show how to use
se.emilsjolander.sprinkles.Transaction#finish() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UploadService.java From flickr-uploader with GNU General Public License v2.0 | 6 votes |
public static void enqueueRetry(Iterable<Media> medias) { int nbQueued = 0; Transaction t = new Transaction(); try { for (Media media : medias) { if (!media.isQueued() && media.getTimestampRetry() < Long.MAX_VALUE) { nbQueued++; media.setStatus(STATUS.QUEUED, t); } } t.setSuccessful(true); } finally { t.finish(); } if (nbQueued > 0) { checkQueue(); } wake(nbQueued > 0); }
Example 2
Source File: UploadService.java From flickr-uploader with GNU General Public License v2.0 | 6 votes |
public static void dequeue(Collection<Media> medias) { int nbDequeued = 0; Transaction t = new Transaction(); try { for (final Media media : medias) { if (media.isQueued()) { LOG.debug("dequeueing " + media); media.setStatus(STATUS.PAUSED, t); nbDequeued++; if (media.equals(mediaCurrentlyUploading)) { REST.kill(media); } } } t.setSuccessful(true); } finally { t.finish(); } if (nbDequeued > 0) { checkQueue(); for (UploadProgressListener uploadProgressListener : uploadProgressListeners) { uploadProgressListener.onDequeued(nbDequeued); } } wake(); }
Example 3
Source File: SprinklesTest.java From Storm with Apache License 2.0 | 5 votes |
@Override protected void insert(List<SprinklesObject> list) { final Transaction transaction = new Transaction(); for (SprinklesObject object: list) { object.save(transaction); } transaction.setSuccessful(true); transaction.finish(); }
Example 4
Source File: SprinklesTest.java From Storm with Apache License 2.0 | 5 votes |
@Override protected void deleteAll() { // no exceptions are thrown, catch it yourself // throws IndexOutOfBoundsException if passed db version is not starts with 0 // java.lang.IllegalStateException: Couldn't read row 5470, col 5 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. final Transaction dt = new Transaction(); for (SprinklesObject sprinklesObject : Query.all(SprinklesObject.class).get()) { sprinklesObject.delete(dt); } dt.setSuccessful(true); dt.finish(); }
Example 5
Source File: UploadService.java From flickr-uploader with GNU General Public License v2.0 | 5 votes |
public static int enqueue(boolean auto, Collection<Media> medias, String photoSetTitle) { int nbQueued = 0; int nbAlreadyQueued = 0; int nbAlreadyUploaded = 0; Transaction t = new Transaction(); try { for (Media media : medias) { if (media.isQueued()) { nbAlreadyQueued++; } else if (media.isUploaded()) { nbAlreadyUploaded++; } else if (auto && media.getRetries() > 3) { LOG.debug("not auto enqueueing file with too many retries : " + media); } else { nbQueued++; LOG.debug("enqueueing " + media); media.setFlickrSetTitle(photoSetTitle); media.setStatus(STATUS.QUEUED, t); } } t.setSuccessful(true); } finally { t.finish(); } if (nbQueued > 0) { checkQueue(); } for (UploadProgressListener uploadProgressListener : uploadProgressListeners) { uploadProgressListener.onQueued(nbQueued, nbAlreadyUploaded, nbAlreadyQueued); } wake(nbQueued > 0); return nbQueued; }