List of usage examples for org.joda.time LocalDateTime now
public static LocalDateTime now()
ISOChronology
in the default time zone. From source file:com.axelor.apps.message.service.MessageServiceImpl.java
License:Open Source License
@Transactional(rollbackOn = { MessagingException.class, IOException.class, Exception.class }) public Message sendByEmail(Message message) throws MessagingException, IOException { MailAccount mailAccount = message.getMailAccount(); if (mailAccount == null) { return message; }//from w w w. j a v a 2s.c o m log.debug("Sent email"); com.axelor.mail.MailAccount account = new SmtpAccount(mailAccount.getHost(), mailAccount.getPort().toString(), mailAccount.getLogin(), mailAccount.getPassword(), mailAccountService.getSmtpSecurity(mailAccount)); List<String> replytoRecipients = this.getEmailAddresses(message.getReplyToEmailAddressSet()), toRecipients = this.getEmailAddresses(message.getToEmailAddressSet()), ccRecipients = this.getEmailAddresses(message.getCcEmailAddressSet()), bccRecipients = this.getEmailAddresses(message.getBccEmailAddressSet()); MailSender sender = new MailSender(account); MailBuilder mailBuilder = sender.compose(); mailBuilder.subject(message.getSubject()); if (message.getFromEmailAddress() != null) { log.debug("Override from ::: {}", message.getFromEmailAddress().getAddress()); mailBuilder.from(message.getFromEmailAddress().getAddress()); } if (replytoRecipients != null && !replytoRecipients.isEmpty()) { mailBuilder.replyTo(Joiner.on(",").join(toRecipients)); } if (toRecipients != null && !toRecipients.isEmpty()) { mailBuilder.to(Joiner.on(",").join(toRecipients)); } if (ccRecipients != null && !ccRecipients.isEmpty()) { mailBuilder.cc(Joiner.on(",").join(ccRecipients)); } if (bccRecipients != null && !bccRecipients.isEmpty()) { mailBuilder.bcc(Joiner.on(",").join(bccRecipients)); } if (!Strings.isNullOrEmpty(message.getContent())) { mailBuilder.html(message.getContent()); } for (MetaAttachment metaAttachment : getMetaAttachments(message)) { MetaFile metaFile = metaAttachment.getMetaFile(); mailBuilder.attach(metaFile.getFileName(), MetaFiles.getPath(metaFile).toString()); } mailBuilder.send(); message.setSentByEmail(true); message.setStatusSelect(MessageRepository.STATUS_SENT); message.setSentDateT(LocalDateTime.now()); return messageRepo.save(message); }
From source file:com.axelor.auth.service.PermissionAssistantService.java
License:Open Source License
private String getFileName(PermissionAssistant assistant) { String userCode = assistant.getCreatedBy().getCode(); String dateString = LocalDateTime.now().toString("yyyyMMddHHmm"); String fileName = userCode + "-" + dateString + ".csv"; return fileName; }
From source file:com.axelor.auth.web.PermissionAssitantController.java
License:Open Source License
public void importPermissions(ActionRequest request, ActionResponse response) { Long permissionAssistantId = (Long) request.getContext().get("id"); String errors = permissionAssistantService .importPermissions(permissionAssistantRepo.find(permissionAssistantId)); response.setValue("importDate", LocalDateTime.now()); response.setValue("log", errors); if (errors.equals("")) { response.setFlash(I18n.get(IMessage.IMPORT_OK)); } else {/*from w w w. j a v a2 s.co m*/ response.setFlash(I18n.get(IMessage.ERR_IMPORT)); } }
From source file:com.axelor.meta.service.MetaGroupMenuAssistantService.java
License:Open Source License
private String getFileName(MetaGroupMenuAssistant groupMenuAssistant) { String userCode = groupMenuAssistant.getCreatedBy().getCode(); String dateString = LocalDateTime.now().toString("yyyyMMddHHmm"); String fileName = "GroupMenu" + "-" + userCode + "-" + dateString + ".csv"; return fileName; }
From source file:com.axelor.meta.web.MetaGroupMenuAssistantController.java
License:Open Source License
public void importGroupMenu(ActionRequest request, ActionResponse response) { Long groupMenuAssistantId = (Long) request.getContext().get("id"); String errorLog = groupMenuAssistantService .importGroupMenu(groupMenuAssistantRepo.find(groupMenuAssistantId)); if (errorLog.equals("")) { response.setFlash(I18n.get(IMessage.IMPORT_OK)); response.setValue("importDate", LocalDateTime.now()); } else {//from w ww.ja v a 2s . com response.setValue("log", errorLog); response.setFlash(I18n.get(IMessage.ERR_IMPORT)); } }
From source file:com.axelor.studio.service.ReportPrinterService.java
License:Open Source License
/** * Root method to access the service. It process template of reportBuilder * and generate html from it. It also process fileName of report builder. * /*from w ww.j a v a2 s .c o m*/ * @param reportBuilder * ReportBuilder to process; * @param recordId * Id of record to process. * @return Generated html report and processed file name.. */ public String[] getHtml(ReportBuilder reportBuilder, Long recordId) { try { String model = reportBuilder.getMetaModel().getFullName(); @SuppressWarnings("unchecked") Model entity = JPA.find((Class<Model>) Class.forName(model), recordId); StringTemplates strTemplate = new StringTemplates('$', '$'); String text = getTemplate(reportBuilder); if (text == null) { return new String[] { I18n.get("No template found") }; } String fileName = reportBuilder.getFileName(); fileName = fileName.replace("$TODAY$", LocalDate.now().toString("ddMMYYYY")); fileName = fileName.replace("$NOW$", LocalDateTime.now().toString("ddMMYYYYHHmm")); Template template = strTemplate.fromText(fileName); fileName = template.make(entity).render(); template = strTemplate.fromText(text); return new String[] { fileName, template.make(entity).render() }; } catch (ClassNotFoundException e) { e.printStackTrace(); } return new String[] { I18n.get("Error in printing") }; }
From source file:com.coast.PDFPrinter_iText.java
License:Apache License
/** * Prints the document at its actual size. This is the recommended way to print. *//*from ww w . ja v a2 s . c om*/ private static void print(String pFileName, String pPayload) throws IOException, Exception { Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(pFileName)); // step 3 document.open(); // step 4 String _dateTime = LocalDateTime.now().toString(); document.addTitle("List of All Customers & their assets as of: " + _dateTime); document.addCreationDate(); document.addSubject("List of All Customers & their assets as of: " + _dateTime); Font _font = new Font(); _font.setColor(BaseColor.BLUE); _font.setStyle(Font.BOLD); _font.setSize(15); Chunk _chunk = new Chunk("List of All Customers & their assets as of: " + _dateTime); _chunk.setFont(_font); Paragraph _header = new Paragraph(); _header.add(_chunk); document.add(_header); document.add(new Paragraph(pPayload)); // step 5 document.close(); }
From source file:com.effektif.workflow.impl.job.RelativeTimeImpl.java
License:Apache License
public LocalDateTime resolve(ActivityInstanceImpl activityInstance) { LocalDateTime baseTime = null; if (activityInstance != null && base != null) { baseTime = activityInstance.getValue(base); }//from ww w. j a v a 2s . c o m if (baseTime == null) { baseTime = Time.now(); } LocalDateTime time = relativeTime.resolve(baseTime); return time; }
From source file:com.einzig.ipst2.util.AsyncLogger.java
License:Open Source License
/** * Get the name of the file to write logs to * * @return name of the file to write logs to *//*ww w . j a va2 s .com*/ private String getFilename() { DateTimeFormatter formatter = ISODateTimeFormat.basicDate(); return "IPST_Logs_" + formatter.print(LocalDateTime.now()) + ".txt"; }
From source file:com.einzig.ipst2.util.AsyncLogger.java
License:Open Source License
/** * Write log to log file//from ww w .j a va 2 s. c o m * * @param level Severity of the log * @param scope Scope the message was written from * @param message Message to be logged */ private void log(String level, String scope, String message) { fileQueue.add(new LogEntry(level, LocalDateTime.now(), scope, message)); }