use of com.fathomdb.jdbc.JdbcTransaction in project platformlayer by platformlayer.
the class JdbcJobRepository method recordJobEnd.
@Override
@JdbcTransaction
public void recordJobEnd(PlatformLayerKey jobKey, String executionId, Date endedAt, JobState state, String logCookie) throws RepositoryException {
DbHelper db = new DbHelper();
try {
ProjectId project = jobKey.getProject();
String jobId = jobKey.getItemIdString();
int projectId = db.mapToValue(project);
int updateCount = db.queries.updateExecution(logCookie, endedAt, state, projectId, jobId, executionId);
if (updateCount != 1) {
throw new RepositoryException("Unexpected number of rows updated");
}
updateCount = db.queries.updateJob(endedAt, state, executionId, projectId, jobId);
if (updateCount != 1) {
throw new RepositoryException("Unexpected number of rows updated");
}
} catch (SQLException e) {
throw new RepositoryException("Error updating job execution", e);
} finally {
db.close();
}
}
use of com.fathomdb.jdbc.JdbcTransaction in project platformlayer by platformlayer.
the class JdbcJobRepository method findJob.
@Override
@JdbcTransaction
public JobData findJob(PlatformLayerKey jobKey) throws RepositoryException {
DbHelper db = new DbHelper();
try {
ProjectId projectId = jobKey.getProject();
String jobId = jobKey.getItemIdString();
JobEntity execution = db.queries.findJob(db.mapToValue(projectId), jobId);
if (execution == null) {
return null;
}
return mapFromEntity(execution, jobKey);
} catch (SQLException e) {
throw new RepositoryException("Error listing job executions", e);
} finally {
db.close();
}
}
use of com.fathomdb.jdbc.JdbcTransaction in project platformlayer by platformlayer.
the class JdbcJobRepository method insertJob.
@Override
@JdbcTransaction
public String insertJob(ProjectId projectId, JobData jobData) throws RepositoryException {
DbHelper db = new DbHelper();
try {
String jobId = UUID.randomUUID().toString();
JobEntity entity = new JobEntity();
entity.project = db.mapToValue(projectId);
entity.jobId = jobId;
entity.actionXml = toXml(jobData.action);
entity.target = jobData.targetId.getUrl();
int updateCount = db.queries.insert(entity);
if (updateCount != 1) {
throw new RepositoryException("Unexpected number of rows inserted");
}
return jobId;
} catch (SQLException e) {
throw new RepositoryException("Error inserting job execution", e);
} finally {
db.close();
}
}
use of com.fathomdb.jdbc.JdbcTransaction in project platformlayer by platformlayer.
the class JdbcUserRepository method listProjectsByUserId.
@Override
@JdbcTransaction
public List<ProjectEntity> listProjectsByUserId(int userId) throws RepositoryException {
DbHelper db = new DbHelper();
try {
List<ProjectEntity> projects = Lists.newArrayList();
projects.addAll(db.findProjectsByUserId(userId));
return projects;
} catch (SQLException e) {
throw new RepositoryException("Error reading groups", e);
} finally {
db.close();
}
}
use of com.fathomdb.jdbc.JdbcTransaction in project platformlayer by platformlayer.
the class JdbcUserRepository method listAllProjectNames.
@Override
@JdbcTransaction
public List<String> listAllProjectNames(String prefix) throws RepositoryException {
String match;
if (prefix == null) {
match = "%";
} else {
match = prefix + "%";
}
DbHelper db = new DbHelper();
try {
return db.listProjects(match);
} catch (SQLException e) {
throw new RepositoryException("Error listing projects", e);
} finally {
db.close();
}
}
Aggregations