use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class ObjectDataExportController method export.
public void export(ActionRequest request, ActionResponse response) throws AxelorException {
ObjectDataConfigExport objDataConfigExport = request.getContext().asType(ObjectDataConfigExport.class);
Long objectDataconfigId = objDataConfigExport.getObjectDataConfig().getId();
ObjectDataConfig objectDataConfig = Beans.get(ObjectDataConfigRepository.class).find(objectDataconfigId);
MetaFile dataFile = Beans.get(ObjectDataExportService.class).export(objectDataConfig, objDataConfigExport);
if (dataFile != null) {
response.setView(ActionView.define(I18n.get("Data")).add("html", "ws/rest/com.axelor.meta.db.MetaFile/" + dataFile.getId() + "/content/download?v=" + dataFile.getVersion()).param("download", "true").map());
}
response.setCanClose(true);
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class PermissionAssistantService method importPermissions.
public String importPermissions(PermissionAssistant permissionAssistant) {
try {
ResourceBundle bundle = I18n.getBundle(new Locale(permissionAssistant.getLanguage()));
MetaFile metaFile = permissionAssistant.getMetaFile();
File csvFile = MetaFiles.getPath(metaFile).toFile();
try (CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(csvFile), StandardCharsets.UTF_8), ';')) {
String[] groupRow = csvReader.readNext();
if (groupRow == null || groupRow.length < 11) {
errorLog = I18n.get(IMessage.BAD_FILE);
}
String[] headerRow = csvReader.readNext();
if (headerRow == null) {
errorLog = I18n.get(IMessage.NO_HEADER);
}
if (!checkHeaderRow(Arrays.asList(headerRow), bundle)) {
errorLog = I18n.get(IMessage.BAD_HEADER) + " " + Arrays.asList(headerRow);
}
if (!errorLog.equals("")) {
return errorLog;
}
if (permissionAssistant.getTypeSelect() == PermissionAssistantRepository.TYPE_GROUPS) {
Map<String, Group> groupMap = checkBadGroups(groupRow);
processGroupCSV(csvReader, groupRow, groupMap, permissionAssistant.getMetaField(), permissionAssistant.getFieldPermission());
saveGroups(groupMap);
} else if (permissionAssistant.getTypeSelect() == PermissionAssistantRepository.TYPE_ROLES) {
Map<String, Role> roleMap = checkBadRoles(groupRow);
processRoleCSV(csvReader, groupRow, roleMap, permissionAssistant.getMetaField(), permissionAssistant.getFieldPermission());
saveRoles(roleMap);
}
}
} catch (Exception e) {
LOG.error(e.getLocalizedMessage());
TraceBackService.trace(e);
errorLog += "\n" + String.format(I18n.get(IMessage.ERR_IMPORT_WITH_MSG), e.getMessage());
}
return errorLog;
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class ImportApp method importApp.
public Object importApp(Object bean, Map<String, Object> values) {
assert bean instanceof App;
App app = (App) bean;
final Path path = (Path) values.get("__path__");
String fileName = (String) values.get("imagePath");
if (!Strings.isNullOrEmpty(fileName)) {
try {
final File image = path.resolve("img" + File.separator + fileName).toFile();
if (image.exists()) {
final MetaFile metaFile = metaFiles.upload(image);
app.setImage(metaFile);
}
} catch (Exception e) {
LOG.warn("Can't load image {} for app {}", fileName, app.getName());
}
}
if (app.getLanguageSelect() == null) {
String language = AppSettings.get().get("application.locale");
app.setLanguageSelect(language);
}
return app;
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class AccessTemplateServiceImpl method createMetaFile.
public MetaFile createMetaFile(XSSFWorkbook workBook) throws IOException {
Path path = MetaFiles.createTempFile("AccessConfigTemplate", ".xlsx");
File file = path.toFile();
FileOutputStream fout = new FileOutputStream(file);
workBook.write(fout);
fout.close();
return metaFiles.upload(file);
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class BpmDeploymentServiceImpl method deploy.
@Override
@Transactional
public void deploy(WkfModel wkfModel, Map<String, Map<String, String>> migrationMap) {
if (wkfModel.getDiagramXml() == null) {
return;
}
this.wkfModel = wkfModel;
this.migrationMap = migrationMap;
ProcessEngine engine = Beans.get(ProcessEngineService.class).getEngine();
String key = wkfModel.getId() + ".bpmn";
BpmnModelInstance bpmInstance = Bpmn.readModelFromStream(new ByteArrayInputStream(wkfModel.getDiagramXml().getBytes()));
DeploymentBuilder deploymentBuilder = engine.getRepositoryService().createDeployment().addModelInstance(key, bpmInstance).source(key);
Set<MetaFile> dmnFiles = wkfModel.getDmnFileSet();
if (dmnFiles != null) {
addDmn(deploymentBuilder, dmnFiles);
}
Map<String, String> processMap = deployProcess(engine, deploymentBuilder, bpmInstance);
List<MetaAttrs> metaAttrsList = Beans.get(WkfNodeService.class).extractNodes(wkfModel, bpmInstance, processMap);
Beans.get(WkfModelRepository.class).save(wkfModel);
metaAttrsService.saveMetaAttrs(metaAttrsList, wkfModel.getId());
}
Aggregations