BrightSide Workbench Full Report + Source Code
org.turro.documentation.model.DocumentationVM Class Reference

Public Member Functions

void init (@ExecutionArgParam("entityPath") String entityPath)
 
IElephantEntity getIee ()
 
boolean isCanCreate ()
 
void add (@BindingParam("document") EntityDocumentation document)
 
void upload (@BindingParam("document") EntityDocumentation document, @BindingParam("medias") Media medias[])
 
void download (@BindingParam("document") Document document)
 
void deleteDoc (@BindingParam("document") Document document)
 
void validate (@BindingParam("document") EntityDocumentation document)
 
void deny (@BindingParam("document") EntityDocumentation document)
 
void delete (@BindingParam("document") EntityDocumentation document)
 
void info (@BindingParam("document") DocumentDefinition document)
 
void create ()
 
String getSelectedType ()
 
void setSelectedType (String selectedType)
 
List< String > getDocumentationTypes ()
 
List< EntityDocumentationgetModel ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 67 of file DocumentationVM.java.

Member Function Documentation

◆ add()

void org.turro.documentation.model.DocumentationVM.add ( @BindingParam("document") EntityDocumentation  document)

Definition at line 96 of file DocumentationVM.java.

96  {
97  DocumentDefinition dd = document.getDefinition();
98  if(dd.isAllowMultiple()) {
99  Dialogs.title(I_.get("Add contact"))
100  .width("400px")
101  .height("150px")
102  .addField(DialogField.field("Request to").onEditor(() -> {
103  AssistantListbox al = new AssistantListbox();
104  al.setWebUsers(true);
105  al.setEntityPath(iee.getPath());
106  al.setMold("select");
107  return al;
108  }))
109  .onOk((dialogs) -> {
110  IContact require = dialogs.<AssistantListbox>getEditor("Request to").getObjectValue();
111  if(require != null && require.isValid()) {
112  document.getAssistantIds().add(require.getId());
113  getDao().saveObject(document);
114  BindUtils.postNotifyChange(null, null, DocumentationVM.this, "model");
115  PushSenders.getPool()
116  .addAdministrators()
117  .addContact(require)
118  .send(I_.get("Documentation"), I_.get("Pending upload documents"), document.getEntity().getEntityUrl());
119  MailSenders.getPool().setRoot("/documentation")
120  .addAdministrators()
121  .addContact(require)
122  .silentSendTemplate(document, "required", I_.get("Pending upload documents"));
123  }
124  })
125  .emptyCancel()
126  .show();
127  }
128  }
Here is the call graph for this function:

◆ create()

void org.turro.documentation.model.DocumentationVM.create ( )

Definition at line 242 of file DocumentationVM.java.

242  {
243  Dialogs.title(I_.get("Request new documentation"))
244  .width("400px")
245  .height("500px")
246  .addField(DialogField.field("Request to").onEditor(() -> {
247  AssistantListbox al = new AssistantListbox();
248  al.setWebUsers(true);
249  al.setEntityPath(iee.getPath());
250  al.setMold("select");
251  return al;
252  }))
253  .addField(DialogField.field("Deadline").onEditor(() -> {
254  Datebox dl = new Datebox();
255  dl.setFormat("short");
256  return dl;
257  }))
258  .addField(DialogField.field("Documentation").onEditor(() -> {
259  DocumentationListbox dl = new DocumentationListbox(iee.getRoot());
260  dl.setSelectFirst(false);
261  dl.setCheckmark(true);
262  dl.setMultiple(true);
263  return dl;
264  }))
265  .onOk((dialogs) -> {
266  Collection<DocumentDefinition> dds = dialogs.<DocumentationListbox>getEditor("Documentation").getObjectValues();
267  if(!dds.isEmpty()) {
268  IContact require = dialogs.<AssistantListbox>getEditor("Request to").getObjectValue();
269  if(require != null && require.isValid()) {
270  List<EntityDocumentation> eds = new ArrayList<>();
271  dds.forEach(dd -> {
272  EntityDocumentation ed = new EntityDocumentation();
273  ed.setRequesterId(Authentication.getIContact().getId());
274  ed.setEntityPath(iee.getPath());
275  ed.setContactId(require.getId());
276  ed.setDocumentation(dd.getName());
277  ed.setStatus(EntityDocumentationStatus.PENDING_UPLOAD);
278  ed.setDeadline(dialogs.<Datebox>getEditor("Deadline").getValue());
279  eds.add(ed);
280  });
281  getDao().saveCollection(eds);
282  BindUtils.postNotifyChange(null, null, DocumentationVM.this, "model");
283  EntityDocumentation document = eds.iterator().next();
284  PushSenders.getPool()
285  .addAdministrators()
286  .addContact(require)
287  .send(I_.get("Documentation"), I_.get("Pending upload documents"), document.getEntity().getEntityUrl());
288  MailSenders.getPool().setRoot("/documentation")
289  .addAdministrators()
290  .addContact(require)
291  .silentSendTemplate(document, "required", I_.get("Pending upload documents"));
292  }
293  }
294  })
295  .emptyCancel()
296  .show();
297  }
void saveCollection(Collection objs)
Definition: Dao.java:144
Here is the call graph for this function:

◆ delete()

void org.turro.documentation.model.DocumentationVM.delete ( @BindingParam("document") EntityDocumentation  document)

Definition at line 221 of file DocumentationVM.java.

221  {
222  Messages.confirmDeletion().add(document.getDocumentation()).show(() -> {
223  document.getFolder().remove();
224  getDao().deleteObject(document);
225  BindUtils.postNotifyChange(null, null, DocumentationVM.this, "model");
226  });
227  }
void deleteObject(Object obj)
Definition: Dao.java:162
Here is the call graph for this function:

◆ deleteDoc()

void org.turro.documentation.model.DocumentationVM.deleteDoc ( @BindingParam("document") Document  document)

Definition at line 169 of file DocumentationVM.java.

169  {
170  Messages.confirmDeletion().add(document.name()).show(() -> {
171  document.delete();
172  BindUtils.postNotifyChange(null, null, DocumentationVM.this, "model");
173  });
174  }
Here is the call graph for this function:

◆ deny()

void org.turro.documentation.model.DocumentationVM.deny ( @BindingParam("document") EntityDocumentation  document)

Definition at line 194 of file DocumentationVM.java.

194  {
195  Dialogs.title(I_.get("Deny"))
196  .width("400px")
197  .height("250px")
198  .addField(DialogField.field("Reason").scale(2))
199  .onOk((dialogs) -> {
200  String comment = dialogs.<Textbox>getEditor("Reason").getValue();
201  document.setStatus(EntityDocumentationStatus.DENIED);
202  document.setComment(comment);
203  getDao().saveObject(document);
204  BindUtils.postNotifyChange(null, null, DocumentationVM.this, "model");
205  PushSenders.getPool()
206  .addAdministrators()
207  .addContact(document.getContact())
208  .addContacts(document.getAssistants())
209  .send(I_.get("Documentation"), I_.get("Denied"), document.getEntity().getEntityUrl());
210  MailSenders.getPool().setRoot("/documentation")
211  .addAdministrators()
212  .addContact(document.getContact())
213  .addContacts(document.getAssistants())
214  .silentSendTemplate(document, "denied", I_.get("Denied") + ": " + document.getComment());
215  })
216  .emptyCancel()
217  .show();
218  }
Here is the call graph for this function:

◆ download()

void org.turro.documentation.model.DocumentationVM.download ( @BindingParam("document") Document  document)

Definition at line 164 of file DocumentationVM.java.

164  {
165  new FileWrapper(document.document()).download();
166  }
Here is the call graph for this function:

◆ getDocumentationTypes()

List<String> org.turro.documentation.model.DocumentationVM.getDocumentationTypes ( )

Definition at line 310 of file DocumentationVM.java.

310  {
311  List<String> types = new ArrayList<>();
312  types.add("");
313  types.addAll(model.stream().map(ed -> ed.getDefinition().getName()).distinct().toList());
314  return types;
315  }

◆ getIee()

IElephantEntity org.turro.documentation.model.DocumentationVM.getIee ( )

Definition at line 87 of file DocumentationVM.java.

87  {
88  return iee;
89  }

◆ getModel()

List<EntityDocumentation> org.turro.documentation.model.DocumentationVM.getModel ( )

Definition at line 317 of file DocumentationVM.java.

317  {
318  prepareValues();
319  String orderBy = canCreate ? "ed.status, ed.entityPath, ed.documentation" :
320  "ed.documentation";
321  model = SqlClause.select("ed")
322  .from("EntityDocumentation ed")
323  .where().any()
324  .startIf(!canCreate)
325  .and().group()
326  .and().in("ed.contactId", contactIds)
327  .or().equal("ed.requesterId", contact.getId())
328  .or().members("ed.assistantIds", contactIds)
329  .endGroup()
330  .endIf()
331  .startIf(!iee.isEmpty())
332  .and().equal("ed.entityPath", iee.getPath())
333  .endIf()
334  .startIf(iee.isEmpty())
335  .and().not().equal("ed.status", EntityDocumentationStatus.VALIDATED)
336  .endIf()
337  .orderBy(orderBy)
338  .dao(getDao())
339  .resultList(EntityDocumentation.class);
340  List<EntityDocumentation> invalids = new ArrayList<>();
341  model.removeIf(ed -> !ed.isValid(invalids));
342  if(!invalids.isEmpty()) getDao().deleteCollection(invalids);
343  model.forEach(ed -> ed.reviewStatus());
344  getDao().saveCollection(model);
345  if(!Strings.isBlank(selectedType)) {
346  model.removeIf(ed -> !selectedType.equals(ed.getDefinition().getName()));
347  }
348  return model;
349  }
void deleteCollection(Collection objs)
Definition: Dao.java:175
Here is the call graph for this function:

◆ getSelectedType()

String org.turro.documentation.model.DocumentationVM.getSelectedType ( )

Definition at line 301 of file DocumentationVM.java.

301  {
302  return selectedType;
303  }

◆ info()

void org.turro.documentation.model.DocumentationVM.info ( @BindingParam("document") DocumentDefinition  document)

Definition at line 230 of file DocumentationVM.java.

230  {
231  Dialogs.title(I_.get("Information"))
232  .width("400px")
233  .height("300px")
234  .addComponent(new Label(document.getDescription()))
235  .addComponent(new Space())
236  .addComponent(new DownloadDocuments(I_.get("References"), document.getDocumentsFor(contact)))
237  .emptyClose()
238  .show();
239  }
Here is the call graph for this function:

◆ init()

void org.turro.documentation.model.DocumentationVM.init ( @ExecutionArgParam("entityPath") String  entityPath)

Definition at line 76 of file DocumentationVM.java.

76  {
77  if(Strings.isBlank(entityPath)) {
78  entityPath = Executions.getCurrent().getParameter("entityPath");
79  }
80  if(!Strings.isBlank(entityPath)) {
81  iee = Entities.getController(entityPath);
82  } else {
83  iee = Entities.emptyController();
84  }
85  }
IElephantEntity getController(String entityPath)
Here is the call graph for this function:

◆ isCanCreate()

boolean org.turro.documentation.model.DocumentationVM.isCanCreate ( )

Definition at line 91 of file DocumentationVM.java.

91  {
92  return canCreate;
93  }

◆ setSelectedType()

void org.turro.documentation.model.DocumentationVM.setSelectedType ( String  selectedType)

Definition at line 305 of file DocumentationVM.java.

305  {
306  this.selectedType = selectedType;
307  BindUtils.postNotifyChange(null, null, DocumentationVM.this, "model");
308  }

◆ upload()

void org.turro.documentation.model.DocumentationVM.upload ( @BindingParam("document") EntityDocumentation  document,
@BindingParam("medias") Media  medias[] 
)

Definition at line 132 of file DocumentationVM.java.

132  {
133  DocumentDefinition dd = document.getDefinition();
134  Folder folder = document.getFolder();
135  long count = folder.count();
136  int done = 0;
137  for(Media media : medias) {
138  if(++count > dd.getMax() && !exists(folder, media)) break;
139  if(!dd.isUploadControl() || !guessOverrides(folder, media)) {
140  Medias.toFolder(media, folder);
141  done++;
142  } else {
143  Messages.error().format(I_.get("Download current %s version first!"), media.getName()).show();
144  }
145  }
146  if(count > dd.getMin()) {
147  document.setStatus(EntityDocumentationStatus.PENDING_VALIDATION);
148  }
149  document.reviewStatus();
150  getDao().saveObject(document);
151  if(done > 0) {
152  PushSenders.getPool()
153  .addAdministrators()
154  .addContact(document.getRequester())
155  .send(I_.get("Documentation"), I_.get("Pending to validate"), document.getEntity().getEntityUrl());
156  MailSenders.getPool().setRoot("/documentation")
157  .addAdministrators()
158  .addContact(document.getRequester())
159  .silentSendTemplate(document, "uploaded", I_.get("Pending to validate"));
160  }
161  }
Here is the call graph for this function:

◆ validate()

void org.turro.documentation.model.DocumentationVM.validate ( @BindingParam("document") EntityDocumentation  document)

Definition at line 178 of file DocumentationVM.java.

178  {
179  document.setStatus(EntityDocumentationStatus.VALIDATED);
180  getDao().saveObject(document);
181  PushSenders.getPool()
182  .addAdministrators()
183  .addContact(document.getContact())
184  .addContacts(document.getAssistants())
185  .send(I_.get("Documentation"), I_.get("Validated"), document.getEntity().getEntityUrl());
186  MailSenders.getPool().setRoot("/documentation")
187  .addAdministrators()
188  .addContact(document.getContact())
189  .addContacts(document.getAssistants())
190  .silentSendTemplate(document, "validated", I_.get("Validated"));
191  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: