19 package org.turro.dossier.zul.dossier;
21 import java.util.List;
22 import org.turro.action.queue.ConstraintKeys;
23 import org.turro.dossier.db.DossierPU;
24 import org.turro.dossier.dossier.ParticipantSet;
25 import org.turro.dossier.entity.CategoryParticipant;
26 import org.turro.dossier.entity.Participant;
27 import org.turro.dossier.entity.ParticipantRequest;
28 import org.turro.elephant.db.WhereClause;
29 import org.turro.elephant.util.DateFormats;
30 import org.turro.elephant.util.Images;
31 import org.turro.entities.Entities;
32 import org.turro.i18n.I_;
33 import org.turro.jpa.Dao;
34 import org.turro.mail.queue.QueueManager;
35 import org.turro.zkoss.grid.PagingGrid;
36 import org.zkoss.zk.ui.Component;
37 import org.zkoss.zk.ui.event.Event;
38 import org.zkoss.zk.ui.event.Events;
39 import org.zkoss.zk.ui.ext.AfterCompose;
40 import org.zkoss.zul.Button;
41 import org.zkoss.zul.Checkbox;
42 import org.zkoss.zul.Column;
43 import org.zkoss.zul.Columns;
44 import org.zkoss.zul.Hlayout;
45 import org.zkoss.zul.Label;
46 import org.zkoss.zul.Row;
58 private void addColumns() {
59 Columns cols =
new Columns();
60 cols.setSizable(
true);
63 Column col =
new Column(
I_.
get(
"Contact"));
65 cols.appendChild(col);
66 col =
new Column(
I_.
get(
"Creation"));
67 col.setWidth(
"150px");
68 cols.appendChild(col);
69 col =
new Column(
I_.
get(
"Dossier"));
71 cols.appendChild(col);
73 col.setTooltiptext(
I_.
get(
"Coordinator"));
76 cols.appendChild(col);
78 col.setTooltiptext(
I_.
get(
"Beneficiary"));
81 cols.appendChild(col);
83 col.setTooltiptext(
I_.
get(
"Offerer"));
86 cols.appendChild(col);
88 col.setTooltiptext(
I_.
get(
"R&D"));
91 cols.appendChild(col);
93 col.setTooltiptext(
I_.
get(
"Funding"));
96 cols.appendChild(col);
98 col.setTooltiptext(
I_.
get(
"Support"));
100 col.setWidth(
"25px");
101 cols.appendChild(col);
103 col.setTooltiptext(
I_.
get(
"Consortium"));
105 col.setWidth(
"25px");
106 cols.appendChild(col);
107 col =
new Column(
"");
109 cols.appendChild(col);
112 private void addRows() {
113 WhereClause wc =
new WhereClause();
114 wc.addClause(
"select pr from ParticipantRequest pr");
115 wc.addClause(
"order by idContact, dossier.id");
116 List<ParticipantRequest> prs = getDao().getResultList(wc);
117 for(ParticipantRequest pr : prs) {
119 row.appendChild((Component) Entities.getController(pr.getIContact().getContact()).getLabelCtrl());
120 row.appendChild(
new Label(DateFormats.format(pr.getCreation(),
true)));
121 row.appendChild((Component) Entities.getController(pr.getDossier()).getLabelCtrl());
122 Checkbox asCoordinator =
new Checkbox();
123 asCoordinator.setChecked(pr.isCoordinator());
124 row.appendChild(asCoordinator);
125 Checkbox asBeneficiary =
new Checkbox();
126 asBeneficiary.setChecked(pr.isBeneficiary());
127 row.appendChild(asBeneficiary);
128 Checkbox asOfferer =
new Checkbox();
129 asOfferer.setChecked(pr.isOfferer());
130 row.appendChild(asOfferer);
131 Checkbox asResearch =
new Checkbox();
132 asResearch.setChecked(pr.isResearch());
133 row.appendChild(asResearch);
134 Checkbox asFunding =
new Checkbox();
135 asFunding.setChecked(pr.isFunding());
136 row.appendChild(asFunding);
137 Checkbox asSupport =
new Checkbox();
138 asSupport.setChecked(pr.isSupport());
139 row.appendChild(asSupport);
140 Checkbox asConsortium =
new Checkbox();
141 asConsortium.setChecked(pr.isConsortium());
142 row.appendChild(asConsortium);
143 Hlayout hbox =
new Hlayout();
144 Button add =
new Button(I_.get(
"Add"));
145 add.addEventListener(Events.ON_CLICK, (Event event) -> {
146 Participant participant = pr.getDossier().addOrReturnAssistant(pr.getIContact());
147 participant.setDiscriminator(pr.getDiscriminator());
148 participant.setBeneficiary(asBeneficiary.isChecked());
149 participant.setCoordinator(asCoordinator.isChecked());
150 participant.setFunding(asFunding.isChecked());
151 participant.setOfferer(asOfferer.isChecked());
152 participant.setResearch(asResearch.isChecked());
153 participant.setSupport(asSupport.isChecked());
154 participant.setConsortium(asConsortium.isChecked());
155 getDao().saveObject(pr.getDossier());
156 CategoryParticipant cp;
157 ParticipantSet ps = new ParticipantSet(pr.getDossier().getCategory().getParticipants());
158 if(ps.isParticipant(pr.getIContact())) {
159 cp = (CategoryParticipant) ps.getActiveParticipation(pr.getIContact());
161 cp = pr.getDossier().getCategory().addAssistant(pr.getIContact());
163 cp.setShowAllIssues(
true);
164 getDao().saveObject(pr.getDossier().getCategory());
165 getDao().deleteObject(pr);
166 new QueueManager().subscribeDefaults(ConstraintKeys.from(pr.getIContact()));
169 hbox.appendChild(add);
170 Button
delete =
new Button(I_.get(
"Delete"));
171 delete.addEventListener(Events.ON_CLICK, (Event event) -> {
172 getDao().deleteObject(pr);
175 hbox.appendChild(
delete);
176 row.appendChild(hbox);
177 row.getChildren().stream().filter((o) -> (o instanceof AfterCompose)).forEachOrdered((o) -> {
178 ((AfterCompose) o).afterCompose();
180 getRows(
true).appendChild(row);
193 private Dao getDao() {
static String getImage(String image)
static String get(String msg)
Rows getRows(boolean create)