18 package org.turro.contacts.zul.proposal;
20 import java.io.IOException;
21 import java.util.Collection;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import java.util.stream.Collectors;
27 import org.turro.command.Command;
28 import org.turro.command.Context;
29 import org.turro.contacts.Contact;
30 import org.turro.contacts.ContactType;
31 import org.turro.contacts.form.ContactWrapper;
32 import org.turro.contacts.proposal.ContactProposal;
33 import org.turro.contacts.proposal.GenericAttribute;
34 import org.turro.contacts.proposal.ProposalSet;
35 import org.turro.contacts.social.SocialGroupValue;
36 import org.turro.elephant.context.Application;
37 import org.turro.elephant.context.ElephantContext;
38 import org.turro.elephant.util.Messages;
39 import org.turro.security.SocialGroups;
40 import org.zkoss.zul.Listbox;
41 import org.zkoss.zul.Listitem;
50 private Collection<SocialGroupValue> socialGroups;
59 this.socialGroups = socialGroups;
66 public void importVCard() throws InterruptedException, IOException {
70 public Object execute(Context context) {
79 Iterator<Listitem> it = getItems().iterator();
82 Listitem li = it.next();
86 }
else if(li.getValue().equals(proposal)) {
99 Iterator<Listitem> it = getItems().iterator();
100 while(it.hasNext()) {
101 Listitem li = it.next();
102 if(li.isSelected()) {
107 proposals.remove(cp);
109 }
catch (Exception ex) {
121 Iterator<Listitem> it = getItems().iterator();
122 while(it.hasNext()) {
123 Listitem li = it.next();
124 if(li.isSelected()) {
133 private void addProposalItems() {
136 Listitem li =
new Listitem(cp.getDescription(), cp);
137 if(cp.isDuplicated()) {
138 li.setSclass(
"duplicated");
139 }
else if(cp.isProbablyNew()) {
140 li.setSclass(
"probablynew");
146 private void processProposal(ContactProposal cp)
throws Exception {
148 Contact destination = cp.getDestination();
149 if(destination !=
null) {
150 for(GenericAttribute ga : cp.getAttributes()) {
152 ga.addToContact(destination);
155 saveDestination(destination);
157 cp.clearInactiveAttributes();
158 saveDestination(cp.getProposal());
163 private void saveDestination(Contact destination)
throws Exception {
164 if(type !=
null) destination.setType(type);
165 SocialGroups.syndicate(List.of(destination),
166 socialGroups.stream().map(sgv -> sgv.getKey()).collect(Collectors.toSet()),
168 new ContactWrapper(destination).save();
static Application getApplication()
static String logMsg(String msg)
static Messages confirmDeletion()
static Messages confirmProcess()