use of javax.jdo.PersistenceManager in project OpenRefine by OpenRefine.
the class AppEngineRefineBrokerImpl method expireLocks.
protected void expireLocks(HttpServletResponse response) throws Exception {
PersistenceManager pm = pmfInstance.getPersistenceManager();
try {
Extent<Lock> extent = pm.getExtent(Lock.class, false);
try {
for (Lock lock : extent) {
if (lock.timestamp + LOCK_DURATION < System.currentTimeMillis()) {
Transaction tx = pm.currentTransaction();
try {
tx.begin();
pm.deletePersistent(lock);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
}
}
}
} finally {
extent.closeAll();
}
respond(response, OK);
} finally {
pm.close();
}
}
use of javax.jdo.PersistenceManager in project OpenRefine by OpenRefine.
the class AppEngineRefineBrokerImpl method getHistory.
protected void getHistory(HttpServletResponse response, String pid, int tindex) throws Exception {
PersistenceManager pm = pmfInstance.getPersistenceManager();
try {
Project project = getProject(pm, pid);
Writer w = response.getWriter();
JSONWriter writer = new JSONWriter(w);
writer.object();
writer.key("transformations");
writer.array();
int size = project.transformations.size();
for (int i = tindex; i < size; i++) {
writer.value(project.transformations.get(i).toString());
}
writer.endArray();
writer.endObject();
w.flush();
w.close();
} finally {
pm.close();
}
}
use of javax.jdo.PersistenceManager in project OpenRefine by OpenRefine.
the class AppEngineRefineBrokerImpl method obtainLock.
protected void obtainLock(HttpServletResponse response, String pid, String uid, int locktype, String lockvalue) throws Exception {
PersistenceManager pm = pmfInstance.getPersistenceManager();
try {
Lock lock = getLock(pm, pid);
if (lock == null) {
Transaction tx = pm.currentTransaction();
try {
tx.begin();
lock = new Lock(Long.toHexString(tx.hashCode()), pid, uid);
pm.makePersistent(lock);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
}
}
respond(response, lockToJSON(lock));
} finally {
pm.close();
}
}
use of javax.jdo.PersistenceManager in project OpenRefine by OpenRefine.
the class AppEngineRefineBrokerImpl method startProject.
// ----------------------------------------------------------------------------------------------------
protected void startProject(HttpServletResponse response, String pid, String uid, String lid, String data) throws Exception {
PersistenceManager pm = pmfInstance.getPersistenceManager();
try {
checkLock(pm, pid, uid, lid);
Project project = getProject(pm, pid);
if (project != null) {
throw new RuntimeException("Project '" + pid + "' already exists");
}
Transaction tx = pm.currentTransaction();
try {
tx.begin();
project = new Project(pid, data);
pm.makePersistent(project);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
}
respond(response, OK);
} finally {
pm.close();
}
}
use of javax.jdo.PersistenceManager in project estatio by estatio.
the class IncomingInvoiceItemRepository method findDistinctReportDates.
@Programmatic
public List<LocalDate> findDistinctReportDates() {
final PersistenceManager pm = isisJdoSupport.getJdoPersistenceManager();
final Query query = pm.newQuery(IncomingInvoiceItem.class);
query.setResultClass(LocalDate.class);
query.setResult("distinct reportedDate");
query.setOrdering("reportedDate descending");
return executeListAndClose(query);
}
Aggregations