Commit 5a5ca51d by Harsh Shah

Culture related BOs added

parent ab6106e7
<?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">rs_culture_element</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="culture_element_desc" type="String" nullable="true" length="200"/>
<column name="culture_class_code" type="String" nullable="true" length="200"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">rs_culture_element_quest</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="quest" type="String" nullable="true" length="200"/>
<column name="culture_element_number" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_culture_element_quest" indexName="idx_rs_culture_element_quest_culture_element_number" isUnique="false"><column name="culture_element_number"/></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">rs_culture_element_rating</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="culture_element_rating_desc" type="String" nullable="true" length="200"/>
<column name="culture_element_number" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_culture_element_rating" indexName="idx_rs_culture_element_rating_culture_element_number" isUnique="false"><column name="culture_element_number"/></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">rs_culture_narrative</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="narrative_notes" type="CLOB" nullable="true"/>
<column name="color_code" type="String" nullable="true" length="200"/>
<column name="culture_element_number" type="Long" length="11" nullable="true"/>
<column name="culture_element_quest_id" type="Long" length="11" nullable="true"/>
<column name="culture_element_rating_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_culture_narrative" indexName="idx_rs_culture_narrative_culture_element_number" isUnique="false"><column name="culture_element_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_culture_narrative" indexName="idx_rs_culture_narrative_culture_element_quest_id" isUnique="false"><column name="culture_element_quest_id"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_culture_narrative" indexName="idx_rs_culture_narrative_culture_element_rating_id" isUnique="false"><column name="culture_element_rating_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE rs_culture_element;
CREATE TABLE rs_culture_element (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
culture_element_desc varchar(200) NULL,
culture_class_code varchar(200) NULL
);
ALTER TABLE rs_culture_element ADD
CONSTRAINT PK_rs_culture_element PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE rs_culture_element_quest;
CREATE TABLE rs_culture_element_quest (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
quest varchar(200) NULL,
culture_element_number numeric(12) NULL
);
ALTER TABLE rs_culture_element_quest ADD
CONSTRAINT PK_rs_culture_element_quest PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_element_quest_culture_element_number
ON rs_culture_element_quest (culture_element_number);
-- DROP TABLE rs_culture_element_rating;
CREATE TABLE rs_culture_element_rating (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
culture_element_rating_desc varchar(200) NULL,
culture_element_number numeric(12) NULL
);
ALTER TABLE rs_culture_element_rating ADD
CONSTRAINT PK_rs_culture_element_rating PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_element_rating_culture_element_number
ON rs_culture_element_rating (culture_element_number);
-- DROP TABLE rs_culture_narrative;
CREATE TABLE rs_culture_narrative (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
narrative_notes text NULL,
color_code varchar(200) NULL,
culture_element_number numeric(12) NULL,
culture_element_quest_id numeric(12) NULL,
culture_element_rating_id numeric(12) NULL
);
ALTER TABLE rs_culture_narrative ADD
CONSTRAINT PK_rs_culture_narrative PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_narrative_culture_element_number
ON rs_culture_narrative (culture_element_number);
CREATE INDEX idx_rs_culture_narrative_culture_element_quest_id
ON rs_culture_narrative (culture_element_quest_id);
CREATE INDEX idx_rs_culture_narrative_culture_element_rating_id
ON rs_culture_narrative (culture_element_rating_id);
-- DROP TABLE rs_culture_element;
CREATE TABLE rs_culture_element (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
culture_element_desc varchar2(200) NULL,
culture_class_code varchar2(200) NULL
);
ALTER TABLE rs_culture_element ADD
CONSTRAINT PK_rs_culture_element PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE rs_culture_element_quest;
CREATE TABLE rs_culture_element_quest (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
quest varchar2(200) NULL,
culture_element_number number(12) NULL
);
ALTER TABLE rs_culture_element_quest ADD
CONSTRAINT PK_rs_culture_element_quest PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_element_quest_culture_element_number
ON rs_culture_element_quest (culture_element_number);
-- DROP TABLE rs_culture_element_rating;
CREATE TABLE rs_culture_element_rating (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
culture_element_rating_desc varchar2(200) NULL,
culture_element_number number(12) NULL
);
ALTER TABLE rs_culture_element_rating ADD
CONSTRAINT PK_rs_culture_element_rating PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_element_rating_culture_element_number
ON rs_culture_element_rating (culture_element_number);
-- DROP TABLE rs_culture_narrative;
CREATE TABLE rs_culture_narrative (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
narrative_notes clob NULL,
color_code varchar2(200) NULL,
culture_element_number number(12) NULL,
culture_element_quest_id number(12) NULL,
culture_element_rating_id number(12) NULL
);
ALTER TABLE rs_culture_narrative ADD
CONSTRAINT PK_rs_culture_narrative PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_narrative_culture_element_number
ON rs_culture_narrative (culture_element_number);
CREATE INDEX idx_rs_culture_narrative_culture_element_quest_id
ON rs_culture_narrative (culture_element_quest_id);
CREATE INDEX idx_rs_culture_narrative_culture_element_rating_id
ON rs_culture_narrative (culture_element_rating_id);
-- @AutoRun
-- drop table rs_culture_element;
CREATE TABLE rs_culture_element (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
culture_element_desc varchar(200) NULL,
culture_class_code varchar(200) NULL
);
ALTER TABLE rs_culture_element ADD
CONSTRAINT pk_rs_culture_element PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table rs_culture_element_quest;
CREATE TABLE rs_culture_element_quest (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
quest varchar(200) NULL,
culture_element_number numeric(12) NULL
);
ALTER TABLE rs_culture_element_quest ADD
CONSTRAINT pk_rs_culture_element_quest PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_element_quest_culture_element_number
ON rs_culture_element_quest (culture_element_number);
-- @AutoRun
-- drop table rs_culture_element_rating;
CREATE TABLE rs_culture_element_rating (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
culture_element_rating_desc varchar(200) NULL,
culture_element_number numeric(12) NULL
);
ALTER TABLE rs_culture_element_rating ADD
CONSTRAINT pk_rs_culture_element_rating PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_element_rating_culture_element_number
ON rs_culture_element_rating (culture_element_number);
-- @AutoRun
-- drop table rs_culture_narrative;
CREATE TABLE rs_culture_narrative (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
narrative_notes text NULL,
color_code varchar(200) NULL,
culture_element_number numeric(12) NULL,
culture_element_quest_id numeric(12) NULL,
culture_element_rating_id numeric(12) NULL
);
ALTER TABLE rs_culture_narrative ADD
CONSTRAINT pk_rs_culture_narrative PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_rs_culture_narrative_culture_element_number
ON rs_culture_narrative (culture_element_number);
CREATE INDEX idx_rs_culture_narrative_culture_element_quest_id
ON rs_culture_narrative (culture_element_quest_id);
CREATE INDEX idx_rs_culture_narrative_culture_element_rating_id
ON rs_culture_narrative (culture_element_rating_id);
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseCultureElement extends BaseBusinessClass
{
// Reference instance for the object
public static final CultureElement REFERENCE_CultureElement = new CultureElement ();
// Reference instance for the object
public static final CultureElement DUMMY_CultureElement = new DummyCultureElement ();
// Static constants corresponding to field names
public static final String FIELD_Description = "Description";
public static final String FIELD_CultureClass = "CultureClass";
public static final String MULTIPLEREFERENCE_Questions = "Questions";
public static final String BACKREF_Questions = "";
public static final String MULTIPLEREFERENCE_Ratings = "Ratings";
public static final String BACKREF_Ratings = "";
public static final String MULTIPLEREFERENCE_Narratives = "Narratives";
public static final String BACKREF_Narratives = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<CultureElement> HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<CultureElement, CultureClass> HELPER_CultureClass = new EnumeratedAttributeHelper<CultureElement, CultureClass> (CultureClass.FACTORY_CultureClass);
// Private attributes corresponding to business object data
private String _Description;
private CultureClass _CultureClass;
// Private attributes corresponding to single references
// Private attributes corresponding to multiple references
private MultipleAssociation<CultureElement, CultureElementQuestion> _Questions;
private MultipleAssociation<CultureElement, CultureElementRating> _Ratings;
private MultipleAssociation<CultureElement, CultureNarrative> _Narratives;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_CultureElement = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Description_Validators;
private static final AttributeValidator[] FIELD_CultureClass_Validators;
// Arrays of behaviour decorators
private static final CultureElementBehaviourDecorator[] CultureElement_BehaviourDecorators;
static
{
try
{
String tmp_Questions = CultureElementQuestion.BACKREF_CultureElement;
String tmp_Ratings = CultureElementRating.BACKREF_CultureElement;
String tmp_Narratives = CultureNarrative.BACKREF_CultureElement;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Questions();
setupAssocMetaData_Ratings();
setupAssocMetaData_Narratives();
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_CultureClass_Validators = (AttributeValidator[])setupAttribMetaData_CultureClass(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_CultureElement.initialiseReference ();
DUMMY_CultureElement.initialiseReference ();
CultureElement_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CultureElement.class).toArray(new CultureElementBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Questions()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "CultureElement");
metaInfo.put ("name", "Questions");
metaInfo.put ("type", "CultureElementQuestion");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElement.Questions:", metaInfo);
ATTRIBUTES_METADATA_CultureElement.put (MULTIPLEREFERENCE_Questions, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Ratings()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "CultureElement");
metaInfo.put ("name", "Ratings");
metaInfo.put ("type", "CultureElementRating");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElement.Ratings:", metaInfo);
ATTRIBUTES_METADATA_CultureElement.put (MULTIPLEREFERENCE_Ratings, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Narratives()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "CultureElement");
metaInfo.put ("name", "Narratives");
metaInfo.put ("type", "CultureNarrative");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElement.Narratives:", metaInfo);
ATTRIBUTES_METADATA_CultureElement.put (MULTIPLEREFERENCE_Narratives, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "culture_element_desc");
metaInfo.put ("length", "200");
metaInfo.put ("name", "Description");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElement.Description:", metaInfo);
ATTRIBUTES_METADATA_CultureElement.put (FIELD_Description, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CultureElement.class, "Description", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CultureElement.Description:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_CultureClass(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "culture_class_code");
metaInfo.put ("name", "CultureClass");
metaInfo.put ("type", "CultureClass");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElement.CultureClass:", metaInfo);
ATTRIBUTES_METADATA_CultureElement.put (FIELD_CultureClass, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CultureElement.class, "CultureClass", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CultureElement.CultureClass:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseCultureElement ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return CultureElement_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Description = (String)(HELPER_Description.initialise (_Description));
_CultureClass = (CultureClass)(HELPER_CultureClass.initialise (_CultureClass));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_Questions = new MultipleAssociation<CultureElement, CultureElementQuestion> (this, MULTIPLEREFERENCE_Questions, CultureElementQuestion.SINGLEREFERENCE_CultureElement, CultureElementQuestion.REFERENCE_CultureElementQuestion);
_Ratings = new MultipleAssociation<CultureElement, CultureElementRating> (this, MULTIPLEREFERENCE_Ratings, CultureElementRating.SINGLEREFERENCE_CultureElement, CultureElementRating.REFERENCE_CultureElementRating);
_Narratives = new MultipleAssociation<CultureElement, CultureNarrative> (this, MULTIPLEREFERENCE_Narratives, CultureNarrative.SINGLEREFERENCE_CultureElement, CultureNarrative.REFERENCE_CultureNarrative);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_Questions = new MultipleAssociation<CultureElement, CultureElementQuestion> (this, MULTIPLEREFERENCE_Questions, CultureElementQuestion.SINGLEREFERENCE_CultureElement, CultureElementQuestion.REFERENCE_CultureElementQuestion);
_Ratings = new MultipleAssociation<CultureElement, CultureElementRating> (this, MULTIPLEREFERENCE_Ratings, CultureElementRating.SINGLEREFERENCE_CultureElement, CultureElementRating.REFERENCE_CultureElementRating);
_Narratives = new MultipleAssociation<CultureElement, CultureNarrative> (this, MULTIPLEREFERENCE_Narratives, CultureNarrative.SINGLEREFERENCE_CultureElement, CultureNarrative.REFERENCE_CultureNarrative);
return this;
}
/**
* Get the attribute Description
*/
public String getDescription ()
{
assertValid();
String valToReturn = _Description;
for (CultureElementBehaviourDecorator bhd : CultureElement_BehaviourDecorators)
{
valToReturn = bhd.getDescription ((CultureElement)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preDescriptionChange (String newDescription) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postDescriptionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Description ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Description. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDescription (String newDescription) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
try
{
for (CultureElementBehaviourDecorator bhd : CultureElement_BehaviourDecorators)
{
newDescription = bhd.setDescription ((CultureElement)this, newDescription);
oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
}
if (FIELD_Description_Validators.length > 0)
{
Object newDescriptionObj = HELPER_Description.toObject (newDescription);
if (newDescriptionObj != null)
{
int loopMax = FIELD_Description_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CultureElement.get (FIELD_Description);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Description_Validators[v].checkAttribute (this, FIELD_Description, metadata, newDescriptionObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Description () != FieldWriteability.FALSE, "Field Description is not writeable");
preDescriptionChange (newDescription);
markFieldChange (FIELD_Description);
_Description = newDescription;
postFieldChange (FIELD_Description);
postDescriptionChange ();
}
}
/**
* Get the attribute CultureClass
*/
public CultureClass getCultureClass ()
{
assertValid();
CultureClass valToReturn = _CultureClass;
for (CultureElementBehaviourDecorator bhd : CultureElement_BehaviourDecorators)
{
valToReturn = bhd.getCultureClass ((CultureElement)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 preCultureClassChange (CultureClass newCultureClass) 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 postCultureClassChange () throws FieldException
{
}
public FieldWriteability getWriteability_CultureClass ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute CultureClass. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setCultureClass (CultureClass newCultureClass) throws FieldException
{
boolean oldAndNewIdentical = HELPER_CultureClass.compare (_CultureClass, newCultureClass);
try
{
for (CultureElementBehaviourDecorator bhd : CultureElement_BehaviourDecorators)
{
newCultureClass = bhd.setCultureClass ((CultureElement)this, newCultureClass);
oldAndNewIdentical = HELPER_CultureClass.compare (_CultureClass, newCultureClass);
}
if (FIELD_CultureClass_Validators.length > 0)
{
Object newCultureClassObj = HELPER_CultureClass.toObject (newCultureClass);
if (newCultureClassObj != null)
{
int loopMax = FIELD_CultureClass_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CultureElement.get (FIELD_CultureClass);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_CultureClass_Validators[v].checkAttribute (this, FIELD_CultureClass, metadata, newCultureClassObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_CultureClass () != FieldWriteability.FALSE, "Field CultureClass is not writeable");
preCultureClassChange (newCultureClass);
markFieldChange (FIELD_CultureClass);
_CultureClass = newCultureClass;
postFieldChange (FIELD_CultureClass);
postCultureClassChange ();
}
}
/**
* 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("Questions");
result.add("Ratings");
result.add("Narratives");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return CultureElementQuestion.REFERENCE_CultureElementQuestion ;
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
return CultureElementRating.REFERENCE_CultureElementRating ;
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return CultureNarrative.REFERENCE_CultureNarrative ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return CultureElementQuestion.SINGLEREFERENCE_CultureElement ;
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
return CultureElementRating.SINGLEREFERENCE_CultureElement ;
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return CultureNarrative.SINGLEREFERENCE_CultureElement ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return this.getQuestionsCount();
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
return this.getRatingsCount();
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return this.getQuestionsAt(index);
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
return this.getRatingsAt(index);
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesAt(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_Questions.equals(attribName))
{
addToQuestions((CultureElementQuestion)newElement);
return;
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
addToRatings((CultureElementRating)newElement);
return;
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
addToNarratives((CultureNarrative)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_Questions.equals(attribName))
{
removeFromQuestions((CultureElementQuestion)oldElement);
return;
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
removeFromRatings((CultureElementRating)oldElement);
return;
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
removeFromNarratives((CultureNarrative)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
_Questions.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
_Ratings.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
_Narratives.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return _Questions.isLoaded ();
}
if (MULTIPLEREFERENCE_Ratings.equals(attribName))
{
return _Ratings.isLoaded ();
}
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return _Narratives.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_Questions ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getQuestionsCount () throws StorageException
{
assertValid();
return _Questions.getReferencedObjectsCount ();
}
public void addToQuestions (CultureElementQuestion newElement) throws StorageException
{
if (_Questions.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Questions () != FieldWriteability.FALSE, "MultiAssoc Questions is not writeable (add)");
_Questions.appendElement (newElement);
try
{
if (newElement.getCultureElement () != this)
{
newElement.setCultureElement ((CultureElement)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromQuestions (CultureElementQuestion elementToRemove) throws StorageException
{
if (_Questions.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Questions () != FieldWriteability.FALSE, "MultiAssoc Questions is not writeable (remove)");
_Questions.removeElement (elementToRemove);
try
{
if (elementToRemove.getCultureElement () != null)
{
elementToRemove.setCultureElement (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public CultureElementQuestion getQuestionsAt (int index) throws StorageException
{
return (CultureElementQuestion)(_Questions.getElementAt (index));
}
public SortedSet<CultureElementQuestion> getQuestionsSet () throws StorageException
{
return _Questions.getSet ();
}
public FieldWriteability getWriteability_Ratings ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getRatingsCount () throws StorageException
{
assertValid();
return _Ratings.getReferencedObjectsCount ();
}
public void addToRatings (CultureElementRating newElement) throws StorageException
{
if (_Ratings.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Ratings () != FieldWriteability.FALSE, "MultiAssoc Ratings is not writeable (add)");
_Ratings.appendElement (newElement);
try
{
if (newElement.getCultureElement () != this)
{
newElement.setCultureElement ((CultureElement)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromRatings (CultureElementRating elementToRemove) throws StorageException
{
if (_Ratings.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Ratings () != FieldWriteability.FALSE, "MultiAssoc Ratings is not writeable (remove)");
_Ratings.removeElement (elementToRemove);
try
{
if (elementToRemove.getCultureElement () != null)
{
elementToRemove.setCultureElement (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public CultureElementRating getRatingsAt (int index) throws StorageException
{
return (CultureElementRating)(_Ratings.getElementAt (index));
}
public SortedSet<CultureElementRating> getRatingsSet () throws StorageException
{
return _Ratings.getSet ();
}
public FieldWriteability getWriteability_Narratives ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getNarrativesCount () throws StorageException
{
assertValid();
return _Narratives.getReferencedObjectsCount ();
}
public void addToNarratives (CultureNarrative newElement) throws StorageException
{
if (_Narratives.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (add)");
_Narratives.appendElement (newElement);
try
{
if (newElement.getCultureElement () != this)
{
newElement.setCultureElement ((CultureElement)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromNarratives (CultureNarrative elementToRemove) throws StorageException
{
if (_Narratives.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (remove)");
_Narratives.removeElement (elementToRemove);
try
{
if (elementToRemove.getCultureElement () != null)
{
elementToRemove.setCultureElement (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public CultureNarrative getNarrativesAt (int index) throws StorageException
{
return (CultureNarrative)(_Narratives.getElementAt (index));
}
public SortedSet<CultureNarrative> getNarrativesSet () throws StorageException
{
return _Narratives.getSet ();
}
public void onDelete ()
{
try
{
for(CultureElementQuestion referenced : CollectionUtils.reverse(getQuestionsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CultureElement from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCultureElement(null);
}
for(CultureElementRating referenced : CollectionUtils.reverse(getRatingsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CultureElement from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCultureElement(null);
}
for(CultureNarrative referenced : CollectionUtils.reverse(getNarrativesSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CultureElement from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCultureElement(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public CultureElement newInstance ()
{
return new CultureElement ();
}
public CultureElement referenceInstance ()
{
return REFERENCE_CultureElement;
}
public CultureElement getInTransaction (ObjectTransaction t) throws StorageException
{
return getCultureElementByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_CultureElement;
}
public String getBaseSetName ()
{
return "rs_culture_element";
}
/**
* 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 rs_culture_elementPSet = allSets.getPersistentSet (myID, "rs_culture_element", myPSetStatus);
rs_culture_elementPSet.setAttrib (FIELD_ObjectID, myID);
rs_culture_elementPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
rs_culture_elementPSet.setAttrib (FIELD_CultureClass, HELPER_CultureClass.toObject (_CultureClass)); //
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet rs_culture_elementPSet = allSets.getPersistentSet (objectID, "rs_culture_element");
_Description = (String)(HELPER_Description.fromObject (_Description, rs_culture_elementPSet.getAttrib (FIELD_Description))); //
_CultureClass = (CultureClass)(HELPER_CultureClass.fromObject (_CultureClass, rs_culture_elementPSet.getAttrib (FIELD_CultureClass))); //
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof CultureElement)
{
CultureElement otherCultureElement = (CultureElement)other;
try
{
setDescription (otherCultureElement.getDescription ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setCultureClass (otherCultureElement.getCultureClass ());
}
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 BaseCultureElement)
{
BaseCultureElement sourceCultureElement = (BaseCultureElement)(source);
_Description = sourceCultureElement._Description;
_CultureClass = sourceCultureElement._CultureClass;
}
}
/**
* 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 BaseCultureElement)
{
BaseCultureElement sourceCultureElement = (BaseCultureElement)(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 BaseCultureElement)
{
BaseCultureElement sourceCultureElement = (BaseCultureElement)(source);
_Questions.copyFrom (sourceCultureElement._Questions, linkToGhosts);
_Ratings.copyFrom (sourceCultureElement._Ratings, linkToGhosts);
_Narratives.copyFrom (sourceCultureElement._Narratives, 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);
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_CultureClass = (CultureClass)(HELPER_CultureClass.readExternal (_CultureClass, vals.get(FIELD_CultureClass))); //
_Questions.readExternalData(vals.get(MULTIPLEREFERENCE_Questions));
_Ratings.readExternalData(vals.get(MULTIPLEREFERENCE_Ratings));
_Narratives.readExternalData(vals.get(MULTIPLEREFERENCE_Narratives));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (FIELD_CultureClass, HELPER_CultureClass.writeExternal (_CultureClass));
vals.put (MULTIPLEREFERENCE_Questions, _Questions.writeExternalData());
vals.put (MULTIPLEREFERENCE_Ratings, _Ratings.writeExternalData());
vals.put (MULTIPLEREFERENCE_Narratives, _Narratives.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseCultureElement)
{
BaseCultureElement otherCultureElement = (BaseCultureElement)(other);
if (!HELPER_Description.compare(this._Description, otherCultureElement._Description))
{
listener.notifyFieldChange(this, other, FIELD_Description, HELPER_Description.toObject(this._Description), HELPER_Description.toObject(otherCultureElement._Description));
}
if (!HELPER_CultureClass.compare(this._CultureClass, otherCultureElement._CultureClass))
{
listener.notifyFieldChange(this, other, FIELD_CultureClass, HELPER_CultureClass.toObject(this._CultureClass), HELPER_CultureClass.toObject(otherCultureElement._CultureClass));
}
// Compare single assocs
// Compare multiple assocs
_Questions.compare (otherCultureElement._Questions, listener);
_Ratings.compare (otherCultureElement._Ratings, listener);
_Narratives.compare (otherCultureElement._Narratives, 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_Description, HELPER_Description.toObject(getDescription()));
visitor.visitField(this, FIELD_CultureClass, HELPER_CultureClass.toObject(getCultureClass()));
visitor.visitAssociation (_Questions);
visitor.visitAssociation (_Ratings);
visitor.visitAssociation (_Narratives);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Questions))
{
visitor.visit (_Questions);
}
if (scope.includes (_Ratings))
{
visitor.visit (_Ratings);
}
if (scope.includes (_Narratives))
{
visitor.visit (_Narratives);
}
}
public static CultureElement createCultureElement (ObjectTransaction transaction) throws StorageException
{
CultureElement result = new CultureElement ();
result.initialiseNewObject (transaction);
return result;
}
public static CultureElement getCultureElementByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (CultureElement)(transaction.getObjectByID (REFERENCE_CultureElement, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return filter.matches (getDescription ());
}
else if (attribName.equals (FIELD_CultureClass))
{
return filter.matches (getCultureClass ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<CultureElement>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "rs_culture_element.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_element.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_element.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "rs_culture_element.culture_element_desc", "Description");
return this;
}
public SearchAll andCultureClass (QueryFilter<CultureClass> filter)
{
filter.addFilter (context, "rs_culture_element.culture_class_code", "CultureClass");
return this;
}
public CultureElement[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_CultureElement, SEARCH_All, criteria);
Set<CultureElement> typedResults = new LinkedHashSet <CultureElement> ();
for (BaseBusinessClass bbcResult : results)
{
CultureElement aResult = (CultureElement)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CultureElement[0]);
}
}
public static CultureElement[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description.toObject (getDescription ());
}
else if (attribName.equals (FIELD_CultureClass))
{
return HELPER_CultureClass.toObject (getCultureClass ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description;
}
else if (attribName.equals (FIELD_CultureClass))
{
return HELPER_CultureClass;
}
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_Description))
{
setDescription ((String)(HELPER_Description.fromObject (_Description, attribValue)));
}
else if (attribName.equals (FIELD_CultureClass))
{
setCultureClass ((CultureClass)(HELPER_CultureClass.fromObject (_CultureClass, 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_Description))
{
return getWriteability_Description ();
}
else if (fieldName.equals (FIELD_CultureClass))
{
return getWriteability_CultureClass ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Questions))
{
return getWriteability_Questions ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Ratings))
{
return getWriteability_Ratings ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Narratives))
{
return getWriteability_Narratives ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Description () != FieldWriteability.TRUE)
{
fields.add (FIELD_Description);
}
if (getWriteability_CultureClass () != FieldWriteability.TRUE)
{
fields.add (FIELD_CultureClass);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Description.getAttribObject (getClass (), _Description, false, FIELD_Description));
result.add(HELPER_CultureClass.getAttribObject (getClass (), _CultureClass, false, FIELD_CultureClass));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_CultureElement.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_CultureElement.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_CultureElement.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_CultureElement.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 CultureElementBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CultureElement>
{
/**
* Get the attribute Description
*/
public String getDescription (CultureElement obj, String original)
{
return original;
}
/**
* Change the value set for attribute Description.
* May modify the field beforehand
* Occurs before validation.
*/
public String setDescription (CultureElement obj, String newDescription) throws FieldException
{
return newDescription;
}
/**
* Get the attribute CultureClass
*/
public CultureClass getCultureClass (CultureElement obj, CultureClass original)
{
return original;
}
/**
* Change the value set for attribute CultureClass.
* May modify the field beforehand
* Occurs before validation.
*/
public CultureClass setCultureClass (CultureElement obj, CultureClass newCultureClass) throws FieldException
{
return newCultureClass;
}
}
public ORMPipeLine pipes()
{
return new CultureElementPipeLineFactory<CultureElement, CultureElement> ((CultureElement)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public CultureElementPipeLineFactory<CultureElement, CultureElement> pipelineCultureElement()
{
return (CultureElementPipeLineFactory<CultureElement, CultureElement>) pipes();
}
public static CultureElementPipeLineFactory<CultureElement, CultureElement> pipesCultureElement(Collection<CultureElement> items)
{
return REFERENCE_CultureElement.new CultureElementPipeLineFactory<CultureElement, CultureElement> (items);
}
public static CultureElementPipeLineFactory<CultureElement, CultureElement> pipesCultureElement(CultureElement[] _items)
{
return pipesCultureElement(Arrays.asList (_items));
}
public static CultureElementPipeLineFactory<CultureElement, CultureElement> pipesCultureElement()
{
return pipesCultureElement((Collection)null);
}
public class CultureElementPipeLineFactory<From extends BaseBusinessClass, Me extends CultureElement> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> CultureElementPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public CultureElementPipeLineFactory (From seed)
{
super(seed);
}
public CultureElementPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Questions"))
{
return toQuestions ();
}
if (name.equals ("Ratings"))
{
return toRatings ();
}
if (name.equals ("Narratives"))
{
return toNarratives ();
}
if (name.equals ("Description"))
{
return toDescription ();
}
if (name.equals ("CultureClass"))
{
return toCultureClass ();
}
return super.to(name);
}
public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); }
public PipeLine<From, CultureClass> toCultureClass () { return pipe(new ORMAttributePipe<Me, CultureClass>(FIELD_CultureClass)); }
public CultureElementQuestion.CultureElementQuestionPipeLineFactory<From, CultureElementQuestion> toQuestions () { return toQuestions(Filter.ALL); }
public CultureElementQuestion.CultureElementQuestionPipeLineFactory<From, CultureElementQuestion> toQuestions (Filter<CultureElementQuestion> filter)
{
return CultureElementQuestion.REFERENCE_CultureElementQuestion.new CultureElementQuestionPipeLineFactory<From, CultureElementQuestion> (this, new ORMMultiAssocPipe<Me, CultureElementQuestion>(MULTIPLEREFERENCE_Questions, filter));
}
public CultureElementRating.CultureElementRatingPipeLineFactory<From, CultureElementRating> toRatings () { return toRatings(Filter.ALL); }
public CultureElementRating.CultureElementRatingPipeLineFactory<From, CultureElementRating> toRatings (Filter<CultureElementRating> filter)
{
return CultureElementRating.REFERENCE_CultureElementRating.new CultureElementRatingPipeLineFactory<From, CultureElementRating> (this, new ORMMultiAssocPipe<Me, CultureElementRating>(MULTIPLEREFERENCE_Ratings, filter));
}
public CultureNarrative.CultureNarrativePipeLineFactory<From, CultureNarrative> toNarratives () { return toNarratives(Filter.ALL); }
public CultureNarrative.CultureNarrativePipeLineFactory<From, CultureNarrative> toNarratives (Filter<CultureNarrative> filter)
{
return CultureNarrative.REFERENCE_CultureNarrative.new CultureNarrativePipeLineFactory<From, CultureNarrative> (this, new ORMMultiAssocPipe<Me, CultureNarrative>(MULTIPLEREFERENCE_Narratives, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyCultureElement extends CultureElement
{
// Default constructor primarily to support Externalisable
public DummyCultureElement()
{
super();
}
public void assertValid ()
{
}
public int getQuestionsCount () throws StorageException
{
return 0;
}
public CultureElementQuestion getQuestionsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Questions");
}
public SortedSet getQuestionsSet () throws StorageException
{
return new TreeSet();
}
public int getRatingsCount () throws StorageException
{
return 0;
}
public CultureElementRating getRatingsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Ratings");
}
public SortedSet getRatingsSet () throws StorageException
{
return new TreeSet();
}
public int getNarrativesCount () throws StorageException
{
return 0;
}
public CultureNarrative getNarrativesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Narratives");
}
public SortedSet getNarrativesSet () throws StorageException
{
return new TreeSet();
}
}
/*
* 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;
public abstract class BaseCultureElementQuestion extends BaseBusinessClass
{
// Reference instance for the object
public static final CultureElementQuestion REFERENCE_CultureElementQuestion = new CultureElementQuestion ();
// Reference instance for the object
public static final CultureElementQuestion DUMMY_CultureElementQuestion = new DummyCultureElementQuestion ();
// Static constants corresponding to field names
public static final String FIELD_Description = "Description";
public static final String SINGLEREFERENCE_CultureElement = "CultureElement";
public static final String BACKREF_CultureElement = "";
public static final String MULTIPLEREFERENCE_Narratives = "Narratives";
public static final String BACKREF_Narratives = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<CultureElementQuestion> HELPER_Description = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _Description;
// Private attributes corresponding to single references
private SingleAssociation<CultureElementQuestion, CultureElement> _CultureElement;
// Private attributes corresponding to multiple references
private MultipleAssociation<CultureElementQuestion, CultureNarrative> _Narratives;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_CultureElementQuestion = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Description_Validators;
// Arrays of behaviour decorators
private static final CultureElementQuestionBehaviourDecorator[] CultureElementQuestion_BehaviourDecorators;
static
{
try
{
String tmp_Narratives = CultureNarrative.BACKREF_CultureElementQuestion;
String tmp_CultureElement = CultureElement.BACKREF_Questions;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Narratives();
setupAssocMetaData_CultureElement();
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_CultureElementQuestion.initialiseReference ();
DUMMY_CultureElementQuestion.initialiseReference ();
CultureElementQuestion_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CultureElementQuestion.class).toArray(new CultureElementQuestionBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Narratives()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "CultureElementQuestion");
metaInfo.put ("name", "Narratives");
metaInfo.put ("type", "CultureNarrative");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElementQuestion.Narratives:", metaInfo);
ATTRIBUTES_METADATA_CultureElementQuestion.put (MULTIPLEREFERENCE_Narratives, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_CultureElement()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Questions");
metaInfo.put ("dbcol", "culture_element_number");
metaInfo.put ("name", "CultureElement");
metaInfo.put ("type", "CultureElement");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElementQuestion.CultureElement:", metaInfo);
ATTRIBUTES_METADATA_CultureElementQuestion.put (SINGLEREFERENCE_CultureElement, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "quest");
metaInfo.put ("length", "200");
metaInfo.put ("name", "Description");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElementQuestion.Description:", metaInfo);
ATTRIBUTES_METADATA_CultureElementQuestion.put (FIELD_Description, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CultureElementQuestion.class, "Description", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CultureElementQuestion.Description:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseCultureElementQuestion ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return CultureElementQuestion_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Description = (String)(HELPER_Description.initialise (_Description));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_CultureElement = new SingleAssociation<CultureElementQuestion, CultureElement> (this, SINGLEREFERENCE_CultureElement, CultureElement.MULTIPLEREFERENCE_Questions, CultureElement.REFERENCE_CultureElement, "rs_culture_element_quest");
_Narratives = new MultipleAssociation<CultureElementQuestion, CultureNarrative> (this, MULTIPLEREFERENCE_Narratives, CultureNarrative.SINGLEREFERENCE_CultureElementQuestion, CultureNarrative.REFERENCE_CultureNarrative);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_CultureElement = new SingleAssociation<CultureElementQuestion, CultureElement> (this, SINGLEREFERENCE_CultureElement, CultureElement.MULTIPLEREFERENCE_Questions, CultureElement.REFERENCE_CultureElement, "rs_culture_element_quest");
_Narratives = new MultipleAssociation<CultureElementQuestion, CultureNarrative> (this, MULTIPLEREFERENCE_Narratives, CultureNarrative.SINGLEREFERENCE_CultureElementQuestion, CultureNarrative.REFERENCE_CultureNarrative);
return this;
}
/**
* Get the attribute Description
*/
public String getDescription ()
{
assertValid();
String valToReturn = _Description;
for (CultureElementQuestionBehaviourDecorator bhd : CultureElementQuestion_BehaviourDecorators)
{
valToReturn = bhd.getDescription ((CultureElementQuestion)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preDescriptionChange (String newDescription) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postDescriptionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Description ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Description. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDescription (String newDescription) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
try
{
for (CultureElementQuestionBehaviourDecorator bhd : CultureElementQuestion_BehaviourDecorators)
{
newDescription = bhd.setDescription ((CultureElementQuestion)this, newDescription);
oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
}
if (FIELD_Description_Validators.length > 0)
{
Object newDescriptionObj = HELPER_Description.toObject (newDescription);
if (newDescriptionObj != null)
{
int loopMax = FIELD_Description_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CultureElementQuestion.get (FIELD_Description);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Description_Validators[v].checkAttribute (this, FIELD_Description, metadata, newDescriptionObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Description () != FieldWriteability.FALSE, "Field Description is not writeable");
preDescriptionChange (newDescription);
markFieldChange (FIELD_Description);
_Description = newDescription;
postFieldChange (FIELD_Description);
postDescriptionChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("CultureElement");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CultureElement))
{
return _CultureElement.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_CultureElement))
{
return CultureElement.MULTIPLEREFERENCE_Questions ;
}
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_CultureElement))
{
return getCultureElement ();
}
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_CultureElement))
{
return getCultureElement (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_CultureElement))
{
return getCultureElementID ();
}
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_CultureElement))
{
setCultureElement ((CultureElement)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference CultureElement
*/
public CultureElement getCultureElement () throws StorageException
{
assertValid();
try
{
return (CultureElement)(_CultureElement.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CultureElementQuestion:", this.getObjectID (), ", was trying to get CultureElement:", getCultureElementID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _CultureElement.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CultureElement getCultureElement (Get getType) throws StorageException
{
assertValid();
return _CultureElement.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementID ()
{
assertValid();
if (_CultureElement == null)
{
return null;
}
else
{
return _CultureElement.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 preCultureElementChange (CultureElement newCultureElement) 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 postCultureElementChange () throws FieldException
{
}
public FieldWriteability getWriteability_CultureElement ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference CultureElement. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCultureElement (CultureElement newCultureElement) throws StorageException, FieldException
{
if (_CultureElement.wouldReferencedChange (newCultureElement))
{
assertValid();
Debug.assertion (getWriteability_CultureElement () != FieldWriteability.FALSE, "Assoc CultureElement is not writeable");
preCultureElementChange (newCultureElement);
CultureElement oldCultureElement = getCultureElement ();
if (oldCultureElement != null)
{
// This is to stop validation from triggering when we are removed
_CultureElement.set (null);
oldCultureElement.removeFromQuestions ((CultureElementQuestion)(this));
}
_CultureElement.set (newCultureElement);
if (newCultureElement != null)
{
newCultureElement.addToQuestions ((CultureElementQuestion)(this));
}
postCultureElementChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
result.add("Narratives");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return CultureNarrative.REFERENCE_CultureNarrative ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return CultureNarrative.SINGLEREFERENCE_CultureElementQuestion ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesAt(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_Narratives.equals(attribName))
{
addToNarratives((CultureNarrative)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_Narratives.equals(attribName))
{
removeFromNarratives((CultureNarrative)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
_Narratives.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return _Narratives.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_Narratives ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getNarrativesCount () throws StorageException
{
assertValid();
return _Narratives.getReferencedObjectsCount ();
}
public void addToNarratives (CultureNarrative newElement) throws StorageException
{
if (_Narratives.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (add)");
_Narratives.appendElement (newElement);
try
{
if (newElement.getCultureElementQuestion () != this)
{
newElement.setCultureElementQuestion ((CultureElementQuestion)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromNarratives (CultureNarrative elementToRemove) throws StorageException
{
if (_Narratives.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (remove)");
_Narratives.removeElement (elementToRemove);
try
{
if (elementToRemove.getCultureElementQuestion () != null)
{
elementToRemove.setCultureElementQuestion (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public CultureNarrative getNarrativesAt (int index) throws StorageException
{
return (CultureNarrative)(_Narratives.getElementAt (index));
}
public SortedSet<CultureNarrative> getNarrativesSet () throws StorageException
{
return _Narratives.getSet ();
}
public void onDelete ()
{
try
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_CultureElement.isLoaded () || getTransaction ().isObjectLoaded (_CultureElement.getReferencedType (), getCultureElementID ()))
{
CultureElement referenced = getCultureElement ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Questions from ", getObjectID (), " to ", referenced.getObjectID ());
_CultureElement.set (null);
referenced.removeFromQuestions ((CultureElementQuestion)this);
}
}
for(CultureNarrative referenced : CollectionUtils.reverse(getNarrativesSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CultureElementQuestion from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCultureElementQuestion(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public CultureElementQuestion newInstance ()
{
return new CultureElementQuestion ();
}
public CultureElementQuestion referenceInstance ()
{
return REFERENCE_CultureElementQuestion;
}
public CultureElementQuestion getInTransaction (ObjectTransaction t) throws StorageException
{
return getCultureElementQuestionByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_CultureElementQuestion;
}
public String getBaseSetName ()
{
return "rs_culture_element_quest";
}
/**
* 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 rs_culture_element_questPSet = allSets.getPersistentSet (myID, "rs_culture_element_quest", myPSetStatus);
rs_culture_element_questPSet.setAttrib (FIELD_ObjectID, myID);
rs_culture_element_questPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
_CultureElement.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet rs_culture_element_questPSet = allSets.getPersistentSet (objectID, "rs_culture_element_quest");
_Description = (String)(HELPER_Description.fromObject (_Description, rs_culture_element_questPSet.getAttrib (FIELD_Description))); //
_CultureElement.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof CultureElementQuestion)
{
CultureElementQuestion otherCultureElementQuestion = (CultureElementQuestion)other;
try
{
setDescription (otherCultureElementQuestion.getDescription ());
}
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 BaseCultureElementQuestion)
{
BaseCultureElementQuestion sourceCultureElementQuestion = (BaseCultureElementQuestion)(source);
_Description = sourceCultureElementQuestion._Description;
}
}
/**
* 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 BaseCultureElementQuestion)
{
BaseCultureElementQuestion sourceCultureElementQuestion = (BaseCultureElementQuestion)(source);
_CultureElement.copyFrom (sourceCultureElementQuestion._CultureElement, 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 BaseCultureElementQuestion)
{
BaseCultureElementQuestion sourceCultureElementQuestion = (BaseCultureElementQuestion)(source);
_Narratives.copyFrom (sourceCultureElementQuestion._Narratives, 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);
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_CultureElement.readExternalData(vals.get(SINGLEREFERENCE_CultureElement));
_Narratives.readExternalData(vals.get(MULTIPLEREFERENCE_Narratives));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (SINGLEREFERENCE_CultureElement, _CultureElement.writeExternalData());
vals.put (MULTIPLEREFERENCE_Narratives, _Narratives.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseCultureElementQuestion)
{
BaseCultureElementQuestion otherCultureElementQuestion = (BaseCultureElementQuestion)(other);
if (!HELPER_Description.compare(this._Description, otherCultureElementQuestion._Description))
{
listener.notifyFieldChange(this, other, FIELD_Description, HELPER_Description.toObject(this._Description), HELPER_Description.toObject(otherCultureElementQuestion._Description));
}
// Compare single assocs
_CultureElement.compare (otherCultureElementQuestion._CultureElement, listener);
// Compare multiple assocs
_Narratives.compare (otherCultureElementQuestion._Narratives, 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_Description, HELPER_Description.toObject(getDescription()));
visitor.visitAssociation (_CultureElement);
visitor.visitAssociation (_Narratives);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_CultureElement))
{
visitor.visit (_CultureElement);
}
if (scope.includes (_Narratives))
{
visitor.visit (_Narratives);
}
}
public static CultureElementQuestion createCultureElementQuestion (ObjectTransaction transaction) throws StorageException
{
CultureElementQuestion result = new CultureElementQuestion ();
result.initialiseNewObject (transaction);
return result;
}
public static CultureElementQuestion getCultureElementQuestionByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (CultureElementQuestion)(transaction.getObjectByID (REFERENCE_CultureElementQuestion, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return filter.matches (getDescription ());
}
else if (attribName.equals (SINGLEREFERENCE_CultureElement))
{
return filter.matches (getCultureElement ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<CultureElementQuestion>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "rs_culture_element_quest.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_element_quest.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_element_quest.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "rs_culture_element_quest.quest", "Description");
return this;
}
public SearchAll andCultureElement (QueryFilter<CultureElement> filter)
{
filter.addFilter (context, "rs_culture_element_quest.culture_element_number", "CultureElement");
return this;
}
public CultureElementQuestion[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_CultureElementQuestion, SEARCH_All, criteria);
Set<CultureElementQuestion> typedResults = new LinkedHashSet <CultureElementQuestion> ();
for (BaseBusinessClass bbcResult : results)
{
CultureElementQuestion aResult = (CultureElementQuestion)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CultureElementQuestion[0]);
}
}
public static CultureElementQuestion[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description.toObject (getDescription ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description;
}
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_Description))
{
setDescription ((String)(HELPER_Description.fromObject (_Description, 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_Description))
{
return getWriteability_Description ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Narratives))
{
return getWriteability_Narratives ();
}
else if (fieldName.equals (SINGLEREFERENCE_CultureElement))
{
return getWriteability_CultureElement ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Description () != FieldWriteability.TRUE)
{
fields.add (FIELD_Description);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Description.getAttribObject (getClass (), _Description, false, FIELD_Description));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_CultureElementQuestion.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_CultureElementQuestion.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_CultureElementQuestion.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_CultureElementQuestion.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 CultureElementQuestionBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CultureElementQuestion>
{
/**
* Get the attribute Description
*/
public String getDescription (CultureElementQuestion obj, String original)
{
return original;
}
/**
* Change the value set for attribute Description.
* May modify the field beforehand
* Occurs before validation.
*/
public String setDescription (CultureElementQuestion obj, String newDescription) throws FieldException
{
return newDescription;
}
}
public ORMPipeLine pipes()
{
return new CultureElementQuestionPipeLineFactory<CultureElementQuestion, CultureElementQuestion> ((CultureElementQuestion)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public CultureElementQuestionPipeLineFactory<CultureElementQuestion, CultureElementQuestion> pipelineCultureElementQuestion()
{
return (CultureElementQuestionPipeLineFactory<CultureElementQuestion, CultureElementQuestion>) pipes();
}
public static CultureElementQuestionPipeLineFactory<CultureElementQuestion, CultureElementQuestion> pipesCultureElementQuestion(Collection<CultureElementQuestion> items)
{
return REFERENCE_CultureElementQuestion.new CultureElementQuestionPipeLineFactory<CultureElementQuestion, CultureElementQuestion> (items);
}
public static CultureElementQuestionPipeLineFactory<CultureElementQuestion, CultureElementQuestion> pipesCultureElementQuestion(CultureElementQuestion[] _items)
{
return pipesCultureElementQuestion(Arrays.asList (_items));
}
public static CultureElementQuestionPipeLineFactory<CultureElementQuestion, CultureElementQuestion> pipesCultureElementQuestion()
{
return pipesCultureElementQuestion((Collection)null);
}
public class CultureElementQuestionPipeLineFactory<From extends BaseBusinessClass, Me extends CultureElementQuestion> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> CultureElementQuestionPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public CultureElementQuestionPipeLineFactory (From seed)
{
super(seed);
}
public CultureElementQuestionPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Narratives"))
{
return toNarratives ();
}
if (name.equals ("Description"))
{
return toDescription ();
}
if (name.equals ("CultureElement"))
{
return toCultureElement ();
}
return super.to(name);
}
public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); }
public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement () { return toCultureElement (Filter.ALL); }
public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement (Filter<CultureElement> filter)
{
return CultureElement.REFERENCE_CultureElement.new CultureElementPipeLineFactory<From, CultureElement> (this, new ORMSingleAssocPipe<Me, CultureElement>(SINGLEREFERENCE_CultureElement, filter));
}
public CultureNarrative.CultureNarrativePipeLineFactory<From, CultureNarrative> toNarratives () { return toNarratives(Filter.ALL); }
public CultureNarrative.CultureNarrativePipeLineFactory<From, CultureNarrative> toNarratives (Filter<CultureNarrative> filter)
{
return CultureNarrative.REFERENCE_CultureNarrative.new CultureNarrativePipeLineFactory<From, CultureNarrative> (this, new ORMMultiAssocPipe<Me, CultureNarrative>(MULTIPLEREFERENCE_Narratives, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyCultureElementQuestion extends CultureElementQuestion
{
// Default constructor primarily to support Externalisable
public DummyCultureElementQuestion()
{
super();
}
public void assertValid ()
{
}
public CultureElement getCultureElement () throws StorageException
{
return (CultureElement)(CultureElement.DUMMY_CultureElement);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementID ()
{
return CultureElement.DUMMY_CultureElement.getObjectID();
}
public int getNarrativesCount () throws StorageException
{
return 0;
}
public CultureNarrative getNarrativesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Narratives");
}
public SortedSet getNarrativesSet () throws StorageException
{
return new TreeSet();
}
}
/*
* 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;
public abstract class BaseCultureElementRating extends BaseBusinessClass
{
// Reference instance for the object
public static final CultureElementRating REFERENCE_CultureElementRating = new CultureElementRating ();
// Reference instance for the object
public static final CultureElementRating DUMMY_CultureElementRating = new DummyCultureElementRating ();
// Static constants corresponding to field names
public static final String FIELD_Description = "Description";
public static final String SINGLEREFERENCE_CultureElement = "CultureElement";
public static final String BACKREF_CultureElement = "";
public static final String MULTIPLEREFERENCE_Narratives = "Narratives";
public static final String BACKREF_Narratives = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<CultureElementRating> HELPER_Description = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _Description;
// Private attributes corresponding to single references
private SingleAssociation<CultureElementRating, CultureElement> _CultureElement;
// Private attributes corresponding to multiple references
private MultipleAssociation<CultureElementRating, CultureNarrative> _Narratives;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_CultureElementRating = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Description_Validators;
// Arrays of behaviour decorators
private static final CultureElementRatingBehaviourDecorator[] CultureElementRating_BehaviourDecorators;
static
{
try
{
String tmp_Narratives = CultureNarrative.BACKREF_CultureElementRating;
String tmp_CultureElement = CultureElement.BACKREF_Ratings;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Narratives();
setupAssocMetaData_CultureElement();
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_CultureElementRating.initialiseReference ();
DUMMY_CultureElementRating.initialiseReference ();
CultureElementRating_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CultureElementRating.class).toArray(new CultureElementRatingBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Narratives()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "CultureElementRating");
metaInfo.put ("name", "Narratives");
metaInfo.put ("type", "CultureNarrative");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElementRating.Narratives:", metaInfo);
ATTRIBUTES_METADATA_CultureElementRating.put (MULTIPLEREFERENCE_Narratives, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_CultureElement()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Ratings");
metaInfo.put ("dbcol", "culture_element_number");
metaInfo.put ("name", "CultureElement");
metaInfo.put ("type", "CultureElement");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElementRating.CultureElement:", metaInfo);
ATTRIBUTES_METADATA_CultureElementRating.put (SINGLEREFERENCE_CultureElement, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "culture_element_rating_desc");
metaInfo.put ("length", "200");
metaInfo.put ("name", "Description");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureElementRating.Description:", metaInfo);
ATTRIBUTES_METADATA_CultureElementRating.put (FIELD_Description, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CultureElementRating.class, "Description", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CultureElementRating.Description:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseCultureElementRating ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return CultureElementRating_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Description = (String)(HELPER_Description.initialise (_Description));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_CultureElement = new SingleAssociation<CultureElementRating, CultureElement> (this, SINGLEREFERENCE_CultureElement, CultureElement.MULTIPLEREFERENCE_Ratings, CultureElement.REFERENCE_CultureElement, "rs_culture_element_rating");
_Narratives = new MultipleAssociation<CultureElementRating, CultureNarrative> (this, MULTIPLEREFERENCE_Narratives, CultureNarrative.SINGLEREFERENCE_CultureElementRating, CultureNarrative.REFERENCE_CultureNarrative);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_CultureElement = new SingleAssociation<CultureElementRating, CultureElement> (this, SINGLEREFERENCE_CultureElement, CultureElement.MULTIPLEREFERENCE_Ratings, CultureElement.REFERENCE_CultureElement, "rs_culture_element_rating");
_Narratives = new MultipleAssociation<CultureElementRating, CultureNarrative> (this, MULTIPLEREFERENCE_Narratives, CultureNarrative.SINGLEREFERENCE_CultureElementRating, CultureNarrative.REFERENCE_CultureNarrative);
return this;
}
/**
* Get the attribute Description
*/
public String getDescription ()
{
assertValid();
String valToReturn = _Description;
for (CultureElementRatingBehaviourDecorator bhd : CultureElementRating_BehaviourDecorators)
{
valToReturn = bhd.getDescription ((CultureElementRating)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preDescriptionChange (String newDescription) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postDescriptionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Description ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Description. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDescription (String newDescription) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
try
{
for (CultureElementRatingBehaviourDecorator bhd : CultureElementRating_BehaviourDecorators)
{
newDescription = bhd.setDescription ((CultureElementRating)this, newDescription);
oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
}
if (FIELD_Description_Validators.length > 0)
{
Object newDescriptionObj = HELPER_Description.toObject (newDescription);
if (newDescriptionObj != null)
{
int loopMax = FIELD_Description_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CultureElementRating.get (FIELD_Description);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Description_Validators[v].checkAttribute (this, FIELD_Description, metadata, newDescriptionObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Description () != FieldWriteability.FALSE, "Field Description is not writeable");
preDescriptionChange (newDescription);
markFieldChange (FIELD_Description);
_Description = newDescription;
postFieldChange (FIELD_Description);
postDescriptionChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("CultureElement");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CultureElement))
{
return _CultureElement.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_CultureElement))
{
return CultureElement.MULTIPLEREFERENCE_Ratings ;
}
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_CultureElement))
{
return getCultureElement ();
}
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_CultureElement))
{
return getCultureElement (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_CultureElement))
{
return getCultureElementID ();
}
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_CultureElement))
{
setCultureElement ((CultureElement)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference CultureElement
*/
public CultureElement getCultureElement () throws StorageException
{
assertValid();
try
{
return (CultureElement)(_CultureElement.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CultureElementRating:", this.getObjectID (), ", was trying to get CultureElement:", getCultureElementID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _CultureElement.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CultureElement getCultureElement (Get getType) throws StorageException
{
assertValid();
return _CultureElement.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementID ()
{
assertValid();
if (_CultureElement == null)
{
return null;
}
else
{
return _CultureElement.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 preCultureElementChange (CultureElement newCultureElement) 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 postCultureElementChange () throws FieldException
{
}
public FieldWriteability getWriteability_CultureElement ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference CultureElement. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCultureElement (CultureElement newCultureElement) throws StorageException, FieldException
{
if (_CultureElement.wouldReferencedChange (newCultureElement))
{
assertValid();
Debug.assertion (getWriteability_CultureElement () != FieldWriteability.FALSE, "Assoc CultureElement is not writeable");
preCultureElementChange (newCultureElement);
CultureElement oldCultureElement = getCultureElement ();
if (oldCultureElement != null)
{
// This is to stop validation from triggering when we are removed
_CultureElement.set (null);
oldCultureElement.removeFromRatings ((CultureElementRating)(this));
}
_CultureElement.set (newCultureElement);
if (newCultureElement != null)
{
newCultureElement.addToRatings ((CultureElementRating)(this));
}
postCultureElementChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
result.add("Narratives");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return CultureNarrative.REFERENCE_CultureNarrative ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return CultureNarrative.SINGLEREFERENCE_CultureElementRating ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesAt(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_Narratives.equals(attribName))
{
addToNarratives((CultureNarrative)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_Narratives.equals(attribName))
{
removeFromNarratives((CultureNarrative)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
_Narratives.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return _Narratives.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_Narratives ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getNarrativesCount () throws StorageException
{
assertValid();
return _Narratives.getReferencedObjectsCount ();
}
public void addToNarratives (CultureNarrative newElement) throws StorageException
{
if (_Narratives.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (add)");
_Narratives.appendElement (newElement);
try
{
if (newElement.getCultureElementRating () != this)
{
newElement.setCultureElementRating ((CultureElementRating)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromNarratives (CultureNarrative elementToRemove) throws StorageException
{
if (_Narratives.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (remove)");
_Narratives.removeElement (elementToRemove);
try
{
if (elementToRemove.getCultureElementRating () != null)
{
elementToRemove.setCultureElementRating (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public CultureNarrative getNarrativesAt (int index) throws StorageException
{
return (CultureNarrative)(_Narratives.getElementAt (index));
}
public SortedSet<CultureNarrative> getNarrativesSet () throws StorageException
{
return _Narratives.getSet ();
}
public void onDelete ()
{
try
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_CultureElement.isLoaded () || getTransaction ().isObjectLoaded (_CultureElement.getReferencedType (), getCultureElementID ()))
{
CultureElement referenced = getCultureElement ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Ratings from ", getObjectID (), " to ", referenced.getObjectID ());
_CultureElement.set (null);
referenced.removeFromRatings ((CultureElementRating)this);
}
}
for(CultureNarrative referenced : CollectionUtils.reverse(getNarrativesSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CultureElementRating from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCultureElementRating(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public CultureElementRating newInstance ()
{
return new CultureElementRating ();
}
public CultureElementRating referenceInstance ()
{
return REFERENCE_CultureElementRating;
}
public CultureElementRating getInTransaction (ObjectTransaction t) throws StorageException
{
return getCultureElementRatingByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_CultureElementRating;
}
public String getBaseSetName ()
{
return "rs_culture_element_rating";
}
/**
* 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 rs_culture_element_ratingPSet = allSets.getPersistentSet (myID, "rs_culture_element_rating", myPSetStatus);
rs_culture_element_ratingPSet.setAttrib (FIELD_ObjectID, myID);
rs_culture_element_ratingPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
_CultureElement.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet rs_culture_element_ratingPSet = allSets.getPersistentSet (objectID, "rs_culture_element_rating");
_Description = (String)(HELPER_Description.fromObject (_Description, rs_culture_element_ratingPSet.getAttrib (FIELD_Description))); //
_CultureElement.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof CultureElementRating)
{
CultureElementRating otherCultureElementRating = (CultureElementRating)other;
try
{
setDescription (otherCultureElementRating.getDescription ());
}
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 BaseCultureElementRating)
{
BaseCultureElementRating sourceCultureElementRating = (BaseCultureElementRating)(source);
_Description = sourceCultureElementRating._Description;
}
}
/**
* 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 BaseCultureElementRating)
{
BaseCultureElementRating sourceCultureElementRating = (BaseCultureElementRating)(source);
_CultureElement.copyFrom (sourceCultureElementRating._CultureElement, 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 BaseCultureElementRating)
{
BaseCultureElementRating sourceCultureElementRating = (BaseCultureElementRating)(source);
_Narratives.copyFrom (sourceCultureElementRating._Narratives, 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);
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_CultureElement.readExternalData(vals.get(SINGLEREFERENCE_CultureElement));
_Narratives.readExternalData(vals.get(MULTIPLEREFERENCE_Narratives));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (SINGLEREFERENCE_CultureElement, _CultureElement.writeExternalData());
vals.put (MULTIPLEREFERENCE_Narratives, _Narratives.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseCultureElementRating)
{
BaseCultureElementRating otherCultureElementRating = (BaseCultureElementRating)(other);
if (!HELPER_Description.compare(this._Description, otherCultureElementRating._Description))
{
listener.notifyFieldChange(this, other, FIELD_Description, HELPER_Description.toObject(this._Description), HELPER_Description.toObject(otherCultureElementRating._Description));
}
// Compare single assocs
_CultureElement.compare (otherCultureElementRating._CultureElement, listener);
// Compare multiple assocs
_Narratives.compare (otherCultureElementRating._Narratives, 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_Description, HELPER_Description.toObject(getDescription()));
visitor.visitAssociation (_CultureElement);
visitor.visitAssociation (_Narratives);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_CultureElement))
{
visitor.visit (_CultureElement);
}
if (scope.includes (_Narratives))
{
visitor.visit (_Narratives);
}
}
public static CultureElementRating createCultureElementRating (ObjectTransaction transaction) throws StorageException
{
CultureElementRating result = new CultureElementRating ();
result.initialiseNewObject (transaction);
return result;
}
public static CultureElementRating getCultureElementRatingByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (CultureElementRating)(transaction.getObjectByID (REFERENCE_CultureElementRating, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return filter.matches (getDescription ());
}
else if (attribName.equals (SINGLEREFERENCE_CultureElement))
{
return filter.matches (getCultureElement ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<CultureElementRating>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "rs_culture_element_rating.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_element_rating.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_element_rating.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "rs_culture_element_rating.culture_element_rating_desc", "Description");
return this;
}
public SearchAll andCultureElement (QueryFilter<CultureElement> filter)
{
filter.addFilter (context, "rs_culture_element_rating.culture_element_number", "CultureElement");
return this;
}
public CultureElementRating[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_CultureElementRating, SEARCH_All, criteria);
Set<CultureElementRating> typedResults = new LinkedHashSet <CultureElementRating> ();
for (BaseBusinessClass bbcResult : results)
{
CultureElementRating aResult = (CultureElementRating)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CultureElementRating[0]);
}
}
public static CultureElementRating[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description.toObject (getDescription ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description;
}
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_Description))
{
setDescription ((String)(HELPER_Description.fromObject (_Description, 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_Description))
{
return getWriteability_Description ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Narratives))
{
return getWriteability_Narratives ();
}
else if (fieldName.equals (SINGLEREFERENCE_CultureElement))
{
return getWriteability_CultureElement ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Description () != FieldWriteability.TRUE)
{
fields.add (FIELD_Description);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Description.getAttribObject (getClass (), _Description, false, FIELD_Description));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_CultureElementRating.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_CultureElementRating.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_CultureElementRating.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_CultureElementRating.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 CultureElementRatingBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CultureElementRating>
{
/**
* Get the attribute Description
*/
public String getDescription (CultureElementRating obj, String original)
{
return original;
}
/**
* Change the value set for attribute Description.
* May modify the field beforehand
* Occurs before validation.
*/
public String setDescription (CultureElementRating obj, String newDescription) throws FieldException
{
return newDescription;
}
}
public ORMPipeLine pipes()
{
return new CultureElementRatingPipeLineFactory<CultureElementRating, CultureElementRating> ((CultureElementRating)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public CultureElementRatingPipeLineFactory<CultureElementRating, CultureElementRating> pipelineCultureElementRating()
{
return (CultureElementRatingPipeLineFactory<CultureElementRating, CultureElementRating>) pipes();
}
public static CultureElementRatingPipeLineFactory<CultureElementRating, CultureElementRating> pipesCultureElementRating(Collection<CultureElementRating> items)
{
return REFERENCE_CultureElementRating.new CultureElementRatingPipeLineFactory<CultureElementRating, CultureElementRating> (items);
}
public static CultureElementRatingPipeLineFactory<CultureElementRating, CultureElementRating> pipesCultureElementRating(CultureElementRating[] _items)
{
return pipesCultureElementRating(Arrays.asList (_items));
}
public static CultureElementRatingPipeLineFactory<CultureElementRating, CultureElementRating> pipesCultureElementRating()
{
return pipesCultureElementRating((Collection)null);
}
public class CultureElementRatingPipeLineFactory<From extends BaseBusinessClass, Me extends CultureElementRating> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> CultureElementRatingPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public CultureElementRatingPipeLineFactory (From seed)
{
super(seed);
}
public CultureElementRatingPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Narratives"))
{
return toNarratives ();
}
if (name.equals ("Description"))
{
return toDescription ();
}
if (name.equals ("CultureElement"))
{
return toCultureElement ();
}
return super.to(name);
}
public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); }
public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement () { return toCultureElement (Filter.ALL); }
public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement (Filter<CultureElement> filter)
{
return CultureElement.REFERENCE_CultureElement.new CultureElementPipeLineFactory<From, CultureElement> (this, new ORMSingleAssocPipe<Me, CultureElement>(SINGLEREFERENCE_CultureElement, filter));
}
public CultureNarrative.CultureNarrativePipeLineFactory<From, CultureNarrative> toNarratives () { return toNarratives(Filter.ALL); }
public CultureNarrative.CultureNarrativePipeLineFactory<From, CultureNarrative> toNarratives (Filter<CultureNarrative> filter)
{
return CultureNarrative.REFERENCE_CultureNarrative.new CultureNarrativePipeLineFactory<From, CultureNarrative> (this, new ORMMultiAssocPipe<Me, CultureNarrative>(MULTIPLEREFERENCE_Narratives, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyCultureElementRating extends CultureElementRating
{
// Default constructor primarily to support Externalisable
public DummyCultureElementRating()
{
super();
}
public void assertValid ()
{
}
public CultureElement getCultureElement () throws StorageException
{
return (CultureElement)(CultureElement.DUMMY_CultureElement);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementID ()
{
return CultureElement.DUMMY_CultureElement.getObjectID();
}
public int getNarrativesCount () throws StorageException
{
return 0;
}
public CultureNarrative getNarrativesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Narratives");
}
public SortedSet getNarrativesSet () throws StorageException
{
return new TreeSet();
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseCultureNarrative extends BaseBusinessClass
{
// Reference instance for the object
public static final CultureNarrative REFERENCE_CultureNarrative = new CultureNarrative ();
// Reference instance for the object
public static final CultureNarrative DUMMY_CultureNarrative = new DummyCultureNarrative ();
// Static constants corresponding to field names
public static final String FIELD_Notes = "Notes";
public static final String FIELD_ColorCode = "ColorCode";
public static final String SINGLEREFERENCE_CultureElement = "CultureElement";
public static final String BACKREF_CultureElement = "";
public static final String SINGLEREFERENCE_CultureElementQuestion = "CultureElementQuestion";
public static final String BACKREF_CultureElementQuestion = "";
public static final String SINGLEREFERENCE_CultureElementRating = "CultureElementRating";
public static final String BACKREF_CultureElementRating = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<CultureNarrative> HELPER_Notes = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<CultureNarrative, ColorCode> HELPER_ColorCode = new EnumeratedAttributeHelper<CultureNarrative, ColorCode> (ColorCode.FACTORY_ColorCode);
// Private attributes corresponding to business object data
private String _Notes;
private ColorCode _ColorCode;
// Private attributes corresponding to single references
private SingleAssociation<CultureNarrative, CultureElement> _CultureElement;
private SingleAssociation<CultureNarrative, CultureElementQuestion> _CultureElementQuestion;
private SingleAssociation<CultureNarrative, CultureElementRating> _CultureElementRating;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_CultureNarrative = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Notes_Validators;
private static final AttributeValidator[] FIELD_ColorCode_Validators;
// Arrays of behaviour decorators
private static final CultureNarrativeBehaviourDecorator[] CultureNarrative_BehaviourDecorators;
static
{
try
{
String tmp_CultureElement = CultureElement.BACKREF_Narratives;
String tmp_CultureElementQuestion = CultureElementQuestion.BACKREF_Narratives;
String tmp_CultureElementRating = CultureElementRating.BACKREF_Narratives;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_CultureElement();
setupAssocMetaData_CultureElementQuestion();
setupAssocMetaData_CultureElementRating();
FIELD_Notes_Validators = (AttributeValidator[])setupAttribMetaData_Notes(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ColorCode_Validators = (AttributeValidator[])setupAttribMetaData_ColorCode(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_CultureNarrative.initialiseReference ();
DUMMY_CultureNarrative.initialiseReference ();
CultureNarrative_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CultureNarrative.class).toArray(new CultureNarrativeBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_CultureElement()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Narratives");
metaInfo.put ("dbcol", "culture_element_number");
metaInfo.put ("name", "CultureElement");
metaInfo.put ("type", "CultureElement");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureNarrative.CultureElement:", metaInfo);
ATTRIBUTES_METADATA_CultureNarrative.put (SINGLEREFERENCE_CultureElement, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_CultureElementQuestion()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Narratives");
metaInfo.put ("dbcol", "culture_element_quest_id");
metaInfo.put ("name", "CultureElementQuestion");
metaInfo.put ("type", "CultureElementQuestion");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureNarrative.CultureElementQuestion:", metaInfo);
ATTRIBUTES_METADATA_CultureNarrative.put (SINGLEREFERENCE_CultureElementQuestion, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_CultureElementRating()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Narratives");
metaInfo.put ("dbcol", "culture_element_rating_id");
metaInfo.put ("name", "CultureElementRating");
metaInfo.put ("type", "CultureElementRating");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureNarrative.CultureElementRating:", metaInfo);
ATTRIBUTES_METADATA_CultureNarrative.put (SINGLEREFERENCE_CultureElementRating, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Notes(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "narrative_notes");
metaInfo.put ("name", "Notes");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureNarrative.Notes:", metaInfo);
ATTRIBUTES_METADATA_CultureNarrative.put (FIELD_Notes, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CultureNarrative.class, "Notes", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CultureNarrative.Notes:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ColorCode(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "color_code");
metaInfo.put ("name", "ColorCode");
metaInfo.put ("type", "ColorCode");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureNarrative.ColorCode:", metaInfo);
ATTRIBUTES_METADATA_CultureNarrative.put (FIELD_ColorCode, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(CultureNarrative.class, "ColorCode", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CultureNarrative.ColorCode:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseCultureNarrative ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return CultureNarrative_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Notes = (String)(HELPER_Notes.initialise (_Notes));
_ColorCode = (ColorCode)(HELPER_ColorCode.initialise (_ColorCode));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_CultureElement = new SingleAssociation<CultureNarrative, CultureElement> (this, SINGLEREFERENCE_CultureElement, CultureElement.MULTIPLEREFERENCE_Narratives, CultureElement.REFERENCE_CultureElement, "rs_culture_narrative");
_CultureElementQuestion = new SingleAssociation<CultureNarrative, CultureElementQuestion> (this, SINGLEREFERENCE_CultureElementQuestion, CultureElementQuestion.MULTIPLEREFERENCE_Narratives, CultureElementQuestion.REFERENCE_CultureElementQuestion, "rs_culture_narrative");
_CultureElementRating = new SingleAssociation<CultureNarrative, CultureElementRating> (this, SINGLEREFERENCE_CultureElementRating, CultureElementRating.MULTIPLEREFERENCE_Narratives, CultureElementRating.REFERENCE_CultureElementRating, "rs_culture_narrative");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_CultureElement = new SingleAssociation<CultureNarrative, CultureElement> (this, SINGLEREFERENCE_CultureElement, CultureElement.MULTIPLEREFERENCE_Narratives, CultureElement.REFERENCE_CultureElement, "rs_culture_narrative");
_CultureElementQuestion = new SingleAssociation<CultureNarrative, CultureElementQuestion> (this, SINGLEREFERENCE_CultureElementQuestion, CultureElementQuestion.MULTIPLEREFERENCE_Narratives, CultureElementQuestion.REFERENCE_CultureElementQuestion, "rs_culture_narrative");
_CultureElementRating = new SingleAssociation<CultureNarrative, CultureElementRating> (this, SINGLEREFERENCE_CultureElementRating, CultureElementRating.MULTIPLEREFERENCE_Narratives, CultureElementRating.REFERENCE_CultureElementRating, "rs_culture_narrative");
return this;
}
/**
* Get the attribute Notes
*/
public String getNotes ()
{
assertValid();
String valToReturn = _Notes;
for (CultureNarrativeBehaviourDecorator bhd : CultureNarrative_BehaviourDecorators)
{
valToReturn = bhd.getNotes ((CultureNarrative)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 preNotesChange (String newNotes) 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 postNotesChange () throws FieldException
{
}
public FieldWriteability getWriteability_Notes ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Notes. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setNotes (String newNotes) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Notes.compare (_Notes, newNotes);
try
{
for (CultureNarrativeBehaviourDecorator bhd : CultureNarrative_BehaviourDecorators)
{
newNotes = bhd.setNotes ((CultureNarrative)this, newNotes);
oldAndNewIdentical = HELPER_Notes.compare (_Notes, newNotes);
}
if (FIELD_Notes_Validators.length > 0)
{
Object newNotesObj = HELPER_Notes.toObject (newNotes);
if (newNotesObj != null)
{
int loopMax = FIELD_Notes_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CultureNarrative.get (FIELD_Notes);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Notes_Validators[v].checkAttribute (this, FIELD_Notes, metadata, newNotesObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Notes () != FieldWriteability.FALSE, "Field Notes is not writeable");
preNotesChange (newNotes);
markFieldChange (FIELD_Notes);
_Notes = newNotes;
postFieldChange (FIELD_Notes);
postNotesChange ();
}
}
/**
* Get the attribute ColorCode
*/
public ColorCode getColorCode ()
{
assertValid();
ColorCode valToReturn = _ColorCode;
for (CultureNarrativeBehaviourDecorator bhd : CultureNarrative_BehaviourDecorators)
{
valToReturn = bhd.getColorCode ((CultureNarrative)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 preColorCodeChange (ColorCode newColorCode) 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 postColorCodeChange () throws FieldException
{
}
public FieldWriteability getWriteability_ColorCode ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ColorCode. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setColorCode (ColorCode newColorCode) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ColorCode.compare (_ColorCode, newColorCode);
try
{
for (CultureNarrativeBehaviourDecorator bhd : CultureNarrative_BehaviourDecorators)
{
newColorCode = bhd.setColorCode ((CultureNarrative)this, newColorCode);
oldAndNewIdentical = HELPER_ColorCode.compare (_ColorCode, newColorCode);
}
if (FIELD_ColorCode_Validators.length > 0)
{
Object newColorCodeObj = HELPER_ColorCode.toObject (newColorCode);
if (newColorCodeObj != null)
{
int loopMax = FIELD_ColorCode_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_CultureNarrative.get (FIELD_ColorCode);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ColorCode_Validators[v].checkAttribute (this, FIELD_ColorCode, metadata, newColorCodeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ColorCode () != FieldWriteability.FALSE, "Field ColorCode is not writeable");
preColorCodeChange (newColorCode);
markFieldChange (FIELD_ColorCode);
_ColorCode = newColorCode;
postFieldChange (FIELD_ColorCode);
postColorCodeChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("CultureElement");
result.add("CultureElementQuestion");
result.add("CultureElementRating");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CultureElement))
{
return _CultureElement.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
return _CultureElementQuestion.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
{
return _CultureElementRating.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_CultureElement))
{
return CultureElement.MULTIPLEREFERENCE_Narratives ;
}else if (assocName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
return CultureElementQuestion.MULTIPLEREFERENCE_Narratives ;
}else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
{
return CultureElementRating.MULTIPLEREFERENCE_Narratives ;
}
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_CultureElement))
{
return getCultureElement ();
}else if (assocName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
return getCultureElementQuestion ();
}else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
{
return getCultureElementRating ();
}
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_CultureElement))
{
return getCultureElement (getType);
}else if (assocName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
return getCultureElementQuestion (getType);
}else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
{
return getCultureElementRating (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_CultureElement))
{
return getCultureElementID ();
}else if (assocName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
return getCultureElementQuestionID ();
}else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
{
return getCultureElementRatingID ();
}
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_CultureElement))
{
setCultureElement ((CultureElement)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
setCultureElementQuestion ((CultureElementQuestion)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
{
setCultureElementRating ((CultureElementRating)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference CultureElement
*/
public CultureElement getCultureElement () throws StorageException
{
assertValid();
try
{
return (CultureElement)(_CultureElement.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CultureNarrative:", this.getObjectID (), ", was trying to get CultureElement:", getCultureElementID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _CultureElement.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CultureElement getCultureElement (Get getType) throws StorageException
{
assertValid();
return _CultureElement.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementID ()
{
assertValid();
if (_CultureElement == null)
{
return null;
}
else
{
return _CultureElement.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 preCultureElementChange (CultureElement newCultureElement) 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 postCultureElementChange () throws FieldException
{
}
public FieldWriteability getWriteability_CultureElement ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference CultureElement. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCultureElement (CultureElement newCultureElement) throws StorageException, FieldException
{
if (_CultureElement.wouldReferencedChange (newCultureElement))
{
assertValid();
Debug.assertion (getWriteability_CultureElement () != FieldWriteability.FALSE, "Assoc CultureElement is not writeable");
preCultureElementChange (newCultureElement);
CultureElement oldCultureElement = getCultureElement ();
if (oldCultureElement != null)
{
// This is to stop validation from triggering when we are removed
_CultureElement.set (null);
oldCultureElement.removeFromNarratives ((CultureNarrative)(this));
}
_CultureElement.set (newCultureElement);
if (newCultureElement != null)
{
newCultureElement.addToNarratives ((CultureNarrative)(this));
}
postCultureElementChange ();
}
}
/**
* Get the reference CultureElementQuestion
*/
public CultureElementQuestion getCultureElementQuestion () throws StorageException
{
assertValid();
try
{
return (CultureElementQuestion)(_CultureElementQuestion.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CultureNarrative:", this.getObjectID (), ", was trying to get CultureElementQuestion:", getCultureElementQuestionID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _CultureElementQuestion.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CultureElementQuestion getCultureElementQuestion (Get getType) throws StorageException
{
assertValid();
return _CultureElementQuestion.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementQuestionID ()
{
assertValid();
if (_CultureElementQuestion == null)
{
return null;
}
else
{
return _CultureElementQuestion.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 preCultureElementQuestionChange (CultureElementQuestion newCultureElementQuestion) 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 postCultureElementQuestionChange () throws FieldException
{
}
public FieldWriteability getWriteability_CultureElementQuestion ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference CultureElementQuestion. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCultureElementQuestion (CultureElementQuestion newCultureElementQuestion) throws StorageException, FieldException
{
if (_CultureElementQuestion.wouldReferencedChange (newCultureElementQuestion))
{
assertValid();
Debug.assertion (getWriteability_CultureElementQuestion () != FieldWriteability.FALSE, "Assoc CultureElementQuestion is not writeable");
preCultureElementQuestionChange (newCultureElementQuestion);
CultureElementQuestion oldCultureElementQuestion = getCultureElementQuestion ();
if (oldCultureElementQuestion != null)
{
// This is to stop validation from triggering when we are removed
_CultureElementQuestion.set (null);
oldCultureElementQuestion.removeFromNarratives ((CultureNarrative)(this));
}
_CultureElementQuestion.set (newCultureElementQuestion);
if (newCultureElementQuestion != null)
{
newCultureElementQuestion.addToNarratives ((CultureNarrative)(this));
}
postCultureElementQuestionChange ();
}
}
/**
* Get the reference CultureElementRating
*/
public CultureElementRating getCultureElementRating () throws StorageException
{
assertValid();
try
{
return (CultureElementRating)(_CultureElementRating.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CultureNarrative:", this.getObjectID (), ", was trying to get CultureElementRating:", getCultureElementRatingID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _CultureElementRating.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CultureElementRating getCultureElementRating (Get getType) throws StorageException
{
assertValid();
return _CultureElementRating.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementRatingID ()
{
assertValid();
if (_CultureElementRating == null)
{
return null;
}
else
{
return _CultureElementRating.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 preCultureElementRatingChange (CultureElementRating newCultureElementRating) 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 postCultureElementRatingChange () throws FieldException
{
}
public FieldWriteability getWriteability_CultureElementRating ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference CultureElementRating. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCultureElementRating (CultureElementRating newCultureElementRating) throws StorageException, FieldException
{
if (_CultureElementRating.wouldReferencedChange (newCultureElementRating))
{
assertValid();
Debug.assertion (getWriteability_CultureElementRating () != FieldWriteability.FALSE, "Assoc CultureElementRating is not writeable");
preCultureElementRatingChange (newCultureElementRating);
CultureElementRating oldCultureElementRating = getCultureElementRating ();
if (oldCultureElementRating != null)
{
// This is to stop validation from triggering when we are removed
_CultureElementRating.set (null);
oldCultureElementRating.removeFromNarratives ((CultureNarrative)(this));
}
_CultureElementRating.set (newCultureElementRating);
if (newCultureElementRating != null)
{
newCultureElementRating.addToNarratives ((CultureNarrative)(this));
}
postCultureElementRatingChange ();
}
}
/**
* 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 (_CultureElement.isLoaded () || getTransaction ().isObjectLoaded (_CultureElement.getReferencedType (), getCultureElementID ()))
{
CultureElement referenced = getCultureElement ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Narratives from ", getObjectID (), " to ", referenced.getObjectID ());
_CultureElement.set (null);
referenced.removeFromNarratives ((CultureNarrative)this);
}
}
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_CultureElementQuestion.isLoaded () || getTransaction ().isObjectLoaded (_CultureElementQuestion.getReferencedType (), getCultureElementQuestionID ()))
{
CultureElementQuestion referenced = getCultureElementQuestion ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Narratives from ", getObjectID (), " to ", referenced.getObjectID ());
_CultureElementQuestion.set (null);
referenced.removeFromNarratives ((CultureNarrative)this);
}
}
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_CultureElementRating.isLoaded () || getTransaction ().isObjectLoaded (_CultureElementRating.getReferencedType (), getCultureElementRatingID ()))
{
CultureElementRating referenced = getCultureElementRating ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Narratives from ", getObjectID (), " to ", referenced.getObjectID ());
_CultureElementRating.set (null);
referenced.removeFromNarratives ((CultureNarrative)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public CultureNarrative newInstance ()
{
return new CultureNarrative ();
}
public CultureNarrative referenceInstance ()
{
return REFERENCE_CultureNarrative;
}
public CultureNarrative getInTransaction (ObjectTransaction t) throws StorageException
{
return getCultureNarrativeByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_CultureNarrative;
}
public String getBaseSetName ()
{
return "rs_culture_narrative";
}
/**
* 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 rs_culture_narrativePSet = allSets.getPersistentSet (myID, "rs_culture_narrative", myPSetStatus);
rs_culture_narrativePSet.setAttrib (FIELD_ObjectID, myID);
rs_culture_narrativePSet.setAttrib (FIELD_Notes, HELPER_Notes.toObject (_Notes)); //
rs_culture_narrativePSet.setAttrib (FIELD_ColorCode, HELPER_ColorCode.toObject (_ColorCode)); //
_CultureElement.getPersistentSets (allSets);
_CultureElementQuestion.getPersistentSets (allSets);
_CultureElementRating.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet rs_culture_narrativePSet = allSets.getPersistentSet (objectID, "rs_culture_narrative");
_Notes = (String)(HELPER_Notes.fromObject (_Notes, rs_culture_narrativePSet.getAttrib (FIELD_Notes))); //
_ColorCode = (ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, rs_culture_narrativePSet.getAttrib (FIELD_ColorCode))); //
_CultureElement.setFromPersistentSets (objectID, allSets);
_CultureElementQuestion.setFromPersistentSets (objectID, allSets);
_CultureElementRating.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof CultureNarrative)
{
CultureNarrative otherCultureNarrative = (CultureNarrative)other;
try
{
setNotes (otherCultureNarrative.getNotes ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setColorCode (otherCultureNarrative.getColorCode ());
}
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 BaseCultureNarrative)
{
BaseCultureNarrative sourceCultureNarrative = (BaseCultureNarrative)(source);
_Notes = sourceCultureNarrative._Notes;
_ColorCode = sourceCultureNarrative._ColorCode;
}
}
/**
* 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 BaseCultureNarrative)
{
BaseCultureNarrative sourceCultureNarrative = (BaseCultureNarrative)(source);
_CultureElement.copyFrom (sourceCultureNarrative._CultureElement, linkToGhosts);
_CultureElementQuestion.copyFrom (sourceCultureNarrative._CultureElementQuestion, linkToGhosts);
_CultureElementRating.copyFrom (sourceCultureNarrative._CultureElementRating, 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 BaseCultureNarrative)
{
BaseCultureNarrative sourceCultureNarrative = (BaseCultureNarrative)(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);
_Notes = (String)(HELPER_Notes.readExternal (_Notes, vals.get(FIELD_Notes))); //
_ColorCode = (ColorCode)(HELPER_ColorCode.readExternal (_ColorCode, vals.get(FIELD_ColorCode))); //
_CultureElement.readExternalData(vals.get(SINGLEREFERENCE_CultureElement));
_CultureElementQuestion.readExternalData(vals.get(SINGLEREFERENCE_CultureElementQuestion));
_CultureElementRating.readExternalData(vals.get(SINGLEREFERENCE_CultureElementRating));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Notes, HELPER_Notes.writeExternal (_Notes));
vals.put (FIELD_ColorCode, HELPER_ColorCode.writeExternal (_ColorCode));
vals.put (SINGLEREFERENCE_CultureElement, _CultureElement.writeExternalData());
vals.put (SINGLEREFERENCE_CultureElementQuestion, _CultureElementQuestion.writeExternalData());
vals.put (SINGLEREFERENCE_CultureElementRating, _CultureElementRating.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseCultureNarrative)
{
BaseCultureNarrative otherCultureNarrative = (BaseCultureNarrative)(other);
if (!HELPER_Notes.compare(this._Notes, otherCultureNarrative._Notes))
{
listener.notifyFieldChange(this, other, FIELD_Notes, HELPER_Notes.toObject(this._Notes), HELPER_Notes.toObject(otherCultureNarrative._Notes));
}
if (!HELPER_ColorCode.compare(this._ColorCode, otherCultureNarrative._ColorCode))
{
listener.notifyFieldChange(this, other, FIELD_ColorCode, HELPER_ColorCode.toObject(this._ColorCode), HELPER_ColorCode.toObject(otherCultureNarrative._ColorCode));
}
// Compare single assocs
_CultureElement.compare (otherCultureNarrative._CultureElement, listener);
_CultureElementQuestion.compare (otherCultureNarrative._CultureElementQuestion, listener);
_CultureElementRating.compare (otherCultureNarrative._CultureElementRating, 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_Notes, HELPER_Notes.toObject(getNotes()));
visitor.visitField(this, FIELD_ColorCode, HELPER_ColorCode.toObject(getColorCode()));
visitor.visitAssociation (_CultureElement);
visitor.visitAssociation (_CultureElementQuestion);
visitor.visitAssociation (_CultureElementRating);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_CultureElement))
{
visitor.visit (_CultureElement);
}
if (scope.includes (_CultureElementQuestion))
{
visitor.visit (_CultureElementQuestion);
}
if (scope.includes (_CultureElementRating))
{
visitor.visit (_CultureElementRating);
}
}
public static CultureNarrative createCultureNarrative (ObjectTransaction transaction) throws StorageException
{
CultureNarrative result = new CultureNarrative ();
result.initialiseNewObject (transaction);
return result;
}
public static CultureNarrative getCultureNarrativeByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (CultureNarrative)(transaction.getObjectByID (REFERENCE_CultureNarrative, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Notes))
{
return filter.matches (getNotes ());
}
else if (attribName.equals (FIELD_ColorCode))
{
return filter.matches (getColorCode ());
}
else if (attribName.equals (SINGLEREFERENCE_CultureElement))
{
return filter.matches (getCultureElement ());
}
else if (attribName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
return filter.matches (getCultureElementQuestion ());
}
else if (attribName.equals (SINGLEREFERENCE_CultureElementRating))
{
return filter.matches (getCultureElementRating ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<CultureNarrative>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "rs_culture_narrative.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_narrative.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_culture_narrative.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andNotes (QueryFilter<String> filter)
{
filter.addFilter (context, "rs_culture_narrative.narrative_notes", "Notes");
return this;
}
public SearchAll andColorCode (QueryFilter<ColorCode> filter)
{
filter.addFilter (context, "rs_culture_narrative.color_code", "ColorCode");
return this;
}
public SearchAll andCultureElement (QueryFilter<CultureElement> filter)
{
filter.addFilter (context, "rs_culture_narrative.culture_element_number", "CultureElement");
return this;
}
public SearchAll andCultureElementQuestion (QueryFilter<CultureElementQuestion> filter)
{
filter.addFilter (context, "rs_culture_narrative.culture_element_quest_id", "CultureElementQuestion");
return this;
}
public SearchAll andCultureElementRating (QueryFilter<CultureElementRating> filter)
{
filter.addFilter (context, "rs_culture_narrative.culture_element_rating_id", "CultureElementRating");
return this;
}
public CultureNarrative[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_CultureNarrative, SEARCH_All, criteria);
Set<CultureNarrative> typedResults = new LinkedHashSet <CultureNarrative> ();
for (BaseBusinessClass bbcResult : results)
{
CultureNarrative aResult = (CultureNarrative)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CultureNarrative[0]);
}
}
public static CultureNarrative[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Notes))
{
return HELPER_Notes.toObject (getNotes ());
}
else if (attribName.equals (FIELD_ColorCode))
{
return HELPER_ColorCode.toObject (getColorCode ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Notes))
{
return HELPER_Notes;
}
else if (attribName.equals (FIELD_ColorCode))
{
return HELPER_ColorCode;
}
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_Notes))
{
setNotes ((String)(HELPER_Notes.fromObject (_Notes, attribValue)));
}
else if (attribName.equals (FIELD_ColorCode))
{
setColorCode ((ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, 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_Notes))
{
return getWriteability_Notes ();
}
else if (fieldName.equals (FIELD_ColorCode))
{
return getWriteability_ColorCode ();
}
else if (fieldName.equals (SINGLEREFERENCE_CultureElement))
{
return getWriteability_CultureElement ();
}
else if (fieldName.equals (SINGLEREFERENCE_CultureElementQuestion))
{
return getWriteability_CultureElementQuestion ();
}
else if (fieldName.equals (SINGLEREFERENCE_CultureElementRating))
{
return getWriteability_CultureElementRating ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Notes () != FieldWriteability.TRUE)
{
fields.add (FIELD_Notes);
}
if (getWriteability_ColorCode () != FieldWriteability.TRUE)
{
fields.add (FIELD_ColorCode);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Notes.getAttribObject (getClass (), _Notes, false, FIELD_Notes));
result.add(HELPER_ColorCode.getAttribObject (getClass (), _ColorCode, false, FIELD_ColorCode));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_CultureNarrative.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_CultureNarrative.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_CultureNarrative.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_CultureNarrative.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 CultureNarrativeBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CultureNarrative>
{
/**
* Get the attribute Notes
*/
public String getNotes (CultureNarrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute Notes.
* May modify the field beforehand
* Occurs before validation.
*/
public String setNotes (CultureNarrative obj, String newNotes) throws FieldException
{
return newNotes;
}
/**
* Get the attribute ColorCode
*/
public ColorCode getColorCode (CultureNarrative obj, ColorCode original)
{
return original;
}
/**
* Change the value set for attribute ColorCode.
* May modify the field beforehand
* Occurs before validation.
*/
public ColorCode setColorCode (CultureNarrative obj, ColorCode newColorCode) throws FieldException
{
return newColorCode;
}
}
public ORMPipeLine pipes()
{
return new CultureNarrativePipeLineFactory<CultureNarrative, CultureNarrative> ((CultureNarrative)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public CultureNarrativePipeLineFactory<CultureNarrative, CultureNarrative> pipelineCultureNarrative()
{
return (CultureNarrativePipeLineFactory<CultureNarrative, CultureNarrative>) pipes();
}
public static CultureNarrativePipeLineFactory<CultureNarrative, CultureNarrative> pipesCultureNarrative(Collection<CultureNarrative> items)
{
return REFERENCE_CultureNarrative.new CultureNarrativePipeLineFactory<CultureNarrative, CultureNarrative> (items);
}
public static CultureNarrativePipeLineFactory<CultureNarrative, CultureNarrative> pipesCultureNarrative(CultureNarrative[] _items)
{
return pipesCultureNarrative(Arrays.asList (_items));
}
public static CultureNarrativePipeLineFactory<CultureNarrative, CultureNarrative> pipesCultureNarrative()
{
return pipesCultureNarrative((Collection)null);
}
public class CultureNarrativePipeLineFactory<From extends BaseBusinessClass, Me extends CultureNarrative> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> CultureNarrativePipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public CultureNarrativePipeLineFactory (From seed)
{
super(seed);
}
public CultureNarrativePipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Notes"))
{
return toNotes ();
}
if (name.equals ("ColorCode"))
{
return toColorCode ();
}
if (name.equals ("CultureElement"))
{
return toCultureElement ();
}
if (name.equals ("CultureElementQuestion"))
{
return toCultureElementQuestion ();
}
if (name.equals ("CultureElementRating"))
{
return toCultureElementRating ();
}
return super.to(name);
}
public PipeLine<From, String> toNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Notes)); }
public PipeLine<From, ColorCode> toColorCode () { return pipe(new ORMAttributePipe<Me, ColorCode>(FIELD_ColorCode)); }
public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement () { return toCultureElement (Filter.ALL); }
public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement (Filter<CultureElement> filter)
{
return CultureElement.REFERENCE_CultureElement.new CultureElementPipeLineFactory<From, CultureElement> (this, new ORMSingleAssocPipe<Me, CultureElement>(SINGLEREFERENCE_CultureElement, filter));
}
public CultureElementQuestion.CultureElementQuestionPipeLineFactory<From, CultureElementQuestion> toCultureElementQuestion () { return toCultureElementQuestion (Filter.ALL); }
public CultureElementQuestion.CultureElementQuestionPipeLineFactory<From, CultureElementQuestion> toCultureElementQuestion (Filter<CultureElementQuestion> filter)
{
return CultureElementQuestion.REFERENCE_CultureElementQuestion.new CultureElementQuestionPipeLineFactory<From, CultureElementQuestion> (this, new ORMSingleAssocPipe<Me, CultureElementQuestion>(SINGLEREFERENCE_CultureElementQuestion, filter));
}
public CultureElementRating.CultureElementRatingPipeLineFactory<From, CultureElementRating> toCultureElementRating () { return toCultureElementRating (Filter.ALL); }
public CultureElementRating.CultureElementRatingPipeLineFactory<From, CultureElementRating> toCultureElementRating (Filter<CultureElementRating> filter)
{
return CultureElementRating.REFERENCE_CultureElementRating.new CultureElementRatingPipeLineFactory<From, CultureElementRating> (this, new ORMSingleAssocPipe<Me, CultureElementRating>(SINGLEREFERENCE_CultureElementRating, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyCultureNarrative extends CultureNarrative
{
// Default constructor primarily to support Externalisable
public DummyCultureNarrative()
{
super();
}
public void assertValid ()
{
}
public CultureElement getCultureElement () throws StorageException
{
return (CultureElement)(CultureElement.DUMMY_CultureElement);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementID ()
{
return CultureElement.DUMMY_CultureElement.getObjectID();
}
public CultureElementQuestion getCultureElementQuestion () throws StorageException
{
return (CultureElementQuestion)(CultureElementQuestion.DUMMY_CultureElementQuestion);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementQuestionID ()
{
return CultureElementQuestion.DUMMY_CultureElementQuestion.getObjectID();
}
public CultureElementRating getCultureElementRating () throws StorageException
{
return (CultureElementRating)(CultureElementRating.DUMMY_CultureElementRating);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCultureElementRatingID ()
{
return CultureElementRating.DUMMY_CultureElementRating.getObjectID();
}
}
package performa.orm;
public class CultureElement extends BaseCultureElement
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public CultureElement ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public String getObjectIDSpace()
{
return "CultureElement";
}
}
\ 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="CultureElement" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<MULTIPLEREFERENCE name="Questions" type="CultureElementQuestion" backreferenceName="CultureElement" />
<MULTIPLEREFERENCE name="Ratings" type="CultureElementRating" backreferenceName="CultureElement" />
<MULTIPLEREFERENCE name="Narratives" type="CultureNarrative" backreferenceName="CultureElement" />
<TABLE name="rs_culture_element" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="culture_element_desc" length="200"/>
<ATTRIB name="CultureClass" type="CultureClass" dbcol="culture_class_code" attribHelper="EnumeratedAttributeHelper" />
</TABLE>
<SEARCH type="All" paramFilter="rs_culture_element.object_id is not null" orderBy="rs_culture_element.object_id" />
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import performa.orm.types.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class CultureElementPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea CultureElementPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CultureElement");
// Private attributes corresponding to business object data
private String dummyDescription;
private CultureClass dummyCultureClass;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_CultureClass = new EnumeratedAttributeHelper (CultureClass.FACTORY_CultureClass);
public CultureElementPersistenceMgr ()
{
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
dummyCultureClass = (CultureClass)(HELPER_CultureClass.initialise (dummyCultureClass));
}
private String SELECT_COLUMNS = "{PREFIX}rs_culture_element.object_id as id, {PREFIX}rs_culture_element.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_culture_element.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_culture_element.culture_element_desc, {PREFIX}rs_culture_element.culture_class_code, 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, CultureElement.REFERENCE_CultureElement);
if (objectToReturn instanceof CultureElement)
{
LogMgr.log (CultureElementPersistence, 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 CultureElement");
}
}
PersistentSet rs_culture_elementPSet = allPSets.getPersistentSet(id, "rs_culture_element", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !rs_culture_elementPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!rs_culture_elementPSet.containsAttrib(CultureElement.FIELD_Description)||
!rs_culture_elementPSet.containsAttrib(CultureElement.FIELD_CultureClass))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (CultureElementPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
CultureElement result = new CultureElement ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element " +
"WHERE " + SELECT_JOINS + "{PREFIX}rs_culture_element.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 rs_culture_elementPSet = allPSets.getPersistentSet(objectID, "rs_culture_element");
if (rs_culture_elementPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_elementPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}rs_culture_element " +
"SET culture_element_desc = ?, culture_class_code = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE rs_culture_element.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_culture_elementPSet.getAttrib (CultureElement.FIELD_Description))).listEntry (HELPER_CultureClass.getForSQL(dummyCultureClass, rs_culture_elementPSet.getAttrib (CultureElement.FIELD_CultureClass))).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}rs_culture_element 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[] { "rs_culture_element", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (CultureElementPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "rs_culture_element");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:rs_culture_element for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CultureElementPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_elementPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (CultureElementPersistence, 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 rs_culture_elementPSet = allPSets.getPersistentSet(objectID, "rs_culture_element");
LogMgr.log (CultureElementPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (rs_culture_elementPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_elementPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}rs_culture_element " +
"WHERE rs_culture_element.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}rs_culture_element WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "rs_culture_element");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:rs_culture_element for row:" + objectID;
LogMgr.log (CultureElementPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_elementPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, CultureElement> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (CultureElement.REFERENCE_CultureElement.getObjectIDSpace (), r.getLong ("id"));
CultureElement 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, CultureElement.REFERENCE_CultureElement);
if (cachedElement instanceof CultureElement)
{
LogMgr.log (CultureElementPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (CultureElement)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a CultureElement");
}
}
else
{
PersistentSet rs_culture_elementPSet = allPSets.getPersistentSet(objectID, "rs_culture_element", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new CultureElement ();
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 (CultureElementPersistence, 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}rs_culture_element " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (CultureElement.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY rs_culture_element.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: rs_culture_element.object_id is not null
String preFilter = "(rs_culture_element.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet rs_culture_elementPSet = allPSets.getPersistentSet(objectID, "rs_culture_element", PersistentSetStatus.FETCHED);
// Object Modified
rs_culture_elementPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
rs_culture_elementPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
rs_culture_elementPSet.setAttrib(CultureElement.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "culture_element_desc"));
rs_culture_elementPSet.setAttrib(CultureElement.FIELD_CultureClass, HELPER_CultureClass.getFromRS(dummyCultureClass, r, "culture_class_code"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet rs_culture_elementPSet = allPSets.getPersistentSet(objectID, "rs_culture_element");
if (rs_culture_elementPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_elementPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}rs_culture_element " +
" (culture_element_desc, culture_class_code, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_culture_elementPSet.getAttrib (CultureElement.FIELD_Description))).listEntry (HELPER_CultureClass.getForSQL(dummyCultureClass, rs_culture_elementPSet.getAttrib (CultureElement.FIELD_CultureClass))) .listEntry (objectID.longID ()).toList().toArray());
rs_culture_elementPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm;
public class CultureElementQuestion extends BaseCultureElementQuestion
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public CultureElementQuestion ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public String getObjectIDSpace()
{
return "CultureElementQuestion";
}
}
\ 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="CultureElementQuestion" package="performa.orm">
<MULTIPLEREFERENCE name="Narratives" type="CultureNarrative" backreferenceName="CultureElementQuestion" />
<TABLE name="rs_culture_element_quest" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="quest" length="200"/>
<SINGLEREFERENCE name="CultureElement" type="CultureElement" dbcol="culture_element_number" backreferenceName="Questions"/>
</TABLE>
<SEARCH type="All" paramFilter="rs_culture_element_quest.object_id is not null" orderBy="rs_culture_element_quest.object_id" />
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class CultureElementQuestionPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea CultureElementQuestionPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CultureElementQuestion");
// Private attributes corresponding to business object data
private String dummyDescription;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
public CultureElementQuestionPersistenceMgr ()
{
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
}
private String SELECT_COLUMNS = "{PREFIX}rs_culture_element_quest.object_id as id, {PREFIX}rs_culture_element_quest.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_culture_element_quest.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_culture_element_quest.quest, {PREFIX}rs_culture_element_quest.culture_element_number, 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, CultureElementQuestion.REFERENCE_CultureElementQuestion);
if (objectToReturn instanceof CultureElementQuestion)
{
LogMgr.log (CultureElementQuestionPersistence, 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 CultureElementQuestion");
}
}
PersistentSet rs_culture_element_questPSet = allPSets.getPersistentSet(id, "rs_culture_element_quest", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !rs_culture_element_questPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!rs_culture_element_questPSet.containsAttrib(CultureElementQuestion.FIELD_Description)||
!rs_culture_element_questPSet.containsAttrib(CultureElementQuestion.SINGLEREFERENCE_CultureElement))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (CultureElementQuestionPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
CultureElementQuestion result = new CultureElementQuestion ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element_quest " +
"WHERE " + SELECT_JOINS + "{PREFIX}rs_culture_element_quest.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 (CultureElementQuestion.SINGLEREFERENCE_CultureElement))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element_quest " +
"WHERE " + SELECT_JOINS + "culture_element_number = ?";
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 rs_culture_element_questPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_quest");
if (rs_culture_element_questPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_element_questPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}rs_culture_element_quest " +
"SET quest = ?, culture_element_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE rs_culture_element_quest.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_culture_element_questPSet.getAttrib (CultureElementQuestion.FIELD_Description))).listEntry (SQLManager.CheckNull((Long)(rs_culture_element_questPSet.getAttrib (CultureElementQuestion.SINGLEREFERENCE_CultureElement)))).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}rs_culture_element_quest 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[] { "rs_culture_element_quest", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (CultureElementQuestionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "rs_culture_element_quest");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:rs_culture_element_quest for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CultureElementQuestionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_element_questPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (CultureElementQuestionPersistence, 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 rs_culture_element_questPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_quest");
LogMgr.log (CultureElementQuestionPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (rs_culture_element_questPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_element_questPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}rs_culture_element_quest " +
"WHERE rs_culture_element_quest.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}rs_culture_element_quest WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "rs_culture_element_quest");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:rs_culture_element_quest for row:" + objectID;
LogMgr.log (CultureElementQuestionPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_element_questPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, CultureElementQuestion> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (CultureElementQuestion.REFERENCE_CultureElementQuestion.getObjectIDSpace (), r.getLong ("id"));
CultureElementQuestion 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, CultureElementQuestion.REFERENCE_CultureElementQuestion);
if (cachedElement instanceof CultureElementQuestion)
{
LogMgr.log (CultureElementQuestionPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (CultureElementQuestion)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a CultureElementQuestion");
}
}
else
{
PersistentSet rs_culture_element_questPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_quest", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new CultureElementQuestion ();
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 (CultureElementQuestionPersistence, 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}rs_culture_element_quest " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (CultureElementQuestion.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY rs_culture_element_quest.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: rs_culture_element_quest.object_id is not null
String preFilter = "(rs_culture_element_quest.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element_quest " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet rs_culture_element_questPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_quest", PersistentSetStatus.FETCHED);
// Object Modified
rs_culture_element_questPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
rs_culture_element_questPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
rs_culture_element_questPSet.setAttrib(CultureElementQuestion.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "quest"));
rs_culture_element_questPSet.setAttrib(CultureElementQuestion.SINGLEREFERENCE_CultureElement, r.getObject ("culture_element_number"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet rs_culture_element_questPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_quest");
if (rs_culture_element_questPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_element_questPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}rs_culture_element_quest " +
" (quest, culture_element_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_culture_element_questPSet.getAttrib (CultureElementQuestion.FIELD_Description))) .listEntry (SQLManager.CheckNull((Long)(rs_culture_element_questPSet.getAttrib (CultureElementQuestion.SINGLEREFERENCE_CultureElement)))) .listEntry (objectID.longID ()).toList().toArray());
rs_culture_element_questPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm;
public class CultureElementRating extends BaseCultureElementRating
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public CultureElementRating ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public String getObjectIDSpace()
{
return "CultureElementRating";
}
}
\ 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="CultureElementRating" package="performa.orm">
<MULTIPLEREFERENCE name="Narratives" type="CultureNarrative" backreferenceName="CultureElementRating" />
<TABLE name="rs_culture_element_rating" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="culture_element_rating_desc" length="200"/>
<SINGLEREFERENCE name="CultureElement" type="CultureElement" dbcol="culture_element_number" backreferenceName="Ratings"/>
</TABLE>
<SEARCH type="All" paramFilter="rs_culture_element_rating.object_id is not null" orderBy="rs_culture_element_rating.object_id" />
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class CultureElementRatingPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea CultureElementRatingPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CultureElementRating");
// Private attributes corresponding to business object data
private String dummyDescription;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
public CultureElementRatingPersistenceMgr ()
{
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
}
private String SELECT_COLUMNS = "{PREFIX}rs_culture_element_rating.object_id as id, {PREFIX}rs_culture_element_rating.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_culture_element_rating.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_culture_element_rating.culture_element_rating_desc, {PREFIX}rs_culture_element_rating.culture_element_number, 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, CultureElementRating.REFERENCE_CultureElementRating);
if (objectToReturn instanceof CultureElementRating)
{
LogMgr.log (CultureElementRatingPersistence, 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 CultureElementRating");
}
}
PersistentSet rs_culture_element_ratingPSet = allPSets.getPersistentSet(id, "rs_culture_element_rating", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !rs_culture_element_ratingPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!rs_culture_element_ratingPSet.containsAttrib(CultureElementRating.FIELD_Description)||
!rs_culture_element_ratingPSet.containsAttrib(CultureElementRating.SINGLEREFERENCE_CultureElement))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (CultureElementRatingPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
CultureElementRating result = new CultureElementRating ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element_rating " +
"WHERE " + SELECT_JOINS + "{PREFIX}rs_culture_element_rating.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 (CultureElementRating.SINGLEREFERENCE_CultureElement))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element_rating " +
"WHERE " + SELECT_JOINS + "culture_element_number = ?";
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 rs_culture_element_ratingPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_rating");
if (rs_culture_element_ratingPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_element_ratingPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}rs_culture_element_rating " +
"SET culture_element_rating_desc = ?, culture_element_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE rs_culture_element_rating.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_culture_element_ratingPSet.getAttrib (CultureElementRating.FIELD_Description))).listEntry (SQLManager.CheckNull((Long)(rs_culture_element_ratingPSet.getAttrib (CultureElementRating.SINGLEREFERENCE_CultureElement)))).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}rs_culture_element_rating 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[] { "rs_culture_element_rating", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (CultureElementRatingPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "rs_culture_element_rating");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:rs_culture_element_rating for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CultureElementRatingPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_element_ratingPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (CultureElementRatingPersistence, 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 rs_culture_element_ratingPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_rating");
LogMgr.log (CultureElementRatingPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (rs_culture_element_ratingPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_element_ratingPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}rs_culture_element_rating " +
"WHERE rs_culture_element_rating.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}rs_culture_element_rating WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "rs_culture_element_rating");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:rs_culture_element_rating for row:" + objectID;
LogMgr.log (CultureElementRatingPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_element_ratingPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, CultureElementRating> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (CultureElementRating.REFERENCE_CultureElementRating.getObjectIDSpace (), r.getLong ("id"));
CultureElementRating 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, CultureElementRating.REFERENCE_CultureElementRating);
if (cachedElement instanceof CultureElementRating)
{
LogMgr.log (CultureElementRatingPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (CultureElementRating)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a CultureElementRating");
}
}
else
{
PersistentSet rs_culture_element_ratingPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_rating", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new CultureElementRating ();
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 (CultureElementRatingPersistence, 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}rs_culture_element_rating " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (CultureElementRating.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY rs_culture_element_rating.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: rs_culture_element_rating.object_id is not null
String preFilter = "(rs_culture_element_rating.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_element_rating " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet rs_culture_element_ratingPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_rating", PersistentSetStatus.FETCHED);
// Object Modified
rs_culture_element_ratingPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
rs_culture_element_ratingPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
rs_culture_element_ratingPSet.setAttrib(CultureElementRating.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "culture_element_rating_desc"));
rs_culture_element_ratingPSet.setAttrib(CultureElementRating.SINGLEREFERENCE_CultureElement, r.getObject ("culture_element_number"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet rs_culture_element_ratingPSet = allPSets.getPersistentSet(objectID, "rs_culture_element_rating");
if (rs_culture_element_ratingPSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_element_ratingPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}rs_culture_element_rating " +
" (culture_element_rating_desc, culture_element_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_culture_element_ratingPSet.getAttrib (CultureElementRating.FIELD_Description))) .listEntry (SQLManager.CheckNull((Long)(rs_culture_element_ratingPSet.getAttrib (CultureElementRating.SINGLEREFERENCE_CultureElement)))) .listEntry (objectID.longID ()).toList().toArray());
rs_culture_element_ratingPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm;
public class CultureNarrative extends BaseCultureNarrative
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public CultureNarrative ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public String getObjectIDSpace()
{
return "CultureNarrative";
}
}
\ 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="CultureNarrative" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TABLE name="rs_culture_narrative" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Notes" type="String" dbcol="narrative_notes" />
<ATTRIB name="ColorCode" type="ColorCode" dbcol="color_code" attribHelper="EnumeratedAttributeHelper" />
<SINGLEREFERENCE name="CultureElement" type="CultureElement" dbcol="culture_element_number" backreferenceName="Narratives"/>
<SINGLEREFERENCE name="CultureElementQuestion" type="CultureElementQuestion" dbcol="culture_element_quest_id" backreferenceName="Narratives"/>
<SINGLEREFERENCE name="CultureElementRating" type="CultureElementRating" dbcol="culture_element_rating_id" backreferenceName="Narratives"/>
</TABLE>
<SEARCH type="All" paramFilter="rs_culture_narrative.object_id is not null" orderBy="rs_culture_narrative.object_id" />
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import performa.orm.types.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class CultureNarrativePersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea CultureNarrativePersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "CultureNarrative");
// Private attributes corresponding to business object data
private String dummyNotes;
private ColorCode dummyColorCode;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Notes = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_ColorCode = new EnumeratedAttributeHelper (ColorCode.FACTORY_ColorCode);
public CultureNarrativePersistenceMgr ()
{
dummyNotes = (String)(HELPER_Notes.initialise (dummyNotes));
dummyColorCode = (ColorCode)(HELPER_ColorCode.initialise (dummyColorCode));
}
private String SELECT_COLUMNS = "{PREFIX}rs_culture_narrative.object_id as id, {PREFIX}rs_culture_narrative.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_culture_narrative.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_culture_narrative.narrative_notes, {PREFIX}rs_culture_narrative.color_code, {PREFIX}rs_culture_narrative.culture_element_number, {PREFIX}rs_culture_narrative.culture_element_quest_id, {PREFIX}rs_culture_narrative.culture_element_rating_id, 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, CultureNarrative.REFERENCE_CultureNarrative);
if (objectToReturn instanceof CultureNarrative)
{
LogMgr.log (CultureNarrativePersistence, 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 CultureNarrative");
}
}
PersistentSet rs_culture_narrativePSet = allPSets.getPersistentSet(id, "rs_culture_narrative", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !rs_culture_narrativePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!rs_culture_narrativePSet.containsAttrib(CultureNarrative.FIELD_Notes)||
!rs_culture_narrativePSet.containsAttrib(CultureNarrative.FIELD_ColorCode)||
!rs_culture_narrativePSet.containsAttrib(CultureNarrative.SINGLEREFERENCE_CultureElement)||
!rs_culture_narrativePSet.containsAttrib(CultureNarrative.SINGLEREFERENCE_CultureElementQuestion)||
!rs_culture_narrativePSet.containsAttrib(CultureNarrative.SINGLEREFERENCE_CultureElementRating))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (CultureNarrativePersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
CultureNarrative result = new CultureNarrative ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_narrative " +
"WHERE " + SELECT_JOINS + "{PREFIX}rs_culture_narrative.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 (CultureNarrative.SINGLEREFERENCE_CultureElement))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_narrative " +
"WHERE " + SELECT_JOINS + "culture_element_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else if (refName.equals (CultureNarrative.SINGLEREFERENCE_CultureElementQuestion))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_narrative " +
"WHERE " + SELECT_JOINS + "culture_element_quest_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else if (refName.equals (CultureNarrative.SINGLEREFERENCE_CultureElementRating))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_narrative " +
"WHERE " + SELECT_JOINS + "culture_element_rating_id = ?";
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 rs_culture_narrativePSet = allPSets.getPersistentSet(objectID, "rs_culture_narrative");
if (rs_culture_narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}rs_culture_narrative " +
"SET narrative_notes = ?, color_code = ?, culture_element_number = ? , culture_element_quest_id = ? , culture_element_rating_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE rs_culture_narrative.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Notes.getForSQL(dummyNotes, rs_culture_narrativePSet.getAttrib (CultureNarrative.FIELD_Notes))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, rs_culture_narrativePSet.getAttrib (CultureNarrative.FIELD_ColorCode))).listEntry (SQLManager.CheckNull((Long)(rs_culture_narrativePSet.getAttrib (CultureNarrative.SINGLEREFERENCE_CultureElement)))).listEntry (SQLManager.CheckNull((Long)(rs_culture_narrativePSet.getAttrib (CultureNarrative.SINGLEREFERENCE_CultureElementQuestion)))).listEntry (SQLManager.CheckNull((Long)(rs_culture_narrativePSet.getAttrib (CultureNarrative.SINGLEREFERENCE_CultureElementRating)))).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}rs_culture_narrative 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[] { "rs_culture_narrative", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (CultureNarrativePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "rs_culture_narrative");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:rs_culture_narrative for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CultureNarrativePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (CultureNarrativePersistence, 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 rs_culture_narrativePSet = allPSets.getPersistentSet(objectID, "rs_culture_narrative");
LogMgr.log (CultureNarrativePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (rs_culture_narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}rs_culture_narrative " +
"WHERE rs_culture_narrative.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}rs_culture_narrative WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "rs_culture_narrative");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:rs_culture_narrative for row:" + objectID;
LogMgr.log (CultureNarrativePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
rs_culture_narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, CultureNarrative> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (CultureNarrative.REFERENCE_CultureNarrative.getObjectIDSpace (), r.getLong ("id"));
CultureNarrative 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, CultureNarrative.REFERENCE_CultureNarrative);
if (cachedElement instanceof CultureNarrative)
{
LogMgr.log (CultureNarrativePersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (CultureNarrative)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a CultureNarrative");
}
}
else
{
PersistentSet rs_culture_narrativePSet = allPSets.getPersistentSet(objectID, "rs_culture_narrative", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new CultureNarrative ();
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 (CultureNarrativePersistence, 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}rs_culture_narrative " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (CultureNarrative.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY rs_culture_narrative.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: rs_culture_narrative.object_id is not null
String preFilter = "(rs_culture_narrative.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_culture_narrative " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet rs_culture_narrativePSet = allPSets.getPersistentSet(objectID, "rs_culture_narrative", PersistentSetStatus.FETCHED);
// Object Modified
rs_culture_narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
rs_culture_narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
rs_culture_narrativePSet.setAttrib(CultureNarrative.FIELD_Notes, HELPER_Notes.getFromRS(dummyNotes, r, "narrative_notes"));
rs_culture_narrativePSet.setAttrib(CultureNarrative.FIELD_ColorCode, HELPER_ColorCode.getFromRS(dummyColorCode, r, "color_code"));
rs_culture_narrativePSet.setAttrib(CultureNarrative.SINGLEREFERENCE_CultureElement, r.getObject ("culture_element_number"));
rs_culture_narrativePSet.setAttrib(CultureNarrative.SINGLEREFERENCE_CultureElementQuestion, r.getObject ("culture_element_quest_id"));
rs_culture_narrativePSet.setAttrib(CultureNarrative.SINGLEREFERENCE_CultureElementRating, r.getObject ("culture_element_rating_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet rs_culture_narrativePSet = allPSets.getPersistentSet(objectID, "rs_culture_narrative");
if (rs_culture_narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
rs_culture_narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}rs_culture_narrative " +
" (narrative_notes, color_code, culture_element_number, culture_element_quest_id, culture_element_rating_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Notes.getForSQL(dummyNotes, rs_culture_narrativePSet.getAttrib (CultureNarrative.FIELD_Notes))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, rs_culture_narrativePSet.getAttrib (CultureNarrative.FIELD_ColorCode))) .listEntry (SQLManager.CheckNull((Long)(rs_culture_narrativePSet.getAttrib (CultureNarrative.SINGLEREFERENCE_CultureElement)))).listEntry (SQLManager.CheckNull((Long)(rs_culture_narrativePSet.getAttrib (CultureNarrative.SINGLEREFERENCE_CultureElementQuestion)))).listEntry (SQLManager.CheckNull((Long)(rs_culture_narrativePSet.getAttrib (CultureNarrative.SINGLEREFERENCE_CultureElementRating)))) .listEntry (objectID.longID ()).toList().toArray());
rs_culture_narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm.types;
import java.util.*;
import oneit.utils.*;
/**
* This class was generated using constGen.bat.
* DO NOT MODIFY THIS CODE.
* Edit the associated .xml file, and regenerate this file
* constGen (directory) (file minus extension)
* e.g. constGen C:\...\sql FieldType
*/
public class CultureClass extends AbstractEnumerated
{
public static final EnumeratedFactory FACTORY_CultureClass = new CultureClassFactory();
public static final CultureClass BELONGING = new CultureClass ("BELONGING", "BELONGING", "Belonging", false);
public static final CultureClass CLIMATE = new CultureClass ("CLIMATE", "CLIMATE", "Climate", false);
public static final CultureClass PERFORMANCE = new CultureClass ("PERFORMANCE", "PERFORMANCE", "Performance", false);
private static final CultureClass[] allCultureClasss =
new CultureClass[] { BELONGING,CLIMATE,PERFORMANCE};
private static CultureClass[] getAllCultureClasss ()
{
return allCultureClasss;
}
private CultureClass (String name, String value, String description, boolean disabled)
{
super (name, value, description, disabled);
}
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allCultureClasss);
static
{
defineAdditionalData ();
}
public boolean isEqual (CultureClass other)
{
return this.name.equals (other.name);
}
public Enumeration getAllInstances ()
{
return CultureClass.getAll ();
}
private Object readResolve() throws java.io.ObjectStreamException
{
return CultureClass.forName (this.name);
}
public EnumeratedFactory getFactory ()
{
return FACTORY_CultureClass;
}
public static CultureClass forName (String name)
{
if (name == null) { return null; }
CultureClass[] all = getAllCultureClasss();
int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex];
}
public static CultureClass forValue (String value)
{
if (value == null) { return null; }
CultureClass[] all = getAllCultureClasss();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllCultureClasss (), value);
return all[enumIndex];
}
public static java.util.Enumeration getAll ()
{
return AbstractEnumerated.getAll (getAllCultureClasss());
}
public static CultureClass[] getCultureClassArray ()
{
return (CultureClass[])getAllCultureClasss().clone ();
}
public static void defineAdditionalData ()
{
}
static class CultureClassFactory implements EnumeratedFactory
{
public AbstractEnumerated getForName (String name)
{
return CultureClass.forName (name);
}
public AbstractEnumerated getForValue (String name)
{
return CultureClass.forValue (name);
}
public Enumeration getAll ()
{
return CultureClass.getAll ();
}
}
public Map getAdditionalAttributes ()
{
Map attribs = new HashMap ();
return attribs;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="CultureClass">
<VALUE name="BELONGING" description="Belonging" />
<VALUE name="CLIMATE" description="Climate" />
<VALUE name="PERFORMANCE" description="Performance"/>
</CONSTANT>
</ROOT>
\ 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