1 package org.turro.crm.entity;
3 import java.util.ArrayList;
4 import java.util.Collection;
6 import java.util.HashSet;
7 import java.util.Iterator;
9 import javax.persistence.*;
10 import org.turro.string.Strings;
11 import org.turro.action.Contacts;
12 import org.turro.contacts.Address;
13 import org.turro.contacts.db.ContactsPU;
14 import org.turro.jpa.entity.IDaoEntity;
15 import org.turro.plugin.contacts.IContact;
16 import org.turro.util.CompareUtil;
25 public static final int SA_PENDING = 0, SA_DONE = 1, SA_CANCELLED = 2;
28 @GeneratedValue(strategy=GenerationType.IDENTITY)
29 @Column(name=
"IDENTIFIER")
32 @Temporal(TemporalType.TIMESTAMP)
33 private java.util.Date actionDate;
35 @Temporal(TemporalType.TIMESTAMP)
36 private java.util.Date finalDate;
40 private String comment;
42 @ManyToMany(fetch = FetchType.EAGER, targetEntity =
TouchPoint.class)
50 @ElementCollection(fetch=FetchType.EAGER)
51 private Set<String> attendees = new HashSet<String>();
53 @ElementCollection(fetch=FetchType.EAGER)
54 private Set<String> actionType = new HashSet<String>();
56 private String addressId;
63 this.actionDate = actionDate;
71 this.actionType = actionType;
79 this.addressId = addressId;
87 this.attendees = attendees;
95 this.comment = comment;
103 this.finalDate = finalDate;
119 this.status = status;
127 this.touchPoints = touchPoints;
131 return vendorProspect;
135 this.vendorProspect = vendorProspect;
142 return CompareUtil.compare(actionDate, o.actionDate);
154 return actionDate ==
null ||
156 actionDate.after(finalDate) ||
157 Strings.isBlank(comment) ||
158 vendorProspect ==
null ||
159 actionType.isEmpty();
165 Iterator<String> it = attendees.iterator();
166 while(it.hasNext()) {
167 if(Strings.isBlank(it.next())) {
177 return actionDate !=
null &&
178 actionDate.after(now);
182 if(actionDate ==
null) {
183 actionDate =
new Date();
184 finalDate =
new Date();
186 if(CompareUtil.compare(actionDate, finalDate) > 0) {
187 finalDate.setTime(actionDate.getTime());
194 ArrayList<IContact> list =
new ArrayList<>();
195 for(String s : attendees) {
205 if(c.isValid()) attendees.add(c.getId());
210 return (!Strings.isBlank(addressId) ?
215 addressId = (address !=
null ? address.
getId() :
null);
219 HashSet<TouchPoint> hs =
new HashSet<TouchPoint>();
221 if(!tp.isEndsSale()) {
230 while(it.hasNext()) {
231 if(!it.next().isEndsSale()) {
240 if(tp.isEndsSale()) {
249 while(it.hasNext()) {
250 if(it.next().isEndsSale()) {
void setActionType(Set< String > actionType)
void setAddressId(String addressId)
void setStatus(int status)
TouchPoint getEndingTouchPoint()
void setEndingTouchPoint(TouchPoint tp)
void setIAttendees(Collection< IContact > contacts)
void setAttendees(Set< String > attendees)
VendorProspect getVendorProspect()
Set< TouchPoint > getProcessTouchPoints()
Collection< IContact > getIAttendees()
int compareTo(SaleAction o)
void setVendorProspect(VendorProspect vendorProspect)
Set< String > getAttendees()
boolean isOverdue(Date now)
void setComment(String comment)
void setFinalDate(Date finalDate)
void setProcessTouchPoints(Set< TouchPoint > stp)
void setActionDate(Date actionDate)
Set< TouchPoint > getTouchPoints()
void setTouchPoints(Set< TouchPoint > touchPoints)
void setAddress(Address address)
static final int SA_PENDING
Set< String > getActionType()
default void removeEmpties()