BrightSide Workbench Full Report + Source Code
InactiveProspects.java
Go to the documentation of this file.
1
/*
2
* TurrĂ³ i Cutiller Foundation. License notice.
3
* Copyright (C) 2013 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Affero General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
14
*
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
package
org.turro.crm.search;
20
21
import
org.turro.crm.db.CrmPU;
22
import
org.turro.crm.entity.ProspectStage;
23
import
org.turro.crm.entity.SaleProspect;
24
import
org.turro.crm.entity.Vendor;
25
import
org.turro.elephant.context.Application;
26
import
org.turro.elephant.db.WhereClause;
27
import
org.turro.vendor.VendorUtil;
28
33
public
class
InactiveProspects
{
34
35
public
InactiveProspects
() {
36
}
37
38
public
java.util.List<
SaleProspect
>
getObjectValues
(
Vendor
vendor) {
39
return
new
CrmPU
().getResultList(
createCriteria
(vendor));
40
}
41
42
public
WhereClause
createCriteria
(
Vendor
vendor) {
43
WhereClause
wc =
new
WhereClause
();
44
wc.
addClause
(
"select distinct salep from SaleProspect as salep"
);
45
if
(!
Application
.
getApplication
().
isInRole
(
"sale-prospect:all"
)) {
46
vendor = vendor ==
null
?
VendorUtil
.
getCurrent
() : vendor;
47
if
(vendor ==
null
) {
48
wc.
addClause
(
"where 1=2"
);
49
return
wc;
50
}
51
}
52
if
(vendor !=
null
) {
53
wc.
addClause
(
"left join salep.vendorProspects vendorp"
);
54
wc.
addClause
(
"left join salep.customer.ownedBy vendoro"
);
55
wc.
addClause
(
"where (vendorp.vendor = :vendorlimp"
);
56
wc.
addClause
(
"or vendoro.vendor = :vendorlimo)"
);
57
wc.
addNamedValue
(
"vendorlimp"
, vendor);
58
wc.
addNamedValue
(
"vendorlimo"
, vendor);
59
}
else
{
60
wc.
addClause
(
"where 1=1"
);
61
}
62
wc.
addClause
(
"and salep.stage <> :close_won"
);
63
wc.
addNamedValue
(
"close_won"
,
ProspectStage
.
CLOSED_WON
);
64
wc.
addClause
(
"and salep.stage <> :close_lost"
);
65
wc.
addNamedValue
(
"close_lost"
,
ProspectStage
.
CLOSED_LOST
);
66
wc.
addClause
(
"and not exists ("
);
67
wc.
addClause
(
"select sa from SaleAction sa"
);
68
wc.
addClause
(
"where sa.vendorProspect.saleProspect = salep"
);
69
wc.
addClause
(
"and sa.status = 0"
);
70
wc.
addClause
(
")"
);
71
wc.
addClause
(
"order by salep.prospectDate"
);
72
return
wc;
73
}
74
75
}
org.turro.crm.db.CrmPU
Definition:
CrmPU.java:19
org.turro.crm.entity.SaleProspect
Definition:
SaleProspect.java:24
org.turro.crm.entity.Vendor
Definition:
Vendor.java:18
org.turro.crm.search.InactiveProspects
Definition:
InactiveProspects.java:33
org.turro.crm.search.InactiveProspects.getObjectValues
java.util.List< SaleProspect > getObjectValues(Vendor vendor)
Definition:
InactiveProspects.java:38
org.turro.crm.search.InactiveProspects.createCriteria
WhereClause createCriteria(Vendor vendor)
Definition:
InactiveProspects.java:42
org.turro.crm.search.InactiveProspects.InactiveProspects
InactiveProspects()
Definition:
InactiveProspects.java:35
org.turro.elephant.context.Application
Definition:
Application.java:49
org.turro.elephant.context.Application.isInRole
boolean isInRole(String role)
Definition:
Application.java:139
org.turro.elephant.context.Application.getApplication
static Application getApplication()
Definition:
Application.java:71
org.turro.elephant.db.WhereClause
Definition:
WhereClause.java:32
org.turro.elephant.db.WhereClause.addClause
void addClause(String clause)
Definition:
WhereClause.java:56
org.turro.elephant.db.WhereClause.addNamedValue
void addNamedValue(String name, Object value)
Definition:
WhereClause.java:78
org.turro.vendor.VendorUtil
Definition:
VendorUtil.java:30
org.turro.vendor.VendorUtil.getCurrent
static Vendor getCurrent()
Definition:
VendorUtil.java:32
org.turro.crm.entity.ProspectStage
Definition:
ProspectStage.java:24
org.turro.crm.entity.ProspectStage.CLOSED_LOST
CLOSED_LOST
Definition:
ProspectStage.java:30
org.turro.crm.entity.ProspectStage.CLOSED_WON
CLOSED_WON
Definition:
ProspectStage.java:29
TurroProjects
Public
BrightSide
elephant-crm
src
main
java
org
turro
crm
search
InactiveProspects.java
Generated on Tue Mar 12 2024 07:01:19 for BrightSide by
1.9.1