Commit 5e8aad37 by Nilu

Stripe plan retrieval via batch. Subscribe to multiple plans in one…

Stripe plan retrieval via batch. Subscribe to multiple plans in one subscription. Creating accounts in stripe upone adding hiring teams where billing is managed on their own.
parent d8031d35
<?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.DefineTableOperation">
<tableName factory="String">tl_coupon</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="coupon_code" type="String" nullable="false" length="100"/>
<column name="percentage_off" type="Long" nullable="true"/>
<column name="duration_in_months" type="Long" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
......@@ -17,6 +17,10 @@
<column name="interval_count" type="Long" nullable="false"/>
<column name="trial_period_days" type="Long" nullable="true"/>
<column name="active_job_count" type="Long" nullable="true"/>
<column name="disabled" type="Boolean" nullable="true"/>
<column name="product_reference" type="String" nullable="true" length="100"/>
<column name="usage_type" type="String" nullable="true" length="200"/>
<column name="linked_plan" type="String" nullable="true" length="100"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?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.DefineTableOperation">
<tableName factory="String">tl_coupon</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="coupon_code" type="String" nullable="false" length="100"/>
<column name="percentage_off" type="Long" nullable="true"/>
<column name="duration_in_months" type="Long" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_coupon;
CREATE TABLE tl_coupon (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL,
duration_in_months numeric(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT PK_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -16,7 +16,11 @@ CREATE TABLE tl_payment_plan (
interval varchar(200) NOT NULL,
interval_count numeric(12) NOT NULL,
trial_period_days numeric(12) NULL,
active_job_count numeric(12) NULL
active_job_count numeric(12) NULL,
disabled char(1) NULL,
product_reference varchar(100) NULL,
usage_type varchar(200) NULL,
linked_plan varchar(100) NULL
);
......
-- DROP TABLE tl_coupon;
CREATE TABLE tl_coupon (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL,
duration_in_months numeric(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT PK_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_coupon;
CREATE TABLE tl_coupon (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
coupon_code varchar2(100) NOT NULL,
percentage_off number(12) NULL,
duration_in_months number(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT PK_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -17,7 +17,11 @@ CREATE TABLE tl_payment_plan (
interval varchar2(200) NOT NULL,
interval_count number(12) NOT NULL,
trial_period_days number(12) NULL,
active_job_count number(12) NULL
active_job_count number(12) NULL,
disabled char(1) NULL,
product_reference varchar2(100) NULL,
usage_type varchar2(200) NULL,
linked_plan varchar2(100) NULL
);
......
-- DROP TABLE tl_coupon;
CREATE TABLE tl_coupon (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
coupon_code varchar2(100) NOT NULL,
percentage_off number(12) NULL,
duration_in_months number(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT PK_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table tl_coupon;
CREATE TABLE tl_coupon (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL,
duration_in_months numeric(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT pk_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
......@@ -17,7 +17,11 @@ CREATE TABLE tl_payment_plan (
interval varchar(200) NOT NULL,
interval_count numeric(12) NOT NULL,
trial_period_days numeric(12) NULL,
active_job_count numeric(12) NULL
active_job_count numeric(12) NULL,
disabled char(1) NULL,
product_reference varchar(100) NULL,
usage_type varchar(200) NULL,
linked_plan varchar(100) NULL
);
......
-- @AutoRun
-- drop table tl_coupon;
CREATE TABLE tl_coupon (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
coupon_code varchar(100) NOT NULL,
percentage_off numeric(12) NULL,
duration_in_months numeric(12) NULL
);
ALTER TABLE tl_coupon ADD
CONSTRAINT pk_tl_coupon PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
package performa.batch;
import com.stripe.Stripe;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.exception.StripeException;
import com.stripe.model.Plan;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -17,10 +14,13 @@ import oneit.logging.LoggingArea;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.utils.filter.CollectionFilter;
import oneit.utils.filter.Filter;
import oneit.utils.parsers.FieldException;
import performa.orm.PaymentPlan;
import performa.orm.types.CurrencyType;
import performa.orm.types.Interval;
import performa.orm.types.UsageType;
import performa.utils.StripeUtils;
......@@ -38,16 +38,28 @@ public class PullStripeDataBatch extends ORMBatch
Stripe.apiKey = StripeUtils.STRIPE_KEY;
Map<String, Object> planParams = new HashMap<>();
planParams.put("active", true);
List<Plan> plansList = Plan.list(planParams).getData();
PaymentPlan[] paymentPlans = PaymentPlan.searchAll(ot);
for (PaymentPlan paymentPlan : paymentPlans)
{
paymentPlan.setDisabled(Boolean.TRUE);
}
for (Plan plan : plansList)
{
PaymentPlan[] paymentPlans = PaymentPlan.SearchByAll().andStripeReference(new EqualsFilter<>(plan.getId())).search(ot);
System.out.println("pllan :: " + plan);
Filter<PaymentPlan> filter = PaymentPlan.SearchByAll().andStripeReference(new EqualsFilter<>(plan.getId()));
List<PaymentPlan> activePlans = (List<PaymentPlan>) CollectionFilter.filter(Arrays.asList(paymentPlans) , filter);
PaymentPlan paymentPlan;
if(paymentPlans != null && paymentPlans.length > 0)
if(activePlans != null && !activePlans.isEmpty())
{
paymentPlan = paymentPlans[0];
paymentPlan = activePlans.get(0);
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, "Updating exiting payment plan: " , paymentPlan, " to match stripe plan: ", plan);
}
else
......@@ -58,25 +70,34 @@ public class PullStripeDataBatch extends ORMBatch
Map<String, String> metadata = plan.getMetadata();
String activeJobs = metadata.get("ActiveJobs");
String linkedPlan = metadata.get("LinkedPlan");
paymentPlan.setStripeReference(plan.getId());
paymentPlan.setPlanName(plan.getName());
paymentPlan.setDescription(plan.getStatementDescriptor());
paymentPlan.setPlanName(plan.getNickname());
// paymentPlan.setDescription(plan.());
paymentPlan.setCurrencyType(CurrencyType.forName(plan.getCurrency().toUpperCase()));
paymentPlan.setAmount(plan.getAmount().doubleValue() / 100);
paymentPlan.setInterval(Interval.forName(plan.getInterval().toUpperCase()));
paymentPlan.setIntervalCount(plan.getIntervalCount());
paymentPlan.setTrialPeriodDays(plan.getTrialPeriodDays());
paymentPlan.setIntervalCount(plan.getIntervalCount().intValue());
paymentPlan.setTrialPeriodDays(plan.getTrialPeriodDays().intValue());
paymentPlan.setDisabled(Boolean.FALSE);
paymentPlan.setProductReference(plan.getProduct());
paymentPlan.setUsageType(UsageType.forName(plan.getUsageType().toUpperCase()));
if(activeJobs != null)
{
paymentPlan.setActiveJobCount(Integer.valueOf(activeJobs));
}
if(linkedPlan != null)
{
paymentPlan.setLinkedPlanReference(linkedPlan);
}
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, "Saving payment plan: " , paymentPlan, " mapped from stripe plan: ", plan);
}
}
catch (AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException | StorageException | FieldException | NumberFormatException ex)
catch (StripeException ex)
{
LogMgr.log(PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, ex, "Error while pulling plan details from stripe");
......
......@@ -16,6 +16,7 @@ import oneit.utils.BusinessException;
import oneit.utils.MultiException;
import performa.orm.Company;
import performa.orm.HiringTeam;
import performa.utils.StripeUtils;
public class AddHiringTeamFP extends SaveFP
......@@ -58,6 +59,8 @@ public class AddHiringTeamFP extends SaveFP
if(hiringTeam.getManageOwnBilling())
{
hiringTeam.setBillingTeam(null);
StripeUtils.createCustomer(hiringTeam);
}
else
{
......
......@@ -13,6 +13,7 @@ import oneit.servlets.process.ORMProcessFormProcessor;
import oneit.servlets.process.ORMProcessState;
import oneit.utils.BusinessException;
import performa.orm.HiringTeam;
import performa.orm.StripeCoupon;
import performa.utils.StripeUtils;
......@@ -28,6 +29,15 @@ public class ApplyCouponFP extends ORMProcessFormProcessor
Coupon coupon = StripeUtils.retrieveCoupon(hiringTeam.getCouponCode());
if(coupon.getValid())
{
StripeCoupon stripeCoupon = StripeCoupon.createStripeCoupon(process.getTransaction());
stripeCoupon.setCouponCode(coupon.getId());
// stripeCoupon.setDurationInMonths(coupon.getDurationInMonths());
// stripeCoupon.setPercentageOff(coupon.getPercentOff());
}
System.out.println("coupon : " + coupon);
return RedisplayResult.getInstance();
......
......@@ -109,7 +109,7 @@ public class MakePaymentFP extends SaveFP
// company.setPlanRenewedOn(DateDiff.getToday());
// company.setUsedCredits(1);
StripeUtils.updatePlan(company);
// StripeUtils.updatePlan(company);
}
// restarting process as custom attributes needs to be updated to intercom
......
......@@ -69,7 +69,7 @@ public class ReplaceCardFP extends SaveFP
// cannot subscribe to a plan without card details
if(company.getPaymentPlan() != null)
{
StripeUtils.updatePlan(company);
// StripeUtils.updatePlan(company);
}
}
catch(StorageException | FieldException e)
......
......@@ -13,9 +13,8 @@ import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import oneit.utils.CollectionUtils;
import oneit.utils.MultiException;
import performa.intercom.utils.IntercomUtils;
import performa.orm.Company;
import performa.orm.HiringTeam;
import performa.orm.PaymentPlan;
import performa.utils.StripeUtils;
......@@ -28,6 +27,7 @@ public class SaveCompanyFP extends SaveFP
// Company company = process.getAttribute("Company") != null ? (Company) process.getAttribute("Company") : (Company) request.getAttribute("Company");
HiringTeam hiringTeam = (HiringTeam) process.getAttribute("HiringTeam");
Boolean isPayment = (Boolean) request.getAttribute("IsPayment");
PaymentPlan paymentPlan = (PaymentPlan) request.getAttribute("PaymentPlan");
// LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP saving company : ", company );
......@@ -35,28 +35,33 @@ public class SaveCompanyFP extends SaveFP
{
hiringTeam.setHiringTeamLogo(null);
LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP setting hiring team logo to null of hiring team : ", hiringTeam );
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"In SaveCompanyFP setting hiring team logo to null of hiring team : ", hiringTeam );
}
if(hiringTeam.getManageOwnBilling())
{
hiringTeam.setBillingTeam(null);
if(hiringTeam.getStripeReference() == null)
{
StripeUtils.createCustomer(hiringTeam);
}
}
// if(CollectionUtils.equals(isPayment, Boolean.TRUE) && company.getPaymentJobCount()!=null)
// {
// company.setPaymentPlan(company.getSelectedPaymentPlan());
//
// LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"Company payment plan updated.", company, company.getPaymentPlan());
//
// if(company.getCardID() != null )
// {
// // cannot subscribe a user to a plan without card details
// StripeUtils.updatePlan(company);
//
// LogMgr.log(Company.LOG, LogLevel.PROCESSING1,"Strpe subscription updated.", company, company.getStripeSubscription());
// }
// }
if(CollectionUtils.equals(isPayment, Boolean.TRUE))
{
hiringTeam.setPaymentPlan(paymentPlan);
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Hiring Team payment plan updated.", hiringTeam, " payment plan: ", hiringTeam.getPaymentPlan());
if(hiringTeam.getCompany().getCardID() != null )
{
// cannot subscribe a user to a plan without card details
StripeUtils.updatePlan(hiringTeam);
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1,"Strpe subscription updated.", hiringTeam, hiringTeam.getStripeSubscription());
}
}
//
// // Update company in intercom
// IntercomUtils.updateCompany(company);
......
package performa.form;
import com.stripe.Stripe;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.model.Customer;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import oneit.appservices.config.ConfigMgr;
import oneit.business.content.Article;
import oneit.components.ParticipantInitialisationContext;
import oneit.email.ConfigurableArticleTemplateEmailer;
......@@ -117,7 +106,7 @@ public class SendCompanyUserInvitesFP extends SaveFP
// Create customer in Stripe and subscribe for plan 0001 and coupon EAP. Only for 0.0.4.1 release
// Need to handle properly when plan and billing screens are added
StripeUtils.createCustomer(companyUser);
StripeUtils.createCustomer(companyUser.getDefaultHiringTeam());
LogMgr.log(LOG, LogLevel.PROCESSING1,"Created customer in Stripe, customer reference ", company.getStripeReference());
// StripeUtils.subscribeCustomer(company);
......
package performa.form;
import com.stripe.Stripe;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.exception.StripeException;
import com.stripe.model.Card;
import java.util.HashMap;
import java.util.Map;
......@@ -83,7 +82,7 @@ public class UpdateCardFP extends SaveFP
LogMgr.log(LOG, LogLevel.PROCESSING1,"Updated card details of user : ", company, " updated card : " , updatedCard );
}
catch (AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException e)
catch (StripeException e)
{
LogMgr.log(LOG, LogLevel.PROCESSING1, e, "Error while updating card details of user");
}
......
......@@ -49,6 +49,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
public static final String FIELD_IntervalCount = "IntervalCount";
public static final String FIELD_TrialPeriodDays = "TrialPeriodDays";
public static final String FIELD_ActiveJobCount = "ActiveJobCount";
public static final String FIELD_Disabled = "Disabled";
public static final String FIELD_ProductReference = "ProductReference";
public static final String FIELD_UsageType = "UsageType";
public static final String FIELD_LinkedPlanReference = "LinkedPlanReference";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
......@@ -65,6 +69,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
private static final DefaultAttributeHelper<PaymentPlan> HELPER_IntervalCount = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<PaymentPlan> HELPER_TrialPeriodDays = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<PaymentPlan> HELPER_ActiveJobCount = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<PaymentPlan> HELPER_Disabled = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<PaymentPlan> HELPER_ProductReference = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<PaymentPlan, UsageType> HELPER_UsageType = new EnumeratedAttributeHelper<PaymentPlan, UsageType> (UsageType.FACTORY_UsageType);
private static final DefaultAttributeHelper<PaymentPlan> HELPER_LinkedPlanReference = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
......@@ -77,6 +85,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
private Integer _IntervalCount;
private Integer _TrialPeriodDays;
private Integer _ActiveJobCount;
private Boolean _Disabled;
private String _ProductReference;
private UsageType _UsageType;
private String _LinkedPlanReference;
// Private attributes corresponding to single references
......@@ -98,6 +110,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
private static final AttributeValidator[] FIELD_IntervalCount_Validators;
private static final AttributeValidator[] FIELD_TrialPeriodDays_Validators;
private static final AttributeValidator[] FIELD_ActiveJobCount_Validators;
private static final AttributeValidator[] FIELD_Disabled_Validators;
private static final AttributeValidator[] FIELD_ProductReference_Validators;
private static final AttributeValidator[] FIELD_UsageType_Validators;
private static final AttributeValidator[] FIELD_LinkedPlanReference_Validators;
// Arrays of behaviour decorators
......@@ -120,6 +136,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
FIELD_IntervalCount_Validators = (AttributeValidator[])setupAttribMetaData_IntervalCount(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_TrialPeriodDays_Validators = (AttributeValidator[])setupAttribMetaData_TrialPeriodDays(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ActiveJobCount_Validators = (AttributeValidator[])setupAttribMetaData_ActiveJobCount(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Disabled_Validators = (AttributeValidator[])setupAttribMetaData_Disabled(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ProductReference_Validators = (AttributeValidator[])setupAttribMetaData_ProductReference(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_UsageType_Validators = (AttributeValidator[])setupAttribMetaData_UsageType(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_LinkedPlanReference_Validators = (AttributeValidator[])setupAttribMetaData_LinkedPlanReference(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_PaymentPlan.initialiseReference ();
......@@ -309,6 +329,81 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Disabled(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "disabled");
metaInfo.put ("name", "Disabled");
metaInfo.put ("type", "Boolean");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.Disabled:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_Disabled, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "Disabled", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.Disabled:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ProductReference(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "product_reference");
metaInfo.put ("length", "100");
metaInfo.put ("name", "ProductReference");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.ProductReference:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_ProductReference, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "ProductReference", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.ProductReference:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_UsageType(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "usage_type");
metaInfo.put ("name", "UsageType");
metaInfo.put ("type", "UsageType");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.UsageType:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_UsageType, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "UsageType", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.UsageType:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_LinkedPlanReference(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "linked_plan");
metaInfo.put ("length", "100");
metaInfo.put ("name", "LinkedPlanReference");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.LinkedPlanReference:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_LinkedPlanReference, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "LinkedPlanReference", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.LinkedPlanReference:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
......@@ -345,6 +440,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
_IntervalCount = (Integer)(HELPER_IntervalCount.initialise (_IntervalCount));
_TrialPeriodDays = (Integer)(HELPER_TrialPeriodDays.initialise (_TrialPeriodDays));
_ActiveJobCount = (Integer)(HELPER_ActiveJobCount.initialise (_ActiveJobCount));
_Disabled = (Boolean)(HELPER_Disabled.initialise (_Disabled));
_ProductReference = (String)(HELPER_ProductReference.initialise (_ProductReference));
_UsageType = (UsageType)(HELPER_UsageType.initialise (_UsageType));
_LinkedPlanReference = (String)(HELPER_LinkedPlanReference.initialise (_LinkedPlanReference));
}
......@@ -993,47 +1092,439 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postIntervalCountChange () throws FieldException
protected void postIntervalCountChange () throws FieldException
{
}
public FieldWriteability getWriteability_IntervalCount ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute IntervalCount. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setIntervalCount (Integer newIntervalCount) throws FieldException
{
boolean oldAndNewIdentical = HELPER_IntervalCount.compare (_IntervalCount, newIntervalCount);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newIntervalCount = bhd.setIntervalCount ((PaymentPlan)this, newIntervalCount);
oldAndNewIdentical = HELPER_IntervalCount.compare (_IntervalCount, newIntervalCount);
}
BusinessObjectParser.assertFieldCondition (newIntervalCount != null, this, FIELD_IntervalCount, "mandatory");
if (FIELD_IntervalCount_Validators.length > 0)
{
Object newIntervalCountObj = HELPER_IntervalCount.toObject (newIntervalCount);
if (newIntervalCountObj != null)
{
int loopMax = FIELD_IntervalCount_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_IntervalCount);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_IntervalCount_Validators[v].checkAttribute (this, FIELD_IntervalCount, metadata, newIntervalCountObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_IntervalCount () != FieldWriteability.FALSE, "Field IntervalCount is not writeable");
preIntervalCountChange (newIntervalCount);
markFieldChange (FIELD_IntervalCount);
_IntervalCount = newIntervalCount;
postFieldChange (FIELD_IntervalCount);
postIntervalCountChange ();
}
}
/**
* Get the attribute TrialPeriodDays
*/
public Integer getTrialPeriodDays ()
{
assertValid();
Integer valToReturn = _TrialPeriodDays;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getTrialPeriodDays ((PaymentPlan)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 preTrialPeriodDaysChange (Integer newTrialPeriodDays) 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 postTrialPeriodDaysChange () throws FieldException
{
}
public FieldWriteability getWriteability_TrialPeriodDays ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute TrialPeriodDays. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setTrialPeriodDays (Integer newTrialPeriodDays) throws FieldException
{
boolean oldAndNewIdentical = HELPER_TrialPeriodDays.compare (_TrialPeriodDays, newTrialPeriodDays);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newTrialPeriodDays = bhd.setTrialPeriodDays ((PaymentPlan)this, newTrialPeriodDays);
oldAndNewIdentical = HELPER_TrialPeriodDays.compare (_TrialPeriodDays, newTrialPeriodDays);
}
if (FIELD_TrialPeriodDays_Validators.length > 0)
{
Object newTrialPeriodDaysObj = HELPER_TrialPeriodDays.toObject (newTrialPeriodDays);
if (newTrialPeriodDaysObj != null)
{
int loopMax = FIELD_TrialPeriodDays_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_TrialPeriodDays);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_TrialPeriodDays_Validators[v].checkAttribute (this, FIELD_TrialPeriodDays, metadata, newTrialPeriodDaysObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_TrialPeriodDays () != FieldWriteability.FALSE, "Field TrialPeriodDays is not writeable");
preTrialPeriodDaysChange (newTrialPeriodDays);
markFieldChange (FIELD_TrialPeriodDays);
_TrialPeriodDays = newTrialPeriodDays;
postFieldChange (FIELD_TrialPeriodDays);
postTrialPeriodDaysChange ();
}
}
/**
* Get the attribute ActiveJobCount
*/
public Integer getActiveJobCount ()
{
assertValid();
Integer valToReturn = _ActiveJobCount;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getActiveJobCount ((PaymentPlan)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 preActiveJobCountChange (Integer newActiveJobCount) 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 postActiveJobCountChange () throws FieldException
{
}
public FieldWriteability getWriteability_ActiveJobCount ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ActiveJobCount. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setActiveJobCount (Integer newActiveJobCount) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ActiveJobCount.compare (_ActiveJobCount, newActiveJobCount);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newActiveJobCount = bhd.setActiveJobCount ((PaymentPlan)this, newActiveJobCount);
oldAndNewIdentical = HELPER_ActiveJobCount.compare (_ActiveJobCount, newActiveJobCount);
}
if (FIELD_ActiveJobCount_Validators.length > 0)
{
Object newActiveJobCountObj = HELPER_ActiveJobCount.toObject (newActiveJobCount);
if (newActiveJobCountObj != null)
{
int loopMax = FIELD_ActiveJobCount_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_ActiveJobCount);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ActiveJobCount_Validators[v].checkAttribute (this, FIELD_ActiveJobCount, metadata, newActiveJobCountObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ActiveJobCount () != FieldWriteability.FALSE, "Field ActiveJobCount is not writeable");
preActiveJobCountChange (newActiveJobCount);
markFieldChange (FIELD_ActiveJobCount);
_ActiveJobCount = newActiveJobCount;
postFieldChange (FIELD_ActiveJobCount);
postActiveJobCountChange ();
}
}
/**
* Get the attribute Disabled
*/
public Boolean getDisabled ()
{
assertValid();
Boolean valToReturn = _Disabled;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getDisabled ((PaymentPlan)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 preDisabledChange (Boolean newDisabled) 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 postDisabledChange () throws FieldException
{
}
public FieldWriteability getWriteability_Disabled ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Disabled. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDisabled (Boolean newDisabled) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Disabled.compare (_Disabled, newDisabled);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newDisabled = bhd.setDisabled ((PaymentPlan)this, newDisabled);
oldAndNewIdentical = HELPER_Disabled.compare (_Disabled, newDisabled);
}
if (FIELD_Disabled_Validators.length > 0)
{
Object newDisabledObj = HELPER_Disabled.toObject (newDisabled);
if (newDisabledObj != null)
{
int loopMax = FIELD_Disabled_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_Disabled);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Disabled_Validators[v].checkAttribute (this, FIELD_Disabled, metadata, newDisabledObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Disabled () != FieldWriteability.FALSE, "Field Disabled is not writeable");
preDisabledChange (newDisabled);
markFieldChange (FIELD_Disabled);
_Disabled = newDisabled;
postFieldChange (FIELD_Disabled);
postDisabledChange ();
}
}
/**
* Get the attribute ProductReference
*/
public String getProductReference ()
{
assertValid();
String valToReturn = _ProductReference;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getProductReference ((PaymentPlan)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 preProductReferenceChange (String newProductReference) 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 postProductReferenceChange () throws FieldException
{
}
public FieldWriteability getWriteability_IntervalCount ()
public FieldWriteability getWriteability_ProductReference ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute IntervalCount. Checks to ensure a new value
* Set the attribute ProductReference. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setIntervalCount (Integer newIntervalCount) throws FieldException
public void setProductReference (String newProductReference) throws FieldException
{
boolean oldAndNewIdentical = HELPER_IntervalCount.compare (_IntervalCount, newIntervalCount);
boolean oldAndNewIdentical = HELPER_ProductReference.compare (_ProductReference, newProductReference);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newIntervalCount = bhd.setIntervalCount ((PaymentPlan)this, newIntervalCount);
oldAndNewIdentical = HELPER_IntervalCount.compare (_IntervalCount, newIntervalCount);
newProductReference = bhd.setProductReference ((PaymentPlan)this, newProductReference);
oldAndNewIdentical = HELPER_ProductReference.compare (_ProductReference, newProductReference);
}
BusinessObjectParser.assertFieldCondition (newIntervalCount != null, this, FIELD_IntervalCount, "mandatory");
if (FIELD_IntervalCount_Validators.length > 0)
if (FIELD_ProductReference_Validators.length > 0)
{
Object newIntervalCountObj = HELPER_IntervalCount.toObject (newIntervalCount);
Object newProductReferenceObj = HELPER_ProductReference.toObject (newProductReference);
if (newIntervalCountObj != null)
if (newProductReferenceObj != null)
{
int loopMax = FIELD_IntervalCount_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_IntervalCount);
int loopMax = FIELD_ProductReference_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_ProductReference);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_IntervalCount_Validators[v].checkAttribute (this, FIELD_IntervalCount, metadata, newIntervalCountObj);
FIELD_ProductReference_Validators[v].checkAttribute (this, FIELD_ProductReference, metadata, newProductReferenceObj);
}
}
}
......@@ -1051,26 +1542,26 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_IntervalCount () != FieldWriteability.FALSE, "Field IntervalCount is not writeable");
preIntervalCountChange (newIntervalCount);
markFieldChange (FIELD_IntervalCount);
_IntervalCount = newIntervalCount;
postFieldChange (FIELD_IntervalCount);
postIntervalCountChange ();
Debug.assertion (getWriteability_ProductReference () != FieldWriteability.FALSE, "Field ProductReference is not writeable");
preProductReferenceChange (newProductReference);
markFieldChange (FIELD_ProductReference);
_ProductReference = newProductReference;
postFieldChange (FIELD_ProductReference);
postProductReferenceChange ();
}
}
/**
* Get the attribute TrialPeriodDays
* Get the attribute UsageType
*/
public Integer getTrialPeriodDays ()
public UsageType getUsageType ()
{
assertValid();
Integer valToReturn = _TrialPeriodDays;
UsageType valToReturn = _UsageType;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getTrialPeriodDays ((PaymentPlan)this, valToReturn);
valToReturn = bhd.getUsageType ((PaymentPlan)this, valToReturn);
}
return valToReturn;
......@@ -1082,7 +1573,7 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
* 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 preTrialPeriodDaysChange (Integer newTrialPeriodDays) throws FieldException
protected void preUsageTypeChange (UsageType newUsageType) throws FieldException
{
}
......@@ -1092,46 +1583,46 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postTrialPeriodDaysChange () throws FieldException
protected void postUsageTypeChange () throws FieldException
{
}
public FieldWriteability getWriteability_TrialPeriodDays ()
public FieldWriteability getWriteability_UsageType ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute TrialPeriodDays. Checks to ensure a new value
* Set the attribute UsageType. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setTrialPeriodDays (Integer newTrialPeriodDays) throws FieldException
public void setUsageType (UsageType newUsageType) throws FieldException
{
boolean oldAndNewIdentical = HELPER_TrialPeriodDays.compare (_TrialPeriodDays, newTrialPeriodDays);
boolean oldAndNewIdentical = HELPER_UsageType.compare (_UsageType, newUsageType);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newTrialPeriodDays = bhd.setTrialPeriodDays ((PaymentPlan)this, newTrialPeriodDays);
oldAndNewIdentical = HELPER_TrialPeriodDays.compare (_TrialPeriodDays, newTrialPeriodDays);
newUsageType = bhd.setUsageType ((PaymentPlan)this, newUsageType);
oldAndNewIdentical = HELPER_UsageType.compare (_UsageType, newUsageType);
}
if (FIELD_TrialPeriodDays_Validators.length > 0)
if (FIELD_UsageType_Validators.length > 0)
{
Object newTrialPeriodDaysObj = HELPER_TrialPeriodDays.toObject (newTrialPeriodDays);
Object newUsageTypeObj = HELPER_UsageType.toObject (newUsageType);
if (newTrialPeriodDaysObj != null)
if (newUsageTypeObj != null)
{
int loopMax = FIELD_TrialPeriodDays_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_TrialPeriodDays);
int loopMax = FIELD_UsageType_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_UsageType);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_TrialPeriodDays_Validators[v].checkAttribute (this, FIELD_TrialPeriodDays, metadata, newTrialPeriodDaysObj);
FIELD_UsageType_Validators[v].checkAttribute (this, FIELD_UsageType, metadata, newUsageTypeObj);
}
}
}
......@@ -1149,26 +1640,26 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_TrialPeriodDays () != FieldWriteability.FALSE, "Field TrialPeriodDays is not writeable");
preTrialPeriodDaysChange (newTrialPeriodDays);
markFieldChange (FIELD_TrialPeriodDays);
_TrialPeriodDays = newTrialPeriodDays;
postFieldChange (FIELD_TrialPeriodDays);
postTrialPeriodDaysChange ();
Debug.assertion (getWriteability_UsageType () != FieldWriteability.FALSE, "Field UsageType is not writeable");
preUsageTypeChange (newUsageType);
markFieldChange (FIELD_UsageType);
_UsageType = newUsageType;
postFieldChange (FIELD_UsageType);
postUsageTypeChange ();
}
}
/**
* Get the attribute ActiveJobCount
* Get the attribute LinkedPlanReference
*/
public Integer getActiveJobCount ()
public String getLinkedPlanReference ()
{
assertValid();
Integer valToReturn = _ActiveJobCount;
String valToReturn = _LinkedPlanReference;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getActiveJobCount ((PaymentPlan)this, valToReturn);
valToReturn = bhd.getLinkedPlanReference ((PaymentPlan)this, valToReturn);
}
return valToReturn;
......@@ -1180,7 +1671,7 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
* 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 preActiveJobCountChange (Integer newActiveJobCount) throws FieldException
protected void preLinkedPlanReferenceChange (String newLinkedPlanReference) throws FieldException
{
}
......@@ -1190,46 +1681,46 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postActiveJobCountChange () throws FieldException
protected void postLinkedPlanReferenceChange () throws FieldException
{
}
public FieldWriteability getWriteability_ActiveJobCount ()
public FieldWriteability getWriteability_LinkedPlanReference ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ActiveJobCount. Checks to ensure a new value
* Set the attribute LinkedPlanReference. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setActiveJobCount (Integer newActiveJobCount) throws FieldException
public void setLinkedPlanReference (String newLinkedPlanReference) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ActiveJobCount.compare (_ActiveJobCount, newActiveJobCount);
boolean oldAndNewIdentical = HELPER_LinkedPlanReference.compare (_LinkedPlanReference, newLinkedPlanReference);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newActiveJobCount = bhd.setActiveJobCount ((PaymentPlan)this, newActiveJobCount);
oldAndNewIdentical = HELPER_ActiveJobCount.compare (_ActiveJobCount, newActiveJobCount);
newLinkedPlanReference = bhd.setLinkedPlanReference ((PaymentPlan)this, newLinkedPlanReference);
oldAndNewIdentical = HELPER_LinkedPlanReference.compare (_LinkedPlanReference, newLinkedPlanReference);
}
if (FIELD_ActiveJobCount_Validators.length > 0)
if (FIELD_LinkedPlanReference_Validators.length > 0)
{
Object newActiveJobCountObj = HELPER_ActiveJobCount.toObject (newActiveJobCount);
Object newLinkedPlanReferenceObj = HELPER_LinkedPlanReference.toObject (newLinkedPlanReference);
if (newActiveJobCountObj != null)
if (newLinkedPlanReferenceObj != null)
{
int loopMax = FIELD_ActiveJobCount_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_ActiveJobCount);
int loopMax = FIELD_LinkedPlanReference_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_LinkedPlanReference);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ActiveJobCount_Validators[v].checkAttribute (this, FIELD_ActiveJobCount, metadata, newActiveJobCountObj);
FIELD_LinkedPlanReference_Validators[v].checkAttribute (this, FIELD_LinkedPlanReference, metadata, newLinkedPlanReferenceObj);
}
}
}
......@@ -1247,12 +1738,12 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ActiveJobCount () != FieldWriteability.FALSE, "Field ActiveJobCount is not writeable");
preActiveJobCountChange (newActiveJobCount);
markFieldChange (FIELD_ActiveJobCount);
_ActiveJobCount = newActiveJobCount;
postFieldChange (FIELD_ActiveJobCount);
postActiveJobCountChange ();
Debug.assertion (getWriteability_LinkedPlanReference () != FieldWriteability.FALSE, "Field LinkedPlanReference is not writeable");
preLinkedPlanReferenceChange (newLinkedPlanReference);
markFieldChange (FIELD_LinkedPlanReference);
_LinkedPlanReference = newLinkedPlanReference;
postFieldChange (FIELD_LinkedPlanReference);
postLinkedPlanReferenceChange ();
}
}
......@@ -1523,6 +2014,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
tl_payment_planPSet.setAttrib (FIELD_IntervalCount, HELPER_IntervalCount.toObject (_IntervalCount)); //
tl_payment_planPSet.setAttrib (FIELD_TrialPeriodDays, HELPER_TrialPeriodDays.toObject (_TrialPeriodDays)); //
tl_payment_planPSet.setAttrib (FIELD_ActiveJobCount, HELPER_ActiveJobCount.toObject (_ActiveJobCount)); //
tl_payment_planPSet.setAttrib (FIELD_Disabled, HELPER_Disabled.toObject (_Disabled)); //
tl_payment_planPSet.setAttrib (FIELD_ProductReference, HELPER_ProductReference.toObject (_ProductReference)); //
tl_payment_planPSet.setAttrib (FIELD_UsageType, HELPER_UsageType.toObject (_UsageType)); //
tl_payment_planPSet.setAttrib (FIELD_LinkedPlanReference, HELPER_LinkedPlanReference.toObject (_LinkedPlanReference)); //
}
......@@ -1546,6 +2041,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
_IntervalCount = (Integer)(HELPER_IntervalCount.fromObject (_IntervalCount, tl_payment_planPSet.getAttrib (FIELD_IntervalCount))); //
_TrialPeriodDays = (Integer)(HELPER_TrialPeriodDays.fromObject (_TrialPeriodDays, tl_payment_planPSet.getAttrib (FIELD_TrialPeriodDays))); //
_ActiveJobCount = (Integer)(HELPER_ActiveJobCount.fromObject (_ActiveJobCount, tl_payment_planPSet.getAttrib (FIELD_ActiveJobCount))); //
_Disabled = (Boolean)(HELPER_Disabled.fromObject (_Disabled, tl_payment_planPSet.getAttrib (FIELD_Disabled))); //
_ProductReference = (String)(HELPER_ProductReference.fromObject (_ProductReference, tl_payment_planPSet.getAttrib (FIELD_ProductReference))); //
_UsageType = (UsageType)(HELPER_UsageType.fromObject (_UsageType, tl_payment_planPSet.getAttrib (FIELD_UsageType))); //
_LinkedPlanReference = (String)(HELPER_LinkedPlanReference.fromObject (_LinkedPlanReference, tl_payment_planPSet.getAttrib (FIELD_LinkedPlanReference))); //
}
......@@ -1642,6 +2141,42 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
e.addException (ex);
}
try
{
setDisabled (otherPaymentPlan.getDisabled ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setProductReference (otherPaymentPlan.getProductReference ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setUsageType (otherPaymentPlan.getUsageType ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setLinkedPlanReference (otherPaymentPlan.getLinkedPlanReference ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
......@@ -1666,6 +2201,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
_IntervalCount = sourcePaymentPlan._IntervalCount;
_TrialPeriodDays = sourcePaymentPlan._TrialPeriodDays;
_ActiveJobCount = sourcePaymentPlan._ActiveJobCount;
_Disabled = sourcePaymentPlan._Disabled;
_ProductReference = sourcePaymentPlan._ProductReference;
_UsageType = sourcePaymentPlan._UsageType;
_LinkedPlanReference = sourcePaymentPlan._LinkedPlanReference;
}
}
......@@ -1727,6 +2266,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
_IntervalCount = (Integer)(HELPER_IntervalCount.readExternal (_IntervalCount, vals.get(FIELD_IntervalCount))); //
_TrialPeriodDays = (Integer)(HELPER_TrialPeriodDays.readExternal (_TrialPeriodDays, vals.get(FIELD_TrialPeriodDays))); //
_ActiveJobCount = (Integer)(HELPER_ActiveJobCount.readExternal (_ActiveJobCount, vals.get(FIELD_ActiveJobCount))); //
_Disabled = (Boolean)(HELPER_Disabled.readExternal (_Disabled, vals.get(FIELD_Disabled))); //
_ProductReference = (String)(HELPER_ProductReference.readExternal (_ProductReference, vals.get(FIELD_ProductReference))); //
_UsageType = (UsageType)(HELPER_UsageType.readExternal (_UsageType, vals.get(FIELD_UsageType))); //
_LinkedPlanReference = (String)(HELPER_LinkedPlanReference.readExternal (_LinkedPlanReference, vals.get(FIELD_LinkedPlanReference))); //
}
......@@ -1747,6 +2290,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
vals.put (FIELD_IntervalCount, HELPER_IntervalCount.writeExternal (_IntervalCount));
vals.put (FIELD_TrialPeriodDays, HELPER_TrialPeriodDays.writeExternal (_TrialPeriodDays));
vals.put (FIELD_ActiveJobCount, HELPER_ActiveJobCount.writeExternal (_ActiveJobCount));
vals.put (FIELD_Disabled, HELPER_Disabled.writeExternal (_Disabled));
vals.put (FIELD_ProductReference, HELPER_ProductReference.writeExternal (_ProductReference));
vals.put (FIELD_UsageType, HELPER_UsageType.writeExternal (_UsageType));
vals.put (FIELD_LinkedPlanReference, HELPER_LinkedPlanReference.writeExternal (_LinkedPlanReference));
}
......@@ -1796,6 +2343,22 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
{
listener.notifyFieldChange(this, other, FIELD_ActiveJobCount, HELPER_ActiveJobCount.toObject(this._ActiveJobCount), HELPER_ActiveJobCount.toObject(otherPaymentPlan._ActiveJobCount));
}
if (!HELPER_Disabled.compare(this._Disabled, otherPaymentPlan._Disabled))
{
listener.notifyFieldChange(this, other, FIELD_Disabled, HELPER_Disabled.toObject(this._Disabled), HELPER_Disabled.toObject(otherPaymentPlan._Disabled));
}
if (!HELPER_ProductReference.compare(this._ProductReference, otherPaymentPlan._ProductReference))
{
listener.notifyFieldChange(this, other, FIELD_ProductReference, HELPER_ProductReference.toObject(this._ProductReference), HELPER_ProductReference.toObject(otherPaymentPlan._ProductReference));
}
if (!HELPER_UsageType.compare(this._UsageType, otherPaymentPlan._UsageType))
{
listener.notifyFieldChange(this, other, FIELD_UsageType, HELPER_UsageType.toObject(this._UsageType), HELPER_UsageType.toObject(otherPaymentPlan._UsageType));
}
if (!HELPER_LinkedPlanReference.compare(this._LinkedPlanReference, otherPaymentPlan._LinkedPlanReference))
{
listener.notifyFieldChange(this, other, FIELD_LinkedPlanReference, HELPER_LinkedPlanReference.toObject(this._LinkedPlanReference), HELPER_LinkedPlanReference.toObject(otherPaymentPlan._LinkedPlanReference));
}
// Compare single assocs
......@@ -1827,6 +2390,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
visitor.visitField(this, FIELD_IntervalCount, HELPER_IntervalCount.toObject(getIntervalCount()));
visitor.visitField(this, FIELD_TrialPeriodDays, HELPER_TrialPeriodDays.toObject(getTrialPeriodDays()));
visitor.visitField(this, FIELD_ActiveJobCount, HELPER_ActiveJobCount.toObject(getActiveJobCount()));
visitor.visitField(this, FIELD_Disabled, HELPER_Disabled.toObject(getDisabled()));
visitor.visitField(this, FIELD_ProductReference, HELPER_ProductReference.toObject(getProductReference()));
visitor.visitField(this, FIELD_UsageType, HELPER_UsageType.toObject(getUsageType()));
visitor.visitField(this, FIELD_LinkedPlanReference, HELPER_LinkedPlanReference.toObject(getLinkedPlanReference()));
}
......@@ -1896,6 +2463,22 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
{
return filter.matches (getActiveJobCount ());
}
else if (attribName.equals (FIELD_Disabled))
{
return filter.matches (getDisabled ());
}
else if (attribName.equals (FIELD_ProductReference))
{
return filter.matches (getProductReference ());
}
else if (attribName.equals (FIELD_UsageType))
{
return filter.matches (getUsageType ());
}
else if (attribName.equals (FIELD_LinkedPlanReference))
{
return filter.matches (getLinkedPlanReference ());
}
else
{
return super.testFilter (attribName, filter);
......@@ -1981,6 +2564,30 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
return this;
}
public SearchAll andDisabled (QueryFilter<Boolean> filter)
{
filter.addFilter (context, "tl_payment_plan.disabled", "Disabled");
return this;
}
public SearchAll andProductReference (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.product_reference", "ProductReference");
return this;
}
public SearchAll andUsageType (QueryFilter<UsageType> filter)
{
filter.addFilter (context, "tl_payment_plan.usage_type", "UsageType");
return this;
}
public SearchAll andLinkedPlanReference (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.linked_plan", "LinkedPlanReference");
return this;
}
public PaymentPlan[]
search (ObjectTransaction transaction) throws StorageException
{
......@@ -2086,6 +2693,30 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
return this;
}
public SearchMax andDisabled (QueryFilter<Boolean> filter)
{
filter.addFilter (context, "tl_payment_plan.disabled", "Disabled");
return this;
}
public SearchMax andProductReference (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.product_reference", "ProductReference");
return this;
}
public SearchMax andUsageType (QueryFilter<UsageType> filter)
{
filter.addFilter (context, "tl_payment_plan.usage_type", "UsageType");
return this;
}
public SearchMax andLinkedPlanReference (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.linked_plan", "LinkedPlanReference");
return this;
}
public PaymentPlan search (ObjectTransaction transaction) throws StorageException
{
......@@ -2155,6 +2786,22 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
{
return HELPER_ActiveJobCount.toObject (getActiveJobCount ());
}
else if (attribName.equals (FIELD_Disabled))
{
return HELPER_Disabled.toObject (getDisabled ());
}
else if (attribName.equals (FIELD_ProductReference))
{
return HELPER_ProductReference.toObject (getProductReference ());
}
else if (attribName.equals (FIELD_UsageType))
{
return HELPER_UsageType.toObject (getUsageType ());
}
else if (attribName.equals (FIELD_LinkedPlanReference))
{
return HELPER_LinkedPlanReference.toObject (getLinkedPlanReference ());
}
else
{
return super.getAttribute (attribName);
......@@ -2204,6 +2851,22 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
{
return HELPER_ActiveJobCount;
}
else if (attribName.equals (FIELD_Disabled))
{
return HELPER_Disabled;
}
else if (attribName.equals (FIELD_ProductReference))
{
return HELPER_ProductReference;
}
else if (attribName.equals (FIELD_UsageType))
{
return HELPER_UsageType;
}
else if (attribName.equals (FIELD_LinkedPlanReference))
{
return HELPER_LinkedPlanReference;
}
else
{
return super.getAttributeHelper (attribName);
......@@ -2253,6 +2916,22 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
{
setActiveJobCount ((Integer)(HELPER_ActiveJobCount.fromObject (_ActiveJobCount, attribValue)));
}
else if (attribName.equals (FIELD_Disabled))
{
setDisabled ((Boolean)(HELPER_Disabled.fromObject (_Disabled, attribValue)));
}
else if (attribName.equals (FIELD_ProductReference))
{
setProductReference ((String)(HELPER_ProductReference.fromObject (_ProductReference, attribValue)));
}
else if (attribName.equals (FIELD_UsageType))
{
setUsageType ((UsageType)(HELPER_UsageType.fromObject (_UsageType, attribValue)));
}
else if (attribName.equals (FIELD_LinkedPlanReference))
{
setLinkedPlanReference ((String)(HELPER_LinkedPlanReference.fromObject (_LinkedPlanReference, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
......@@ -2309,6 +2988,22 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
{
return getWriteability_ActiveJobCount ();
}
else if (fieldName.equals (FIELD_Disabled))
{
return getWriteability_Disabled ();
}
else if (fieldName.equals (FIELD_ProductReference))
{
return getWriteability_ProductReference ();
}
else if (fieldName.equals (FIELD_UsageType))
{
return getWriteability_UsageType ();
}
else if (fieldName.equals (FIELD_LinkedPlanReference))
{
return getWriteability_LinkedPlanReference ();
}
else
{
return super.getWriteable (fieldName);
......@@ -2364,6 +3059,26 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
fields.add (FIELD_ActiveJobCount);
}
if (getWriteability_Disabled () != FieldWriteability.TRUE)
{
fields.add (FIELD_Disabled);
}
if (getWriteability_ProductReference () != FieldWriteability.TRUE)
{
fields.add (FIELD_ProductReference);
}
if (getWriteability_UsageType () != FieldWriteability.TRUE)
{
fields.add (FIELD_UsageType);
}
if (getWriteability_LinkedPlanReference () != FieldWriteability.TRUE)
{
fields.add (FIELD_LinkedPlanReference);
}
super.putUnwriteable (fields);
}
......@@ -2382,6 +3097,10 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
result.add(HELPER_IntervalCount.getAttribObject (getClass (), _IntervalCount, true, FIELD_IntervalCount));
result.add(HELPER_TrialPeriodDays.getAttribObject (getClass (), _TrialPeriodDays, false, FIELD_TrialPeriodDays));
result.add(HELPER_ActiveJobCount.getAttribObject (getClass (), _ActiveJobCount, false, FIELD_ActiveJobCount));
result.add(HELPER_Disabled.getAttribObject (getClass (), _Disabled, false, FIELD_Disabled));
result.add(HELPER_ProductReference.getAttribObject (getClass (), _ProductReference, false, FIELD_ProductReference));
result.add(HELPER_UsageType.getAttribObject (getClass (), _UsageType, false, FIELD_UsageType));
result.add(HELPER_LinkedPlanReference.getAttribObject (getClass (), _LinkedPlanReference, false, FIELD_LinkedPlanReference));
return result;
}
......@@ -2594,6 +3313,78 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
return newActiveJobCount;
}
/**
* Get the attribute Disabled
*/
public Boolean getDisabled (PaymentPlan obj, Boolean original)
{
return original;
}
/**
* Change the value set for attribute Disabled.
* May modify the field beforehand
* Occurs before validation.
*/
public Boolean setDisabled (PaymentPlan obj, Boolean newDisabled) throws FieldException
{
return newDisabled;
}
/**
* Get the attribute ProductReference
*/
public String getProductReference (PaymentPlan obj, String original)
{
return original;
}
/**
* Change the value set for attribute ProductReference.
* May modify the field beforehand
* Occurs before validation.
*/
public String setProductReference (PaymentPlan obj, String newProductReference) throws FieldException
{
return newProductReference;
}
/**
* Get the attribute UsageType
*/
public UsageType getUsageType (PaymentPlan obj, UsageType original)
{
return original;
}
/**
* Change the value set for attribute UsageType.
* May modify the field beforehand
* Occurs before validation.
*/
public UsageType setUsageType (PaymentPlan obj, UsageType newUsageType) throws FieldException
{
return newUsageType;
}
/**
* Get the attribute LinkedPlanReference
*/
public String getLinkedPlanReference (PaymentPlan obj, String original)
{
return original;
}
/**
* Change the value set for attribute LinkedPlanReference.
* May modify the field beforehand
* Occurs before validation.
*/
public String setLinkedPlanReference (PaymentPlan obj, String newLinkedPlanReference) throws FieldException
{
return newLinkedPlanReference;
}
}
......@@ -2682,6 +3473,22 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
{
return toActiveJobCount ();
}
if (name.equals ("Disabled"))
{
return toDisabled ();
}
if (name.equals ("ProductReference"))
{
return toProductReference ();
}
if (name.equals ("UsageType"))
{
return toUsageType ();
}
if (name.equals ("LinkedPlanReference"))
{
return toLinkedPlanReference ();
}
return super.to(name);
......@@ -2706,6 +3513,14 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
public PipeLine<From, Integer> toActiveJobCount () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ActiveJobCount)); }
public PipeLine<From, Boolean> toDisabled () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_Disabled)); }
public PipeLine<From, String> toProductReference () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ProductReference)); }
public PipeLine<From, UsageType> toUsageType () { return pipe(new ORMAttributePipe<Me, UsageType>(FIELD_UsageType)); }
public PipeLine<From, String> toLinkedPlanReference () { return pipe(new ORMAttributePipe<Me, String>(FIELD_LinkedPlanReference)); }
}
public boolean isTransientAttrib(String attribName)
......
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseStripeCoupon extends BaseBusinessClass
{
// Reference instance for the object
public static final StripeCoupon REFERENCE_StripeCoupon = new StripeCoupon ();
// Reference instance for the object
public static final StripeCoupon DUMMY_StripeCoupon = new DummyStripeCoupon ();
// Static constants corresponding to field names
public static final String FIELD_CouponCode = "CouponCode";
public static final String FIELD_PercentageOff = "PercentageOff";
public static final String FIELD_DurationInMonths = "DurationInMonths";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<StripeCoupon> HELPER_CouponCode = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripeCoupon> HELPER_PercentageOff = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripeCoupon> HELPER_DurationInMonths = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _CouponCode;
private Integer _PercentageOff;
private Integer _DurationInMonths;
// Private attributes corresponding to single references
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_StripeCoupon = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_CouponCode_Validators;
private static final AttributeValidator[] FIELD_PercentageOff_Validators;
private static final AttributeValidator[] FIELD_DurationInMonths_Validators;
// Arrays of behaviour decorators
private static final StripeCouponBehaviourDecorator[] StripeCoupon_BehaviourDecorators;
static
{
try
{
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
FIELD_CouponCode_Validators = (AttributeValidator[])setupAttribMetaData_CouponCode(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_PercentageOff_Validators = (AttributeValidator[])setupAttribMetaData_PercentageOff(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_DurationInMonths_Validators = (AttributeValidator[])setupAttribMetaData_DurationInMonths(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_StripeCoupon.initialiseReference ();
DUMMY_StripeCoupon.initialiseReference ();
StripeCoupon_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(StripeCoupon.class).toArray(new StripeCouponBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static List setupAttribMetaData_CouponCode(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "coupon_code");
metaInfo.put ("length", "100");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "CouponCode");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.CouponCode:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_CouponCode, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripeCoupon.class, "CouponCode", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripeCoupon.CouponCode:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_PercentageOff(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "percentage_off");
metaInfo.put ("name", "PercentageOff");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.PercentageOff:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_PercentageOff, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripeCoupon.class, "PercentageOff", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripeCoupon.PercentageOff:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_DurationInMonths(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "duration_in_months");
metaInfo.put ("name", "DurationInMonths");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripeCoupon.DurationInMonths:", metaInfo);
ATTRIBUTES_METADATA_StripeCoupon.put (FIELD_DurationInMonths, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripeCoupon.class, "DurationInMonths", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripeCoupon.DurationInMonths:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseStripeCoupon ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return StripeCoupon_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_CouponCode = (String)(HELPER_CouponCode.initialise (_CouponCode));
_PercentageOff = (Integer)(HELPER_PercentageOff.initialise (_PercentageOff));
_DurationInMonths = (Integer)(HELPER_DurationInMonths.initialise (_DurationInMonths));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
return this;
}
/**
* Get the attribute CouponCode
*/
public String getCouponCode ()
{
assertValid();
String valToReturn = _CouponCode;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
valToReturn = bhd.getCouponCode ((StripeCoupon)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 preCouponCodeChange (String newCouponCode) 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 postCouponCodeChange () throws FieldException
{
}
public FieldWriteability getWriteability_CouponCode ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CouponCode. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCouponCode (String newCouponCode) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CouponCode.compare (_CouponCode, newCouponCode);
try
{
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
newCouponCode = bhd.setCouponCode ((StripeCoupon)this, newCouponCode);
oldAndNewIdentical = HELPER_CouponCode.compare (_CouponCode, newCouponCode);
}
BusinessObjectParser.assertFieldCondition (newCouponCode != null, this, FIELD_CouponCode, "mandatory");
if (FIELD_CouponCode_Validators.length > 0)
{
Object newCouponCodeObj = HELPER_CouponCode.toObject (newCouponCode);
if (newCouponCodeObj != null)
{
int loopMax = FIELD_CouponCode_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripeCoupon.get (FIELD_CouponCode);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CouponCode_Validators[v].checkAttribute (this, FIELD_CouponCode, metadata, newCouponCodeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CouponCode () != FieldWriteability.FALSE, "Field CouponCode is not writeable");
preCouponCodeChange (newCouponCode);
markFieldChange (FIELD_CouponCode);
_CouponCode = newCouponCode;
postFieldChange (FIELD_CouponCode);
postCouponCodeChange ();
}
}
/**
* Get the attribute PercentageOff
*/
public Integer getPercentageOff ()
{
assertValid();
Integer valToReturn = _PercentageOff;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
valToReturn = bhd.getPercentageOff ((StripeCoupon)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 prePercentageOffChange (Integer newPercentageOff) 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 postPercentageOffChange () throws FieldException
{
}
public FieldWriteability getWriteability_PercentageOff ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute PercentageOff. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setPercentageOff (Integer newPercentageOff) throws FieldException
{
boolean oldAndNewIdentical = HELPER_PercentageOff.compare (_PercentageOff, newPercentageOff);
try
{
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
newPercentageOff = bhd.setPercentageOff ((StripeCoupon)this, newPercentageOff);
oldAndNewIdentical = HELPER_PercentageOff.compare (_PercentageOff, newPercentageOff);
}
if (FIELD_PercentageOff_Validators.length > 0)
{
Object newPercentageOffObj = HELPER_PercentageOff.toObject (newPercentageOff);
if (newPercentageOffObj != null)
{
int loopMax = FIELD_PercentageOff_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripeCoupon.get (FIELD_PercentageOff);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_PercentageOff_Validators[v].checkAttribute (this, FIELD_PercentageOff, metadata, newPercentageOffObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_PercentageOff () != FieldWriteability.FALSE, "Field PercentageOff is not writeable");
prePercentageOffChange (newPercentageOff);
markFieldChange (FIELD_PercentageOff);
_PercentageOff = newPercentageOff;
postFieldChange (FIELD_PercentageOff);
postPercentageOffChange ();
}
}
/**
* Get the attribute DurationInMonths
*/
public Integer getDurationInMonths ()
{
assertValid();
Integer valToReturn = _DurationInMonths;
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
valToReturn = bhd.getDurationInMonths ((StripeCoupon)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 preDurationInMonthsChange (Integer newDurationInMonths) 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 postDurationInMonthsChange () throws FieldException
{
}
public FieldWriteability getWriteability_DurationInMonths ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute DurationInMonths. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDurationInMonths (Integer newDurationInMonths) throws FieldException
{
boolean oldAndNewIdentical = HELPER_DurationInMonths.compare (_DurationInMonths, newDurationInMonths);
try
{
for (StripeCouponBehaviourDecorator bhd : StripeCoupon_BehaviourDecorators)
{
newDurationInMonths = bhd.setDurationInMonths ((StripeCoupon)this, newDurationInMonths);
oldAndNewIdentical = HELPER_DurationInMonths.compare (_DurationInMonths, newDurationInMonths);
}
if (FIELD_DurationInMonths_Validators.length > 0)
{
Object newDurationInMonthsObj = HELPER_DurationInMonths.toObject (newDurationInMonths);
if (newDurationInMonthsObj != null)
{
int loopMax = FIELD_DurationInMonths_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripeCoupon.get (FIELD_DurationInMonths);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_DurationInMonths_Validators[v].checkAttribute (this, FIELD_DurationInMonths, metadata, newDurationInMonthsObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_DurationInMonths () != FieldWriteability.FALSE, "Field DurationInMonths is not writeable");
preDurationInMonthsChange (newDurationInMonths);
markFieldChange (FIELD_DurationInMonths);
_DurationInMonths = newDurationInMonths;
postFieldChange (FIELD_DurationInMonths);
postDurationInMonthsChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
return super.__isMultiAssocLoaded(attribName);
}
public void onDelete ()
{
try
{
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public StripeCoupon newInstance ()
{
return new StripeCoupon ();
}
public StripeCoupon referenceInstance ()
{
return REFERENCE_StripeCoupon;
}
public StripeCoupon getInTransaction (ObjectTransaction t) throws StorageException
{
return getStripeCouponByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_StripeCoupon;
}
public String getBaseSetName ()
{
return "tl_coupon";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_couponPSet = allSets.getPersistentSet (myID, "tl_coupon", myPSetStatus);
tl_couponPSet.setAttrib (FIELD_ObjectID, myID);
tl_couponPSet.setAttrib (FIELD_CouponCode, HELPER_CouponCode.toObject (_CouponCode)); //
tl_couponPSet.setAttrib (FIELD_PercentageOff, HELPER_PercentageOff.toObject (_PercentageOff)); //
tl_couponPSet.setAttrib (FIELD_DurationInMonths, HELPER_DurationInMonths.toObject (_DurationInMonths)); //
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_couponPSet = allSets.getPersistentSet (objectID, "tl_coupon");
_CouponCode = (String)(HELPER_CouponCode.fromObject (_CouponCode, tl_couponPSet.getAttrib (FIELD_CouponCode))); //
_PercentageOff = (Integer)(HELPER_PercentageOff.fromObject (_PercentageOff, tl_couponPSet.getAttrib (FIELD_PercentageOff))); //
_DurationInMonths = (Integer)(HELPER_DurationInMonths.fromObject (_DurationInMonths, tl_couponPSet.getAttrib (FIELD_DurationInMonths))); //
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof StripeCoupon)
{
StripeCoupon otherStripeCoupon = (StripeCoupon)other;
try
{
setCouponCode (otherStripeCoupon.getCouponCode ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setPercentageOff (otherStripeCoupon.getPercentageOff ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setDurationInMonths (otherStripeCoupon.getDurationInMonths ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseStripeCoupon)
{
BaseStripeCoupon sourceStripeCoupon = (BaseStripeCoupon)(source);
_CouponCode = sourceStripeCoupon._CouponCode;
_PercentageOff = sourceStripeCoupon._PercentageOff;
_DurationInMonths = sourceStripeCoupon._DurationInMonths;
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseStripeCoupon)
{
BaseStripeCoupon sourceStripeCoupon = (BaseStripeCoupon)(source);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseStripeCoupon)
{
BaseStripeCoupon sourceStripeCoupon = (BaseStripeCoupon)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_CouponCode = (String)(HELPER_CouponCode.readExternal (_CouponCode, vals.get(FIELD_CouponCode))); //
_PercentageOff = (Integer)(HELPER_PercentageOff.readExternal (_PercentageOff, vals.get(FIELD_PercentageOff))); //
_DurationInMonths = (Integer)(HELPER_DurationInMonths.readExternal (_DurationInMonths, vals.get(FIELD_DurationInMonths))); //
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_CouponCode, HELPER_CouponCode.writeExternal (_CouponCode));
vals.put (FIELD_PercentageOff, HELPER_PercentageOff.writeExternal (_PercentageOff));
vals.put (FIELD_DurationInMonths, HELPER_DurationInMonths.writeExternal (_DurationInMonths));
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseStripeCoupon)
{
BaseStripeCoupon otherStripeCoupon = (BaseStripeCoupon)(other);
if (!HELPER_CouponCode.compare(this._CouponCode, otherStripeCoupon._CouponCode))
{
listener.notifyFieldChange(this, other, FIELD_CouponCode, HELPER_CouponCode.toObject(this._CouponCode), HELPER_CouponCode.toObject(otherStripeCoupon._CouponCode));
}
if (!HELPER_PercentageOff.compare(this._PercentageOff, otherStripeCoupon._PercentageOff))
{
listener.notifyFieldChange(this, other, FIELD_PercentageOff, HELPER_PercentageOff.toObject(this._PercentageOff), HELPER_PercentageOff.toObject(otherStripeCoupon._PercentageOff));
}
if (!HELPER_DurationInMonths.compare(this._DurationInMonths, otherStripeCoupon._DurationInMonths))
{
listener.notifyFieldChange(this, other, FIELD_DurationInMonths, HELPER_DurationInMonths.toObject(this._DurationInMonths), HELPER_DurationInMonths.toObject(otherStripeCoupon._DurationInMonths));
}
// Compare single assocs
// Compare multiple assocs
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_CouponCode, HELPER_CouponCode.toObject(getCouponCode()));
visitor.visitField(this, FIELD_PercentageOff, HELPER_PercentageOff.toObject(getPercentageOff()));
visitor.visitField(this, FIELD_DurationInMonths, HELPER_DurationInMonths.toObject(getDurationInMonths()));
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
}
public static StripeCoupon createStripeCoupon (ObjectTransaction transaction) throws StorageException
{
StripeCoupon result = new StripeCoupon ();
result.initialiseNewObject (transaction);
return result;
}
public static StripeCoupon getStripeCouponByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (StripeCoupon)(transaction.getObjectByID (REFERENCE_StripeCoupon, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CouponCode))
{
return filter.matches (getCouponCode ());
}
else if (attribName.equals (FIELD_PercentageOff))
{
return filter.matches (getPercentageOff ());
}
else if (attribName.equals (FIELD_DurationInMonths))
{
return filter.matches (getDurationInMonths ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<StripeCoupon>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_coupon.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_coupon.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_coupon.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andCouponCode (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_coupon.coupon_code", "CouponCode");
return this;
}
public SearchAll andPercentageOff (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_coupon.percentage_off", "PercentageOff");
return this;
}
public SearchAll andDurationInMonths (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_coupon.duration_in_months", "DurationInMonths");
return this;
}
public StripeCoupon[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_StripeCoupon, SEARCH_All, criteria);
Set<StripeCoupon> typedResults = new LinkedHashSet <StripeCoupon> ();
for (BaseBusinessClass bbcResult : results)
{
StripeCoupon aResult = (StripeCoupon)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new StripeCoupon[0]);
}
}
public static StripeCoupon[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CouponCode))
{
return HELPER_CouponCode.toObject (getCouponCode ());
}
else if (attribName.equals (FIELD_PercentageOff))
{
return HELPER_PercentageOff.toObject (getPercentageOff ());
}
else if (attribName.equals (FIELD_DurationInMonths))
{
return HELPER_DurationInMonths.toObject (getDurationInMonths ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CouponCode))
{
return HELPER_CouponCode;
}
else if (attribName.equals (FIELD_PercentageOff))
{
return HELPER_PercentageOff;
}
else if (attribName.equals (FIELD_DurationInMonths))
{
return HELPER_DurationInMonths;
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_CouponCode))
{
setCouponCode ((String)(HELPER_CouponCode.fromObject (_CouponCode, attribValue)));
}
else if (attribName.equals (FIELD_PercentageOff))
{
setPercentageOff ((Integer)(HELPER_PercentageOff.fromObject (_PercentageOff, attribValue)));
}
else if (attribName.equals (FIELD_DurationInMonths))
{
setDurationInMonths ((Integer)(HELPER_DurationInMonths.fromObject (_DurationInMonths, attribValue)));
}
else
{
super.setAttribute (attribName, attribValue);
}
}
public boolean isWriteable (String fieldName)
{
return getWriteable (fieldName) == FieldWriteability.TRUE;
}
public FieldWriteability getWriteable (String fieldName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (fieldName.equals (FIELD_CouponCode))
{
return getWriteability_CouponCode ();
}
else if (fieldName.equals (FIELD_PercentageOff))
{
return getWriteability_PercentageOff ();
}
else if (fieldName.equals (FIELD_DurationInMonths))
{
return getWriteability_DurationInMonths ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_CouponCode () != FieldWriteability.TRUE)
{
fields.add (FIELD_CouponCode);
}
if (getWriteability_PercentageOff () != FieldWriteability.TRUE)
{
fields.add (FIELD_PercentageOff);
}
if (getWriteability_DurationInMonths () != FieldWriteability.TRUE)
{
fields.add (FIELD_DurationInMonths);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_CouponCode.getAttribObject (getClass (), _CouponCode, true, FIELD_CouponCode));
result.add(HELPER_PercentageOff.getAttribObject (getClass (), _PercentageOff, false, FIELD_PercentageOff));
result.add(HELPER_DurationInMonths.getAttribObject (getClass (), _DurationInMonths, false, FIELD_DurationInMonths));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_StripeCoupon.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_StripeCoupon.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_StripeCoupon.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_StripeCoupon.get (attribute)).get(metadata);
}
else
{
return super.getAttributeMetadata (attribute, metadata);
}
}
public void preCommit (boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
}
}
public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
{
return super.getBinaryContentHandler(attribName);
}
public static class StripeCouponBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<StripeCoupon>
{
/**
* Get the attribute CouponCode
*/
public String getCouponCode (StripeCoupon obj, String original)
{
return original;
}
/**
* Change the value set for attribute CouponCode.
* May modify the field beforehand
* Occurs before validation.
*/
public String setCouponCode (StripeCoupon obj, String newCouponCode) throws FieldException
{
return newCouponCode;
}
/**
* Get the attribute PercentageOff
*/
public Integer getPercentageOff (StripeCoupon obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute PercentageOff.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setPercentageOff (StripeCoupon obj, Integer newPercentageOff) throws FieldException
{
return newPercentageOff;
}
/**
* Get the attribute DurationInMonths
*/
public Integer getDurationInMonths (StripeCoupon obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute DurationInMonths.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setDurationInMonths (StripeCoupon obj, Integer newDurationInMonths) throws FieldException
{
return newDurationInMonths;
}
}
public ORMPipeLine pipes()
{
return new StripeCouponPipeLineFactory<StripeCoupon, StripeCoupon> ((StripeCoupon)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public StripeCouponPipeLineFactory<StripeCoupon, StripeCoupon> pipelineStripeCoupon()
{
return (StripeCouponPipeLineFactory<StripeCoupon, StripeCoupon>) pipes();
}
public static StripeCouponPipeLineFactory<StripeCoupon, StripeCoupon> pipesStripeCoupon(Collection<StripeCoupon> items)
{
return REFERENCE_StripeCoupon.new StripeCouponPipeLineFactory<StripeCoupon, StripeCoupon> (items);
}
public static StripeCouponPipeLineFactory<StripeCoupon, StripeCoupon> pipesStripeCoupon(StripeCoupon[] _items)
{
return pipesStripeCoupon(Arrays.asList (_items));
}
public static StripeCouponPipeLineFactory<StripeCoupon, StripeCoupon> pipesStripeCoupon()
{
return pipesStripeCoupon((Collection)null);
}
public class StripeCouponPipeLineFactory<From extends BaseBusinessClass, Me extends StripeCoupon> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> StripeCouponPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public StripeCouponPipeLineFactory (From seed)
{
super(seed);
}
public StripeCouponPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("CouponCode"))
{
return toCouponCode ();
}
if (name.equals ("PercentageOff"))
{
return toPercentageOff ();
}
if (name.equals ("DurationInMonths"))
{
return toDurationInMonths ();
}
return super.to(name);
}
public PipeLine<From, String> toCouponCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CouponCode)); }
public PipeLine<From, Integer> toPercentageOff () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_PercentageOff)); }
public PipeLine<From, Integer> toDurationInMonths () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DurationInMonths)); }
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyStripeCoupon extends StripeCoupon
{
// Default constructor primarily to support Externalisable
public DummyStripeCoupon()
{
super();
}
public void assertValid ()
{
}
}
package performa.orm;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.objstore.rdbms.filters.IsNotNullFilter;
import oneit.utils.math.NullArith;
......
......@@ -17,6 +17,10 @@
<ATTRIB name="IntervalCount" type="Integer" dbcol="interval_count" mandatory="true"/>
<ATTRIB name="TrialPeriodDays" type="Integer" dbcol="trial_period_days" />
<ATTRIB name="ActiveJobCount" type="Integer" dbcol="active_job_count" />
<ATTRIB name="Disabled" type="Boolean" dbcol="disabled" />
<ATTRIB name="ProductReference" type="String" dbcol="product_reference" length="100" />
<ATTRIB name="UsageType" type="UsageType" dbcol="usage_type" attribHelper="EnumeratedAttributeHelper" />
<ATTRIB name="LinkedPlanReference" type="String" dbcol="linked_plan" length="100" />
</TABLE>
......
......@@ -36,6 +36,10 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
private Integer dummyIntervalCount;
private Integer dummyTrialPeriodDays;
private Integer dummyActiveJobCount;
private Boolean dummyDisabled;
private String dummyProductReference;
private UsageType dummyUsageType;
private String dummyLinkedPlanReference;
// Static constants corresponding to attribute helpers
......@@ -48,6 +52,10 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
private static final DefaultAttributeHelper HELPER_IntervalCount = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_TrialPeriodDays = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ActiveJobCount = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Disabled = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ProductReference = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_UsageType = new EnumeratedAttributeHelper (UsageType.FACTORY_UsageType);
private static final DefaultAttributeHelper HELPER_LinkedPlanReference = DefaultAttributeHelper.INSTANCE;
......@@ -63,10 +71,14 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
dummyIntervalCount = (Integer)(HELPER_IntervalCount.initialise (dummyIntervalCount));
dummyTrialPeriodDays = (Integer)(HELPER_TrialPeriodDays.initialise (dummyTrialPeriodDays));
dummyActiveJobCount = (Integer)(HELPER_ActiveJobCount.initialise (dummyActiveJobCount));
dummyDisabled = (Boolean)(HELPER_Disabled.initialise (dummyDisabled));
dummyProductReference = (String)(HELPER_ProductReference.initialise (dummyProductReference));
dummyUsageType = (UsageType)(HELPER_UsageType.initialise (dummyUsageType));
dummyLinkedPlanReference = (String)(HELPER_LinkedPlanReference.initialise (dummyLinkedPlanReference));
}
private String SELECT_COLUMNS = "{PREFIX}tl_payment_plan.object_id as id, {PREFIX}tl_payment_plan.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_payment_plan.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_payment_plan.stripe_reference, {PREFIX}tl_payment_plan.plan_name, {PREFIX}tl_payment_plan.description, {PREFIX}tl_payment_plan.currency_type, {PREFIX}tl_payment_plan.amount, {PREFIX}tl_payment_plan.interval, {PREFIX}tl_payment_plan.interval_count, {PREFIX}tl_payment_plan.trial_period_days, {PREFIX}tl_payment_plan.active_job_count, 1 AS commasafe ";
private String SELECT_COLUMNS = "{PREFIX}tl_payment_plan.object_id as id, {PREFIX}tl_payment_plan.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_payment_plan.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_payment_plan.stripe_reference, {PREFIX}tl_payment_plan.plan_name, {PREFIX}tl_payment_plan.description, {PREFIX}tl_payment_plan.currency_type, {PREFIX}tl_payment_plan.amount, {PREFIX}tl_payment_plan.interval, {PREFIX}tl_payment_plan.interval_count, {PREFIX}tl_payment_plan.trial_period_days, {PREFIX}tl_payment_plan.active_job_count, {PREFIX}tl_payment_plan.disabled, {PREFIX}tl_payment_plan.product_reference, {PREFIX}tl_payment_plan.usage_type, {PREFIX}tl_payment_plan.linked_plan, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
......@@ -125,7 +137,11 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_Interval)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_IntervalCount)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_TrialPeriodDays)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_ActiveJobCount))
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_ActiveJobCount)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_Disabled)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_ProductReference)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_UsageType)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_LinkedPlanReference))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
......@@ -195,10 +211,10 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_payment_plan " +
"SET stripe_reference = ?, plan_name = ?, description = ?, currency_type = ?, amount = ?, interval = ?, interval_count = ?, trial_period_days = ?, active_job_count = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"SET stripe_reference = ?, plan_name = ?, description = ?, currency_type = ?, amount = ?, interval = ?, interval_count = ?, trial_period_days = ?, active_job_count = ?, disabled = ?, product_reference = ?, usage_type = ?, linked_plan = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_payment_plan.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_StripeReference))).listEntry (HELPER_PlanName.getForSQL(dummyPlanName, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_PlanName))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Description))).listEntry (HELPER_CurrencyType.getForSQL(dummyCurrencyType, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_CurrencyType))).listEntry (HELPER_Amount.getForSQL(dummyAmount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Amount))).listEntry (HELPER_Interval.getForSQL(dummyInterval, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Interval))).listEntry (HELPER_IntervalCount.getForSQL(dummyIntervalCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_IntervalCount))).listEntry (HELPER_TrialPeriodDays.getForSQL(dummyTrialPeriodDays, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_TrialPeriodDays))).listEntry (HELPER_ActiveJobCount.getForSQL(dummyActiveJobCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_ActiveJobCount))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
CollectionUtils.listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_StripeReference))).listEntry (HELPER_PlanName.getForSQL(dummyPlanName, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_PlanName))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Description))).listEntry (HELPER_CurrencyType.getForSQL(dummyCurrencyType, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_CurrencyType))).listEntry (HELPER_Amount.getForSQL(dummyAmount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Amount))).listEntry (HELPER_Interval.getForSQL(dummyInterval, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Interval))).listEntry (HELPER_IntervalCount.getForSQL(dummyIntervalCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_IntervalCount))).listEntry (HELPER_TrialPeriodDays.getForSQL(dummyTrialPeriodDays, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_TrialPeriodDays))).listEntry (HELPER_ActiveJobCount.getForSQL(dummyActiveJobCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_ActiveJobCount))).listEntry (HELPER_Disabled.getForSQL(dummyDisabled, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Disabled))).listEntry (HELPER_ProductReference.getForSQL(dummyProductReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_ProductReference))).listEntry (HELPER_UsageType.getForSQL(dummyUsageType, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_UsageType))).listEntry (HELPER_LinkedPlanReference.getForSQL(dummyLinkedPlanReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_LinkedPlanReference))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
......@@ -505,6 +521,10 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_IntervalCount, HELPER_IntervalCount.getFromRS(dummyIntervalCount, r, "interval_count"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_TrialPeriodDays, HELPER_TrialPeriodDays.getFromRS(dummyTrialPeriodDays, r, "trial_period_days"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_ActiveJobCount, HELPER_ActiveJobCount.getFromRS(dummyActiveJobCount, r, "active_job_count"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_Disabled, HELPER_Disabled.getFromRS(dummyDisabled, r, "disabled"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_ProductReference, HELPER_ProductReference.getFromRS(dummyProductReference, r, "product_reference"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_UsageType, HELPER_UsageType.getFromRS(dummyUsageType, r, "usage_type"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_LinkedPlanReference, HELPER_LinkedPlanReference.getFromRS(dummyLinkedPlanReference, r, "linked_plan"));
}
......@@ -522,10 +542,10 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_payment_plan " +
" (stripe_reference, plan_name, description, currency_type, amount, interval, interval_count, trial_period_days, active_job_count, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
" (stripe_reference, plan_name, description, currency_type, amount, interval, interval_count, trial_period_days, active_job_count, disabled, product_reference, usage_type, linked_plan, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_StripeReference))).listEntry (HELPER_PlanName.getForSQL(dummyPlanName, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_PlanName))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Description))).listEntry (HELPER_CurrencyType.getForSQL(dummyCurrencyType, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_CurrencyType))).listEntry (HELPER_Amount.getForSQL(dummyAmount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Amount))).listEntry (HELPER_Interval.getForSQL(dummyInterval, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Interval))).listEntry (HELPER_IntervalCount.getForSQL(dummyIntervalCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_IntervalCount))).listEntry (HELPER_TrialPeriodDays.getForSQL(dummyTrialPeriodDays, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_TrialPeriodDays))).listEntry (HELPER_ActiveJobCount.getForSQL(dummyActiveJobCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_ActiveJobCount))) .listEntry (objectID.longID ()).toList().toArray());
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_StripeReference.getForSQL(dummyStripeReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_StripeReference))).listEntry (HELPER_PlanName.getForSQL(dummyPlanName, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_PlanName))).listEntry (HELPER_Description.getForSQL(dummyDescription, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Description))).listEntry (HELPER_CurrencyType.getForSQL(dummyCurrencyType, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_CurrencyType))).listEntry (HELPER_Amount.getForSQL(dummyAmount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Amount))).listEntry (HELPER_Interval.getForSQL(dummyInterval, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Interval))).listEntry (HELPER_IntervalCount.getForSQL(dummyIntervalCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_IntervalCount))).listEntry (HELPER_TrialPeriodDays.getForSQL(dummyTrialPeriodDays, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_TrialPeriodDays))).listEntry (HELPER_ActiveJobCount.getForSQL(dummyActiveJobCount, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_ActiveJobCount))).listEntry (HELPER_Disabled.getForSQL(dummyDisabled, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_Disabled))).listEntry (HELPER_ProductReference.getForSQL(dummyProductReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_ProductReference))).listEntry (HELPER_UsageType.getForSQL(dummyUsageType, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_UsageType))).listEntry (HELPER_LinkedPlanReference.getForSQL(dummyLinkedPlanReference, tl_payment_planPSet.getAttrib (PaymentPlan.FIELD_LinkedPlanReference))) .listEntry (objectID.longID ()).toList().toArray());
tl_payment_planPSet.setStatus (PersistentSetStatus.PROCESSED);
}
......
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
import performa.orm.types.*;
public class StripeCoupon extends BaseStripeCoupon
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public StripeCoupon ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="StripeCoupon" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TABLE name="tl_coupon" tablePrefix="object">
<ATTRIB name="CouponCode" type="String" dbcol="coupon_code" mandatory="true" length="100" />
<ATTRIB name="PercentageOff" type="Integer" dbcol="percentage_off" />
<ATTRIB name="DurationInMonths" type="Integer" dbcol="duration_in_months" />
</TABLE>
<SEARCH type="All" paramFilter="tl_coupon.object_id is not null" >
</SEARCH>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import performa.orm.types.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class StripeCouponPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea StripeCouponPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "StripeCoupon");
// Private attributes corresponding to business object data
private String dummyCouponCode;
private Integer dummyPercentageOff;
private Integer dummyDurationInMonths;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_CouponCode = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_PercentageOff = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DurationInMonths = DefaultAttributeHelper.INSTANCE;
public StripeCouponPersistenceMgr ()
{
dummyCouponCode = (String)(HELPER_CouponCode.initialise (dummyCouponCode));
dummyPercentageOff = (Integer)(HELPER_PercentageOff.initialise (dummyPercentageOff));
dummyDurationInMonths = (Integer)(HELPER_DurationInMonths.initialise (dummyDurationInMonths));
}
private String SELECT_COLUMNS = "{PREFIX}tl_coupon.object_id as id, {PREFIX}tl_coupon.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_coupon.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_coupon.coupon_code, {PREFIX}tl_coupon.percentage_off, {PREFIX}tl_coupon.duration_in_months, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, StripeCoupon.REFERENCE_StripeCoupon);
if (objectToReturn instanceof StripeCoupon)
{
LogMgr.log (StripeCouponPersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a StripeCoupon");
}
}
PersistentSet tl_couponPSet = allPSets.getPersistentSet(id, "tl_coupon", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_couponPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_CouponCode)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_PercentageOff)||
!tl_couponPSet.containsAttrib(StripeCoupon.FIELD_DurationInMonths))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (StripeCouponPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
StripeCoupon result = new StripeCoupon ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_coupon " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_coupon.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_couponPSet = allPSets.getPersistentSet(objectID, "tl_coupon");
if (tl_couponPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_couponPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_coupon " +
"SET coupon_code = ?, percentage_off = ?, duration_in_months = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_coupon.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_CouponCode.getForSQL(dummyCouponCode, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponCode))).listEntry (HELPER_PercentageOff.getForSQL(dummyPercentageOff, tl_couponPSet.getAttrib (StripeCoupon.FIELD_PercentageOff))).listEntry (HELPER_DurationInMonths.getForSQL(dummyDurationInMonths, tl_couponPSet.getAttrib (StripeCoupon.FIELD_DurationInMonths))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_coupon WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_coupon", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (StripeCouponPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_coupon");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_coupon for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (StripeCouponPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_couponPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (StripeCouponPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_couponPSet = allPSets.getPersistentSet(objectID, "tl_coupon");
LogMgr.log (StripeCouponPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_couponPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_couponPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_coupon " +
"WHERE tl_coupon.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_coupon WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_coupon");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_coupon for row:" + objectID;
LogMgr.log (StripeCouponPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_couponPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, StripeCoupon> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (StripeCoupon.REFERENCE_StripeCoupon.getObjectIDSpace (), r.getLong ("id"));
StripeCoupon resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
if (truncateExtra)
{
break;
}
else
{
throw new SearchRowsExceededException ("Maximum rows exceeded:" + maxRows);
}
}
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, StripeCoupon.REFERENCE_StripeCoupon);
if (cachedElement instanceof StripeCoupon)
{
LogMgr.log (StripeCouponPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (StripeCoupon)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a StripeCoupon");
}
}
else
{
PersistentSet tl_couponPSet = allPSets.getPersistentSet(objectID, "tl_coupon", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new StripeCoupon ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
}
results.put (objectID, resultElement);
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
return results.values ().toArray (resultsArr);
}
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (StripeCouponPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_coupon " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (StripeCoupon.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_coupon.object_id is not null
String preFilter = "(tl_coupon.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_coupon " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_couponPSet = allPSets.getPersistentSet(objectID, "tl_coupon", PersistentSetStatus.FETCHED);
// Object Modified
tl_couponPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_couponPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_CouponCode, HELPER_CouponCode.getFromRS(dummyCouponCode, r, "coupon_code"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_PercentageOff, HELPER_PercentageOff.getFromRS(dummyPercentageOff, r, "percentage_off"));
tl_couponPSet.setAttrib(StripeCoupon.FIELD_DurationInMonths, HELPER_DurationInMonths.getFromRS(dummyDurationInMonths, r, "duration_in_months"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_couponPSet = allPSets.getPersistentSet(objectID, "tl_coupon");
if (tl_couponPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_couponPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_coupon " +
" (coupon_code, percentage_off, duration_in_months, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_CouponCode.getForSQL(dummyCouponCode, tl_couponPSet.getAttrib (StripeCoupon.FIELD_CouponCode))).listEntry (HELPER_PercentageOff.getForSQL(dummyPercentageOff, tl_couponPSet.getAttrib (StripeCoupon.FIELD_PercentageOff))).listEntry (HELPER_DurationInMonths.getForSQL(dummyDurationInMonths, tl_couponPSet.getAttrib (StripeCoupon.FIELD_DurationInMonths))) .listEntry (objectID.longID ()).toList().toArray());
tl_couponPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class UsageType extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_UsageType = new UsageTypeFactory();
public static final UsageType METERED = new UsageType ("METERED", "METERED", "Metered", false);
public static final UsageType LICENSED = new UsageType ("LICENSED", "LICENSED", "Licensed", false);
private static final UsageType[] allUsageTypes =
new UsageType[] { METERED,LICENSED};
private static UsageType[] getAllUsageTypes ()
{
return allUsageTypes;
}
private UsageType (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allUsageTypes);
static
{
defineAdditionalData ();
}
public boolean isEqual (UsageType other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return UsageType.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return UsageType.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_UsageType;
}
public static UsageType forName (String name)
{
if (name == null) { return null; }
UsageType[] all = getAllUsageTypes();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static UsageType forValue (String value)
{
if (value == null) { return null; }
UsageType[] all = getAllUsageTypes();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllUsageTypes (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllUsageTypes());
}
public static UsageType[] getUsageTypeArray ()
{
return (UsageType[])getAllUsageTypes().clone ();
}
public static void defineAdditionalData ()
{
}
static class UsageTypeFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return UsageType.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return UsageType.forValue (name);
}
public Enumeration getAll ()
{
return UsageType.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="UsageType">
<VALUE name="METERED" description="Metered" />
<VALUE name="LICENSED" description="Licensed" />
</CONSTANT>
</ROOT>
\ No newline at end of file
package performa.utils;
import com.stripe.Stripe;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.exception.StripeException;
import com.stripe.model.Card;
import com.stripe.model.Coupon;
import com.stripe.model.Customer;
......@@ -21,19 +17,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.HiringTeam;
import performa.orm.PaymentPlan;
import spark.utils.IOUtils;
......@@ -51,24 +46,23 @@ public class StripeUtils
}
public static void createCustomer(CompanyUser companyUser) throws FieldException
public static void createCustomer(HiringTeam hiringTeam) throws FieldException
{
try
{
Company company = companyUser.getCompany();
SecUser secUser = companyUser.getUser();
SecUser secUser = hiringTeam.getAddedByUser().getUser();
Map<String, Object> customerParams = new HashMap<>();
customerParams.put("description", company);
customerParams.put("description", hiringTeam);
customerParams.put("email", secUser.getEmail());
Customer customer = Customer.create(customerParams);
company.setStripeReference(customer.getId());
hiringTeam.setStripeReference(customer.getId());
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Create customer in stripe : ", customer);
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while creating a customer in stripe");
}
......@@ -81,7 +75,7 @@ public class StripeUtils
{
if(company.getStripeReference() == null)
{
createCustomer(company.getAddedByUser());
createCustomer(company.getAddedByUser().getDefaultHiringTeam());
}
Customer customer = Customer.retrieve(company.getStripeReference());
......@@ -99,7 +93,7 @@ public class StripeUtils
return card;
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating a customer in stripe");
}
......@@ -116,7 +110,7 @@ public class StripeUtils
return (Card) customer.getSources().retrieve(customer.getDefaultSource());
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating a customer in stripe");
}
......@@ -130,7 +124,7 @@ public class StripeUtils
{
return Coupon.retrieve(couponCode);
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating a customer in stripe");
}
......@@ -151,7 +145,7 @@ public class StripeUtils
return Invoice.list(invoiceParams).getData();
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while retriving invoices in stripe for subscription: " + company.getStripeSubscription());
}
......@@ -167,7 +161,7 @@ public class StripeUtils
{
Plan plan = Plan.retrieve(STRIPE_PLAN_ID);
Date today = new Date();
Date trialExpiry = DateDiff.add(today, Calendar.DATE, plan.getTrialPeriodDays());
Date trialExpiry = DateDiff.add(today, Calendar.DATE, plan.getTrialPeriodDays().intValue());
Map<String, Object> item = new HashMap<>();
item.put("plan", STRIPE_PLAN_ID);
......@@ -187,33 +181,38 @@ public class StripeUtils
company.setStripeSubscription(subscription.getId());
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while creating subscrition in stripe");
}
}
public static void updatePlan(Company company) throws FieldException
public static void updatePlan(HiringTeam hiringTeam) throws FieldException
{
try
{
Subscription subscription = null;
PaymentPlan paymentPlan = company.getPaymentPlan();
PaymentPlan paymentPlan = hiringTeam.getPaymentPlan();
Map<String, Object> item = new HashMap<>();
Map<String, Object> itemA = new HashMap<>();
Map<String, Object> itemB = new HashMap<>();
if(company.getStripeSubscription() != null)
if(hiringTeam.getStripeSubscription() != null)
{
subscription = Subscription.retrieve(company.getStripeSubscription());
subscription = Subscription.retrieve(hiringTeam.getStripeSubscription());
String subID = subscription.getSubscriptionItems().getData().get(0).getId();
item.put("id", subscription.getSubscriptionItems().getData().get(0).getId());
itemA.put("id", subID);
itemB.put("id", subID);
}
item.put("plan", paymentPlan.getStripeReference());
itemA.put("plan", paymentPlan.getStripeReference());
itemB.put("plan", paymentPlan.getLinkedPlanReference());
Map<String, Object> items = new HashMap<>();
items.put("0", item);
items.put("0", itemA);
items.put("1", itemB);
Map<String, Object> params = new HashMap<>();
params.put("items", items);
......@@ -224,16 +223,16 @@ public class StripeUtils
}
else
{
params.put("customer", company.getStripeReference());
params.put("customer", hiringTeam.getStripeReference());
subscription = Subscription.create(params);
}
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Subscribing customer in stripe : ", subscription);
company.setStripeSubscription(subscription.getId());
hiringTeam.setStripeSubscription(subscription.getId());
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while creating subscrition in stripe");
}
......
......@@ -15,15 +15,18 @@
Debug.assertion(company != null , "Invalid company in admin portal my company");
Debug.assertion(hiringTeam != null , "Invalid Hiring Team in admin portal manage plan");
HiringTeam billingTeam = hiringTeam.getManageOwnBilling() ? hiringTeam : hiringTeam.getBillingTeam();
PaymentPlan[] plans = Utils.getPaymentPlansForJobs(transaction);
Integer maxCount = 0;
Integer minCount = 0;
PaymentPlan[] paymentPlans = PaymentPlan.SearchByAll().andDisabled(new EqualsFilter<>(Boolean.FALSE)).andActiveJobCount(new EqualsFilter<>(10)).search(transaction);
if(company.getPaymentPlan() != null && company.getPaymentJobCount() == null)
{
company.setPaymentJobCount(company.getPaymentPlan().getActiveJobCount());
}
PaymentPlan paymentPlan = PaymentPlan.getPaymentPlanByID(transaction, (long)38021473);
if(plans.length > 0)
{
Collection<Integer> jCounts = PaymentPlan.pipesPaymentPlan(plans).toActiveJobCount().vals();
......@@ -71,6 +74,7 @@
<oneit:ormInput obj="<%= hiringTeam %>" type="text" attributeName="CouponCode" placeholder="Coupon Code" cssClass="form-control" />
<oneit:button value="APPLY" name="applyCoupon" cssClass="btn btn-input-inside"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry("HiringTeam", hiringTeam)
.toMap() %>" />
</div>
</div>
......@@ -85,8 +89,6 @@
<oneit:toString value="18 Sep 2018" mode="EscapeHTML"/>
</span>
</div>
<div class="form-group row">
<div class="col-md-12 oneit-radio coupon-applied">
<div class="rectangle-5">
......@@ -113,7 +115,6 @@
<div class="clearboth"></div>
</div>
</div>
</div>
</div>
<div class="form-group row">
......@@ -134,21 +135,17 @@
</div>
<div class="manage-plan-payplan">
<div class="per-job-amount">
</div>
<div class="per-job-amount-past">
</div>
</div>
<div class="clearboth"></div>
</div>
<div class="manage-plan-hidden-info">
<div class="subscription-billed">
<img src="images/icon-calendar.png"> Your subscription is billed and resets on the <oneit:toString value="12th" mode="EscapeHTML"/> of every month
</div>
<div class="choose-plan-row">
<div class="choose-your-plan-title">
Choose Your Plan
</div>
......@@ -209,7 +206,6 @@
.toMap() %>" />
</div>
</div>
<div class="additional-jobs-over">
<span class="blue-alert">
Additional jobs over plan allowance are billed at the Cost Per Job for the subscription level
......@@ -218,8 +214,6 @@
Would you like to set a maximum limit on the total jobs able to be posted
</span>
</div>
<div class="set-a-cap-option">
<div >
<span> No, leave it open</span>
......@@ -243,22 +237,20 @@
</div>
<div class="form-group row">
<oneit:button value="Update Subscription" name="saveCompany" cssClass="btn btn-primary largeBtn btn-green save-btn" style="display:none;"
<oneit:button value="Update Subscription" name="saveCompany" cssClass="btn btn-primary largeBtn btn-green save-btn" style="display:inline;"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry ("restartProcess", Boolean.TRUE)
.mapEntry ("Company", company)
.mapEntry ("IsPayment", Boolean.TRUE)
.mapEntry ("attribNamesToRestore", Collections.singleton("Company"))
.mapEntry ("PaymentPlan", paymentPlan)
.mapEntry ("attribNamesToRestore", Collections.singleton("HiringTeam"))
.toMap() %>" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="text-center footer-note">
Looking to cancel your account? Please <a href="http://www.talentology.com/">contact us.</a>
</div>
......
<?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_payment_plan</tableName>
<column name="disabled" type="Boolean" nullable="true"/>
<column name="product_reference" type="String" nullable="true" length="100"/>
<column name="usage_type" type="String" nullable="true" length="200"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
<?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_payment_plan</tableName>
<column name="linked_plan" type="String" nullable="true" length="100"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment