Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PERFORMA_REPLICA
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Usman
PERFORMA_REPLICA
Commits
fdd9b7c3
Commit
fdd9b7c3
authored
Apr 25, 2018
by
Nilu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stripe - credit based job openings (webhook to receive invoice paid event)
parent
80f0a11b
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
532 additions
and
25 deletions
+532
-25
spark-core-2.7.1.jar
cmsWebApp/libraries/spark-core-2.7.1.jar
+0
-0
Company.xml
cmsWebApp/sql/Company.xml
+2
-0
Company.sql
cmsWebApp/sql/ms/Company.sql
+2
-0
Company.sql
cmsWebApp/sql/oracle/Company.sql
+2
-0
Company.sql
cmsWebApp/sql/postgres/Company.sql
+2
-0
MakePaymentFP.java
cmsWebApp/src/performa/form/MakePaymentFP.java
+9
-7
SaveJobFP.java
cmsWebApp/src/performa/form/SaveJobFP.java
+2
-0
BaseCompany.java
cmsWebApp/src/performa/orm/BaseCompany.java
+395
-0
Company.java
cmsWebApp/src/performa/orm/Company.java
+2
-4
Company.xml
cmsWebApp/src/performa/orm/Company.xml
+10
-8
CompanyPersistenceMgr.java
cmsWebApp/src/performa/orm/CompanyPersistenceMgr.java
+16
-6
StripeUtils.java
cmsWebApp/src/performa/utils/StripeUtils.java
+54
-0
CustomServlets_adminPortal.xml
...oot/extensions/adminportal/CustomServlets_adminPortal.xml
+4
-0
20180424_Alter_Company.xml
...xtensions/adminportal/upgrades/20180424_Alter_Company.xml
+15
-0
webhook.jsp
cmsWebApp/webroot/extensions/adminportal/webhook.jsp
+17
-0
No files found.
cmsWebApp/libraries/spark-core-2.7.1.jar
0 → 100644
View file @
fdd9b7c3
File added
cmsWebApp/sql/Company.xml
View file @
fdd9b7c3
...
...
@@ -24,6 +24,8 @@
<column
name=
"name_on_card"
type=
"String"
nullable=
"true"
length=
"100"
/>
<column
name=
"card_post_code"
type=
"String"
nullable=
"true"
length=
"10"
/>
<column
name=
"card_id"
type=
"String"
nullable=
"true"
length=
"100"
/>
<column
name=
"plan_renewed_on"
type=
"Date"
nullable=
"true"
/>
<column
name=
"used_credits"
type=
"Long"
nullable=
"true"
/>
<column
name=
"added_by_user_id"
type=
"Long"
length=
"11"
nullable=
"false"
/>
<column
name=
"payment_plan_id"
type=
"Long"
length=
"11"
nullable=
"true"
/>
</NODE>
...
...
cmsWebApp/sql/ms/Company.sql
View file @
fdd9b7c3
...
...
@@ -24,6 +24,8 @@ CREATE TABLE tl_company (
name_on_card
varchar
(
100
)
NULL
,
card_post_code
varchar
(
10
)
NULL
,
card_id
varchar
(
100
)
NULL
,
plan_renewed_on
datetime
NULL
,
used_credits
numeric
(
12
)
NULL
,
added_by_user_id
numeric
(
12
)
NOT
NULL
,
payment_plan_id
numeric
(
12
)
NULL
);
...
...
cmsWebApp/sql/oracle/Company.sql
View file @
fdd9b7c3
...
...
@@ -25,6 +25,8 @@ CREATE TABLE tl_company (
name_on_card
varchar2
(
100
)
NULL
,
card_post_code
varchar2
(
10
)
NULL
,
card_id
varchar2
(
100
)
NULL
,
plan_renewed_on
date
NULL
,
used_credits
number
(
12
)
NULL
,
added_by_user_id
number
(
12
)
NOT
NULL
,
payment_plan_id
number
(
12
)
NULL
);
...
...
cmsWebApp/sql/postgres/Company.sql
View file @
fdd9b7c3
...
...
@@ -25,6 +25,8 @@ CREATE TABLE tl_company (
name_on_card
varchar
(
100
)
NULL
,
card_post_code
varchar
(
10
)
NULL
,
card_id
varchar
(
100
)
NULL
,
plan_renewed_on
timestamp
NULL
,
used_credits
numeric
(
12
)
NULL
,
added_by_user_id
numeric
(
12
)
NOT
NULL
,
payment_plan_id
numeric
(
12
)
NULL
);
...
...
cmsWebApp/src/performa/form/MakePaymentFP.java
View file @
fdd9b7c3
...
...
@@ -91,13 +91,6 @@ public class MakePaymentFP extends SaveFP
company
.
setCardID
(
card
.
getId
());
}
if
(!
ppj
&&
company
.
getPaymentPlan
()
!=
null
)
{
// cannot subscribe to a plan without card details
StripeUtils
.
updatePlan
(
company
);
}
job
.
setApplyBy
(
DateDiff
.
add
(
DateDiff
.
getToday
(),
Calendar
.
DATE
,
30
));
job
.
setOpenDate
(
new
Date
());
job
.
setJobStatus
(
JobStatus
.
OPEN
);
...
...
@@ -108,6 +101,15 @@ public class MakePaymentFP extends SaveFP
job
.
createShortenedURL
();
}
if
(!
ppj
&&
company
.
getPaymentPlan
()
!=
null
)
{
// cannot subscribe to a plan without card details
company
.
setPlanRenewedOn
(
DateDiff
.
getToday
());
company
.
setUsedCredits
(
1
);
StripeUtils
.
updatePlan
(
company
);
}
// restarting process as custom attributes needs to be updated to intercom
completeProcessRestartAndRestoreAttribs
(
process
,
request
);
...
...
cmsWebApp/src/performa/form/SaveJobFP.java
View file @
fdd9b7c3
...
...
@@ -49,6 +49,8 @@ public class SaveJobFP extends SaveFP
job
.
setApplyBy
(
DateDiff
.
add
(
DateDiff
.
getToday
(),
Calendar
.
DATE
,
30
));
job
.
setOpenDate
(
new
Date
());
company
.
setUsedCredits
(
company
.
getUsedCredits
()
+
1
);
if
(
status
==
JobStatus
.
OPEN
)
{
if
(
company
.
getSelectedPaymentPlan
()
!=
null
)
...
...
cmsWebApp/src/performa/orm/BaseCompany.java
View file @
fdd9b7c3
...
...
@@ -60,6 +60,8 @@ public abstract class BaseCompany extends BaseBusinessClass
public
static
final
String
FIELD_NameOnCard
=
"NameOnCard"
;
public
static
final
String
FIELD_CardPostCode
=
"CardPostCode"
;
public
static
final
String
FIELD_CardID
=
"CardID"
;
public
static
final
String
FIELD_PlanRenewedOn
=
"PlanRenewedOn"
;
public
static
final
String
FIELD_UsedCredits
=
"UsedCredits"
;
public
static
final
String
FIELD_UserEmail
=
"UserEmail"
;
public
static
final
String
FIELD_FirstName
=
"FirstName"
;
public
static
final
String
FIELD_LastName
=
"LastName"
;
...
...
@@ -97,6 +99,8 @@ public abstract class BaseCompany extends BaseBusinessClass
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_NameOnCard
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_CardPostCode
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_CardID
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_PlanRenewedOn
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_UsedCredits
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_UserEmail
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_FirstName
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
<
Company
>
HELPER_LastName
=
DefaultAttributeHelper
.
INSTANCE
;
...
...
@@ -125,6 +129,8 @@ public abstract class BaseCompany extends BaseBusinessClass
private
String
_NameOnCard
;
private
String
_CardPostCode
;
private
String
_CardID
;
private
Date
_PlanRenewedOn
;
private
Integer
_UsedCredits
;
private
String
_UserEmail
;
private
String
_FirstName
;
private
String
_LastName
;
...
...
@@ -175,6 +181,8 @@ public abstract class BaseCompany extends BaseBusinessClass
private
static
final
AttributeValidator
[]
FIELD_NameOnCard_Validators
;
private
static
final
AttributeValidator
[]
FIELD_CardPostCode_Validators
;
private
static
final
AttributeValidator
[]
FIELD_CardID_Validators
;
private
static
final
AttributeValidator
[]
FIELD_PlanRenewedOn_Validators
;
private
static
final
AttributeValidator
[]
FIELD_UsedCredits_Validators
;
// Arrays of behaviour decorators
...
...
@@ -219,6 +227,8 @@ public abstract class BaseCompany extends BaseBusinessClass
FIELD_NameOnCard_Validators
=
(
AttributeValidator
[])
setupAttribMetaData_NameOnCard
(
validatorMapping
).
toArray
(
new
AttributeValidator
[
0
]);
FIELD_CardPostCode_Validators
=
(
AttributeValidator
[])
setupAttribMetaData_CardPostCode
(
validatorMapping
).
toArray
(
new
AttributeValidator
[
0
]);
FIELD_CardID_Validators
=
(
AttributeValidator
[])
setupAttribMetaData_CardID
(
validatorMapping
).
toArray
(
new
AttributeValidator
[
0
]);
FIELD_PlanRenewedOn_Validators
=
(
AttributeValidator
[])
setupAttribMetaData_PlanRenewedOn
(
validatorMapping
).
toArray
(
new
AttributeValidator
[
0
]);
FIELD_UsedCredits_Validators
=
(
AttributeValidator
[])
setupAttribMetaData_UsedCredits
(
validatorMapping
).
toArray
(
new
AttributeValidator
[
0
]);
REFERENCE_Company
.
initialiseReference
();
...
...
@@ -766,6 +776,43 @@ public abstract class BaseCompany extends BaseBusinessClass
return
validators
;
}
// Meta Info setup
private
static
List
setupAttribMetaData_PlanRenewedOn
(
Map
validatorMapping
)
{
Map
metaInfo
=
new
HashMap
();
metaInfo
.
put
(
"dbcol"
,
"plan_renewed_on"
);
metaInfo
.
put
(
"mandatory"
,
"false"
);
metaInfo
.
put
(
"name"
,
"PlanRenewedOn"
);
metaInfo
.
put
(
"type"
,
"Date"
);
LogMgr
.
log
(
BUSINESS_OBJECTS
,
LogLevel
.
DEBUG2
,
"Metadata for Company.PlanRenewedOn:"
,
metaInfo
);
ATTRIBUTES_METADATA_Company
.
put
(
FIELD_PlanRenewedOn
,
Collections
.
unmodifiableMap
(
metaInfo
));
List
validators
=
BaseBusinessClass
.
getAttribValidators
(
Company
.
class
,
"PlanRenewedOn"
,
metaInfo
,
validatorMapping
);
LogMgr
.
log
(
BUSINESS_OBJECTS
,
LogLevel
.
DEBUG1
,
"Validators for Company.PlanRenewedOn:"
,
validators
);
return
validators
;
}
// Meta Info setup
private
static
List
setupAttribMetaData_UsedCredits
(
Map
validatorMapping
)
{
Map
metaInfo
=
new
HashMap
();
metaInfo
.
put
(
"dbcol"
,
"used_credits"
);
metaInfo
.
put
(
"name"
,
"UsedCredits"
);
metaInfo
.
put
(
"type"
,
"Integer"
);
LogMgr
.
log
(
BUSINESS_OBJECTS
,
LogLevel
.
DEBUG2
,
"Metadata for Company.UsedCredits:"
,
metaInfo
);
ATTRIBUTES_METADATA_Company
.
put
(
FIELD_UsedCredits
,
Collections
.
unmodifiableMap
(
metaInfo
));
List
validators
=
BaseBusinessClass
.
getAttribValidators
(
Company
.
class
,
"UsedCredits"
,
metaInfo
,
validatorMapping
);
LogMgr
.
log
(
BUSINESS_OBJECTS
,
LogLevel
.
DEBUG1
,
"Validators for Company.UsedCredits:"
,
validators
);
return
validators
;
}
// END OF STATIC METADATA DEFINITION
...
...
@@ -809,6 +856,8 @@ public abstract class BaseCompany extends BaseBusinessClass
_NameOnCard
=
(
String
)(
HELPER_NameOnCard
.
initialise
(
_NameOnCard
));
_CardPostCode
=
(
String
)(
HELPER_CardPostCode
.
initialise
(
_CardPostCode
));
_CardID
=
(
String
)(
HELPER_CardID
.
initialise
(
_CardID
));
_PlanRenewedOn
=
(
Date
)(
HELPER_PlanRenewedOn
.
initialise
(
_PlanRenewedOn
));
_UsedCredits
=
(
Integer
)(
HELPER_UsedCredits
.
initialise
(
_UsedCredits
));
_UserEmail
=
(
String
)(
HELPER_UserEmail
.
initialise
(
_UserEmail
));
_FirstName
=
(
String
)(
HELPER_FirstName
.
initialise
(
_FirstName
));
_LastName
=
(
String
)(
HELPER_LastName
.
initialise
(
_LastName
));
...
...
@@ -2420,6 +2469,202 @@ public abstract class BaseCompany extends BaseBusinessClass
}
/**
* Get the attribute PlanRenewedOn
*/
public
Date
getPlanRenewedOn
()
{
assertValid
();
Date
valToReturn
=
_PlanRenewedOn
;
for
(
CompanyBehaviourDecorator
bhd
:
Company_BehaviourDecorators
)
{
valToReturn
=
bhd
.
getPlanRenewedOn
((
Company
)
this
,
valToReturn
);
}
return
valToReturn
;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected
void
prePlanRenewedOnChange
(
Date
newPlanRenewedOn
)
throws
FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected
void
postPlanRenewedOnChange
()
throws
FieldException
{
}
public
FieldWriteability
getWriteability_PlanRenewedOn
()
{
return
getFieldWritabilityUtil
(
FieldWriteability
.
TRUE
);
}
/**
* Set the attribute PlanRenewedOn. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public
void
setPlanRenewedOn
(
Date
newPlanRenewedOn
)
throws
FieldException
{
boolean
oldAndNewIdentical
=
HELPER_PlanRenewedOn
.
compare
(
_PlanRenewedOn
,
newPlanRenewedOn
);
try
{
for
(
CompanyBehaviourDecorator
bhd
:
Company_BehaviourDecorators
)
{
newPlanRenewedOn
=
bhd
.
setPlanRenewedOn
((
Company
)
this
,
newPlanRenewedOn
);
oldAndNewIdentical
=
HELPER_PlanRenewedOn
.
compare
(
_PlanRenewedOn
,
newPlanRenewedOn
);
}
if
(
FIELD_PlanRenewedOn_Validators
.
length
>
0
)
{
Object
newPlanRenewedOnObj
=
HELPER_PlanRenewedOn
.
toObject
(
newPlanRenewedOn
);
if
(
newPlanRenewedOnObj
!=
null
)
{
int
loopMax
=
FIELD_PlanRenewedOn_Validators
.
length
;
Map
metadata
=
(
Map
)
ATTRIBUTES_METADATA_Company
.
get
(
FIELD_PlanRenewedOn
);
for
(
int
v
=
0
;
v
<
loopMax
;
++
v
)
{
FIELD_PlanRenewedOn_Validators
[
v
].
checkAttribute
(
this
,
FIELD_PlanRenewedOn
,
metadata
,
newPlanRenewedOnObj
);
}
}
}
}
catch
(
FieldException
e
)
{
if
(!
oldAndNewIdentical
)
{
e
.
setWouldModify
();
}
throw
e
;
}
if
(!
oldAndNewIdentical
)
{
assertValid
();
Debug
.
assertion
(
getWriteability_PlanRenewedOn
()
!=
FieldWriteability
.
FALSE
,
"Field PlanRenewedOn is not writeable"
);
prePlanRenewedOnChange
(
newPlanRenewedOn
);
markFieldChange
(
FIELD_PlanRenewedOn
);
_PlanRenewedOn
=
newPlanRenewedOn
;
postFieldChange
(
FIELD_PlanRenewedOn
);
postPlanRenewedOnChange
();
}
}
/**
* Get the attribute UsedCredits
*/
public
Integer
getUsedCredits
()
{
assertValid
();
Integer
valToReturn
=
_UsedCredits
;
for
(
CompanyBehaviourDecorator
bhd
:
Company_BehaviourDecorators
)
{
valToReturn
=
bhd
.
getUsedCredits
((
Company
)
this
,
valToReturn
);
}
return
valToReturn
;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected
void
preUsedCreditsChange
(
Integer
newUsedCredits
)
throws
FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected
void
postUsedCreditsChange
()
throws
FieldException
{
}
public
FieldWriteability
getWriteability_UsedCredits
()
{
return
getFieldWritabilityUtil
(
FieldWriteability
.
TRUE
);
}
/**
* Set the attribute UsedCredits. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public
void
setUsedCredits
(
Integer
newUsedCredits
)
throws
FieldException
{
boolean
oldAndNewIdentical
=
HELPER_UsedCredits
.
compare
(
_UsedCredits
,
newUsedCredits
);
try
{
for
(
CompanyBehaviourDecorator
bhd
:
Company_BehaviourDecorators
)
{
newUsedCredits
=
bhd
.
setUsedCredits
((
Company
)
this
,
newUsedCredits
);
oldAndNewIdentical
=
HELPER_UsedCredits
.
compare
(
_UsedCredits
,
newUsedCredits
);
}
if
(
FIELD_UsedCredits_Validators
.
length
>
0
)
{
Object
newUsedCreditsObj
=
HELPER_UsedCredits
.
toObject
(
newUsedCredits
);
if
(
newUsedCreditsObj
!=
null
)
{
int
loopMax
=
FIELD_UsedCredits_Validators
.
length
;
Map
metadata
=
(
Map
)
ATTRIBUTES_METADATA_Company
.
get
(
FIELD_UsedCredits
);
for
(
int
v
=
0
;
v
<
loopMax
;
++
v
)
{
FIELD_UsedCredits_Validators
[
v
].
checkAttribute
(
this
,
FIELD_UsedCredits
,
metadata
,
newUsedCreditsObj
);
}
}
}
}
catch
(
FieldException
e
)
{
if
(!
oldAndNewIdentical
)
{
e
.
setWouldModify
();
}
throw
e
;
}
if
(!
oldAndNewIdentical
)
{
assertValid
();
Debug
.
assertion
(
getWriteability_UsedCredits
()
!=
FieldWriteability
.
FALSE
,
"Field UsedCredits is not writeable"
);
preUsedCreditsChange
(
newUsedCredits
);
markFieldChange
(
FIELD_UsedCredits
);
_UsedCredits
=
newUsedCredits
;
postFieldChange
(
FIELD_UsedCredits
);
postUsedCreditsChange
();
}
}
/**
* Get the attribute UserEmail
*/
public
String
getUserEmail
()
...
...
@@ -4048,6 +4293,8 @@ public abstract class BaseCompany extends BaseBusinessClass
tl_companyPSet
.
setAttrib
(
FIELD_NameOnCard
,
HELPER_NameOnCard
.
toObject
(
_NameOnCard
));
//
tl_companyPSet
.
setAttrib
(
FIELD_CardPostCode
,
HELPER_CardPostCode
.
toObject
(
_CardPostCode
));
//
tl_companyPSet
.
setAttrib
(
FIELD_CardID
,
HELPER_CardID
.
toObject
(
_CardID
));
//
tl_companyPSet
.
setAttrib
(
FIELD_PlanRenewedOn
,
HELPER_PlanRenewedOn
.
toObject
(
_PlanRenewedOn
));
//
tl_companyPSet
.
setAttrib
(
FIELD_UsedCredits
,
HELPER_UsedCredits
.
toObject
(
_UsedCredits
));
//
_AddedByUser
.
getPersistentSets
(
allSets
);
_PaymentPlan
.
getPersistentSets
(
allSets
);
...
...
@@ -4080,6 +4327,8 @@ public abstract class BaseCompany extends BaseBusinessClass
_NameOnCard
=
(
String
)(
HELPER_NameOnCard
.
fromObject
(
_NameOnCard
,
tl_companyPSet
.
getAttrib
(
FIELD_NameOnCard
)));
//
_CardPostCode
=
(
String
)(
HELPER_CardPostCode
.
fromObject
(
_CardPostCode
,
tl_companyPSet
.
getAttrib
(
FIELD_CardPostCode
)));
//
_CardID
=
(
String
)(
HELPER_CardID
.
fromObject
(
_CardID
,
tl_companyPSet
.
getAttrib
(
FIELD_CardID
)));
//
_PlanRenewedOn
=
(
Date
)(
HELPER_PlanRenewedOn
.
fromObject
(
_PlanRenewedOn
,
tl_companyPSet
.
getAttrib
(
FIELD_PlanRenewedOn
)));
//
_UsedCredits
=
(
Integer
)(
HELPER_UsedCredits
.
fromObject
(
_UsedCredits
,
tl_companyPSet
.
getAttrib
(
FIELD_UsedCredits
)));
//
_AddedByUser
.
setFromPersistentSets
(
objectID
,
allSets
);
_PaymentPlan
.
setFromPersistentSets
(
objectID
,
allSets
);
...
...
@@ -4241,6 +4490,24 @@ public abstract class BaseCompany extends BaseBusinessClass
e
.
addException
(
ex
);
}
try
{
setPlanRenewedOn
(
otherCompany
.
getPlanRenewedOn
());
}
catch
(
FieldException
ex
)
{
e
.
addException
(
ex
);
}
try
{
setUsedCredits
(
otherCompany
.
getUsedCredits
());
}
catch
(
FieldException
ex
)
{
e
.
addException
(
ex
);
}
}
}
...
...
@@ -4272,6 +4539,8 @@ public abstract class BaseCompany extends BaseBusinessClass
_NameOnCard
=
sourceCompany
.
_NameOnCard
;
_CardPostCode
=
sourceCompany
.
_CardPostCode
;
_CardID
=
sourceCompany
.
_CardID
;
_PlanRenewedOn
=
sourceCompany
.
_PlanRenewedOn
;
_UsedCredits
=
sourceCompany
.
_UsedCredits
;
_UserEmail
=
sourceCompany
.
_UserEmail
;
_FirstName
=
sourceCompany
.
_FirstName
;
_LastName
=
sourceCompany
.
_LastName
;
...
...
@@ -4355,6 +4624,8 @@ public abstract class BaseCompany extends BaseBusinessClass
_NameOnCard
=
(
String
)(
HELPER_NameOnCard
.
readExternal
(
_NameOnCard
,
vals
.
get
(
FIELD_NameOnCard
)));
//
_CardPostCode
=
(
String
)(
HELPER_CardPostCode
.
readExternal
(
_CardPostCode
,
vals
.
get
(
FIELD_CardPostCode
)));
//
_CardID
=
(
String
)(
HELPER_CardID
.
readExternal
(
_CardID
,
vals
.
get
(
FIELD_CardID
)));
//
_PlanRenewedOn
=
(
Date
)(
HELPER_PlanRenewedOn
.
readExternal
(
_PlanRenewedOn
,
vals
.
get
(
FIELD_PlanRenewedOn
)));
//
_UsedCredits
=
(
Integer
)(
HELPER_UsedCredits
.
readExternal
(
_UsedCredits
,
vals
.
get
(
FIELD_UsedCredits
)));
//
_UserEmail
=
(
String
)(
HELPER_UserEmail
.
readExternal
(
_UserEmail
,
vals
.
get
(
FIELD_UserEmail
)));
//
_FirstName
=
(
String
)(
HELPER_FirstName
.
readExternal
(
_FirstName
,
vals
.
get
(
FIELD_FirstName
)));
//
_LastName
=
(
String
)(
HELPER_LastName
.
readExternal
(
_LastName
,
vals
.
get
(
FIELD_LastName
)));
//
...
...
@@ -4395,6 +4666,8 @@ public abstract class BaseCompany extends BaseBusinessClass
vals
.
put
(
FIELD_NameOnCard
,
HELPER_NameOnCard
.
writeExternal
(
_NameOnCard
));
vals
.
put
(
FIELD_CardPostCode
,
HELPER_CardPostCode
.
writeExternal
(
_CardPostCode
));
vals
.
put
(
FIELD_CardID
,
HELPER_CardID
.
writeExternal
(
_CardID
));
vals
.
put
(
FIELD_PlanRenewedOn
,
HELPER_PlanRenewedOn
.
writeExternal
(
_PlanRenewedOn
));
vals
.
put
(
FIELD_UsedCredits
,
HELPER_UsedCredits
.
writeExternal
(
_UsedCredits
));
vals
.
put
(
FIELD_UserEmail
,
HELPER_UserEmail
.
writeExternal
(
_UserEmail
));
vals
.
put
(
FIELD_FirstName
,
HELPER_FirstName
.
writeExternal
(
_FirstName
));
vals
.
put
(
FIELD_LastName
,
HELPER_LastName
.
writeExternal
(
_LastName
));
...
...
@@ -4485,6 +4758,14 @@ public abstract class BaseCompany extends BaseBusinessClass
{
listener
.
notifyFieldChange
(
this
,
other
,
FIELD_CardID
,
HELPER_CardID
.
toObject
(
this
.
_CardID
),
HELPER_CardID
.
toObject
(
otherCompany
.
_CardID
));
}
if
(!
HELPER_PlanRenewedOn
.
compare
(
this
.
_PlanRenewedOn
,
otherCompany
.
_PlanRenewedOn
))
{
listener
.
notifyFieldChange
(
this
,
other
,
FIELD_PlanRenewedOn
,
HELPER_PlanRenewedOn
.
toObject
(
this
.
_PlanRenewedOn
),
HELPER_PlanRenewedOn
.
toObject
(
otherCompany
.
_PlanRenewedOn
));
}
if
(!
HELPER_UsedCredits
.
compare
(
this
.
_UsedCredits
,
otherCompany
.
_UsedCredits
))
{
listener
.
notifyFieldChange
(
this
,
other
,
FIELD_UsedCredits
,
HELPER_UsedCredits
.
toObject
(
this
.
_UsedCredits
),
HELPER_UsedCredits
.
toObject
(
otherCompany
.
_UsedCredits
));
}
// Compare single assocs
_AddedByUser
.
compare
(
otherCompany
.
_AddedByUser
,
listener
);
...
...
@@ -4536,6 +4817,8 @@ public abstract class BaseCompany extends BaseBusinessClass
visitor
.
visitField
(
this
,
FIELD_NameOnCard
,
HELPER_NameOnCard
.
toObject
(
getNameOnCard
()));
visitor
.
visitField
(
this
,
FIELD_CardPostCode
,
HELPER_CardPostCode
.
toObject
(
getCardPostCode
()));
visitor
.
visitField
(
this
,
FIELD_CardID
,
HELPER_CardID
.
toObject
(
getCardID
()));
visitor
.
visitField
(
this
,
FIELD_PlanRenewedOn
,
HELPER_PlanRenewedOn
.
toObject
(
getPlanRenewedOn
()));
visitor
.
visitField
(
this
,
FIELD_UsedCredits
,
HELPER_UsedCredits
.
toObject
(
getUsedCredits
()));
visitor
.
visitAssociation
(
_AddedByUser
);
visitor
.
visitAssociation
(
_PaymentPlan
);
visitor
.
visitAssociation
(
_Users
);
...
...
@@ -4653,6 +4936,14 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return
filter
.
matches
(
getCardID
());
}
else
if
(
attribName
.
equals
(
FIELD_PlanRenewedOn
))
{
return
filter
.
matches
(
getPlanRenewedOn
());
}
else
if
(
attribName
.
equals
(
FIELD_UsedCredits
))
{
return
filter
.
matches
(
getUsedCredits
());
}
else
if
(
attribName
.
equals
(
SINGLEREFERENCE_AddedByUser
))
{
return
filter
.
matches
(
getAddedByUser
());
...
...
@@ -4788,6 +5079,18 @@ public abstract class BaseCompany extends BaseBusinessClass
return
this
;
}
public
SearchAll
andPlanRenewedOn
(
QueryFilter
<
Date
>
filter
)
{
filter
.
addFilter
(
context
,
"tl_company.plan_renewed_on"
,
"PlanRenewedOn"
);
return
this
;
}
public
SearchAll
andUsedCredits
(
QueryFilter
<
Integer
>
filter
)
{
filter
.
addFilter
(
context
,
"tl_company.used_credits"
,
"UsedCredits"
);
return
this
;
}
public
SearchAll
andAddedByUser
(
QueryFilter
<
CompanyUser
>
filter
)
{
filter
.
addFilter
(
context
,
"tl_company.added_by_user_id"
,
"AddedByUser"
);
...
...
@@ -4899,6 +5202,14 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return
HELPER_CardID
.
toObject
(
getCardID
());
}
else
if
(
attribName
.
equals
(
FIELD_PlanRenewedOn
))
{
return
HELPER_PlanRenewedOn
.
toObject
(
getPlanRenewedOn
());
}
else
if
(
attribName
.
equals
(
FIELD_UsedCredits
))
{
return
HELPER_UsedCredits
.
toObject
(
getUsedCredits
());
}
else
if
(
attribName
.
equals
(
FIELD_UserEmail
))
{
return
HELPER_UserEmail
.
toObject
(
getUserEmail
());
...
...
@@ -5012,6 +5323,14 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return
HELPER_CardID
;
}
else
if
(
attribName
.
equals
(
FIELD_PlanRenewedOn
))
{
return
HELPER_PlanRenewedOn
;
}
else
if
(
attribName
.
equals
(
FIELD_UsedCredits
))
{
return
HELPER_UsedCredits
;
}
else
if
(
attribName
.
equals
(
FIELD_UserEmail
))
{
return
HELPER_UserEmail
;
...
...
@@ -5125,6 +5444,14 @@ public abstract class BaseCompany extends BaseBusinessClass
{
setCardID
((
String
)(
HELPER_CardID
.
fromObject
(
_CardID
,
attribValue
)));
}
else
if
(
attribName
.
equals
(
FIELD_PlanRenewedOn
))
{
setPlanRenewedOn
((
Date
)(
HELPER_PlanRenewedOn
.
fromObject
(
_PlanRenewedOn
,
attribValue
)));
}
else
if
(
attribName
.
equals
(
FIELD_UsedCredits
))
{
setUsedCredits
((
Integer
)(
HELPER_UsedCredits
.
fromObject
(
_UsedCredits
,
attribValue
)));
}
else
if
(
attribName
.
equals
(
FIELD_UserEmail
))
{
setUserEmail
((
String
)(
HELPER_UserEmail
.
fromObject
(
_UserEmail
,
attribValue
)));
...
...
@@ -5245,6 +5572,14 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return
getWriteability_CardID
();
}
else
if
(
fieldName
.
equals
(
FIELD_PlanRenewedOn
))
{
return
getWriteability_PlanRenewedOn
();
}
else
if
(
fieldName
.
equals
(
FIELD_UsedCredits
))
{
return
getWriteability_UsedCredits
();
}
else
if
(
fieldName
.
equals
(
MULTIPLEREFERENCE_Users
))
{
return
getWriteability_Users
();
...
...
@@ -5387,6 +5722,16 @@ public abstract class BaseCompany extends BaseBusinessClass
fields
.
add
(
FIELD_CardID
);
}
if
(
getWriteability_PlanRenewedOn
()
!=
FieldWriteability
.
TRUE
)
{
fields
.
add
(
FIELD_PlanRenewedOn
);
}
if
(
getWriteability_UsedCredits
()
!=
FieldWriteability
.
TRUE
)
{
fields
.
add
(
FIELD_UsedCredits
);
}
if
(
getWriteability_UserEmail
()
!=
FieldWriteability
.
TRUE
)
{
fields
.
add
(
FIELD_UserEmail
);
...
...
@@ -5457,6 +5802,8 @@ public abstract class BaseCompany extends BaseBusinessClass
result
.
add
(
HELPER_NameOnCard
.
getAttribObject
(
getClass
(),
_NameOnCard
,
false
,
FIELD_NameOnCard
));
result
.
add
(
HELPER_CardPostCode
.
getAttribObject
(
getClass
(),
_CardPostCode
,
false
,
FIELD_CardPostCode
));
result
.
add
(
HELPER_CardID
.
getAttribObject
(
getClass
(),
_CardID
,
false
,
FIELD_CardID
));
result
.
add
(
HELPER_PlanRenewedOn
.
getAttribObject
(
getClass
(),
_PlanRenewedOn
,
false
,
FIELD_PlanRenewedOn
));
result
.
add
(
HELPER_UsedCredits
.
getAttribObject
(
getClass
(),
_UsedCredits
,
false
,
FIELD_UsedCredits
));
result
.
add
(
HELPER_UserEmail
.
getAttribObject
(
getClass
(),
_UserEmail
,
false
,
FIELD_UserEmail
));
result
.
add
(
HELPER_FirstName
.
getAttribObject
(
getClass
(),
_FirstName
,
false
,
FIELD_FirstName
));
result
.
add
(
HELPER_LastName
.
getAttribObject
(
getClass
(),
_LastName
,
false
,
FIELD_LastName
));
...
...
@@ -5823,6 +6170,42 @@ public abstract class BaseCompany extends BaseBusinessClass
}
/**
* Get the attribute PlanRenewedOn
*/
public
Date
getPlanRenewedOn
(
Company
obj
,
Date
original
)
{
return
original
;
}
/**
* Change the value set for attribute PlanRenewedOn.
* May modify the field beforehand
* Occurs before validation.
*/
public
Date
setPlanRenewedOn
(
Company
obj
,
Date
newPlanRenewedOn
)
throws
FieldException
{
return
newPlanRenewedOn
;
}
/**
* Get the attribute UsedCredits
*/
public
Integer
getUsedCredits
(
Company
obj
,
Integer
original
)
{
return
original
;
}
/**
* Change the value set for attribute UsedCredits.
* May modify the field beforehand
* Occurs before validation.
*/
public
Integer
setUsedCredits
(
Company
obj
,
Integer
newUsedCredits
)
throws
FieldException
{
return
newUsedCredits
;
}
/**
* Get the attribute UserEmail
*/
public
String
getUserEmail
(
Company
obj
,
String
original
)
...
...
@@ -6144,6 +6527,14 @@ public abstract class BaseCompany extends BaseBusinessClass
{
return
toCardID
();
}
if
(
name
.
equals
(
"PlanRenewedOn"
))
{
return
toPlanRenewedOn
();
}
if
(
name
.
equals
(
"UsedCredits"
))
{
return
toUsedCredits
();
}
if
(
name
.
equals
(
"AddedByUser"
))
{
return
toAddedByUser
();
...
...
@@ -6207,6 +6598,10 @@ public abstract class BaseCompany extends BaseBusinessClass
public
PipeLine
<
From
,
String
>
toCardPostCode
()
{
return
pipe
(
new
ORMAttributePipe
<
Me
,
String
>(
FIELD_CardPostCode
));
}
public
PipeLine
<
From
,
String
>
toCardID
()
{
return
pipe
(
new
ORMAttributePipe
<
Me
,
String
>(
FIELD_CardID
));
}
public
PipeLine
<
From
,
Date
>
toPlanRenewedOn
()
{
return
pipe
(
new
ORMAttributePipe
<
Me
,
Date
>(
FIELD_PlanRenewedOn
));
}
public
PipeLine
<
From
,
Integer
>
toUsedCredits
()
{
return
pipe
(
new
ORMAttributePipe
<
Me
,
Integer
>(
FIELD_UsedCredits
));
}
public
CompanyUser
.
CompanyUserPipeLineFactory
<
From
,
CompanyUser
>
toAddedByUser
()
{
return
toAddedByUser
(
Filter
.
ALL
);
}
public
CompanyUser
.
CompanyUserPipeLineFactory
<
From
,
CompanyUser
>
toAddedByUser
(
Filter
<
CompanyUser
>
filter
)
...
...
cmsWebApp/src/performa/orm/Company.java
View file @
fdd9b7c3
...
...
@@ -146,10 +146,8 @@ public class Company extends BaseCompany
public
boolean
canCreateJob
()
{
Job
[]
openJobs
=
getOpenJobs
();
return
getPaymentPlan
()
!=
null
&&
getPaymentPlan
().
getActiveJobCount
()
>
openJobs
.
length
;
{
return
getPaymentPlan
()
!=
null
&&
getPaymentPlan
().
getActiveJobCount
()
>
getUsedCredits
();
}
...
...
cmsWebApp/src/performa/orm/Company.xml
View file @
fdd9b7c3
...
...
@@ -34,14 +34,16 @@
<ATTRIB
name=
"PostCode"
type=
"String"
dbcol=
"post_code"
mandatory=
"false"
length=
"10"
/>
<ATTRIB
name=
"City"
type=
"String"
dbcol=
"city"
mandatory=
"false"
length=
"100"
/>
<ATTRIB
name=
"HasClientSupport"
type=
"Boolean"
dbcol=
"has_client_support"
mandatory=
"false"
defaultValue=
"Boolean.FALSE"
/>
<ATTRIB
name=
"StripeReference"
type=
"String"
dbcol=
"stripe_reference"
length=
"100"
/>
<ATTRIB
name=
"StripeSubscription"
type=
"String"
dbcol=
"stripe_subscription"
length=
"100"
/>
<ATTRIB
name=
"NameOnCard"
type=
"String"
dbcol=
"name_on_card"
length=
"100"
/>
<ATTRIB
name=
"CardPostCode"
type=
"String"
dbcol=
"card_post_code"
length=
"10"
/>
<ATTRIB
name=
"CardID"
type=
"String"
dbcol=
"card_id"
length=
"100"
/>
<SINGLEREFERENCE
name=
"AddedByUser"
type=
"CompanyUser"
dbcol=
"added_by_user_id"
mandatory=
"true"
/>
<SINGLEREFERENCE
name=
"PaymentPlan"
type=
"PaymentPlan"
dbcol=
"payment_plan_id"
mandatory=
"false"
/>
<ATTRIB
name=
"StripeReference"
type=
"String"
dbcol=
"stripe_reference"
length=
"100"
/>
<ATTRIB
name=
"StripeSubscription"
type=
"String"
dbcol=
"stripe_subscription"
length=
"100"
/>
<ATTRIB
name=
"NameOnCard"
type=
"String"
dbcol=
"name_on_card"
length=
"100"
/>
<ATTRIB
name=
"CardPostCode"
type=
"String"
dbcol=
"card_post_code"
length=
"10"
/>
<ATTRIB
name=
"CardID"
type=
"String"
dbcol=
"card_id"
length=
"100"
/>
<ATTRIB
name=
"PlanRenewedOn"
type=
"Date"
dbcol=
"plan_renewed_on"
mandatory=
"false"
/>
<ATTRIB
name=
"UsedCredits"
type=
"Integer"
dbcol=
"used_credits"
/>
<SINGLEREFERENCE
name=
"AddedByUser"
type=
"CompanyUser"
dbcol=
"added_by_user_id"
mandatory=
"true"
/>
<SINGLEREFERENCE
name=
"PaymentPlan"
type=
"PaymentPlan"
dbcol=
"payment_plan_id"
mandatory=
"false"
/>
</TABLE>
...
...
cmsWebApp/src/performa/orm/CompanyPersistenceMgr.java
View file @
fdd9b7c3
...
...
@@ -45,6 +45,8 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
private
String
dummyNameOnCard
;
private
String
dummyCardPostCode
;
private
String
dummyCardID
;
private
Date
dummyPlanRenewedOn
;
private
Integer
dummyUsedCredits
;
// Static constants corresponding to attribute helpers
...
...
@@ -64,6 +66,8 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
private
static
final
DefaultAttributeHelper
HELPER_NameOnCard
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
HELPER_CardPostCode
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
HELPER_CardID
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
HELPER_PlanRenewedOn
=
DefaultAttributeHelper
.
INSTANCE
;
private
static
final
DefaultAttributeHelper
HELPER_UsedCredits
=
DefaultAttributeHelper
.
INSTANCE
;
...
...
@@ -86,10 +90,12 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
dummyNameOnCard
=
(
String
)(
HELPER_NameOnCard
.
initialise
(
dummyNameOnCard
));
dummyCardPostCode
=
(
String
)(
HELPER_CardPostCode
.
initialise
(
dummyCardPostCode
));
dummyCardID
=
(
String
)(
HELPER_CardID
.
initialise
(
dummyCardID
));
dummyPlanRenewedOn
=
(
Date
)(
HELPER_PlanRenewedOn
.
initialise
(
dummyPlanRenewedOn
));
dummyUsedCredits
=
(
Integer
)(
HELPER_UsedCredits
.
initialise
(
dummyUsedCredits
));
}
private
String
SELECT_COLUMNS
=
"{PREFIX}tl_company.object_id as id, {PREFIX}tl_company.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_company.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_company.company_name, {PREFIX}tl_company.company_logo, {PREFIX}tl_company.hiring_team_type, {PREFIX}tl_company.industry, {PREFIX}tl_company.time_zone, {PREFIX}tl_company.is_verified, {PREFIX}tl_company.state, {PREFIX}tl_company.country, {PREFIX}tl_company.post_code, {PREFIX}tl_company.city, {PREFIX}tl_company.has_client_support, {PREFIX}tl_company.stripe_reference, {PREFIX}tl_company.stripe_subscription, {PREFIX}tl_company.name_on_card, {PREFIX}tl_company.card_post_code, {PREFIX}tl_company.card_id, {PREFIX}tl_company.added_by_user_id, {PREFIX}tl_company.payment_plan_id, 1 AS commasafe "
;
private
String
SELECT_COLUMNS
=
"{PREFIX}tl_company.object_id as id, {PREFIX}tl_company.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_company.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_company.company_name, {PREFIX}tl_company.company_logo, {PREFIX}tl_company.hiring_team_type, {PREFIX}tl_company.industry, {PREFIX}tl_company.time_zone, {PREFIX}tl_company.is_verified, {PREFIX}tl_company.state, {PREFIX}tl_company.country, {PREFIX}tl_company.post_code, {PREFIX}tl_company.city, {PREFIX}tl_company.has_client_support, {PREFIX}tl_company.stripe_reference, {PREFIX}tl_company.stripe_subscription, {PREFIX}tl_company.name_on_card, {PREFIX}tl_company.card_post_code, {PREFIX}tl_company.card_id, {PREFIX}tl_company.
plan_renewed_on, {PREFIX}tl_company.used_credits, {PREFIX}tl_company.
added_by_user_id, {PREFIX}tl_company.payment_plan_id, 1 AS commasafe "
;
private
String
SELECT_JOINS
=
""
;
public
BaseBusinessClass
fetchByID
(
ObjectID
id
,
PersistentSetCollection
allPSets
,
RDBMSPersistenceContext
context
,
SQLManager
sqlMgr
)
throws
SQLException
,
StorageException
...
...
@@ -156,6 +162,8 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
!
tl_companyPSet
.
containsAttrib
(
Company
.
FIELD_NameOnCard
)||
!
tl_companyPSet
.
containsAttrib
(
Company
.
FIELD_CardPostCode
)||
!
tl_companyPSet
.
containsAttrib
(
Company
.
FIELD_CardID
)||
!
tl_companyPSet
.
containsAttrib
(
Company
.
FIELD_PlanRenewedOn
)||
!
tl_companyPSet
.
containsAttrib
(
Company
.
FIELD_UsedCredits
)||
!
tl_companyPSet
.
containsAttrib
(
Company
.
SINGLEREFERENCE_AddedByUser
)||
!
tl_companyPSet
.
containsAttrib
(
Company
.
SINGLEREFERENCE_PaymentPlan
))
{
...
...
@@ -227,10 +235,10 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
{
int
rowsUpdated
=
executeStatement
(
sqlMgr
,
"UPDATE {PREFIX}tl_company "
+
"SET company_name = ?, company_logo = ?, hiring_team_type = ?, industry = ?, time_zone = ?, is_verified = ?, state = ?, country = ?, post_code = ?, city = ?, has_client_support = ?, stripe_reference = ?, stripe_subscription = ?, name_on_card = ?, card_post_code = ?, card_id = ?, added_by_user_id = ? , payment_plan_id = ? , object_LAST_UPDATED_DATE = "
+
sqlMgr
.
getPortabilityServices
().
getTimestampExpression
()
+
" "
+
"SET company_name = ?, company_logo = ?, hiring_team_type = ?, industry = ?, time_zone = ?, is_verified = ?, state = ?, country = ?, post_code = ?, city = ?, has_client_support = ?, stripe_reference = ?, stripe_subscription = ?, name_on_card = ?, card_post_code = ?, card_id = ?,
plan_renewed_on = ?, used_credits = ?,
added_by_user_id = ? , payment_plan_id = ? , object_LAST_UPDATED_DATE = "
+
sqlMgr
.
getPortabilityServices
().
getTimestampExpression
()
+
" "
+
"WHERE tl_company.object_id = ? AND "
+
getConcurrencyCheck
(
sqlMgr
,
"object_LAST_UPDATED_DATE"
,
obj
.
getObjectLastModified
())
+
" "
,
CollectionUtils
.
listEntry
(
HELPER_CompanyName
.
getForSQL
(
dummyCompanyName
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyName
))).
listEntry
(
HELPER_CompanyLogo
.
getForSQL
(
dummyCompanyLogo
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyLogo
))).
listEntry
(
HELPER_HiringTeamType
.
getForSQL
(
dummyHiringTeamType
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HiringTeamType
))).
listEntry
(
HELPER_Industry
.
getForSQL
(
dummyIndustry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Industry
))).
listEntry
(
HELPER_TimeZone
.
getForSQL
(
dummyTimeZone
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_TimeZone
))).
listEntry
(
HELPER_IsVerified
.
getForSQL
(
dummyIsVerified
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_IsVerified
))).
listEntry
(
HELPER_State
.
getForSQL
(
dummyState
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_State
))).
listEntry
(
HELPER_Country
.
getForSQL
(
dummyCountry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Country
))).
listEntry
(
HELPER_PostCode
.
getForSQL
(
dummyPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_PostCode
))).
listEntry
(
HELPER_City
.
getForSQL
(
dummyCity
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_City
))).
listEntry
(
HELPER_HasClientSupport
.
getForSQL
(
dummyHasClientSupport
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HasClientSupport
))).
listEntry
(
HELPER_StripeReference
.
getForSQL
(
dummyStripeReference
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeReference
))).
listEntry
(
HELPER_StripeSubscription
.
getForSQL
(
dummyStripeSubscription
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeSubscription
))).
listEntry
(
HELPER_NameOnCard
.
getForSQL
(
dummyNameOnCard
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_NameOnCard
))).
listEntry
(
HELPER_CardPostCode
.
getForSQL
(
dummyCardPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardPostCode
))).
listEntry
(
HELPER_CardID
.
getForSQL
(
dummyCardID
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardID
))).
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_AddedByUser
)))).
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_PaymentPlan
)))).
listEntry
(
objectID
.
longID
()).
listEntry
(
obj
.
getObjectLastModified
()).
toList
().
toArray
());
CollectionUtils
.
listEntry
(
HELPER_CompanyName
.
getForSQL
(
dummyCompanyName
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyName
))).
listEntry
(
HELPER_CompanyLogo
.
getForSQL
(
dummyCompanyLogo
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyLogo
))).
listEntry
(
HELPER_HiringTeamType
.
getForSQL
(
dummyHiringTeamType
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HiringTeamType
))).
listEntry
(
HELPER_Industry
.
getForSQL
(
dummyIndustry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Industry
))).
listEntry
(
HELPER_TimeZone
.
getForSQL
(
dummyTimeZone
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_TimeZone
))).
listEntry
(
HELPER_IsVerified
.
getForSQL
(
dummyIsVerified
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_IsVerified
))).
listEntry
(
HELPER_State
.
getForSQL
(
dummyState
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_State
))).
listEntry
(
HELPER_Country
.
getForSQL
(
dummyCountry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Country
))).
listEntry
(
HELPER_PostCode
.
getForSQL
(
dummyPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_PostCode
))).
listEntry
(
HELPER_City
.
getForSQL
(
dummyCity
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_City
))).
listEntry
(
HELPER_HasClientSupport
.
getForSQL
(
dummyHasClientSupport
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HasClientSupport
))).
listEntry
(
HELPER_StripeReference
.
getForSQL
(
dummyStripeReference
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeReference
))).
listEntry
(
HELPER_StripeSubscription
.
getForSQL
(
dummyStripeSubscription
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeSubscription
))).
listEntry
(
HELPER_NameOnCard
.
getForSQL
(
dummyNameOnCard
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_NameOnCard
))).
listEntry
(
HELPER_CardPostCode
.
getForSQL
(
dummyCardPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardPostCode
))).
listEntry
(
HELPER_CardID
.
getForSQL
(
dummyCardID
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardID
))).
listEntry
(
HELPER_PlanRenewedOn
.
getForSQL
(
dummyPlanRenewedOn
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_PlanRenewedOn
))).
listEntry
(
HELPER_UsedCredits
.
getForSQL
(
dummyUsedCredits
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_UsedCredits
))).
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_AddedByUser
)))).
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_PaymentPlan
)))).
listEntry
(
objectID
.
longID
()).
listEntry
(
obj
.
getObjectLastModified
()).
toList
().
toArray
());
if
(
rowsUpdated
!=
1
)
{
...
...
@@ -502,6 +510,8 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
tl_companyPSet
.
setAttrib
(
Company
.
FIELD_NameOnCard
,
HELPER_NameOnCard
.
getFromRS
(
dummyNameOnCard
,
r
,
"name_on_card"
));
tl_companyPSet
.
setAttrib
(
Company
.
FIELD_CardPostCode
,
HELPER_CardPostCode
.
getFromRS
(
dummyCardPostCode
,
r
,
"card_post_code"
));
tl_companyPSet
.
setAttrib
(
Company
.
FIELD_CardID
,
HELPER_CardID
.
getFromRS
(
dummyCardID
,
r
,
"card_id"
));
tl_companyPSet
.
setAttrib
(
Company
.
FIELD_PlanRenewedOn
,
HELPER_PlanRenewedOn
.
getFromRS
(
dummyPlanRenewedOn
,
r
,
"plan_renewed_on"
));
tl_companyPSet
.
setAttrib
(
Company
.
FIELD_UsedCredits
,
HELPER_UsedCredits
.
getFromRS
(
dummyUsedCredits
,
r
,
"used_credits"
));
tl_companyPSet
.
setAttrib
(
Company
.
SINGLEREFERENCE_AddedByUser
,
r
.
getObject
(
"added_by_user_id"
));
tl_companyPSet
.
setAttrib
(
Company
.
SINGLEREFERENCE_PaymentPlan
,
r
.
getObject
(
"payment_plan_id"
));
...
...
@@ -521,10 +531,10 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
{
executeStatement
(
sqlMgr
,
"INSERT INTO {PREFIX}tl_company "
+
" (company_name, company_logo, hiring_team_type, industry, time_zone, is_verified, state, country, post_code, city, has_client_support, stripe_reference, stripe_subscription, name_on_card, card_post_code, card_id, added_by_user_id, payment_plan_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) "
+
" (company_name, company_logo, hiring_team_type, industry, time_zone, is_verified, state, country, post_code, city, has_client_support, stripe_reference, stripe_subscription, name_on_card, card_post_code, card_id,
plan_renewed_on, used_credits,
added_by_user_id, payment_plan_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) "
+
"VALUES "
+
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
+
sqlMgr
.
getPortabilityServices
().
getTimestampExpression
()
+
", "
+
sqlMgr
.
getPortabilityServices
().
getTimestampExpression
()
+
")"
,
CollectionUtils
.
listEntry
(
HELPER_CompanyName
.
getForSQL
(
dummyCompanyName
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyName
))).
listEntry
(
HELPER_CompanyLogo
.
getForSQL
(
dummyCompanyLogo
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyLogo
))).
listEntry
(
HELPER_HiringTeamType
.
getForSQL
(
dummyHiringTeamType
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HiringTeamType
))).
listEntry
(
HELPER_Industry
.
getForSQL
(
dummyIndustry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Industry
))).
listEntry
(
HELPER_TimeZone
.
getForSQL
(
dummyTimeZone
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_TimeZone
))).
listEntry
(
HELPER_IsVerified
.
getForSQL
(
dummyIsVerified
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_IsVerified
))).
listEntry
(
HELPER_State
.
getForSQL
(
dummyState
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_State
))).
listEntry
(
HELPER_Country
.
getForSQL
(
dummyCountry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Country
))).
listEntry
(
HELPER_PostCode
.
getForSQL
(
dummyPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_PostCode
))).
listEntry
(
HELPER_City
.
getForSQL
(
dummyCity
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_City
))).
listEntry
(
HELPER_HasClientSupport
.
getForSQL
(
dummyHasClientSupport
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HasClientSupport
))).
listEntry
(
HELPER_StripeReference
.
getForSQL
(
dummyStripeReference
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeReference
))).
listEntry
(
HELPER_StripeSubscription
.
getForSQL
(
dummyStripeSubscription
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeSubscription
))).
listEntry
(
HELPER_NameOnCard
.
getForSQL
(
dummyNameOnCard
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_NameOnCard
))).
listEntry
(
HELPER_CardPostCode
.
getForSQL
(
dummyCardPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardPostCode
))).
listEntry
(
HELPER_CardID
.
getForSQL
(
dummyCardID
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardID
)))
.
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_AddedByUser
)))).
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_PaymentPlan
))))
.
listEntry
(
objectID
.
longID
()).
toList
().
toArray
());
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?,
?, ?, ?, "
+
sqlMgr
.
getPortabilityServices
().
getTimestampExpression
()
+
", "
+
sqlMgr
.
getPortabilityServices
().
getTimestampExpression
()
+
")"
,
CollectionUtils
.
listEntry
(
HELPER_CompanyName
.
getForSQL
(
dummyCompanyName
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyName
))).
listEntry
(
HELPER_CompanyLogo
.
getForSQL
(
dummyCompanyLogo
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CompanyLogo
))).
listEntry
(
HELPER_HiringTeamType
.
getForSQL
(
dummyHiringTeamType
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HiringTeamType
))).
listEntry
(
HELPER_Industry
.
getForSQL
(
dummyIndustry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Industry
))).
listEntry
(
HELPER_TimeZone
.
getForSQL
(
dummyTimeZone
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_TimeZone
))).
listEntry
(
HELPER_IsVerified
.
getForSQL
(
dummyIsVerified
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_IsVerified
))).
listEntry
(
HELPER_State
.
getForSQL
(
dummyState
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_State
))).
listEntry
(
HELPER_Country
.
getForSQL
(
dummyCountry
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_Country
))).
listEntry
(
HELPER_PostCode
.
getForSQL
(
dummyPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_PostCode
))).
listEntry
(
HELPER_City
.
getForSQL
(
dummyCity
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_City
))).
listEntry
(
HELPER_HasClientSupport
.
getForSQL
(
dummyHasClientSupport
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_HasClientSupport
))).
listEntry
(
HELPER_StripeReference
.
getForSQL
(
dummyStripeReference
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeReference
))).
listEntry
(
HELPER_StripeSubscription
.
getForSQL
(
dummyStripeSubscription
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_StripeSubscription
))).
listEntry
(
HELPER_NameOnCard
.
getForSQL
(
dummyNameOnCard
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_NameOnCard
))).
listEntry
(
HELPER_CardPostCode
.
getForSQL
(
dummyCardPostCode
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardPostCode
))).
listEntry
(
HELPER_CardID
.
getForSQL
(
dummyCardID
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_CardID
)))
.
listEntry
(
HELPER_PlanRenewedOn
.
getForSQL
(
dummyPlanRenewedOn
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_PlanRenewedOn
))).
listEntry
(
HELPER_UsedCredits
.
getForSQL
(
dummyUsedCredits
,
tl_companyPSet
.
getAttrib
(
Company
.
FIELD_UsedCredits
)))
.
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_AddedByUser
)))).
listEntry
(
SQLManager
.
CheckNull
((
Long
)(
tl_companyPSet
.
getAttrib
(
Company
.
SINGLEREFERENCE_PaymentPlan
))))
.
listEntry
(
objectID
.
longID
()).
toList
().
toArray
());
tl_companyPSet
.
setStatus
(
PersistentSetStatus
.
PROCESSED
);
}
...
...
cmsWebApp/src/performa/utils/StripeUtils.java
View file @
fdd9b7c3
...
...
@@ -8,25 +8,32 @@ import com.stripe.exception.CardException;
import
com.stripe.exception.InvalidRequestException
;
import
com.stripe.model.Card
;
import
com.stripe.model.Customer
;
import
com.stripe.model.Event
;
import
com.stripe.model.Invoice
;
import
com.stripe.model.Plan
;
import
com.stripe.model.Subscription
;
import
com.stripe.net.APIResource
;
import
java.io.IOException
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
oneit.appservices.config.ConfigMgr
;
import
oneit.logging.LogLevel
;
import
oneit.logging.LogMgr
;
import
oneit.logging.LoggingArea
;
import
oneit.objstore.ObjectTransaction
;
import
oneit.objstore.StorageException
;
import
oneit.objstore.rdbms.filters.EqualsFilter
;
import
oneit.security.SecUser
;
import
oneit.utils.DateDiff
;
import
oneit.utils.parsers.FieldException
;
import
performa.orm.Company
;
import
performa.orm.CompanyUser
;
import
performa.orm.PaymentPlan
;
import
spark.utils.IOUtils
;
public
class
StripeUtils
...
...
@@ -212,4 +219,51 @@ public class StripeUtils
LogMgr
.
log
(
LoggingArea
.
ALL
,
LogLevel
.
PROCESSING1
,
ex
,
"Error while creating subscrition in stripe"
);
}
}
public
static
void
handleWebhook
(
HttpServletRequest
request
,
ObjectTransaction
objTran
)
throws
FieldException
{
try
{
String
rawJson
=
IOUtils
.
toString
(
request
.
getInputStream
());
Event
event
=
APIResource
.
GSON
.
fromJson
(
rawJson
,
Event
.
class
);
LogMgr
.
log
(
LoggingArea
.
ALL
,
LogLevel
.
PROCESSING1
,
"Event received from stripe : "
,
event
);
if
(
event
!=
null
&&
event
.
getType
().
equals
(
"invoice.payment_succeeded"
))
{
Invoice
invoice
=
(
Invoice
)
event
.
getData
().
getObject
();
LogMgr
.
log
(
LoggingArea
.
ALL
,
LogLevel
.
PROCESSING1
,
"Payment Succeeded event received from stripe with invoice : "
,
invoice
);
if
(
invoice
.
getBilling
().
equals
(
"charge_automatically"
))
{
Company
[]
companies
=
Company
.
SearchByAll
().
andStripeReference
(
new
EqualsFilter
<>(
invoice
.
getCustomer
())).
search
(
objTran
);
if
(
companies
!=
null
&&
companies
.
length
>
0
)
{
Company
company
=
companies
[
0
];
Date
invoiceDate
=
new
Date
(
invoice
.
getDate
()
*
1000L
);
if
(
company
.
getPlanRenewedOn
()
==
null
||
!
DateDiff
.
startOfDay
(
invoiceDate
).
equals
(
DateDiff
.
startOfDay
(
company
.
getPlanRenewedOn
())))
{
if
(
company
.
getPlanRenewedOn
()
!=
null
)
{
company
.
setUsedCredits
(
0
);
}
company
.
setPlanRenewedOn
(
invoiceDate
);
}
LogMgr
.
log
(
LoggingArea
.
ALL
,
LogLevel
.
PROCESSING1
,
"Setting company with reset plan details : "
,
company
);
}
}
}
}
catch
(
IOException
ex
)
{
LogMgr
.
log
(
LoggingArea
.
ALL
,
LogLevel
.
PROCESSING1
,
ex
,
"Error while handling webhook"
);
}
}
}
cmsWebApp/webroot/extensions/adminportal/CustomServlets_adminPortal.xml
View file @
fdd9b7c3
...
...
@@ -130,6 +130,10 @@
<INHERITS
factory=
"Named"
nodename=
"CoreORMAdminNoPriv"
/>
</NODE>
<NODE
name=
"webhook_jsp"
factory=
"Participant"
>
<INHERITS
factory=
"Named"
nodename=
"CoreORMAdminNoPriv"
/>
</NODE>
<NODE
name=
"ORMErrorConfig::ADMIN_PORTAL"
factory=
"Participant"
class=
"oneit.servlets.forms.ErrorReportConfig"
>
<format
item=
"field.*.error.pageHeader_performa_errorPrefix"
>
<![CDATA[<div class="error-message message-common"><img src="${contextRoot}/images/error-alert.png" class="alert-icon" /><span class="message-txt" style="font-weight: bold">${translateLabel:Errors_Occurred:Errors occurred, please correct them and try again}</span><br/>]]>
...
...
cmsWebApp/webroot/extensions/adminportal/upgrades/20180424_Alter_Company.xml
0 → 100644
View file @
fdd9b7c3
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS
name=
""
xmlns:oneit=
"http://www.1iT.com.au"
>
<NODE
name=
"Script"
factory=
"Vector"
>
<NODE
name=
"DDL"
factory=
"Participant"
class=
"oneit.sql.transfer.RedefineTableOperation"
>
<tableName
factory=
"String"
>
tl_company
</tableName>
<column
name=
"plan_renewed_on"
type=
"Date"
nullable=
"true"
/>
<column
name=
"used_credits"
type=
"Long"
nullable=
"true"
/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
cmsWebApp/webroot/extensions/adminportal/webhook.jsp
0 → 100644
View file @
fdd9b7c3
<%@page import="performa.utils.StripeUtils"%>
<%@page import="oneit.objstore.ObjectTransaction"%>
<%@page import="oneit.servlets.process.ProcessDecorator"%>
<%@page import="oneit.servlets.process.ORMProcessState"%>
<%@ page extends="oneit.servlets.jsp.FormJSP" %>
<%! protected String getName (ServletConfig config) { return "webhook_jsp"; } %>
<%
ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
ObjectTransaction objTran = process.getTransaction ();
StripeUtils.handleWebhook(request, objTran);
process.complete();
%>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment