19 package org.turro.alliance.client.model;
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.turro.alliance.db.AlliancePU;
24 import org.turro.dossier.entity.ProjectGrant;
25 import org.turro.elephant.util.Toasts;
26 import org.turro.i18n.I_;
27 import org.turro.jpa.Dao;
28 import org.turro.member.db.entities.AxProjectGrantPublic;
29 import org.turro.sql.SqlClause;
30 import org.turro.ws.WsServer;
31 import org.zkoss.bind.annotation.BindingParam;
32 import org.zkoss.bind.annotation.Command;
33 import org.zkoss.bind.annotation.ExecutionArgParam;
34 import org.zkoss.bind.annotation.Init;
35 import org.zkoss.bind.annotation.NotifyChange;
36 import org.zkoss.zk.ui.Executions;
48 if(projectGrant !=
null) this.projectGrant = projectGrant;
49 if(this.projectGrant ==
null) {
50 this.projectGrant = (
ProjectGrant) Executions.getCurrent().getAttribute(
"projectGrant");
59 this.needsSave = needsSave;
62 @NotifyChange(
"model")
65 if(server !=
null && !inModel(server)) {
76 @NotifyChange(
"model")
80 model.stream().filter(pc -> pc.isEmpty())
82 model.removeIf(pc -> pc.isEmpty());
89 @NotifyChange(
"model")
92 deletions.add(pgpublic);
93 model.removeIf(pc -> pc.getServerDomain().equals(pgpublic.getServerDomain()));
99 private boolean needsSave;
101 private List<AxProjectGrantPublic> model;
102 private List<AxProjectGrantPublic> deletions =
new ArrayList<>();
106 model = SqlClause.select(
"pc").from(
"AxProjectGrantPublic pc")
107 .where().equal(
"pc.projectGrantId", String.valueOf(projectGrant.
getId()))
114 private boolean inModel(
WsServer server) {
115 return model.stream().anyMatch(apc -> apc.getServerDomain().equals(server.
getServerDomain()));
127 this.server = server;
List< AxProjectGrantPublic > getModel()
void delete(@BindingParam("pgpublic") AxProjectGrantPublic pgpublic)
void setNeedsSave(boolean needsSave)
void init(@ExecutionArgParam("projectGrant") ProjectGrant projectGrant)
void setServer(WsServer server)
static Toasts message(String message)
static String get(String msg)
void deleteEntity(IDaoEntity entity)
void deleteCollection(Collection objs)
void saveEntities(Collection<? extends IDaoEntity > entities)
void setServerDomain(String serverDomain)
void setProjectGrant(ProjectGrant projectGrant)