Search in sources :

Example 11 with App

use of com.axelor.apps.base.db.App in project axelor-open-suite by axelor.

the class AppServiceImpl method importRoles.

@Override
public void importRoles() throws AxelorException, IOException {
    List<App> apps = appRepo.all().filter("self.isRolesImported = false").fetch();
    apps = sortApps(apps);
    for (App app : apps) {
        importRoles(app);
    }
}
Also used : App(com.axelor.apps.base.db.App)

Example 12 with App

use of com.axelor.apps.base.db.App in project axelor-open-suite by axelor.

the class AccessConfigImportServiceImpl method importObjectAccess.

private void importObjectAccess(XSSFSheet sheet) {
    App app = Beans.get(AppRepository.class).findByCode(sheet.getSheetName());
    if (app == null) {
        return;
    }
    Iterator<Row> rowIter = sheet.iterator();
    Map<Integer, AccessConfig> accessMap = null;
    while (rowIter.hasNext()) {
        if (accessMap == null) {
            accessMap = getAccessConfig(rowIter.next(), app);
            continue;
        }
        createObjectRoles(accessMap, rowIter.next());
    }
}
Also used : App(com.axelor.apps.base.db.App) AppRepository(com.axelor.apps.base.db.repo.AppRepository) Row(org.apache.poi.ss.usermodel.Row) AccessConfig(com.axelor.apps.base.db.AccessConfig)

Example 13 with App

use of com.axelor.apps.base.db.App in project axelor-open-suite by axelor.

the class AccessTemplateServiceImpl method getApp.

private String getApp(MetaMenu menu) {
    String appCode = null;
    String condition = menu.getConditionToCheck();
    if (condition != null) {
        String[] cond = condition.split("__config__\\.app\\.isApp\\('");
        if (cond.length > 1) {
            App app = Beans.get(AppRepository.class).findByCode(cond[1].split("'")[0]);
            if (app != null) {
                if (condition.trim().equals("__config__.app.isApp('" + app.getCode() + "')") && menu.getAction() == null) {
                    appMenus.add(menu.getName());
                }
                appCode = app.getCode();
            }
        }
    }
    MetaMenu parent = menu.getParent();
    if (appCode == null && parent != null && menuApp.containsKey(parent.getName())) {
        appCode = menuApp.get(parent.getName());
    }
    if (parent == null && appCode == null) {
        configMenus.add(menu.getName());
    }
    if (menu.getTitle().equals("Configuration") || menu.getTitle().equals("Configurations")) {
        configMenus.add(menu.getName());
        appMenus.remove(menu.getName());
    }
    if (appCode == null) {
        return defaultApp;
    }
    return appCode;
}
Also used : App(com.axelor.apps.base.db.App) AppRepository(com.axelor.apps.base.db.repo.AppRepository) MetaMenu(com.axelor.meta.db.MetaMenu)

Example 14 with App

use of com.axelor.apps.base.db.App in project axelor-open-suite by axelor.

the class AccessTemplateServiceImpl method generateTemplate.

@Override
public MetaFile generateTemplate() throws AxelorException {
    try {
        menuApp = new HashMap<>();
        objMenu = new HashMap<>();
        configMenus = new ArrayList<>();
        appMenus = new ArrayList<>();
        defaultApp = null;
        App app = Beans.get(AppRepository.class).findByCode("base");
        if (app == null) {
            return null;
        }
        defaultApp = app.getCode();
        getMenusPerApp();
        updateNoMenuObjects();
        return createExcel();
    } catch (Exception e) {
        TraceBackService.trace(e);
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, e.getMessage());
    }
}
Also used : App(com.axelor.apps.base.db.App) AxelorException(com.axelor.exception.AxelorException) AppRepository(com.axelor.apps.base.db.repo.AppRepository) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 15 with App

use of com.axelor.apps.base.db.App in project axelor-open-suite by axelor.

the class AppController method bulkInstall.

public void bulkInstall(ActionRequest request, ActionResponse response) throws AxelorException, IOException {
    Context context = request.getContext();
    Set<Map<String, Object>> apps = new HashSet<>();
    Collection<Map<String, Object>> appsSet = (Collection<Map<String, Object>>) context.get("appsSet");
    if (appsSet != null) {
        apps.addAll(appsSet);
    }
    Boolean importDemo = (Boolean) context.get("importDemoData");
    String language = (String) context.get("languageSelect");
    AppRepository appRepository = Beans.get(AppRepository.class);
    List<App> appList = new ArrayList<>();
    for (Map<String, Object> appData : apps) {
        App app = appRepository.find(Long.parseLong(appData.get("id").toString()));
        appList.add(app);
    }
    Beans.get(AppService.class).bulkInstall(appList, importDemo, language);
    response.setFlash(I18n.get(IExceptionMessages.BULK_INSTALL_SUCCESS));
    response.setSignal("refresh-app", true);
}
Also used : Context(com.axelor.rpc.Context) App(com.axelor.apps.base.db.App) AppService(com.axelor.apps.base.service.app.AppService) AppRepository(com.axelor.apps.base.db.repo.AppRepository) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

App (com.axelor.apps.base.db.App)18 AppRepository (com.axelor.apps.base.db.repo.AppRepository)7 AppService (com.axelor.apps.base.service.app.AppService)7 AxelorException (com.axelor.exception.AxelorException)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 AccessConfig (com.axelor.apps.base.db.AccessConfig)2 XMLImporter (com.axelor.data.xml.XMLImporter)2 MetaFile (com.axelor.meta.db.MetaFile)2 AppBuilder (com.axelor.studio.db.AppBuilder)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 AppSettings (com.axelor.app.AppSettings)1 IExceptionMessages (com.axelor.apps.base.exceptions.IExceptionMessages)1 FileUtils (com.axelor.common.FileUtils)1 Inflector (com.axelor.common.Inflector)1 Importer (com.axelor.data.Importer)1 CSVBind (com.axelor.data.csv.CSVBind)1