use of com.axelor.apps.base.db.AccessConfig in project axelor-open-suite by axelor.
the class AccessConfigImportServiceImpl method getAccessConfig.
@Transactional
public Map<Integer, AccessConfig> getAccessConfig(Row row, App app) {
Map<Integer, AccessConfig> configMap = new HashMap<>();
Iterator<Cell> cellIter = row.iterator();
cellIter.next();
while (cellIter.hasNext()) {
Cell cell = cellIter.next();
String name = cell.getStringCellValue();
if (name != null) {
AccessConfig config = accessConfigRepo.all().filter("self.name = ?1 and self.app = ?2", name, app).fetchOne();
if (config == null) {
config = new AccessConfig(name);
config.setApp(app);
config = accessConfigRepo.save(config);
}
configMap.put(cell.getColumnIndex(), config);
}
}
return configMap;
}
use of com.axelor.apps.base.db.AccessConfig in project axelor-open-suite by axelor.
the class AccessConfigImportServiceImpl method createMenuRoles.
private void createMenuRoles(Map<Integer, AccessConfig> accessMap, Row row) {
Iterator<Cell> cellIter = row.iterator();
String menu = cellIter.next().getStringCellValue().trim();
while (cellIter.hasNext()) {
Cell cell = cellIter.next();
String value = cell.getStringCellValue();
if (Strings.isNullOrEmpty(value)) {
continue;
}
AccessConfig config = accessMap.get(cell.getColumnIndex());
addRole(config, menu);
}
}
use of com.axelor.apps.base.db.AccessConfig in project axelor-open-suite by axelor.
the class AccessConfigImportServiceImpl method importMenuAccess.
private void importMenuAccess(XSSFSheet sheet) {
App app = Beans.get(AppRepository.class).findByCode(sheet.getSheetName().split("-")[0]);
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;
}
createMenuRoles(accessMap, rowIter.next());
}
}
use of com.axelor.apps.base.db.AccessConfig 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());
}
}
use of com.axelor.apps.base.db.AccessConfig in project axelor-open-suite by axelor.
the class AccessConfigImportServiceImpl method createObjectRoles.
private void createObjectRoles(Map<Integer, AccessConfig> accessMap, Row row) {
Iterator<Cell> cellIter = row.iterator();
String obj = cellIter.next().getStringCellValue();
while (cellIter.hasNext()) {
Cell cell = cellIter.next();
String value = cell.getStringCellValue();
if (Strings.isNullOrEmpty(value) || invalidValue(value)) {
continue;
}
AccessConfig config = accessMap.get(cell.getColumnIndex());
Permission permission = getPermission(obj, value.trim(), config);
addRole(config, permission);
}
}
Aggregations