Search in sources :

Example 1 with MetaAction

use of com.axelor.meta.db.MetaAction in project axelor-open-suite by axelor.

the class CalendarConfigurationService method deleteEntryMenu.

@Transactional
public void deleteEntryMenu(CalendarConfiguration calendarConfiguration) {
    MetaAction metaAction = calendarConfiguration.getMetaAction();
    Role role = calendarConfiguration.getRole();
    Group group = calendarConfiguration.getCalendarGroup();
    calendarConfiguration.setMetaAction(null);
    calendarConfiguration.setRole(null);
    calendarConfiguration.getCalendarUser().removeRole(role);
    if (group != null) {
        group.removeRole(role);
    }
    String menuName = NAME + calendarConfiguration.getName().toLowerCase() + "-" + calendarConfiguration.getId();
    MetaMenuRepository metaMenuRepository = Beans.get(MetaMenuRepository.class);
    MetaMenu metaMenu = metaMenuRepository.findByName(menuName);
    metaMenuRepository.remove(metaMenu);
    MetaActionRepository metaActionRepository = Beans.get(MetaActionRepository.class);
    metaActionRepository.remove(metaAction);
    RoleRepository roleRepository = Beans.get(RoleRepository.class);
    roleRepository.remove(role);
}
Also used : Role(com.axelor.auth.db.Role) Group(com.axelor.auth.db.Group) MetaMenuRepository(com.axelor.meta.db.repo.MetaMenuRepository) MetaActionRepository(com.axelor.meta.db.repo.MetaActionRepository) MetaMenu(com.axelor.meta.db.MetaMenu) MetaAction(com.axelor.meta.db.MetaAction) RoleRepository(com.axelor.auth.db.repo.RoleRepository) Transactional(com.google.inject.persist.Transactional)

Example 2 with MetaAction

use of com.axelor.meta.db.MetaAction in project axelor-open-suite by axelor.

the class CalendarConfigurationService method createEntryMenu.

@Transactional
public void createEntryMenu(CalendarConfiguration calendarConfiguration) {
    String menuName = NAME + calendarConfiguration.getName().toLowerCase() + "-" + calendarConfiguration.getId();
    String subName = menuName.replaceAll("[-\\s]", ".");
    String title = calendarConfiguration.getName();
    User user = calendarConfiguration.getCalendarUser();
    Group group = calendarConfiguration.getCalendarGroup();
    MetaAction metaAction = this.createMetaAction("action." + subName, title);
    MetaMenu metaMenu = this.createMetaMenu(menuName, title, metaAction, calendarConfiguration.getParentMetaMenu());
    Beans.get(MetaMenuRepository.class).save(metaMenu);
    Role role = new Role();
    role.setName("role." + subName);
    role.addMenu(metaMenu);
    Beans.get(RoleRepository.class).save(role);
    user.addRole(role);
    Beans.get(UserRepository.class).save(user);
    if (group != null) {
        group.addRole(role);
        Beans.get(GroupRepository.class).save(group);
    }
    calendarConfiguration.setRole(role);
    calendarConfiguration.setMetaAction(metaAction);
    calendarConfigurationRepo.save(calendarConfiguration);
}
Also used : Role(com.axelor.auth.db.Role) Group(com.axelor.auth.db.Group) MetaMenuRepository(com.axelor.meta.db.repo.MetaMenuRepository) User(com.axelor.auth.db.User) UserRepository(com.axelor.auth.db.repo.UserRepository) MetaMenu(com.axelor.meta.db.MetaMenu) MetaAction(com.axelor.meta.db.MetaAction) GroupRepository(com.axelor.auth.db.repo.GroupRepository) RoleRepository(com.axelor.auth.db.repo.RoleRepository) Transactional(com.google.inject.persist.Transactional)

Example 3 with MetaAction

use of com.axelor.meta.db.MetaAction in project axelor-open-suite by axelor.

the class StudioMetaService method updateMetaAction.

@Transactional
public MetaAction updateMetaAction(String name, String actionType, String xml, String model, String xmlId) {
    MetaAction action = metaActionRepo.findByID(xmlId);
    if (action == null) {
        action = new MetaAction(name);
        action.setXmlId(xmlId);
        Integer priority = getPriority(MetaAction.class.getSimpleName(), name);
        action.setPriority(priority);
    }
    action.setType(actionType);
    action.setModel(model);
    action.setXml(xml);
    return metaActionRepo.save(action);
}
Also used : MetaAction(com.axelor.meta.db.MetaAction) Transactional(com.google.inject.persist.Transactional)

Example 4 with MetaAction

use of com.axelor.meta.db.MetaAction in project axelor-open-suite by axelor.

the class ActionBuilderService method build.

@Transactional
public MetaAction build(ActionBuilder builder) {
    if (builder == null) {
        return null;
    }
    log.debug("Processing action: {}, type: {}", builder.getName(), builder.getTypeSelect());
    if (Arrays.asList(ActionBuilderRepository.TYPE_SELECT_CREATE, ActionBuilderRepository.TYPE_SELECT_UPDATE).contains(builder.getTypeSelect()) && (builder.getLines() == null || builder.getLines().isEmpty())) {
        return null;
    }
    MetaAction metaAction = null;
    switch(builder.getTypeSelect()) {
        case ActionBuilderRepository.TYPE_SELECT_CREATE:
            metaAction = actionScriptBuilderService.build(builder);
            break;
        case ActionBuilderRepository.TYPE_SELECT_UPDATE:
            metaAction = actionScriptBuilderService.build(builder);
            break;
        case ActionBuilderRepository.TYPE_SELECT_SCRIPT:
            metaAction = actionScriptBuilderService.build(builder);
            break;
        case ActionBuilderRepository.TYPE_SELECT_VIEW:
            metaAction = actionViewBuilderService.build(builder);
            break;
        case ActionBuilderRepository.TYPE_SELECT_EMAIL:
            metaAction = actionEmailBuilderService.build(builder);
    }
    if (builder.getMetaModule() != null) {
        metaAction.setModule(builder.getMetaModule().getName());
    }
    MetaStore.clear();
    return metaAction;
}
Also used : MetaAction(com.axelor.meta.db.MetaAction) Transactional(com.google.inject.persist.Transactional)

Example 5 with MetaAction

use of com.axelor.meta.db.MetaAction in project axelor-open-suite by axelor.

the class DashboardBuilderService method build.

/**
 * Method to generate Dashboard (meta schema) from View Builder.
 *
 * @param viewBuilder ViewBuilder of type dashboard.
 * @return Dashboard.
 */
public MetaView build(DashboardBuilder dashboardBuilder) {
    log.debug("Processing dashboard: {}", dashboardBuilder.getName());
    log.debug("Dashlet list: {}", dashboardBuilder.getDashletBuilderList());
    if (dashboardBuilder.getDashletBuilderList() == null || dashboardBuilder.getDashletBuilderList().isEmpty()) {
        return null;
    }
    Dashboard dashboard = new Dashboard();
    String boardName = dashboardBuilder.getName();
    dashboard.setTitle(dashboardBuilder.getTitle());
    dashboard.setName(dashboardBuilder.getName());
    List<AbstractWidget> dashlets = new ArrayList<AbstractWidget>();
    dashboardBuilder.clearGeneratedActions();
    for (DashletBuilder dashletBuilder : dashboardBuilder.getDashletBuilderList()) {
        Dashlet dashlet = new Dashlet();
        String name = null;
        String model = null;
        MetaView metaView = dashletBuilder.getMetaView();
        MetaAction action = dashletBuilder.getAction();
        String actionName = null;
        if (metaView != null) {
            name = metaView.getName();
            model = metaView.getModel();
            MetaAction metaAction = getAction(boardName, name, model, dashletBuilder);
            actionName = metaAction.getName();
            dashboardBuilder.addGeneratedAction(metaAction);
        } else if (action != null) {
            model = action.getModel();
            actionName = action.getName();
        }
        dashlet.setAction(actionName);
        dashlet.setHeight("350");
        Integer colSpan = dashletBuilder.getColspan();
        if (colSpan > 12) {
            colSpan = 12;
        } else if (colSpan <= 0) {
            colSpan = 6;
        }
        dashlet.setColSpan(colSpan);
        dashlets.add(dashlet);
    }
    if (dashlets.isEmpty()) {
        return null;
    }
    dashboard.setItems(dashlets);
    MetaStore.clear();
    return metaService.generateMetaView(dashboard);
}
Also used : DashletBuilder(com.axelor.studio.db.DashletBuilder) ArrayList(java.util.ArrayList) Dashboard(com.axelor.meta.schema.views.Dashboard) AbstractWidget(com.axelor.meta.schema.views.AbstractWidget) Dashlet(com.axelor.meta.schema.views.Dashlet) MetaView(com.axelor.meta.db.MetaView) MetaAction(com.axelor.meta.db.MetaAction)

Aggregations

MetaAction (com.axelor.meta.db.MetaAction)11 Transactional (com.google.inject.persist.Transactional)6 MetaMenu (com.axelor.meta.db.MetaMenu)4 Group (com.axelor.auth.db.Group)2 Role (com.axelor.auth.db.Role)2 RoleRepository (com.axelor.auth.db.repo.RoleRepository)2 MetaMenuRepository (com.axelor.meta.db.repo.MetaMenuRepository)2 ObjectViews (com.axelor.meta.schema.ObjectViews)2 ActionView (com.axelor.meta.schema.actions.ActionView)2 ArrayList (java.util.ArrayList)2 WkfInstanceService (com.axelor.apps.bpm.service.execution.WkfInstanceService)1 User (com.axelor.auth.db.User)1 GroupRepository (com.axelor.auth.db.repo.GroupRepository)1 UserRepository (com.axelor.auth.db.repo.UserRepository)1 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)1 MetaView (com.axelor.meta.db.MetaView)1 MetaActionRepository (com.axelor.meta.db.repo.MetaActionRepository)1 Action (com.axelor.meta.schema.actions.Action)1 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)1 AbstractWidget (com.axelor.meta.schema.views.AbstractWidget)1