Commit afce584f by Nilu

stripe data pull batch. Mapping plans from stripe to app.

parent 288caf8d
<?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_payment_plan</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="stripe_reference" type="String" nullable="false" length="100"/>
<column name="plan_name" type="CLOB" nullable="true"/>
<column name="description" type="CLOB" nullable="true"/>
<column name="currency_type" type="String" nullable="false" length="200"/>
<column name="amount" type="Double" nullable="false"/>
<column name="interval" type="String" nullable="false" length="200"/>
<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"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_payment_plan;
CREATE TABLE tl_payment_plan (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
stripe_reference varchar(100) NOT NULL,
plan_name text NULL,
description text NULL,
currency_type varchar(200) NOT NULL,
amount numeric(20,5) NOT NULL,
interval varchar(200) NOT NULL,
interval_count numeric(12) NOT NULL,
trial_period_days numeric(12) NULL,
active_job_count numeric(12) NULL
);
ALTER TABLE tl_payment_plan ADD
CONSTRAINT PK_tl_payment_plan PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE tl_payment_plan;
CREATE TABLE tl_payment_plan (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
stripe_reference varchar2(100) NOT NULL,
plan_name clob NULL,
description clob NULL,
currency_type varchar2(200) NOT NULL,
amount number(20,5) NOT NULL,
interval varchar2(200) NOT NULL,
interval_count number(12) NOT NULL,
trial_period_days number(12) NULL,
active_job_count number(12) NULL
);
ALTER TABLE tl_payment_plan ADD
CONSTRAINT PK_tl_payment_plan PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table tl_payment_plan;
CREATE TABLE tl_payment_plan (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
stripe_reference varchar(100) NOT NULL,
plan_name text NULL,
description text NULL,
currency_type varchar(200) NOT NULL,
amount numeric(20,5) NOT NULL,
interval varchar(200) NOT NULL,
interval_count numeric(12) NOT NULL,
trial_period_days numeric(12) NULL,
active_job_count numeric(12) NULL
);
ALTER TABLE tl_payment_plan ADD
CONSTRAINT pk_tl_payment_plan PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
package performa.batch;
import com.stripe.Stripe;
import com.stripe.model.Plan;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import oneit.appservices.batch.ORMBatch;
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.utils.parsers.FieldException;
import performa.orm.PaymentPlan;
import performa.orm.types.CurrencyType;
import performa.orm.types.Interval;
import performa.utils.StripeUtils;
public class PullStripeDataBatch extends ORMBatch
{
public static LoggingArea PULL_STRIPE_DATA_BATCH = LoggingArea.createLoggingArea("PullStripeDataBatch");
@Override
public void run(ObjectTransaction ot) throws StorageException, FieldException
{
try
{
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "RUNNING Pull Stripe Data Batch");
Stripe.apiKey = StripeUtils.STRIPE_KEY;
Map<String, Object> planParams = new HashMap<>();
List<Plan> plansList = Plan.list(planParams).getData();
for (Plan plan : plansList)
{
PaymentPlan[] paymentPlans = PaymentPlan.SearchByAll().andStripeReference(new EqualsFilter<>(plan.getId())).search(ot);
PaymentPlan paymentPlan;
if(paymentPlans != null && paymentPlans.length > 0)
{
paymentPlan = paymentPlans[0];
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "Updating exiting payment plan: " , paymentPlan, " to match stripe plan: ", plan);
}
else
{
paymentPlan = PaymentPlan.createPaymentPlan(ot);
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "Creating a new payment plan for stripe plan: ", plan);
}
Map<String, String> metadata = plan.getMetadata();
String activeJobs = metadata.get("ActiveJobs");
paymentPlan.setStripeReference(plan.getId());
paymentPlan.setPlanName(plan.getName());
paymentPlan.setDescription(plan.getStatementDescriptor());
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());
if(activeJobs != null)
{
paymentPlan.setActiveJobCount(Integer.valueOf(activeJobs));
}
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "Saving payment plan: " , paymentPlan, " mapped from stripe plan: ", plan);
}
}
catch (Exception ex)
{
LogMgr.log(PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, ex, "Error while pulling plan details from stripe");
}
}
}
\ No newline at end of file
package performa.form;
import com.stripe.Stripe;
import com.stripe.model.Plan;
import com.stripe.model.PlanCollection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import oneit.appservices.config.ConfigMgr;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.StorageException;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import performa.orm.Job;
import performa.orm.PaymentPlan;
import performa.orm.types.CurrencyType;
import performa.orm.types.Interval;
public class ManagePlansFP extends SaveFP
{
public static final String STRIPE_KEY = ConfigMgr.getKeyfileString("stripe.key","");
public static final String STRIPE_PUB_KEY = ConfigMgr.getKeyfileString("stripe.pubkey","");
@Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map p) throws BusinessException, StorageException
{
HttpServletRequest request = submission.getRequest();
LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"In ManagePlansFP : " );
Stripe.apiKey = STRIPE_KEY;
try {
Map<String, Object> planParams = new HashMap<>();
PlanCollection list = Plan.list(planParams);
List<Plan> lists = list.getData();
for (Plan plan : lists)
{
// Map<String, String> metadata = plan.getMetadata();
// PaymentPlan paymentPlan = PaymentPlan.createPaymentPlan(process.getTransaction());
//
// paymentPlan.setStripeReference(plan.getId());
// paymentPlan.setPlanName(plan.getName());
// paymentPlan.setDescription(plan.getStatementDescriptor());
// paymentPlan.setCurrencyType(CurrencyType.forName(plan.getCurrency().toUpperCase()));
// paymentPlan.setAmount(plan.getAmount().doubleValue());
// paymentPlan.setInterval(Interval.forName(plan.getInterval().toUpperCase()));
// paymentPlan.setIntervalCount(plan.getIntervalCount());
// paymentPlan.setTrialPeriodDays(plan.getTrialPeriodDays());
// paymentPlan.setActiveJobCount(Integer.valueOf(metadata.get("ActiveJobs")));
}
} catch (Exception ex)
{
Logger.getLogger(ManagePlansFP.class.getName()).log(Level.SEVERE, null, ex);
}
return super.processForm(process, submission, p);
}
}
/*
* 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 BasePaymentPlan extends BaseBusinessClass
{
// Reference instance for the object
public static final PaymentPlan REFERENCE_PaymentPlan = new PaymentPlan ();
// Reference instance for the object
public static final PaymentPlan DUMMY_PaymentPlan = new DummyPaymentPlan ();
// Static constants corresponding to field names
public static final String FIELD_StripeReference = "StripeReference";
public static final String FIELD_PlanName = "PlanName";
public static final String FIELD_Description = "Description";
public static final String FIELD_CurrencyType = "CurrencyType";
public static final String FIELD_Amount = "Amount";
public static final String FIELD_Interval = "Interval";
public static final String FIELD_IntervalCount = "IntervalCount";
public static final String FIELD_TrialPeriodDays = "TrialPeriodDays";
public static final String FIELD_ActiveJobCount = "ActiveJobCount";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<PaymentPlan> HELPER_StripeReference = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<PaymentPlan> HELPER_PlanName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<PaymentPlan> HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<PaymentPlan, CurrencyType> HELPER_CurrencyType = new EnumeratedAttributeHelper<PaymentPlan, CurrencyType> (CurrencyType.FACTORY_CurrencyType);
private static final DefaultAttributeHelper<PaymentPlan> HELPER_Amount = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<PaymentPlan, Interval> HELPER_Interval = new EnumeratedAttributeHelper<PaymentPlan, Interval> (Interval.FACTORY_Interval);
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 attributes corresponding to business object data
private String _StripeReference;
private String _PlanName;
private String _Description;
private CurrencyType _CurrencyType;
private Double _Amount;
private Interval _Interval;
private Integer _IntervalCount;
private Integer _TrialPeriodDays;
private Integer _ActiveJobCount;
// Private attributes corresponding to single references
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_PaymentPlan = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_StripeReference_Validators;
private static final AttributeValidator[] FIELD_PlanName_Validators;
private static final AttributeValidator[] FIELD_Description_Validators;
private static final AttributeValidator[] FIELD_CurrencyType_Validators;
private static final AttributeValidator[] FIELD_Amount_Validators;
private static final AttributeValidator[] FIELD_Interval_Validators;
private static final AttributeValidator[] FIELD_IntervalCount_Validators;
private static final AttributeValidator[] FIELD_TrialPeriodDays_Validators;
private static final AttributeValidator[] FIELD_ActiveJobCount_Validators;
// Arrays of behaviour decorators
private static final PaymentPlanBehaviourDecorator[] PaymentPlan_BehaviourDecorators;
static
{
try
{
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
FIELD_StripeReference_Validators = (AttributeValidator[])setupAttribMetaData_StripeReference(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_PlanName_Validators = (AttributeValidator[])setupAttribMetaData_PlanName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CurrencyType_Validators = (AttributeValidator[])setupAttribMetaData_CurrencyType(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Amount_Validators = (AttributeValidator[])setupAttribMetaData_Amount(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Interval_Validators = (AttributeValidator[])setupAttribMetaData_Interval(validatorMapping).toArray (new AttributeValidator[0]);
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]);
REFERENCE_PaymentPlan.initialiseReference ();
DUMMY_PaymentPlan.initialiseReference ();
PaymentPlan_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(PaymentPlan.class).toArray(new PaymentPlanBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static List setupAttribMetaData_StripeReference(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "stripe_reference");
metaInfo.put ("length", "100");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "StripeReference");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.StripeReference:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_StripeReference, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "StripeReference", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.StripeReference:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_PlanName(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "plan_name");
metaInfo.put ("name", "PlanName");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.PlanName:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_PlanName, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "PlanName", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.PlanName:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "description");
metaInfo.put ("name", "Description");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.Description:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_Description, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "Description", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.Description:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_CurrencyType(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "currency_type");
metaInfo.put ("defaultValue", "CurrencyType.AUD");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "CurrencyType");
metaInfo.put ("type", "CurrencyType");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.CurrencyType:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_CurrencyType, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "CurrencyType", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.CurrencyType:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Amount(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.putAll ((Map)ConfigMgr.getConfigObject ("CONFIG.SUBTYPE_ATTRIBS", "Currency", new HashMap ()));
metaInfo.put ("dbcol", "amount");
metaInfo.put ("Formatter", "Currency");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Amount");
metaInfo.put ("SubType", "Currency");
metaInfo.put ("type", "Double");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.Amount:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_Amount, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "Amount", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.Amount:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Interval(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "interval");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Interval");
metaInfo.put ("type", "Interval");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.Interval:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_Interval, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "Interval", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.Interval:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_IntervalCount(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "interval_count");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "IntervalCount");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.IntervalCount:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_IntervalCount, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "IntervalCount", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.IntervalCount:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_TrialPeriodDays(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "trial_period_days");
metaInfo.put ("name", "TrialPeriodDays");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.TrialPeriodDays:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_TrialPeriodDays, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "TrialPeriodDays", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.TrialPeriodDays:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ActiveJobCount(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "active_job_count");
metaInfo.put ("name", "ActiveJobCount");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for PaymentPlan.ActiveJobCount:", metaInfo);
ATTRIBUTES_METADATA_PaymentPlan.put (FIELD_ActiveJobCount, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(PaymentPlan.class, "ActiveJobCount", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for PaymentPlan.ActiveJobCount:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BasePaymentPlan ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return PaymentPlan_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_StripeReference = (String)(HELPER_StripeReference.initialise (_StripeReference));
_PlanName = (String)(HELPER_PlanName.initialise (_PlanName));
_Description = (String)(HELPER_Description.initialise (_Description));
_CurrencyType = (CurrencyType)(CurrencyType.AUD);
_Amount = (Double)(HELPER_Amount.initialise (_Amount));
_Interval = (Interval)(HELPER_Interval.initialise (_Interval));
_IntervalCount = (Integer)(HELPER_IntervalCount.initialise (_IntervalCount));
_TrialPeriodDays = (Integer)(HELPER_TrialPeriodDays.initialise (_TrialPeriodDays));
_ActiveJobCount = (Integer)(HELPER_ActiveJobCount.initialise (_ActiveJobCount));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
return this;
}
/**
* Get the attribute StripeReference
*/
public String getStripeReference ()
{
assertValid();
String valToReturn = _StripeReference;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getStripeReference ((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 preStripeReferenceChange (String newStripeReference) 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 postStripeReferenceChange () throws FieldException
{
}
public FieldWriteability getWriteability_StripeReference ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute StripeReference. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setStripeReference (String newStripeReference) throws FieldException
{
boolean oldAndNewIdentical = HELPER_StripeReference.compare (_StripeReference, newStripeReference);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newStripeReference = bhd.setStripeReference ((PaymentPlan)this, newStripeReference);
oldAndNewIdentical = HELPER_StripeReference.compare (_StripeReference, newStripeReference);
}
BusinessObjectParser.assertFieldCondition (newStripeReference != null, this, FIELD_StripeReference, "mandatory");
if (FIELD_StripeReference_Validators.length > 0)
{
Object newStripeReferenceObj = HELPER_StripeReference.toObject (newStripeReference);
if (newStripeReferenceObj != null)
{
int loopMax = FIELD_StripeReference_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_StripeReference);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_StripeReference_Validators[v].checkAttribute (this, FIELD_StripeReference, metadata, newStripeReferenceObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_StripeReference () != FieldWriteability.FALSE, "Field StripeReference is not writeable");
preStripeReferenceChange (newStripeReference);
markFieldChange (FIELD_StripeReference);
_StripeReference = newStripeReference;
postFieldChange (FIELD_StripeReference);
postStripeReferenceChange ();
}
}
/**
* Get the attribute PlanName
*/
public String getPlanName ()
{
assertValid();
String valToReturn = _PlanName;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getPlanName ((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 prePlanNameChange (String newPlanName) 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 postPlanNameChange () throws FieldException
{
}
public FieldWriteability getWriteability_PlanName ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute PlanName. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setPlanName (String newPlanName) throws FieldException
{
boolean oldAndNewIdentical = HELPER_PlanName.compare (_PlanName, newPlanName);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newPlanName = bhd.setPlanName ((PaymentPlan)this, newPlanName);
oldAndNewIdentical = HELPER_PlanName.compare (_PlanName, newPlanName);
}
if (FIELD_PlanName_Validators.length > 0)
{
Object newPlanNameObj = HELPER_PlanName.toObject (newPlanName);
if (newPlanNameObj != null)
{
int loopMax = FIELD_PlanName_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_PlanName);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_PlanName_Validators[v].checkAttribute (this, FIELD_PlanName, metadata, newPlanNameObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_PlanName () != FieldWriteability.FALSE, "Field PlanName is not writeable");
prePlanNameChange (newPlanName);
markFieldChange (FIELD_PlanName);
_PlanName = newPlanName;
postFieldChange (FIELD_PlanName);
postPlanNameChange ();
}
}
/**
* Get the attribute Description
*/
public String getDescription ()
{
assertValid();
String valToReturn = _Description;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getDescription ((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 preDescriptionChange (String newDescription) 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 postDescriptionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Description ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Description. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDescription (String newDescription) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newDescription = bhd.setDescription ((PaymentPlan)this, newDescription);
oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
}
if (FIELD_Description_Validators.length > 0)
{
Object newDescriptionObj = HELPER_Description.toObject (newDescription);
if (newDescriptionObj != null)
{
int loopMax = FIELD_Description_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_Description);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Description_Validators[v].checkAttribute (this, FIELD_Description, metadata, newDescriptionObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Description () != FieldWriteability.FALSE, "Field Description is not writeable");
preDescriptionChange (newDescription);
markFieldChange (FIELD_Description);
_Description = newDescription;
postFieldChange (FIELD_Description);
postDescriptionChange ();
}
}
/**
* Get the attribute CurrencyType
*/
public CurrencyType getCurrencyType ()
{
assertValid();
CurrencyType valToReturn = _CurrencyType;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getCurrencyType ((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 preCurrencyTypeChange (CurrencyType newCurrencyType) 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 postCurrencyTypeChange () throws FieldException
{
}
public FieldWriteability getWriteability_CurrencyType ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CurrencyType. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCurrencyType (CurrencyType newCurrencyType) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CurrencyType.compare (_CurrencyType, newCurrencyType);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newCurrencyType = bhd.setCurrencyType ((PaymentPlan)this, newCurrencyType);
oldAndNewIdentical = HELPER_CurrencyType.compare (_CurrencyType, newCurrencyType);
}
BusinessObjectParser.assertFieldCondition (newCurrencyType != null, this, FIELD_CurrencyType, "mandatory");
if (FIELD_CurrencyType_Validators.length > 0)
{
Object newCurrencyTypeObj = HELPER_CurrencyType.toObject (newCurrencyType);
if (newCurrencyTypeObj != null)
{
int loopMax = FIELD_CurrencyType_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_CurrencyType);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CurrencyType_Validators[v].checkAttribute (this, FIELD_CurrencyType, metadata, newCurrencyTypeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CurrencyType () != FieldWriteability.FALSE, "Field CurrencyType is not writeable");
preCurrencyTypeChange (newCurrencyType);
markFieldChange (FIELD_CurrencyType);
_CurrencyType = newCurrencyType;
postFieldChange (FIELD_CurrencyType);
postCurrencyTypeChange ();
}
}
/**
* Get the attribute Amount
*/
public Double getAmount ()
{
assertValid();
Double valToReturn = _Amount;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getAmount ((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 preAmountChange (Double newAmount) 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 postAmountChange () throws FieldException
{
}
public FieldWriteability getWriteability_Amount ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Amount. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setAmount (Double newAmount) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Amount.compare (_Amount, newAmount);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newAmount = bhd.setAmount ((PaymentPlan)this, newAmount);
oldAndNewIdentical = HELPER_Amount.compare (_Amount, newAmount);
}
BusinessObjectParser.assertFieldCondition (newAmount != null, this, FIELD_Amount, "mandatory");
if (FIELD_Amount_Validators.length > 0)
{
Object newAmountObj = HELPER_Amount.toObject (newAmount);
if (newAmountObj != null)
{
int loopMax = FIELD_Amount_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_Amount);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Amount_Validators[v].checkAttribute (this, FIELD_Amount, metadata, newAmountObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Amount () != FieldWriteability.FALSE, "Field Amount is not writeable");
preAmountChange (newAmount);
markFieldChange (FIELD_Amount);
_Amount = newAmount;
postFieldChange (FIELD_Amount);
postAmountChange ();
}
}
/**
* Get the attribute Interval
*/
public Interval getInterval ()
{
assertValid();
Interval valToReturn = _Interval;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getInterval ((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 preIntervalChange (Interval newInterval) 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 postIntervalChange () throws FieldException
{
}
public FieldWriteability getWriteability_Interval ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Interval. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setInterval (Interval newInterval) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Interval.compare (_Interval, newInterval);
try
{
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
newInterval = bhd.setInterval ((PaymentPlan)this, newInterval);
oldAndNewIdentical = HELPER_Interval.compare (_Interval, newInterval);
}
BusinessObjectParser.assertFieldCondition (newInterval != null, this, FIELD_Interval, "mandatory");
if (FIELD_Interval_Validators.length > 0)
{
Object newIntervalObj = HELPER_Interval.toObject (newInterval);
if (newIntervalObj != null)
{
int loopMax = FIELD_Interval_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_PaymentPlan.get (FIELD_Interval);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Interval_Validators[v].checkAttribute (this, FIELD_Interval, metadata, newIntervalObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Interval () != FieldWriteability.FALSE, "Field Interval is not writeable");
preIntervalChange (newInterval);
markFieldChange (FIELD_Interval);
_Interval = newInterval;
postFieldChange (FIELD_Interval);
postIntervalChange ();
}
}
/**
* Get the attribute IntervalCount
*/
public Integer getIntervalCount ()
{
assertValid();
Integer valToReturn = _IntervalCount;
for (PaymentPlanBehaviourDecorator bhd : PaymentPlan_BehaviourDecorators)
{
valToReturn = bhd.getIntervalCount ((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 preIntervalCountChange (Integer newIntervalCount) 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 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 ();
}
}
/**
* 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 PaymentPlan newInstance ()
{
return new PaymentPlan ();
}
public PaymentPlan referenceInstance ()
{
return REFERENCE_PaymentPlan;
}
public PaymentPlan getInTransaction (ObjectTransaction t) throws StorageException
{
return getPaymentPlanByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_PaymentPlan;
}
public String getBaseSetName ()
{
return "tl_payment_plan";
}
/**
* 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_payment_planPSet = allSets.getPersistentSet (myID, "tl_payment_plan", myPSetStatus);
tl_payment_planPSet.setAttrib (FIELD_ObjectID, myID);
tl_payment_planPSet.setAttrib (FIELD_StripeReference, HELPER_StripeReference.toObject (_StripeReference)); //
tl_payment_planPSet.setAttrib (FIELD_PlanName, HELPER_PlanName.toObject (_PlanName)); //
tl_payment_planPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
tl_payment_planPSet.setAttrib (FIELD_CurrencyType, HELPER_CurrencyType.toObject (_CurrencyType)); //
tl_payment_planPSet.setAttrib (FIELD_Amount, HELPER_Amount.toObject (_Amount)); //
tl_payment_planPSet.setAttrib (FIELD_Interval, HELPER_Interval.toObject (_Interval)); //
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)); //
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_payment_planPSet = allSets.getPersistentSet (objectID, "tl_payment_plan");
_StripeReference = (String)(HELPER_StripeReference.fromObject (_StripeReference, tl_payment_planPSet.getAttrib (FIELD_StripeReference))); //
_PlanName = (String)(HELPER_PlanName.fromObject (_PlanName, tl_payment_planPSet.getAttrib (FIELD_PlanName))); //
_Description = (String)(HELPER_Description.fromObject (_Description, tl_payment_planPSet.getAttrib (FIELD_Description))); //
_CurrencyType = (CurrencyType)(HELPER_CurrencyType.fromObject (_CurrencyType, tl_payment_planPSet.getAttrib (FIELD_CurrencyType))); //
_Amount = (Double)(HELPER_Amount.fromObject (_Amount, tl_payment_planPSet.getAttrib (FIELD_Amount))); //
_Interval = (Interval)(HELPER_Interval.fromObject (_Interval, tl_payment_planPSet.getAttrib (FIELD_Interval))); //
_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))); //
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof PaymentPlan)
{
PaymentPlan otherPaymentPlan = (PaymentPlan)other;
try
{
setStripeReference (otherPaymentPlan.getStripeReference ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setPlanName (otherPaymentPlan.getPlanName ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setDescription (otherPaymentPlan.getDescription ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setCurrencyType (otherPaymentPlan.getCurrencyType ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setAmount (otherPaymentPlan.getAmount ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setInterval (otherPaymentPlan.getInterval ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setIntervalCount (otherPaymentPlan.getIntervalCount ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setTrialPeriodDays (otherPaymentPlan.getTrialPeriodDays ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setActiveJobCount (otherPaymentPlan.getActiveJobCount ());
}
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 BasePaymentPlan)
{
BasePaymentPlan sourcePaymentPlan = (BasePaymentPlan)(source);
_StripeReference = sourcePaymentPlan._StripeReference;
_PlanName = sourcePaymentPlan._PlanName;
_Description = sourcePaymentPlan._Description;
_CurrencyType = sourcePaymentPlan._CurrencyType;
_Amount = sourcePaymentPlan._Amount;
_Interval = sourcePaymentPlan._Interval;
_IntervalCount = sourcePaymentPlan._IntervalCount;
_TrialPeriodDays = sourcePaymentPlan._TrialPeriodDays;
_ActiveJobCount = sourcePaymentPlan._ActiveJobCount;
}
}
/**
* 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 BasePaymentPlan)
{
BasePaymentPlan sourcePaymentPlan = (BasePaymentPlan)(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 BasePaymentPlan)
{
BasePaymentPlan sourcePaymentPlan = (BasePaymentPlan)(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);
_StripeReference = (String)(HELPER_StripeReference.readExternal (_StripeReference, vals.get(FIELD_StripeReference))); //
_PlanName = (String)(HELPER_PlanName.readExternal (_PlanName, vals.get(FIELD_PlanName))); //
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_CurrencyType = (CurrencyType)(HELPER_CurrencyType.readExternal (_CurrencyType, vals.get(FIELD_CurrencyType))); //
_Amount = (Double)(HELPER_Amount.readExternal (_Amount, vals.get(FIELD_Amount))); //
_Interval = (Interval)(HELPER_Interval.readExternal (_Interval, vals.get(FIELD_Interval))); //
_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))); //
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_StripeReference, HELPER_StripeReference.writeExternal (_StripeReference));
vals.put (FIELD_PlanName, HELPER_PlanName.writeExternal (_PlanName));
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (FIELD_CurrencyType, HELPER_CurrencyType.writeExternal (_CurrencyType));
vals.put (FIELD_Amount, HELPER_Amount.writeExternal (_Amount));
vals.put (FIELD_Interval, HELPER_Interval.writeExternal (_Interval));
vals.put (FIELD_IntervalCount, HELPER_IntervalCount.writeExternal (_IntervalCount));
vals.put (FIELD_TrialPeriodDays, HELPER_TrialPeriodDays.writeExternal (_TrialPeriodDays));
vals.put (FIELD_ActiveJobCount, HELPER_ActiveJobCount.writeExternal (_ActiveJobCount));
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BasePaymentPlan)
{
BasePaymentPlan otherPaymentPlan = (BasePaymentPlan)(other);
if (!HELPER_StripeReference.compare(this._StripeReference, otherPaymentPlan._StripeReference))
{
listener.notifyFieldChange(this, other, FIELD_StripeReference, HELPER_StripeReference.toObject(this._StripeReference), HELPER_StripeReference.toObject(otherPaymentPlan._StripeReference));
}
if (!HELPER_PlanName.compare(this._PlanName, otherPaymentPlan._PlanName))
{
listener.notifyFieldChange(this, other, FIELD_PlanName, HELPER_PlanName.toObject(this._PlanName), HELPER_PlanName.toObject(otherPaymentPlan._PlanName));
}
if (!HELPER_Description.compare(this._Description, otherPaymentPlan._Description))
{
listener.notifyFieldChange(this, other, FIELD_Description, HELPER_Description.toObject(this._Description), HELPER_Description.toObject(otherPaymentPlan._Description));
}
if (!HELPER_CurrencyType.compare(this._CurrencyType, otherPaymentPlan._CurrencyType))
{
listener.notifyFieldChange(this, other, FIELD_CurrencyType, HELPER_CurrencyType.toObject(this._CurrencyType), HELPER_CurrencyType.toObject(otherPaymentPlan._CurrencyType));
}
if (!HELPER_Amount.compare(this._Amount, otherPaymentPlan._Amount))
{
listener.notifyFieldChange(this, other, FIELD_Amount, HELPER_Amount.toObject(this._Amount), HELPER_Amount.toObject(otherPaymentPlan._Amount));
}
if (!HELPER_Interval.compare(this._Interval, otherPaymentPlan._Interval))
{
listener.notifyFieldChange(this, other, FIELD_Interval, HELPER_Interval.toObject(this._Interval), HELPER_Interval.toObject(otherPaymentPlan._Interval));
}
if (!HELPER_IntervalCount.compare(this._IntervalCount, otherPaymentPlan._IntervalCount))
{
listener.notifyFieldChange(this, other, FIELD_IntervalCount, HELPER_IntervalCount.toObject(this._IntervalCount), HELPER_IntervalCount.toObject(otherPaymentPlan._IntervalCount));
}
if (!HELPER_TrialPeriodDays.compare(this._TrialPeriodDays, otherPaymentPlan._TrialPeriodDays))
{
listener.notifyFieldChange(this, other, FIELD_TrialPeriodDays, HELPER_TrialPeriodDays.toObject(this._TrialPeriodDays), HELPER_TrialPeriodDays.toObject(otherPaymentPlan._TrialPeriodDays));
}
if (!HELPER_ActiveJobCount.compare(this._ActiveJobCount, otherPaymentPlan._ActiveJobCount))
{
listener.notifyFieldChange(this, other, FIELD_ActiveJobCount, HELPER_ActiveJobCount.toObject(this._ActiveJobCount), HELPER_ActiveJobCount.toObject(otherPaymentPlan._ActiveJobCount));
}
// 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_StripeReference, HELPER_StripeReference.toObject(getStripeReference()));
visitor.visitField(this, FIELD_PlanName, HELPER_PlanName.toObject(getPlanName()));
visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription()));
visitor.visitField(this, FIELD_CurrencyType, HELPER_CurrencyType.toObject(getCurrencyType()));
visitor.visitField(this, FIELD_Amount, HELPER_Amount.toObject(getAmount()));
visitor.visitField(this, FIELD_Interval, HELPER_Interval.toObject(getInterval()));
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()));
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
}
public static PaymentPlan createPaymentPlan (ObjectTransaction transaction) throws StorageException
{
PaymentPlan result = new PaymentPlan ();
result.initialiseNewObject (transaction);
return result;
}
public static PaymentPlan getPaymentPlanByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (PaymentPlan)(transaction.getObjectByID (REFERENCE_PaymentPlan, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_StripeReference))
{
return filter.matches (getStripeReference ());
}
else if (attribName.equals (FIELD_PlanName))
{
return filter.matches (getPlanName ());
}
else if (attribName.equals (FIELD_Description))
{
return filter.matches (getDescription ());
}
else if (attribName.equals (FIELD_CurrencyType))
{
return filter.matches (getCurrencyType ());
}
else if (attribName.equals (FIELD_Amount))
{
return filter.matches (getAmount ());
}
else if (attribName.equals (FIELD_Interval))
{
return filter.matches (getInterval ());
}
else if (attribName.equals (FIELD_IntervalCount))
{
return filter.matches (getIntervalCount ());
}
else if (attribName.equals (FIELD_TrialPeriodDays))
{
return filter.matches (getTrialPeriodDays ());
}
else if (attribName.equals (FIELD_ActiveJobCount))
{
return filter.matches (getActiveJobCount ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<PaymentPlan>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_payment_plan.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_payment_plan.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_payment_plan.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andStripeReference (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.stripe_reference", "StripeReference");
return this;
}
public SearchAll andPlanName (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.plan_name", "PlanName");
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.description", "Description");
return this;
}
public SearchAll andCurrencyType (QueryFilter<CurrencyType> filter)
{
filter.addFilter (context, "tl_payment_plan.currency_type", "CurrencyType");
return this;
}
public SearchAll andAmount (QueryFilter<Double> filter)
{
filter.addFilter (context, "tl_payment_plan.amount", "Amount");
return this;
}
public SearchAll andInterval (QueryFilter<Interval> filter)
{
filter.addFilter (context, "tl_payment_plan.interval", "Interval");
return this;
}
public SearchAll andIntervalCount (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_payment_plan.interval_count", "IntervalCount");
return this;
}
public SearchAll andTrialPeriodDays (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_payment_plan.trial_period_days", "TrialPeriodDays");
return this;
}
public SearchAll andActiveJobCount (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_payment_plan.active_job_count", "ActiveJobCount");
return this;
}
public PaymentPlan[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_PaymentPlan, SEARCH_All, criteria);
Set<PaymentPlan> typedResults = new LinkedHashSet <PaymentPlan> ();
for (BaseBusinessClass bbcResult : results)
{
PaymentPlan aResult = (PaymentPlan)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new PaymentPlan[0]);
}
}
public static PaymentPlan[]
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_StripeReference))
{
return HELPER_StripeReference.toObject (getStripeReference ());
}
else if (attribName.equals (FIELD_PlanName))
{
return HELPER_PlanName.toObject (getPlanName ());
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description.toObject (getDescription ());
}
else if (attribName.equals (FIELD_CurrencyType))
{
return HELPER_CurrencyType.toObject (getCurrencyType ());
}
else if (attribName.equals (FIELD_Amount))
{
return HELPER_Amount.toObject (getAmount ());
}
else if (attribName.equals (FIELD_Interval))
{
return HELPER_Interval.toObject (getInterval ());
}
else if (attribName.equals (FIELD_IntervalCount))
{
return HELPER_IntervalCount.toObject (getIntervalCount ());
}
else if (attribName.equals (FIELD_TrialPeriodDays))
{
return HELPER_TrialPeriodDays.toObject (getTrialPeriodDays ());
}
else if (attribName.equals (FIELD_ActiveJobCount))
{
return HELPER_ActiveJobCount.toObject (getActiveJobCount ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_StripeReference))
{
return HELPER_StripeReference;
}
else if (attribName.equals (FIELD_PlanName))
{
return HELPER_PlanName;
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description;
}
else if (attribName.equals (FIELD_CurrencyType))
{
return HELPER_CurrencyType;
}
else if (attribName.equals (FIELD_Amount))
{
return HELPER_Amount;
}
else if (attribName.equals (FIELD_Interval))
{
return HELPER_Interval;
}
else if (attribName.equals (FIELD_IntervalCount))
{
return HELPER_IntervalCount;
}
else if (attribName.equals (FIELD_TrialPeriodDays))
{
return HELPER_TrialPeriodDays;
}
else if (attribName.equals (FIELD_ActiveJobCount))
{
return HELPER_ActiveJobCount;
}
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_StripeReference))
{
setStripeReference ((String)(HELPER_StripeReference.fromObject (_StripeReference, attribValue)));
}
else if (attribName.equals (FIELD_PlanName))
{
setPlanName ((String)(HELPER_PlanName.fromObject (_PlanName, attribValue)));
}
else if (attribName.equals (FIELD_Description))
{
setDescription ((String)(HELPER_Description.fromObject (_Description, attribValue)));
}
else if (attribName.equals (FIELD_CurrencyType))
{
setCurrencyType ((CurrencyType)(HELPER_CurrencyType.fromObject (_CurrencyType, attribValue)));
}
else if (attribName.equals (FIELD_Amount))
{
setAmount ((Double)(HELPER_Amount.fromObject (_Amount, attribValue)));
}
else if (attribName.equals (FIELD_Interval))
{
setInterval ((Interval)(HELPER_Interval.fromObject (_Interval, attribValue)));
}
else if (attribName.equals (FIELD_IntervalCount))
{
setIntervalCount ((Integer)(HELPER_IntervalCount.fromObject (_IntervalCount, attribValue)));
}
else if (attribName.equals (FIELD_TrialPeriodDays))
{
setTrialPeriodDays ((Integer)(HELPER_TrialPeriodDays.fromObject (_TrialPeriodDays, attribValue)));
}
else if (attribName.equals (FIELD_ActiveJobCount))
{
setActiveJobCount ((Integer)(HELPER_ActiveJobCount.fromObject (_ActiveJobCount, 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_StripeReference))
{
return getWriteability_StripeReference ();
}
else if (fieldName.equals (FIELD_PlanName))
{
return getWriteability_PlanName ();
}
else if (fieldName.equals (FIELD_Description))
{
return getWriteability_Description ();
}
else if (fieldName.equals (FIELD_CurrencyType))
{
return getWriteability_CurrencyType ();
}
else if (fieldName.equals (FIELD_Amount))
{
return getWriteability_Amount ();
}
else if (fieldName.equals (FIELD_Interval))
{
return getWriteability_Interval ();
}
else if (fieldName.equals (FIELD_IntervalCount))
{
return getWriteability_IntervalCount ();
}
else if (fieldName.equals (FIELD_TrialPeriodDays))
{
return getWriteability_TrialPeriodDays ();
}
else if (fieldName.equals (FIELD_ActiveJobCount))
{
return getWriteability_ActiveJobCount ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_StripeReference () != FieldWriteability.TRUE)
{
fields.add (FIELD_StripeReference);
}
if (getWriteability_PlanName () != FieldWriteability.TRUE)
{
fields.add (FIELD_PlanName);
}
if (getWriteability_Description () != FieldWriteability.TRUE)
{
fields.add (FIELD_Description);
}
if (getWriteability_CurrencyType () != FieldWriteability.TRUE)
{
fields.add (FIELD_CurrencyType);
}
if (getWriteability_Amount () != FieldWriteability.TRUE)
{
fields.add (FIELD_Amount);
}
if (getWriteability_Interval () != FieldWriteability.TRUE)
{
fields.add (FIELD_Interval);
}
if (getWriteability_IntervalCount () != FieldWriteability.TRUE)
{
fields.add (FIELD_IntervalCount);
}
if (getWriteability_TrialPeriodDays () != FieldWriteability.TRUE)
{
fields.add (FIELD_TrialPeriodDays);
}
if (getWriteability_ActiveJobCount () != FieldWriteability.TRUE)
{
fields.add (FIELD_ActiveJobCount);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_StripeReference.getAttribObject (getClass (), _StripeReference, true, FIELD_StripeReference));
result.add(HELPER_PlanName.getAttribObject (getClass (), _PlanName, false, FIELD_PlanName));
result.add(HELPER_Description.getAttribObject (getClass (), _Description, false, FIELD_Description));
result.add(HELPER_CurrencyType.getAttribObject (getClass (), _CurrencyType, true, FIELD_CurrencyType));
result.add(HELPER_Amount.getAttribObject (getClass (), _Amount, true, FIELD_Amount));
result.add(HELPER_Interval.getAttribObject (getClass (), _Interval, true, FIELD_Interval));
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));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_PaymentPlan.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_PaymentPlan.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_PaymentPlan.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_PaymentPlan.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 PaymentPlanBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<PaymentPlan>
{
/**
* Get the attribute StripeReference
*/
public String getStripeReference (PaymentPlan obj, String original)
{
return original;
}
/**
* Change the value set for attribute StripeReference.
* May modify the field beforehand
* Occurs before validation.
*/
public String setStripeReference (PaymentPlan obj, String newStripeReference) throws FieldException
{
return newStripeReference;
}
/**
* Get the attribute PlanName
*/
public String getPlanName (PaymentPlan obj, String original)
{
return original;
}
/**
* Change the value set for attribute PlanName.
* May modify the field beforehand
* Occurs before validation.
*/
public String setPlanName (PaymentPlan obj, String newPlanName) throws FieldException
{
return newPlanName;
}
/**
* Get the attribute Description
*/
public String getDescription (PaymentPlan obj, String original)
{
return original;
}
/**
* Change the value set for attribute Description.
* May modify the field beforehand
* Occurs before validation.
*/
public String setDescription (PaymentPlan obj, String newDescription) throws FieldException
{
return newDescription;
}
/**
* Get the attribute CurrencyType
*/
public CurrencyType getCurrencyType (PaymentPlan obj, CurrencyType original)
{
return original;
}
/**
* Change the value set for attribute CurrencyType.
* May modify the field beforehand
* Occurs before validation.
*/
public CurrencyType setCurrencyType (PaymentPlan obj, CurrencyType newCurrencyType) throws FieldException
{
return newCurrencyType;
}
/**
* Get the attribute Amount
*/
public Double getAmount (PaymentPlan obj, Double original)
{
return original;
}
/**
* Change the value set for attribute Amount.
* May modify the field beforehand
* Occurs before validation.
*/
public Double setAmount (PaymentPlan obj, Double newAmount) throws FieldException
{
return newAmount;
}
/**
* Get the attribute Interval
*/
public Interval getInterval (PaymentPlan obj, Interval original)
{
return original;
}
/**
* Change the value set for attribute Interval.
* May modify the field beforehand
* Occurs before validation.
*/
public Interval setInterval (PaymentPlan obj, Interval newInterval) throws FieldException
{
return newInterval;
}
/**
* Get the attribute IntervalCount
*/
public Integer getIntervalCount (PaymentPlan obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute IntervalCount.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setIntervalCount (PaymentPlan obj, Integer newIntervalCount) throws FieldException
{
return newIntervalCount;
}
/**
* Get the attribute TrialPeriodDays
*/
public Integer getTrialPeriodDays (PaymentPlan obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute TrialPeriodDays.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setTrialPeriodDays (PaymentPlan obj, Integer newTrialPeriodDays) throws FieldException
{
return newTrialPeriodDays;
}
/**
* Get the attribute ActiveJobCount
*/
public Integer getActiveJobCount (PaymentPlan obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute ActiveJobCount.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setActiveJobCount (PaymentPlan obj, Integer newActiveJobCount) throws FieldException
{
return newActiveJobCount;
}
}
public ORMPipeLine pipes()
{
return new PaymentPlanPipeLineFactory<PaymentPlan, PaymentPlan> ((PaymentPlan)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public PaymentPlanPipeLineFactory<PaymentPlan, PaymentPlan> pipelinePaymentPlan()
{
return (PaymentPlanPipeLineFactory<PaymentPlan, PaymentPlan>) pipes();
}
public static PaymentPlanPipeLineFactory<PaymentPlan, PaymentPlan> pipesPaymentPlan(Collection<PaymentPlan> items)
{
return REFERENCE_PaymentPlan.new PaymentPlanPipeLineFactory<PaymentPlan, PaymentPlan> (items);
}
public static PaymentPlanPipeLineFactory<PaymentPlan, PaymentPlan> pipesPaymentPlan(PaymentPlan[] _items)
{
return pipesPaymentPlan(Arrays.asList (_items));
}
public static PaymentPlanPipeLineFactory<PaymentPlan, PaymentPlan> pipesPaymentPlan()
{
return pipesPaymentPlan((Collection)null);
}
public class PaymentPlanPipeLineFactory<From extends BaseBusinessClass, Me extends PaymentPlan> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> PaymentPlanPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public PaymentPlanPipeLineFactory (From seed)
{
super(seed);
}
public PaymentPlanPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("StripeReference"))
{
return toStripeReference ();
}
if (name.equals ("PlanName"))
{
return toPlanName ();
}
if (name.equals ("Description"))
{
return toDescription ();
}
if (name.equals ("CurrencyType"))
{
return toCurrencyType ();
}
if (name.equals ("Amount"))
{
return toAmount ();
}
if (name.equals ("Interval"))
{
return toInterval ();
}
if (name.equals ("IntervalCount"))
{
return toIntervalCount ();
}
if (name.equals ("TrialPeriodDays"))
{
return toTrialPeriodDays ();
}
if (name.equals ("ActiveJobCount"))
{
return toActiveJobCount ();
}
return super.to(name);
}
public PipeLine<From, String> toStripeReference () { return pipe(new ORMAttributePipe<Me, String>(FIELD_StripeReference)); }
public PipeLine<From, String> toPlanName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_PlanName)); }
public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); }
public PipeLine<From, CurrencyType> toCurrencyType () { return pipe(new ORMAttributePipe<Me, CurrencyType>(FIELD_CurrencyType)); }
public PipeLine<From, Double> toAmount () { return pipe(new ORMAttributePipe<Me, Double>(FIELD_Amount)); }
public PipeLine<From, Interval> toInterval () { return pipe(new ORMAttributePipe<Me, Interval>(FIELD_Interval)); }
public PipeLine<From, Integer> toIntervalCount () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_IntervalCount)); }
public PipeLine<From, Integer> toTrialPeriodDays () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_TrialPeriodDays)); }
public PipeLine<From, Integer> toActiveJobCount () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ActiveJobCount)); }
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyPaymentPlan extends PaymentPlan
{
// Default constructor primarily to support Externalisable
public DummyPaymentPlan()
{
super();
}
public void assertValid ()
{
}
}
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 PaymentPlan extends BasePaymentPlan
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public PaymentPlan ()
{
// 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="PaymentPlan" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TABLE name="tl_payment_plan" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="StripeReference" type="String" dbcol="stripe_reference" length="100" mandatory="true"/>
<ATTRIB name="PlanName" type="String" dbcol="plan_name" />
<ATTRIB name="Description" type="String" dbcol="description" />
<ATTRIB name="CurrencyType" type="CurrencyType" dbcol="currency_type" mandatory="true" attribHelper="EnumeratedAttributeHelper" defaultValue="CurrencyType.AUD"/>
<ATTRIB name="Amount" type="Double" dbcol="amount" mandatory="true" SubType="Currency" Formatter="Currency" />
<ATTRIB name="Interval" type="Interval" dbcol="interval" mandatory="true" attribHelper="EnumeratedAttributeHelper" />
<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" />
</TABLE>
<SEARCH type="All" paramFilter="tl_payment_plan.object_id is not null" orderBy="tl_payment_plan.object_id" />
</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 PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea PaymentPlanPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "PaymentPlan");
// Private attributes corresponding to business object data
private String dummyStripeReference;
private String dummyPlanName;
private String dummyDescription;
private CurrencyType dummyCurrencyType;
private Double dummyAmount;
private Interval dummyInterval;
private Integer dummyIntervalCount;
private Integer dummyTrialPeriodDays;
private Integer dummyActiveJobCount;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_StripeReference = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_PlanName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_CurrencyType = new EnumeratedAttributeHelper (CurrencyType.FACTORY_CurrencyType);
private static final DefaultAttributeHelper HELPER_Amount = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_Interval = new EnumeratedAttributeHelper (Interval.FACTORY_Interval);
private static final DefaultAttributeHelper HELPER_IntervalCount = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_TrialPeriodDays = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ActiveJobCount = DefaultAttributeHelper.INSTANCE;
public PaymentPlanPersistenceMgr ()
{
dummyStripeReference = (String)(HELPER_StripeReference.initialise (dummyStripeReference));
dummyPlanName = (String)(HELPER_PlanName.initialise (dummyPlanName));
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
dummyCurrencyType = (CurrencyType)(HELPER_CurrencyType.initialise (dummyCurrencyType));
dummyAmount = (Double)(HELPER_Amount.initialise (dummyAmount));
dummyInterval = (Interval)(HELPER_Interval.initialise (dummyInterval));
dummyIntervalCount = (Integer)(HELPER_IntervalCount.initialise (dummyIntervalCount));
dummyTrialPeriodDays = (Integer)(HELPER_TrialPeriodDays.initialise (dummyTrialPeriodDays));
dummyActiveJobCount = (Integer)(HELPER_ActiveJobCount.initialise (dummyActiveJobCount));
}
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_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, PaymentPlan.REFERENCE_PaymentPlan);
if (objectToReturn instanceof PaymentPlan)
{
LogMgr.log (PaymentPlanPersistence, 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 PaymentPlan");
}
}
PersistentSet tl_payment_planPSet = allPSets.getPersistentSet(id, "tl_payment_plan", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_payment_planPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_StripeReference)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_PlanName)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_Description)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_CurrencyType)||
!tl_payment_planPSet.containsAttrib(PaymentPlan.FIELD_Amount)||
!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))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (PaymentPlanPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
PaymentPlan result = new PaymentPlan ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_payment_plan " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_payment_plan.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_payment_planPSet = allPSets.getPersistentSet(objectID, "tl_payment_plan");
if (tl_payment_planPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_payment_planPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
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 () + " " +
"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());
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_payment_plan 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_payment_plan", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (PaymentPlanPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_payment_plan");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_payment_plan for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (PaymentPlanPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_payment_planPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (PaymentPlanPersistence, 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_payment_planPSet = allPSets.getPersistentSet(objectID, "tl_payment_plan");
LogMgr.log (PaymentPlanPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_payment_planPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_payment_planPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_payment_plan " +
"WHERE tl_payment_plan.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_payment_plan WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_payment_plan");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_payment_plan for row:" + objectID;
LogMgr.log (PaymentPlanPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_payment_planPSet.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, PaymentPlan> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (PaymentPlan.REFERENCE_PaymentPlan.getObjectIDSpace (), r.getLong ("id"));
PaymentPlan 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, PaymentPlan.REFERENCE_PaymentPlan);
if (cachedElement instanceof PaymentPlan)
{
LogMgr.log (PaymentPlanPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (PaymentPlan)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a PaymentPlan");
}
}
else
{
PersistentSet tl_payment_planPSet = allPSets.getPersistentSet(objectID, "tl_payment_plan", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new PaymentPlan ();
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 (PaymentPlanPersistence, 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_payment_plan " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (PaymentPlan.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY tl_payment_plan.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_payment_plan.object_id is not null
String preFilter = "(tl_payment_plan.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_payment_plan " + 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_payment_planPSet = allPSets.getPersistentSet(objectID, "tl_payment_plan", PersistentSetStatus.FETCHED);
// Object Modified
tl_payment_planPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_payment_planPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_StripeReference, HELPER_StripeReference.getFromRS(dummyStripeReference, r, "stripe_reference"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_PlanName, HELPER_PlanName.getFromRS(dummyPlanName, r, "plan_name"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "description"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_CurrencyType, HELPER_CurrencyType.getFromRS(dummyCurrencyType, r, "currency_type"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_Amount, HELPER_Amount.getFromRS(dummyAmount, r, "amount"));
tl_payment_planPSet.setAttrib(PaymentPlan.FIELD_Interval, HELPER_Interval.getFromRS(dummyInterval, r, "interval"));
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"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_payment_planPSet = allPSets.getPersistentSet(objectID, "tl_payment_plan");
if (tl_payment_planPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_payment_planPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
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) " +
"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());
tl_payment_planPSet.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 CurrencyType extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_CurrencyType = new CurrencyTypeFactory();
public static final CurrencyType AUD = new CurrencyType ("AUD", "AUD", "AUD", false);
public static final CurrencyType NZD = new CurrencyType ("NZD", "NZD", "NZD", false);
public static final CurrencyType EUR = new CurrencyType ("EUR", "EUR", "EUR", false);
public static final CurrencyType GBP = new CurrencyType ("GBP", "GBP", "GBP", false);
public static final CurrencyType USD = new CurrencyType ("USD", "USD", "USD", false);
public static final CurrencyType SGD = new CurrencyType ("SGD", "SGD", "SGD", false);
private static final CurrencyType[] allCurrencyTypes =
new CurrencyType[] { AUD,NZD,EUR,GBP,USD,SGD};
private static CurrencyType[] getAllCurrencyTypes ()
{
return allCurrencyTypes;
}
private CurrencyType (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allCurrencyTypes);
static
{
defineAdditionalData ();
}
public boolean isEqual (CurrencyType other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return CurrencyType.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return CurrencyType.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_CurrencyType;
}
public static CurrencyType forName (String name)
{
if (name == null) { return null; }
CurrencyType[] all = getAllCurrencyTypes();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static CurrencyType forValue (String value)
{
if (value == null) { return null; }
CurrencyType[] all = getAllCurrencyTypes();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllCurrencyTypes (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllCurrencyTypes());
}
public static CurrencyType[] getCurrencyTypeArray ()
{
return (CurrencyType[])getAllCurrencyTypes().clone ();
}
public static void defineAdditionalData ()
{
}
static class CurrencyTypeFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return CurrencyType.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return CurrencyType.forValue (name);
}
public Enumeration getAll ()
{
return CurrencyType.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="CurrencyType">
<VALUE name="AUD" description="AUD" />
<VALUE name="NZD" description="NZD" />
<VALUE name="EUR" description="EUR" />
<VALUE name="GBP" description="GBP" />
<VALUE name="USD" description="USD" />
<VALUE name="SGD" description="SGD" />
</CONSTANT>
</ROOT>
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 Interval extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_Interval = new IntervalFactory();
public static final Interval DAY = new Interval ("DAY", "DAY", "Day", false);
public static final Interval WEEK = new Interval ("WEEK", "WEEK", "Week", false);
public static final Interval MONTH = new Interval ("MONTH", "MONTH", "Month", false);
public static final Interval YEAR = new Interval ("YEAR", "YEAR", "Year", false);
private static final Interval[] allIntervals =
new Interval[] { DAY,WEEK,MONTH,YEAR};
private static Interval[] getAllIntervals ()
{
return allIntervals;
}
private Interval (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allIntervals);
static
{
defineAdditionalData ();
}
public boolean isEqual (Interval other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return Interval.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return Interval.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_Interval;
}
public static Interval forName (String name)
{
if (name == null) { return null; }
Interval[] all = getAllIntervals();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static Interval forValue (String value)
{
if (value == null) { return null; }
Interval[] all = getAllIntervals();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllIntervals (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllIntervals());
}
public static Interval[] getIntervalArray ()
{
return (Interval[])getAllIntervals().clone ();
}
public static void defineAdditionalData ()
{
}
static class IntervalFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return Interval.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return Interval.forValue (name);
}
public Enumeration getAll ()
{
return Interval.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="Interval">
<VALUE name="DAY" description="Day" />
<VALUE name="WEEK" description="Week" />
<VALUE name="MONTH" description="Month" />
<VALUE name="YEAR" description="Year" />
</CONSTANT>
</ROOT>
\ No newline at end of file
...@@ -61,6 +61,31 @@ public class StripeUtils ...@@ -61,6 +61,31 @@ public class StripeUtils
} }
public static void updateCardDetails(Company company, String token) throws FieldException
{
try
{
if(company.getStripeReference() == null)
{
createCustomer(company.getAddedByUser());
}
Customer customer = Customer.retrieve(company.getStripeReference());
Map<String, Object> updateParams = new HashMap<>();
updateParams.put("source", token);
customer.update(updateParams);
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating a customer in stripe");
}
}
public static void subscribeCustomer(Company company) throws FieldException public static void subscribeCustomer(Company company) throws FieldException
{ {
try try
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<FORM name="*.saveCompany" factory="Participant" class="performa.form.SaveCompanyFP"/> <FORM name="*.saveCompany" factory="Participant" class="performa.form.SaveCompanyFP"/>
<FORM name="*.processCulture" factory="Participant" class="performa.form.ProcessCultureFP"/> <FORM name="*.processCulture" factory="Participant" class="performa.form.ProcessCultureFP"/>
<FORM name="*.savePayment" factory="Participant" class="performa.form.MakePaymentFP"/> <FORM name="*.savePayment" factory="Participant" class="performa.form.MakePaymentFP"/>
<FORM name="*.managePlans" factory="Participant" class="performa.form.ManagePlansFP"/>
</NODE> </NODE>
<NODE name="job_assessment_criteria_add_jsp" factory="Participant"> <NODE name="job_assessment_criteria_add_jsp" factory="Participant">
......
...@@ -133,6 +133,18 @@ ...@@ -133,6 +133,18 @@
</TASK> </TASK>
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask" lockName="performa"> <TASK factory="Participant" class="oneit.appservices.batch.DefaultTask" lockName="performa">
<RUN class="performa.batch.PullStripeDataBatch" factory="Participant"/>
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
<NODE name="schedule" class="oneit.appservices.batch.HourlySchedule">
<NODE name="minuteOfHour" factory="Integer" value="1"/>
</NODE>
</WHEN>
</TASK>
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask" lockName="performa">
<RUN class="performa.batch.URLShortnerBatch" factory="Participant"/> <RUN class="performa.batch.URLShortnerBatch" factory="Participant"/>
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch"> <WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
Debug.assertion(company != null , "Invalid company in admin portal my company"); Debug.assertion(company != null , "Invalid company in admin portal my company");
String nextPage = WebUtils.getSamePageInRenderMode(request, "Page"); String nextPage = WebUtils.getSamePageInRenderMode(request, "Billing");
%> %>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() $(document).ready(function()
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="company-detail"> <div class="tab-pane active" id="company-detail">
<div class="tabpage-title"> <div class="tabpage-title">
<label class="label-20">Billing</label> <label class="label-20">Billing</label><br/>
<span id="card-errors" style="color: #eb1c26; font-size: 15px;"></span>
</div> </div>
<div> <div>
<label class="label-14 bold">Add a payment method</label><br/> <label class="label-14 bold">Add a payment method</label><br/>
...@@ -71,7 +72,6 @@ ...@@ -71,7 +72,6 @@
<oneit:ormInput obj="<%= company %>" type="text" attributeName="PostCode" cssClass="form-control" /> <oneit:ormInput obj="<%= company %>" type="text" attributeName="PostCode" cssClass="form-control" />
</div> </div>
</div> </div>
<div id="card-errors" role="alert"></div>
<div class="form-group"> <div class="form-group">
<oneit:button value="Save Card" name="saveCompany" cssClass="btn btn-primary btn-green large-btn" <oneit:button value="Save Card" name="saveCompany" cssClass="btn btn-primary btn-green large-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</div> </div>
<div> <div>
<label class="label-20">Pay Per Plan</label> <label class="label-20">Pay Per Job</label>
</div> </div>
<div class="grey-area"> <div class="grey-area">
<div class="text-center"> <div class="text-center">
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<label class="label-14">Per Job</label> <label class="label-14">Per Job</label>
</div> </div>
<div class="text-center form-group"> <div class="text-center form-group">
<oneit:button value="Upgrade" name="saveCompany" cssClass="btn btn-primary btn-green large-btn" <oneit:button value="Upgrade" name="managePlans" cssClass="btn btn-primary btn-green large-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry("Company", company) .mapEntry("Company", company)
.toMap() %>" /> .toMap() %>" />
......
<?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_payment_plan</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="stripe_reference" type="String" nullable="false" length="100"/>
<column name="plan_name" type="CLOB" nullable="true"/>
<column name="description" type="CLOB" nullable="true"/>
<column name="currency_type" type="String" nullable="false" length="200"/>
<column name="amount" type="Double" nullable="false"/>
<column name="interval" type="String" nullable="false" length="200"/>
<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"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
...@@ -67,21 +67,22 @@ cardCvc.addEventListener('change', function(event) { ...@@ -67,21 +67,22 @@ cardCvc.addEventListener('change', function(event) {
// Create a token or display an error when the form is submitted. // Create a token or display an error when the form is submitted.
var form = document.getElementById('makePayment'); var form = document.getElementById('makePayment');
form.addEventListener('submit', function(event) { form.addEventListener('submit', function(event) {
event.preventDefault(); event.preventDefault();
stripe.createToken(cardNumber).then(function(result) { stripe.createToken(cardNumber, {name: "Demo Card Name"}).then(function(result) {
if (result.error) { if (result.error) {
// Inform the customer that there was an error // Inform the customer that there was an error
var errorElement = document.getElementById('card-errors'); var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message; errorElement.textContent = result.error.message;
} else { } else {
// Send the token to your server // Send the token to your server
$('input[name=stripe-token-id]').val(result.token.id); $('input[name=stripe-token-id]').val(result.token.id);
$('#payNow').click(); $('#payNow').click();
// stripeTokenHandler(result.token); // stripeTokenHandler(result.token);
} }
}); });
}); });
function stripeTokenHandler(token) { function stripeTokenHandler(token) {
......
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