use of com.axelor.apps.bpm.db.repo.WkfInstanceRepository in project axelor-open-suite by axelor.
the class WkfRequestListener method processDeleted.
@Transactional
public void processDeleted(BeforeTransactionComplete event, String tenantId) {
Set<? extends Model> deleted = new HashSet<Model>(event.getDeleted());
WkfInstanceRepository wkfInstanceRepository = Beans.get(WkfInstanceRepository.class);
for (Model model : deleted) {
String modelName = EntityHelper.getEntityClass(model).getName();
if (WkfCache.WKF_MODEL_CACHE.get(tenantId).containsValue(modelName)) {
try {
log.trace("Remove wkf instance of deleted model: {}, id: {}", modelName, model.getId());
WkfInstance wkfInstance = wkfInstanceRepository.findByInstnaceId(model.getProcessInstanceId());
if (wkfInstance != null && wkfInstance.getWkfProcess().getWkfProcessConfigList().size() == 1) {
wkfInstanceRepository.remove(wkfInstance);
}
} catch (Exception e) {
}
}
}
}
use of com.axelor.apps.bpm.db.repo.WkfInstanceRepository in project axelor-open-suite by axelor.
the class WkfExecutionListener method createWkfInstance.
private void createWkfInstance(DelegateExecution execution) {
String instanceId = execution.getProcessInstanceId();
WkfInstanceRepository instanceRepo = Beans.get(WkfInstanceRepository.class);
WkfInstance wkfInstance = instanceRepo.findByInstnaceId(instanceId);
log.debug("Process called with related wkfInstance: {}", wkfInstance);
if (wkfInstance == null) {
execution.setVariable(getProcessKey(execution, execution.getProcessDefinitionId()), execution.getProcessInstanceId());
createWkfInstance(execution, instanceId, instanceRepo);
}
}
Aggregations