Commit bef1eb82 by Nilu

adding stripe plan setup from backend (supporting multiple currencies)

parent 60014793
<?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">it_does_not_matter</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="" type="Double" nullable="true"/>
<column name="" type="Double" nullable="true"/>
<column name="" type="String" nullable="true" length="200"/>
<column name="" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="it_does_not_matter" indexName="idx_it_does_not_matter_" isUnique="false"><column name=""/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">it_does_not_matter</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="" type="CLOB" nullable="true"/>
<column name="" type="CLOB" nullable="true"/>
<column name="" type="Long" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
numeric(20,5) NULL,
numeric(20,5) NULL,
varchar(200) NULL,
numeric(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_it_does_not_matter_
ON it_does_not_matter ();
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
text NULL,
text NULL,
numeric(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
number(20,5) NULL,
number(20,5) NULL,
varchar2(200) NULL,
number(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_it_does_not_matter_
ON it_does_not_matter ();
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
clob NULL,
clob NULL,
number(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
numeric(20,5) NULL,
numeric(20,5) NULL,
varchar(200) NULL,
numeric(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_it_does_not_matter_
ON it_does_not_matter ();
-- @AutoRun
-- drop table it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
text NULL,
text NULL,
numeric(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
package performa.form;
import com.stripe.Stripe;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.StorageException;
import oneit.servlets.forms.RedisplayResult;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessFormProcessor;
import oneit.servlets.process.ORMProcessState;
import oneit.utils.BusinessException;
import performa.orm.CurrencyPlanNPO;
import performa.orm.HiringTeam;
import performa.orm.StripePlanNPO;
import performa.utils.StripeUtils;
public class CreatePlanFP extends ORMProcessFormProcessor
{
@Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
StripePlanNPO plan = (StripePlanNPO) process.getAttribute("StripePlanNPO");
LogMgr.log(HiringTeam.LOG, LogLevel.PROCESSING1, "Inside CreatePlanFP for creating plan : ", plan);
Stripe.apiKey = StripeUtils.STRIPE_KEY;
for(CurrencyPlanNPO currencyPlan : plan.getCurrencyPlansSet())
{
StripeUtils.createPlan(plan, currencyPlan);
}
process.setAttribute("StripePlanNPO", null);
return RedisplayResult.getInstance();
}
}
\ No newline at end of file
/*
* 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 oneit.servlets.orm.*;
import performa.orm.types.*;
public abstract class BaseCurrencyPlanNPO extends NonPersistentBO
{
// Reference instance for the object
public static final CurrencyPlanNPO REFERENCE_CurrencyPlanNPO = new CurrencyPlanNPO ();
// Reference instance for the object
public static final CurrencyPlanNPO DUMMY_CurrencyPlanNPO = new DummyCurrencyPlanNPO ();
// Static constants corresponding to field names
public static final String FIELD_Amount = "Amount";
public static final String FIELD_PerJobAmount = "PerJobAmount";
public static final String FIELD_CurrencyType = "CurrencyType";
public static final String SINGLEREFERENCE_Plan = "Plan";
public static final String BACKREF_Plan = "";
// Static constants corresponding to searches
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<CurrencyPlanNPO> HELPER_Amount = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<CurrencyPlanNPO> HELPER_PerJobAmount = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<CurrencyPlanNPO, CurrencyType> HELPER_CurrencyType = new EnumeratedAttributeHelper<CurrencyPlanNPO, CurrencyType> (CurrencyType.FACTORY_CurrencyType);
// Private attributes corresponding to business object data
private Double _Amount;
private Double _PerJobAmount;
private CurrencyType _CurrencyType;
// Private attributes corresponding to single references
private SingleAssociation<CurrencyPlanNPO, StripePlanNPO> _Plan;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_CurrencyPlanNPO = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Amount_Validators;
private static final AttributeValidator[] FIELD_PerJobAmount_Validators;
private static final AttributeValidator[] FIELD_CurrencyType_Validators;
// Arrays of behaviour decorators
private static final CurrencyPlanNPOBehaviourDecorator[] CurrencyPlanNPO_BehaviourDecorators;
static
{
try
{
String tmp_Plan = StripePlanNPO.BACKREF_CurrencyPlans;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Plan();
FIELD_Amount_Validators = (AttributeValidator[])setupAttribMetaData_Amount(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_PerJobAmount_Validators = (AttributeValidator[])setupAttribMetaData_PerJobAmount(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CurrencyType_Validators = (AttributeValidator[])setupAttribMetaData_CurrencyType(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_CurrencyPlanNPO.initialiseReference ();
DUMMY_CurrencyPlanNPO.initialiseReference ();
CurrencyPlanNPO_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CurrencyPlanNPO.class).toArray(new CurrencyPlanNPOBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Plan()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "CurrencyPlans");
metaInfo.put ("name", "Plan");
metaInfo.put ("type", "StripePlanNPO");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CurrencyPlanNPO.Plan:", metaInfo);
ATTRIBUTES_METADATA_CurrencyPlanNPO.put (SINGLEREFERENCE_Plan, Collections.unmodifiableMap (metaInfo));
}
// 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 ("Formatter", "Currency");
metaInfo.put ("name", "Amount");
metaInfo.put ("SubType", "Currency");
metaInfo.put ("type", "Double");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CurrencyPlanNPO.Amount:", metaInfo);
ATTRIBUTES_METADATA_CurrencyPlanNPO.put (FIELD_Amount, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CurrencyPlanNPO.class, "Amount", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CurrencyPlanNPO.Amount:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_PerJobAmount(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.putAll ((Map)ConfigMgr.getConfigObject ("CONFIG.SUBTYPE_ATTRIBS", "Currency", new HashMap ()));
metaInfo.put ("Formatter", "Currency");
metaInfo.put ("name", "PerJobAmount");
metaInfo.put ("SubType", "Currency");
metaInfo.put ("type", "Double");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CurrencyPlanNPO.PerJobAmount:", metaInfo);
ATTRIBUTES_METADATA_CurrencyPlanNPO.put (FIELD_PerJobAmount, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CurrencyPlanNPO.class, "PerJobAmount", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CurrencyPlanNPO.PerJobAmount:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_CurrencyType(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("name", "CurrencyType");
metaInfo.put ("type", "CurrencyType");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CurrencyPlanNPO.CurrencyType:", metaInfo);
ATTRIBUTES_METADATA_CurrencyPlanNPO.put (FIELD_CurrencyType, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CurrencyPlanNPO.class, "CurrencyType", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CurrencyPlanNPO.CurrencyType:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseCurrencyPlanNPO ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return CurrencyPlanNPO_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Amount = (Double)(HELPER_Amount.initialise (_Amount));
_PerJobAmount = (Double)(HELPER_PerJobAmount.initialise (_PerJobAmount));
_CurrencyType = (CurrencyType)(HELPER_CurrencyType.initialise (_CurrencyType));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_Plan = new SingleAssociation<CurrencyPlanNPO, StripePlanNPO> (this, SINGLEREFERENCE_Plan, StripePlanNPO.MULTIPLEREFERENCE_CurrencyPlans, StripePlanNPO.REFERENCE_StripePlanNPO, "it_does_not_matter");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_Plan = new SingleAssociation<CurrencyPlanNPO, StripePlanNPO> (this, SINGLEREFERENCE_Plan, StripePlanNPO.MULTIPLEREFERENCE_CurrencyPlans, StripePlanNPO.REFERENCE_StripePlanNPO, "it_does_not_matter");
return this;
}
/**
* Get the attribute Amount
*/
public Double getAmount ()
{
assertValid();
Double valToReturn = _Amount;
for (CurrencyPlanNPOBehaviourDecorator bhd : CurrencyPlanNPO_BehaviourDecorators)
{
valToReturn = bhd.getAmount ((CurrencyPlanNPO)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 (CurrencyPlanNPOBehaviourDecorator bhd : CurrencyPlanNPO_BehaviourDecorators)
{
newAmount = bhd.setAmount ((CurrencyPlanNPO)this, newAmount);
oldAndNewIdentical = HELPER_Amount.compare (_Amount, newAmount);
}
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_CurrencyPlanNPO.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 PerJobAmount
*/
public Double getPerJobAmount ()
{
assertValid();
Double valToReturn = _PerJobAmount;
for (CurrencyPlanNPOBehaviourDecorator bhd : CurrencyPlanNPO_BehaviourDecorators)
{
valToReturn = bhd.getPerJobAmount ((CurrencyPlanNPO)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 prePerJobAmountChange (Double newPerJobAmount) 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 postPerJobAmountChange () throws FieldException
{
}
public FieldWriteability getWriteability_PerJobAmount ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute PerJobAmount. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setPerJobAmount (Double newPerJobAmount) throws FieldException
{
boolean oldAndNewIdentical = HELPER_PerJobAmount.compare (_PerJobAmount, newPerJobAmount);
try
{
for (CurrencyPlanNPOBehaviourDecorator bhd : CurrencyPlanNPO_BehaviourDecorators)
{
newPerJobAmount = bhd.setPerJobAmount ((CurrencyPlanNPO)this, newPerJobAmount);
oldAndNewIdentical = HELPER_PerJobAmount.compare (_PerJobAmount, newPerJobAmount);
}
if (FIELD_PerJobAmount_Validators.length > 0)
{
Object newPerJobAmountObj = HELPER_PerJobAmount.toObject (newPerJobAmount);
if (newPerJobAmountObj != null)
{
int loopMax = FIELD_PerJobAmount_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CurrencyPlanNPO.get (FIELD_PerJobAmount);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_PerJobAmount_Validators[v].checkAttribute (this, FIELD_PerJobAmount, metadata, newPerJobAmountObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_PerJobAmount () != FieldWriteability.FALSE, "Field PerJobAmount is not writeable");
prePerJobAmountChange (newPerJobAmount);
markFieldChange (FIELD_PerJobAmount);
_PerJobAmount = newPerJobAmount;
postFieldChange (FIELD_PerJobAmount);
postPerJobAmountChange ();
}
}
/**
* Get the attribute CurrencyType
*/
public CurrencyType getCurrencyType ()
{
assertValid();
CurrencyType valToReturn = _CurrencyType;
for (CurrencyPlanNPOBehaviourDecorator bhd : CurrencyPlanNPO_BehaviourDecorators)
{
valToReturn = bhd.getCurrencyType ((CurrencyPlanNPO)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 (CurrencyPlanNPOBehaviourDecorator bhd : CurrencyPlanNPO_BehaviourDecorators)
{
newCurrencyType = bhd.setCurrencyType ((CurrencyPlanNPO)this, newCurrencyType);
oldAndNewIdentical = HELPER_CurrencyType.compare (_CurrencyType, newCurrencyType);
}
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_CurrencyPlanNPO.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 ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("Plan");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Plan))
{
return _Plan.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Plan))
{
return StripePlanNPO.MULTIPLEREFERENCE_CurrencyPlans ;
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Plan))
{
return getPlan ();
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Plan))
{
return getPlan (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Plan))
{
return getPlanID ();
}
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 if (assocName.equals (SINGLEREFERENCE_Plan))
{
setPlan ((StripePlanNPO)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference Plan
*/
public StripePlanNPO getPlan () throws StorageException
{
assertValid();
try
{
return (StripePlanNPO)(_Plan.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CurrencyPlanNPO:", this.getObjectID (), ", was trying to get StripePlanNPO:", getPlanID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Plan.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public StripePlanNPO getPlan (Get getType) throws StorageException
{
assertValid();
return _Plan.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getPlanID ()
{
assertValid();
if (_Plan == null)
{
return null;
}
else
{
return _Plan.getID ();
}
}
/**
* Called prior to the assoc 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 prePlanChange (StripePlanNPO newPlan) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postPlanChange () throws FieldException
{
}
public FieldWriteability getWriteability_Plan ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Plan. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setPlan (StripePlanNPO newPlan) throws StorageException, FieldException
{
if (_Plan.wouldReferencedChange (newPlan))
{
assertValid();
Debug.assertion (getWriteability_Plan () != FieldWriteability.FALSE, "Assoc Plan is not writeable");
prePlanChange (newPlan);
StripePlanNPO oldPlan = getPlan ();
if (oldPlan != null)
{
// This is to stop validation from triggering when we are removed
_Plan.set (null);
oldPlan.removeFromCurrencyPlans ((CurrencyPlanNPO)(this));
}
_Plan.set (newPlan);
if (newPlan != null)
{
newPlan.addToCurrencyPlans ((CurrencyPlanNPO)(this));
}
postPlanChange ();
}
}
/**
* 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
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Plan.isLoaded () || getTransaction ().isObjectLoaded (_Plan.getReferencedType (), getPlanID ()))
{
StripePlanNPO referenced = getPlan ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CurrencyPlans from ", getObjectID (), " to ", referenced.getObjectID ());
_Plan.set (null);
referenced.removeFromCurrencyPlans ((CurrencyPlanNPO)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public CurrencyPlanNPO newInstance ()
{
return new CurrencyPlanNPO ();
}
public CurrencyPlanNPO referenceInstance ()
{
return REFERENCE_CurrencyPlanNPO;
}
public CurrencyPlanNPO getInTransaction (ObjectTransaction t) throws StorageException
{
return getCurrencyPlanNPOByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_CurrencyPlanNPO;
}
public String getBaseSetName ()
{
return "it_does_not_matter";
}
/**
* 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 it_does_not_matterPSet = allSets.getPersistentSet (myID, "it_does_not_matter", myPSetStatus);
it_does_not_matterPSet.setAttrib (FIELD_ObjectID, myID);
it_does_not_matterPSet.setAttrib (FIELD_Amount, HELPER_Amount.toObject (_Amount)); //
it_does_not_matterPSet.setAttrib (FIELD_PerJobAmount, HELPER_PerJobAmount.toObject (_PerJobAmount)); //
it_does_not_matterPSet.setAttrib (FIELD_CurrencyType, HELPER_CurrencyType.toObject (_CurrencyType)); //
_Plan.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet it_does_not_matterPSet = allSets.getPersistentSet (objectID, "it_does_not_matter");
_Amount = (Double)(HELPER_Amount.fromObject (_Amount, it_does_not_matterPSet.getAttrib (FIELD_Amount))); //
_PerJobAmount = (Double)(HELPER_PerJobAmount.fromObject (_PerJobAmount, it_does_not_matterPSet.getAttrib (FIELD_PerJobAmount))); //
_CurrencyType = (CurrencyType)(HELPER_CurrencyType.fromObject (_CurrencyType, it_does_not_matterPSet.getAttrib (FIELD_CurrencyType))); //
_Plan.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof CurrencyPlanNPO)
{
CurrencyPlanNPO otherCurrencyPlanNPO = (CurrencyPlanNPO)other;
try
{
setAmount (otherCurrencyPlanNPO.getAmount ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setPerJobAmount (otherCurrencyPlanNPO.getPerJobAmount ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setCurrencyType (otherCurrencyPlanNPO.getCurrencyType ());
}
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 BaseCurrencyPlanNPO)
{
BaseCurrencyPlanNPO sourceCurrencyPlanNPO = (BaseCurrencyPlanNPO)(source);
_Amount = sourceCurrencyPlanNPO._Amount;
_PerJobAmount = sourceCurrencyPlanNPO._PerJobAmount;
_CurrencyType = sourceCurrencyPlanNPO._CurrencyType;
}
}
/**
* 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 BaseCurrencyPlanNPO)
{
BaseCurrencyPlanNPO sourceCurrencyPlanNPO = (BaseCurrencyPlanNPO)(source);
_Plan.copyFrom (sourceCurrencyPlanNPO._Plan, linkToGhosts);
}
}
/**
* 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 BaseCurrencyPlanNPO)
{
BaseCurrencyPlanNPO sourceCurrencyPlanNPO = (BaseCurrencyPlanNPO)(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);
_Amount = (Double)(HELPER_Amount.readExternal (_Amount, vals.get(FIELD_Amount))); //
_PerJobAmount = (Double)(HELPER_PerJobAmount.readExternal (_PerJobAmount, vals.get(FIELD_PerJobAmount))); //
_CurrencyType = (CurrencyType)(HELPER_CurrencyType.readExternal (_CurrencyType, vals.get(FIELD_CurrencyType))); //
_Plan.readExternalData(vals.get(SINGLEREFERENCE_Plan));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Amount, HELPER_Amount.writeExternal (_Amount));
vals.put (FIELD_PerJobAmount, HELPER_PerJobAmount.writeExternal (_PerJobAmount));
vals.put (FIELD_CurrencyType, HELPER_CurrencyType.writeExternal (_CurrencyType));
vals.put (SINGLEREFERENCE_Plan, _Plan.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseCurrencyPlanNPO)
{
BaseCurrencyPlanNPO otherCurrencyPlanNPO = (BaseCurrencyPlanNPO)(other);
if (!HELPER_Amount.compare(this._Amount, otherCurrencyPlanNPO._Amount))
{
listener.notifyFieldChange(this, other, FIELD_Amount, HELPER_Amount.toObject(this._Amount), HELPER_Amount.toObject(otherCurrencyPlanNPO._Amount));
}
if (!HELPER_PerJobAmount.compare(this._PerJobAmount, otherCurrencyPlanNPO._PerJobAmount))
{
listener.notifyFieldChange(this, other, FIELD_PerJobAmount, HELPER_PerJobAmount.toObject(this._PerJobAmount), HELPER_PerJobAmount.toObject(otherCurrencyPlanNPO._PerJobAmount));
}
if (!HELPER_CurrencyType.compare(this._CurrencyType, otherCurrencyPlanNPO._CurrencyType))
{
listener.notifyFieldChange(this, other, FIELD_CurrencyType, HELPER_CurrencyType.toObject(this._CurrencyType), HELPER_CurrencyType.toObject(otherCurrencyPlanNPO._CurrencyType));
}
// Compare single assocs
_Plan.compare (otherCurrencyPlanNPO._Plan, listener);
// 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_Amount, HELPER_Amount.toObject(getAmount()));
visitor.visitField(this, FIELD_PerJobAmount, HELPER_PerJobAmount.toObject(getPerJobAmount()));
visitor.visitField(this, FIELD_CurrencyType, HELPER_CurrencyType.toObject(getCurrencyType()));
visitor.visitAssociation (_Plan);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Plan))
{
visitor.visit (_Plan);
}
}
public static CurrencyPlanNPO createCurrencyPlanNPO (ObjectTransaction transaction) throws StorageException
{
CurrencyPlanNPO result = new CurrencyPlanNPO ();
result.initialiseNewObject (transaction);
return result;
}
public static CurrencyPlanNPO getCurrencyPlanNPOByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (CurrencyPlanNPO)(transaction.getObjectByID (REFERENCE_CurrencyPlanNPO, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Amount))
{
return filter.matches (getAmount ());
}
else if (attribName.equals (FIELD_PerJobAmount))
{
return filter.matches (getPerJobAmount ());
}
else if (attribName.equals (FIELD_CurrencyType))
{
return filter.matches (getCurrencyType ());
}
else if (attribName.equals (SINGLEREFERENCE_Plan))
{
return filter.matches (getPlan ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Amount))
{
return HELPER_Amount.toObject (getAmount ());
}
else if (attribName.equals (FIELD_PerJobAmount))
{
return HELPER_PerJobAmount.toObject (getPerJobAmount ());
}
else if (attribName.equals (FIELD_CurrencyType))
{
return HELPER_CurrencyType.toObject (getCurrencyType ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Amount))
{
return HELPER_Amount;
}
else if (attribName.equals (FIELD_PerJobAmount))
{
return HELPER_PerJobAmount;
}
else if (attribName.equals (FIELD_CurrencyType))
{
return HELPER_CurrencyType;
}
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_Amount))
{
setAmount ((Double)(HELPER_Amount.fromObject (_Amount, attribValue)));
}
else if (attribName.equals (FIELD_PerJobAmount))
{
setPerJobAmount ((Double)(HELPER_PerJobAmount.fromObject (_PerJobAmount, attribValue)));
}
else if (attribName.equals (FIELD_CurrencyType))
{
setCurrencyType ((CurrencyType)(HELPER_CurrencyType.fromObject (_CurrencyType, 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_Amount))
{
return getWriteability_Amount ();
}
else if (fieldName.equals (FIELD_PerJobAmount))
{
return getWriteability_PerJobAmount ();
}
else if (fieldName.equals (FIELD_CurrencyType))
{
return getWriteability_CurrencyType ();
}
else if (fieldName.equals (SINGLEREFERENCE_Plan))
{
return getWriteability_Plan ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Amount () != FieldWriteability.TRUE)
{
fields.add (FIELD_Amount);
}
if (getWriteability_PerJobAmount () != FieldWriteability.TRUE)
{
fields.add (FIELD_PerJobAmount);
}
if (getWriteability_CurrencyType () != FieldWriteability.TRUE)
{
fields.add (FIELD_CurrencyType);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Amount.getAttribObject (getClass (), _Amount, false, FIELD_Amount));
result.add(HELPER_PerJobAmount.getAttribObject (getClass (), _PerJobAmount, false, FIELD_PerJobAmount));
result.add(HELPER_CurrencyType.getAttribObject (getClass (), _CurrencyType, false, FIELD_CurrencyType));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_CurrencyPlanNPO.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_CurrencyPlanNPO.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_CurrencyPlanNPO.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_CurrencyPlanNPO.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 CurrencyPlanNPOBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CurrencyPlanNPO>
{
/**
* Get the attribute Amount
*/
public Double getAmount (CurrencyPlanNPO obj, Double original)
{
return original;
}
/**
* Change the value set for attribute Amount.
* May modify the field beforehand
* Occurs before validation.
*/
public Double setAmount (CurrencyPlanNPO obj, Double newAmount) throws FieldException
{
return newAmount;
}
/**
* Get the attribute PerJobAmount
*/
public Double getPerJobAmount (CurrencyPlanNPO obj, Double original)
{
return original;
}
/**
* Change the value set for attribute PerJobAmount.
* May modify the field beforehand
* Occurs before validation.
*/
public Double setPerJobAmount (CurrencyPlanNPO obj, Double newPerJobAmount) throws FieldException
{
return newPerJobAmount;
}
/**
* Get the attribute CurrencyType
*/
public CurrencyType getCurrencyType (CurrencyPlanNPO obj, CurrencyType original)
{
return original;
}
/**
* Change the value set for attribute CurrencyType.
* May modify the field beforehand
* Occurs before validation.
*/
public CurrencyType setCurrencyType (CurrencyPlanNPO obj, CurrencyType newCurrencyType) throws FieldException
{
return newCurrencyType;
}
}
public ORMPipeLine pipes()
{
return new CurrencyPlanNPOPipeLineFactory<CurrencyPlanNPO, CurrencyPlanNPO> ((CurrencyPlanNPO)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public CurrencyPlanNPOPipeLineFactory<CurrencyPlanNPO, CurrencyPlanNPO> pipelineCurrencyPlanNPO()
{
return (CurrencyPlanNPOPipeLineFactory<CurrencyPlanNPO, CurrencyPlanNPO>) pipes();
}
public static CurrencyPlanNPOPipeLineFactory<CurrencyPlanNPO, CurrencyPlanNPO> pipesCurrencyPlanNPO(Collection<CurrencyPlanNPO> items)
{
return REFERENCE_CurrencyPlanNPO.new CurrencyPlanNPOPipeLineFactory<CurrencyPlanNPO, CurrencyPlanNPO> (items);
}
public static CurrencyPlanNPOPipeLineFactory<CurrencyPlanNPO, CurrencyPlanNPO> pipesCurrencyPlanNPO(CurrencyPlanNPO[] _items)
{
return pipesCurrencyPlanNPO(Arrays.asList (_items));
}
public static CurrencyPlanNPOPipeLineFactory<CurrencyPlanNPO, CurrencyPlanNPO> pipesCurrencyPlanNPO()
{
return pipesCurrencyPlanNPO((Collection)null);
}
public class CurrencyPlanNPOPipeLineFactory<From extends BaseBusinessClass, Me extends CurrencyPlanNPO> extends NonPersistentBOPipeLineFactory<From, Me>
{
public <Prev> CurrencyPlanNPOPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public CurrencyPlanNPOPipeLineFactory (From seed)
{
super(seed);
}
public CurrencyPlanNPOPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Amount"))
{
return toAmount ();
}
if (name.equals ("PerJobAmount"))
{
return toPerJobAmount ();
}
if (name.equals ("CurrencyType"))
{
return toCurrencyType ();
}
if (name.equals ("Plan"))
{
return toPlan ();
}
return super.to(name);
}
public PipeLine<From, Double> toAmount () { return pipe(new ORMAttributePipe<Me, Double>(FIELD_Amount)); }
public PipeLine<From, Double> toPerJobAmount () { return pipe(new ORMAttributePipe<Me, Double>(FIELD_PerJobAmount)); }
public PipeLine<From, CurrencyType> toCurrencyType () { return pipe(new ORMAttributePipe<Me, CurrencyType>(FIELD_CurrencyType)); }
public StripePlanNPO.StripePlanNPOPipeLineFactory<From, StripePlanNPO> toPlan () { return toPlan (Filter.ALL); }
public StripePlanNPO.StripePlanNPOPipeLineFactory<From, StripePlanNPO> toPlan (Filter<StripePlanNPO> filter)
{
return StripePlanNPO.REFERENCE_StripePlanNPO.new StripePlanNPOPipeLineFactory<From, StripePlanNPO> (this, new ORMSingleAssocPipe<Me, StripePlanNPO>(SINGLEREFERENCE_Plan, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyCurrencyPlanNPO extends CurrencyPlanNPO
{
// Default constructor primarily to support Externalisable
public DummyCurrencyPlanNPO()
{
super();
}
public void assertValid ()
{
}
public StripePlanNPO getPlan () throws StorageException
{
return (StripePlanNPO)(StripePlanNPO.DUMMY_StripePlanNPO);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getPlanID ()
{
return StripePlanNPO.DUMMY_StripePlanNPO.getObjectID();
}
}
/*
* 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 oneit.servlets.orm.*;
public abstract class BaseStripePlanNPO extends NonPersistentBO
{
// Reference instance for the object
public static final StripePlanNPO REFERENCE_StripePlanNPO = new StripePlanNPO ();
// Reference instance for the object
public static final StripePlanNPO DUMMY_StripePlanNPO = new DummyStripePlanNPO ();
// Static constants corresponding to field names
public static final String FIELD_ProductID = "ProductID";
public static final String FIELD_PlanName = "PlanName";
public static final String FIELD_ActiveJobs = "ActiveJobs";
public static final String MULTIPLEREFERENCE_CurrencyPlans = "CurrencyPlans";
public static final String BACKREF_CurrencyPlans = "";
// Static constants corresponding to searches
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<StripePlanNPO> HELPER_ProductID = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripePlanNPO> HELPER_PlanName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<StripePlanNPO> HELPER_ActiveJobs = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _ProductID;
private String _PlanName;
private Integer _ActiveJobs;
// Private attributes corresponding to single references
// Private attributes corresponding to multiple references
private MultipleAssociation<StripePlanNPO, CurrencyPlanNPO> _CurrencyPlans;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_StripePlanNPO = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_ProductID_Validators;
private static final AttributeValidator[] FIELD_PlanName_Validators;
private static final AttributeValidator[] FIELD_ActiveJobs_Validators;
// Arrays of behaviour decorators
private static final StripePlanNPOBehaviourDecorator[] StripePlanNPO_BehaviourDecorators;
static
{
try
{
String tmp_CurrencyPlans = CurrencyPlanNPO.BACKREF_Plan;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_CurrencyPlans();
FIELD_ProductID_Validators = (AttributeValidator[])setupAttribMetaData_ProductID(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_PlanName_Validators = (AttributeValidator[])setupAttribMetaData_PlanName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ActiveJobs_Validators = (AttributeValidator[])setupAttribMetaData_ActiveJobs(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_StripePlanNPO.initialiseReference ();
DUMMY_StripePlanNPO.initialiseReference ();
StripePlanNPO_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(StripePlanNPO.class).toArray(new StripePlanNPOBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_CurrencyPlans()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Plan");
metaInfo.put ("name", "CurrencyPlans");
metaInfo.put ("type", "CurrencyPlanNPO");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.CurrencyPlans:", metaInfo);
ATTRIBUTES_METADATA_StripePlanNPO.put (MULTIPLEREFERENCE_CurrencyPlans, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_ProductID(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("name", "ProductID");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.ProductID:", metaInfo);
ATTRIBUTES_METADATA_StripePlanNPO.put (FIELD_ProductID, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripePlanNPO.class, "ProductID", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripePlanNPO.ProductID:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_PlanName(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("name", "PlanName");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.PlanName:", metaInfo);
ATTRIBUTES_METADATA_StripePlanNPO.put (FIELD_PlanName, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripePlanNPO.class, "PlanName", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripePlanNPO.PlanName:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ActiveJobs(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("name", "ActiveJobs");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for StripePlanNPO.ActiveJobs:", metaInfo);
ATTRIBUTES_METADATA_StripePlanNPO.put (FIELD_ActiveJobs, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(StripePlanNPO.class, "ActiveJobs", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for StripePlanNPO.ActiveJobs:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseStripePlanNPO ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return StripePlanNPO_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_ProductID = (String)(HELPER_ProductID.initialise (_ProductID));
_PlanName = (String)(HELPER_PlanName.initialise (_PlanName));
_ActiveJobs = (Integer)(HELPER_ActiveJobs.initialise (_ActiveJobs));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_CurrencyPlans = new MultipleAssociation<StripePlanNPO, CurrencyPlanNPO> (this, MULTIPLEREFERENCE_CurrencyPlans, CurrencyPlanNPO.SINGLEREFERENCE_Plan, CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_CurrencyPlans = new MultipleAssociation<StripePlanNPO, CurrencyPlanNPO> (this, MULTIPLEREFERENCE_CurrencyPlans, CurrencyPlanNPO.SINGLEREFERENCE_Plan, CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO);
return this;
}
/**
* Get the attribute ProductID
*/
public String getProductID ()
{
assertValid();
String valToReturn = _ProductID;
for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
{
valToReturn = bhd.getProductID ((StripePlanNPO)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 preProductIDChange (String newProductID) 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 postProductIDChange () throws FieldException
{
}
public FieldWriteability getWriteability_ProductID ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ProductID. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setProductID (String newProductID) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ProductID.compare (_ProductID, newProductID);
try
{
for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
{
newProductID = bhd.setProductID ((StripePlanNPO)this, newProductID);
oldAndNewIdentical = HELPER_ProductID.compare (_ProductID, newProductID);
}
if (FIELD_ProductID_Validators.length > 0)
{
Object newProductIDObj = HELPER_ProductID.toObject (newProductID);
if (newProductIDObj != null)
{
int loopMax = FIELD_ProductID_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripePlanNPO.get (FIELD_ProductID);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ProductID_Validators[v].checkAttribute (this, FIELD_ProductID, metadata, newProductIDObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ProductID () != FieldWriteability.FALSE, "Field ProductID is not writeable");
preProductIDChange (newProductID);
markFieldChange (FIELD_ProductID);
_ProductID = newProductID;
postFieldChange (FIELD_ProductID);
postProductIDChange ();
}
}
/**
* Get the attribute PlanName
*/
public String getPlanName ()
{
assertValid();
String valToReturn = _PlanName;
for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
{
valToReturn = bhd.getPlanName ((StripePlanNPO)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 (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
{
newPlanName = bhd.setPlanName ((StripePlanNPO)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_StripePlanNPO.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 ActiveJobs
*/
public Integer getActiveJobs ()
{
assertValid();
Integer valToReturn = _ActiveJobs;
for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
{
valToReturn = bhd.getActiveJobs ((StripePlanNPO)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 preActiveJobsChange (Integer newActiveJobs) 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 postActiveJobsChange () throws FieldException
{
}
public FieldWriteability getWriteability_ActiveJobs ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ActiveJobs. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setActiveJobs (Integer newActiveJobs) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ActiveJobs.compare (_ActiveJobs, newActiveJobs);
try
{
for (StripePlanNPOBehaviourDecorator bhd : StripePlanNPO_BehaviourDecorators)
{
newActiveJobs = bhd.setActiveJobs ((StripePlanNPO)this, newActiveJobs);
oldAndNewIdentical = HELPER_ActiveJobs.compare (_ActiveJobs, newActiveJobs);
}
if (FIELD_ActiveJobs_Validators.length > 0)
{
Object newActiveJobsObj = HELPER_ActiveJobs.toObject (newActiveJobs);
if (newActiveJobsObj != null)
{
int loopMax = FIELD_ActiveJobs_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_StripePlanNPO.get (FIELD_ActiveJobs);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ActiveJobs_Validators[v].checkAttribute (this, FIELD_ActiveJobs, metadata, newActiveJobsObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ActiveJobs () != FieldWriteability.FALSE, "Field ActiveJobs is not writeable");
preActiveJobsChange (newActiveJobs);
markFieldChange (FIELD_ActiveJobs);
_ActiveJobs = newActiveJobs;
postFieldChange (FIELD_ActiveJobs);
postActiveJobsChange ();
}
}
/**
* 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 ();
result.add("CurrencyPlans");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
return CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
return CurrencyPlanNPO.SINGLEREFERENCE_Plan ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
return this.getCurrencyPlansCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
return this.getCurrencyPlansAt(index);
}
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
addToCurrencyPlans((CurrencyPlanNPO)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
removeFromCurrencyPlans((CurrencyPlanNPO)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
_CurrencyPlans.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_CurrencyPlans.equals(attribName))
{
return _CurrencyPlans.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_CurrencyPlans ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getCurrencyPlansCount () throws StorageException
{
assertValid();
return _CurrencyPlans.getReferencedObjectsCount ();
}
public void addToCurrencyPlans (CurrencyPlanNPO newElement) throws StorageException
{
if (_CurrencyPlans.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_CurrencyPlans () != FieldWriteability.FALSE, "MultiAssoc CurrencyPlans is not writeable (add)");
_CurrencyPlans.appendElement (newElement);
try
{
if (newElement.getPlan () != this)
{
newElement.setPlan ((StripePlanNPO)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromCurrencyPlans (CurrencyPlanNPO elementToRemove) throws StorageException
{
if (_CurrencyPlans.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_CurrencyPlans () != FieldWriteability.FALSE, "MultiAssoc CurrencyPlans is not writeable (remove)");
_CurrencyPlans.removeElement (elementToRemove);
try
{
if (elementToRemove.getPlan () != null)
{
elementToRemove.setPlan (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public CurrencyPlanNPO getCurrencyPlansAt (int index) throws StorageException
{
return (CurrencyPlanNPO)(_CurrencyPlans.getElementAt (index));
}
public SortedSet<CurrencyPlanNPO> getCurrencyPlansSet () throws StorageException
{
return _CurrencyPlans.getSet ();
}
public void onDelete ()
{
try
{
for(CurrencyPlanNPO referenced : CollectionUtils.reverse(getCurrencyPlansSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Plan from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setPlan(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public StripePlanNPO newInstance ()
{
return new StripePlanNPO ();
}
public StripePlanNPO referenceInstance ()
{
return REFERENCE_StripePlanNPO;
}
public StripePlanNPO getInTransaction (ObjectTransaction t) throws StorageException
{
return getStripePlanNPOByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_StripePlanNPO;
}
public String getBaseSetName ()
{
return "it_does_not_matter";
}
/**
* 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 it_does_not_matterPSet = allSets.getPersistentSet (myID, "it_does_not_matter", myPSetStatus);
it_does_not_matterPSet.setAttrib (FIELD_ObjectID, myID);
it_does_not_matterPSet.setAttrib (FIELD_ProductID, HELPER_ProductID.toObject (_ProductID)); //
it_does_not_matterPSet.setAttrib (FIELD_PlanName, HELPER_PlanName.toObject (_PlanName)); //
it_does_not_matterPSet.setAttrib (FIELD_ActiveJobs, HELPER_ActiveJobs.toObject (_ActiveJobs)); //
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet it_does_not_matterPSet = allSets.getPersistentSet (objectID, "it_does_not_matter");
_ProductID = (String)(HELPER_ProductID.fromObject (_ProductID, it_does_not_matterPSet.getAttrib (FIELD_ProductID))); //
_PlanName = (String)(HELPER_PlanName.fromObject (_PlanName, it_does_not_matterPSet.getAttrib (FIELD_PlanName))); //
_ActiveJobs = (Integer)(HELPER_ActiveJobs.fromObject (_ActiveJobs, it_does_not_matterPSet.getAttrib (FIELD_ActiveJobs))); //
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof StripePlanNPO)
{
StripePlanNPO otherStripePlanNPO = (StripePlanNPO)other;
try
{
setProductID (otherStripePlanNPO.getProductID ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setPlanName (otherStripePlanNPO.getPlanName ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setActiveJobs (otherStripePlanNPO.getActiveJobs ());
}
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 BaseStripePlanNPO)
{
BaseStripePlanNPO sourceStripePlanNPO = (BaseStripePlanNPO)(source);
_ProductID = sourceStripePlanNPO._ProductID;
_PlanName = sourceStripePlanNPO._PlanName;
_ActiveJobs = sourceStripePlanNPO._ActiveJobs;
}
}
/**
* 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 BaseStripePlanNPO)
{
BaseStripePlanNPO sourceStripePlanNPO = (BaseStripePlanNPO)(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 BaseStripePlanNPO)
{
BaseStripePlanNPO sourceStripePlanNPO = (BaseStripePlanNPO)(source);
_CurrencyPlans.copyFrom (sourceStripePlanNPO._CurrencyPlans, linkToGhosts);
}
}
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);
_ProductID = (String)(HELPER_ProductID.readExternal (_ProductID, vals.get(FIELD_ProductID))); //
_PlanName = (String)(HELPER_PlanName.readExternal (_PlanName, vals.get(FIELD_PlanName))); //
_ActiveJobs = (Integer)(HELPER_ActiveJobs.readExternal (_ActiveJobs, vals.get(FIELD_ActiveJobs))); //
_CurrencyPlans.readExternalData(vals.get(MULTIPLEREFERENCE_CurrencyPlans));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_ProductID, HELPER_ProductID.writeExternal (_ProductID));
vals.put (FIELD_PlanName, HELPER_PlanName.writeExternal (_PlanName));
vals.put (FIELD_ActiveJobs, HELPER_ActiveJobs.writeExternal (_ActiveJobs));
vals.put (MULTIPLEREFERENCE_CurrencyPlans, _CurrencyPlans.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseStripePlanNPO)
{
BaseStripePlanNPO otherStripePlanNPO = (BaseStripePlanNPO)(other);
if (!HELPER_ProductID.compare(this._ProductID, otherStripePlanNPO._ProductID))
{
listener.notifyFieldChange(this, other, FIELD_ProductID, HELPER_ProductID.toObject(this._ProductID), HELPER_ProductID.toObject(otherStripePlanNPO._ProductID));
}
if (!HELPER_PlanName.compare(this._PlanName, otherStripePlanNPO._PlanName))
{
listener.notifyFieldChange(this, other, FIELD_PlanName, HELPER_PlanName.toObject(this._PlanName), HELPER_PlanName.toObject(otherStripePlanNPO._PlanName));
}
if (!HELPER_ActiveJobs.compare(this._ActiveJobs, otherStripePlanNPO._ActiveJobs))
{
listener.notifyFieldChange(this, other, FIELD_ActiveJobs, HELPER_ActiveJobs.toObject(this._ActiveJobs), HELPER_ActiveJobs.toObject(otherStripePlanNPO._ActiveJobs));
}
// Compare single assocs
// Compare multiple assocs
_CurrencyPlans.compare (otherStripePlanNPO._CurrencyPlans, listener);
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_ProductID, HELPER_ProductID.toObject(getProductID()));
visitor.visitField(this, FIELD_PlanName, HELPER_PlanName.toObject(getPlanName()));
visitor.visitField(this, FIELD_ActiveJobs, HELPER_ActiveJobs.toObject(getActiveJobs()));
visitor.visitAssociation (_CurrencyPlans);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_CurrencyPlans))
{
visitor.visit (_CurrencyPlans);
}
}
public static StripePlanNPO createStripePlanNPO (ObjectTransaction transaction) throws StorageException
{
StripePlanNPO result = new StripePlanNPO ();
result.initialiseNewObject (transaction);
return result;
}
public static StripePlanNPO getStripePlanNPOByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (StripePlanNPO)(transaction.getObjectByID (REFERENCE_StripePlanNPO, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_ProductID))
{
return filter.matches (getProductID ());
}
else if (attribName.equals (FIELD_PlanName))
{
return filter.matches (getPlanName ());
}
else if (attribName.equals (FIELD_ActiveJobs))
{
return filter.matches (getActiveJobs ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_ProductID))
{
return HELPER_ProductID.toObject (getProductID ());
}
else if (attribName.equals (FIELD_PlanName))
{
return HELPER_PlanName.toObject (getPlanName ());
}
else if (attribName.equals (FIELD_ActiveJobs))
{
return HELPER_ActiveJobs.toObject (getActiveJobs ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_ProductID))
{
return HELPER_ProductID;
}
else if (attribName.equals (FIELD_PlanName))
{
return HELPER_PlanName;
}
else if (attribName.equals (FIELD_ActiveJobs))
{
return HELPER_ActiveJobs;
}
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_ProductID))
{
setProductID ((String)(HELPER_ProductID.fromObject (_ProductID, attribValue)));
}
else if (attribName.equals (FIELD_PlanName))
{
setPlanName ((String)(HELPER_PlanName.fromObject (_PlanName, attribValue)));
}
else if (attribName.equals (FIELD_ActiveJobs))
{
setActiveJobs ((Integer)(HELPER_ActiveJobs.fromObject (_ActiveJobs, 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_ProductID))
{
return getWriteability_ProductID ();
}
else if (fieldName.equals (FIELD_PlanName))
{
return getWriteability_PlanName ();
}
else if (fieldName.equals (FIELD_ActiveJobs))
{
return getWriteability_ActiveJobs ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_CurrencyPlans))
{
return getWriteability_CurrencyPlans ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_ProductID () != FieldWriteability.TRUE)
{
fields.add (FIELD_ProductID);
}
if (getWriteability_PlanName () != FieldWriteability.TRUE)
{
fields.add (FIELD_PlanName);
}
if (getWriteability_ActiveJobs () != FieldWriteability.TRUE)
{
fields.add (FIELD_ActiveJobs);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_ProductID.getAttribObject (getClass (), _ProductID, false, FIELD_ProductID));
result.add(HELPER_PlanName.getAttribObject (getClass (), _PlanName, false, FIELD_PlanName));
result.add(HELPER_ActiveJobs.getAttribObject (getClass (), _ActiveJobs, false, FIELD_ActiveJobs));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_StripePlanNPO.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_StripePlanNPO.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_StripePlanNPO.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_StripePlanNPO.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 StripePlanNPOBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<StripePlanNPO>
{
/**
* Get the attribute ProductID
*/
public String getProductID (StripePlanNPO obj, String original)
{
return original;
}
/**
* Change the value set for attribute ProductID.
* May modify the field beforehand
* Occurs before validation.
*/
public String setProductID (StripePlanNPO obj, String newProductID) throws FieldException
{
return newProductID;
}
/**
* Get the attribute PlanName
*/
public String getPlanName (StripePlanNPO obj, String original)
{
return original;
}
/**
* Change the value set for attribute PlanName.
* May modify the field beforehand
* Occurs before validation.
*/
public String setPlanName (StripePlanNPO obj, String newPlanName) throws FieldException
{
return newPlanName;
}
/**
* Get the attribute ActiveJobs
*/
public Integer getActiveJobs (StripePlanNPO obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute ActiveJobs.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setActiveJobs (StripePlanNPO obj, Integer newActiveJobs) throws FieldException
{
return newActiveJobs;
}
}
public ORMPipeLine pipes()
{
return new StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> ((StripePlanNPO)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipelineStripePlanNPO()
{
return (StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO>) pipes();
}
public static StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipesStripePlanNPO(Collection<StripePlanNPO> items)
{
return REFERENCE_StripePlanNPO.new StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> (items);
}
public static StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipesStripePlanNPO(StripePlanNPO[] _items)
{
return pipesStripePlanNPO(Arrays.asList (_items));
}
public static StripePlanNPOPipeLineFactory<StripePlanNPO, StripePlanNPO> pipesStripePlanNPO()
{
return pipesStripePlanNPO((Collection)null);
}
public class StripePlanNPOPipeLineFactory<From extends BaseBusinessClass, Me extends StripePlanNPO> extends NonPersistentBOPipeLineFactory<From, Me>
{
public <Prev> StripePlanNPOPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public StripePlanNPOPipeLineFactory (From seed)
{
super(seed);
}
public StripePlanNPOPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("CurrencyPlans"))
{
return toCurrencyPlans ();
}
if (name.equals ("ProductID"))
{
return toProductID ();
}
if (name.equals ("PlanName"))
{
return toPlanName ();
}
if (name.equals ("ActiveJobs"))
{
return toActiveJobs ();
}
return super.to(name);
}
public PipeLine<From, String> toProductID () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ProductID)); }
public PipeLine<From, String> toPlanName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_PlanName)); }
public PipeLine<From, Integer> toActiveJobs () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ActiveJobs)); }
public CurrencyPlanNPO.CurrencyPlanNPOPipeLineFactory<From, CurrencyPlanNPO> toCurrencyPlans () { return toCurrencyPlans(Filter.ALL); }
public CurrencyPlanNPO.CurrencyPlanNPOPipeLineFactory<From, CurrencyPlanNPO> toCurrencyPlans (Filter<CurrencyPlanNPO> filter)
{
return CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO.new CurrencyPlanNPOPipeLineFactory<From, CurrencyPlanNPO> (this, new ORMMultiAssocPipe<Me, CurrencyPlanNPO>(MULTIPLEREFERENCE_CurrencyPlans, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyStripePlanNPO extends StripePlanNPO
{
// Default constructor primarily to support Externalisable
public DummyStripePlanNPO()
{
super();
}
public void assertValid ()
{
}
public int getCurrencyPlansCount () throws StorageException
{
return 0;
}
public CurrencyPlanNPO getCurrencyPlansAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association CurrencyPlans");
}
public SortedSet getCurrencyPlansSet () throws StorageException
{
return new TreeSet();
}
}
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
import oneit.servlets.orm.*;
import performa.orm.types.*;
public class CurrencyPlanNPO extends BaseCurrencyPlanNPO
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public CurrencyPlanNPO ()
{
// 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="CurrencyPlanNPO" package="performa.orm" superclass="NonPersistentBO">
<IMPORT value="oneit.servlets.orm.*"/>
<IMPORT value="performa.orm.types.*"/>
<TABLE name="it_does_not_matter" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Amount" type="Double" SubType="Currency" Formatter="Currency" />
<ATTRIB name="PerJobAmount" type="Double" SubType="Currency" Formatter="Currency" />
<ATTRIB name="CurrencyType" type="CurrencyType" attribHelper="EnumeratedAttributeHelper"/>
<SINGLEREFERENCE name="Plan" type="StripePlanNPO" backreferenceName="CurrencyPlans"/>
</TABLE>
</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 oneit.servlets.orm.*;
import performa.orm.types.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class CurrencyPlanNPOPersistenceMgr extends NonPersistentBOPersistenceMgr
{
private static final LoggingArea CurrencyPlanNPOPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CurrencyPlanNPO");
// Private attributes corresponding to business object data
private Double dummyAmount;
private Double dummyPerJobAmount;
private CurrencyType dummyCurrencyType;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Amount = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_PerJobAmount = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_CurrencyType = new EnumeratedAttributeHelper (CurrencyType.FACTORY_CurrencyType);
public CurrencyPlanNPOPersistenceMgr ()
{
dummyAmount = (Double)(HELPER_Amount.initialise (dummyAmount));
dummyPerJobAmount = (Double)(HELPER_PerJobAmount.initialise (dummyPerJobAmount));
dummyCurrencyType = (CurrencyType)(HELPER_CurrencyType.initialise (dummyCurrencyType));
}
private String SELECT_COLUMNS = "{PREFIX}it_does_not_matter.object_id as id, {PREFIX}it_does_not_matter.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}it_does_not_matter.object_CREATED_DATE as CREATED_DATE, {PREFIX}it_does_not_matter., {PREFIX}it_does_not_matter., {PREFIX}it_does_not_matter., {PREFIX}it_does_not_matter., 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, CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO);
if (objectToReturn instanceof CurrencyPlanNPO)
{
LogMgr.log (CurrencyPlanNPOPersistence, 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 CurrencyPlanNPO");
}
}
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(id, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !it_does_not_matterPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!it_does_not_matterPSet.containsAttrib(CurrencyPlanNPO.FIELD_Amount)||
!it_does_not_matterPSet.containsAttrib(CurrencyPlanNPO.FIELD_PerJobAmount)||
!it_does_not_matterPSet.containsAttrib(CurrencyPlanNPO.FIELD_CurrencyType)||
!it_does_not_matterPSet.containsAttrib(CurrencyPlanNPO.SINGLEREFERENCE_Plan))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (CurrencyPlanNPOPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
CurrencyPlanNPO result = new CurrencyPlanNPO ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}it_does_not_matter " +
"WHERE " + SELECT_JOINS + "{PREFIX}it_does_not_matter.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 if (refName.equals (CurrencyPlanNPO.SINGLEREFERENCE_Plan))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}it_does_not_matter " +
"WHERE " + SELECT_JOINS + " = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
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 it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}it_does_not_matter " +
"SET = ?, = ?, = ?, = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE it_does_not_matter.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Amount.getForSQL(dummyAmount, it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.FIELD_Amount))).listEntry (HELPER_PerJobAmount.getForSQL(dummyPerJobAmount, it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.FIELD_PerJobAmount))).listEntry (HELPER_CurrencyType.getForSQL(dummyCurrencyType, it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.FIELD_CurrencyType))).listEntry (SQLManager.CheckNull((Long)(it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.SINGLEREFERENCE_Plan)))).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}it_does_not_matter 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[] { "it_does_not_matter", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (CurrencyPlanNPOPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:it_does_not_matter for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CurrencyPlanNPOPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (CurrencyPlanNPOPersistence, 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 it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
LogMgr.log (CurrencyPlanNPOPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}it_does_not_matter " +
"WHERE it_does_not_matter.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}it_does_not_matter WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:it_does_not_matter for row:" + objectID;
LogMgr.log (CurrencyPlanNPOPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, CurrencyPlanNPO> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO.getObjectIDSpace (), r.getLong ("id"));
CurrencyPlanNPO 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, CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO);
if (cachedElement instanceof CurrencyPlanNPO)
{
LogMgr.log (CurrencyPlanNPOPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (CurrencyPlanNPO)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a CurrencyPlanNPO");
}
}
else
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new CurrencyPlanNPO ();
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 (CurrencyPlanNPOPersistence, 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}it_does_not_matter " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else
{
BaseBusinessClass[] resultsArray = super.find(searchType, allPSets, criteria, context, sqlMgr);
Vector results = new Vector ();
for (int x = 0 ; x < resultsArray.length ; ++x)
{
if (resultsArray[x] instanceof CurrencyPlanNPO)
{
results.add (resultsArray[x]);
}
else
{
// Ignore
}
}
resultsArray = new BaseBusinessClass[results.size ()];
results.copyInto (resultsArray);
return resultsArray;
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Object Modified
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
it_does_not_matterPSet.setAttrib(CurrencyPlanNPO.FIELD_Amount, HELPER_Amount.getFromRS(dummyAmount, r, ""));
it_does_not_matterPSet.setAttrib(CurrencyPlanNPO.FIELD_PerJobAmount, HELPER_PerJobAmount.getFromRS(dummyPerJobAmount, r, ""));
it_does_not_matterPSet.setAttrib(CurrencyPlanNPO.FIELD_CurrencyType, HELPER_CurrencyType.getFromRS(dummyCurrencyType, r, ""));
it_does_not_matterPSet.setAttrib(CurrencyPlanNPO.SINGLEREFERENCE_Plan, r.getObject (""));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}it_does_not_matter " +
" (, , , , object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Amount.getForSQL(dummyAmount, it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.FIELD_Amount))).listEntry (HELPER_PerJobAmount.getForSQL(dummyPerJobAmount, it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.FIELD_PerJobAmount))).listEntry (HELPER_CurrencyType.getForSQL(dummyCurrencyType, it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.FIELD_CurrencyType))) .listEntry (SQLManager.CheckNull((Long)(it_does_not_matterPSet.getAttrib (CurrencyPlanNPO.SINGLEREFERENCE_Plan)))) .listEntry (objectID.longID ()).toList().toArray());
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm;
public class StripePlanNPO extends BaseStripePlanNPO
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public StripePlanNPO ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?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="StripePlanNPO" package="performa.orm" superclass="NonPersistentBO">
<IMPORT value="oneit.servlets.orm.*"/>
<MULTIPLEREFERENCE name="CurrencyPlans" type="CurrencyPlanNPO" backreferenceName="Plan" />
<TABLE name="it_does_not_matter" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="ProductID" type="String" />
<ATTRIB name="PlanName" type="String" />
<ATTRIB name="ActiveJobs" type="Integer" />
</TABLE>
</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 oneit.servlets.orm.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class StripePlanNPOPersistenceMgr extends NonPersistentBOPersistenceMgr
{
private static final LoggingArea StripePlanNPOPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "StripePlanNPO");
// Private attributes corresponding to business object data
private String dummyProductID;
private String dummyPlanName;
private Integer dummyActiveJobs;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_ProductID = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_PlanName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ActiveJobs = DefaultAttributeHelper.INSTANCE;
public StripePlanNPOPersistenceMgr ()
{
dummyProductID = (String)(HELPER_ProductID.initialise (dummyProductID));
dummyPlanName = (String)(HELPER_PlanName.initialise (dummyPlanName));
dummyActiveJobs = (Integer)(HELPER_ActiveJobs.initialise (dummyActiveJobs));
}
private String SELECT_COLUMNS = "{PREFIX}it_does_not_matter.object_id as id, {PREFIX}it_does_not_matter.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}it_does_not_matter.object_CREATED_DATE as CREATED_DATE, {PREFIX}it_does_not_matter., {PREFIX}it_does_not_matter., {PREFIX}it_does_not_matter., 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, StripePlanNPO.REFERENCE_StripePlanNPO);
if (objectToReturn instanceof StripePlanNPO)
{
LogMgr.log (StripePlanNPOPersistence, 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 StripePlanNPO");
}
}
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(id, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !it_does_not_matterPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!it_does_not_matterPSet.containsAttrib(StripePlanNPO.FIELD_ProductID)||
!it_does_not_matterPSet.containsAttrib(StripePlanNPO.FIELD_PlanName)||
!it_does_not_matterPSet.containsAttrib(StripePlanNPO.FIELD_ActiveJobs))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (StripePlanNPOPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
StripePlanNPO result = new StripePlanNPO ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}it_does_not_matter " +
"WHERE " + SELECT_JOINS + "{PREFIX}it_does_not_matter.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 it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}it_does_not_matter " +
"SET = ?, = ?, = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE it_does_not_matter.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_ProductID.getForSQL(dummyProductID, it_does_not_matterPSet.getAttrib (StripePlanNPO.FIELD_ProductID))).listEntry (HELPER_PlanName.getForSQL(dummyPlanName, it_does_not_matterPSet.getAttrib (StripePlanNPO.FIELD_PlanName))).listEntry (HELPER_ActiveJobs.getForSQL(dummyActiveJobs, it_does_not_matterPSet.getAttrib (StripePlanNPO.FIELD_ActiveJobs))).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}it_does_not_matter 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[] { "it_does_not_matter", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (StripePlanNPOPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:it_does_not_matter for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (StripePlanNPOPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (StripePlanNPOPersistence, 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 it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
LogMgr.log (StripePlanNPOPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}it_does_not_matter " +
"WHERE it_does_not_matter.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}it_does_not_matter WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:it_does_not_matter for row:" + objectID;
LogMgr.log (StripePlanNPOPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, StripePlanNPO> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (StripePlanNPO.REFERENCE_StripePlanNPO.getObjectIDSpace (), r.getLong ("id"));
StripePlanNPO 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, StripePlanNPO.REFERENCE_StripePlanNPO);
if (cachedElement instanceof StripePlanNPO)
{
LogMgr.log (StripePlanNPOPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (StripePlanNPO)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a StripePlanNPO");
}
}
else
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new StripePlanNPO ();
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 (StripePlanNPOPersistence, 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}it_does_not_matter " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else
{
BaseBusinessClass[] resultsArray = super.find(searchType, allPSets, criteria, context, sqlMgr);
Vector results = new Vector ();
for (int x = 0 ; x < resultsArray.length ; ++x)
{
if (resultsArray[x] instanceof StripePlanNPO)
{
results.add (resultsArray[x]);
}
else
{
// Ignore
}
}
resultsArray = new BaseBusinessClass[results.size ()];
results.copyInto (resultsArray);
return resultsArray;
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Object Modified
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
it_does_not_matterPSet.setAttrib(StripePlanNPO.FIELD_ProductID, HELPER_ProductID.getFromRS(dummyProductID, r, ""));
it_does_not_matterPSet.setAttrib(StripePlanNPO.FIELD_PlanName, HELPER_PlanName.getFromRS(dummyPlanName, r, ""));
it_does_not_matterPSet.setAttrib(StripePlanNPO.FIELD_ActiveJobs, HELPER_ActiveJobs.getFromRS(dummyActiveJobs, r, ""));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}it_does_not_matter " +
" (, , , object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_ProductID.getForSQL(dummyProductID, it_does_not_matterPSet.getAttrib (StripePlanNPO.FIELD_ProductID))).listEntry (HELPER_PlanName.getForSQL(dummyPlanName, it_does_not_matterPSet.getAttrib (StripePlanNPO.FIELD_PlanName))).listEntry (HELPER_ActiveJobs.getForSQL(dummyActiveJobs, it_does_not_matterPSet.getAttrib (StripePlanNPO.FIELD_ActiveJobs))) .listEntry (objectID.longID ()).toList().toArray());
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
...@@ -31,9 +31,12 @@ import oneit.utils.DateDiff; ...@@ -31,9 +31,12 @@ import oneit.utils.DateDiff;
import oneit.utils.math.NullArith; import oneit.utils.math.NullArith;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.Company; import performa.orm.Company;
import performa.orm.CurrencyPlanNPO;
import performa.orm.HiringTeam; import performa.orm.HiringTeam;
import performa.orm.Job; import performa.orm.Job;
import performa.orm.PaymentPlan; import performa.orm.PaymentPlan;
import performa.orm.StripePlanNPO;
import performa.orm.types.CurrencyType;
import spark.utils.IOUtils; import spark.utils.IOUtils;
...@@ -49,6 +52,47 @@ public class StripeUtils ...@@ -49,6 +52,47 @@ public class StripeUtils
Stripe.apiKey = STRIPE_KEY; Stripe.apiKey = STRIPE_KEY;
} }
public static void createPlan(StripePlanNPO stripePlan, CurrencyPlanNPO currencyPlan) throws FieldException, BusinessException
{
try
{
Map<String, Object> overagePlanParams = new HashMap<>();
overagePlanParams.put("amount", NullArith.intVal(NullArith.multiply(currencyPlan.getPerJobAmount(), 100, 0d)));
overagePlanParams.put("interval", "month");
overagePlanParams.put("usage_type", "metered");
overagePlanParams.put("product", stripePlan.getProductID());
overagePlanParams.put("currency", currencyPlan.getCurrencyType().getName());
overagePlanParams.put("nickname", stripePlan.getPlanName() + " Overage");
Plan overagePlan = Plan.create(overagePlanParams);
Map<String, Object> planParams = new HashMap<>();
planParams.put("amount", NullArith.intVal(NullArith.multiply(currencyPlan.getAmount(), 100, 0d)));
planParams.put("interval", "month");
planParams.put("product", stripePlan.getProductID());
planParams.put("currency", currencyPlan.getCurrencyType().getName());
planParams.put("nickname", stripePlan.getPlanName());
Map<String, Object> planMetadata = new HashMap<>();
planMetadata.put("ActiveJobs", stripePlan.getActiveJobs());
planMetadata.put("LinkedPlan", overagePlan.getId());
planParams.put("metadata", planMetadata);
Plan plan = Plan.create(planParams);
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Create plan in stripe : ", plan + " overage plan: " + overagePlan);
}
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while creating a plan in stripe");
throw new BusinessException("Problem with creating plan : " + ex.getMessage());
}
}
public static void createCustomer(HiringTeam hiringTeam) throws FieldException public static void createCustomer(HiringTeam hiringTeam) throws FieldException
{ {
......
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
<FORM name="*.testAnalysis" factory="Participant" class="performa.form.TestAnalysisFP"/> <FORM name="*.testAnalysis" factory="Participant" class="performa.form.TestAnalysisFP"/>
</NODE> </NODE>
<NODE name="setupPlans_jsp" factory="Participant">
<INHERITS factory="Named" nodename="CoreORMAdmin"/>
<FORM name="*.createPlan" factory="Participant" class="performa.form.CreatePlanFP"/>
</NODE>
<NODE name="createArticle_jsp::TL" factory="Participant"> <NODE name="createArticle_jsp::TL" factory="Participant">
<FORM name="*.assume" factory="Participant" class="performa.form.AssumeHTAdminFP"> <FORM name="*.assume" factory="Participant" class="performa.form.AssumeHTAdminFP">
<NODE name="loginFP" factory="Named" nodename="CMSLoginFP"/> <NODE name="loginFP" factory="Named" nodename="CMSLoginFP"/>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<!-- <TOPMENU name="MENU.TEST_ANALYSIS" desc="Test Analysis" sortOrder="100" factory="Participant" class="oneit.servlets.jsp.ui.DefaultUICustomiser$Element" <!-- <TOPMENU name="MENU.TEST_ANALYSIS" desc="Test Analysis" sortOrder="100" factory="Participant" class="oneit.servlets.jsp.ui.DefaultUICustomiser$Element"
link="/extensions/performa/testAnalysis.jsp"/> --> link="/extensions/performa/testAnalysis.jsp"/> -->
<!--<CHILD name="Performa.Customers" desc="Customers" sortOrder="10" toplevel="ADMIN" priv="admin" link="/extensions/performa/customers.jsp" factory="Participant" class="oneit.servlets.jsp.ui.DefaultUICustomiser$Element" />--> <CHILD name="Performa.SetupPlans" desc="Setup Plans" sortOrder="10" toplevel="ADMIN" priv="admin" link="/extensions/performa/setupPlans.jsp" factory="Participant" class="oneit.servlets.jsp.ui.DefaultUICustomiser$Element" />
</NODE> </NODE>
......
<%@ page extends="oneit.servlets.jsp.FormJSP"%>
<%@ include file="/setuprequest.jsp"%>
<%@ include file="inc/stdimports.jsp"%>
<%@ include file="/editor/stdimports.jsp"%>
<%@ page import="oneit.servlets.jsp.ormtable.*" %>
<%! protected String getName (ServletConfig config) { return "setupPlans_jsp"; } %>
<%
ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
ObjectTransaction objTran = process.getTransaction ();
StripePlanNPO plan = (StripePlanNPO) process.getAttribute("StripePlanNPO");
if(plan == null)
{
plan = StripePlanNPO.createStripePlanNPO(objTran);
process.setAttribute("StripePlanNPO", plan);
%><%@include file="/saferedirect.jsp"%><%
}
ORMTableCellStyle commonCellStyle = new ORMTableCellStyle("nofilter nosort");
BaseBusinessClassFactory currencyPlanFactory = new BaseBusinessClassFactory(CurrencyPlanNPO.REFERENCE_CurrencyPlanNPO, objTran)
.onInitSetSingleAssoc("Plan", plan );
request.setAttribute("oneit.pageFormDetails", CollectionUtils.mapEntry("name", "SetupPlan").mapEntry("enctype", "multipart/form-data").toMap());
request.setAttribute("oneit.pageHeaderTitle", "Setup Stripe Plans");
%>
<%@include file="/editor/header.jsp"%>
<oneit:layout_total widths="<%= new double[] {1, 4, 6} %>" skin="bootstrap">
<oneit:skin tagName="layout_row">
<oneit:layout_label width="1"><oneit:ormlabel obj="<%= plan %>" field="ProductID" /></oneit:layout_label>
<oneit:layout_field width="1">
<oneit:ormInput obj="<%= plan %>" attributeName="ProductID" type="text" class="form-control" required="required"/>
</oneit:layout_field>
</oneit:skin>
<oneit:skin tagName="layout_row">
<oneit:layout_label width="1"><oneit:ormlabel obj="<%= plan %>" field="PlanName" /></oneit:layout_label>
<oneit:layout_field width="1">
<oneit:ormInput obj="<%= plan %>" attributeName="PlanName" type="text" class="form-control" required="required"/>
</oneit:layout_field>
</oneit:skin>
<oneit:skin tagName="layout_row">
<oneit:layout_label width="1"><oneit:ormlabel obj="<%= plan %>" field="ActiveJobs" /></oneit:layout_label>
<oneit:layout_field width="1">
<oneit:ormInput obj="<%= plan %>" attributeName="ActiveJobs" type="text" class="form-control" required="required"/>
</oneit:layout_field>
</oneit:skin>
<oneit:skin tagName="layout_row">
<oneit:layout_field width="2">
<oneit:ormtable class="ormtable cougartable" tableId="currency-plan-list"
rowObjFactory="<%= currencyPlanFactory %>"
rowObjects="<%= plan.getCurrencyPlansSet() %>"
customiser="<%= new TableCustomiser() %>">
<oneit:ormcol expression="CurrencyType" width="3" mode="ormEnum" cellStyle="<%= commonCellStyle %>"/>
<oneit:ormcol expression="PerJobAmount" width="4" mode="text" cellStyle="<%= commonCellStyle %>"/>
<oneit:ormcol expression="Amount" width="4" mode="text" cellStyle="<%= commonCellStyle %>"/>
<oneit:ormcol expression="" width="0.1" mode="jsp" cellStyle="<%= commonCellStyle %>"
jspName="/extensions/standard/ormtable/deleteORMRowButton.jsp" />
</oneit:ormtable>
<input type="button" value="Add" onclick="ormtable_addRow('currency-plan-list');" style="float: right" class="btn btn-default"/>
</oneit:layout_field>
</oneit:skin>
<oneit:skin tagName="layout_row">
<oneit:layout_field width="1">
<oneit:button value="Create Plan" name="createPlan" cssClass="btn btn-primary" requestAttribs='<%= CollectionUtils.EMPTY_MAP %>'/>
</oneit:layout_field>
</oneit:skin>
</oneit:layout_total>
<%@include file="/editor/footer.jsp"%>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment