Examples of UploadFileResult


Examples of org.cipres.treebase.domain.study.UploadFileResult

    // get user's Submission Object
    Study study = ControllerUtil.findStudy(request, mStudyService);
    Submission submission = study.getSubmission();
    MyProgressionListener listener = new MyProgressionListener();

    UploadFileResult uploadResult = getSubmissionService().addNexusFilesJDBC(
      submission,
      files,
      listener);

    request.getSession().setAttribute("uploadMatrixCount", "" + uploadResult.getMatrixCount());
    request.getSession().setAttribute("uploadTreeCount", "" + uploadResult.getTreeCount());
    request.getSession().setAttribute("uploadFileName", firstFile);

    return new ModelAndView(getSuccessView());
  }
View Full Code Here

Examples of org.cipres.treebase.domain.study.UploadFileResult

    Submission sub = getPseudoSubmission();
    Study study = sub.getStudy();
   
    log("submission ID = " + sub.getId() + " study ID " + study.getId());

    UploadFileResult uploadResult = ContextManager.getSubmissionService().addNexusFilesJDBC(sub, files, null);
//    commitTransaction();
    log("added " + uploadResult.getMatrixCount() + " matrices and " + uploadResult.getTreeCount() + " trees.");

    return study;
  }
View Full Code Here

Examples of org.cipres.treebase.domain.study.UploadFileResult

    int countMatrices = 0, countTrees = 0;
    for (File f : files) {
      beginTransaction();
      List<File> theFile = new LinkedList<File> ();
      theFile.add(f);
      UploadFileResult uploadResult = ContextManager.getSubmissionService().addNexusFilesJDBC(sub, theFile, null);
      commitTransaction();
      log("added " + uploadResult.getMatrixCount() + " matrices and " + uploadResult.getTreeCount() + " trees.");
      countMatrices += uploadResult.getMatrixCount();
      countTrees += uploadResult.getTreeCount();
    }
    log("Added in his batch: " + countMatrices + " matrices, " + countTrees + " trees.");
    return study;   
  }
View Full Code Here

Examples of org.cipres.treebase.domain.study.UploadFileResult

  public UploadFileResult addNexusFilesJDBC(
    Submission pSubmission,
    Collection<File> pNexusFiles,
    ProgressionListener pListener) {

    UploadFileResult result = new UploadFileResult();
    if (pSubmission == null) {
      if (LOGGER.isInfoEnabled()) {
        LOGGER.info("processNexusFiles() - Submission is null"); //$NON-NLS-1$
      }
      return result;
    }

    if (!checkFiles(pNexusFiles)) {
      return result;
    }

    int fileCount = pNexusFiles.size();
    int processedCount = 0;

    long timeStart = System.currentTimeMillis();

    int matrixCount = 0;
    int treeCount = 0;
   
    // Process one file at a time:
    for (File file : pNexusFiles) {

      long timeFile = System.currentTimeMillis();

      NexusDataSet dataSet = null;
      try {
        // first start a transaction, use Hibernate to add and persist most of the data
        dataSet = addNexusFile(pSubmission, file);
        NexusDataSetJDBC dataJDBC = dataSet.getDataJDBC();

        // Next use direct JDBC to batch insert data, for performance reason.
        // getDomainHome().refreshAll(dataJDBC.getAllMatrices());

        // TODO: create a new method:
        Connection conn = getSubmissionHome().getConnection();
        for (MatrixJDBC matrixJDBC : dataJDBC.getMatrixJDBCList()) {
          matrixJDBC.batchInsertColumn(conn);
          matrixJDBC.prepElementBatchInsert(conn);
          matrixJDBC.processMatrixElements(conn);
          // MesquiteMatrixConverter converter = matrixJDBC.getMesqMatrixConverter();
          // converter.processMatrixElements(matrixJDBC, conn);

          matrixJDBC.batchInsertCompoundElements(conn);
          matrixCount ++;
        }

        treeCount += dataSet.getTotalTreeCount();

        // ALERT: Do not use. will get connection closed exception!
        // try {
        // conn.close();
        // } catch (SQLException ex) {
        // throw new CleanupFailureDataAccessException("Failed to close connection.", ex);
        // }
      } finally {
        // Dispose the mesquite project after all usage:
        if (dataSet != null && dataSet.getMesqProject()!=null) dataSet.getMesqProject().dispose();
      }
     
      for (Matrix m : dataSet.getMatrices()) {
        getMatrixHome().refresh(m);
        m.setDimensions();
        getMatrixHome().merge(m);
      }

      // TODO: if pListener is not null, launch a thread to do the parsing.
      processedCount++;
      if (pListener != null) {
        pListener.updateProgress(processedCount, fileCount);
      }

      if (LOGGER.isDebugEnabled()) {
        long timeFileEnd = System.currentTimeMillis();
        LOGGER.debug("one file time=" + (timeFileEnd - timeFile) / 1000); //$NON-NLS-1$
      }

    }

    // Third start a new transaction, use Hibernate to store the original nexus files.
    Study study = pSubmission.getStudy();
    getStudyService().addNexusFiles(study, pNexusFiles);
   
    if (LOGGER.isDebugEnabled()) {
      long timeEnd = System.currentTimeMillis();
      LOGGER.debug("total time=" + (timeEnd - timeStart) / 1000); //$NON-NLS-1$
      LOGGER.debug("total matrix=" + matrixCount + " treeCount =" + treeCount); //$NON-NLS-1$
    }
   
    result.setMatrixCount(matrixCount);
    result.setTreeCount(treeCount);
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.