fineract-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FINERACT-65) Implement ability to schedule & e-mail reports
Date Wed, 03 Aug 2016 07:30:20 GMT

    [ https://issues.apache.org/jira/browse/FINERACT-65?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15405499#comment-15405499
] 

ASF GitHub Bot commented on FINERACT-65:
----------------------------------------

Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/191#discussion_r73292182
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/reportmailingjob/api/ReportMailingJobApiResource.java
---
    @@ -0,0 +1,157 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.infrastructure.reportmailingjob.api;
    +
    +import java.util.Collection;
    +
    +import javax.ws.rs.Consumes;
    +import javax.ws.rs.DELETE;
    +import javax.ws.rs.GET;
    +import javax.ws.rs.POST;
    +import javax.ws.rs.PUT;
    +import javax.ws.rs.Path;
    +import javax.ws.rs.PathParam;
    +import javax.ws.rs.Produces;
    +import javax.ws.rs.core.Context;
    +import javax.ws.rs.core.MediaType;
    +import javax.ws.rs.core.UriInfo;
    +
    +import org.apache.fineract.commands.domain.CommandWrapper;
    +import org.apache.fineract.commands.service.CommandWrapperBuilder;
    +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
    +import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
    +import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
    +import org.apache.fineract.infrastructure.reportmailingjob.ReportMailingJobConstants;
    +import org.apache.fineract.infrastructure.reportmailingjob.data.ReportMailingJobData;
    +import org.apache.fineract.infrastructure.reportmailingjob.service.ReportMailingJobReadPlatformService;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.context.annotation.Scope;
    +import org.springframework.stereotype.Component;
    +
    +@Path("/" + ReportMailingJobConstants.REPORT_MAILING_JOB_RESOURCE_NAME)
    +@Component
    +@Scope("singleton")
    +public class ReportMailingJobApiResource {
    +
    +    private final PlatformSecurityContext platformSecurityContext;
    +    private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
    +    private final ApiRequestParameterHelper apiRequestParameterHelper;
    +    private final DefaultToApiJsonSerializer<ReportMailingJobData> reportMailingToApiJsonSerializer;
    +    private final ReportMailingJobReadPlatformService reportMailingJobReadPlatformService;
    +    
    +    @Autowired
    +    public ReportMailingJobApiResource(final PlatformSecurityContext platformSecurityContext,

    +            final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,

    +            final ApiRequestParameterHelper apiRequestParameterHelper, 
    +            final DefaultToApiJsonSerializer<ReportMailingJobData> reportMailingToApiJsonSerializer,

    +            final ReportMailingJobReadPlatformService reportMailingJobReadPlatformService)
{
    +        this.platformSecurityContext = platformSecurityContext;
    +        this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
    +        this.apiRequestParameterHelper = apiRequestParameterHelper;
    +        this.reportMailingToApiJsonSerializer = reportMailingToApiJsonSerializer;
    +        this.reportMailingJobReadPlatformService = reportMailingJobReadPlatformService;
    +    }
    +    
    +    @POST
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String createReportMailingJob(final String apiRequestBodyAsJson) {
    +        final CommandWrapper commandWrapper = new CommandWrapperBuilder().
    +                createReportMailingJob(ReportMailingJobConstants.REPORT_MAILING_JOB_PERMISSION_NAME).
    +                withJson(apiRequestBodyAsJson).build();
    +        
    +        final CommandProcessingResult commandProcessingResult = this.commandsSourceWritePlatformService.logCommandSource(commandWrapper);
    +        
    +        return this.reportMailingToApiJsonSerializer.serialize(commandProcessingResult);
    +    }
    +    
    +    @PUT
    +    @Path("{entityId}")
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String updateReportMailingJob(@PathParam("entityId") final Long entityId,
final String apiRequestBodyAsJson) {
    +        final CommandWrapper commandWrapper = new CommandWrapperBuilder().
    +                updateReportMailingJob(ReportMailingJobConstants.REPORT_MAILING_JOB_PERMISSION_NAME,
entityId).
    +                withJson(apiRequestBodyAsJson).build();
    +        
    +        final CommandProcessingResult commandProcessingResult = this.commandsSourceWritePlatformService.logCommandSource(commandWrapper);
    +        
    +        return this.reportMailingToApiJsonSerializer.serialize(commandProcessingResult);
    +    }
    +    
    +    @DELETE
    +    @Path("{entityId}")
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String deleteReportMailingJob(@PathParam("entityId") final Long entityId,
final String apiRequestBodyAsJson) {
    +        final CommandWrapper commandWrapper = new CommandWrapperBuilder().
    +                deleteReportMailingJob(ReportMailingJobConstants.REPORT_MAILING_JOB_PERMISSION_NAME,
entityId).
    +                withJson(apiRequestBodyAsJson).build();
    +        
    +        final CommandProcessingResult commandProcessingResult = this.commandsSourceWritePlatformService.logCommandSource(commandWrapper);
    +        
    +        return this.reportMailingToApiJsonSerializer.serialize(commandProcessingResult);
    +    }
    +    
    +    @GET
    +    @Path("{entityId}")
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String retrieveReportMailingJob(@PathParam("entityId") final Long entityId,
@Context final UriInfo uriInfo) {
    +        this.platformSecurityContext.authenticatedUser().validateHasReadPermission(ReportMailingJobConstants.REPORT_MAILING_JOB_PERMISSION_NAME);
    +        
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        ReportMailingJobData reportMailingJobData = this.reportMailingJobReadPlatformService.retrieveReportMailingJob(entityId);
    +        
    +        if (settings.isTemplate()) {
    +            final ReportMailingJobData ReportMailingJobDataOptions = this.reportMailingJobReadPlatformService.retrieveReportMailingJobEnumOptions();
    +            reportMailingJobData = ReportMailingJobData.newInstance(reportMailingJobData,
ReportMailingJobDataOptions);
    +        }
    +        
    +        return this.reportMailingToApiJsonSerializer.serialize(settings, reportMailingJobData,
ReportMailingJobConstants.REPORT_MAILING_JOB_DATA_PARAMETERS);
    +    }
    +    
    +    @GET
    +    @Path("template")
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String retrieveReportMailingJobTemplate(@Context final UriInfo uriInfo) {
    +        this.platformSecurityContext.authenticatedUser().validateHasReadPermission(ReportMailingJobConstants.REPORT_MAILING_JOB_PERMISSION_NAME);
    +        
    +        final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    +        final ReportMailingJobData ReportMailingJobDataOptions = this.reportMailingJobReadPlatformService.retrieveReportMailingJobEnumOptions();
    +        
    +        return this.reportMailingToApiJsonSerializer.serialize(settings, ReportMailingJobDataOptions,
ReportMailingJobConstants.REPORT_MAILING_JOB_DATA_PARAMETERS);
    +    }
    +    
    +    @GET
    +    @Consumes({ MediaType.APPLICATION_JSON })
    +    @Produces({ MediaType.APPLICATION_JSON })
    +    public String retrieveAllReportMailingJobs(@Context final UriInfo uriInfo) {
    --- End diff --
    
    Suggestion: Better to give pagination support to retrieve all report mailing jobs. 


> Implement ability to schedule & e-mail reports
> ----------------------------------------------
>
>                 Key: FINERACT-65
>                 URL: https://issues.apache.org/jira/browse/FINERACT-65
>             Project: Apache Fineract
>          Issue Type: New Feature
>            Reporter: Emmanuel Nnaa
>            Assignee: Markus Geiss
>            Priority: Minor
>
> Some reports take a bit longer to run, therefore we should be able to allow our users
to schedule them overnight to be e-mailed. 
> The way this should work is:
> - Add e-mailaddress to users and make it mandatory (possibly already in MifosX)
> - Allow users to configure schedule entries which consist of:
> - One or multiple target users (e-mailaddresses)
> - Set the preferred subject and content of the e-mail (Look at user generated documents
API in MifosX for replacing certain variables)
> - Choose the run frequency of the report (daily, weekly, every x'th day of the month
etc, cron-like flexibility with a UI)
> - Pick the preferred output format (PDF/XLS/CSV)
> These reports should be picked up by a scheduled job overnight and then run in serial
to avoid performance hits and sent out to the users.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message