use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectTaskService method create.
@Override
public Record create(Record record) {
final ID user = UserContextHolder.getUser();
checkModifications(user, record.getID("projectId"));
ID projectId = record.getID("projectId");
ID projectPlanId = record.getID("projectPlanId");
ConfigBean p = ProjectManager.instance.getPlanOfProject(projectPlanId, projectId);
if (p.getInteger("flowStatus") == ProjectPlanConfigService.FLOW_STATUS_PROCESSING) {
throw new DataSpecificationException(Language.L("该任务面板不可新建任务"));
}
record.setLong("taskNumber", getNextTaskNumber(projectId));
applyFlowStatus(record);
record.setInt("seq", getNextSeqViaMidValue(projectPlanId));
record = super.create(record);
if (record.hasValue("executor", false)) {
sendNotification(record.getPrimary());
}
return record;
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectTaskService method applyFlowStatus.
/**
* 自动完成
*
* @param newOrUpdate
*/
private int applyFlowStatus(Record newOrUpdate) {
if (newOrUpdate.hasValue("projectPlanId")) {
ConfigBean c = ProjectManager.instance.getPlanOfProject(newOrUpdate.getID("projectPlanId"), newOrUpdate.getID("projectId"));
int fs = c.getInteger("flowStatus");
if (fs == ProjectPlanConfigService.FLOW_STATUS_END) {
newOrUpdate.setInt("status", 1);
} else if (fs == ProjectPlanConfigService.FLOW_STATUS_PROCESSING) {
newOrUpdate.setDate("startTime", CalendarUtils.now());
}
return fs;
}
return -1;
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class BaseTaskService method checkModifications.
/**
* 是否成员;是否已归档
*
* @param user
* @param taskOrProject
* @return
*/
protected boolean checkModifications(ID user, ID taskOrProject) {
if (user == null)
user = UserContextHolder.getUser();
Assert.notNull(taskOrProject, "taskOrProject");
ConfigBean c = taskOrProject.getEntityCode() == EntityHelper.ProjectTask ? ProjectManager.instance.getProjectByX(taskOrProject, null) : ProjectManager.instance.getProject(taskOrProject, null);
if (c == null || !c.get("members", Set.class).contains(user)) {
throw new DataSpecificationException(Language.L("非项目成员禁止操作"));
}
if (c.getInteger("status") == ProjectManager.STATUS_ARCHIVED) {
throw new DataSpecificationException(Language.L("已归档项目禁止操作"));
}
return true;
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class RobotTriggerManager method filterActions.
/**
* @param record
* @param entity
* @param when
* @return
*/
private TriggerAction[] filterActions(Entity entity, ID record, TriggerWhen... when) {
List<TriggerAction> actions = new ArrayList<>();
for (ConfigBean cb : getConfig(entity)) {
if (allowedWhen(cb, when)) {
if (record == null || QueryHelper.isMatchAdvFilter(record, (JSONObject) cb.getJSON("whenFilter"))) {
ActionContext ctx = new ActionContext(record, entity, cb.getJSON("actionContent"), cb.getID("id"));
TriggerAction o = ActionFactory.createAction(cb.getString("actionType"), ctx);
actions.add(o);
if (log.isDebugEnabled()) {
TRIGGERS_CHAIN_4DEBUG.get().add(String.format("%s (%s) on %s %s (%s)", o.getType(), ctx.getConfigId(), when[0], entity.getName(), record));
}
}
}
}
if (!TRIGGERS_CHAIN_4DEBUG.get().isEmpty()) {
log.info("Record ({}) triggers chain : \n > {}", record, StringUtils.join(TRIGGERS_CHAIN_4DEBUG.get(), "\n > "));
}
return actions.toArray(new TriggerAction[0]);
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class RobotTriggerManager method getConfig.
/**
* @param entity
* @return
*/
@SuppressWarnings("unchecked")
protected List<ConfigBean> getConfig(Entity entity) {
final String cKey = "RobotTriggerManager-" + entity.getName();
Object cached = Application.getCommonsCache().getx(cKey);
if (cached != null) {
return (List<ConfigBean>) cached;
}
Object[][] array = Application.createQueryNoFilter("select when,whenFilter,actionType,actionContent,configId from RobotTriggerConfig" + " where belongEntity = ? and when > 0 and isDisabled = 'F' order by priority desc").setParameter(1, entity.getName()).array();
ArrayList<ConfigBean> entries = new ArrayList<>();
for (Object[] o : array) {
ConfigBean entry = new ConfigBean().set("when", o[0]).set("whenFilter", JSON.parseObject((String) o[1])).set("actionType", o[2]).set("actionContent", JSON.parseObject((String) o[3])).set("id", o[4]);
entries.add(entry);
}
Application.getCommonsCache().putx(cKey, entries);
return entries;
}
Aggregations