예제 #1
0
  public ArrayList<TraceSequenceAnalysis> getTraceSequences(String userId, long entryId) {
    Entry entry = dao.get(entryId);
    if (entry == null) return null;

    authorization.expectRead(userId, entry);
    List<TraceSequence> sequences = DAOFactory.getTraceSequenceDAO().getByEntry(entry);

    ArrayList<TraceSequenceAnalysis> analysisArrayList = new ArrayList<>();
    if (sequences == null) return analysisArrayList;

    AccountController accountController = new AccountController();

    for (TraceSequence traceSequence : sequences) {
      TraceSequenceAnalysis analysis = traceSequence.toDataTransferObject();
      AccountTransfer accountTransfer = new AccountTransfer();

      String depositor = traceSequence.getDepositor();
      boolean canEdit = canEdit(userId, depositor, entry);
      analysis.setCanEdit(canEdit);

      Account account = accountController.getByEmail(traceSequence.getDepositor());
      if (account != null) {
        accountTransfer.setFirstName(account.getFirstName());
        accountTransfer.setLastName(account.getLastName());
        accountTransfer.setEmail(account.getEmail());
        accountTransfer.setId(account.getId());
      }

      analysis.setDepositor(accountTransfer);
      analysisArrayList.add(analysis);
    }

    return analysisArrayList;
  }
예제 #2
0
  public boolean deleteTraceSequence(String userId, long entryId, long traceId) {
    Entry entry = dao.get(entryId);
    if (entry == null) return false;

    TraceSequenceDAO traceSequenceDAO = DAOFactory.getTraceSequenceDAO();
    TraceSequence traceSequence = traceSequenceDAO.get(traceId);
    if (traceSequence == null || !canEdit(userId, traceSequence.getDepositor(), entry))
      return false;

    try {
      new SequenceAnalysisController().removeTraceSequence(traceSequence);
    } catch (Exception e) {
      Logger.error(e);
      return false;
    }
    return true;
  }