use of com.axelor.apps.bpm.db.WkfProcess 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);
}
}
Aggregations