Example usage for org.joda.time LocalDateTime now

List of usage examples for org.joda.time LocalDateTime now

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime now.

Prototype

public static LocalDateTime now() 

Source Link

Document

Obtains a LocalDateTime set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:org.devgateway.eudevfin.dim.pages.Messages.java

License:Open Source License

public Messages() {
    super();//from  w w w.jav  a2 s. co m

    ListGeneratorInterface<Message> listGenerator = new ListGeneratorInterface<Message>() {
        @Override
        public PagingHelper<Message> getResultsList(int pageNumber, int pageSize) {
            return PagingHelper.createPagingHelperFromPage(
                    mxService.findByTo(AuthUtils.getCurrentUser(), new PageRequest(pageNumber - 1, pageSize)));
        }
    };

    final MessagesListTable list = new MessagesListTable("list", listGenerator);
    add(list);

    final Model<Message> messageModel = new Model<>(new Message());

    form = new Form<>("form", messageModel);
    form.setOutputMarkupId(true);
    add(form);

    //DropDownField<PersistedUser> to = new DropDownField<>("to", new PropertyModel<PersistedUser>(messageModel, "to"), userChoiceProvider);
    MultiSelectField<PersistedUser> to = new MultiSelectField<>("to",
            new PropertyModel<Collection<PersistedUser>>(messageModel, "to"), userChoiceProvider);
    to.required();
    to.setSize(InputBehavior.Size.XXLarge);
    form.add(to);

    TextInputField<String> subject = new TextInputField<>("subject",
            new PropertyModel<String>(messageModel, "subject"));
    subject.typeString();
    subject.setSize(InputBehavior.Size.XXLarge);
    form.add(subject);

    messageInputField = new TextAreaInputField("message", new PropertyModel<String>(messageModel, "message"));
    messageInputField.setOutputMarkupId(true);
    messageInputField.setSize(InputBehavior.Size.XXLarge);
    messageInputField.maxContentLength(Message.MAX_BODY_SIZE);
    form.add(messageInputField);

    MultiFileUploadField attachments = new MultiFileUploadField("attachments",
            new PropertyModel<Collection<FileWrapper>>(messageModel, "attachments"));
    form.add(attachments);

    BootstrapSubmitButton send = new BootstrapSubmitButton("send",
            new StringResourceModel("send.label", this, null, null)) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            final Message message = messageModel.getObject();
            message.setFrom(AuthUtils.getCurrentUser());
            message.setSendDate(LocalDateTime.now());
            mxService.save(message);

            messageModel.setObject(new Message());
            target.add(form);

            list.reloadMessageList(target);
        }
    };
    form.add(send);
}

From source file:org.devgateway.eudevfin.dim.pages.transaction.crs.TransactionPage.java

License:Open Source License

private Message newSystemMessage(PersistedUser user, FinancialTransaction transaction) {
    Message ret = new Message();
    ret.setSendDate(LocalDateTime.now());
    ret.setFrom(AuthUtils.getCurrentUser());
    ArrayList<PersistedUser> to = new ArrayList<>();
    to.add(user);//from  w  w  w .  j  a  va  2  s  .com
    ret.setTo(to);

    ret.setMessage(buildTransactionLinkMsg(transaction));

    return ret;
}

From source file:org.devgateway.eudevfin.financial.auditing.CustomRevisionListener.java

License:Open Source License

@Override
public void newRevision(Object revisionEntity) {
    CustomRevisionEntity revision = (CustomRevisionEntity) revisionEntity;
    revision.setUsername(auditor.getCurrentAuditor());
    revision.setModificationTime(LocalDateTime.now());

}

From source file:org.devgateway.eudevfin.financial.repository.CustomFinancialTransactionRepositoryImpl.java

License:Open Source License

@Override
public Page<CustomFinancialTransaction> performSearchByDonorIdCrsIdActive(String donorIdSearch,
        String crsIdSearch, Boolean active, String locale, Pageable pageable) {
    StringBuilder queryBuilder = new StringBuilder(" FROM CustomFinancialTransaction tx WHERE 1=1");

    if (crsIdSearch != null)
        queryBuilder.append(" AND tx.crsIdentificationNumber like :crsIdSearch");
    if (donorIdSearch != null)
        queryBuilder.append(" AND tx.donorProjectNumber like :donorIdSearch");
    if (active)//  ww w.  j  av  a 2 s .c  om
        queryBuilder.append(" AND tx.expectedCompletionDate > :systemDate");

    Query query = em.createQuery("SELECT tx " + queryBuilder.toString());
    query.setMaxResults(pageable.getPageSize());
    query.setFirstResult(pageable.getOffset());

    StringBuilder countBuilder = new StringBuilder("SELECT count(tx) ").append(queryBuilder);
    Query countQuery = em.createQuery(countBuilder.toString());

    if (crsIdSearch != null)
        setQueriesParameter(query, countQuery, "crsIdSearch", crsIdSearch);
    if (donorIdSearch != null)
        setQueriesParameter(query, countQuery, "donorIdSearch", donorIdSearch);
    if (active)
        setQueriesParameter(query, countQuery, "systemDate", LocalDateTime.now());

    long maxResults = (Long) countQuery.getSingleResult();
    @SuppressWarnings("rawtypes")
    List resultList = query.getResultList();

    @SuppressWarnings("unchecked")
    PageImpl<CustomFinancialTransaction> result = new PageImpl<CustomFinancialTransaction>(resultList, pageable,
            maxResults);
    return result;
}

From source file:org.devgateway.eudevfin.sheetexp.iati.util.IatiTransformationStarter.java

License:Open Source License

@Override
public IatiTransformationStarter prepareTransformation(final Filter filter,
        final CustomFinancialTransactionService txService) {
    final LocalDateTime now = LocalDateTime.now();

    this.finalList = new ArrayList<EntityWrapperInterface<?>>();

    final List<CustomFinancialTransaction> txList = txService
            .findByApprovedTrueAndFormTypeInOrderByCrsIdAscCreatedDateAsc(this.getAllowedFormTypes());
    new EntityWrapperListHelper<CustomFinancialTransaction>(txList, "iati-export", now, "en")
            .addToWrappedList(this.finalList);

    return this;

}

From source file:org.devgateway.eudevfin.sheetexp.transformer.DummyDateCellTransformer.java

License:Open Source License

@Override
public MetadataCell<LocalDateTime> transform(final SrcType src) {
    final LocalDateTime date = LocalDateTime.now();
    final MetadataCell<LocalDateTime> cell = new MetadataCell<LocalDateTime>(date);
    cell.getMetadata().put(MetadataConstants.DATA_TYPE, MetadataConstants.DATA_TYPES.DATE.getType());
    return cell;/* w  w w .  j a  v  a 2s . c  o  m*/
}

From source file:org.devgateway.eudevfin.sheetexp.ui.SpreadsheetResource.java

License:Open Source License

@Override
public ResourceResponse newResourceResponse(final Attributes attributes) {
    //final PageParameters pageParameters = attributes.getParameters();

    final ResourceResponse resourceResponse = new ResourceResponse();

    resourceResponse.setContentType("application/vnd.ms-excel");
    resourceResponse.setFileName("fss.xls");

    // if (resourceResponse.dataNeedsToBeWritten(attributes)){

    resourceResponse.setWriteCallback(new WriteCallback() {

        @Override/*from   w w w. ja  v a  2  s . c  om*/
        public void writeData(final Attributes attributes) throws IOException {
            final Response response = attributes.getResponse();

            /* TEST DATA */
            // final List<FinancialTransaction> txList = new ArrayList<FinancialTransaction>();
            // final FinancialTransaction tx1 = new FinancialTransaction();
            // final FinancialTransaction tx2 = new FinancialTransaction();
            //
            // txList.add(tx1);
            // txList.add(tx2);
            //
            // final LocalDateTime now = LocalDateTime.now();
            // final HeaderEntityWrapper<String> header = new HeaderEntityWrapper<String>(MetadataConstants.FSS_REPORT_TYPE, now);
            //
            // final List<EntityWrapperInterface<?>> finalList = new ArrayList<EntityWrapperInterface<?>>();
            // finalList.add(header);
            // new EntityWrapperListHelper<FinancialTransaction>(txList, MetadataConstants.FSS_REPORT_TYPE,
            // now).addToWrappedList(finalList);

            final LocalDateTime now = LocalDateTime.now();
            final HeaderEntityWrapper<String> header = new HeaderEntityWrapper<String>(
                    MetadataConstants.FSS_REPORT_TYPE, now, "en");

            final List<EntityWrapperInterface<?>> finalList = new ArrayList<EntityWrapperInterface<?>>();
            finalList.add(header);

            final List<CustomFinancialTransaction> txList = SpreadsheetResource.this.txService
                    .findByReportingYearAndDraftFalse(SpreadsheetResource.this.year);
            new EntityWrapperListHelper<CustomFinancialTransaction>(txList, MetadataConstants.FSS_REPORT_TYPE,
                    now, "en").addToWrappedList(finalList);

            SpreadsheetResource.this.transformerService.createSpreadsheetOnStream(finalList, finalList.size(),
                    response.getOutputStream(), "Sheet1");

        }

    });
    return resourceResponse;
}

From source file:org.devgateway.eudevfin.sheetexp.util.EntityWrapperListHelper.java

License:Open Source License

public EntityWrapperListHelper(final List<T> sourceList, final String reportType, final String locale) {
    this(sourceList, reportType, LocalDateTime.now(), locale);
}

From source file:org.devgateway.eudevfin.sheetexp.util.TransformationStarter.java

License:Open Source License

@Override
public ITransformationStarter prepareTransformation(final Filter filter,
        final CustomFinancialTransactionService txService) {
    final LocalDateTime now = LocalDateTime.now();
    final HeaderEntityWrapper<String> header = new HeaderEntityWrapper<String>(filter.getExportType(), now,
            "en");

    this.filter = filter;
    this.finalList = new ArrayList<EntityWrapperInterface<?>>();
    this.finalList.add(header);

    final List<CustomFinancialTransaction> txList = txService
            .findByReportingYearAndApprovedTrueAndFormTypeIn(filter.getYear(), this.getAllowedFormTypes());
    new EntityWrapperListHelper<CustomFinancialTransaction>(txList, filter.getExportType(), now, "en")
            .addToWrappedList(this.finalList);

    return this;

}

From source file:org.estatio.dom.lease.invoicing.InvoiceCalculationService.java

License:Apache License

private void startInteraction(final String parameters) {
    if (interactionId == null) {
        interactionId = LocalDateTime.now().toString().concat(" - ").concat(parameters);
    }/*w w w  .jav a2s  .co m*/
}