19 package org.turro.contacts.profile;
21 import java.util.Date;
22 import org.turro.contacts.ContactType;
23 import org.turro.contacts.db.ContactsPU;
24 import org.turro.contacts.relation.FuzzyRelationTypes;
25 import static org.turro.contacts.service.ServiceContext.getServiceContextAttribute;
26 import org.turro.elephant.context.ElephantProperties;
27 import org.turro.elephant.db.WhereClause;
28 import org.turro.jpa.DaoUtil;
36 private static final String PROFILE_CONTEXT =
"profile-context";
42 public static String
getAttribute(String attribute, String defaultValue) {
46 public static Boolean
getAttribute(String attribute, Boolean defaultValue) {
53 return "true".equals(getServiceContextAttribute(
"web-on-users",
"true"));
57 return "true".equals(getServiceContextAttribute(
"show-completion",
"true"));
61 return "true".equals(getServiceContextAttribute(
"requires-company",
"true"));
65 return getServiceContextAttribute(
"networking-roles",
"@admin:is|@patron:on|@partner:on");
69 return getServiceContextAttribute(
"premium-networking-roles",
"@partner:on");
74 private static Boolean companies, centers;
75 private static Long countCompanies, countWorkers, countPossibleWorkers,
76 countCenters, countStudents, countPossibleStudents;
79 if(companies ==
null) {
93 if(countCompanies ==
null) {
96 return countCompanies;
100 if(countWorkers ==
null) {
102 wc.
addClause(
"select count(br) from BusinessRelation br");
103 wc.
addInRange(
"where",
"br.startDate",
"br.endDate",
"date",
new Date());
111 if(countPossibleWorkers ==
null) {
113 wc.
addClause(
"select count(conn) from Connector conn");
114 wc.
addClause(
"left outer join BusinessRelation br on conn.contact = br.contact");
115 wc.
addClause(
"where conn.description = 'su_professional'");
119 return countPossibleWorkers;
123 if(countCenters ==
null) {
130 if(countStudents ==
null) {
132 wc.
addClause(
"select count(br) from BusinessRelation br");
133 wc.
addInRange(
"where",
"br.startDate",
"br.endDate",
"date",
new Date());
137 return countStudents;
141 if(countPossibleStudents ==
null) {
143 wc.
addClause(
"select count(conn) from Connector conn");
144 wc.
addClause(
"left outer join BusinessRelation br on conn.contact = br.contact");
145 wc.
addClause(
"where conn.description = 'su_student'");
149 return countPossibleStudents;
static String getNetworkingRoles()
static long countCenters()
static long countStudents()
static boolean getShowCompletion()
static boolean hasCompanies()
static boolean hasCenters()
static long countPossibleWorkers()
static Boolean getAttribute(String attribute, Boolean defaultValue)
static long countPossibleStudents()
static long countCompanies()
static String getAttribute(String attribute)
static boolean getRequiresCompany()
static boolean getWebOnUsers()
static String getPremiumNetworkingRoles()
static long countWorkers()
static String getAttribute(String attribute, String defaultValue)
static String getContextProperty(String context, String property)
void addInRange(String operator, String startField, String endField, String attribute, Date date)
void addClause(String clause)
static boolean isEmpty(Dao dao, String table)
static Long count(Dao dao, String table)