BrightSide Workbench Full Report + Source Code
IssueDetailSet.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.dossier.issue;
19 
20 import java.util.TreeSet;
21 import org.turro.attach.db.AttachPU;
22 import org.turro.attach.entity.Attachment;
23 import org.turro.commentit.CommentItUtil;
24 import org.turro.dossier.db.DossierPU;
25 import org.turro.dossier.entity.Issue;
26 import org.turro.dossier.entity.IssueComment;
27 import org.turro.dossier.entity.IssuePredecessor;
28 import org.turro.jpa.Dao;
29 import org.turro.sql.SqlClause;
30 import org.turro.starit.StarItUtil;
31 import org.turro.voteit.VoteItUtil;
32 
37 public class IssueDetailSet extends TreeSet {
38 
39  public IssueDetailSet(Issue issue) {
40  super(new IssueDetailComparator());
41  addDetail(issue);
42  }
43 
44  private void addDetail(Issue issue) {
45  String path = DossierPU.getObjectPath(issue);
46  Dao dao = new DossierPU();
47  addAll(SqlClause.select("c").from("IssueComment c")
48  .where().equal("c.issue", issue)
49  .dao(dao).resultList(IssueComment.class));
50  addAll(SqlClause.select("p").from("IssuePredecessor p")
51  .where().notEqual("creation", null)
52  .and().group()
53  .equal("p.source", issue)
54  .or().equal("p.target", issue)
55  .endGroup()
56  .dao(dao).resultList(IssuePredecessor.class));
57  addAll(SqlClause.select("a").from("Attachment a")
58  .where().equal("a.path", path)
59  .dao(new AttachPU()).resultList(Attachment.class));
60  addAll(CommentItUtil.allComments(path));
61  addAll(VoteItUtil.allVotes(path));
62  addAll(StarItUtil.allStars(path));
63  }
64 
65 }
static Collection< CommentIt > allComments(Object entity)
static String getObjectPath(Object object)
Definition: DossierPU.java:66
static List< StarIt > allStars(Object entity)
static List< VoteIt > allVotes(String path)