Search in sources :

Example 1 with ActionType

use of com.rebuild.core.service.trigger.ActionType in project rebuild by getrebuild.

the class MetaschemaImporter method performTrigger.

private void performTrigger(String entity, JSONObject config) {
    Entity configEntity = MetadataHelper.getEntity(EntityHelper.RobotTriggerConfig);
    config.put("metadata", JSONUtils.toJSONObject("entity", configEntity.getName()));
    config.put("belongEntity", entity);
    String actionType = config.getString("actionType");
    boolean available = false;
    for (ActionType type : ActionFactory.getAvailableActions()) {
        if (type.name().equalsIgnoreCase(actionType)) {
            available = true;
            break;
        }
    }
    if (!available) {
        log.warn("Trigger `{}` unavailable", actionType);
        return;
    }
    Record record = new EntityRecordCreator(configEntity, config, getUser()).create();
    Application.getBean(RobotTriggerConfigService.class).create(record);
}
Also used : Entity(cn.devezhao.persist4j.Entity) ActionType(com.rebuild.core.service.trigger.ActionType) Record(cn.devezhao.persist4j.Record) EntityRecordCreator(com.rebuild.core.metadata.EntityRecordCreator) RobotTriggerConfigService(com.rebuild.core.service.trigger.RobotTriggerConfigService)

Example 2 with ActionType

use of com.rebuild.core.service.trigger.ActionType in project rebuild by getrebuild.

the class I18nGettextParser method sysDefined.

// 系统定义的
static void sysDefined(JSONObject into) {
    into.put("_", "中文");
    for (DisplayType o : DisplayType.values()) into.put(o.getDisplayName(), o.getDisplayName());
    for (ActionType o : ActionType.values()) into.put(o.getDisplayName(), o.getDisplayName());
    for (ApprovalState s : ApprovalState.values()) into.put(s.getName(), s.getName());
    for (Entity entity : Application.getPersistManagerFactory().getMetadataFactory().getEntities()) {
        if (!EasyMetaFactory.valueOf(entity).isBuiltin())
            continue;
        sysDefinedMeta(entity, into);
        for (Field field : entity.getFields()) {
            if (!EasyMetaFactory.valueOf(field).isBuiltin())
                continue;
            sysDefinedMeta(field, into);
        }
    }
    into.put("__", "__");
}
Also used : Entity(cn.devezhao.persist4j.Entity) Field(cn.devezhao.persist4j.Field) ActionType(com.rebuild.core.service.trigger.ActionType) DisplayType(com.rebuild.core.metadata.easymeta.DisplayType) ApprovalState(com.rebuild.core.service.approval.ApprovalState)

Example 3 with ActionType

use of com.rebuild.core.service.trigger.ActionType in project rebuild by getrebuild.

the class TriggerAdminController method pageEditor.

@GetMapping("trigger/{id}")
public ModelAndView pageEditor(@PathVariable String id, HttpServletResponse response) throws IOException {
    ID configId = ID.valueOf(id);
    Object[] config = Application.createQuery("select belongEntity,actionType,when,whenFilter,actionContent,priority,name,whenTimer from RobotTriggerConfig where configId = ?").setParameter(1, configId).unique();
    if (config == null) {
        response.sendError(404);
        return null;
    }
    Entity sourceEntity = MetadataHelper.getEntity((String) config[0]);
    ActionType actionType = ActionType.valueOf((String) config[1]);
    ModelAndView mv = createModelAndView("/admin/robot/trigger-design");
    mv.getModel().put("configId", configId);
    mv.getModel().put("sourceEntity", sourceEntity.getName());
    mv.getModel().put("sourceEntityLabel", EasyMetaFactory.getLabel(sourceEntity));
    mv.getModel().put("actionType", actionType.name());
    mv.getModel().put("actionTypeLabel", Language.L(actionType));
    mv.getModel().put("when", config[2]);
    mv.getModel().put("whenTimer", config[7] == null ? StringUtils.EMPTY : config[7]);
    mv.getModel().put("whenFilter", config[3]);
    mv.getModel().put("actionContent", config[4]);
    mv.getModel().put("priority", config[5]);
    mv.getModel().put("name", config[6]);
    mv.getModel().put("lockedUser", JSON.toJSONString(CommonsLock.getLockedUserFormat(configId)));
    return mv;
}
Also used : Entity(cn.devezhao.persist4j.Entity) ActionType(com.rebuild.core.service.trigger.ActionType) ModelAndView(org.springframework.web.servlet.ModelAndView) ID(cn.devezhao.persist4j.engine.ID) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

Entity (cn.devezhao.persist4j.Entity)3 ActionType (com.rebuild.core.service.trigger.ActionType)3 Field (cn.devezhao.persist4j.Field)1 Record (cn.devezhao.persist4j.Record)1 ID (cn.devezhao.persist4j.engine.ID)1 EntityRecordCreator (com.rebuild.core.metadata.EntityRecordCreator)1 DisplayType (com.rebuild.core.metadata.easymeta.DisplayType)1 ApprovalState (com.rebuild.core.service.approval.ApprovalState)1 RobotTriggerConfigService (com.rebuild.core.service.trigger.RobotTriggerConfigService)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1