コード例 #1
0
  private MatchFilesResponse matchReceivedFileNames(
      List<ReceivedFile> receivedFilenames, List<String> fileNameInFileList) {
    MatchFilesResponse response = new MatchFilesResponse();
    List<String> fileNameList = new ArrayList<>();

    for (ReceivedFile receivedFilename : receivedFilenames) {
      fileNameList.add(receivedFilename.getFileIdentifier());

      boolean isMatched =
          findReceivedInFile(receivedFilename.getFileIdentifier(), fileNameInFileList);
      if (!isMatched) {
        log.info(
            "MatchReceivedFilesRoute || not matched || getUnmatchedFilesReceiveds --"
                + receivedFilename);
        response.getUnmatchedFilesReceiveds().add(receivedFilename.getFileIdentifier());
      }
    }

    for (String fileName : fileNameInFileList) {

      boolean isMatched = findReceivedInFile(fileName, fileNameList);
      if (!isMatched) {
        log.info(
            "MatchReceivedFilesRoute || not matched || getUnmatchedFilesFromDats --" + fileName);
        response.getUnmatchedFilesFromDats().add(fileName);
      }
    }

    return response;
  }
コード例 #2
0
  /**
   * 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;
  }