Ejemplo n.º 1
0
    private Collection<BranchReadable> getBranchesToPurge() throws OseeCoreException {
      Set<BranchReadable> specifiedBranches = new HashSet<BranchReadable>();
      for (Long uuid : branchUuids) {
        if (uuid <= 0) {
          console.writeln("UUID listed %s is not a valid UUID", uuid);
        } else {
          BranchReadable cached =
              queryFactory.branchQuery().andUuids(uuid).getResults().getExactlyOne();
          if (cached != null) {
            specifiedBranches.add(cached);
          }
        }
      }

      Collection<BranchReadable> branchesToPurge =
          recurse ? getChildBranchesToPurge(specifiedBranches) : specifiedBranches;

      Iterator<BranchReadable> iter = branchesToPurge.iterator();
      while (iter.hasNext()) {
        if (filterBranch(iter.next())) {
          iter.remove();
        }
      }
      return branchesToPurge;
    }
Ejemplo n.º 2
0
    private Collection<BranchReadable> getChildBranchesToPurge(Iterable<BranchReadable> branches)
        throws OseeCoreException {

      BranchQuery branchQuery = queryFactory.branchQuery();
      branchQuery.includeArchived();
      branchQuery.includeDeleted();

      if (includeBaseline) {
        branchQuery.andIsOfType(
            BranchType.WORKING, BranchType.MERGE, BranchType.PORT, BranchType.BASELINE);
      } else {
        branchQuery.andIsOfType(BranchType.WORKING, BranchType.MERGE, BranchType.PORT);
      }

      if (includeUndeleted) {
        branchQuery.andStateIs(
            BranchState.CREATED,
            BranchState.MODIFIED,
            BranchState.COMMITTED,
            BranchState.REBASELINED,
            BranchState.DELETED,
            BranchState.REBASELINE_IN_PROGRESS,
            BranchState.COMMIT_IN_PROGRESS,
            BranchState.CREATION_IN_PROGRESS,
            BranchState.DELETE_IN_PROGRESS,
            BranchState.PURGE_IN_PROGRESS,
            BranchState.PURGED);
      } else {
        branchQuery.andStateIs(BranchState.DELETED);
      }

      Set<BranchReadable> results = new HashSet<BranchReadable>();
      for (BranchReadable parent : branches) {
        for (BranchReadable branch : branchQuery.andIsChildOf(parent).getResults()) {
          if (includeUnarchived || branch.getArchiveState() == BranchArchivedState.ARCHIVED) {
            results.add(branch);
          }
        }
      }

      if (recurse) {
        results.addAll(getChildBranchesToPurge(new ArrayList<BranchReadable>(results)));
      }
      return results;
    }
Ejemplo n.º 3
0
 public QueryBuilder build(QueryFactory queryFactory, SearchRequest params)
     throws OseeCoreException {
   Conditions.checkNotNull(queryFactory, "queryFactory");
   Conditions.checkNotNull(params, "params");
   IOseeBranch searchBranch = TokenFactory.createBranch(params.getBranchUuid(), "searchBranch");
   QueryBuilder builder = queryFactory.fromBranch(searchBranch);
   List<Predicate> predicates = params.getPredicates();
   if (predicates != null) {
     for (Predicate predicate : predicates) {
       SearchMethod method = predicate.getType();
       PredicateHandler handler = handlers.get(method);
       if (handler != null) {
         builder = handler.handle(builder, predicate);
       }
     }
   }
   return builder;
 }