BrightSide Workbench Full Report + Source Code
ActorCheckVM.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2021 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.actor;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.turro.string.Strings;
24 import org.turro.action.Contacts;
25 import org.turro.entities.Entities;
26 import org.turro.entities.IElephantEntity;
27 import org.turro.plugin.contacts.IContact;
28 import org.zkoss.bind.annotation.BindingParam;
29 import org.zkoss.bind.annotation.Command;
30 import org.zkoss.bind.annotation.NotifyChange;
31 
36 public class ActorCheckVM {
37 
38  private IContact contact;
39  private String actor;
40  private Object entity;
41  private int mode;
42 
43  public ActorCheckVM() {
44  }
45 
46  public IContact getContact() {
47  return contact;
48  }
49 
50  public void setContact(IContact contact) {
51  this.contact = contact;
52  }
53 
54  public String getActor() {
55  return actor;
56  }
57 
58  public void setActor(String actor) {
59  this.actor = actor;
60  }
61 
62  public Object getEntity() {
63  return entity;
64  }
65 
66  public void setEntity(Object entity) {
67  this.entity = entity;
68  }
69 
70  public int getMode() {
71  return mode;
72  }
73 
74  public void setMode(int mode) {
75  this.mode = mode;
76  }
77 
78  @Command
79  @NotifyChange("model")
80  public void mode(@BindingParam("mode") Integer index) {
81  mode = index;
82  }
83 
84  @NotifyChange("model")
85  @Command("update")
86  public void update() {}
87 
88  public List getModel() {
89  List list = new ArrayList();
91  if(mode == 0) {
92  if(contact != null) {
93  Actors.getSortedActors().forEach(actor -> {
94  list.add(new ContactEntityCheck(actor, contact, iee));
95  });
96  }
97  } else if(mode == 1) {
98  if(!Strings.isBlank(actor)) {
99  Contacts.getEmpty().loadByPartialName("%%%").forEach(contact -> {
100  ActorEntityCheck aec = new ActorEntityCheck(actor, contact, iee);
101  if(aec.precheck()) {
102  list.add(aec);
103  }
104  });
105  }
106  }
107  return list;
108  }
109 
110 }
static IContact getEmpty()
Definition: Contacts.java:56
void setEntity(Object entity)
void setContact(IContact contact)
void setActor(String actor)
static List< String > getSortedActors()
Definition: Actors.java:75
static IElephantEntity getController(String path)
Definition: Entities.java:78
List< IContact > loadByPartialName(String name)