18 package org.turro.contacts.proposal;
20 import java.io.Serializable;
21 import java.util.ArrayList;
22 import java.util.Iterator;
23 import java.util.List;
24 import org.turro.string.Strings;
25 import org.turro.contacts.Address;
26 import org.turro.contacts.Comment;
27 import org.turro.contacts.Connector;
28 import org.turro.contacts.Contact;
29 import org.turro.util.CompareUtil;
35 public class ContactProposal implements Serializable, Comparable<ContactProposal> {
37 private Contact proposal, destination;
38 private String reason;
39 private List<GenericAttribute> attributes;
40 private boolean noAction, exists;
47 this.proposal = proposal;
54 this.proposal = proposal;
69 if(destination ==
null && this.destination !=
null) {
74 this.destination = destination;
90 this.noAction = noAction;
107 if(!ga.getRelated().isEmpty()) {
132 private void addAttributes() {
133 attributes =
new ArrayList<>();
139 attributes.add(
new ConnectorAttribute(c));
142 attributes.add(
new AddressAttribute(a));
145 attributes.add(
new CommentAttribute(c));
149 for(GenericAttribute ga : attributes) {
150 Iterator<IAttribute> it = ga.getRelated().iterator();
151 while(it.hasNext()) {
152 if(!Strings.isBlank(proposal.
getId()) && it.next().getContact().getId().equals(proposal.
getId())) {
158 MostProposedSet mps =
new MostProposedSet();
159 for(GenericAttribute ga : attributes) {
160 for(IAttribute a : (List<IAttribute>) ga.getRelated()) {
161 mps.addProposition(a.getContact());
165 for(GenericAttribute ga : attributes) {
172 Iterator<GenericAttribute> it = attributes.iterator();
173 while(it.hasNext()) {
174 if(!it.next().isActive()) {
180 private void checkNoAction() {
182 destination !=
null &&
195 int result = CompareUtil.compare(proposal.
getName(), o.proposal.
getName());
200 CompareUtil.compare(this.toString(), o.toString());