Пример #1
0
 public Branch trunk(Session session) {
   if (getBranches() != null) {
     for (Branch b : getBranches()) {
       if (Branch.TRUNK.equals(b.getName())) {
         return b;
       }
     }
   }
   return null;
 }
Пример #2
0
 public void delete(Session session) {
   if (getBranches() != null) {
     for (Branch b : getBranches()) {
       b.delete(session);
     }
     setBranches(null);
   }
   if (getNvPairs() != null) {
     for (NvPair p : getNvPairs()) {
       p.delete(session);
     }
     setNvPairs(null);
   }
   session.delete(this);
 }
Пример #3
0
  /**
   * Creates and saves a new branch, including setting up initial commit etc
   *
   * @param name
   * @param user
   * @param session
   * @return
   */
  public Branch createBranch(String name, Profile user, Session session) {
    Commit head = new Commit();
    head.setCreatedDate(new Date());
    head.setEditor(user);
    head.setItemHash(null);
    session.save(head);

    Branch b = new Branch();
    b.setName(Branch.TRUNK);
    b.setRepository(this);
    b.setHead(head);
    session.save(b);

    if (getBranches() == null) {
      setBranches(new ArrayList<Branch>());
    }
    getBranches().add(b);

    return b;
  }