/** * Determine if this inbound file for voucher processing has been presented before. 1. Check if a * camunda process is in flight 2. * * @param processBusinessKey * @return */ public boolean matchFile(String processBusinessKey) { boolean isMatched = true; Job job = jobStore.findJob(processBusinessKey); GetReceivedFilesResponse getReceivedFilesResponse = getReceivedFilesResponse(job); if (getReceivedFilesResponse == null) return false; File sourceFile = new File(lockerPath, processBusinessKey); log.info("MatchReceivedFilesRoute || sourceFile path - " + sourceFile.getAbsolutePath()); if (!sourceFile.exists()) { log.error("SourceFile Does not exist --" + sourceFile.getAbsolutePath()); return false; } File[] receivedFile = sourceFile.listFiles( new FilenameFilter() { public boolean accept(File dir, String filename) { return filename.endsWith(".DAT"); } }); File receivedFileName = receivedFile[0]; log.info("MatchReceivedFilesRoute || receivedDatFile name - " + receivedFileName.getName()); List<String> fileNameInFileList = getFileNamesInFile(receivedFileName); log.info("MatchReceivedFilesRoute || fileNameInDATFile - Size - " + fileNameInFileList.size()); MatchFilesResponse matchFilesResponse = matchReceivedFileNames(getReceivedFilesResponse.getReceivedFiles(), fileNameInFileList); Activity parameterActivity = new Activity(); parameterActivity.setPredicate("match"); parameterActivity.setSubject("receivedfiles"); parameterActivity.setJobIdentifier(processBusinessKey); parameterActivity.setResponse(matchFilesResponse); parameterActivity.setRequestDateTime(new Date()); job.getActivities().add(parameterActivity); if ((matchFilesResponse.getUnmatchedFilesFromDats().size() != 0) || (matchFilesResponse.getUnmatchedFilesReceiveds().size() != 0)) { isMatched = false; } log.info("MatchReceivedFilesRoute || isMatched - " + isMatched); return isMatched; }
@Override public UnpackageListingRequest transform(Job job) { UnpackageListingRequest request = new UnpackageListingRequest(); request.setJobIdentifier(job.getJobIdentifier()); return request; }
private GetReceivedFilesResponse getReceivedFilesResponse(Job job) { for (Activity activity : job.getActivities()) { if (activity.getSubject().equals("receivedfiles") && activity.getPredicate().equals("get")) { return (GetReceivedFilesResponse) activity.getResponse(); } } return null; }
@Override public GetVouchersRequest transform(Job job) { GetVouchersRequest request = new GetVouchersRequest(); request.setJobIdentifier(job.getJobIdentifier()); request.setVoucherStatusFrom(VoucherStatus.PENDING); request.setVoucherStatusTo(VoucherStatus.NEW); return request; }
@Override public GenerateBatchBulkCreditRequest transform(Job job) { GenerateBatchBulkCreditRequest request = new GenerateBatchBulkCreditRequest(); request.setJobIdentifier(job.getJobIdentifier()); // We need at least an empty voucher in the response to hold the Credit value for all the Debit // in the bulk. request.setMaxDebitVouchers(metadataRetriever.retrieveMaxQuerySize() - 1); List<VoucherGroupCriteria> voucherGroupCriteriaList = buildVoucherGroupCriteriaList(job); request.getVouchers().addAll(voucherGroupCriteriaList); return request; }
private List<VoucherGroupCriteria> buildVoucherGroupCriteriaList(Job job) { File vouchersDirectory = new File(lockerPath, job.getJobIdentifier()); List<VoucherInformation> collectedVoucherInfoList = voucherCollector.collectVoucherInformationFrom(vouchersDirectory); List<VoucherGroupCriteria> voucherGroupCriteriaList = new ArrayList<>(collectedVoucherInfoList.size()); VoucherGroupCriteria voucherGroupCriteria = null; for (VoucherInformation collectedVoucherInfo : collectedVoucherInfoList) { voucherGroupCriteria = new VoucherGroupCriteria(); voucherGroupCriteria.setDocumentReferenceNumber( collectedVoucherInfo.getVoucher().getDocumentReferenceNumber()); voucherGroupCriteria.setProcessingDate(collectedVoucherInfo.getVoucher().getProcessingDate()); voucherGroupCriteria.setCaptureBsb(collectedVoucherInfo.getVoucherBatch().getCaptureBsb()); voucherGroupCriteriaList.add(voucherGroupCriteria); } return voucherGroupCriteriaList; }