Search in sources :

Example 11 with WkfModel

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());
}
Also used : WkfModel(com.axelor.apps.bpm.db.WkfModel) ArrayList(java.util.ArrayList)

Example 12 with WkfModel

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);
    }
}
Also used : WkfProcess(com.axelor.apps.bpm.db.WkfProcess) WkfProcessConfig(com.axelor.apps.bpm.db.WkfProcessConfig) WkfModel(com.axelor.apps.bpm.db.WkfModel) ArrayList(java.util.ArrayList) AxelorException(com.axelor.exception.AxelorException)

Example 13 with WkfModel

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);
}
Also used : WkfModel(com.axelor.apps.bpm.db.WkfModel)

Example 14 with WkfModel

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);
}
Also used : WkfModel(com.axelor.apps.bpm.db.WkfModel)

Example 15 with WkfModel

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);
    }
}
Also used : User(com.axelor.auth.db.User) WkfModel(com.axelor.apps.bpm.db.WkfModel) AxelorException(com.axelor.exception.AxelorException)

Aggregations

WkfModel (com.axelor.apps.bpm.db.WkfModel)17 ArrayList (java.util.ArrayList)7 WkfProcess (com.axelor.apps.bpm.db.WkfProcess)4 User (com.axelor.auth.db.User)3 AxelorException (com.axelor.exception.AxelorException)3 Map (java.util.Map)3 WkfProcessConfig (com.axelor.apps.bpm.db.WkfProcessConfig)2 Transactional (com.google.inject.persist.Transactional)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Wizard (com.axelor.apps.base.db.Wizard)1 WkfInstance (com.axelor.apps.bpm.db.WkfInstance)1 WkfTaskConfig (com.axelor.apps.bpm.db.WkfTaskConfig)1 WkfInstanceRepository (com.axelor.apps.bpm.db.repo.WkfInstanceRepository)1 WkfModelRepository (com.axelor.apps.bpm.db.repo.WkfModelRepository)1 WkfTaskConfigRepository (com.axelor.apps.bpm.db.repo.WkfTaskConfigRepository)1 WkfModelService (com.axelor.apps.bpm.service.WkfModelService)1 BpmDeploymentService (com.axelor.apps.bpm.service.deployment.BpmDeploymentService)1 WkfInstanceService (com.axelor.apps.bpm.service.execution.WkfInstanceService)1 ProcessEngineService (com.axelor.apps.bpm.service.init.ProcessEngineService)1