19 package org.turro.dossier.zul.www;
21 import java.util.Date;
22 import java.util.EnumSet;
23 import java.util.List;
24 import java.util.stream.Collectors;
25 import org.turro.string.ObjectString;
26 import org.turro.string.Strings;
27 import org.turro.action.IAgreements;
28 import org.turro.action.Plugins;
29 import org.turro.auth.Authentication;
30 import org.turro.collections.CollectionUtil;
31 import org.turro.dossier.db.DossierPU;
32 import org.turro.dossier.dossier.DescriptorSet;
33 import org.turro.dossier.dossier.DossierWrapper;
34 import org.turro.dossier.entity.Category;
35 import org.turro.dossier.entity.DescriptorType;
36 import org.turro.dossier.entity.Dossier;
37 import org.turro.dossier.entity.DossierStatus;
38 import org.turro.dossier.entity.DossierType;
39 import org.turro.dossier.entity.Participant;
40 import org.turro.dossier.entity.Project;
41 import org.turro.dossier.project.NewIdeaNotification;
42 import org.turro.elephant.TemplateControl;
43 import org.turro.elephant.context.Application;
44 import org.turro.jpa.Dao;
45 import org.turro.phase.PhaseType;
46 import org.turro.plugin.contacts.IContact;
47 import org.turro.tags.TagItem;
48 import org.turro.tags.Tags;
49 import org.turro.tags.TagsChosenbox;
50 import org.turro.util.CompareUtil;
51 import org.turro.zkoss.input.ExpressionInput;
52 import org.zkoss.zk.ui.event.InputEvent;
53 import org.zkoss.zk.ui.select.annotation.Listen;
54 import org.zkoss.zk.ui.select.annotation.Wire;
55 import org.zkoss.zul.Div;
56 import org.zkoss.zul.Textbox;
65 private String grouping, path;
66 private boolean required;
69 @Wire(
"#title")
private Textbox title;
71 @Wire(
"#goal")
private Textbox goal;
72 @Wire(
"#searching")
private Textbox searching;
73 @Wire(
"#tagsdiv")
private Div tagsdiv;
75 @Wire(
"#descs")
private Div descs;
77 @Listen(
"onSelect=#category")
80 "?item=" + dossier.
getId() +
85 @Listen(
"onChange=#title")
91 @Listen(
"onChange=#estimatedBudget")
97 @Listen(
"onChange=#goal")
102 @Listen(
"onChange=#searching")
107 @Listen(
"onSelect=#tags")
111 .stream().map(s -> s.getTagName()).collect(Collectors.toSet()));
114 @Listen(
"onSearch=#tags")
116 String value =
event.getValue();
118 if(!Strings.isBlank(value)) {
124 @Listen(
"onClick=#save")
126 boolean wasNew = dossier.
getId() ==
null || dossier.
getId() < 1;
142 this.grouping = grouping;
158 this.required = required;
162 this.dossier = dossier;
168 if(!
"all".equals(grouping)) {
169 CollectionUtil.from(ds).remove(e -> {
170 return CompareUtil.compare(grouping, e.getGrouping()) != 0 ||
171 CompareUtil.compare(required, e.isRequired()) != 0;
175 CollectionUtil.from(ds).remove(e -> {
187 if(!agreements.
isValid() || !agreements.
canAct(
"project-new")) {
195 private void checkDossier() {
196 if(dossier ==
null) {
199 dossier = getDao().find(
Dossier.class, dossierId);
202 IContact contact = Authentication.getIContact();
203 if(dossier ==
null) {
204 dossier =
new Dossier();
206 dossier.
setStatus(DossierStatus.DOSSIER_OPENED);
207 dossier.
setType(DossierType.TYPE_PROJECT);
209 Project project =
new Project();
212 project.setDossier(dossier);
213 project.setChangePhase(
new Date());
218 Long catId = (Long) ObjectString.parseString(Application.getApplication().getConstructor().getParameter(
"cat"), Long.class,
true);
220 Category cat = getDao().find(Category.class, catId);
226 private void initComponents() {
227 IContact contact = Authentication.getIContact();
230 Application.getApplication().isInRole(
"dossier:all")) {
236 String entityPath = DossierPU.getObjectPath(dossier);
238 tagsdiv.setVisible(!dossier.
isNew());
240 Application.getApplication().sendRedirect(
"/user");
248 private Dao getDao() {
250 _dao =
new DossierPU();
255 private Category getDefaultCategory() {
256 Long catId = (Long) ObjectString.parseString(Application.getApplication().getConstructor().getParameter(
"cat"), Long.class,
true);
258 Category cat = getDao().find(Category.class, catId);
259 if(cat !=
null)
return cat;
261 List<Category> list = getDao().getResultList(
262 "select c from Category c where ownsProjects = TRUE order by description"
264 if(!list.isEmpty()) {
static< T > T loadImplementation(Class< T > jclass)
static IContact getIContact()
static String getObjectPath(Object object)
boolean isEmptyDescriptors(String grouping, boolean required)
void setCategory(Category category)
DescriptorSet getDescriptorSet()
void setType(DossierType type)
ParticipantSet< IDossierParticipant > getFullParticipants()
void setPublishable(boolean publishable)
void setProject(Project project)
void setDescription(String description)
void setSearching(String searching)
void setStatus(DossierStatus status)
Participant addAssistant(IContact contact)
void setDriver(boolean driver)
void setProjectTitle(String projectTitle)
void setEstimatedBudget(double estimatedBudget)
void setGoal(String goal)
double getEstimatedBudget()
PhaseDefinition getPhaseDefinition()
void setPath(String path)
DescriptorSet getDescriptors()
void onNewTag(InputEvent event)
void setRequired(boolean required)
void setGrouping(String grouping)
void setDossier(Dossier dossier)
IConstructor getConstructor()
abstract void sendRedirect(String uri)
static Application getApplication()
boolean anyTypeMatch(Collection< PhaseType > types)
void setContact(IContact contact)
String getPendingActURL(String action)
boolean canAct(String action)
String getParameter(String param)