use of com.axelor.apps.bpm.db.WkfModel in project axelor-open-suite by axelor.
the class WkfModelController method showVersions.
public void showVersions(ActionRequest request, ActionResponse response) {
WkfModel wkfModel = request.getContext().asType(WkfModel.class);
List<Long> versionIds = new ArrayList<Long>();
if (wkfModel.getId() != null) {
wkfModel = wkfModelRepository.find(wkfModel.getId());
versionIds = wkfModelService.findVersions(wkfModel);
}
versionIds.add(0l);
response.setView(ActionView.define(I18n.get("Previous Versions")).model(WkfModel.class.getName()).add("grid", "wkf-model-grid").add("form", "wkf-model-form").domain("self.id in :versionIds").context("versionIds", versionIds).map());
}
use of com.axelor.apps.bpm.db.WkfModel in project axelor-open-suite by axelor.
the class WkfModelController method setModelsDomain.
public void setModelsDomain(ActionRequest request, ActionResponse response) {
try {
WkfModel wkfModel = null;
List<Long> jsonModelIds = new ArrayList<>();
List<Long> metaModelIds = new ArrayList<>();
if (request.getContext().get("wkfId") != null) {
wkfModel = wkfModelRepository.find(Long.parseLong(request.getContext().get("wkfId").toString()));
}
String process = (String) request.getContext().get("_process");
if (wkfModel != null) {
for (WkfProcess wkfProcess : wkfModel.getWkfProcessList()) {
if (CollectionUtils.isEmpty(wkfProcess.getWkfProcessConfigList()) || !wkfProcess.getName().equals(process)) {
continue;
}
for (WkfProcessConfig processConfig : wkfProcess.getWkfProcessConfigList()) {
if (processConfig.getMetaModel() != null) {
metaModelIds.add(processConfig.getMetaModel().getId());
}
if (processConfig.getMetaJsonModel() != null) {
jsonModelIds.add(processConfig.getMetaJsonModel().getId());
}
}
}
}
response.setAttr("metaJsonModel", "domain", !jsonModelIds.isEmpty() ? "self.id IN (" + StringUtils.join(jsonModelIds, ',') + ")" : "self.id IN (0)");
response.setAttr("metaModel", "domain", !metaModelIds.isEmpty() ? "self.id IN (" + StringUtils.join(metaModelIds, ',') + ")" : "self.id IN (0)");
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.bpm.db.WkfModel in project axelor-open-suite by axelor.
the class WkfModelController method backToDraft.
public void backToDraft(ActionRequest request, ActionResponse response) {
WkfModel wkfModel = request.getContext().asType(WkfModel.class);
wkfModel = wkfModelRepository.find(wkfModel.getId());
wkfModelService.backToDraft(wkfModel);
response.setReload(true);
}
use of com.axelor.apps.bpm.db.WkfModel in project axelor-open-suite by axelor.
the class WkfModelController method start.
public void start(ActionRequest request, ActionResponse response) {
WkfModel wkfModel = request.getContext().asType(WkfModel.class);
wkfModel = wkfModelRepository.find(wkfModel.getId());
wkfModelService.start(wkfModel);
response.setReload(true);
}
use of com.axelor.apps.bpm.db.WkfModel in project axelor-open-suite by axelor.
the class WkfModelController method changeAttrs.
public void changeAttrs(ActionRequest request, ActionResponse response) {
try {
WkfModel wkfModel = request.getContext().asType(WkfModel.class);
wkfModel = wkfModelRepository.find(wkfModel.getId());
User user = AuthUtils.getUser();
boolean superUser = user.getCode().equals("admin");
if (superUser) {
return;
}
if (isAdmin(wkfModel, user)) {
return;
}
response.setAttr("actionPanelBtn", "hidden", true);
response.setAttr("adminPanel", "hidden", true);
response.setAttr("managerPanel", "hidden", true);
if (isManager(wkfModel, user)) {
return;
}
response.setAttr("allProcessPanel", "hidden", true);
if (isUser(wkfModel, user)) {
return;
}
response.setAttr("userPanel", "hidden", true);
response.setAttr("myProcessPanel", "hidden", true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations