19 package org.turro.contacts.name;
21 import java.util.List;
23 import org.turro.contacts.Contact;
24 import org.turro.contacts.ContactType;
25 import org.turro.contacts.db.ContactsPU;
26 import org.turro.elephant.util.Messages;
27 import org.turro.jpa.Dao;
28 import org.turro.sql.SqlClause;
29 import org.turro.util.Cached;
30 import org.zkoss.bind.BindUtils;
31 import org.zkoss.bind.annotation.Command;
39 private Set<NameEntry> selected;
46 this.selected = selected;
51 if(selected !=
null && !selected.isEmpty()) {
53 selected.forEach(item -> {
54 SqlClause.update(
"Contact")
55 .
set(
"complexName.full", item.getFull())
56 .andSet(
"complexName.informal", item.getInformal())
57 .andSet(
"complexName.formal", item.getFormal())
58 .where().equal(
"id", item.getContactId())
59 .dao(dao.get()).execute();
61 BindUtils.postNotifyChange(
null,
null,
NamesVM.this,
"model");
67 return SqlClause.select(
"c").from(
"Contact c")
68 .where().group().isNull(
"complexName.formal").or().isNull(
"complexName.informal").endGroup()
70 .orderBy(
"complexName.full")
71 .dao(dao.get()).resultList(
Contact.class).stream()
72 .map(c ->
NameEntry.
from(c.getId(), c.getComplexName().getFull(),
false))
73 .filter(e -> !e.isEmpty())
77 private final Cached<Dao> dao = Cached.instance(() ->
new ContactsPU());
static NameEntry from(String contactId, String name, boolean entity)
static Messages confirmProcess()
Messages add(String word)