Commit 0d6d079a by Nilu

new BO TestAnalysis and FactorScore

parent 82465240
<?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">score</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="score_number" type="Long" nullable="true"/>
<column name="test_analysis_id" type="Long" length="11" nullable="true"/>
<column name="factor_number" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="score" indexName="idx_score_test_analysis_id" isUnique="false"><column name="test_analysis_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">it_does_not_matter</tableName> <tableName factory="String">test_analysis</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <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_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="xxxx" type="BLOB" nullable="false"/> <column name="level_id" type="Long" length="11" nullable="true"/>
<column name="candidate_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE score;
CREATE TABLE score (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
score_number numeric(12) NULL,
test_analysis_id numeric(12) NULL,
factor_number numeric(12) NULL
);
ALTER TABLE score ADD
CONSTRAINT PK_score PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_score_test_analysis_id
ON score (test_analysis_id);
-- DROP TABLE it_does_not_matter; -- DROP TABLE test_analysis;
CREATE TABLE it_does_not_matter ( CREATE TABLE test_analysis (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, ,
xxxx image NOT NULL level_id numeric(12) NULL,
candidate_id numeric(12) NULL
); );
ALTER TABLE it_does_not_matter ADD ALTER TABLE test_analysis ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY CONSTRAINT PK_test_analysis PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- DROP TABLE score;
CREATE TABLE score (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
score_number number(12) NULL,
test_analysis_id number(12) NULL,
factor_number number(12) NULL
);
ALTER TABLE score ADD
CONSTRAINT PK_score PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_score_test_analysis_id
ON score (test_analysis_id);
-- DROP TABLE it_does_not_matter; -- DROP TABLE test_analysis;
CREATE TABLE it_does_not_matter ( CREATE TABLE test_analysis (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, ,
xxxx blob NOT NULL level_id number(12) NULL,
candidate_id number(12) NULL
); );
ALTER TABLE it_does_not_matter ADD ALTER TABLE test_analysis ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY CONSTRAINT PK_test_analysis PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- @AutoRun
-- drop table score;
CREATE TABLE score (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
score_number numeric(12) NULL,
test_analysis_id numeric(12) NULL,
factor_number numeric(12) NULL
);
ALTER TABLE score ADD
CONSTRAINT pk_score PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_score_test_analysis_id
ON score (test_analysis_id);
-- @AutoRun -- @AutoRun
-- drop table it_does_not_matter; -- drop table test_analysis;
CREATE TABLE it_does_not_matter ( CREATE TABLE test_analysis (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, ,
xxxx bytea NOT NULL level_id numeric(12) NULL,
candidate_id numeric(12) NULL
); );
ALTER TABLE it_does_not_matter ADD ALTER TABLE test_analysis ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY CONSTRAINT pk_test_analysis PRIMARY KEY
( (
object_id object_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;
public abstract class BaseFactorScore extends BaseBusinessClass
{
// Reference instance for the object
public static final FactorScore REFERENCE_FactorScore = new FactorScore ();
// Reference instance for the object
public static final FactorScore DUMMY_FactorScore = new DummyFactorScore ();
// Static constants corresponding to field names
public static final String FIELD_Score = "Score";
public static final String SINGLEREFERENCE_TestAnalysis = "TestAnalysis";
public static final String BACKREF_TestAnalysis = "";
public static final String SINGLEREFERENCE_Factor = "Factor";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<FactorScore> HELPER_Score = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private Integer _Score;
// Private attributes corresponding to single references
private SingleAssociation<FactorScore, TestAnalysis> _TestAnalysis;
private SingleAssociation<FactorScore, Factor> _Factor;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_FactorScore = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Score_Validators;
// Arrays of behaviour decorators
private static final FactorScoreBehaviourDecorator[] FactorScore_BehaviourDecorators;
static
{
try
{
String tmp_TestAnalysis = TestAnalysis.BACKREF_FactorScores;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_TestAnalysis();
setupAssocMetaData_Factor();
FIELD_Score_Validators = (AttributeValidator[])setupAttribMetaData_Score(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_FactorScore.initialiseReference ();
DUMMY_FactorScore.initialiseReference ();
FactorScore_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(FactorScore.class).toArray(new FactorScoreBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_TestAnalysis()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "FactorScores");
metaInfo.put ("dbcol", "test_analysis_id");
metaInfo.put ("name", "TestAnalysis");
metaInfo.put ("type", "TestAnalysis");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.TestAnalysis:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (SINGLEREFERENCE_TestAnalysis, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Factor()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "factor_number");
metaInfo.put ("name", "Factor");
metaInfo.put ("type", "Factor");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.Factor:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (SINGLEREFERENCE_Factor, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Score(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "score_number");
metaInfo.put ("name", "Score");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.Score:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (FIELD_Score, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(FactorScore.class, "Score", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for FactorScore.Score:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseFactorScore ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return FactorScore_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Score = (Integer)(HELPER_Score.initialise (_Score));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_TestAnalysis = new SingleAssociation<FactorScore, TestAnalysis> (this, SINGLEREFERENCE_TestAnalysis, TestAnalysis.MULTIPLEREFERENCE_FactorScores, TestAnalysis.REFERENCE_TestAnalysis, "score");
_Factor = new SingleAssociation<FactorScore, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "score");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_TestAnalysis = new SingleAssociation<FactorScore, TestAnalysis> (this, SINGLEREFERENCE_TestAnalysis, TestAnalysis.MULTIPLEREFERENCE_FactorScores, TestAnalysis.REFERENCE_TestAnalysis, "score");
_Factor = new SingleAssociation<FactorScore, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "score");
return this;
}
/**
* Get the attribute Score
*/
public Integer getScore ()
{
assertValid();
Integer valToReturn = _Score;
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
valToReturn = bhd.getScore ((FactorScore)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 preScoreChange (Integer newScore) 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 postScoreChange () throws FieldException
{
}
public FieldWriteability getWriteability_Score ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Score. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setScore (Integer newScore) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Score.compare (_Score, newScore);
try
{
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
newScore = bhd.setScore ((FactorScore)this, newScore);
oldAndNewIdentical = HELPER_Score.compare (_Score, newScore);
}
if (FIELD_Score_Validators.length > 0)
{
Object newScoreObj = HELPER_Score.toObject (newScore);
if (newScoreObj != null)
{
int loopMax = FIELD_Score_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_FactorScore.get (FIELD_Score);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Score_Validators[v].checkAttribute (this, FIELD_Score, metadata, newScoreObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Score () != FieldWriteability.FALSE, "Field Score is not writeable");
preScoreChange (newScore);
markFieldChange (FIELD_Score);
_Score = newScore;
postFieldChange (FIELD_Score);
postScoreChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("TestAnalysis");
result.add("Factor");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_TestAnalysis))
{
return _TestAnalysis.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return _Factor.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_TestAnalysis))
{
return TestAnalysis.MULTIPLEREFERENCE_FactorScores ;
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return null ;
}
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_TestAnalysis))
{
return getTestAnalysis ();
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return getFactor ();
}
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_TestAnalysis))
{
return getTestAnalysis (getType);
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return getFactor (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_TestAnalysis))
{
return getTestAnalysisID ();
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return getFactorID ();
}
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_TestAnalysis))
{
setTestAnalysis ((TestAnalysis)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
setFactor ((Factor)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference TestAnalysis
*/
public TestAnalysis getTestAnalysis () throws StorageException
{
assertValid();
try
{
return (TestAnalysis)(_TestAnalysis.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in FactorScore:", this.getObjectID (), ", was trying to get TestAnalysis:", getTestAnalysisID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _TestAnalysis.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public TestAnalysis getTestAnalysis (Get getType) throws StorageException
{
assertValid();
return _TestAnalysis.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getTestAnalysisID ()
{
assertValid();
if (_TestAnalysis == null)
{
return null;
}
else
{
return _TestAnalysis.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 preTestAnalysisChange (TestAnalysis newTestAnalysis) 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 postTestAnalysisChange () throws FieldException
{
}
public FieldWriteability getWriteability_TestAnalysis ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference TestAnalysis. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setTestAnalysis (TestAnalysis newTestAnalysis) throws StorageException, FieldException
{
if (_TestAnalysis.wouldReferencedChange (newTestAnalysis))
{
assertValid();
Debug.assertion (getWriteability_TestAnalysis () != FieldWriteability.FALSE, "Assoc TestAnalysis is not writeable");
preTestAnalysisChange (newTestAnalysis);
TestAnalysis oldTestAnalysis = getTestAnalysis ();
if (oldTestAnalysis != null)
{
// This is to stop validation from triggering when we are removed
_TestAnalysis.set (null);
oldTestAnalysis.removeFromFactorScores ((FactorScore)(this));
}
_TestAnalysis.set (newTestAnalysis);
if (newTestAnalysis != null)
{
newTestAnalysis.addToFactorScores ((FactorScore)(this));
}
postTestAnalysisChange ();
}
}
/**
* Get the reference Factor
*/
public Factor getFactor () throws StorageException
{
assertValid();
try
{
return (Factor)(_Factor.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in FactorScore:", this.getObjectID (), ", was trying to get Factor:", getFactorID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Factor.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Factor getFactor (Get getType) throws StorageException
{
assertValid();
return _Factor.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getFactorID ()
{
assertValid();
if (_Factor == null)
{
return null;
}
else
{
return _Factor.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 preFactorChange (Factor newFactor) 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 postFactorChange () throws FieldException
{
}
public FieldWriteability getWriteability_Factor ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Factor. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setFactor (Factor newFactor) throws StorageException, FieldException
{
if (_Factor.wouldReferencedChange (newFactor))
{
assertValid();
Debug.assertion (getWriteability_Factor () != FieldWriteability.FALSE, "Assoc Factor is not writeable");
preFactorChange (newFactor);
_Factor.set (newFactor);
postFactorChange ();
}
}
/**
* 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 (_TestAnalysis.isLoaded () || getTransaction ().isObjectLoaded (_TestAnalysis.getReferencedType (), getTestAnalysisID ()))
{
TestAnalysis referenced = getTestAnalysis ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null FactorScores from ", getObjectID (), " to ", referenced.getObjectID ());
_TestAnalysis.set (null);
referenced.removeFromFactorScores ((FactorScore)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public FactorScore newInstance ()
{
return new FactorScore ();
}
public FactorScore referenceInstance ()
{
return REFERENCE_FactorScore;
}
public FactorScore getInTransaction (ObjectTransaction t) throws StorageException
{
return getFactorScoreByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_FactorScore;
}
public String getBaseSetName ()
{
return "score";
}
/**
* 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 scorePSet = allSets.getPersistentSet (myID, "score", myPSetStatus);
scorePSet.setAttrib (FIELD_ObjectID, myID);
scorePSet.setAttrib (FIELD_Score, HELPER_Score.toObject (_Score)); //
_TestAnalysis.getPersistentSets (allSets);
_Factor.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet scorePSet = allSets.getPersistentSet (objectID, "score");
_Score = (Integer)(HELPER_Score.fromObject (_Score, scorePSet.getAttrib (FIELD_Score))); //
_TestAnalysis.setFromPersistentSets (objectID, allSets);
_Factor.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof FactorScore)
{
FactorScore otherFactorScore = (FactorScore)other;
try
{
setScore (otherFactorScore.getScore ());
}
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 BaseFactorScore)
{
BaseFactorScore sourceFactorScore = (BaseFactorScore)(source);
_Score = sourceFactorScore._Score;
}
}
/**
* 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 BaseFactorScore)
{
BaseFactorScore sourceFactorScore = (BaseFactorScore)(source);
_TestAnalysis.copyFrom (sourceFactorScore._TestAnalysis, linkToGhosts);
_Factor.copyFrom (sourceFactorScore._Factor, 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 BaseFactorScore)
{
BaseFactorScore sourceFactorScore = (BaseFactorScore)(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);
_Score = (Integer)(HELPER_Score.readExternal (_Score, vals.get(FIELD_Score))); //
_TestAnalysis.readExternalData(vals.get(SINGLEREFERENCE_TestAnalysis));
_Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Score, HELPER_Score.writeExternal (_Score));
vals.put (SINGLEREFERENCE_TestAnalysis, _TestAnalysis.writeExternalData());
vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseFactorScore)
{
BaseFactorScore otherFactorScore = (BaseFactorScore)(other);
if (!HELPER_Score.compare(this._Score, otherFactorScore._Score))
{
listener.notifyFieldChange(this, other, FIELD_Score, HELPER_Score.toObject(this._Score), HELPER_Score.toObject(otherFactorScore._Score));
}
// Compare single assocs
_TestAnalysis.compare (otherFactorScore._TestAnalysis, listener);
_Factor.compare (otherFactorScore._Factor, 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_Score, HELPER_Score.toObject(getScore()));
visitor.visitAssociation (_TestAnalysis);
visitor.visitAssociation (_Factor);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_TestAnalysis))
{
visitor.visit (_TestAnalysis);
}
if (scope.includes (_Factor))
{
visitor.visit (_Factor);
}
}
public static FactorScore createFactorScore (ObjectTransaction transaction) throws StorageException
{
FactorScore result = new FactorScore ();
result.initialiseNewObject (transaction);
return result;
}
public static FactorScore getFactorScoreByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (FactorScore)(transaction.getObjectByID (REFERENCE_FactorScore, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Score))
{
return filter.matches (getScore ());
}
else if (attribName.equals (SINGLEREFERENCE_TestAnalysis))
{
return filter.matches (getTestAnalysis ());
}
else if (attribName.equals (SINGLEREFERENCE_Factor))
{
return filter.matches (getFactor ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<FactorScore>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "score.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "score.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "score.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andScore (QueryFilter<Integer> filter)
{
filter.addFilter (context, "score.score_number", "Score");
return this;
}
public SearchAll andTestAnalysis (QueryFilter<TestAnalysis> filter)
{
filter.addFilter (context, "score.test_analysis_id", "TestAnalysis");
return this;
}
public SearchAll andFactor (QueryFilter<Factor> filter)
{
filter.addFilter (context, "score.factor_number", "Factor");
return this;
}
public FactorScore[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_FactorScore, SEARCH_All, criteria);
Set<FactorScore> typedResults = new LinkedHashSet <FactorScore> ();
for (BaseBusinessClass bbcResult : results)
{
FactorScore aResult = (FactorScore)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new FactorScore[0]);
}
}
public static FactorScore[]
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_Score))
{
return HELPER_Score.toObject (getScore ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Score))
{
return HELPER_Score;
}
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_Score))
{
setScore ((Integer)(HELPER_Score.fromObject (_Score, 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_Score))
{
return getWriteability_Score ();
}
else if (fieldName.equals (SINGLEREFERENCE_TestAnalysis))
{
return getWriteability_TestAnalysis ();
}
else if (fieldName.equals (SINGLEREFERENCE_Factor))
{
return getWriteability_Factor ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Score () != FieldWriteability.TRUE)
{
fields.add (FIELD_Score);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Score.getAttribObject (getClass (), _Score, false, FIELD_Score));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_FactorScore.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_FactorScore.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_FactorScore.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_FactorScore.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 FactorScoreBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<FactorScore>
{
/**
* Get the attribute Score
*/
public Integer getScore (FactorScore obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute Score.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setScore (FactorScore obj, Integer newScore) throws FieldException
{
return newScore;
}
}
public ORMPipeLine pipes()
{
return new FactorScorePipeLineFactory<FactorScore, FactorScore> ((FactorScore)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public FactorScorePipeLineFactory<FactorScore, FactorScore> pipelineFactorScore()
{
return (FactorScorePipeLineFactory<FactorScore, FactorScore>) pipes();
}
public static FactorScorePipeLineFactory<FactorScore, FactorScore> pipesFactorScore(Collection<FactorScore> items)
{
return REFERENCE_FactorScore.new FactorScorePipeLineFactory<FactorScore, FactorScore> (items);
}
public static FactorScorePipeLineFactory<FactorScore, FactorScore> pipesFactorScore(FactorScore[] _items)
{
return pipesFactorScore(Arrays.asList (_items));
}
public static FactorScorePipeLineFactory<FactorScore, FactorScore> pipesFactorScore()
{
return pipesFactorScore((Collection)null);
}
public class FactorScorePipeLineFactory<From extends BaseBusinessClass, Me extends FactorScore> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> FactorScorePipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public FactorScorePipeLineFactory (From seed)
{
super(seed);
}
public FactorScorePipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Score"))
{
return toScore ();
}
if (name.equals ("TestAnalysis"))
{
return toTestAnalysis ();
}
if (name.equals ("Factor"))
{
return toFactor ();
}
return super.to(name);
}
public PipeLine<From, Integer> toScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_Score)); }
public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysis () { return toTestAnalysis (Filter.ALL); }
public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysis (Filter<TestAnalysis> filter)
{
return TestAnalysis.REFERENCE_TestAnalysis.new TestAnalysisPipeLineFactory<From, TestAnalysis> (this, new ORMSingleAssocPipe<Me, TestAnalysis>(SINGLEREFERENCE_TestAnalysis, filter));
}
public Factor.FactorPipeLineFactory<From, Factor> toFactor () { return toFactor (Filter.ALL); }
public Factor.FactorPipeLineFactory<From, Factor> toFactor (Filter<Factor> filter)
{
return Factor.REFERENCE_Factor.new FactorPipeLineFactory<From, Factor> (this, new ORMSingleAssocPipe<Me, Factor>(SINGLEREFERENCE_Factor, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyFactorScore extends FactorScore
{
// Default constructor primarily to support Externalisable
public DummyFactorScore()
{
super();
}
public void assertValid ()
{
}
public TestAnalysis getTestAnalysis () throws StorageException
{
return (TestAnalysis)(TestAnalysis.DUMMY_TestAnalysis);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getTestAnalysisID ()
{
return TestAnalysis.DUMMY_TestAnalysis.getObjectID();
}
public Factor getFactor () throws StorageException
{
return (Factor)(Factor.DUMMY_Factor);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getFactorID ()
{
return Factor.DUMMY_Factor.getObjectID();
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
public abstract class BaseTestAnalysis extends BaseBusinessClass
{
// Reference instance for the object
public static final TestAnalysis REFERENCE_TestAnalysis = new TestAnalysis ();
// Reference instance for the object
public static final TestAnalysis DUMMY_TestAnalysis = new DummyTestAnalysis ();
// Static constants corresponding to field names
public static final String SINGLEREFERENCE_Level = "Level";
public static final String SINGLEREFERENCE_Candidate = "Candidate";
public static final String MULTIPLEREFERENCE_FactorScores = "FactorScores";
public static final String BACKREF_FactorScores = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
// Private attributes corresponding to business object data
// Private attributes corresponding to single references
private SingleAssociation<TestAnalysis, Level> _Level;
private SingleAssociation<TestAnalysis, Candidate> _Candidate;
// Private attributes corresponding to multiple references
private MultipleAssociation<TestAnalysis, FactorScore> _FactorScores;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_TestAnalysis = new HashMap ();
// Arrays of validators for each attribute
// Arrays of behaviour decorators
private static final TestAnalysisBehaviourDecorator[] TestAnalysis_BehaviourDecorators;
static
{
try
{
String tmp_FactorScores = FactorScore.BACKREF_TestAnalysis;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_FactorScores();
setupAssocMetaData_Level();
setupAssocMetaData_Candidate();
REFERENCE_TestAnalysis.initialiseReference ();
DUMMY_TestAnalysis.initialiseReference ();
TestAnalysis_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(TestAnalysis.class).toArray(new TestAnalysisBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_FactorScores()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "TestAnalysis");
metaInfo.put ("name", "FactorScores");
metaInfo.put ("type", "FactorScore");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for TestAnalysis.FactorScores:", metaInfo);
ATTRIBUTES_METADATA_TestAnalysis.put (MULTIPLEREFERENCE_FactorScores, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Level()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "level_id");
metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for TestAnalysis.Level:", metaInfo);
ATTRIBUTES_METADATA_TestAnalysis.put (SINGLEREFERENCE_Level, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Candidate()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "candidate_id");
metaInfo.put ("name", "Candidate");
metaInfo.put ("type", "Candidate");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for TestAnalysis.Candidate:", metaInfo);
ATTRIBUTES_METADATA_TestAnalysis.put (SINGLEREFERENCE_Candidate, Collections.unmodifiableMap (metaInfo));
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseTestAnalysis ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return TestAnalysis_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_Level = new SingleAssociation<TestAnalysis, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "test_analysis");
_Candidate = new SingleAssociation<TestAnalysis, Candidate> (this, SINGLEREFERENCE_Candidate, null, Candidate.REFERENCE_Candidate, "test_analysis");
_FactorScores = new MultipleAssociation<TestAnalysis, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_TestAnalysis, FactorScore.REFERENCE_FactorScore);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_Level = new SingleAssociation<TestAnalysis, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "test_analysis");
_Candidate = new SingleAssociation<TestAnalysis, Candidate> (this, SINGLEREFERENCE_Candidate, null, Candidate.REFERENCE_Candidate, "test_analysis");
_FactorScores = new MultipleAssociation<TestAnalysis, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_TestAnalysis, FactorScore.REFERENCE_FactorScore);
return this;
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("Level");
result.add("Candidate");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return _Level.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{
return _Candidate.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_Level))
{
return null ;
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{
return null ;
}
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_Level))
{
return getLevel ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{
return getCandidate ();
}
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_Level))
{
return getLevel (getType);
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{
return getCandidate (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_Level))
{
return getLevelID ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{
return getCandidateID ();
}
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_Level))
{
setLevel ((Level)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{
setCandidate ((Candidate)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference Level
*/
public Level getLevel () throws StorageException
{
assertValid();
try
{
return (Level)(_Level.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in TestAnalysis:", this.getObjectID (), ", was trying to get Level:", getLevelID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Level.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Level getLevel (Get getType) throws StorageException
{
assertValid();
return _Level.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getLevelID ()
{
assertValid();
if (_Level == null)
{
return null;
}
else
{
return _Level.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 preLevelChange (Level newLevel) 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 postLevelChange () throws FieldException
{
}
public FieldWriteability getWriteability_Level ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Level. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setLevel (Level newLevel) throws StorageException, FieldException
{
if (_Level.wouldReferencedChange (newLevel))
{
assertValid();
Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable");
preLevelChange (newLevel);
_Level.set (newLevel);
postLevelChange ();
}
}
/**
* Get the reference Candidate
*/
public Candidate getCandidate () throws StorageException
{
assertValid();
try
{
return (Candidate)(_Candidate.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in TestAnalysis:", this.getObjectID (), ", was trying to get Candidate:", getCandidateID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Candidate.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Candidate getCandidate (Get getType) throws StorageException
{
assertValid();
return _Candidate.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCandidateID ()
{
assertValid();
if (_Candidate == null)
{
return null;
}
else
{
return _Candidate.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 preCandidateChange (Candidate newCandidate) 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 postCandidateChange () throws FieldException
{
}
public FieldWriteability getWriteability_Candidate ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Candidate. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCandidate (Candidate newCandidate) throws StorageException, FieldException
{
if (_Candidate.wouldReferencedChange (newCandidate))
{
assertValid();
Debug.assertion (getWriteability_Candidate () != FieldWriteability.FALSE, "Assoc Candidate is not writeable");
preCandidateChange (newCandidate);
_Candidate.set (newCandidate);
postCandidateChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
result.add("FactorScores");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return FactorScore.REFERENCE_FactorScore ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return FactorScore.SINGLEREFERENCE_TestAnalysis ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return this.getFactorScoresCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return this.getFactorScoresAt(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_FactorScores.equals(attribName))
{
addToFactorScores((FactorScore)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_FactorScores.equals(attribName))
{
removeFromFactorScores((FactorScore)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
_FactorScores.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return _FactorScores.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_FactorScores ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getFactorScoresCount () throws StorageException
{
assertValid();
return _FactorScores.getReferencedObjectsCount ();
}
public void addToFactorScores (FactorScore newElement) throws StorageException
{
if (_FactorScores.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_FactorScores () != FieldWriteability.FALSE, "MultiAssoc FactorScores is not writeable (add)");
_FactorScores.appendElement (newElement);
try
{
if (newElement.getTestAnalysis () != this)
{
newElement.setTestAnalysis ((TestAnalysis)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromFactorScores (FactorScore elementToRemove) throws StorageException
{
if (_FactorScores.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_FactorScores () != FieldWriteability.FALSE, "MultiAssoc FactorScores is not writeable (remove)");
_FactorScores.removeElement (elementToRemove);
try
{
if (elementToRemove.getTestAnalysis () != null)
{
elementToRemove.setTestAnalysis (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public FactorScore getFactorScoresAt (int index) throws StorageException
{
return (FactorScore)(_FactorScores.getElementAt (index));
}
public SortedSet<FactorScore> getFactorScoresSet () throws StorageException
{
return _FactorScores.getSet ();
}
public void onDelete ()
{
try
{
for(FactorScore referenced : CollectionUtils.reverse(getFactorScoresSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null TestAnalysis from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setTestAnalysis(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public TestAnalysis newInstance ()
{
return new TestAnalysis ();
}
public TestAnalysis referenceInstance ()
{
return REFERENCE_TestAnalysis;
}
public TestAnalysis getInTransaction (ObjectTransaction t) throws StorageException
{
return getTestAnalysisByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_TestAnalysis;
}
public String getBaseSetName ()
{
return "test_analysis";
}
/**
* 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 test_analysisPSet = allSets.getPersistentSet (myID, "test_analysis", myPSetStatus);
test_analysisPSet.setAttrib (FIELD_ObjectID, myID);
_Level.getPersistentSets (allSets);
_Candidate.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet test_analysisPSet = allSets.getPersistentSet (objectID, "test_analysis");
_Level.setFromPersistentSets (objectID, allSets);
_Candidate.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof TestAnalysis)
{
TestAnalysis otherTestAnalysis = (TestAnalysis)other;
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseTestAnalysis)
{
BaseTestAnalysis sourceTestAnalysis = (BaseTestAnalysis)(source);
}
}
/**
* 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 BaseTestAnalysis)
{
BaseTestAnalysis sourceTestAnalysis = (BaseTestAnalysis)(source);
_Level.copyFrom (sourceTestAnalysis._Level, linkToGhosts);
_Candidate.copyFrom (sourceTestAnalysis._Candidate, 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 BaseTestAnalysis)
{
BaseTestAnalysis sourceTestAnalysis = (BaseTestAnalysis)(source);
_FactorScores.copyFrom (sourceTestAnalysis._FactorScores, 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);
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Candidate.readExternalData(vals.get(SINGLEREFERENCE_Candidate));
_FactorScores.readExternalData(vals.get(MULTIPLEREFERENCE_FactorScores));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (SINGLEREFERENCE_Candidate, _Candidate.writeExternalData());
vals.put (MULTIPLEREFERENCE_FactorScores, _FactorScores.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseTestAnalysis)
{
BaseTestAnalysis otherTestAnalysis = (BaseTestAnalysis)(other);
// Compare single assocs
_Level.compare (otherTestAnalysis._Level, listener);
_Candidate.compare (otherTestAnalysis._Candidate, listener);
// Compare multiple assocs
_FactorScores.compare (otherTestAnalysis._FactorScores, listener);
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitAssociation (_Level);
visitor.visitAssociation (_Candidate);
visitor.visitAssociation (_FactorScores);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Level))
{
visitor.visit (_Level);
}
if (scope.includes (_Candidate))
{
visitor.visit (_Candidate);
}
if (scope.includes (_FactorScores))
{
visitor.visit (_FactorScores);
}
}
public static TestAnalysis createTestAnalysis (ObjectTransaction transaction) throws StorageException
{
TestAnalysis result = new TestAnalysis ();
result.initialiseNewObject (transaction);
return result;
}
public static TestAnalysis getTestAnalysisByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (TestAnalysis)(transaction.getObjectByID (REFERENCE_TestAnalysis, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (SINGLEREFERENCE_Level))
{
return filter.matches (getLevel ());
}
else if (attribName.equals (SINGLEREFERENCE_Candidate))
{
return filter.matches (getCandidate ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<TestAnalysis>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "test_analysis.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "test_analysis.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "test_analysis.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andLevel (QueryFilter<Level> filter)
{
filter.addFilter (context, "test_analysis.level_id", "Level");
return this;
}
public SearchAll andCandidate (QueryFilter<Candidate> filter)
{
filter.addFilter (context, "test_analysis.candidate_id", "Candidate");
return this;
}
public TestAnalysis[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_TestAnalysis, SEARCH_All, criteria);
Set<TestAnalysis> typedResults = new LinkedHashSet <TestAnalysis> ();
for (BaseBusinessClass bbcResult : results)
{
TestAnalysis aResult = (TestAnalysis)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new TestAnalysis[0]);
}
}
public static TestAnalysis[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
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 (MULTIPLEREFERENCE_FactorScores))
{
return getWriteability_FactorScores ();
}
else if (fieldName.equals (SINGLEREFERENCE_Level))
{
return getWriteability_Level ();
}
else if (fieldName.equals (SINGLEREFERENCE_Candidate))
{
return getWriteability_Candidate ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_TestAnalysis.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_TestAnalysis.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_TestAnalysis.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_TestAnalysis.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 TestAnalysisBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<TestAnalysis>
{
}
public ORMPipeLine pipes()
{
return new TestAnalysisPipeLineFactory<TestAnalysis, TestAnalysis> ((TestAnalysis)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public TestAnalysisPipeLineFactory<TestAnalysis, TestAnalysis> pipelineTestAnalysis()
{
return (TestAnalysisPipeLineFactory<TestAnalysis, TestAnalysis>) pipes();
}
public static TestAnalysisPipeLineFactory<TestAnalysis, TestAnalysis> pipesTestAnalysis(Collection<TestAnalysis> items)
{
return REFERENCE_TestAnalysis.new TestAnalysisPipeLineFactory<TestAnalysis, TestAnalysis> (items);
}
public static TestAnalysisPipeLineFactory<TestAnalysis, TestAnalysis> pipesTestAnalysis(TestAnalysis[] _items)
{
return pipesTestAnalysis(Arrays.asList (_items));
}
public static TestAnalysisPipeLineFactory<TestAnalysis, TestAnalysis> pipesTestAnalysis()
{
return pipesTestAnalysis((Collection)null);
}
public class TestAnalysisPipeLineFactory<From extends BaseBusinessClass, Me extends TestAnalysis> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> TestAnalysisPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public TestAnalysisPipeLineFactory (From seed)
{
super(seed);
}
public TestAnalysisPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("FactorScores"))
{
return toFactorScores ();
}
if (name.equals ("Level"))
{
return toLevel ();
}
if (name.equals ("Candidate"))
{
return toCandidate ();
}
return super.to(name);
}
public Level.LevelPipeLineFactory<From, Level> toLevel () { return toLevel (Filter.ALL); }
public Level.LevelPipeLineFactory<From, Level> toLevel (Filter<Level> filter)
{
return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_Level, filter));
}
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate () { return toCandidate (Filter.ALL); }
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate (Filter<Candidate> filter)
{
return Candidate.REFERENCE_Candidate.new CandidatePipeLineFactory<From, Candidate> (this, new ORMSingleAssocPipe<Me, Candidate>(SINGLEREFERENCE_Candidate, filter));
}
public FactorScore.FactorScorePipeLineFactory<From, FactorScore> toFactorScores () { return toFactorScores(Filter.ALL); }
public FactorScore.FactorScorePipeLineFactory<From, FactorScore> toFactorScores (Filter<FactorScore> filter)
{
return FactorScore.REFERENCE_FactorScore.new FactorScorePipeLineFactory<From, FactorScore> (this, new ORMMultiAssocPipe<Me, FactorScore>(MULTIPLEREFERENCE_FactorScores, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyTestAnalysis extends TestAnalysis
{
// Default constructor primarily to support Externalisable
public DummyTestAnalysis()
{
super();
}
public void assertValid ()
{
}
public Level getLevel () throws StorageException
{
return (Level)(Level.DUMMY_Level);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getLevelID ()
{
return Level.DUMMY_Level.getObjectID();
}
public Candidate getCandidate () throws StorageException
{
return (Candidate)(Candidate.DUMMY_Candidate);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCandidateID ()
{
return Candidate.DUMMY_Candidate.getObjectID();
}
public int getFactorScoresCount () throws StorageException
{
return 0;
}
public FactorScore getFactorScoresAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association FactorScores");
}
public SortedSet getFactorScoresSet () throws StorageException
{
return new TreeSet();
}
}
package performa.orm;
public class FactorScore extends BaseFactorScore
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public FactorScore ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="FactorScore" package="performa.orm">
<TABLE name="score" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Score" type="Integer" dbcol="score_number"/>
<SINGLEREFERENCE name="TestAnalysis" type="TestAnalysis" dbcol="test_analysis_id" backreferenceName="FactorScores"/>
<SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number"/>
</TABLE>
<SEARCH type="All" paramFilter="score.object_id is not null" orderBy="score.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 FactorScorePersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea FactorScorePersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "FactorScore");
// Private attributes corresponding to business object data
private Integer dummyScore;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Score = DefaultAttributeHelper.INSTANCE;
public FactorScorePersistenceMgr ()
{
dummyScore = (Integer)(HELPER_Score.initialise (dummyScore));
}
private String SELECT_COLUMNS = "{PREFIX}score.object_id as id, {PREFIX}score.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}score.object_CREATED_DATE as CREATED_DATE, {PREFIX}score.score_number, {PREFIX}score.test_analysis_id, {PREFIX}score.factor_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, FactorScore.REFERENCE_FactorScore);
if (objectToReturn instanceof FactorScore)
{
LogMgr.log (FactorScorePersistence, 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 FactorScore");
}
}
PersistentSet scorePSet = allPSets.getPersistentSet(id, "score", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !scorePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!scorePSet.containsAttrib(FactorScore.FIELD_Score)||
!scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis)||
!scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Factor))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (FactorScorePersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
FactorScore result = new FactorScore ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}score " +
"WHERE " + SELECT_JOINS + "{PREFIX}score.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 (FactorScore.SINGLEREFERENCE_TestAnalysis))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}score " +
"WHERE " + SELECT_JOINS + "test_analysis_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 scorePSet = allPSets.getPersistentSet(objectID, "score");
if (scorePSet.getStatus () != PersistentSetStatus.PROCESSED &&
scorePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}score " +
"SET score_number = ?, test_analysis_id = ? , factor_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE score.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, scorePSet.getAttrib (FactorScore.FIELD_Score))).listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).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}score 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[] { "score", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (FactorScorePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "score");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:score for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (FactorScorePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
scorePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (FactorScorePersistence, 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 scorePSet = allPSets.getPersistentSet(objectID, "score");
LogMgr.log (FactorScorePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (scorePSet.getStatus () != PersistentSetStatus.PROCESSED &&
scorePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}score " +
"WHERE score.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}score WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "score");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:score for row:" + objectID;
LogMgr.log (FactorScorePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
scorePSet.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, FactorScore> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (FactorScore.REFERENCE_FactorScore.getObjectIDSpace (), r.getLong ("id"));
FactorScore 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, FactorScore.REFERENCE_FactorScore);
if (cachedElement instanceof FactorScore)
{
LogMgr.log (FactorScorePersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (FactorScore)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a FactorScore");
}
}
else
{
PersistentSet scorePSet = allPSets.getPersistentSet(objectID, "score", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new FactorScore ();
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 (FactorScorePersistence, 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}score " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (FactorScore.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY score.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: score.object_id is not null
String preFilter = "(score.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}score " + 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 scorePSet = allPSets.getPersistentSet(objectID, "score", PersistentSetStatus.FETCHED);
// Object Modified
scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
scorePSet.setAttrib(FactorScore.FIELD_Score, HELPER_Score.getFromRS(dummyScore, r, "score_number"));
scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis, r.getObject ("test_analysis_id"));
scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet scorePSet = allPSets.getPersistentSet(objectID, "score");
if (scorePSet.getStatus () != PersistentSetStatus.PROCESSED &&
scorePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}score " +
" (score_number, test_analysis_id, factor_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, scorePSet.getAttrib (FactorScore.FIELD_Score))) .listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))) .listEntry (objectID.longID ()).toList().toArray());
scorePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
...@@ -19,4 +19,4 @@ ...@@ -19,4 +19,4 @@
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
\ No newline at end of file
package performa.orm;
public class TestAnalysis extends BaseTestAnalysis
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public TestAnalysis ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="TestAnalysis" package="performa.orm">
<MULTIPLEREFERENCE name="FactorScores" type="FactorScore" backreferenceName="TestAnalysis" />
<TABLE name="test_analysis" tablePrefix="object" polymorphic="FALSE">
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_id"/>
<SINGLEREFERENCE name="Candidate" type="Candidate" dbcol="candidate_id"/>
</TABLE>
<SEARCH type="All" paramFilter="test_analysis.object_id is not null" orderBy="test_analysis.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 TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea TestAnalysisPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "TestAnalysis");
// Private attributes corresponding to business object data
// Static constants corresponding to attribute helpers
public TestAnalysisPersistenceMgr ()
{
}
private String SELECT_COLUMNS = "{PREFIX}test_analysis.object_id as id, {PREFIX}test_analysis.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}test_analysis.object_CREATED_DATE as CREATED_DATE, {PREFIX}test_analysis.level_id, {PREFIX}test_analysis.candidate_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, TestAnalysis.REFERENCE_TestAnalysis);
if (objectToReturn instanceof TestAnalysis)
{
LogMgr.log (TestAnalysisPersistence, 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 TestAnalysis");
}
}
PersistentSet test_analysisPSet = allPSets.getPersistentSet(id, "test_analysis", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !test_analysisPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!test_analysisPSet.containsAttrib(TestAnalysis.SINGLEREFERENCE_Level)||
!test_analysisPSet.containsAttrib(TestAnalysis.SINGLEREFERENCE_Candidate))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (TestAnalysisPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
TestAnalysis result = new TestAnalysis ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}test_analysis " +
"WHERE " + SELECT_JOINS + "{PREFIX}test_analysis.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 test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis");
if (test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED &&
test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}test_analysis " +
"SET level_id = ? , candidate_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE test_analysis.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Candidate)))).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}test_analysis 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[] { "test_analysis", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (TestAnalysisPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "test_analysis");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:test_analysis for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (TestAnalysisPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (TestAnalysisPersistence, 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 test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis");
LogMgr.log (TestAnalysisPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED &&
test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}test_analysis " +
"WHERE test_analysis.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}test_analysis WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "test_analysis");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:test_analysis for row:" + objectID;
LogMgr.log (TestAnalysisPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
test_analysisPSet.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, TestAnalysis> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (TestAnalysis.REFERENCE_TestAnalysis.getObjectIDSpace (), r.getLong ("id"));
TestAnalysis 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, TestAnalysis.REFERENCE_TestAnalysis);
if (cachedElement instanceof TestAnalysis)
{
LogMgr.log (TestAnalysisPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (TestAnalysis)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a TestAnalysis");
}
}
else
{
PersistentSet test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new TestAnalysis ();
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 (TestAnalysisPersistence, 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}test_analysis " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (TestAnalysis.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY test_analysis.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: test_analysis.object_id is not null
String preFilter = "(test_analysis.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}test_analysis " + 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 test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis", PersistentSetStatus.FETCHED);
// Object Modified
test_analysisPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
test_analysisPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
test_analysisPSet.setAttrib(TestAnalysis.SINGLEREFERENCE_Level, r.getObject ("level_id"));
test_analysisPSet.setAttrib(TestAnalysis.SINGLEREFERENCE_Candidate, r.getObject ("candidate_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis");
if (test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED &&
test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}test_analysis " +
" ( level_id, candidate_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" ( ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils .listEntry (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Candidate)))) .listEntry (objectID.longID ()).toList().toArray());
test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
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