use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class CampaignController method sendReminderEmail.
public void sendReminderEmail(ActionRequest request, ActionResponse response) {
Campaign campaign = request.getContext().asType(Campaign.class);
try {
campaign = Beans.get(CampaignRepository.class).find(campaign.getId());
if (campaign.getInvitedPartnerSet().isEmpty() && campaign.getInvitedPartnerSet().isEmpty()) {
response.setFlash(I18n.get(IExceptionMessage.REMINDER_EMAIL1));
return;
}
MetaFile logFile = Beans.get(CampaignService.class).sendReminderEmail(campaign);
if (logFile == null) {
response.setFlash(I18n.get(IExceptionMessage.EMAIL_SUCCESS));
} else {
response.setFlash(I18n.get(IExceptionMessage.EMAIL_ERROR2));
}
response.setValue("emailLog", logFile);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class CampaignController method sendEmail.
public void sendEmail(ActionRequest request, ActionResponse response) {
Campaign campaign = request.getContext().asType(Campaign.class);
try {
campaign = Beans.get(CampaignRepository.class).find(campaign.getId());
if (campaign.getLeadSet().isEmpty() && campaign.getPartnerSet().isEmpty()) {
response.setFlash(I18n.get(IExceptionMessage.EMPTY_TARGET));
return;
}
MetaFile logFile = Beans.get(CampaignService.class).sendEmail(campaign);
if (logFile == null) {
response.setFlash(I18n.get(IExceptionMessage.EMAIL_SUCCESS));
} else {
response.setFlash(I18n.get(IExceptionMessage.EMAIL_ERROR2));
}
response.setValue("emailLog", logFile);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class DeclarationOfExchangesExporter method attach.
protected String attach(String path) {
DMSFile dmsFile;
try (InputStream is = new FileInputStream(path)) {
dmsFile = Beans.get(MetaFiles.class).attach(is, getFileName(), declarationOfExchanges);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
MetaFile metaFile = dmsFile.getMetaFile();
return String.format("ws/rest/com.axelor.meta.db.MetaFile/%d/content/download?v=%d/%s", metaFile.getId(), metaFile.getVersion(), path);
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class ExportObserver method onExport.
void onExport(@Observes @Named(RequestEvent.EXPORT) PostRequest event) throws IOException {
List<GlobalTrackingConfigurationLine> gtcLines = Beans.get(AppBaseService.class).getAppBase().getGlobalTrackingConfigurationLines();
if (CollectionUtils.isEmpty(gtcLines)) {
return;
}
MetaModel model = Beans.get(MetaModelRepository.class).all().filter("self.fullName = ?", event.getRequest().getBeanClass().getName()).fetchOne();
if (gtcLines.stream().anyMatch(l -> l.getMetaModel().equals(model) && l.getTrackExport())) {
@SuppressWarnings("unchecked") final Map<String, Object> data = (Map<String, Object>) event.getResponse().getData();
if (data == null || data.get("fileName") == null) {
return;
}
final String fileName = (String) data.get("fileName");
final Path filePath = MetaFiles.findTempFile(fileName);
MetaFile mf = new MetaFile();
mf.setFileName(fileName);
Beans.get(MetaFiles.class).upload(new FileInputStream(filePath.toFile()), mf);
Beans.get(GlobalTrackingLogService.class).createExportLog(model, mf);
}
}
use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class DmsImportWizardController method importDMS.
public void importDMS(ActionRequest request, ActionResponse response) throws AxelorException {
try {
@SuppressWarnings("unchecked") Map<String, Object> metaFileMap = (Map<String, Object>) request.getContext().get("metaFile");
MetaFile metaFile = metaFileRepo.find(Long.parseLong(metaFileMap.get("id").toString()));
dmsImportWizardService.importDMS(metaFile);
response.setReload(true);
} catch (AxelorException e) {
response.setFlash(e.getMessage());
}
}
Aggregations