19 package org.turro.deliverables.model;
21 import java.io.IOException;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.Optional;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import org.turro.string.Strings;
28 import org.turro.elephant.util.Messages;
29 import org.turro.entities.Entities;
30 import org.turro.entities.IElephantEntity;
31 import org.turro.file.Document;
32 import org.turro.file.FileWrapper;
33 import org.turro.file.Folder;
34 import org.turro.security.ConceptPermission;
35 import org.turro.upload.Medias;
36 import org.zkoss.bind.BindUtils;
37 import org.zkoss.bind.annotation.BindingParam;
38 import org.zkoss.bind.annotation.Command;
39 import org.zkoss.bind.annotation.ExecutionArgParam;
40 import org.zkoss.bind.annotation.Init;
41 import org.zkoss.bind.annotation.NotifyChange;
42 import org.zkoss.util.media.Media;
43 import org.zkoss.zk.ui.Executions;
52 private boolean canView, canCreate;
55 public void init(@ExecutionArgParam(
"entityPath") String entityPath) {
56 if(Strings.isBlank(entityPath)) {
57 entityPath = Executions.getCurrent().getParameter(
"entityPath");
59 if(!Strings.isBlank(entityPath)) {
79 @NotifyChange(
"model")
81 public
void upload(@BindingParam("medias") Media medias[]) {
84 for(Media media : medias) {
91 public
void download(@BindingParam("document") Document document) {
96 public
void deleteDoc(@BindingParam("document") Document document) {
99 BindUtils.postNotifyChange(
null,
null,
DeliverablesVM.this,
"model");
106 if(folder !=
null && folder.exists())
return folder.documents();
107 }
catch (IOException ex) {
108 Logger.getLogger(
DeliverablesVM.class.getName()).log(Level.SEVERE,
null, ex);
110 return Collections.EMPTY_LIST;
113 private void prepareValues() {
115 .ifPresentOrElse(permission -> {
116 canCreate = permission.canAct();
117 canView = permission.canShow();
void deleteDoc(@BindingParam("document") Document document)
void upload(@BindingParam("medias") Media medias[])
void init(@ExecutionArgParam("entityPath") String entityPath)
List< Document > getModel()
void download(@BindingParam("document") Document document)
static Messages confirmDeletion()
Messages add(String word)
static IElephantEntity getController(String path)
static IElephantEntity emptyController()
ConceptPermission getConceptPermission(String name)