use of pro.taskana.common.api.exceptions.SystemException in project taskana by Taskana.
the class TaskHistoryEventRepresentationModelAssembler method toModel.
@NonNull
@Override
public TaskHistoryEventRepresentationModel toModel(@NonNull TaskHistoryEvent historyEvent) {
TaskHistoryEventRepresentationModel repModel = new TaskHistoryEventRepresentationModel();
repModel.setTaskHistoryId(historyEvent.getId());
repModel.setBusinessProcessId(historyEvent.getBusinessProcessId());
repModel.setParentBusinessProcessId(historyEvent.getParentBusinessProcessId());
repModel.setTaskId(historyEvent.getTaskId());
repModel.setEventType(historyEvent.getEventType());
repModel.setCreated(historyEvent.getCreated());
repModel.setUserId(historyEvent.getUserId());
repModel.setUserLongName(historyEvent.getUserLongName());
repModel.setDomain(historyEvent.getDomain());
repModel.setWorkbasketKey(historyEvent.getWorkbasketKey());
repModel.setPorCompany(historyEvent.getPorCompany());
repModel.setPorType(historyEvent.getPorType());
repModel.setPorInstance(historyEvent.getPorInstance());
repModel.setPorSystem(historyEvent.getPorSystem());
repModel.setPorValue(historyEvent.getPorValue());
repModel.setTaskOwnerLongName(historyEvent.getTaskOwnerLongName());
repModel.setTaskClassificationKey(historyEvent.getTaskClassificationKey());
repModel.setTaskClassificationCategory(historyEvent.getTaskClassificationCategory());
repModel.setAttachmentClassificationKey(historyEvent.getAttachmentClassificationKey());
repModel.setOldValue(historyEvent.getOldValue());
repModel.setNewValue(historyEvent.getNewValue());
repModel.setCustom1(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_1));
repModel.setCustom2(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_2));
repModel.setCustom3(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_3));
repModel.setCustom4(historyEvent.getCustomAttribute(TaskHistoryCustomField.CUSTOM_4));
repModel.setDetails(historyEvent.getDetails());
try {
repModel.add(linkTo(methodOn(TaskHistoryEventController.class).getTaskHistoryEvent(historyEvent.getId())).withSelfRel());
} catch (Exception e) {
throw new SystemException("caught unexpected Exception", e);
}
return repModel;
}
use of pro.taskana.common.api.exceptions.SystemException in project taskana by Taskana.
the class ClassificationQueryImpl method list.
@Override
public List<ClassificationSummary> list(int offset, int limit) {
List<ClassificationSummary> result = new ArrayList<>();
try {
taskanaEngine.openConnection();
RowBounds rowBounds = new RowBounds(offset, limit);
result = taskanaEngine.getSqlSession().selectList(LINK_TO_SUMMARYMAPPER, this, rowBounds);
return result;
} catch (PersistenceException e) {
if (e.getMessage().contains("ERRORCODE=-4470")) {
TaskanaRuntimeException ex = new SystemException("The offset beginning was set over the amount of result-rows.", e.getCause());
ex.setStackTrace(e.getStackTrace());
throw ex;
}
throw e;
} finally {
taskanaEngine.returnConnection();
}
}
use of pro.taskana.common.api.exceptions.SystemException in project taskana by Taskana.
the class WorkbasketRepresentationModelAssembler method toModel.
@NonNull
@Override
public WorkbasketRepresentationModel toModel(@NonNull Workbasket workbasket) {
WorkbasketRepresentationModel repModel = new WorkbasketRepresentationModel();
repModel.setWorkbasketId(workbasket.getId());
repModel.setKey(workbasket.getKey());
repModel.setName(workbasket.getName());
repModel.setDomain(workbasket.getDomain());
repModel.setType(workbasket.getType());
repModel.setDescription(workbasket.getDescription());
repModel.setOwner(workbasket.getOwner());
repModel.setMarkedForDeletion(workbasket.isMarkedForDeletion());
repModel.setCustom1(workbasket.getCustomField(WorkbasketCustomField.CUSTOM_1));
repModel.setCustom2(workbasket.getCustomField(WorkbasketCustomField.CUSTOM_2));
repModel.setCustom3(workbasket.getCustomField(WorkbasketCustomField.CUSTOM_3));
repModel.setCustom4(workbasket.getCustomField(WorkbasketCustomField.CUSTOM_4));
repModel.setOrgLevel1(workbasket.getOrgLevel1());
repModel.setOrgLevel2(workbasket.getOrgLevel2());
repModel.setOrgLevel3(workbasket.getOrgLevel3());
repModel.setOrgLevel4(workbasket.getOrgLevel4());
repModel.setCreated(workbasket.getCreated());
repModel.setModified(workbasket.getModified());
try {
return addLinks(repModel, workbasket);
} catch (Exception e) {
throw new SystemException("caught unexpected Exception.", e.getCause());
}
}
use of pro.taskana.common.api.exceptions.SystemException in project taskana by Taskana.
the class JobRunnerAccTest method should_onlyExecuteJobOnce_When_MultipleThreadsTryToRunJobsAtTheSameTime.
@Test
void should_onlyExecuteJobOnce_When_MultipleThreadsTryToRunJobsAtTheSameTime() throws Exception {
// for some reason clearing the job table is not enough..
resetDb(true);
assertThat(jobService.findJobsToRun()).isEmpty();
ScheduledJob job = createJob(Instant.now().minus(5, ChronoUnit.MINUTES));
assertThat(jobService.findJobsToRun()).containsExactly(job);
ParallelThreadHelper.runInThread(() -> {
try {
TaskanaEngine taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
DataSource dataSource = DataSourceGenerator.getDataSource();
// We have to slow down the transaction.
// This is necessary to guarantee the execution of
// both test threads and therefore test the database lock.
// Without the slow down the test threads would execute too fast and
// would not request executable jobs from the database at the same time.
// TODO: please fix this. With the slowdown the test suite fails often
// dataSource = slowDownDatabaseTransaction(dataSource);
PlainJavaTransactionProvider transactionProvider = new PlainJavaTransactionProvider(taskanaEngine, dataSource);
JobRunner runner = new JobRunner(taskanaEngine);
runner.registerTransactionProvider(transactionProvider);
runner.runJobs();
} catch (Exception e) {
throw new SystemException("Caught Exception", e);
}
}, 2);
// runEvery is set to P1D Therefore we need to check which jobs run tomorrow.
// Just to be sure the jobs are found we will look for any job scheduled in the next 2 days.
List<ScheduledJob> jobsToRun = getJobMapper().findJobsToRun(Instant.now().plus(2, ChronoUnit.DAYS));
assertThat(jobsToRun).hasSize(1).doesNotContain(job);
}
use of pro.taskana.common.api.exceptions.SystemException in project taskana by Taskana.
the class WorkbasketCleanupJob method execute.
@Override
public void execute() throws TaskanaException {
LOGGER.info("Running job to delete all workbaskets marked for deletion");
try {
List<String> workbasketsMarkedForDeletion = getWorkbasketsMarkedForDeletion();
int totalNumberOfWorkbasketDeleted = CollectionUtil.partitionBasedOnSize(workbasketsMarkedForDeletion, batchSize).stream().mapToInt(this::deleteWorkbasketsTransactionally).sum();
LOGGER.info("Job ended successfully. {} workbaskets deleted.", totalNumberOfWorkbasketDeleted);
} catch (Exception e) {
throw new SystemException("Error while processing WorkbasketCleanupJob.", e);
}
}
Aggregations