BrightSide Workbench Full Report + Source Code
KnowledgeBaseVM.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2016 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 
19 package org.turro.dossier.kb;
20 
21 import java.util.Set;
22 import org.turro.dossier.entity.Category;
23 import org.turro.dossier.entity.Dossier;
24 import org.turro.dossier.entity.Issue;
25 import org.turro.dossier.entity.IssueStatus;
26 import org.turro.dossier.entity.IssueType;
27 import org.turro.dossier.issue.IssueWrapper;
28 import org.turro.dossier.util.DossiersInfo;
29 import org.turro.dossier.zul.attach.IssueAttachTree;
30 import org.turro.dossier.zul.menu.DossierMenu;
31 import org.turro.elephant.context.Application;
32 import org.turro.i18n.I_;
33 import org.turro.plugin.contacts.IContact;
34 import org.turro.registry.Changes;
35 import org.turro.zkoss.dialog.SelectionDialog;
36 import org.turro.zul.frame.Framework;
37 import org.zkoss.bind.annotation.BindingParam;
38 import org.zkoss.bind.annotation.Command;
39 import org.zkoss.bind.annotation.NotifyChange;
40 
45 public class KnowledgeBaseVM {
46 
47  private final KnowledgeBaseQuery query;
48 
49  public KnowledgeBaseVM() {
50  query = new KnowledgeBaseQuery();
51  }
52 
53  @Command
54  public void showInfo(@BindingParam("item") IssueWrapper item) {
56  if(app.isInRole("issue:show") &&
57  (app.isInRole("issue:all") || item.isFullParticipant())) {
58  DossiersInfo.popup(item.getIssue());
59  }
60  }
61 
62  @NotifyChange("model")
63  @Command("update")
64  public void update() {}
65 
66  @NotifyChange("model")
67  @Command
68  public void selectEntity(@BindingParam("entity") Object entity) {
69  if(entity instanceof Category) {
70  setSelectedCategory((Category) entity);
71  setSelectedDossier(null);
72  } else if(entity instanceof Dossier) {
73  setSelectedDossier((Dossier) entity);
74  setSelectedCategory(null);
75  } else {
76  setSelectedCategory(null);
77  setSelectedDossier(null);
78  }
79  }
80 
81  @NotifyChange("model")
82  @Command
83  public void selectContact(@BindingParam("contact") IContact contact) {
84  setParticipant(contact);
85  }
86 
87  @Command
88  public void showAttachments(@BindingParam("issue") Issue issue) {
90  IssueWrapper iw = new IssueWrapper(issue);
91  if(app.isInRole("issue:show") &&
92  (app.isInRole("issue:all") || iw.isFullParticipant())) {
93  IssueAttachTree iat = new IssueAttachTree();
94  iat.setEntity(issue);
95  iat.setChanges(new Changes());
96  SelectionDialog.showComponent(Framework.getCurrent().getPage(), I_.get("Attachments"),
97  iat, "80%", "80%", null);
98  }
99  }
100 
101  @Command
102  public void addInformation(@BindingParam("issue") Issue issue) {
103  DossierMenu.addInformation(issue, null);
104  }
105 
106  public void setSearchValue(String searchValue) {
107  query.setSearchValue(searchValue);
108  }
109 
110  public String getSearchValue() {
111  return query.getSearchValue();
112  }
113 
114  public boolean isOnlyTitle() {
115  return query.isOnlyTitle();
116  }
117 
118  public void setOnlyTitle(boolean onlyTitle) {
119  query.setOnlyTitle(onlyTitle);
120  }
121 
122  public void setSelectedCategory(Category category) {
123  query.setCategory(category);
124  }
125 
127  return query.getCategory();
128  }
129 
130  public void setSelectedDossier(Dossier dossier) {
131  query.setDossier(dossier);
132  }
133 
135  return query.getDossier();
136  }
137 
138  public void setParticipant(IContact contact) {
139  query.setByParticipant(contact);
140  }
141 
143  return query.getByParticipant();
144  }
145 
146  public Set<IssueStatus> getStatus() {
147  return query.getStatus();
148  }
149 
150  public void setStatus(Set<IssueStatus> status) {
151  query.setStatus(status);
152  }
153 
154  public Set<IssueType> getTypes() {
155  return query.getTypes();
156  }
157 
158  public void setTypes(Set<IssueType> types) {
159  query.setTypes(types);
160  }
161 
162  public int getMaxResults() {
163  return query.getMaxResults();
164  }
165 
166  public void setMaxResults(int maxResults) {
167  query.setMaxResults(maxResults);
168  }
169 
171  return query.getResultList();
172  }
173 
174 }
175 
void setByParticipant(IContact byParticipant)
void setStatus(Set< IssueStatus > status)
void selectEntity(@BindingParam("entity") Object entity)
void selectContact(@BindingParam("contact") IContact contact)
void addInformation(@BindingParam("issue") Issue issue)
void setStatus(Set< IssueStatus > status)
void setTypes(Set< IssueType > types)
void showInfo(@BindingParam("item") IssueWrapper item)
void showAttachments(@BindingParam("issue") Issue issue)
void setSelectedCategory(Category category)
void setSearchValue(String searchValue)
static void popup(Issue issue)
static void addInformation(Issue issue, final Command command)
static String get(String msg)
Definition: I_.java:41
static void showComponent(Page page, String title, Component component, String width, String height, final Command command)
static Framework getCurrent()
Definition: Framework.java:203