Search in sources :

Example 1 with UploadedFileDto

use of org.mifos.dto.screen.UploadedFileDto in project head by mifos.

the class ClientFileServiceFileSystem method readAll.

public List<UploadedFileDto> readAll(Integer clientId) {
    List<ClientFileEntity> clientFileEntities = customerDao.getClientAllUploadedFiles(clientId);
    List<UploadedFileDto> uploadedFiles = new ArrayList<UploadedFileDto>();
    for (ClientFileEntity entity : clientFileEntities) {
        FileInfoEntity fileInfo = entity.getFileInfo();
        Long uploadFileId = entity.getFileId();
        String fileName = fileInfo.getName();
        String contentType = fileInfo.getContentType();
        Integer fileSize = fileInfo.getSize();
        String description = fileInfo.getDescription();
        java.util.Date uploadDate = fileInfo.getUploadDate();
        uploadedFiles.add(new UploadedFileDto(uploadFileId, fileName, contentType, fileSize, description, uploadDate));
    }
    return uploadedFiles;
}
Also used : ClientFileEntity(org.mifos.framework.fileupload.domain.ClientFileEntity) ArrayList(java.util.ArrayList) FileInfoEntity(org.mifos.framework.fileupload.domain.FileInfoEntity) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto)

Example 2 with UploadedFileDto

use of org.mifos.dto.screen.UploadedFileDto in project head by mifos.

the class LoanFileServiceFileSystem method readAll.

public List<UploadedFileDto> readAll(Integer accountId) {
    List<LoanFileEntity> loanFileEntities = loanDao.getLoanAllUploadedFiles(accountId);
    List<UploadedFileDto> uploadedFiles = new ArrayList<UploadedFileDto>();
    for (LoanFileEntity entity : loanFileEntities) {
        FileInfoEntity fileInfo = entity.getFileInfo();
        Long uploadFileId = entity.getFileId();
        String fileName = fileInfo.getName();
        String contentType = fileInfo.getContentType();
        Integer fileSize = fileInfo.getSize();
        String description = fileInfo.getDescription();
        java.util.Date uploadDate = fileInfo.getUploadDate();
        uploadedFiles.add(new UploadedFileDto(uploadFileId, fileName, contentType, fileSize, description, uploadDate));
    }
    return uploadedFiles;
}
Also used : LoanFileEntity(org.mifos.framework.fileupload.domain.LoanFileEntity) ArrayList(java.util.ArrayList) FileInfoEntity(org.mifos.framework.fileupload.domain.FileInfoEntity) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto)

Example 3 with UploadedFileDto

use of org.mifos.dto.screen.UploadedFileDto in project head by mifos.

the class PictureFormFile method addFile.

@TransactionDemarcate(joinToken = true)
public ActionForward addFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    FormFile file = actionForm.getSelectedFile();
    String fileName = actionForm.getSelectedFile().getFileName();
    String fileContentType = actionForm.getSelectedFile().getContentType();
    Integer fileSize = actionForm.getSelectedFile().getFileSize();
    String fileDescription = actionForm.getSelectedFileDescription();
    if (file != null) {
        actionForm.getFiles().add(file);
        actionForm.getFilesMetadata().add(new UploadedFileDto(fileName, fileContentType, fileSize, fileDescription));
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto) FormFile(org.apache.struts.upload.FormFile) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with UploadedFileDto

use of org.mifos.dto.screen.UploadedFileDto in project head by mifos.

the class ClientCustActionForm method clearMostButNotAllFieldsOnActionForm.

public void clearMostButNotAllFieldsOnActionForm() {
    setDefaultFees(new ArrayList<ApplicableAccountFeeDto>());
    setAdditionalFees(new ArrayList<ApplicableAccountFeeDto>());
    setCustomFields(new ArrayList<CustomFieldDto>());
    setFamilyNames(new ArrayList<ClientNameDetailDto>());
    setFamilyDetails(new ArrayList<ClientFamilyDetailDto>());
    setFamilyRelationship(new ArrayList<Short>());
    setFamilyFirstName(new ArrayList<String>());
    setFamilyMiddleName(new ArrayList<String>());
    setFamilyLastName(new ArrayList<String>());
    setFamilySecondLastName(new ArrayList<String>());
    setFamilyDateOfBirthDD(new ArrayList<String>());
    setFamilyDateOfBirthMM(new ArrayList<String>());
    setFamilyDateOfBirthYY(new ArrayList<String>());
    setFamilyGender(new ArrayList<Short>());
    setFamilyLivingStatus(new ArrayList<Short>());
    initializeFamilyMember();
    addFamilyMember();
    setAddress(new Address());
    setDisplayName(null);
    setDateOfBirthDD(null);
    setDateOfBirthMM(null);
    setDateOfBirthYY(null);
    setGovernmentId(null);
    setMfiJoiningDate(null);
    setGlobalCustNum(null);
    setCustomerId(null);
    setExternalId(null);
    setLoanOfficerId(null);
    setLoanOfficerName("");
    setFormedByPersonnel(null);
    setTrained(null);
    setTrainedDate(null);
    setClientName(new ClientNameDetailDto());
    setSpouseName(new ClientNameDetailDto());
    setClientDetailView(new ClientPersonalDetailDto());
    setNextOrPreview("next");
    setQuestionGroups(null);
    for (int i = 0; i < getSelectedOfferings().size(); i++) {
        getSelectedOfferings().set(i, null);
    }
    setFiles(new ArrayList<FormFile>());
    setFilesMetadata(new ArrayList<UploadedFileDto>());
}
Also used : Address(org.mifos.framework.business.util.Address) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FormFile(org.apache.struts.upload.FormFile) ClientFamilyDetailDto(org.mifos.dto.screen.ClientFamilyDetailDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto)

Example 5 with UploadedFileDto

use of org.mifos.dto.screen.UploadedFileDto in project head by mifos.

the class LoanAccountController method submitLoanApplication.

private LoanCreationResultDto submitLoanApplication(Integer accountState, LoanAccountFormBean formBean, LoanAccountQuestionGroupFormBean loanAccountQuestionGroupFormBean, LoanAccountCashFlow loanAccountCashFlow, CashFlowSummaryFormBean cashFlowSummaryFormBean, LoanScheduleFormBean loanScheduleFormBean) {
    LocalDate disbursementDate = LoanCreationHelper.translateDisbursementDateToLocalDate(formBean);
    RecurringSchedule recurringSchedule = LoanCreationHelper.determineRecurringSchedule(formBean);
    List<CreateAccountFeeDto> accountFees = LoanCreationHelper.translateToAccountFeeDtos(formBean);
    List<CreateAccountFeeDto> additionalAccountFees = LoanCreationHelper.translateToAdditionalAccountFeeDtos(formBean);
    List<CreateAccountPenaltyDto> accountPenalties = LoanCreationHelper.translateToAccountPenaltyDtos(formBean);
    accountFees.addAll(additionalAccountFees);
    BigDecimal loanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
    BigDecimal minAllowedLoanAmount = BigDecimal.valueOf(formBean.getMinAllowedAmount().doubleValue());
    BigDecimal maxAllowedLoanAmount = BigDecimal.valueOf(formBean.getMaxAllowedAmount().doubleValue());
    CreateLoanAccount loanAccountDetails = new CreateLoanAccount(formBean.getCustomerId(), formBean.getProductId(), accountState, loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, formBean.getInterestRate().doubleValue(), disbursementDate, null, formBean.getNumberOfInstallments().intValue(), formBean.getMinNumberOfInstallments().intValue(), formBean.getMaxNumberOfInstallments().intValue(), formBean.getGraceDuration().intValue(), formBean.getFundId(), formBean.getLoanPurposeId(), formBean.getCollateralTypeId(), formBean.getCollateralNotes(), formBean.getExternalId(), formBean.isRepaymentScheduleIndependentOfCustomerMeeting(), recurringSchedule, accountFees, accountPenalties);
    LoanCreationResultDto loanCreationResultDto = null;
    if (formBean.isGlimApplicable()) {
        List<GroupMemberAccountDto> memberAccounts = createGroupMemberAccounts(formBean);
        BigDecimal totalLoanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
        CreateGlimLoanAccount createGroupLoanAccount = new CreateGlimLoanAccount(memberAccounts, totalLoanAmount, loanAccountDetails);
        loanCreationResultDto = loanAccountServiceFacade.createGroupLoanWithIndividualMonitoring(createGroupLoanAccount, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow);
    } else {
        if (formBean.isVariableInstallmentsAllowed()) {
            List<DateTime> installmentDates = cashFlowSummaryFormBean.getInstallments();
            List<Number> totalInstallmentAmounts = cashFlowSummaryFormBean.getInstallmentAmounts();
            if (installmentDates.isEmpty()) {
                installmentDates = loanScheduleFormBean.getInstallments();
                totalInstallmentAmounts = loanScheduleFormBean.getInstallmentAmounts();
            }
            // api for creating loan with premade loan schedule
            loanCreationResultDto = loanAccountServiceFacade.createLoan(loanAccountDetails, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow, installmentDates, totalInstallmentAmounts);
        } else {
            loanCreationResultDto = loanAccountServiceFacade.createLoan(loanAccountDetails, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow);
        }
    }
    List<CommonsMultipartFile> formFiles = formBean.getFiles();
    List<UploadedFileDto> filesMetadata = formBean.getFilesMetadata();
    for (int i = 0; i < formFiles.size(); i++) {
        if (formFiles.get(i).getSize() != 0) {
            InputStream inputStream;
            try {
                inputStream = formFiles.get(i).getInputStream();
            } catch (IOException e) {
                throw new MifosRuntimeException();
            }
            UploadedFileDto fileMetadata = filesMetadata.get(i);
            loanAccountServiceFacade.uploadFile(loanCreationResultDto.getAccountId(), inputStream, fileMetadata);
        }
    }
    return loanCreationResultDto;
}
Also used : InputStream(java.io.InputStream) GroupMemberAccountDto(org.mifos.clientportfolio.newloan.applicationservice.GroupMemberAccountDto) IOException(java.io.IOException) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) DateTime(org.joda.time.DateTime) CommonsMultipartFile(org.springframework.web.multipart.commons.CommonsMultipartFile) RecurringSchedule(org.mifos.clientportfolio.loan.service.RecurringSchedule) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) LoanCreationResultDto(org.mifos.dto.screen.LoanCreationResultDto) CreateGlimLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateGlimLoanAccount) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

UploadedFileDto (org.mifos.dto.screen.UploadedFileDto)9 IOException (java.io.IOException)3 FormFile (org.apache.struts.upload.FormFile)3 LocalDate (org.joda.time.LocalDate)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)2 CreateAccountFeeDto (org.mifos.dto.domain.CreateAccountFeeDto)2 CreateAccountPenaltyDto (org.mifos.dto.domain.CreateAccountPenaltyDto)2 ClientFamilyDetailDto (org.mifos.dto.screen.ClientFamilyDetailDto)2 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)2 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)2 FileInfoEntity (org.mifos.framework.fileupload.domain.FileInfoEntity)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CommonsMultipartFile (org.springframework.web.multipart.commons.CommonsMultipartFile)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 BigDecimal (java.math.BigDecimal)1