use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class EbicsController method sendFULRequest.
public void sendFULRequest(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
try {
MetaFile testDataMetaFile = ebicsUser.getTestDataFile();
MetaFile testSignatureMetaFile = ebicsUser.getTestSignatureFile();
BankOrderFileFormat bankOrderFileFormat = ebicsUser.getTestBankOrderFileFormat();
if (testDataMetaFile != null && bankOrderFileFormat != null) {
File testSignatureFile = null;
if (ebicsUser.getEbicsPartner().getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS && testSignatureMetaFile != null) {
testSignatureFile = MetaFiles.getPath(testSignatureMetaFile).toFile();
}
Beans.get(EbicsService.class).sendFULRequest(ebicsUser, ebicsUser.getTestSignatoryEbicsUser(), null, MetaFiles.getPath(testDataMetaFile).toFile(), bankOrderFileFormat, testSignatureFile);
} else {
response.setFlash(I18n.get(IExceptionMessage.EBICS_TEST_MODE_NOT_ENABLED));
}
} catch (Exception e) {
response.setFlash(stripClass(e.getLocalizedMessage()));
}
response.setReload(true);
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class WkfModelController method importWkfModels.
@SuppressWarnings("unchecked")
@Transactional
public void importWkfModels(ActionRequest request, ActionResponse response) throws AxelorException {
boolean isTranslate = request.getContext().get("isTranslate") == null ? false : (boolean) request.getContext().get("isTranslate");
String sourceLanguage = (String) request.getContext().get("sourceLanguageSelect");
String targetLanguage = (String) request.getContext().get("targetLanguageSelect");
String metaFileId = ((Map<String, Object>) request.getContext().get("dataFile")).get("id").toString();
MetaFile metaFile = Beans.get(MetaFileRepository.class).find(Long.parseLong(metaFileId));
String logText = wkfModelService.importWkfModels(metaFile, isTranslate, sourceLanguage, targetLanguage);
if (Strings.isNullOrEmpty(logText)) {
response.setCanClose(true);
} else {
response.setValue("importLog", logText);
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class MpsChargeController method print.
public void print(ActionRequest request, ActionResponse response) throws AxelorException {
String name = I18n.get(ITranslation.MPS_CHARGE);
LocalDate startMonthDate = (LocalDate) request.getContext().get("startMonthDate");
LocalDate endMonthDate = (LocalDate) request.getContext().get("endMonthDate");
if (startMonthDate == null || endMonthDate == null) {
return;
}
String fileLink = ReportFactory.createReport(IReport.MPS_CHARGE, name + "-${date}").addParam("mpsId", request.getContext().get("id")).addParam("logoPath", Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).map(Company::getLogo).map(MetaFile::getFilePath).orElse(null)).addParam("startMonthDate", startMonthDate.format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))).addParam("endMonthDate", endMonthDate.format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))).generate().getFileLink();
LOG.debug("Printing {}", name);
response.setView(ActionView.define(name).add("html", fileLink).map());
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class UnitCostCalculationController method importUnitCostCalc.
@SuppressWarnings("unchecked")
public void importUnitCostCalc(ActionRequest request, ActionResponse response) throws IOException {
try {
LinkedHashMap<String, Object> map = (LinkedHashMap<String, Object>) request.getContext().get("metaFile");
MetaFile dataFile = Beans.get(MetaFileRepository.class).find(((Integer) map.get("id")).longValue());
File csvFile = MetaFiles.getPath(dataFile).toFile();
Long unitCostCalculationId = Long.valueOf(request.getContext().get("_id").toString());
UnitCostCalculation unitCostCalculation = Beans.get(UnitCostCalculationRepository.class).find(unitCostCalculationId);
if (Files.getFileExtension(csvFile.getName()).equals("csv")) {
Beans.get(UnitCostCalculationService.class).importUnitCostCalc(dataFile, unitCostCalculation);
response.setCanClose(true);
} else {
response.setError(IExceptionMessage.UNIT_COST_CALCULATION_IMPORT_CSV_ERROR);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class OperationOrderServiceImpl method createBarcode.
@Override
public void createBarcode(OperationOrder operationOrder) {
try {
String stringId = operationOrder.getId().toString();
boolean addPadding = true;
InputStream inStream = barcodeGeneratorService.createBarCode(stringId, appProductionService.getAppProduction().getBarcodeTypeConfig(), addPadding);
if (inStream != null) {
MetaFile barcodeFile = metaFiles.upload(inStream, String.format("OppOrderBarcode%d.png", operationOrder.getId()));
operationOrder.setBarCode(barcodeFile);
}
} catch (IOException e) {
e.printStackTrace();
} catch (AxelorException e) {
throw new ValidationException(e);
}
}
Aggregations