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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations