BrightSide Workbench Full Report + Source Code
org.turro.crm.command.CrmCalendar Class Reference
Inheritance diagram for org.turro.crm.command.CrmCalendar:
Collaboration diagram for org.turro.crm.command.CrmCalendar:

Protected Member Functions

void executePlugin ()
 
- Protected Member Functions inherited from org.turro.plugin.command.CalendarPlugin
void addToResult (Object data)
 
abstract void executePlugin (Context context) throws Exception
 

Additional Inherited Members

- Public Member Functions inherited from org.turro.plugin.command.CalendarPlugin
String getName ()
 
boolean stopPropagating ()
 
IContact getContact ()
 
Date getFrom ()
 
Date getTo ()
 
void execute ()
 
String getName ()
 
boolean stopsPropagating ()
 
void setParams (Object params)
 
IContact getContact ()
 
Date getFrom ()
 
Date getTo ()
 
Object execute (Context context)
 
- Public Member Functions inherited from org.turro.action.DefaultPlugin
void setContext (Map< String, Object > params, Map< String, Object > results)
 
Object getParam (String key)
 
boolean itsMe (String name)
 
Object addResult (String key, Object value)
 
- Static Public Member Functions inherited from org.turro.plugin.command.CalendarPlugin
static Collection< Object > getCalendarFor (IContact contact, Date from, Date to)
 
static Collection< ICalendarEventgetCalendarFor (Application app, IContact contact, Date from, Date to)
 
- Protected Attributes inherited from org.turro.plugin.command.CalendarPlugin
Map< String, Object > params
 
Collection< ICalendarEventresult
 
- Protected Attributes inherited from org.turro.action.DefaultPlugin
Map< String, Object > params
 
Map< String, Object > results
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 44 of file CrmCalendar.java.

Member Function Documentation

◆ executePlugin()

void org.turro.crm.command.CrmCalendar.executePlugin ( )
protected

Reimplemented from org.turro.plugin.command.CalendarPlugin.

Definition at line 47 of file CrmCalendar.java.

47  {
48  Dao dao = new CrmPU();
49  Vendor vendor = (Vendor) dao.getSingleResultOrNull(
50  "select v from Vendor v where v.idContact = ?",
51  new Object[] { getContact().getId() });
52  if(vendor != null) {
53  Date newFrom = new CheckDate(getFrom()).addDays(-7).getDate(),
54  newTo = new CheckDate(getTo()).addDays(7).getDate();
55  List<SaleAction> list = dao.getResultList(
56  "select sa from SaleAction sa " +
57  "where sa.vendorProspect.vendor = ? " +
58  "and (" +
59  "(sa.actionDate >= ? and sa.actionDate <= ?) " +
60  "or (sa.finalDate >= ? and sa.finalDate <= ?) " +
61  "or (sa.actionDate < ? and sa.finalDate > ?) " +
62  ")",
63  new Object[] { vendor,
64  newFrom, newTo,
65  newFrom, newTo,
66  getFrom(), getTo()
67  });
68  for(SaleAction sa : list) {
69  DefaultCalendarEvent calendarEvent = new DefaultCalendarEvent();
70  calendarEvent.setLocked(false);
71  calendarEvent.setDone(sa.getStatus() > 0);
72  if(sa.getStatus() > SaleAction.SA_PENDING) {
73  calendarEvent.setHeaderColor(CalendarColor.SILVER.getHeader());
74  calendarEvent.setContentColor(CalendarColor.SILVER.getContent());
75  } else {
76  calendarEvent.setHeaderColor(CalendarColor.GREEN.getHeader());
77  calendarEvent.setContentColor(CalendarColor.GREEN.getContent());
78  }
79  calendarEvent.setBeginDate(sa.getActionDate());
80  calendarEvent.setEndDate(sa.getFinalDate());
81  calendarEvent.setPath(CrmPU.getObjectPath(sa));
82  calendarEvent.setOrganizer(sa.getVendorProspect().getVendor().getIContact());
83  PhraseBuilder pb = new PhraseBuilder();
84  VendorProspect vp = sa.getVendorProspect();
85  pb.addWord(vp.getSaleProspect().getCustomer().getName());
86  pb.addPendingSeparator(Chars.forward().toString());
87  pb.addWord(vp.getSaleProspect().getDescription());
88  calendarEvent.setTitle(pb.toString());
89  pb.addPendingSeparator(Chars.nl().repeat(2).toString());
90  pb.addWord(sa.getComment());
91  pb.addPendingSeparator(Chars.nl().repeat(2).toString());
92  for(IContact contact : sa.getIAttendees()) {
93  pb.addWord(contact.getName());
94  pb.addPendingSeparator(", ");
95  calendarEvent.addAttendee(contact);
96  }
97  calendarEvent.setContent(pb.toString());
98  calendarEvent.setEventId(Strings.identifier("sa" + sa.getId() +
99  ObjectString.formatObject(calendarEvent.getBeginDate(), ObjectString.COMPRESSED_DATE_PATTERN, true)));
100  addResult(calendarEvent.getEventId(), calendarEvent);
101  }
102  }
103  }
Object addResult(String key, Object value)
Here is the call graph for this function:

The documentation for this class was generated from the following file: