Commit 8c2028a6 by Nilu

Bo changes. added search and multi ref to where possible.

parent 86187315
...@@ -13,4 +13,8 @@ ...@@ -13,4 +13,8 @@
<column name="quest_number" type="Long" length="11" nullable="true"/> <column name="quest_number" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="factor_lin" indexName="idx_factor_lin_factor_number" isUnique="false"><column name="factor_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="factor_lin" indexName="idx_factor_lin_quest_number" isUnique="false"><column name="quest_number"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -10,10 +10,16 @@ ...@@ -10,10 +10,16 @@
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="from_score" type="Long" nullable="true"/> <column name="from_score" type="Long" nullable="true"/>
<column name="to_score" type="Long" nullable="true"/> <column name="to_score" type="Long" nullable="true"/>
<column name="narrative_code" type="String" nullable="true" length="15"/>
<column name="color_code" type="String" nullable="true" length="200"/> <column name="color_code" type="String" nullable="true" length="200"/>
<column name="factor_number" type="Long" length="11" nullable="true"/> <column name="factor_number" type="Long" length="11" nullable="true"/>
<column name="level_number" type="Long" length="11" nullable="true"/> <column name="level_number" type="Long" length="11" nullable="true"/>
<column name="narrative_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="level_factor" indexName="idx_level_factor_factor_number" isUnique="false"><column name="factor_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="level_factor" indexName="idx_level_factor_level_number" isUnique="false"><column name="level_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="level_factor" indexName="idx_level_factor_narrative_id" isUnique="false"><column name="narrative_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">narrative</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="narrative_code" type="String" nullable="false" length="15"/>
<column name="narrative_desc" type="String" nullable="true" length="30"/>
<column name="graphic_notes" type="CLOB" nullable="true"/>
<column name="exec_sum_notes" type="CLOB" nullable="true"/>
<column name="mod_connect_flag" type="String" nullable="true" length="15"/>
<column name="narrative_notes" type="CLOB" nullable="true"/>
<column name="devel_narrative" type="String" nullable="true" length="128"/>
<column name="question" type="CLOB" nullable="true"/>
<column name="level_number" type="Long" length="11" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
...@@ -23,3 +23,8 @@ ALTER TABLE factor_lin ADD ...@@ -23,3 +23,8 @@ ALTER TABLE factor_lin ADD
CREATE INDEX idx_factor_lin_factor_number
ON factor_lin (factor_number);
CREATE INDEX idx_factor_lin_quest_number
ON factor_lin (quest_number);
...@@ -10,10 +10,10 @@ CREATE TABLE level_factor ( ...@@ -10,10 +10,10 @@ CREATE TABLE level_factor (
, ,
from_score numeric(12) NULL, from_score numeric(12) NULL,
to_score numeric(12) NULL, to_score numeric(12) NULL,
narrative_code varchar(15) NULL,
color_code varchar(200) NULL, color_code varchar(200) NULL,
factor_number numeric(12) NULL, factor_number numeric(12) NULL,
level_number numeric(12) NULL level_number numeric(12) NULL,
narrative_id numeric(12) NULL
); );
...@@ -26,3 +26,11 @@ ALTER TABLE level_factor ADD ...@@ -26,3 +26,11 @@ ALTER TABLE level_factor ADD
CREATE INDEX idx_level_factor_factor_number
ON level_factor (factor_number);
CREATE INDEX idx_level_factor_level_number
ON level_factor (level_number);
CREATE INDEX idx_level_factor_narrative_id
ON level_factor (narrative_id);
-- DROP TABLE narrative;
CREATE TABLE narrative (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
narrative_code varchar(15) NOT NULL,
narrative_desc varchar(30) NULL,
graphic_notes text NULL,
exec_sum_notes text NULL,
mod_connect_flag varchar(15) NULL,
narrative_notes text NULL,
devel_narrative varchar(128) NULL,
question text NULL,
level_number numeric(12) NULL
);
ALTER TABLE narrative ADD
CONSTRAINT PK_narrative PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -24,3 +24,8 @@ ALTER TABLE factor_lin ADD ...@@ -24,3 +24,8 @@ ALTER TABLE factor_lin ADD
CREATE INDEX idx_factor_lin_factor_number
ON factor_lin (factor_number);
CREATE INDEX idx_factor_lin_quest_number
ON factor_lin (quest_number);
...@@ -11,10 +11,10 @@ CREATE TABLE level_factor ( ...@@ -11,10 +11,10 @@ CREATE TABLE level_factor (
, ,
from_score number(12) NULL, from_score number(12) NULL,
to_score number(12) NULL, to_score number(12) NULL,
narrative_code varchar2(15) NULL,
color_code varchar2(200) NULL, color_code varchar2(200) NULL,
factor_number number(12) NULL, factor_number number(12) NULL,
level_number number(12) NULL level_number number(12) NULL,
narrative_id number(12) NULL
); );
...@@ -27,3 +27,11 @@ ALTER TABLE level_factor ADD ...@@ -27,3 +27,11 @@ ALTER TABLE level_factor ADD
CREATE INDEX idx_level_factor_factor_number
ON level_factor (factor_number);
CREATE INDEX idx_level_factor_level_number
ON level_factor (level_number);
CREATE INDEX idx_level_factor_narrative_id
ON level_factor (narrative_id);
-- DROP TABLE narrative;
CREATE TABLE narrative (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
narrative_code varchar2(15) NOT NULL,
narrative_desc varchar2(30) NULL,
graphic_notes clob NULL,
exec_sum_notes clob NULL,
mod_connect_flag varchar2(15) NULL,
narrative_notes clob NULL,
devel_narrative varchar2(128) NULL,
question clob NULL,
level_number number(12) NULL
);
ALTER TABLE narrative ADD
CONSTRAINT PK_narrative PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -24,3 +24,8 @@ ALTER TABLE factor_lin ADD ...@@ -24,3 +24,8 @@ ALTER TABLE factor_lin ADD
CREATE INDEX idx_factor_lin_factor_number
ON factor_lin (factor_number);
CREATE INDEX idx_factor_lin_quest_number
ON factor_lin (quest_number);
...@@ -11,10 +11,10 @@ CREATE TABLE level_factor ( ...@@ -11,10 +11,10 @@ CREATE TABLE level_factor (
, ,
from_score numeric(12) NULL, from_score numeric(12) NULL,
to_score numeric(12) NULL, to_score numeric(12) NULL,
narrative_code varchar(15) NULL,
color_code varchar(200) NULL, color_code varchar(200) NULL,
factor_number numeric(12) NULL, factor_number numeric(12) NULL,
level_number numeric(12) NULL level_number numeric(12) NULL,
narrative_id numeric(12) NULL
); );
...@@ -27,3 +27,11 @@ ALTER TABLE level_factor ADD ...@@ -27,3 +27,11 @@ ALTER TABLE level_factor ADD
CREATE INDEX idx_level_factor_factor_number
ON level_factor (factor_number);
CREATE INDEX idx_level_factor_level_number
ON level_factor (level_number);
CREATE INDEX idx_level_factor_narrative_id
ON level_factor (narrative_id);
-- @AutoRun
-- drop table narrative;
CREATE TABLE narrative (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
narrative_code varchar(15) NOT NULL,
narrative_desc varchar(30) NULL,
graphic_notes text NULL,
exec_sum_notes text NULL,
mod_connect_flag varchar(15) NULL,
narrative_notes text NULL,
devel_narrative varchar(128) NULL,
question text NULL,
level_number numeric(12) NULL
);
ALTER TABLE narrative ADD
CONSTRAINT pk_narrative PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="answer.object_id is not null" orderBy="answer.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -251,6 +251,10 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -251,6 +251,10 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
} }
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
...@@ -362,6 +366,44 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -362,6 +366,44 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (Answer.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY answer.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: answer.object_id is not null
String preFilter = "(answer.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}answer " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
...@@ -43,6 +43,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -43,6 +43,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
public static final String SINGLEREFERENCE_Question = "Question"; public static final String SINGLEREFERENCE_Question = "Question";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -1017,6 +1018,75 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -1017,6 +1018,75 @@ public abstract class BaseAnswer extends BaseBusinessClass
} }
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Answer>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "answer.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "answer.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "answer.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andAnswerNo (QueryFilter<Integer> filter)
{
filter.addFilter (context, "answer.answer_number", "AnswerNo");
return this;
}
public SearchAll andCandidate (QueryFilter<Candidate> filter)
{
filter.addFilter (context, "answer.candidate_id", "Candidate");
return this;
}
public SearchAll andQuestion (QueryFilter<Question> filter)
{
filter.addFilter (context, "answer.quest_number", "Question");
return this;
}
public Answer[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Answer, SEARCH_All, criteria);
Set<Answer> typedResults = new LinkedHashSet <Answer> ();
for (BaseBusinessClass bbcResult : results)
{
Answer aResult = (Answer)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Answer[0]);
}
}
public static Answer[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
......
...@@ -54,6 +54,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -54,6 +54,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
public static final String FIELD_Email = "Email"; public static final String FIELD_Email = "Email";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -2617,6 +2618,141 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2617,6 +2618,141 @@ public abstract class BaseCandidate extends BaseBusinessClass
} }
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Candidate>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "candidate.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "candidate.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "candidate.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andFirstName (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.first_name", "FirstName");
return this;
}
public SearchAll andMiddleName (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.middle_name", "MiddleName");
return this;
}
public SearchAll andLastName (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.last_name", "LastName");
return this;
}
public SearchAll andPreferredName (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.preferred_name", "PreferredName");
return this;
}
public SearchAll andSalutation (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.salutation", "Salutation");
return this;
}
public SearchAll andPosition (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.position", "Position");
return this;
}
public SearchAll andDateOfBirth (QueryFilter<Date> filter)
{
filter.addFilter (context, "candidate.date_of_birth", "DateOfBirth");
return this;
}
public SearchAll andDateRegistered (QueryFilter<Date> filter)
{
filter.addFilter (context, "candidate.date_registered", "DateRegistered");
return this;
}
public SearchAll andGender (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.gender", "Gender");
return this;
}
public SearchAll andPassword (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.password", "Password");
return this;
}
public SearchAll andDateTaken (QueryFilter<Date> filter)
{
filter.addFilter (context, "candidate.date_taken", "DateTaken");
return this;
}
public SearchAll andLocation (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.location", "Location");
return this;
}
public SearchAll andPhone (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.contact_phone", "Phone");
return this;
}
public SearchAll andEmail (QueryFilter<String> filter)
{
filter.addFilter (context, "candidate.email", "Email");
return this;
}
public Candidate[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Candidate, SEARCH_All, criteria);
Set<Candidate> typedResults = new LinkedHashSet <Candidate> ();
for (BaseBusinessClass bbcResult : results)
{
Candidate aResult = (Candidate)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Candidate[0]);
}
}
public static Candidate[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
......
...@@ -39,10 +39,15 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -39,10 +39,15 @@ public abstract class BaseFactor extends BaseBusinessClass
// Static constants corresponding to field names // Static constants corresponding to field names
public static final String FIELD_Description = "Description"; public static final String FIELD_Description = "Description";
public static final String MULTIPLEREFERENCE_FactorLinks = "FactorLinks"; public static final String MULTIPLEREFERENCE_Levels = "Levels";
public static final String BACKREF_FactorLinks = ""; public static final String BACKREF_Levels = "";
public static final String MULTIPLEREFERENCE_Questions = "Questions";
public static final String BACKREF_Questions = "";
public static final String MULTIPLEREFERENCE_Results = "Results";
public static final String BACKREF_Results = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -57,7 +62,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -57,7 +62,9 @@ public abstract class BaseFactor extends BaseBusinessClass
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
private MultipleAssociation<Factor, FactorLevelLink> _FactorLinks; private MultipleAssociation<Factor, FactorLevelLink> _Levels;
private MultipleAssociation<Factor, FactorQuestionLink> _Questions;
private MultipleAssociation<Factor, FactorScoreResult> _Results;
// Map of maps of metadata // Map of maps of metadata
...@@ -75,11 +82,15 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -75,11 +82,15 @@ public abstract class BaseFactor extends BaseBusinessClass
try try
{ {
String tmp_FactorLinks = FactorLevelLink.BACKREF_Factor; String tmp_Levels = FactorLevelLink.BACKREF_Factor;
String tmp_Questions = FactorQuestionLink.BACKREF_Factor;
String tmp_Results = FactorScoreResult.BACKREF_Factor;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_FactorLinks(); setupAssocMetaData_Levels();
setupAssocMetaData_Questions();
setupAssocMetaData_Results();
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -96,16 +107,44 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -96,16 +107,44 @@ public abstract class BaseFactor extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_FactorLinks() private static void setupAssocMetaData_Levels()
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Factor"); metaInfo.put ("backreferenceName", "Factor");
metaInfo.put ("name", "FactorLinks"); metaInfo.put ("name", "Levels");
metaInfo.put ("type", "FactorLevelLink"); metaInfo.put ("type", "FactorLevelLink");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.FactorLinks:", metaInfo); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.Levels:", metaInfo);
ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_FactorLinks, Collections.unmodifiableMap (metaInfo)); ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_Levels, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Questions()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Factor");
metaInfo.put ("name", "Questions");
metaInfo.put ("type", "FactorQuestionLink");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.Questions:", metaInfo);
ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_Questions, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Results()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Factor");
metaInfo.put ("name", "Results");
metaInfo.put ("type", "FactorScoreResult");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.Results:", metaInfo);
ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_Results, Collections.unmodifiableMap (metaInfo));
} }
...@@ -164,7 +203,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -164,7 +203,9 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_FactorLinks = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_FactorLinks, FactorLevelLink.SINGLEREFERENCE_Factor, FactorLevelLink.REFERENCE_FactorLevelLink); _Levels = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_Levels, FactorLevelLink.SINGLEREFERENCE_Factor, FactorLevelLink.REFERENCE_FactorLevelLink);
_Questions = new MultipleAssociation<Factor, FactorQuestionLink> (this, MULTIPLEREFERENCE_Questions, FactorQuestionLink.SINGLEREFERENCE_Factor, FactorQuestionLink.REFERENCE_FactorQuestionLink);
_Results = new MultipleAssociation<Factor, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Factor, FactorScoreResult.REFERENCE_FactorScoreResult);
} }
...@@ -174,7 +215,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -174,7 +215,9 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_FactorLinks = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_FactorLinks, FactorLevelLink.SINGLEREFERENCE_Factor, FactorLevelLink.REFERENCE_FactorLevelLink); _Levels = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_Levels, FactorLevelLink.SINGLEREFERENCE_Factor, FactorLevelLink.REFERENCE_FactorLevelLink);
_Questions = new MultipleAssociation<Factor, FactorQuestionLink> (this, MULTIPLEREFERENCE_Questions, FactorQuestionLink.SINGLEREFERENCE_Factor, FactorQuestionLink.REFERENCE_FactorQuestionLink);
_Results = new MultipleAssociation<Factor, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Factor, FactorScoreResult.REFERENCE_FactorScoreResult);
return this; return this;
...@@ -388,7 +431,11 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -388,7 +431,11 @@ public abstract class BaseFactor extends BaseBusinessClass
List result = super.getMultiAssocs (); List result = super.getMultiAssocs ();
result.add("FactorLinks"); result.add("Levels");
result.add("Questions");
result.add("Results");
return result; return result;
...@@ -401,11 +448,21 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -401,11 +448,21 @@ public abstract class BaseFactor extends BaseBusinessClass
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName) public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{ {
return FactorLevelLink.REFERENCE_FactorLevelLink ; return FactorLevelLink.REFERENCE_FactorLevelLink ;
} }
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return FactorQuestionLink.REFERENCE_FactorQuestionLink ;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return FactorScoreResult.REFERENCE_FactorScoreResult ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -414,11 +471,21 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -414,11 +471,21 @@ public abstract class BaseFactor extends BaseBusinessClass
public String getMultiAssocBackReference(String attribName) public String getMultiAssocBackReference(String attribName)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{ {
return FactorLevelLink.SINGLEREFERENCE_Factor ; return FactorLevelLink.SINGLEREFERENCE_Factor ;
} }
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return FactorQuestionLink.SINGLEREFERENCE_Factor ;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return FactorScoreResult.SINGLEREFERENCE_Factor ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -430,9 +497,19 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -430,9 +497,19 @@ public abstract class BaseFactor extends BaseBusinessClass
public int getMultiAssocCount(String attribName) throws StorageException public int getMultiAssocCount(String attribName) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{ {
return this.getFactorLinksCount(); return this.getLevelsCount();
}
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return this.getQuestionsCount();
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return this.getResultsCount();
} }
...@@ -446,9 +523,19 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -446,9 +523,19 @@ public abstract class BaseFactor extends BaseBusinessClass
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{
return this.getLevelsAt(index);
}
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return this.getQuestionsAt(index);
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{ {
return this.getFactorLinksAt(index); return this.getResultsAt(index);
} }
...@@ -462,9 +549,23 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -462,9 +549,23 @@ public abstract class BaseFactor extends BaseBusinessClass
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{
addToLevels((FactorLevelLink)newElement);
return;
}
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
addToQuestions((FactorQuestionLink)newElement);
return;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{ {
addToFactorLinks((FactorLevelLink)newElement); addToResults((FactorScoreResult)newElement);
return; return;
} }
...@@ -479,9 +580,23 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -479,9 +580,23 @@ public abstract class BaseFactor extends BaseBusinessClass
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{ {
removeFromFactorLinks((FactorLevelLink)oldElement); removeFromLevels((FactorLevelLink)oldElement);
return;
}
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
removeFromQuestions((FactorQuestionLink)oldElement);
return;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
removeFromResults((FactorScoreResult)oldElement);
return; return;
} }
...@@ -494,9 +609,21 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -494,9 +609,21 @@ public abstract class BaseFactor extends BaseBusinessClass
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements) protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{
_Levels.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
_Questions.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{ {
_FactorLinks.__loadAssociation (elements); _Results.__loadAssociation (elements);
return; return;
} }
...@@ -508,9 +635,19 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -508,9 +635,19 @@ public abstract class BaseFactor extends BaseBusinessClass
protected boolean __isMultiAssocLoaded (String attribName) protected boolean __isMultiAssocLoaded (String attribName)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Levels.equals(attribName))
{
return _Levels.isLoaded ();
}
if (MULTIPLEREFERENCE_Questions.equals(attribName))
{
return _Questions.isLoaded ();
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{ {
return _FactorLinks.isLoaded (); return _Results.isLoaded ();
} }
...@@ -519,26 +656,26 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -519,26 +656,26 @@ public abstract class BaseFactor extends BaseBusinessClass
public FieldWriteability getWriteability_FactorLinks () public FieldWriteability getWriteability_Levels ()
{ {
return getFieldWritabilityUtil (FieldWriteability.TRUE); return getFieldWritabilityUtil (FieldWriteability.TRUE);
} }
public int getFactorLinksCount () throws StorageException public int getLevelsCount () throws StorageException
{ {
assertValid(); assertValid();
return _FactorLinks.getReferencedObjectsCount (); return _Levels.getReferencedObjectsCount ();
} }
public void addToFactorLinks (FactorLevelLink newElement) throws StorageException public void addToLevels (FactorLevelLink newElement) throws StorageException
{ {
if (_FactorLinks.wouldAddChange (newElement)) if (_Levels.wouldAddChange (newElement))
{ {
assertValid(); assertValid();
Debug.assertion (getWriteability_FactorLinks () != FieldWriteability.FALSE, "MultiAssoc FactorLinks is not writeable (add)"); Debug.assertion (getWriteability_Levels () != FieldWriteability.FALSE, "MultiAssoc Levels is not writeable (add)");
_FactorLinks.appendElement (newElement); _Levels.appendElement (newElement);
try try
{ {
...@@ -555,13 +692,13 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -555,13 +692,13 @@ public abstract class BaseFactor extends BaseBusinessClass
} }
public void removeFromFactorLinks (FactorLevelLink elementToRemove) throws StorageException public void removeFromLevels (FactorLevelLink elementToRemove) throws StorageException
{ {
if (_FactorLinks.wouldRemoveChange (elementToRemove)) if (_Levels.wouldRemoveChange (elementToRemove))
{ {
assertValid(); assertValid();
Debug.assertion (getWriteability_FactorLinks () != FieldWriteability.FALSE, "MultiAssoc FactorLinks is not writeable (remove)"); Debug.assertion (getWriteability_Levels () != FieldWriteability.FALSE, "MultiAssoc Levels is not writeable (remove)");
_FactorLinks.removeElement (elementToRemove); _Levels.removeElement (elementToRemove);
try try
{ {
if (elementToRemove.getFactor () != null) if (elementToRemove.getFactor () != null)
...@@ -577,15 +714,153 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -577,15 +714,153 @@ public abstract class BaseFactor extends BaseBusinessClass
} }
public FactorLevelLink getFactorLinksAt (int index) throws StorageException public FactorLevelLink getLevelsAt (int index) throws StorageException
{ {
return (FactorLevelLink)(_FactorLinks.getElementAt (index)); return (FactorLevelLink)(_Levels.getElementAt (index));
} }
public SortedSet<FactorLevelLink> getFactorLinksSet () throws StorageException public SortedSet<FactorLevelLink> getLevelsSet () throws StorageException
{ {
return _FactorLinks.getSet (); return _Levels.getSet ();
}
public FieldWriteability getWriteability_Questions ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getQuestionsCount () throws StorageException
{
assertValid();
return _Questions.getReferencedObjectsCount ();
}
public void addToQuestions (FactorQuestionLink newElement) throws StorageException
{
if (_Questions.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Questions () != FieldWriteability.FALSE, "MultiAssoc Questions is not writeable (add)");
_Questions.appendElement (newElement);
try
{
if (newElement.getFactor () != this)
{
newElement.setFactor ((Factor)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromQuestions (FactorQuestionLink elementToRemove) throws StorageException
{
if (_Questions.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Questions () != FieldWriteability.FALSE, "MultiAssoc Questions is not writeable (remove)");
_Questions.removeElement (elementToRemove);
try
{
if (elementToRemove.getFactor () != null)
{
elementToRemove.setFactor (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public FactorQuestionLink getQuestionsAt (int index) throws StorageException
{
return (FactorQuestionLink)(_Questions.getElementAt (index));
}
public SortedSet<FactorQuestionLink> getQuestionsSet () throws StorageException
{
return _Questions.getSet ();
}
public FieldWriteability getWriteability_Results ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getResultsCount () throws StorageException
{
assertValid();
return _Results.getReferencedObjectsCount ();
}
public void addToResults (FactorScoreResult newElement) throws StorageException
{
if (_Results.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (add)");
_Results.appendElement (newElement);
try
{
if (newElement.getFactor () != this)
{
newElement.setFactor ((Factor)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromResults (FactorScoreResult elementToRemove) throws StorageException
{
if (_Results.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (remove)");
_Results.removeElement (elementToRemove);
try
{
if (elementToRemove.getFactor () != null)
{
elementToRemove.setFactor (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public FactorScoreResult getResultsAt (int index) throws StorageException
{
return (FactorScoreResult)(_Results.getElementAt (index));
}
public SortedSet<FactorScoreResult> getResultsSet () throws StorageException
{
return _Results.getSet ();
} }
...@@ -594,7 +869,19 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -594,7 +869,19 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
try try
{ {
for(FactorLevelLink referenced : CollectionUtils.reverse(getFactorLinksSet())) for(FactorLevelLink referenced : CollectionUtils.reverse(getLevelsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factor from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setFactor(null);
}
for(FactorQuestionLink referenced : CollectionUtils.reverse(getQuestionsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factor from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setFactor(null);
}
for(FactorScoreResult referenced : CollectionUtils.reverse(getResultsSet()))
{ {
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factor from ", getObjectID (), " to ", referenced.getObjectID ()); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factor from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setFactor(null); referenced.setFactor(null);
...@@ -748,7 +1035,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -748,7 +1035,9 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
BaseFactor sourceFactor = (BaseFactor)(source); BaseFactor sourceFactor = (BaseFactor)(source);
_FactorLinks.copyFrom (sourceFactor._FactorLinks, linkToGhosts); _Levels.copyFrom (sourceFactor._Levels, linkToGhosts);
_Questions.copyFrom (sourceFactor._Questions, linkToGhosts);
_Results.copyFrom (sourceFactor._Results, linkToGhosts);
} }
} }
...@@ -770,7 +1059,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -770,7 +1059,9 @@ public abstract class BaseFactor extends BaseBusinessClass
super.readExternalData(vals); super.readExternalData(vals);
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); // _Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_FactorLinks.readExternalData(vals.get(MULTIPLEREFERENCE_FactorLinks)); _Levels.readExternalData(vals.get(MULTIPLEREFERENCE_Levels));
_Questions.readExternalData(vals.get(MULTIPLEREFERENCE_Questions));
_Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
} }
...@@ -783,7 +1074,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -783,7 +1074,9 @@ public abstract class BaseFactor extends BaseBusinessClass
super.writeExternalData(vals); super.writeExternalData(vals);
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description)); vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (MULTIPLEREFERENCE_FactorLinks, _FactorLinks.writeExternalData()); vals.put (MULTIPLEREFERENCE_Levels, _Levels.writeExternalData());
vals.put (MULTIPLEREFERENCE_Questions, _Questions.writeExternalData());
vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
} }
...@@ -806,7 +1099,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -806,7 +1099,9 @@ public abstract class BaseFactor extends BaseBusinessClass
// Compare multiple assocs // Compare multiple assocs
_FactorLinks.compare (otherFactor._FactorLinks, listener); _Levels.compare (otherFactor._Levels, listener);
_Questions.compare (otherFactor._Questions, listener);
_Results.compare (otherFactor._Results, listener);
} }
} }
...@@ -825,7 +1120,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -825,7 +1120,9 @@ public abstract class BaseFactor extends BaseBusinessClass
super.visitAttributes (visitor); super.visitAttributes (visitor);
visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription())); visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription()));
visitor.visitAssociation (_FactorLinks); visitor.visitAssociation (_Levels);
visitor.visitAssociation (_Questions);
visitor.visitAssociation (_Results);
} }
...@@ -834,9 +1131,17 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -834,9 +1131,17 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
super.visitAssociations (visitor, scope); super.visitAssociations (visitor, scope);
if (scope.includes (_FactorLinks)) if (scope.includes (_Levels))
{
visitor.visit (_Levels);
}
if (scope.includes (_Questions))
{ {
visitor.visit (_FactorLinks); visitor.visit (_Questions);
}
if (scope.includes (_Results))
{
visitor.visit (_Results);
} }
} }
...@@ -874,6 +1179,63 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -874,6 +1179,63 @@ public abstract class BaseFactor extends BaseBusinessClass
} }
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Factor>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "factor.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "factor.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "factor.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "factor.factor_hdr_desc", "Description");
return this;
}
public Factor[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Factor, SEARCH_All, criteria);
Set<Factor> typedResults = new LinkedHashSet <Factor> ();
for (BaseBusinessClass bbcResult : results)
{
Factor aResult = (Factor)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Factor[0]);
}
}
public static Factor[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
...@@ -944,9 +1306,17 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -944,9 +1306,17 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
return getWriteability_Description (); return getWriteability_Description ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_FactorLinks)) else if (fieldName.equals (MULTIPLEREFERENCE_Levels))
{
return getWriteability_Levels ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Questions))
{ {
return getWriteability_FactorLinks (); return getWriteability_Questions ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Results))
{
return getWriteability_Results ();
} }
else else
{ {
...@@ -1093,9 +1463,17 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1093,9 +1463,17 @@ public abstract class BaseFactor extends BaseBusinessClass
public PipeLine<From, ? extends Object> to(String name) public PipeLine<From, ? extends Object> to(String name)
{ {
if (name.equals ("FactorLinks")) if (name.equals ("Levels"))
{
return toLevels ();
}
if (name.equals ("Questions"))
{
return toQuestions ();
}
if (name.equals ("Results"))
{ {
return toFactorLinks (); return toResults ();
} }
if (name.equals ("Description")) if (name.equals ("Description"))
{ {
...@@ -1108,11 +1486,23 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1108,11 +1486,23 @@ public abstract class BaseFactor extends BaseBusinessClass
public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); } public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); }
public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactorLinks () { return toFactorLinks(Filter.ALL); } public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toLevels () { return toLevels(Filter.ALL); }
public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactorLinks (Filter<FactorLevelLink> filter) public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toLevels (Filter<FactorLevelLink> filter)
{ {
return FactorLevelLink.REFERENCE_FactorLevelLink.new FactorLevelLinkPipeLineFactory<From, FactorLevelLink> (this, new ORMMultiAssocPipe<Me, FactorLevelLink>(MULTIPLEREFERENCE_FactorLinks, filter)); return FactorLevelLink.REFERENCE_FactorLevelLink.new FactorLevelLinkPipeLineFactory<From, FactorLevelLink> (this, new ORMMultiAssocPipe<Me, FactorLevelLink>(MULTIPLEREFERENCE_Levels, filter));
}
public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toQuestions () { return toQuestions(Filter.ALL); }
public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toQuestions (Filter<FactorQuestionLink> filter)
{
return FactorQuestionLink.REFERENCE_FactorQuestionLink.new FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> (this, new ORMMultiAssocPipe<Me, FactorQuestionLink>(MULTIPLEREFERENCE_Questions, filter));
}
public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults () { return toResults(Filter.ALL); }
public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults (Filter<FactorScoreResult> filter)
{
return FactorScoreResult.REFERENCE_FactorScoreResult.new FactorScoreResultPipeLineFactory<From, FactorScoreResult> (this, new ORMMultiAssocPipe<Me, FactorScoreResult>(MULTIPLEREFERENCE_Results, filter));
} }
} }
...@@ -1145,19 +1535,53 @@ class DummyFactor extends Factor ...@@ -1145,19 +1535,53 @@ class DummyFactor extends Factor
} }
public int getFactorLinksCount () throws StorageException public int getLevelsCount () throws StorageException
{
return 0;
}
public FactorLevelLink getLevelsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Levels");
}
public SortedSet getLevelsSet () throws StorageException
{
return new TreeSet();
}
public int getQuestionsCount () throws StorageException
{
return 0;
}
public FactorQuestionLink getQuestionsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Questions");
}
public SortedSet getQuestionsSet () throws StorageException
{
return new TreeSet();
}
public int getResultsCount () throws StorageException
{ {
return 0; return 0;
} }
public FactorLevelLink getFactorLinksAt (int index) throws StorageException public FactorScoreResult getResultsAt (int index) throws StorageException
{ {
throw new RuntimeException ("No elements in a dummy object in association FactorLinks"); throw new RuntimeException ("No elements in a dummy object in association Results");
} }
public SortedSet getFactorLinksSet () throws StorageException public SortedSet getResultsSet () throws StorageException
{ {
return new TreeSet(); return new TreeSet();
} }
......
...@@ -51,6 +51,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -51,6 +51,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
public static final String BACKREF_Factor = ""; public static final String BACKREF_Factor = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -102,8 +103,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -102,8 +103,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
try try
{ {
String tmp_Level = Level.BACKREF_FactorLinks; String tmp_Level = Level.BACKREF_Factors;
String tmp_Factor = Factor.BACKREF_FactorLinks; String tmp_Factor = Factor.BACKREF_Levels;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
...@@ -135,7 +136,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -135,7 +136,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "FactorLinks"); metaInfo.put ("backreferenceName", "Factors");
metaInfo.put ("dbcol", "level_number"); metaInfo.put ("dbcol", "level_number");
metaInfo.put ("name", "Level"); metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level"); metaInfo.put ("type", "Level");
...@@ -150,7 +151,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -150,7 +151,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "FactorLinks"); metaInfo.put ("backreferenceName", "Levels");
metaInfo.put ("dbcol", "factor_number"); metaInfo.put ("dbcol", "factor_number");
metaInfo.put ("name", "Factor"); metaInfo.put ("name", "Factor");
metaInfo.put ("type", "Factor"); metaInfo.put ("type", "Factor");
...@@ -332,8 +333,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -332,8 +333,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_FactorLinks, Level.REFERENCE_Level, "factor_hdr"); _Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Factors, Level.REFERENCE_Level, "factor_hdr");
_Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_FactorLinks, Factor.REFERENCE_Factor, "factor_hdr"); _Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Levels, Factor.REFERENCE_Factor, "factor_hdr");
} }
...@@ -343,8 +344,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -343,8 +344,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_FactorLinks, Level.REFERENCE_Level, "factor_hdr"); _Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Factors, Level.REFERENCE_Level, "factor_hdr");
_Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_FactorLinks, Factor.REFERENCE_Factor, "factor_hdr"); _Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Levels, Factor.REFERENCE_Factor, "factor_hdr");
return this; return this;
...@@ -1085,10 +1086,10 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1085,10 +1086,10 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
} }
else if (assocName.equals (SINGLEREFERENCE_Level)) else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return Level.MULTIPLEREFERENCE_FactorLinks ; return Level.MULTIPLEREFERENCE_Factors ;
}else if (assocName.equals (SINGLEREFERENCE_Factor)) }else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return Factor.MULTIPLEREFERENCE_FactorLinks ; return Factor.MULTIPLEREFERENCE_Levels ;
} }
else else
{ {
...@@ -1271,14 +1272,14 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1271,14 +1272,14 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
// This is to stop validation from triggering when we are removed // This is to stop validation from triggering when we are removed
_Level.set (null); _Level.set (null);
oldLevel.removeFromFactorLinks ((FactorLevelLink)(this)); oldLevel.removeFromFactors ((FactorLevelLink)(this));
} }
_Level.set (newLevel); _Level.set (newLevel);
if (newLevel != null) if (newLevel != null)
{ {
newLevel.addToFactorLinks ((FactorLevelLink)(this)); newLevel.addToFactors ((FactorLevelLink)(this));
} }
postLevelChange (); postLevelChange ();
...@@ -1378,14 +1379,14 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1378,14 +1379,14 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
// This is to stop validation from triggering when we are removed // This is to stop validation from triggering when we are removed
_Factor.set (null); _Factor.set (null);
oldFactor.removeFromFactorLinks ((FactorLevelLink)(this)); oldFactor.removeFromLevels ((FactorLevelLink)(this));
} }
_Factor.set (newFactor); _Factor.set (newFactor);
if (newFactor != null) if (newFactor != null)
{ {
newFactor.addToFactorLinks ((FactorLevelLink)(this)); newFactor.addToLevels ((FactorLevelLink)(this));
} }
postFactorChange (); postFactorChange ();
...@@ -1498,9 +1499,9 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1498,9 +1499,9 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
if (referenced != null) if (referenced != null)
{ {
// Stop the callback // Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null FactorLinks from ", getObjectID (), " to ", referenced.getObjectID ()); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factors from ", getObjectID (), " to ", referenced.getObjectID ());
_Level.set (null); _Level.set (null);
referenced.removeFromFactorLinks ((FactorLevelLink)this); referenced.removeFromFactors ((FactorLevelLink)this);
} }
} }
...@@ -1512,9 +1513,9 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1512,9 +1513,9 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
if (referenced != null) if (referenced != null)
{ {
// Stop the callback // Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null FactorLinks from ", getObjectID (), " to ", referenced.getObjectID ()); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Levels from ", getObjectID (), " to ", referenced.getObjectID ());
_Factor.set (null); _Factor.set (null);
referenced.removeFromFactorLinks ((FactorLevelLink)this); referenced.removeFromLevels ((FactorLevelLink)this);
} }
} }
...@@ -1951,6 +1952,111 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1951,6 +1952,111 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
} }
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<FactorLevelLink>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "factor_hdr.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "factor_hdr.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "factor_hdr.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "factor_hdr.factor_hdr_desc", "Description");
return this;
}
public SearchAll andClassCode (QueryFilter<String> filter)
{
filter.addFilter (context, "factor_hdr.class_code", "ClassCode");
return this;
}
public SearchAll andNotes (QueryFilter<String> filter)
{
filter.addFilter (context, "factor_hdr.factor_hdr_notes", "Notes");
return this;
}
public SearchAll andLeftAnnot (QueryFilter<String> filter)
{
filter.addFilter (context, "factor_hdr.left_annot", "LeftAnnot");
return this;
}
public SearchAll andRightAnnot (QueryFilter<String> filter)
{
filter.addFilter (context, "factor_hdr.right_annot", "RightAnnot");
return this;
}
public SearchAll andZScoreWeight (QueryFilter<Double> filter)
{
filter.addFilter (context, "factor_hdr.z_score_wght", "ZScoreWeight");
return this;
}
public SearchAll andZScoreWeight2 (QueryFilter<Double> filter)
{
filter.addFilter (context, "factor_hdr.z_score_wght_2", "ZScoreWeight2");
return this;
}
public SearchAll andLevel (QueryFilter<Level> filter)
{
filter.addFilter (context, "factor_hdr.level_number", "Level");
return this;
}
public SearchAll andFactor (QueryFilter<Factor> filter)
{
filter.addFilter (context, "factor_hdr.factor_number", "Factor");
return this;
}
public FactorLevelLink[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_FactorLevelLink, SEARCH_All, criteria);
Set<FactorLevelLink> typedResults = new LinkedHashSet <FactorLevelLink> ();
for (BaseBusinessClass bbcResult : results)
{
FactorLevelLink aResult = (FactorLevelLink)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new FactorLevelLink[0]);
}
}
public static FactorLevelLink[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
......
...@@ -40,7 +40,9 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -40,7 +40,9 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
public static final String FIELD_ReverseScore = "ReverseScore"; public static final String FIELD_ReverseScore = "ReverseScore";
public static final String SINGLEREFERENCE_Factor = "Factor"; public static final String SINGLEREFERENCE_Factor = "Factor";
public static final String BACKREF_Factor = "";
public static final String SINGLEREFERENCE_Question = "Question"; public static final String SINGLEREFERENCE_Question = "Question";
public static final String BACKREF_Question = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -77,6 +79,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -77,6 +79,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
try try
{ {
String tmp_Factor = Factor.BACKREF_Questions;
String tmp_Question = Question.BACKREF_Factors;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
...@@ -102,6 +106,7 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -102,6 +106,7 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Questions");
metaInfo.put ("dbcol", "factor_number"); metaInfo.put ("dbcol", "factor_number");
metaInfo.put ("name", "Factor"); metaInfo.put ("name", "Factor");
metaInfo.put ("type", "Factor"); metaInfo.put ("type", "Factor");
...@@ -116,6 +121,7 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -116,6 +121,7 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Factors");
metaInfo.put ("dbcol", "quest_number"); metaInfo.put ("dbcol", "quest_number");
metaInfo.put ("name", "Question"); metaInfo.put ("name", "Question");
metaInfo.put ("type", "Question"); metaInfo.put ("type", "Question");
...@@ -179,8 +185,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -179,8 +185,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "factor_lin"); _Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Questions, Factor.REFERENCE_Factor, "factor_lin");
_Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, null, Question.REFERENCE_Question, "factor_lin"); _Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, Question.MULTIPLEREFERENCE_Factors, Question.REFERENCE_Question, "factor_lin");
} }
...@@ -190,8 +196,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -190,8 +196,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "factor_lin"); _Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Questions, Factor.REFERENCE_Factor, "factor_lin");
_Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, null, Question.REFERENCE_Question, "factor_lin"); _Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, Question.MULTIPLEREFERENCE_Factors, Question.REFERENCE_Question, "factor_lin");
return this; return this;
...@@ -344,10 +350,10 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -344,10 +350,10 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
} }
else if (assocName.equals (SINGLEREFERENCE_Factor)) else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return null ; return Factor.MULTIPLEREFERENCE_Questions ;
}else if (assocName.equals (SINGLEREFERENCE_Question)) }else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
return null ; return Question.MULTIPLEREFERENCE_Factors ;
} }
else else
{ {
...@@ -524,9 +530,22 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -524,9 +530,22 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Factor () != FieldWriteability.FALSE, "Assoc Factor is not writeable"); Debug.assertion (getWriteability_Factor () != FieldWriteability.FALSE, "Assoc Factor is not writeable");
preFactorChange (newFactor); preFactorChange (newFactor);
Factor oldFactor = getFactor ();
if (oldFactor != null)
{
// This is to stop validation from triggering when we are removed
_Factor.set (null);
oldFactor.removeFromQuestions ((FactorQuestionLink)(this));
}
_Factor.set (newFactor); _Factor.set (newFactor);
if (newFactor != null)
{
newFactor.addToQuestions ((FactorQuestionLink)(this));
}
postFactorChange (); postFactorChange ();
} }
} }
...@@ -618,9 +637,22 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -618,9 +637,22 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Question () != FieldWriteability.FALSE, "Assoc Question is not writeable"); Debug.assertion (getWriteability_Question () != FieldWriteability.FALSE, "Assoc Question is not writeable");
preQuestionChange (newQuestion); preQuestionChange (newQuestion);
Question oldQuestion = getQuestion ();
if (oldQuestion != null)
{
// This is to stop validation from triggering when we are removed
_Question.set (null);
oldQuestion.removeFromFactors ((FactorQuestionLink)(this));
}
_Question.set (newQuestion); _Question.set (newQuestion);
if (newQuestion != null)
{
newQuestion.addToFactors ((FactorQuestionLink)(this));
}
postQuestionChange (); postQuestionChange ();
} }
} }
...@@ -723,6 +755,34 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -723,6 +755,34 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
{ {
try try
{ {
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Factor.isLoaded () || getTransaction ().isObjectLoaded (_Factor.getReferencedType (), getFactorID ()))
{
Factor referenced = getFactor ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Questions from ", getObjectID (), " to ", referenced.getObjectID ());
_Factor.set (null);
referenced.removeFromQuestions ((FactorQuestionLink)this);
}
}
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Question.isLoaded () || getTransaction ().isObjectLoaded (_Question.getReferencedType (), getQuestionID ()))
{
Question referenced = getQuestion ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factors from ", getObjectID (), " to ", referenced.getObjectID ());
_Question.set (null);
referenced.removeFromFactors ((FactorQuestionLink)this);
}
}
} }
catch (Exception e) catch (Exception e)
{ {
......
...@@ -42,10 +42,13 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -42,10 +42,13 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
public static final String FIELD_FromScore = "FromScore"; public static final String FIELD_FromScore = "FromScore";
public static final String FIELD_ToScore = "ToScore"; public static final String FIELD_ToScore = "ToScore";
public static final String FIELD_NarrativeCode = "NarrativeCode";
public static final String FIELD_ColorCode = "ColorCode"; public static final String FIELD_ColorCode = "ColorCode";
public static final String SINGLEREFERENCE_Factor = "Factor"; public static final String SINGLEREFERENCE_Factor = "Factor";
public static final String BACKREF_Factor = "";
public static final String SINGLEREFERENCE_Level = "Level"; public static final String SINGLEREFERENCE_Level = "Level";
public static final String BACKREF_Level = "";
public static final String SINGLEREFERENCE_Narrative = "Narrative";
public static final String BACKREF_Narrative = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -55,20 +58,19 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -55,20 +58,19 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<FactorScoreResult> HELPER_FromScore = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<FactorScoreResult> HELPER_FromScore = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<FactorScoreResult> HELPER_ToScore = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<FactorScoreResult> HELPER_ToScore = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<FactorScoreResult> HELPER_NarrativeCode = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<FactorScoreResult, ColorCode> HELPER_ColorCode = new EnumeratedAttributeHelper<FactorScoreResult, ColorCode> (ColorCode.FACTORY_ColorCode); private static final EnumeratedAttributeHelper<FactorScoreResult, ColorCode> HELPER_ColorCode = new EnumeratedAttributeHelper<FactorScoreResult, ColorCode> (ColorCode.FACTORY_ColorCode);
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private Integer _FromScore; private Integer _FromScore;
private Integer _ToScore; private Integer _ToScore;
private String _NarrativeCode;
private ColorCode _ColorCode; private ColorCode _ColorCode;
// Private attributes corresponding to single references // Private attributes corresponding to single references
private SingleAssociation<FactorScoreResult, Factor> _Factor; private SingleAssociation<FactorScoreResult, Factor> _Factor;
private SingleAssociation<FactorScoreResult, Level> _Level; private SingleAssociation<FactorScoreResult, Level> _Level;
private SingleAssociation<FactorScoreResult, Narrative> _Narrative;
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
...@@ -80,7 +82,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -80,7 +82,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
// Arrays of validators for each attribute // Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_FromScore_Validators; private static final AttributeValidator[] FIELD_FromScore_Validators;
private static final AttributeValidator[] FIELD_ToScore_Validators; private static final AttributeValidator[] FIELD_ToScore_Validators;
private static final AttributeValidator[] FIELD_NarrativeCode_Validators;
private static final AttributeValidator[] FIELD_ColorCode_Validators; private static final AttributeValidator[] FIELD_ColorCode_Validators;
...@@ -92,14 +93,17 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -92,14 +93,17 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
try try
{ {
String tmp_Factor = Factor.BACKREF_Results;
String tmp_Level = Level.BACKREF_Results;
String tmp_Narrative = Narrative.BACKREF_Results;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Factor(); setupAssocMetaData_Factor();
setupAssocMetaData_Level(); setupAssocMetaData_Level();
setupAssocMetaData_Narrative();
FIELD_FromScore_Validators = (AttributeValidator[])setupAttribMetaData_FromScore(validatorMapping).toArray (new AttributeValidator[0]); FIELD_FromScore_Validators = (AttributeValidator[])setupAttribMetaData_FromScore(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ToScore_Validators = (AttributeValidator[])setupAttribMetaData_ToScore(validatorMapping).toArray (new AttributeValidator[0]); FIELD_ToScore_Validators = (AttributeValidator[])setupAttribMetaData_ToScore(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_NarrativeCode_Validators = (AttributeValidator[])setupAttribMetaData_NarrativeCode(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ColorCode_Validators = (AttributeValidator[])setupAttribMetaData_ColorCode(validatorMapping).toArray (new AttributeValidator[0]); FIELD_ColorCode_Validators = (AttributeValidator[])setupAttribMetaData_ColorCode(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -120,6 +124,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -120,6 +124,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Results");
metaInfo.put ("dbcol", "factor_number"); metaInfo.put ("dbcol", "factor_number");
metaInfo.put ("name", "Factor"); metaInfo.put ("name", "Factor");
metaInfo.put ("type", "Factor"); metaInfo.put ("type", "Factor");
...@@ -134,6 +139,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -134,6 +139,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Results");
metaInfo.put ("dbcol", "level_number"); metaInfo.put ("dbcol", "level_number");
metaInfo.put ("name", "Level"); metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level"); metaInfo.put ("type", "Level");
...@@ -144,6 +150,21 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -144,6 +150,21 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Narrative()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Results");
metaInfo.put ("dbcol", "narrative_id");
metaInfo.put ("name", "Narrative");
metaInfo.put ("type", "Narrative");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.Narrative:", metaInfo);
ATTRIBUTES_METADATA_FactorScoreResult.put (SINGLEREFERENCE_Narrative, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_FromScore(Map validatorMapping) private static List setupAttribMetaData_FromScore(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -180,25 +201,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -180,25 +201,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
} }
// Meta Info setup // Meta Info setup
private static List setupAttribMetaData_NarrativeCode(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "narrative_code");
metaInfo.put ("length", "15");
metaInfo.put ("name", "NarrativeCode");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.NarrativeCode:", metaInfo);
ATTRIBUTES_METADATA_FactorScoreResult.put (FIELD_NarrativeCode, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(FactorScoreResult.class, "NarrativeCode", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for FactorScoreResult.NarrativeCode:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ColorCode(Map validatorMapping) private static List setupAttribMetaData_ColorCode(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -246,7 +248,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -246,7 +248,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
_FromScore = (Integer)(HELPER_FromScore.initialise (_FromScore)); _FromScore = (Integer)(HELPER_FromScore.initialise (_FromScore));
_ToScore = (Integer)(HELPER_ToScore.initialise (_ToScore)); _ToScore = (Integer)(HELPER_ToScore.initialise (_ToScore));
_NarrativeCode = (String)(HELPER_NarrativeCode.initialise (_NarrativeCode));
_ColorCode = (ColorCode)(HELPER_ColorCode.initialise (_ColorCode)); _ColorCode = (ColorCode)(HELPER_ColorCode.initialise (_ColorCode));
} }
...@@ -256,8 +257,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -256,8 +257,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "level_factor"); _Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Results, Factor.REFERENCE_Factor, "level_factor");
_Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "level_factor"); _Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Results, Level.REFERENCE_Level, "level_factor");
_Narrative = new SingleAssociation<FactorScoreResult, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_Results, Narrative.REFERENCE_Narrative, "level_factor");
} }
...@@ -267,8 +269,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -267,8 +269,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "level_factor"); _Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Results, Factor.REFERENCE_Factor, "level_factor");
_Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "level_factor"); _Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Results, Level.REFERENCE_Level, "level_factor");
_Narrative = new SingleAssociation<FactorScoreResult, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_Results, Narrative.REFERENCE_Narrative, "level_factor");
return this; return this;
...@@ -473,104 +476,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -473,104 +476,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
} }
/** /**
* Get the attribute NarrativeCode
*/
public String getNarrativeCode ()
{
assertValid();
String valToReturn = _NarrativeCode;
for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
{
valToReturn = bhd.getNarrativeCode ((FactorScoreResult)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 preNarrativeCodeChange (String newNarrativeCode) 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 postNarrativeCodeChange () throws FieldException
{
}
public FieldWriteability getWriteability_NarrativeCode ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute NarrativeCode. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setNarrativeCode (String newNarrativeCode) throws FieldException
{
boolean oldAndNewIdentical = HELPER_NarrativeCode.compare (_NarrativeCode, newNarrativeCode);
try
{
for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
{
newNarrativeCode = bhd.setNarrativeCode ((FactorScoreResult)this, newNarrativeCode);
oldAndNewIdentical = HELPER_NarrativeCode.compare (_NarrativeCode, newNarrativeCode);
}
if (FIELD_NarrativeCode_Validators.length > 0)
{
Object newNarrativeCodeObj = HELPER_NarrativeCode.toObject (newNarrativeCode);
if (newNarrativeCodeObj != null)
{
int loopMax = FIELD_NarrativeCode_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_FactorScoreResult.get (FIELD_NarrativeCode);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_NarrativeCode_Validators[v].checkAttribute (this, FIELD_NarrativeCode, metadata, newNarrativeCodeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_NarrativeCode () != FieldWriteability.FALSE, "Field NarrativeCode is not writeable");
preNarrativeCodeChange (newNarrativeCode);
markFieldChange (FIELD_NarrativeCode);
_NarrativeCode = newNarrativeCode;
postFieldChange (FIELD_NarrativeCode);
postNarrativeCodeChange ();
}
}
/**
* Get the attribute ColorCode * Get the attribute ColorCode
*/ */
public ColorCode getColorCode () public ColorCode getColorCode ()
...@@ -682,6 +587,8 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -682,6 +587,8 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
result.add("Level"); result.add("Level");
result.add("Narrative");
return result; return result;
} }
...@@ -699,6 +606,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -699,6 +606,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level)) }else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return _Level.getReferencedType (); return _Level.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return _Narrative.getReferencedType ();
} }
else else
{ {
...@@ -715,10 +625,13 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -715,10 +625,13 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
} }
else if (assocName.equals (SINGLEREFERENCE_Factor)) else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return null ; return Factor.MULTIPLEREFERENCE_Results ;
}else if (assocName.equals (SINGLEREFERENCE_Level)) }else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return null ; return Level.MULTIPLEREFERENCE_Results ;
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return Narrative.MULTIPLEREFERENCE_Results ;
} }
else else
{ {
...@@ -739,6 +652,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -739,6 +652,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level)) }else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return getLevel (); return getLevel ();
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return getNarrative ();
} }
else else
{ {
...@@ -759,6 +675,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -759,6 +675,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level)) }else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return getLevel (getType); return getLevel (getType);
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return getNarrative (getType);
} }
else else
{ {
...@@ -779,6 +698,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -779,6 +698,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level)) }else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return getLevelID (); return getLevelID ();
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return getNarrativeID ();
} }
else else
{ {
...@@ -799,6 +721,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -799,6 +721,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Level)) }else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
setLevel ((Level)(newValue)); setLevel ((Level)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
setNarrative ((Narrative)(newValue));
} }
else else
{ {
...@@ -895,9 +820,22 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -895,9 +820,22 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Factor () != FieldWriteability.FALSE, "Assoc Factor is not writeable"); Debug.assertion (getWriteability_Factor () != FieldWriteability.FALSE, "Assoc Factor is not writeable");
preFactorChange (newFactor); preFactorChange (newFactor);
Factor oldFactor = getFactor ();
if (oldFactor != null)
{
// This is to stop validation from triggering when we are removed
_Factor.set (null);
oldFactor.removeFromResults ((FactorScoreResult)(this));
}
_Factor.set (newFactor); _Factor.set (newFactor);
if (newFactor != null)
{
newFactor.addToResults ((FactorScoreResult)(this));
}
postFactorChange (); postFactorChange ();
} }
} }
...@@ -989,14 +927,134 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -989,14 +927,134 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable"); Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable");
preLevelChange (newLevel); preLevelChange (newLevel);
Level oldLevel = getLevel ();
if (oldLevel != null)
{
// This is to stop validation from triggering when we are removed
_Level.set (null);
oldLevel.removeFromResults ((FactorScoreResult)(this));
}
_Level.set (newLevel); _Level.set (newLevel);
if (newLevel != null)
{
newLevel.addToResults ((FactorScoreResult)(this));
}
postLevelChange (); postLevelChange ();
} }
} }
/** /**
* Get the reference Narrative
*/
public Narrative getNarrative () throws StorageException
{
assertValid();
try
{
return (Narrative)(_Narrative.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in FactorScoreResult:", this.getObjectID (), ", was trying to get Narrative:", getNarrativeID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Narrative.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Narrative getNarrative (Get getType) throws StorageException
{
assertValid();
return _Narrative.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getNarrativeID ()
{
assertValid();
if (_Narrative == null)
{
return null;
}
else
{
return _Narrative.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 preNarrativeChange (Narrative newNarrative) 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 postNarrativeChange () throws FieldException
{
}
public FieldWriteability getWriteability_Narrative ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Narrative. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setNarrative (Narrative newNarrative) throws StorageException, FieldException
{
if (_Narrative.wouldReferencedChange (newNarrative))
{
assertValid();
Debug.assertion (getWriteability_Narrative () != FieldWriteability.FALSE, "Assoc Narrative is not writeable");
preNarrativeChange (newNarrative);
Narrative oldNarrative = getNarrative ();
if (oldNarrative != null)
{
// This is to stop validation from triggering when we are removed
_Narrative.set (null);
oldNarrative.removeFromResults ((FactorScoreResult)(this));
}
_Narrative.set (newNarrative);
if (newNarrative != null)
{
newNarrative.addToResults ((FactorScoreResult)(this));
}
postNarrativeChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings. * A list of multi assoc names e.g. list of strings.
*/ */
public List<String> getMultiAssocs() public List<String> getMultiAssocs()
...@@ -1094,6 +1152,48 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1094,6 +1152,48 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
try try
{ {
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Factor.isLoaded () || getTransaction ().isObjectLoaded (_Factor.getReferencedType (), getFactorID ()))
{
Factor referenced = getFactor ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Results from ", getObjectID (), " to ", referenced.getObjectID ());
_Factor.set (null);
referenced.removeFromResults ((FactorScoreResult)this);
}
}
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Level.isLoaded () || getTransaction ().isObjectLoaded (_Level.getReferencedType (), getLevelID ()))
{
Level referenced = getLevel ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Results from ", getObjectID (), " to ", referenced.getObjectID ());
_Level.set (null);
referenced.removeFromResults ((FactorScoreResult)this);
}
}
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Narrative.isLoaded () || getTransaction ().isObjectLoaded (_Narrative.getReferencedType (), getNarrativeID ()))
{
Narrative referenced = getNarrative ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Results from ", getObjectID (), " to ", referenced.getObjectID ());
_Narrative.set (null);
referenced.removeFromResults ((FactorScoreResult)this);
}
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -1156,10 +1256,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1156,10 +1256,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
level_factorPSet.setAttrib (FIELD_ObjectID, myID); level_factorPSet.setAttrib (FIELD_ObjectID, myID);
level_factorPSet.setAttrib (FIELD_FromScore, HELPER_FromScore.toObject (_FromScore)); // level_factorPSet.setAttrib (FIELD_FromScore, HELPER_FromScore.toObject (_FromScore)); //
level_factorPSet.setAttrib (FIELD_ToScore, HELPER_ToScore.toObject (_ToScore)); // level_factorPSet.setAttrib (FIELD_ToScore, HELPER_ToScore.toObject (_ToScore)); //
level_factorPSet.setAttrib (FIELD_NarrativeCode, HELPER_NarrativeCode.toObject (_NarrativeCode)); //
level_factorPSet.setAttrib (FIELD_ColorCode, HELPER_ColorCode.toObject (_ColorCode)); // level_factorPSet.setAttrib (FIELD_ColorCode, HELPER_ColorCode.toObject (_ColorCode)); //
_Factor.getPersistentSets (allSets); _Factor.getPersistentSets (allSets);
_Level.getPersistentSets (allSets); _Level.getPersistentSets (allSets);
_Narrative.getPersistentSets (allSets);
} }
...@@ -1176,10 +1276,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1176,10 +1276,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
_FromScore = (Integer)(HELPER_FromScore.fromObject (_FromScore, level_factorPSet.getAttrib (FIELD_FromScore))); // _FromScore = (Integer)(HELPER_FromScore.fromObject (_FromScore, level_factorPSet.getAttrib (FIELD_FromScore))); //
_ToScore = (Integer)(HELPER_ToScore.fromObject (_ToScore, level_factorPSet.getAttrib (FIELD_ToScore))); // _ToScore = (Integer)(HELPER_ToScore.fromObject (_ToScore, level_factorPSet.getAttrib (FIELD_ToScore))); //
_NarrativeCode = (String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, level_factorPSet.getAttrib (FIELD_NarrativeCode))); //
_ColorCode = (ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, level_factorPSet.getAttrib (FIELD_ColorCode))); // _ColorCode = (ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, level_factorPSet.getAttrib (FIELD_ColorCode))); //
_Factor.setFromPersistentSets (objectID, allSets); _Factor.setFromPersistentSets (objectID, allSets);
_Level.setFromPersistentSets (objectID, allSets); _Level.setFromPersistentSets (objectID, allSets);
_Narrative.setFromPersistentSets (objectID, allSets);
} }
...@@ -1215,15 +1315,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1215,15 +1315,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
try try
{ {
setNarrativeCode (otherFactorScoreResult.getNarrativeCode ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setColorCode (otherFactorScoreResult.getColorCode ()); setColorCode (otherFactorScoreResult.getColorCode ());
} }
catch (FieldException ex) catch (FieldException ex)
...@@ -1248,7 +1339,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1248,7 +1339,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
_FromScore = sourceFactorScoreResult._FromScore; _FromScore = sourceFactorScoreResult._FromScore;
_ToScore = sourceFactorScoreResult._ToScore; _ToScore = sourceFactorScoreResult._ToScore;
_NarrativeCode = sourceFactorScoreResult._NarrativeCode;
_ColorCode = sourceFactorScoreResult._ColorCode; _ColorCode = sourceFactorScoreResult._ColorCode;
} }
...@@ -1268,6 +1358,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1268,6 +1358,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
_Factor.copyFrom (sourceFactorScoreResult._Factor, linkToGhosts); _Factor.copyFrom (sourceFactorScoreResult._Factor, linkToGhosts);
_Level.copyFrom (sourceFactorScoreResult._Level, linkToGhosts); _Level.copyFrom (sourceFactorScoreResult._Level, linkToGhosts);
_Narrative.copyFrom (sourceFactorScoreResult._Narrative, linkToGhosts);
} }
} }
...@@ -1306,10 +1397,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1306,10 +1397,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
_FromScore = (Integer)(HELPER_FromScore.readExternal (_FromScore, vals.get(FIELD_FromScore))); // _FromScore = (Integer)(HELPER_FromScore.readExternal (_FromScore, vals.get(FIELD_FromScore))); //
_ToScore = (Integer)(HELPER_ToScore.readExternal (_ToScore, vals.get(FIELD_ToScore))); // _ToScore = (Integer)(HELPER_ToScore.readExternal (_ToScore, vals.get(FIELD_ToScore))); //
_NarrativeCode = (String)(HELPER_NarrativeCode.readExternal (_NarrativeCode, vals.get(FIELD_NarrativeCode))); //
_ColorCode = (ColorCode)(HELPER_ColorCode.readExternal (_ColorCode, vals.get(FIELD_ColorCode))); // _ColorCode = (ColorCode)(HELPER_ColorCode.readExternal (_ColorCode, vals.get(FIELD_ColorCode))); //
_Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor)); _Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor));
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level)); _Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Narrative.readExternalData(vals.get(SINGLEREFERENCE_Narrative));
} }
...@@ -1323,10 +1414,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1323,10 +1414,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
vals.put (FIELD_FromScore, HELPER_FromScore.writeExternal (_FromScore)); vals.put (FIELD_FromScore, HELPER_FromScore.writeExternal (_FromScore));
vals.put (FIELD_ToScore, HELPER_ToScore.writeExternal (_ToScore)); vals.put (FIELD_ToScore, HELPER_ToScore.writeExternal (_ToScore));
vals.put (FIELD_NarrativeCode, HELPER_NarrativeCode.writeExternal (_NarrativeCode));
vals.put (FIELD_ColorCode, HELPER_ColorCode.writeExternal (_ColorCode)); vals.put (FIELD_ColorCode, HELPER_ColorCode.writeExternal (_ColorCode));
vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData()); vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData());
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData()); vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (SINGLEREFERENCE_Narrative, _Narrative.writeExternalData());
} }
...@@ -1348,10 +1439,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1348,10 +1439,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
listener.notifyFieldChange(this, other, FIELD_ToScore, HELPER_ToScore.toObject(this._ToScore), HELPER_ToScore.toObject(otherFactorScoreResult._ToScore)); listener.notifyFieldChange(this, other, FIELD_ToScore, HELPER_ToScore.toObject(this._ToScore), HELPER_ToScore.toObject(otherFactorScoreResult._ToScore));
} }
if (!HELPER_NarrativeCode.compare(this._NarrativeCode, otherFactorScoreResult._NarrativeCode))
{
listener.notifyFieldChange(this, other, FIELD_NarrativeCode, HELPER_NarrativeCode.toObject(this._NarrativeCode), HELPER_NarrativeCode.toObject(otherFactorScoreResult._NarrativeCode));
}
if (!HELPER_ColorCode.compare(this._ColorCode, otherFactorScoreResult._ColorCode)) if (!HELPER_ColorCode.compare(this._ColorCode, otherFactorScoreResult._ColorCode))
{ {
listener.notifyFieldChange(this, other, FIELD_ColorCode, HELPER_ColorCode.toObject(this._ColorCode), HELPER_ColorCode.toObject(otherFactorScoreResult._ColorCode)); listener.notifyFieldChange(this, other, FIELD_ColorCode, HELPER_ColorCode.toObject(this._ColorCode), HELPER_ColorCode.toObject(otherFactorScoreResult._ColorCode));
...@@ -1360,6 +1447,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1360,6 +1447,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
// Compare single assocs // Compare single assocs
_Factor.compare (otherFactorScoreResult._Factor, listener); _Factor.compare (otherFactorScoreResult._Factor, listener);
_Level.compare (otherFactorScoreResult._Level, listener); _Level.compare (otherFactorScoreResult._Level, listener);
_Narrative.compare (otherFactorScoreResult._Narrative, listener);
// Compare multiple assocs // Compare multiple assocs
...@@ -1382,10 +1470,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1382,10 +1470,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
visitor.visitField(this, FIELD_FromScore, HELPER_FromScore.toObject(getFromScore())); visitor.visitField(this, FIELD_FromScore, HELPER_FromScore.toObject(getFromScore()));
visitor.visitField(this, FIELD_ToScore, HELPER_ToScore.toObject(getToScore())); visitor.visitField(this, FIELD_ToScore, HELPER_ToScore.toObject(getToScore()));
visitor.visitField(this, FIELD_NarrativeCode, HELPER_NarrativeCode.toObject(getNarrativeCode()));
visitor.visitField(this, FIELD_ColorCode, HELPER_ColorCode.toObject(getColorCode())); visitor.visitField(this, FIELD_ColorCode, HELPER_ColorCode.toObject(getColorCode()));
visitor.visitAssociation (_Factor); visitor.visitAssociation (_Factor);
visitor.visitAssociation (_Level); visitor.visitAssociation (_Level);
visitor.visitAssociation (_Narrative);
} }
...@@ -1402,6 +1490,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1402,6 +1490,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
visitor.visit (_Level); visitor.visit (_Level);
} }
if (scope.includes (_Narrative))
{
visitor.visit (_Narrative);
}
} }
...@@ -1435,10 +1527,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1435,10 +1527,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return filter.matches (getToScore ()); return filter.matches (getToScore ());
} }
else if (attribName.equals (FIELD_NarrativeCode))
{
return filter.matches (getNarrativeCode ());
}
else if (attribName.equals (FIELD_ColorCode)) else if (attribName.equals (FIELD_ColorCode))
{ {
return filter.matches (getColorCode ()); return filter.matches (getColorCode ());
...@@ -1451,6 +1539,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1451,6 +1539,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return filter.matches (getLevel ()); return filter.matches (getLevel ());
} }
else if (attribName.equals (SINGLEREFERENCE_Narrative))
{
return filter.matches (getNarrative ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -1494,12 +1586,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1494,12 +1586,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
return this; return this;
} }
public SearchAll andNarrativeCode (QueryFilter<String> filter)
{
filter.addFilter (context, "level_factor.narrative_code", "NarrativeCode");
return this;
}
public SearchAll andColorCode (QueryFilter<ColorCode> filter) public SearchAll andColorCode (QueryFilter<ColorCode> filter)
{ {
filter.addFilter (context, "level_factor.color_code", "ColorCode"); filter.addFilter (context, "level_factor.color_code", "ColorCode");
...@@ -1518,6 +1604,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1518,6 +1604,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
return this; return this;
} }
public SearchAll andNarrative (QueryFilter<Narrative> filter)
{
filter.addFilter (context, "level_factor.narrative_id", "Narrative");
return this;
}
public FactorScoreResult[] public FactorScoreResult[]
search (ObjectTransaction transaction) throws StorageException search (ObjectTransaction transaction) throws StorageException
{ {
...@@ -1581,12 +1673,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1581,12 +1673,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
return this; return this;
} }
public SearchFactorScore andNarrativeCode (QueryFilter<String> filter)
{
filter.addFilter (context, "level_factor.narrative_code", "NarrativeCode");
return this;
}
public SearchFactorScore andColorCode (QueryFilter<ColorCode> filter) public SearchFactorScore andColorCode (QueryFilter<ColorCode> filter)
{ {
filter.addFilter (context, "level_factor.color_code", "ColorCode"); filter.addFilter (context, "level_factor.color_code", "ColorCode");
...@@ -1605,6 +1691,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1605,6 +1691,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
return this; return this;
} }
public SearchFactorScore andNarrative (QueryFilter<Narrative> filter)
{
filter.addFilter (context, "level_factor.narrative_id", "Narrative");
return this;
}
public FactorScoreResult search (ObjectTransaction transaction) throws StorageException public FactorScoreResult search (ObjectTransaction transaction) throws StorageException
{ {
...@@ -1646,10 +1738,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1646,10 +1738,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return HELPER_ToScore.toObject (getToScore ()); return HELPER_ToScore.toObject (getToScore ());
} }
else if (attribName.equals (FIELD_NarrativeCode))
{
return HELPER_NarrativeCode.toObject (getNarrativeCode ());
}
else if (attribName.equals (FIELD_ColorCode)) else if (attribName.equals (FIELD_ColorCode))
{ {
return HELPER_ColorCode.toObject (getColorCode ()); return HELPER_ColorCode.toObject (getColorCode ());
...@@ -1675,10 +1763,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1675,10 +1763,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return HELPER_ToScore; return HELPER_ToScore;
} }
else if (attribName.equals (FIELD_NarrativeCode))
{
return HELPER_NarrativeCode;
}
else if (attribName.equals (FIELD_ColorCode)) else if (attribName.equals (FIELD_ColorCode))
{ {
return HELPER_ColorCode; return HELPER_ColorCode;
...@@ -1704,10 +1788,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1704,10 +1788,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
setToScore ((Integer)(HELPER_ToScore.fromObject (_ToScore, attribValue))); setToScore ((Integer)(HELPER_ToScore.fromObject (_ToScore, attribValue)));
} }
else if (attribName.equals (FIELD_NarrativeCode))
{
setNarrativeCode ((String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, attribValue)));
}
else if (attribName.equals (FIELD_ColorCode)) else if (attribName.equals (FIELD_ColorCode))
{ {
setColorCode ((ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, attribValue))); setColorCode ((ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, attribValue)));
...@@ -1740,10 +1820,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1740,10 +1820,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return getWriteability_ToScore (); return getWriteability_ToScore ();
} }
else if (fieldName.equals (FIELD_NarrativeCode))
{
return getWriteability_NarrativeCode ();
}
else if (fieldName.equals (FIELD_ColorCode)) else if (fieldName.equals (FIELD_ColorCode))
{ {
return getWriteability_ColorCode (); return getWriteability_ColorCode ();
...@@ -1756,6 +1832,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1756,6 +1832,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return getWriteability_Level (); return getWriteability_Level ();
} }
else if (fieldName.equals (SINGLEREFERENCE_Narrative))
{
return getWriteability_Narrative ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1776,11 +1856,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1776,11 +1856,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
fields.add (FIELD_ToScore); fields.add (FIELD_ToScore);
} }
if (getWriteability_NarrativeCode () != FieldWriteability.TRUE)
{
fields.add (FIELD_NarrativeCode);
}
if (getWriteability_ColorCode () != FieldWriteability.TRUE) if (getWriteability_ColorCode () != FieldWriteability.TRUE)
{ {
fields.add (FIELD_ColorCode); fields.add (FIELD_ColorCode);
...@@ -1797,7 +1872,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1797,7 +1872,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
result.add(HELPER_FromScore.getAttribObject (getClass (), _FromScore, false, FIELD_FromScore)); result.add(HELPER_FromScore.getAttribObject (getClass (), _FromScore, false, FIELD_FromScore));
result.add(HELPER_ToScore.getAttribObject (getClass (), _ToScore, false, FIELD_ToScore)); result.add(HELPER_ToScore.getAttribObject (getClass (), _ToScore, false, FIELD_ToScore));
result.add(HELPER_NarrativeCode.getAttribObject (getClass (), _NarrativeCode, false, FIELD_NarrativeCode));
result.add(HELPER_ColorCode.getAttribObject (getClass (), _ColorCode, false, FIELD_ColorCode)); result.add(HELPER_ColorCode.getAttribObject (getClass (), _ColorCode, false, FIELD_ColorCode));
return result; return result;
...@@ -1886,24 +1960,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1886,24 +1960,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
} }
/** /**
* Get the attribute NarrativeCode
*/
public String getNarrativeCode (FactorScoreResult obj, String original)
{
return original;
}
/**
* Change the value set for attribute NarrativeCode.
* May modify the field beforehand
* Occurs before validation.
*/
public String setNarrativeCode (FactorScoreResult obj, String newNarrativeCode) throws FieldException
{
return newNarrativeCode;
}
/**
* Get the attribute ColorCode * Get the attribute ColorCode
*/ */
public ColorCode getColorCode (FactorScoreResult obj, ColorCode original) public ColorCode getColorCode (FactorScoreResult obj, ColorCode original)
...@@ -1981,10 +2037,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1981,10 +2037,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return toToScore (); return toToScore ();
} }
if (name.equals ("NarrativeCode"))
{
return toNarrativeCode ();
}
if (name.equals ("ColorCode")) if (name.equals ("ColorCode"))
{ {
return toColorCode (); return toColorCode ();
...@@ -1997,6 +2049,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1997,6 +2049,10 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return toLevel (); return toLevel ();
} }
if (name.equals ("Narrative"))
{
return toNarrative ();
}
return super.to(name); return super.to(name);
...@@ -2007,8 +2063,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -2007,8 +2063,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
public PipeLine<From, Integer> toToScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ToScore)); } public PipeLine<From, Integer> toToScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ToScore)); }
public PipeLine<From, String> toNarrativeCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_NarrativeCode)); }
public PipeLine<From, ColorCode> toColorCode () { return pipe(new ORMAttributePipe<Me, ColorCode>(FIELD_ColorCode)); } public PipeLine<From, ColorCode> toColorCode () { return pipe(new ORMAttributePipe<Me, ColorCode>(FIELD_ColorCode)); }
public Factor.FactorPipeLineFactory<From, Factor> toFactor () { return toFactor (Filter.ALL); } public Factor.FactorPipeLineFactory<From, Factor> toFactor () { return toFactor (Filter.ALL); }
...@@ -2022,6 +2076,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -2022,6 +2076,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_Level, filter)); return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_Level, filter));
} }
public Narrative.NarrativePipeLineFactory<From, Narrative> toNarrative () { return toNarrative (Filter.ALL); }
public Narrative.NarrativePipeLineFactory<From, Narrative> toNarrative (Filter<Narrative> filter)
{
return Narrative.REFERENCE_Narrative.new NarrativePipeLineFactory<From, Narrative> (this, new ORMSingleAssocPipe<Me, Narrative>(SINGLEREFERENCE_Narrative, filter));
}
} }
...@@ -2081,6 +2141,20 @@ class DummyFactorScoreResult extends FactorScoreResult ...@@ -2081,6 +2141,20 @@ class DummyFactorScoreResult extends FactorScoreResult
return Level.DUMMY_Level.getObjectID(); return Level.DUMMY_Level.getObjectID();
} }
public Narrative getNarrative () throws StorageException
{
return (Narrative)(Narrative.DUMMY_Narrative);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getNarrativeID ()
{
return Narrative.DUMMY_Narrative.getObjectID();
}
} }
...@@ -41,10 +41,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -41,10 +41,13 @@ public abstract class BaseLevel extends BaseBusinessClass
public static final String FIELD_LevelDescription = "LevelDescription"; public static final String FIELD_LevelDescription = "LevelDescription";
public static final String FIELD_LevelNotes = "LevelNotes"; public static final String FIELD_LevelNotes = "LevelNotes";
public static final String FIELD_ReportHeader = "ReportHeader"; public static final String FIELD_ReportHeader = "ReportHeader";
public static final String MULTIPLEREFERENCE_FactorLinks = "FactorLinks"; public static final String MULTIPLEREFERENCE_Factors = "Factors";
public static final String BACKREF_FactorLinks = ""; public static final String BACKREF_Factors = "";
public static final String MULTIPLEREFERENCE_Results = "Results";
public static final String BACKREF_Results = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -63,7 +66,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -63,7 +66,8 @@ public abstract class BaseLevel extends BaseBusinessClass
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
private MultipleAssociation<Level, FactorLevelLink> _FactorLinks; private MultipleAssociation<Level, FactorLevelLink> _Factors;
private MultipleAssociation<Level, FactorScoreResult> _Results;
// Map of maps of metadata // Map of maps of metadata
...@@ -83,11 +87,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -83,11 +87,13 @@ public abstract class BaseLevel extends BaseBusinessClass
try try
{ {
String tmp_FactorLinks = FactorLevelLink.BACKREF_Level; String tmp_Factors = FactorLevelLink.BACKREF_Level;
String tmp_Results = FactorScoreResult.BACKREF_Level;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_FactorLinks(); setupAssocMetaData_Factors();
setupAssocMetaData_Results();
FIELD_LevelDescription_Validators = (AttributeValidator[])setupAttribMetaData_LevelDescription(validatorMapping).toArray (new AttributeValidator[0]); FIELD_LevelDescription_Validators = (AttributeValidator[])setupAttribMetaData_LevelDescription(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_LevelNotes_Validators = (AttributeValidator[])setupAttribMetaData_LevelNotes(validatorMapping).toArray (new AttributeValidator[0]); FIELD_LevelNotes_Validators = (AttributeValidator[])setupAttribMetaData_LevelNotes(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ReportHeader_Validators = (AttributeValidator[])setupAttribMetaData_ReportHeader(validatorMapping).toArray (new AttributeValidator[0]); FIELD_ReportHeader_Validators = (AttributeValidator[])setupAttribMetaData_ReportHeader(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -106,16 +112,30 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -106,16 +112,30 @@ public abstract class BaseLevel extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_FactorLinks() private static void setupAssocMetaData_Factors()
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Level"); metaInfo.put ("backreferenceName", "Level");
metaInfo.put ("name", "FactorLinks"); metaInfo.put ("name", "Factors");
metaInfo.put ("type", "FactorLevelLink"); metaInfo.put ("type", "FactorLevelLink");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.FactorLinks:", metaInfo); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.Factors:", metaInfo);
ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_FactorLinks, Collections.unmodifiableMap (metaInfo)); ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_Factors, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Results()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Level");
metaInfo.put ("name", "Results");
metaInfo.put ("type", "FactorScoreResult");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.Results:", metaInfo);
ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_Results, Collections.unmodifiableMap (metaInfo));
} }
...@@ -212,7 +232,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -212,7 +232,8 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_FactorLinks = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_FactorLinks, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink); _Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink);
_Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult);
} }
...@@ -222,7 +243,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -222,7 +243,8 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_FactorLinks = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_FactorLinks, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink); _Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink);
_Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult);
return this; return this;
...@@ -632,7 +654,9 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -632,7 +654,9 @@ public abstract class BaseLevel extends BaseBusinessClass
List result = super.getMultiAssocs (); List result = super.getMultiAssocs ();
result.add("FactorLinks"); result.add("Factors");
result.add("Results");
return result; return result;
...@@ -645,11 +669,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -645,11 +669,16 @@ public abstract class BaseLevel extends BaseBusinessClass
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName) public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{ {
return FactorLevelLink.REFERENCE_FactorLevelLink ; return FactorLevelLink.REFERENCE_FactorLevelLink ;
} }
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return FactorScoreResult.REFERENCE_FactorScoreResult ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -658,11 +687,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -658,11 +687,16 @@ public abstract class BaseLevel extends BaseBusinessClass
public String getMultiAssocBackReference(String attribName) public String getMultiAssocBackReference(String attribName)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{ {
return FactorLevelLink.SINGLEREFERENCE_Level ; return FactorLevelLink.SINGLEREFERENCE_Level ;
} }
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return FactorScoreResult.SINGLEREFERENCE_Level ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -674,9 +708,14 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -674,9 +708,14 @@ public abstract class BaseLevel extends BaseBusinessClass
public int getMultiAssocCount(String attribName) throws StorageException public int getMultiAssocCount(String attribName) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{ {
return this.getFactorLinksCount(); return this.getFactorsCount();
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return this.getResultsCount();
} }
...@@ -690,9 +729,14 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -690,9 +729,14 @@ public abstract class BaseLevel extends BaseBusinessClass
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{ {
return this.getFactorLinksAt(index); return this.getFactorsAt(index);
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return this.getResultsAt(index);
} }
...@@ -706,9 +750,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -706,9 +750,16 @@ public abstract class BaseLevel extends BaseBusinessClass
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
addToFactors((FactorLevelLink)newElement);
return;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{ {
addToFactorLinks((FactorLevelLink)newElement); addToResults((FactorScoreResult)newElement);
return; return;
} }
...@@ -723,9 +774,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -723,9 +774,16 @@ public abstract class BaseLevel extends BaseBusinessClass
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
removeFromFactors((FactorLevelLink)oldElement);
return;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{ {
removeFromFactorLinks((FactorLevelLink)oldElement); removeFromResults((FactorScoreResult)oldElement);
return; return;
} }
...@@ -738,9 +796,15 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -738,9 +796,15 @@ public abstract class BaseLevel extends BaseBusinessClass
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements) protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
_Factors.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{ {
_FactorLinks.__loadAssociation (elements); _Results.__loadAssociation (elements);
return; return;
} }
...@@ -752,9 +816,14 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -752,9 +816,14 @@ public abstract class BaseLevel extends BaseBusinessClass
protected boolean __isMultiAssocLoaded (String attribName) protected boolean __isMultiAssocLoaded (String attribName)
{ {
if (MULTIPLEREFERENCE_FactorLinks.equals(attribName)) if (MULTIPLEREFERENCE_Factors.equals(attribName))
{ {
return _FactorLinks.isLoaded (); return _Factors.isLoaded ();
}
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return _Results.isLoaded ();
} }
...@@ -763,26 +832,26 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -763,26 +832,26 @@ public abstract class BaseLevel extends BaseBusinessClass
public FieldWriteability getWriteability_FactorLinks () public FieldWriteability getWriteability_Factors ()
{ {
return getFieldWritabilityUtil (FieldWriteability.TRUE); return getFieldWritabilityUtil (FieldWriteability.TRUE);
} }
public int getFactorLinksCount () throws StorageException public int getFactorsCount () throws StorageException
{ {
assertValid(); assertValid();
return _FactorLinks.getReferencedObjectsCount (); return _Factors.getReferencedObjectsCount ();
} }
public void addToFactorLinks (FactorLevelLink newElement) throws StorageException public void addToFactors (FactorLevelLink newElement) throws StorageException
{ {
if (_FactorLinks.wouldAddChange (newElement)) if (_Factors.wouldAddChange (newElement))
{ {
assertValid(); assertValid();
Debug.assertion (getWriteability_FactorLinks () != FieldWriteability.FALSE, "MultiAssoc FactorLinks is not writeable (add)"); Debug.assertion (getWriteability_Factors () != FieldWriteability.FALSE, "MultiAssoc Factors is not writeable (add)");
_FactorLinks.appendElement (newElement); _Factors.appendElement (newElement);
try try
{ {
...@@ -799,13 +868,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -799,13 +868,13 @@ public abstract class BaseLevel extends BaseBusinessClass
} }
public void removeFromFactorLinks (FactorLevelLink elementToRemove) throws StorageException public void removeFromFactors (FactorLevelLink elementToRemove) throws StorageException
{ {
if (_FactorLinks.wouldRemoveChange (elementToRemove)) if (_Factors.wouldRemoveChange (elementToRemove))
{ {
assertValid(); assertValid();
Debug.assertion (getWriteability_FactorLinks () != FieldWriteability.FALSE, "MultiAssoc FactorLinks is not writeable (remove)"); Debug.assertion (getWriteability_Factors () != FieldWriteability.FALSE, "MultiAssoc Factors is not writeable (remove)");
_FactorLinks.removeElement (elementToRemove); _Factors.removeElement (elementToRemove);
try try
{ {
if (elementToRemove.getLevel () != null) if (elementToRemove.getLevel () != null)
...@@ -821,15 +890,84 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -821,15 +890,84 @@ public abstract class BaseLevel extends BaseBusinessClass
} }
public FactorLevelLink getFactorLinksAt (int index) throws StorageException public FactorLevelLink getFactorsAt (int index) throws StorageException
{
return (FactorLevelLink)(_Factors.getElementAt (index));
}
public SortedSet<FactorLevelLink> getFactorsSet () throws StorageException
{
return _Factors.getSet ();
}
public FieldWriteability getWriteability_Results ()
{ {
return (FactorLevelLink)(_FactorLinks.getElementAt (index)); return getFieldWritabilityUtil (FieldWriteability.TRUE);
} }
public SortedSet<FactorLevelLink> getFactorLinksSet () throws StorageException public int getResultsCount () throws StorageException
{ {
return _FactorLinks.getSet (); assertValid();
return _Results.getReferencedObjectsCount ();
}
public void addToResults (FactorScoreResult newElement) throws StorageException
{
if (_Results.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (add)");
_Results.appendElement (newElement);
try
{
if (newElement.getLevel () != this)
{
newElement.setLevel ((Level)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromResults (FactorScoreResult elementToRemove) throws StorageException
{
if (_Results.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (remove)");
_Results.removeElement (elementToRemove);
try
{
if (elementToRemove.getLevel () != null)
{
elementToRemove.setLevel (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public FactorScoreResult getResultsAt (int index) throws StorageException
{
return (FactorScoreResult)(_Results.getElementAt (index));
}
public SortedSet<FactorScoreResult> getResultsSet () throws StorageException
{
return _Results.getSet ();
} }
...@@ -838,7 +976,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -838,7 +976,13 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
try try
{ {
for(FactorLevelLink referenced : CollectionUtils.reverse(getFactorLinksSet())) for(FactorLevelLink referenced : CollectionUtils.reverse(getFactorsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setLevel(null);
}
for(FactorScoreResult referenced : CollectionUtils.reverse(getResultsSet()))
{ {
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ()); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setLevel(null); referenced.setLevel(null);
...@@ -1016,7 +1160,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1016,7 +1160,8 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
BaseLevel sourceLevel = (BaseLevel)(source); BaseLevel sourceLevel = (BaseLevel)(source);
_FactorLinks.copyFrom (sourceLevel._FactorLinks, linkToGhosts); _Factors.copyFrom (sourceLevel._Factors, linkToGhosts);
_Results.copyFrom (sourceLevel._Results, linkToGhosts);
} }
} }
...@@ -1040,7 +1185,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1040,7 +1185,8 @@ public abstract class BaseLevel extends BaseBusinessClass
_LevelDescription = (String)(HELPER_LevelDescription.readExternal (_LevelDescription, vals.get(FIELD_LevelDescription))); // _LevelDescription = (String)(HELPER_LevelDescription.readExternal (_LevelDescription, vals.get(FIELD_LevelDescription))); //
_LevelNotes = (String)(HELPER_LevelNotes.readExternal (_LevelNotes, vals.get(FIELD_LevelNotes))); // _LevelNotes = (String)(HELPER_LevelNotes.readExternal (_LevelNotes, vals.get(FIELD_LevelNotes))); //
_ReportHeader = (String)(HELPER_ReportHeader.readExternal (_ReportHeader, vals.get(FIELD_ReportHeader))); // _ReportHeader = (String)(HELPER_ReportHeader.readExternal (_ReportHeader, vals.get(FIELD_ReportHeader))); //
_FactorLinks.readExternalData(vals.get(MULTIPLEREFERENCE_FactorLinks)); _Factors.readExternalData(vals.get(MULTIPLEREFERENCE_Factors));
_Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
} }
...@@ -1055,7 +1201,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1055,7 +1201,8 @@ public abstract class BaseLevel extends BaseBusinessClass
vals.put (FIELD_LevelDescription, HELPER_LevelDescription.writeExternal (_LevelDescription)); vals.put (FIELD_LevelDescription, HELPER_LevelDescription.writeExternal (_LevelDescription));
vals.put (FIELD_LevelNotes, HELPER_LevelNotes.writeExternal (_LevelNotes)); vals.put (FIELD_LevelNotes, HELPER_LevelNotes.writeExternal (_LevelNotes));
vals.put (FIELD_ReportHeader, HELPER_ReportHeader.writeExternal (_ReportHeader)); vals.put (FIELD_ReportHeader, HELPER_ReportHeader.writeExternal (_ReportHeader));
vals.put (MULTIPLEREFERENCE_FactorLinks, _FactorLinks.writeExternalData()); vals.put (MULTIPLEREFERENCE_Factors, _Factors.writeExternalData());
vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
} }
...@@ -1086,7 +1233,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1086,7 +1233,8 @@ public abstract class BaseLevel extends BaseBusinessClass
// Compare multiple assocs // Compare multiple assocs
_FactorLinks.compare (otherLevel._FactorLinks, listener); _Factors.compare (otherLevel._Factors, listener);
_Results.compare (otherLevel._Results, listener);
} }
} }
...@@ -1107,7 +1255,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1107,7 +1255,8 @@ public abstract class BaseLevel extends BaseBusinessClass
visitor.visitField(this, FIELD_LevelDescription, HELPER_LevelDescription.toObject(getLevelDescription())); visitor.visitField(this, FIELD_LevelDescription, HELPER_LevelDescription.toObject(getLevelDescription()));
visitor.visitField(this, FIELD_LevelNotes, HELPER_LevelNotes.toObject(getLevelNotes())); visitor.visitField(this, FIELD_LevelNotes, HELPER_LevelNotes.toObject(getLevelNotes()));
visitor.visitField(this, FIELD_ReportHeader, HELPER_ReportHeader.toObject(getReportHeader())); visitor.visitField(this, FIELD_ReportHeader, HELPER_ReportHeader.toObject(getReportHeader()));
visitor.visitAssociation (_FactorLinks); visitor.visitAssociation (_Factors);
visitor.visitAssociation (_Results);
} }
...@@ -1116,9 +1265,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1116,9 +1265,13 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
super.visitAssociations (visitor, scope); super.visitAssociations (visitor, scope);
if (scope.includes (_FactorLinks)) if (scope.includes (_Factors))
{ {
visitor.visit (_FactorLinks); visitor.visit (_Factors);
}
if (scope.includes (_Results))
{
visitor.visit (_Results);
} }
} }
...@@ -1164,6 +1317,75 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1164,6 +1317,75 @@ public abstract class BaseLevel extends BaseBusinessClass
} }
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Level>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "level.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "level.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "level.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andLevelDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "level.level_desc", "LevelDescription");
return this;
}
public SearchAll andLevelNotes (QueryFilter<String> filter)
{
filter.addFilter (context, "level.level_notes", "LevelNotes");
return this;
}
public SearchAll andReportHeader (QueryFilter<String> filter)
{
filter.addFilter (context, "level.rpt_hdr", "ReportHeader");
return this;
}
public Level[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Level, SEARCH_All, criteria);
Set<Level> typedResults = new LinkedHashSet <Level> ();
for (BaseBusinessClass bbcResult : results)
{
Level aResult = (Level)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Level[0]);
}
}
public static Level[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
...@@ -1266,9 +1488,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1266,9 +1488,13 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
return getWriteability_ReportHeader (); return getWriteability_ReportHeader ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_FactorLinks)) else if (fieldName.equals (MULTIPLEREFERENCE_Factors))
{ {
return getWriteability_FactorLinks (); return getWriteability_Factors ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Results))
{
return getWriteability_Results ();
} }
else else
{ {
...@@ -1463,9 +1689,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1463,9 +1689,13 @@ public abstract class BaseLevel extends BaseBusinessClass
public PipeLine<From, ? extends Object> to(String name) public PipeLine<From, ? extends Object> to(String name)
{ {
if (name.equals ("FactorLinks")) if (name.equals ("Factors"))
{ {
return toFactorLinks (); return toFactors ();
}
if (name.equals ("Results"))
{
return toResults ();
} }
if (name.equals ("LevelDescription")) if (name.equals ("LevelDescription"))
{ {
...@@ -1490,11 +1720,17 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1490,11 +1720,17 @@ public abstract class BaseLevel extends BaseBusinessClass
public PipeLine<From, String> toLevelNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_LevelNotes)); } public PipeLine<From, String> toLevelNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_LevelNotes)); }
public PipeLine<From, String> toReportHeader () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ReportHeader)); } public PipeLine<From, String> toReportHeader () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ReportHeader)); }
public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactorLinks () { return toFactorLinks(Filter.ALL); } public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactors () { return toFactors(Filter.ALL); }
public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactors (Filter<FactorLevelLink> filter)
{
return FactorLevelLink.REFERENCE_FactorLevelLink.new FactorLevelLinkPipeLineFactory<From, FactorLevelLink> (this, new ORMMultiAssocPipe<Me, FactorLevelLink>(MULTIPLEREFERENCE_Factors, filter));
}
public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults () { return toResults(Filter.ALL); }
public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactorLinks (Filter<FactorLevelLink> filter) public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults (Filter<FactorScoreResult> filter)
{ {
return FactorLevelLink.REFERENCE_FactorLevelLink.new FactorLevelLinkPipeLineFactory<From, FactorLevelLink> (this, new ORMMultiAssocPipe<Me, FactorLevelLink>(MULTIPLEREFERENCE_FactorLinks, filter)); return FactorScoreResult.REFERENCE_FactorScoreResult.new FactorScoreResultPipeLineFactory<From, FactorScoreResult> (this, new ORMMultiAssocPipe<Me, FactorScoreResult>(MULTIPLEREFERENCE_Results, filter));
} }
} }
...@@ -1527,19 +1763,36 @@ class DummyLevel extends Level ...@@ -1527,19 +1763,36 @@ class DummyLevel extends Level
} }
public int getFactorLinksCount () throws StorageException public int getFactorsCount () throws StorageException
{
return 0;
}
public FactorLevelLink getFactorsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Factors");
}
public SortedSet getFactorsSet () throws StorageException
{
return new TreeSet();
}
public int getResultsCount () throws StorageException
{ {
return 0; return 0;
} }
public FactorLevelLink getFactorLinksAt (int index) throws StorageException public FactorScoreResult getResultsAt (int index) throws StorageException
{ {
throw new RuntimeException ("No elements in a dummy object in association FactorLinks"); throw new RuntimeException ("No elements in a dummy object in association Results");
} }
public SortedSet getFactorLinksSet () throws StorageException public SortedSet getResultsSet () throws StorageException
{ {
return new TreeSet(); return new TreeSet();
} }
......
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
public abstract class BaseNarrative extends BaseBusinessClass
{
// Reference instance for the object
public static final Narrative REFERENCE_Narrative = new Narrative ();
// Reference instance for the object
public static final Narrative DUMMY_Narrative = new DummyNarrative ();
// Static constants corresponding to field names
public static final String FIELD_NarrativeCode = "NarrativeCode";
public static final String FIELD_Description = "Description";
public static final String FIELD_GraphicNotes = "GraphicNotes";
public static final String FIELD_SummaryNotes = "SummaryNotes";
public static final String FIELD_ModConnect = "ModConnect";
public static final String FIELD_NarrativeNotes = "NarrativeNotes";
public static final String FIELD_DevelNarrative = "DevelNarrative";
public static final String FIELD_Question = "Question";
public static final String SINGLEREFERENCE_Level = "Level";
public static final String MULTIPLEREFERENCE_Results = "Results";
public static final String BACKREF_Results = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<Narrative> HELPER_NarrativeCode = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Narrative> HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Narrative> HELPER_GraphicNotes = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Narrative> HELPER_SummaryNotes = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Narrative> HELPER_ModConnect = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Narrative> HELPER_NarrativeNotes = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Narrative> HELPER_DevelNarrative = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Narrative> HELPER_Question = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _NarrativeCode;
private String _Description;
private String _GraphicNotes;
private String _SummaryNotes;
private String _ModConnect;
private String _NarrativeNotes;
private String _DevelNarrative;
private String _Question;
// Private attributes corresponding to single references
private SingleAssociation<Narrative, Level> _Level;
// Private attributes corresponding to multiple references
private MultipleAssociation<Narrative, FactorScoreResult> _Results;
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_Narrative = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_NarrativeCode_Validators;
private static final AttributeValidator[] FIELD_Description_Validators;
private static final AttributeValidator[] FIELD_GraphicNotes_Validators;
private static final AttributeValidator[] FIELD_SummaryNotes_Validators;
private static final AttributeValidator[] FIELD_ModConnect_Validators;
private static final AttributeValidator[] FIELD_NarrativeNotes_Validators;
private static final AttributeValidator[] FIELD_DevelNarrative_Validators;
private static final AttributeValidator[] FIELD_Question_Validators;
// Arrays of behaviour decorators
private static final NarrativeBehaviourDecorator[] Narrative_BehaviourDecorators;
static
{
try
{
String tmp_Results = FactorScoreResult.BACKREF_Narrative;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Results();
setupAssocMetaData_Level();
FIELD_NarrativeCode_Validators = (AttributeValidator[])setupAttribMetaData_NarrativeCode(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_GraphicNotes_Validators = (AttributeValidator[])setupAttribMetaData_GraphicNotes(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_SummaryNotes_Validators = (AttributeValidator[])setupAttribMetaData_SummaryNotes(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ModConnect_Validators = (AttributeValidator[])setupAttribMetaData_ModConnect(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_NarrativeNotes_Validators = (AttributeValidator[])setupAttribMetaData_NarrativeNotes(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_DevelNarrative_Validators = (AttributeValidator[])setupAttribMetaData_DevelNarrative(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Question_Validators = (AttributeValidator[])setupAttribMetaData_Question(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_Narrative.initialiseReference ();
DUMMY_Narrative.initialiseReference ();
Narrative_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Narrative.class).toArray(new NarrativeBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Results()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Narrative");
metaInfo.put ("name", "Results");
metaInfo.put ("type", "FactorScoreResult");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.Results:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (MULTIPLEREFERENCE_Results, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Level()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "level_number");
metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.Level:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (SINGLEREFERENCE_Level, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_NarrativeCode(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "narrative_code");
metaInfo.put ("length", "15");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "NarrativeCode");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.NarrativeCode:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_NarrativeCode, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "NarrativeCode", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.NarrativeCode:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "narrative_desc");
metaInfo.put ("length", "30");
metaInfo.put ("name", "Description");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.Description:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_Description, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "Description", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.Description:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_GraphicNotes(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "graphic_notes");
metaInfo.put ("name", "GraphicNotes");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.GraphicNotes:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_GraphicNotes, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "GraphicNotes", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.GraphicNotes:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_SummaryNotes(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "exec_sum_notes");
metaInfo.put ("name", "SummaryNotes");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.SummaryNotes:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_SummaryNotes, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "SummaryNotes", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.SummaryNotes:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ModConnect(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "mod_connect_flag");
metaInfo.put ("length", "15");
metaInfo.put ("name", "ModConnect");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.ModConnect:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_ModConnect, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "ModConnect", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.ModConnect:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_NarrativeNotes(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "narrative_notes");
metaInfo.put ("name", "NarrativeNotes");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.NarrativeNotes:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_NarrativeNotes, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "NarrativeNotes", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.NarrativeNotes:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_DevelNarrative(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "devel_narrative");
metaInfo.put ("length", "128");
metaInfo.put ("name", "DevelNarrative");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.DevelNarrative:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_DevelNarrative, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "DevelNarrative", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.DevelNarrative:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Question(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "question");
metaInfo.put ("name", "Question");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.Question:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (FIELD_Question, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Narrative.class, "Question", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Narrative.Question:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseNarrative ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return Narrative_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_NarrativeCode = (String)(HELPER_NarrativeCode.initialise (_NarrativeCode));
_Description = (String)(HELPER_Description.initialise (_Description));
_GraphicNotes = (String)(HELPER_GraphicNotes.initialise (_GraphicNotes));
_SummaryNotes = (String)(HELPER_SummaryNotes.initialise (_SummaryNotes));
_ModConnect = (String)(HELPER_ModConnect.initialise (_ModConnect));
_NarrativeNotes = (String)(HELPER_NarrativeNotes.initialise (_NarrativeNotes));
_DevelNarrative = (String)(HELPER_DevelNarrative.initialise (_DevelNarrative));
_Question = (String)(HELPER_Question.initialise (_Question));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_Level = new SingleAssociation<Narrative, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "narrative");
_Results = new MultipleAssociation<Narrative, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Narrative, FactorScoreResult.REFERENCE_FactorScoreResult);
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_Level = new SingleAssociation<Narrative, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "narrative");
_Results = new MultipleAssociation<Narrative, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Narrative, FactorScoreResult.REFERENCE_FactorScoreResult);
return this;
}
/**
* Get the attribute NarrativeCode
*/
public String getNarrativeCode ()
{
assertValid();
String valToReturn = _NarrativeCode;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getNarrativeCode ((Narrative)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 preNarrativeCodeChange (String newNarrativeCode) 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 postNarrativeCodeChange () throws FieldException
{
}
public FieldWriteability getWriteability_NarrativeCode ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute NarrativeCode. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setNarrativeCode (String newNarrativeCode) throws FieldException
{
boolean oldAndNewIdentical = HELPER_NarrativeCode.compare (_NarrativeCode, newNarrativeCode);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newNarrativeCode = bhd.setNarrativeCode ((Narrative)this, newNarrativeCode);
oldAndNewIdentical = HELPER_NarrativeCode.compare (_NarrativeCode, newNarrativeCode);
}
BusinessObjectParser.assertFieldCondition (newNarrativeCode != null, this, FIELD_NarrativeCode, "mandatory");
if (FIELD_NarrativeCode_Validators.length > 0)
{
Object newNarrativeCodeObj = HELPER_NarrativeCode.toObject (newNarrativeCode);
if (newNarrativeCodeObj != null)
{
int loopMax = FIELD_NarrativeCode_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_NarrativeCode);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_NarrativeCode_Validators[v].checkAttribute (this, FIELD_NarrativeCode, metadata, newNarrativeCodeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_NarrativeCode () != FieldWriteability.FALSE, "Field NarrativeCode is not writeable");
preNarrativeCodeChange (newNarrativeCode);
markFieldChange (FIELD_NarrativeCode);
_NarrativeCode = newNarrativeCode;
postFieldChange (FIELD_NarrativeCode);
postNarrativeCodeChange ();
}
}
/**
* Get the attribute Description
*/
public String getDescription ()
{
assertValid();
String valToReturn = _Description;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getDescription ((Narrative)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preDescriptionChange (String newDescription) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postDescriptionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Description ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Description. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDescription (String newDescription) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newDescription = bhd.setDescription ((Narrative)this, newDescription);
oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
}
if (FIELD_Description_Validators.length > 0)
{
Object newDescriptionObj = HELPER_Description.toObject (newDescription);
if (newDescriptionObj != null)
{
int loopMax = FIELD_Description_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_Description);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Description_Validators[v].checkAttribute (this, FIELD_Description, metadata, newDescriptionObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Description () != FieldWriteability.FALSE, "Field Description is not writeable");
preDescriptionChange (newDescription);
markFieldChange (FIELD_Description);
_Description = newDescription;
postFieldChange (FIELD_Description);
postDescriptionChange ();
}
}
/**
* Get the attribute GraphicNotes
*/
public String getGraphicNotes ()
{
assertValid();
String valToReturn = _GraphicNotes;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getGraphicNotes ((Narrative)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 preGraphicNotesChange (String newGraphicNotes) 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 postGraphicNotesChange () throws FieldException
{
}
public FieldWriteability getWriteability_GraphicNotes ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute GraphicNotes. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setGraphicNotes (String newGraphicNotes) throws FieldException
{
boolean oldAndNewIdentical = HELPER_GraphicNotes.compare (_GraphicNotes, newGraphicNotes);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newGraphicNotes = bhd.setGraphicNotes ((Narrative)this, newGraphicNotes);
oldAndNewIdentical = HELPER_GraphicNotes.compare (_GraphicNotes, newGraphicNotes);
}
if (FIELD_GraphicNotes_Validators.length > 0)
{
Object newGraphicNotesObj = HELPER_GraphicNotes.toObject (newGraphicNotes);
if (newGraphicNotesObj != null)
{
int loopMax = FIELD_GraphicNotes_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_GraphicNotes);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_GraphicNotes_Validators[v].checkAttribute (this, FIELD_GraphicNotes, metadata, newGraphicNotesObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_GraphicNotes () != FieldWriteability.FALSE, "Field GraphicNotes is not writeable");
preGraphicNotesChange (newGraphicNotes);
markFieldChange (FIELD_GraphicNotes);
_GraphicNotes = newGraphicNotes;
postFieldChange (FIELD_GraphicNotes);
postGraphicNotesChange ();
}
}
/**
* Get the attribute SummaryNotes
*/
public String getSummaryNotes ()
{
assertValid();
String valToReturn = _SummaryNotes;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getSummaryNotes ((Narrative)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 preSummaryNotesChange (String newSummaryNotes) 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 postSummaryNotesChange () throws FieldException
{
}
public FieldWriteability getWriteability_SummaryNotes ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute SummaryNotes. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setSummaryNotes (String newSummaryNotes) throws FieldException
{
boolean oldAndNewIdentical = HELPER_SummaryNotes.compare (_SummaryNotes, newSummaryNotes);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newSummaryNotes = bhd.setSummaryNotes ((Narrative)this, newSummaryNotes);
oldAndNewIdentical = HELPER_SummaryNotes.compare (_SummaryNotes, newSummaryNotes);
}
if (FIELD_SummaryNotes_Validators.length > 0)
{
Object newSummaryNotesObj = HELPER_SummaryNotes.toObject (newSummaryNotes);
if (newSummaryNotesObj != null)
{
int loopMax = FIELD_SummaryNotes_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_SummaryNotes);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_SummaryNotes_Validators[v].checkAttribute (this, FIELD_SummaryNotes, metadata, newSummaryNotesObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_SummaryNotes () != FieldWriteability.FALSE, "Field SummaryNotes is not writeable");
preSummaryNotesChange (newSummaryNotes);
markFieldChange (FIELD_SummaryNotes);
_SummaryNotes = newSummaryNotes;
postFieldChange (FIELD_SummaryNotes);
postSummaryNotesChange ();
}
}
/**
* Get the attribute ModConnect
*/
public String getModConnect ()
{
assertValid();
String valToReturn = _ModConnect;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getModConnect ((Narrative)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 preModConnectChange (String newModConnect) 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 postModConnectChange () throws FieldException
{
}
public FieldWriteability getWriteability_ModConnect ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ModConnect. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setModConnect (String newModConnect) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ModConnect.compare (_ModConnect, newModConnect);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newModConnect = bhd.setModConnect ((Narrative)this, newModConnect);
oldAndNewIdentical = HELPER_ModConnect.compare (_ModConnect, newModConnect);
}
if (FIELD_ModConnect_Validators.length > 0)
{
Object newModConnectObj = HELPER_ModConnect.toObject (newModConnect);
if (newModConnectObj != null)
{
int loopMax = FIELD_ModConnect_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_ModConnect);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ModConnect_Validators[v].checkAttribute (this, FIELD_ModConnect, metadata, newModConnectObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ModConnect () != FieldWriteability.FALSE, "Field ModConnect is not writeable");
preModConnectChange (newModConnect);
markFieldChange (FIELD_ModConnect);
_ModConnect = newModConnect;
postFieldChange (FIELD_ModConnect);
postModConnectChange ();
}
}
/**
* Get the attribute NarrativeNotes
*/
public String getNarrativeNotes ()
{
assertValid();
String valToReturn = _NarrativeNotes;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getNarrativeNotes ((Narrative)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 preNarrativeNotesChange (String newNarrativeNotes) 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 postNarrativeNotesChange () throws FieldException
{
}
public FieldWriteability getWriteability_NarrativeNotes ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute NarrativeNotes. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setNarrativeNotes (String newNarrativeNotes) throws FieldException
{
boolean oldAndNewIdentical = HELPER_NarrativeNotes.compare (_NarrativeNotes, newNarrativeNotes);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newNarrativeNotes = bhd.setNarrativeNotes ((Narrative)this, newNarrativeNotes);
oldAndNewIdentical = HELPER_NarrativeNotes.compare (_NarrativeNotes, newNarrativeNotes);
}
if (FIELD_NarrativeNotes_Validators.length > 0)
{
Object newNarrativeNotesObj = HELPER_NarrativeNotes.toObject (newNarrativeNotes);
if (newNarrativeNotesObj != null)
{
int loopMax = FIELD_NarrativeNotes_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_NarrativeNotes);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_NarrativeNotes_Validators[v].checkAttribute (this, FIELD_NarrativeNotes, metadata, newNarrativeNotesObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_NarrativeNotes () != FieldWriteability.FALSE, "Field NarrativeNotes is not writeable");
preNarrativeNotesChange (newNarrativeNotes);
markFieldChange (FIELD_NarrativeNotes);
_NarrativeNotes = newNarrativeNotes;
postFieldChange (FIELD_NarrativeNotes);
postNarrativeNotesChange ();
}
}
/**
* Get the attribute DevelNarrative
*/
public String getDevelNarrative ()
{
assertValid();
String valToReturn = _DevelNarrative;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getDevelNarrative ((Narrative)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 preDevelNarrativeChange (String newDevelNarrative) 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 postDevelNarrativeChange () throws FieldException
{
}
public FieldWriteability getWriteability_DevelNarrative ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute DevelNarrative. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDevelNarrative (String newDevelNarrative) throws FieldException
{
boolean oldAndNewIdentical = HELPER_DevelNarrative.compare (_DevelNarrative, newDevelNarrative);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newDevelNarrative = bhd.setDevelNarrative ((Narrative)this, newDevelNarrative);
oldAndNewIdentical = HELPER_DevelNarrative.compare (_DevelNarrative, newDevelNarrative);
}
if (FIELD_DevelNarrative_Validators.length > 0)
{
Object newDevelNarrativeObj = HELPER_DevelNarrative.toObject (newDevelNarrative);
if (newDevelNarrativeObj != null)
{
int loopMax = FIELD_DevelNarrative_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_DevelNarrative);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_DevelNarrative_Validators[v].checkAttribute (this, FIELD_DevelNarrative, metadata, newDevelNarrativeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_DevelNarrative () != FieldWriteability.FALSE, "Field DevelNarrative is not writeable");
preDevelNarrativeChange (newDevelNarrative);
markFieldChange (FIELD_DevelNarrative);
_DevelNarrative = newDevelNarrative;
postFieldChange (FIELD_DevelNarrative);
postDevelNarrativeChange ();
}
}
/**
* Get the attribute Question
*/
public String getQuestion ()
{
assertValid();
String valToReturn = _Question;
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
valToReturn = bhd.getQuestion ((Narrative)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 preQuestionChange (String newQuestion) 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 postQuestionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Question ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Question. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setQuestion (String newQuestion) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Question.compare (_Question, newQuestion);
try
{
for (NarrativeBehaviourDecorator bhd : Narrative_BehaviourDecorators)
{
newQuestion = bhd.setQuestion ((Narrative)this, newQuestion);
oldAndNewIdentical = HELPER_Question.compare (_Question, newQuestion);
}
if (FIELD_Question_Validators.length > 0)
{
Object newQuestionObj = HELPER_Question.toObject (newQuestion);
if (newQuestionObj != null)
{
int loopMax = FIELD_Question_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Narrative.get (FIELD_Question);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Question_Validators[v].checkAttribute (this, FIELD_Question, metadata, newQuestionObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Question () != FieldWriteability.FALSE, "Field Question is not writeable");
preQuestionChange (newQuestion);
markFieldChange (FIELD_Question);
_Question = newQuestion;
postFieldChange (FIELD_Question);
postQuestionChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("Level");
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
{
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
{
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
{
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
{
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
{
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
{
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 Narrative:", 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 ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
result.add("Results");
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return FactorScoreResult.REFERENCE_FactorScoreResult ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return FactorScoreResult.SINGLEREFERENCE_Narrative ;
}
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return this.getResultsCount();
}
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return this.getResultsAt(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_Results.equals(attribName))
{
addToResults((FactorScoreResult)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_Results.equals(attribName))
{
removeFromResults((FactorScoreResult)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
_Results.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
if (MULTIPLEREFERENCE_Results.equals(attribName))
{
return _Results.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
public FieldWriteability getWriteability_Results ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getResultsCount () throws StorageException
{
assertValid();
return _Results.getReferencedObjectsCount ();
}
public void addToResults (FactorScoreResult newElement) throws StorageException
{
if (_Results.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (add)");
_Results.appendElement (newElement);
try
{
if (newElement.getNarrative () != this)
{
newElement.setNarrative ((Narrative)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromResults (FactorScoreResult elementToRemove) throws StorageException
{
if (_Results.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (remove)");
_Results.removeElement (elementToRemove);
try
{
if (elementToRemove.getNarrative () != null)
{
elementToRemove.setNarrative (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public FactorScoreResult getResultsAt (int index) throws StorageException
{
return (FactorScoreResult)(_Results.getElementAt (index));
}
public SortedSet<FactorScoreResult> getResultsSet () throws StorageException
{
return _Results.getSet ();
}
public void onDelete ()
{
try
{
for(FactorScoreResult referenced : CollectionUtils.reverse(getResultsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Narrative from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setNarrative(null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public Narrative newInstance ()
{
return new Narrative ();
}
public Narrative referenceInstance ()
{
return REFERENCE_Narrative;
}
public Narrative getInTransaction (ObjectTransaction t) throws StorageException
{
return getNarrativeByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_Narrative;
}
public String getBaseSetName ()
{
return "narrative";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet narrativePSet = allSets.getPersistentSet (myID, "narrative", myPSetStatus);
narrativePSet.setAttrib (FIELD_ObjectID, myID);
narrativePSet.setAttrib (FIELD_NarrativeCode, HELPER_NarrativeCode.toObject (_NarrativeCode)); //
narrativePSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
narrativePSet.setAttrib (FIELD_GraphicNotes, HELPER_GraphicNotes.toObject (_GraphicNotes)); //
narrativePSet.setAttrib (FIELD_SummaryNotes, HELPER_SummaryNotes.toObject (_SummaryNotes)); //
narrativePSet.setAttrib (FIELD_ModConnect, HELPER_ModConnect.toObject (_ModConnect)); //
narrativePSet.setAttrib (FIELD_NarrativeNotes, HELPER_NarrativeNotes.toObject (_NarrativeNotes)); //
narrativePSet.setAttrib (FIELD_DevelNarrative, HELPER_DevelNarrative.toObject (_DevelNarrative)); //
narrativePSet.setAttrib (FIELD_Question, HELPER_Question.toObject (_Question)); //
_Level.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet narrativePSet = allSets.getPersistentSet (objectID, "narrative");
_NarrativeCode = (String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, narrativePSet.getAttrib (FIELD_NarrativeCode))); //
_Description = (String)(HELPER_Description.fromObject (_Description, narrativePSet.getAttrib (FIELD_Description))); //
_GraphicNotes = (String)(HELPER_GraphicNotes.fromObject (_GraphicNotes, narrativePSet.getAttrib (FIELD_GraphicNotes))); //
_SummaryNotes = (String)(HELPER_SummaryNotes.fromObject (_SummaryNotes, narrativePSet.getAttrib (FIELD_SummaryNotes))); //
_ModConnect = (String)(HELPER_ModConnect.fromObject (_ModConnect, narrativePSet.getAttrib (FIELD_ModConnect))); //
_NarrativeNotes = (String)(HELPER_NarrativeNotes.fromObject (_NarrativeNotes, narrativePSet.getAttrib (FIELD_NarrativeNotes))); //
_DevelNarrative = (String)(HELPER_DevelNarrative.fromObject (_DevelNarrative, narrativePSet.getAttrib (FIELD_DevelNarrative))); //
_Question = (String)(HELPER_Question.fromObject (_Question, narrativePSet.getAttrib (FIELD_Question))); //
_Level.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof Narrative)
{
Narrative otherNarrative = (Narrative)other;
try
{
setNarrativeCode (otherNarrative.getNarrativeCode ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setDescription (otherNarrative.getDescription ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setGraphicNotes (otherNarrative.getGraphicNotes ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setSummaryNotes (otherNarrative.getSummaryNotes ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setModConnect (otherNarrative.getModConnect ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setNarrativeNotes (otherNarrative.getNarrativeNotes ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setDevelNarrative (otherNarrative.getDevelNarrative ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setQuestion (otherNarrative.getQuestion ());
}
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 BaseNarrative)
{
BaseNarrative sourceNarrative = (BaseNarrative)(source);
_NarrativeCode = sourceNarrative._NarrativeCode;
_Description = sourceNarrative._Description;
_GraphicNotes = sourceNarrative._GraphicNotes;
_SummaryNotes = sourceNarrative._SummaryNotes;
_ModConnect = sourceNarrative._ModConnect;
_NarrativeNotes = sourceNarrative._NarrativeNotes;
_DevelNarrative = sourceNarrative._DevelNarrative;
_Question = sourceNarrative._Question;
}
}
/**
* 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 BaseNarrative)
{
BaseNarrative sourceNarrative = (BaseNarrative)(source);
_Level.copyFrom (sourceNarrative._Level, 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 BaseNarrative)
{
BaseNarrative sourceNarrative = (BaseNarrative)(source);
_Results.copyFrom (sourceNarrative._Results, 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);
_NarrativeCode = (String)(HELPER_NarrativeCode.readExternal (_NarrativeCode, vals.get(FIELD_NarrativeCode))); //
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_GraphicNotes = (String)(HELPER_GraphicNotes.readExternal (_GraphicNotes, vals.get(FIELD_GraphicNotes))); //
_SummaryNotes = (String)(HELPER_SummaryNotes.readExternal (_SummaryNotes, vals.get(FIELD_SummaryNotes))); //
_ModConnect = (String)(HELPER_ModConnect.readExternal (_ModConnect, vals.get(FIELD_ModConnect))); //
_NarrativeNotes = (String)(HELPER_NarrativeNotes.readExternal (_NarrativeNotes, vals.get(FIELD_NarrativeNotes))); //
_DevelNarrative = (String)(HELPER_DevelNarrative.readExternal (_DevelNarrative, vals.get(FIELD_DevelNarrative))); //
_Question = (String)(HELPER_Question.readExternal (_Question, vals.get(FIELD_Question))); //
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_NarrativeCode, HELPER_NarrativeCode.writeExternal (_NarrativeCode));
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (FIELD_GraphicNotes, HELPER_GraphicNotes.writeExternal (_GraphicNotes));
vals.put (FIELD_SummaryNotes, HELPER_SummaryNotes.writeExternal (_SummaryNotes));
vals.put (FIELD_ModConnect, HELPER_ModConnect.writeExternal (_ModConnect));
vals.put (FIELD_NarrativeNotes, HELPER_NarrativeNotes.writeExternal (_NarrativeNotes));
vals.put (FIELD_DevelNarrative, HELPER_DevelNarrative.writeExternal (_DevelNarrative));
vals.put (FIELD_Question, HELPER_Question.writeExternal (_Question));
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseNarrative)
{
BaseNarrative otherNarrative = (BaseNarrative)(other);
if (!HELPER_NarrativeCode.compare(this._NarrativeCode, otherNarrative._NarrativeCode))
{
listener.notifyFieldChange(this, other, FIELD_NarrativeCode, HELPER_NarrativeCode.toObject(this._NarrativeCode), HELPER_NarrativeCode.toObject(otherNarrative._NarrativeCode));
}
if (!HELPER_Description.compare(this._Description, otherNarrative._Description))
{
listener.notifyFieldChange(this, other, FIELD_Description, HELPER_Description.toObject(this._Description), HELPER_Description.toObject(otherNarrative._Description));
}
if (!HELPER_GraphicNotes.compare(this._GraphicNotes, otherNarrative._GraphicNotes))
{
listener.notifyFieldChange(this, other, FIELD_GraphicNotes, HELPER_GraphicNotes.toObject(this._GraphicNotes), HELPER_GraphicNotes.toObject(otherNarrative._GraphicNotes));
}
if (!HELPER_SummaryNotes.compare(this._SummaryNotes, otherNarrative._SummaryNotes))
{
listener.notifyFieldChange(this, other, FIELD_SummaryNotes, HELPER_SummaryNotes.toObject(this._SummaryNotes), HELPER_SummaryNotes.toObject(otherNarrative._SummaryNotes));
}
if (!HELPER_ModConnect.compare(this._ModConnect, otherNarrative._ModConnect))
{
listener.notifyFieldChange(this, other, FIELD_ModConnect, HELPER_ModConnect.toObject(this._ModConnect), HELPER_ModConnect.toObject(otherNarrative._ModConnect));
}
if (!HELPER_NarrativeNotes.compare(this._NarrativeNotes, otherNarrative._NarrativeNotes))
{
listener.notifyFieldChange(this, other, FIELD_NarrativeNotes, HELPER_NarrativeNotes.toObject(this._NarrativeNotes), HELPER_NarrativeNotes.toObject(otherNarrative._NarrativeNotes));
}
if (!HELPER_DevelNarrative.compare(this._DevelNarrative, otherNarrative._DevelNarrative))
{
listener.notifyFieldChange(this, other, FIELD_DevelNarrative, HELPER_DevelNarrative.toObject(this._DevelNarrative), HELPER_DevelNarrative.toObject(otherNarrative._DevelNarrative));
}
if (!HELPER_Question.compare(this._Question, otherNarrative._Question))
{
listener.notifyFieldChange(this, other, FIELD_Question, HELPER_Question.toObject(this._Question), HELPER_Question.toObject(otherNarrative._Question));
}
// Compare single assocs
_Level.compare (otherNarrative._Level, listener);
// Compare multiple assocs
_Results.compare (otherNarrative._Results, listener);
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_NarrativeCode, HELPER_NarrativeCode.toObject(getNarrativeCode()));
visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription()));
visitor.visitField(this, FIELD_GraphicNotes, HELPER_GraphicNotes.toObject(getGraphicNotes()));
visitor.visitField(this, FIELD_SummaryNotes, HELPER_SummaryNotes.toObject(getSummaryNotes()));
visitor.visitField(this, FIELD_ModConnect, HELPER_ModConnect.toObject(getModConnect()));
visitor.visitField(this, FIELD_NarrativeNotes, HELPER_NarrativeNotes.toObject(getNarrativeNotes()));
visitor.visitField(this, FIELD_DevelNarrative, HELPER_DevelNarrative.toObject(getDevelNarrative()));
visitor.visitField(this, FIELD_Question, HELPER_Question.toObject(getQuestion()));
visitor.visitAssociation (_Level);
visitor.visitAssociation (_Results);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Level))
{
visitor.visit (_Level);
}
if (scope.includes (_Results))
{
visitor.visit (_Results);
}
}
public static Narrative createNarrative (ObjectTransaction transaction) throws StorageException
{
Narrative result = new Narrative ();
result.initialiseNewObject (transaction);
return result;
}
public static Narrative getNarrativeByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (Narrative)(transaction.getObjectByID (REFERENCE_Narrative, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_NarrativeCode))
{
return filter.matches (getNarrativeCode ());
}
else if (attribName.equals (FIELD_Description))
{
return filter.matches (getDescription ());
}
else if (attribName.equals (FIELD_GraphicNotes))
{
return filter.matches (getGraphicNotes ());
}
else if (attribName.equals (FIELD_SummaryNotes))
{
return filter.matches (getSummaryNotes ());
}
else if (attribName.equals (FIELD_ModConnect))
{
return filter.matches (getModConnect ());
}
else if (attribName.equals (FIELD_NarrativeNotes))
{
return filter.matches (getNarrativeNotes ());
}
else if (attribName.equals (FIELD_DevelNarrative))
{
return filter.matches (getDevelNarrative ());
}
else if (attribName.equals (FIELD_Question))
{
return filter.matches (getQuestion ());
}
else if (attribName.equals (SINGLEREFERENCE_Level))
{
return filter.matches (getLevel ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Narrative>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "narrative.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "narrative.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "narrative.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andNarrativeCode (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.narrative_code", "NarrativeCode");
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.narrative_desc", "Description");
return this;
}
public SearchAll andGraphicNotes (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.graphic_notes", "GraphicNotes");
return this;
}
public SearchAll andSummaryNotes (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.exec_sum_notes", "SummaryNotes");
return this;
}
public SearchAll andModConnect (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.mod_connect_flag", "ModConnect");
return this;
}
public SearchAll andNarrativeNotes (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.narrative_notes", "NarrativeNotes");
return this;
}
public SearchAll andDevelNarrative (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.devel_narrative", "DevelNarrative");
return this;
}
public SearchAll andQuestion (QueryFilter<String> filter)
{
filter.addFilter (context, "narrative.question", "Question");
return this;
}
public SearchAll andLevel (QueryFilter<Level> filter)
{
filter.addFilter (context, "narrative.level_number", "Level");
return this;
}
public Narrative[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Narrative, SEARCH_All, criteria);
Set<Narrative> typedResults = new LinkedHashSet <Narrative> ();
for (BaseBusinessClass bbcResult : results)
{
Narrative aResult = (Narrative)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Narrative[0]);
}
}
public static Narrative[]
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_NarrativeCode))
{
return HELPER_NarrativeCode.toObject (getNarrativeCode ());
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description.toObject (getDescription ());
}
else if (attribName.equals (FIELD_GraphicNotes))
{
return HELPER_GraphicNotes.toObject (getGraphicNotes ());
}
else if (attribName.equals (FIELD_SummaryNotes))
{
return HELPER_SummaryNotes.toObject (getSummaryNotes ());
}
else if (attribName.equals (FIELD_ModConnect))
{
return HELPER_ModConnect.toObject (getModConnect ());
}
else if (attribName.equals (FIELD_NarrativeNotes))
{
return HELPER_NarrativeNotes.toObject (getNarrativeNotes ());
}
else if (attribName.equals (FIELD_DevelNarrative))
{
return HELPER_DevelNarrative.toObject (getDevelNarrative ());
}
else if (attribName.equals (FIELD_Question))
{
return HELPER_Question.toObject (getQuestion ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_NarrativeCode))
{
return HELPER_NarrativeCode;
}
else if (attribName.equals (FIELD_Description))
{
return HELPER_Description;
}
else if (attribName.equals (FIELD_GraphicNotes))
{
return HELPER_GraphicNotes;
}
else if (attribName.equals (FIELD_SummaryNotes))
{
return HELPER_SummaryNotes;
}
else if (attribName.equals (FIELD_ModConnect))
{
return HELPER_ModConnect;
}
else if (attribName.equals (FIELD_NarrativeNotes))
{
return HELPER_NarrativeNotes;
}
else if (attribName.equals (FIELD_DevelNarrative))
{
return HELPER_DevelNarrative;
}
else if (attribName.equals (FIELD_Question))
{
return HELPER_Question;
}
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_NarrativeCode))
{
setNarrativeCode ((String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, attribValue)));
}
else if (attribName.equals (FIELD_Description))
{
setDescription ((String)(HELPER_Description.fromObject (_Description, attribValue)));
}
else if (attribName.equals (FIELD_GraphicNotes))
{
setGraphicNotes ((String)(HELPER_GraphicNotes.fromObject (_GraphicNotes, attribValue)));
}
else if (attribName.equals (FIELD_SummaryNotes))
{
setSummaryNotes ((String)(HELPER_SummaryNotes.fromObject (_SummaryNotes, attribValue)));
}
else if (attribName.equals (FIELD_ModConnect))
{
setModConnect ((String)(HELPER_ModConnect.fromObject (_ModConnect, attribValue)));
}
else if (attribName.equals (FIELD_NarrativeNotes))
{
setNarrativeNotes ((String)(HELPER_NarrativeNotes.fromObject (_NarrativeNotes, attribValue)));
}
else if (attribName.equals (FIELD_DevelNarrative))
{
setDevelNarrative ((String)(HELPER_DevelNarrative.fromObject (_DevelNarrative, attribValue)));
}
else if (attribName.equals (FIELD_Question))
{
setQuestion ((String)(HELPER_Question.fromObject (_Question, 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_NarrativeCode))
{
return getWriteability_NarrativeCode ();
}
else if (fieldName.equals (FIELD_Description))
{
return getWriteability_Description ();
}
else if (fieldName.equals (FIELD_GraphicNotes))
{
return getWriteability_GraphicNotes ();
}
else if (fieldName.equals (FIELD_SummaryNotes))
{
return getWriteability_SummaryNotes ();
}
else if (fieldName.equals (FIELD_ModConnect))
{
return getWriteability_ModConnect ();
}
else if (fieldName.equals (FIELD_NarrativeNotes))
{
return getWriteability_NarrativeNotes ();
}
else if (fieldName.equals (FIELD_DevelNarrative))
{
return getWriteability_DevelNarrative ();
}
else if (fieldName.equals (FIELD_Question))
{
return getWriteability_Question ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Results))
{
return getWriteability_Results ();
}
else if (fieldName.equals (SINGLEREFERENCE_Level))
{
return getWriteability_Level ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_NarrativeCode () != FieldWriteability.TRUE)
{
fields.add (FIELD_NarrativeCode);
}
if (getWriteability_Description () != FieldWriteability.TRUE)
{
fields.add (FIELD_Description);
}
if (getWriteability_GraphicNotes () != FieldWriteability.TRUE)
{
fields.add (FIELD_GraphicNotes);
}
if (getWriteability_SummaryNotes () != FieldWriteability.TRUE)
{
fields.add (FIELD_SummaryNotes);
}
if (getWriteability_ModConnect () != FieldWriteability.TRUE)
{
fields.add (FIELD_ModConnect);
}
if (getWriteability_NarrativeNotes () != FieldWriteability.TRUE)
{
fields.add (FIELD_NarrativeNotes);
}
if (getWriteability_DevelNarrative () != FieldWriteability.TRUE)
{
fields.add (FIELD_DevelNarrative);
}
if (getWriteability_Question () != FieldWriteability.TRUE)
{
fields.add (FIELD_Question);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_NarrativeCode.getAttribObject (getClass (), _NarrativeCode, true, FIELD_NarrativeCode));
result.add(HELPER_Description.getAttribObject (getClass (), _Description, false, FIELD_Description));
result.add(HELPER_GraphicNotes.getAttribObject (getClass (), _GraphicNotes, false, FIELD_GraphicNotes));
result.add(HELPER_SummaryNotes.getAttribObject (getClass (), _SummaryNotes, false, FIELD_SummaryNotes));
result.add(HELPER_ModConnect.getAttribObject (getClass (), _ModConnect, false, FIELD_ModConnect));
result.add(HELPER_NarrativeNotes.getAttribObject (getClass (), _NarrativeNotes, false, FIELD_NarrativeNotes));
result.add(HELPER_DevelNarrative.getAttribObject (getClass (), _DevelNarrative, false, FIELD_DevelNarrative));
result.add(HELPER_Question.getAttribObject (getClass (), _Question, false, FIELD_Question));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_Narrative.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_Narrative.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_Narrative.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_Narrative.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 NarrativeBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<Narrative>
{
/**
* Get the attribute NarrativeCode
*/
public String getNarrativeCode (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute NarrativeCode.
* May modify the field beforehand
* Occurs before validation.
*/
public String setNarrativeCode (Narrative obj, String newNarrativeCode) throws FieldException
{
return newNarrativeCode;
}
/**
* Get the attribute Description
*/
public String getDescription (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute Description.
* May modify the field beforehand
* Occurs before validation.
*/
public String setDescription (Narrative obj, String newDescription) throws FieldException
{
return newDescription;
}
/**
* Get the attribute GraphicNotes
*/
public String getGraphicNotes (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute GraphicNotes.
* May modify the field beforehand
* Occurs before validation.
*/
public String setGraphicNotes (Narrative obj, String newGraphicNotes) throws FieldException
{
return newGraphicNotes;
}
/**
* Get the attribute SummaryNotes
*/
public String getSummaryNotes (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute SummaryNotes.
* May modify the field beforehand
* Occurs before validation.
*/
public String setSummaryNotes (Narrative obj, String newSummaryNotes) throws FieldException
{
return newSummaryNotes;
}
/**
* Get the attribute ModConnect
*/
public String getModConnect (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute ModConnect.
* May modify the field beforehand
* Occurs before validation.
*/
public String setModConnect (Narrative obj, String newModConnect) throws FieldException
{
return newModConnect;
}
/**
* Get the attribute NarrativeNotes
*/
public String getNarrativeNotes (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute NarrativeNotes.
* May modify the field beforehand
* Occurs before validation.
*/
public String setNarrativeNotes (Narrative obj, String newNarrativeNotes) throws FieldException
{
return newNarrativeNotes;
}
/**
* Get the attribute DevelNarrative
*/
public String getDevelNarrative (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute DevelNarrative.
* May modify the field beforehand
* Occurs before validation.
*/
public String setDevelNarrative (Narrative obj, String newDevelNarrative) throws FieldException
{
return newDevelNarrative;
}
/**
* Get the attribute Question
*/
public String getQuestion (Narrative obj, String original)
{
return original;
}
/**
* Change the value set for attribute Question.
* May modify the field beforehand
* Occurs before validation.
*/
public String setQuestion (Narrative obj, String newQuestion) throws FieldException
{
return newQuestion;
}
}
public ORMPipeLine pipes()
{
return new NarrativePipeLineFactory<Narrative, Narrative> ((Narrative)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public NarrativePipeLineFactory<Narrative, Narrative> pipelineNarrative()
{
return (NarrativePipeLineFactory<Narrative, Narrative>) pipes();
}
public static NarrativePipeLineFactory<Narrative, Narrative> pipesNarrative(Collection<Narrative> items)
{
return REFERENCE_Narrative.new NarrativePipeLineFactory<Narrative, Narrative> (items);
}
public static NarrativePipeLineFactory<Narrative, Narrative> pipesNarrative(Narrative[] _items)
{
return pipesNarrative(Arrays.asList (_items));
}
public static NarrativePipeLineFactory<Narrative, Narrative> pipesNarrative()
{
return pipesNarrative((Collection)null);
}
public class NarrativePipeLineFactory<From extends BaseBusinessClass, Me extends Narrative> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> NarrativePipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public NarrativePipeLineFactory (From seed)
{
super(seed);
}
public NarrativePipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Results"))
{
return toResults ();
}
if (name.equals ("NarrativeCode"))
{
return toNarrativeCode ();
}
if (name.equals ("Description"))
{
return toDescription ();
}
if (name.equals ("GraphicNotes"))
{
return toGraphicNotes ();
}
if (name.equals ("SummaryNotes"))
{
return toSummaryNotes ();
}
if (name.equals ("ModConnect"))
{
return toModConnect ();
}
if (name.equals ("NarrativeNotes"))
{
return toNarrativeNotes ();
}
if (name.equals ("DevelNarrative"))
{
return toDevelNarrative ();
}
if (name.equals ("Question"))
{
return toQuestion ();
}
if (name.equals ("Level"))
{
return toLevel ();
}
return super.to(name);
}
public PipeLine<From, String> toNarrativeCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_NarrativeCode)); }
public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description)); }
public PipeLine<From, String> toGraphicNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_GraphicNotes)); }
public PipeLine<From, String> toSummaryNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_SummaryNotes)); }
public PipeLine<From, String> toModConnect () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ModConnect)); }
public PipeLine<From, String> toNarrativeNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_NarrativeNotes)); }
public PipeLine<From, String> toDevelNarrative () { return pipe(new ORMAttributePipe<Me, String>(FIELD_DevelNarrative)); }
public PipeLine<From, String> toQuestion () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Question)); }
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 FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults () { return toResults(Filter.ALL); }
public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults (Filter<FactorScoreResult> filter)
{
return FactorScoreResult.REFERENCE_FactorScoreResult.new FactorScoreResultPipeLineFactory<From, FactorScoreResult> (this, new ORMMultiAssocPipe<Me, FactorScoreResult>(MULTIPLEREFERENCE_Results, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyNarrative extends Narrative
{
// Default constructor primarily to support Externalisable
public DummyNarrative()
{
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 int getResultsCount () throws StorageException
{
return 0;
}
public FactorScoreResult getResultsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Results");
}
public SortedSet getResultsSet () throws StorageException
{
return new TreeSet();
}
}
...@@ -41,8 +41,11 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -41,8 +41,11 @@ public abstract class BaseQuestion extends BaseBusinessClass
public static final String FIELD_Description = "Description"; public static final String FIELD_Description = "Description";
public static final String SINGLEREFERENCE_Section = "Section"; public static final String SINGLEREFERENCE_Section = "Section";
public static final String BACKREF_Section = ""; public static final String BACKREF_Section = "";
public static final String MULTIPLEREFERENCE_Factors = "Factors";
public static final String BACKREF_Factors = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -58,6 +61,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -58,6 +61,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
private MultipleAssociation<Question, FactorQuestionLink> _Factors;
// Map of maps of metadata // Map of maps of metadata
...@@ -75,10 +79,12 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -75,10 +79,12 @@ public abstract class BaseQuestion extends BaseBusinessClass
try try
{ {
String tmp_Factors = FactorQuestionLink.BACKREF_Question;
String tmp_Section = Section.BACKREF_Questions; String tmp_Section = Section.BACKREF_Questions;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Factors();
setupAssocMetaData_Section(); setupAssocMetaData_Section();
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -96,6 +102,20 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -96,6 +102,20 @@ public abstract class BaseQuestion extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Factors()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Question");
metaInfo.put ("name", "Factors");
metaInfo.put ("type", "FactorQuestionLink");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Question.Factors:", metaInfo);
ATTRIBUTES_METADATA_Question.put (MULTIPLEREFERENCE_Factors, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Section() private static void setupAssocMetaData_Section()
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -166,6 +186,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -166,6 +186,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
super._initialiseAssociations (); super._initialiseAssociations ();
_Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "quest_lin"); _Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "quest_lin");
_Factors = new MultipleAssociation<Question, FactorQuestionLink> (this, MULTIPLEREFERENCE_Factors, FactorQuestionLink.SINGLEREFERENCE_Question, FactorQuestionLink.REFERENCE_FactorQuestionLink);
} }
...@@ -176,6 +197,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -176,6 +197,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
super.initialiseReference (); super.initialiseReference ();
_Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "quest_lin"); _Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "quest_lin");
_Factors = new MultipleAssociation<Question, FactorQuestionLink> (this, MULTIPLEREFERENCE_Factors, FactorQuestionLink.SINGLEREFERENCE_Question, FactorQuestionLink.REFERENCE_FactorQuestionLink);
return this; return this;
...@@ -516,6 +538,8 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -516,6 +538,8 @@ public abstract class BaseQuestion extends BaseBusinessClass
List result = super.getMultiAssocs (); List result = super.getMultiAssocs ();
result.add("Factors");
return result; return result;
} }
...@@ -527,6 +551,11 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -527,6 +551,11 @@ public abstract class BaseQuestion extends BaseBusinessClass
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName) public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
return FactorQuestionLink.REFERENCE_FactorQuestionLink ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -535,6 +564,11 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -535,6 +564,11 @@ public abstract class BaseQuestion extends BaseBusinessClass
public String getMultiAssocBackReference(String attribName) public String getMultiAssocBackReference(String attribName)
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
return FactorQuestionLink.SINGLEREFERENCE_Question ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -546,6 +580,11 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -546,6 +580,11 @@ public abstract class BaseQuestion extends BaseBusinessClass
public int getMultiAssocCount(String attribName) throws StorageException public int getMultiAssocCount(String attribName) throws StorageException
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
return this.getFactorsCount();
}
return super.getMultiAssocCount(attribName); return super.getMultiAssocCount(attribName);
} }
...@@ -557,6 +596,11 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -557,6 +596,11 @@ public abstract class BaseQuestion extends BaseBusinessClass
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
return this.getFactorsAt(index);
}
return super.getMultiAssocAt(attribName, index); return super.getMultiAssocAt(attribName, index);
} }
...@@ -568,6 +612,13 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -568,6 +612,13 @@ public abstract class BaseQuestion extends BaseBusinessClass
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
addToFactors((FactorQuestionLink)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement); super.addToMultiAssoc(attribName, newElement);
} }
...@@ -578,6 +629,13 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -578,6 +629,13 @@ public abstract class BaseQuestion extends BaseBusinessClass
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
removeFromFactors((FactorQuestionLink)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement); super.removeFromMultiAssoc(attribName, oldElement);
} }
...@@ -586,6 +644,12 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -586,6 +644,12 @@ public abstract class BaseQuestion extends BaseBusinessClass
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements) protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
_Factors.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements); super.__loadMultiAssoc(attribName, elements);
} }
...@@ -594,12 +658,86 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -594,12 +658,86 @@ public abstract class BaseQuestion extends BaseBusinessClass
protected boolean __isMultiAssocLoaded (String attribName) protected boolean __isMultiAssocLoaded (String attribName)
{ {
if (MULTIPLEREFERENCE_Factors.equals(attribName))
{
return _Factors.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName); return super.__isMultiAssocLoaded(attribName);
} }
public FieldWriteability getWriteability_Factors ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getFactorsCount () throws StorageException
{
assertValid();
return _Factors.getReferencedObjectsCount ();
}
public void addToFactors (FactorQuestionLink newElement) throws StorageException
{
if (_Factors.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Factors () != FieldWriteability.FALSE, "MultiAssoc Factors is not writeable (add)");
_Factors.appendElement (newElement);
try
{
if (newElement.getQuestion () != this)
{
newElement.setQuestion ((Question)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromFactors (FactorQuestionLink elementToRemove) throws StorageException
{
if (_Factors.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Factors () != FieldWriteability.FALSE, "MultiAssoc Factors is not writeable (remove)");
_Factors.removeElement (elementToRemove);
try
{
if (elementToRemove.getQuestion () != null)
{
elementToRemove.setQuestion (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public FactorQuestionLink getFactorsAt (int index) throws StorageException
{
return (FactorQuestionLink)(_Factors.getElementAt (index));
}
public SortedSet<FactorQuestionLink> getFactorsSet () throws StorageException
{
return _Factors.getSet ();
}
public void onDelete () public void onDelete ()
...@@ -620,6 +758,12 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -620,6 +758,12 @@ public abstract class BaseQuestion extends BaseBusinessClass
} }
} }
for(FactorQuestionLink referenced : CollectionUtils.reverse(getFactorsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Question from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setQuestion(null);
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -771,6 +915,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -771,6 +915,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
BaseQuestion sourceQuestion = (BaseQuestion)(source); BaseQuestion sourceQuestion = (BaseQuestion)(source);
_Factors.copyFrom (sourceQuestion._Factors, linkToGhosts);
} }
} }
...@@ -793,6 +938,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -793,6 +938,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
_Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); // _Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
_Section.readExternalData(vals.get(SINGLEREFERENCE_Section)); _Section.readExternalData(vals.get(SINGLEREFERENCE_Section));
_Factors.readExternalData(vals.get(MULTIPLEREFERENCE_Factors));
} }
...@@ -806,6 +952,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -806,6 +952,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description)); vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
vals.put (SINGLEREFERENCE_Section, _Section.writeExternalData()); vals.put (SINGLEREFERENCE_Section, _Section.writeExternalData());
vals.put (MULTIPLEREFERENCE_Factors, _Factors.writeExternalData());
} }
...@@ -829,6 +976,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -829,6 +976,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
// Compare multiple assocs // Compare multiple assocs
_Factors.compare (otherQuestion._Factors, listener);
} }
} }
...@@ -848,6 +996,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -848,6 +996,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription())); visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription()));
visitor.visitAssociation (_Section); visitor.visitAssociation (_Section);
visitor.visitAssociation (_Factors);
} }
...@@ -860,6 +1009,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -860,6 +1009,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
visitor.visit (_Section); visitor.visit (_Section);
} }
if (scope.includes (_Factors))
{
visitor.visit (_Factors);
}
} }
...@@ -900,6 +1053,69 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -900,6 +1053,69 @@ public abstract class BaseQuestion extends BaseBusinessClass
} }
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Question>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "quest_lin.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "quest_lin.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "quest_lin.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "quest_lin.left_quest", "Description");
return this;
}
public SearchAll andSection (QueryFilter<Section> filter)
{
filter.addFilter (context, "quest_lin.section_number", "Section");
return this;
}
public Question[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Question, SEARCH_All, criteria);
Set<Question> typedResults = new LinkedHashSet <Question> ();
for (BaseBusinessClass bbcResult : results)
{
Question aResult = (Question)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Question[0]);
}
}
public static Question[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
...@@ -970,6 +1186,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -970,6 +1186,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
return getWriteability_Description (); return getWriteability_Description ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_Factors))
{
return getWriteability_Factors ();
}
else if (fieldName.equals (SINGLEREFERENCE_Section)) else if (fieldName.equals (SINGLEREFERENCE_Section))
{ {
return getWriteability_Section (); return getWriteability_Section ();
...@@ -1119,6 +1339,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1119,6 +1339,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
public PipeLine<From, ? extends Object> to(String name) public PipeLine<From, ? extends Object> to(String name)
{ {
if (name.equals ("Factors"))
{
return toFactors ();
}
if (name.equals ("Description")) if (name.equals ("Description"))
{ {
return toDescription (); return toDescription ();
...@@ -1140,6 +1364,12 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1140,6 +1364,12 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
return Section.REFERENCE_Section.new SectionPipeLineFactory<From, Section> (this, new ORMSingleAssocPipe<Me, Section>(SINGLEREFERENCE_Section, filter)); return Section.REFERENCE_Section.new SectionPipeLineFactory<From, Section> (this, new ORMSingleAssocPipe<Me, Section>(SINGLEREFERENCE_Section, filter));
} }
public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toFactors () { return toFactors(Filter.ALL); }
public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toFactors (Filter<FactorQuestionLink> filter)
{
return FactorQuestionLink.REFERENCE_FactorQuestionLink.new FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> (this, new ORMMultiAssocPipe<Me, FactorQuestionLink>(MULTIPLEREFERENCE_Factors, filter));
}
} }
...@@ -1185,6 +1415,23 @@ class DummyQuestion extends Question ...@@ -1185,6 +1415,23 @@ class DummyQuestion extends Question
return Section.DUMMY_Section.getObjectID(); return Section.DUMMY_Section.getObjectID();
} }
public int getFactorsCount () throws StorageException
{
return 0;
}
public FactorQuestionLink getFactorsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Factors");
}
public SortedSet getFactorsSet () throws StorageException
{
return new TreeSet();
}
} }
...@@ -46,6 +46,7 @@ public abstract class BaseSection extends BaseBusinessClass ...@@ -46,6 +46,7 @@ public abstract class BaseSection extends BaseBusinessClass
public static final String BACKREF_Questions = ""; public static final String BACKREF_Questions = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -1022,6 +1023,69 @@ public abstract class BaseSection extends BaseBusinessClass ...@@ -1022,6 +1023,69 @@ public abstract class BaseSection extends BaseBusinessClass
} }
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<Section>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "quest_hdr.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "quest_hdr.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "quest_hdr.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "quest_hdr.quest_hdr_desc", "Description");
return this;
}
public SearchAll andQuestionType (QueryFilter<QuestionType> filter)
{
filter.addFilter (context, "quest_hdr.quest_type_flag", "QuestionType");
return this;
}
public Section[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Section, SEARCH_All, criteria);
Set<Section> typedResults = new LinkedHashSet <Section> ();
for (BaseBusinessClass bbcResult : results)
{
Section aResult = (Section)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Section[0]);
}
}
public static Section[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="candidate.object_id is not null" orderBy="candidate.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -301,6 +301,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -301,6 +301,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
} }
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
...@@ -412,6 +416,44 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -412,6 +416,44 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (Candidate.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY candidate.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: candidate.object_id is not null
String preFilter = "(candidate.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}candidate " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
<BUSINESSCLASS name="Factor" package="performa.orm"> <BUSINESSCLASS name="Factor" package="performa.orm">
<MULTIPLEREFERENCE name="FactorLinks" type="FactorLevelLink" backreferenceName="Factor" /> <MULTIPLEREFERENCE name="Levels" type="FactorLevelLink" backreferenceName="Factor" />
<MULTIPLEREFERENCE name="Questions" type="FactorQuestionLink" backreferenceName="Factor" />
<MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Factor" />
<TABLE name="factor" tablePrefix="object" polymorphic="FALSE"> <TABLE name="factor" tablePrefix="object" polymorphic="FALSE">
...@@ -12,6 +14,8 @@ ...@@ -12,6 +14,8 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="factor.object_id is not null" orderBy="factor.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
<ATTRIB name="ZScoreWeight" type="Double" dbcol="z_score_wght"/> <ATTRIB name="ZScoreWeight" type="Double" dbcol="z_score_wght"/>
<ATTRIB name="ZScoreWeight2" type="Double" dbcol="z_score_wght_2"/> <ATTRIB name="ZScoreWeight2" type="Double" dbcol="z_score_wght_2"/>
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_number" backreferenceName="FactorLinks" /> <SINGLEREFERENCE name="Level" type="Level" dbcol="level_number" backreferenceName="Factors" />
<SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number" backreferenceName="FactorLinks" /> <SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number" backreferenceName="Levels" />
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="factor_hdr.object_id is not null" orderBy="factor_hdr.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -295,6 +295,10 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -295,6 +295,10 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
} }
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
...@@ -406,6 +410,44 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -406,6 +410,44 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (FactorLevelLink.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY factor_hdr.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: factor_hdr.object_id is not null
String preFilter = "(factor_hdr.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}factor_hdr " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
...@@ -249,6 +249,10 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -249,6 +249,10 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
} }
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
...@@ -360,6 +364,44 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -360,6 +364,44 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (Factor.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY factor.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: factor.object_id is not null
String preFilter = "(factor.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}factor " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
<ATTRIB name="ReverseScore" type="Boolean" dbcol="reverse_score_flag"/> <ATTRIB name="ReverseScore" type="Boolean" dbcol="reverse_score_flag"/>
<SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number" /> <SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number" backreferenceName="Questions"/>
<SINGLEREFERENCE name="Question" type="Question" dbcol="quest_number" /> <SINGLEREFERENCE name="Question" type="Question" dbcol="quest_number" backreferenceName="Factors" />
</TABLE> </TABLE>
......
...@@ -140,6 +140,26 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -140,6 +140,26 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException (); throw new RuntimeException ();
} }
else if (refName.equals (FactorQuestionLink.SINGLEREFERENCE_Factor))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_lin " +
"WHERE " + SELECT_JOINS + "factor_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else if (refName.equals (FactorQuestionLink.SINGLEREFERENCE_Question))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_lin " +
"WHERE " + SELECT_JOINS + "quest_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else else
{ {
throw new IllegalArgumentException ("Illegal reference type:" + refName); throw new IllegalArgumentException ("Illegal reference type:" + refName);
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
<ATTRIB name="FromScore" type="Integer" dbcol="from_score"/> <ATTRIB name="FromScore" type="Integer" dbcol="from_score"/>
<ATTRIB name="ToScore" type="Integer" dbcol="to_score"/> <ATTRIB name="ToScore" type="Integer" dbcol="to_score"/>
<ATTRIB name="NarrativeCode" type="String" dbcol="narrative_code" length="15"/>
<ATTRIB name="ColorCode" type="ColorCode" dbcol="color_code" attribHelper="EnumeratedAttributeHelper" /> <ATTRIB name="ColorCode" type="ColorCode" dbcol="color_code" attribHelper="EnumeratedAttributeHelper" />
<SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number" /> <SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number" backreferenceName="Results"/>
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_number" /> <SINGLEREFERENCE name="Level" type="Level" dbcol="level_number" backreferenceName="Results"/>
<SINGLEREFERENCE name="Narrative" type="Narrative" dbcol="narrative_id" backreferenceName="Results"/>
</TABLE> </TABLE>
......
...@@ -29,14 +29,12 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -29,14 +29,12 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private Integer dummyFromScore; private Integer dummyFromScore;
private Integer dummyToScore; private Integer dummyToScore;
private String dummyNarrativeCode;
private ColorCode dummyColorCode; private ColorCode dummyColorCode;
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_FromScore = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_FromScore = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ToScore = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_ToScore = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_NarrativeCode = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_ColorCode = new EnumeratedAttributeHelper (ColorCode.FACTORY_ColorCode); private static final EnumeratedAttributeHelper HELPER_ColorCode = new EnumeratedAttributeHelper (ColorCode.FACTORY_ColorCode);
...@@ -46,12 +44,11 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -46,12 +44,11 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
{ {
dummyFromScore = (Integer)(HELPER_FromScore.initialise (dummyFromScore)); dummyFromScore = (Integer)(HELPER_FromScore.initialise (dummyFromScore));
dummyToScore = (Integer)(HELPER_ToScore.initialise (dummyToScore)); dummyToScore = (Integer)(HELPER_ToScore.initialise (dummyToScore));
dummyNarrativeCode = (String)(HELPER_NarrativeCode.initialise (dummyNarrativeCode));
dummyColorCode = (ColorCode)(HELPER_ColorCode.initialise (dummyColorCode)); dummyColorCode = (ColorCode)(HELPER_ColorCode.initialise (dummyColorCode));
} }
private String SELECT_COLUMNS = "{PREFIX}level_factor.object_id as id, {PREFIX}level_factor.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}level_factor.object_CREATED_DATE as CREATED_DATE, {PREFIX}level_factor.from_score, {PREFIX}level_factor.to_score, {PREFIX}level_factor.narrative_code, {PREFIX}level_factor.color_code, {PREFIX}level_factor.factor_number, {PREFIX}level_factor.level_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}level_factor.object_id as id, {PREFIX}level_factor.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}level_factor.object_CREATED_DATE as CREATED_DATE, {PREFIX}level_factor.from_score, {PREFIX}level_factor.to_score, {PREFIX}level_factor.color_code, {PREFIX}level_factor.factor_number, {PREFIX}level_factor.level_number, {PREFIX}level_factor.narrative_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -104,10 +101,10 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -104,10 +101,10 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
if (false || !level_factorPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !level_factorPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!level_factorPSet.containsAttrib(FactorScoreResult.FIELD_FromScore)|| !level_factorPSet.containsAttrib(FactorScoreResult.FIELD_FromScore)||
!level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ToScore)|| !level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ToScore)||
!level_factorPSet.containsAttrib(FactorScoreResult.FIELD_NarrativeCode)||
!level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ColorCode)|| !level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ColorCode)||
!level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Factor)|| !level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Factor)||
!level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Level)) !level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Level)||
!level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Narrative))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -153,6 +150,36 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -153,6 +150,36 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException (); throw new RuntimeException ();
} }
else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Factor))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " +
"WHERE " + SELECT_JOINS + "factor_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Level))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " +
"WHERE " + SELECT_JOINS + "level_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Narrative))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " +
"WHERE " + SELECT_JOINS + "narrative_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else else
{ {
throw new IllegalArgumentException ("Illegal reference type:" + refName); throw new IllegalArgumentException ("Illegal reference type:" + refName);
...@@ -177,10 +204,10 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -177,10 +204,10 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}level_factor " + "UPDATE {PREFIX}level_factor " +
"SET from_score = ?, to_score = ?, narrative_code = ?, color_code = ?, factor_number = ? , level_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET from_score = ?, to_score = ?, color_code = ?, factor_number = ? , level_number = ? , narrative_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE level_factor.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE level_factor.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_NarrativeCode))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Narrative)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -480,11 +507,11 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -480,11 +507,11 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
level_factorPSet.setAttrib(FactorScoreResult.FIELD_FromScore, HELPER_FromScore.getFromRS(dummyFromScore, r, "from_score")); level_factorPSet.setAttrib(FactorScoreResult.FIELD_FromScore, HELPER_FromScore.getFromRS(dummyFromScore, r, "from_score"));
level_factorPSet.setAttrib(FactorScoreResult.FIELD_ToScore, HELPER_ToScore.getFromRS(dummyToScore, r, "to_score")); level_factorPSet.setAttrib(FactorScoreResult.FIELD_ToScore, HELPER_ToScore.getFromRS(dummyToScore, r, "to_score"));
level_factorPSet.setAttrib(FactorScoreResult.FIELD_NarrativeCode, HELPER_NarrativeCode.getFromRS(dummyNarrativeCode, r, "narrative_code"));
level_factorPSet.setAttrib(FactorScoreResult.FIELD_ColorCode, HELPER_ColorCode.getFromRS(dummyColorCode, r, "color_code")); level_factorPSet.setAttrib(FactorScoreResult.FIELD_ColorCode, HELPER_ColorCode.getFromRS(dummyColorCode, r, "color_code"));
level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Factor, r.getObject ("factor_number")); level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Level, r.getObject ("level_number")); level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Level, r.getObject ("level_number"));
level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Narrative, r.getObject ("narrative_id"));
} }
...@@ -501,10 +528,10 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -501,10 +528,10 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}level_factor " + "INSERT INTO {PREFIX}level_factor " +
" (from_score, to_score, narrative_code, color_code, factor_number, level_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (from_score, to_score, color_code, factor_number, level_number, narrative_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_NarrativeCode))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))) .listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))) .listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Narrative)))) .listEntry (objectID.longID ()).toList().toArray());
level_factorPSet.setStatus (PersistentSetStatus.PROCESSED); level_factorPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
<BUSINESSCLASS name="Level" package="performa.orm"> <BUSINESSCLASS name="Level" package="performa.orm">
<MULTIPLEREFERENCE name="FactorLinks" type="FactorLevelLink" backreferenceName="Level" /> <MULTIPLEREFERENCE name="Factors" type="FactorLevelLink" backreferenceName="Level" />
<MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Level" />
<TABLE name="level" tablePrefix="object" polymorphic="FALSE"> <TABLE name="level" tablePrefix="object" polymorphic="FALSE">
...@@ -14,6 +15,8 @@ ...@@ -14,6 +15,8 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="level.object_id is not null" orderBy="level.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
...@@ -257,6 +257,10 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -257,6 +257,10 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
} }
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
...@@ -368,6 +372,44 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -368,6 +372,44 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (Level.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY level.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: level.object_id is not null
String preFilter = "(level.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}level " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
package performa.orm;
public class Narrative extends BaseNarrative
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public Narrative ()
{
// 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="Narrative" package="performa.orm">
<MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Narrative" />
<TABLE name="narrative" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="NarrativeCode" type="String" dbcol="narrative_code" length="15" mandatory="true"/>
<ATTRIB name="Description" type="String" dbcol="narrative_desc" length="30"/>
<ATTRIB name="GraphicNotes" type="String" dbcol="graphic_notes"/>
<ATTRIB name="SummaryNotes" type="String" dbcol="exec_sum_notes"/>
<ATTRIB name="ModConnect" type="String" dbcol="mod_connect_flag" length="15"/>
<ATTRIB name="NarrativeNotes" type="String" dbcol="narrative_notes"/>
<ATTRIB name="DevelNarrative" type="String" dbcol="devel_narrative" length="128"/>
<ATTRIB name="Question" type="String" dbcol="question"/>
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_number"/>
</TABLE>
<SEARCH type="All" paramFilter="narrative.object_id is not null" orderBy="narrative.object_id" />
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class NarrativePersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea NarrativePersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "Narrative");
// Private attributes corresponding to business object data
private String dummyNarrativeCode;
private String dummyDescription;
private String dummyGraphicNotes;
private String dummySummaryNotes;
private String dummyModConnect;
private String dummyNarrativeNotes;
private String dummyDevelNarrative;
private String dummyQuestion;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_NarrativeCode = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_GraphicNotes = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_SummaryNotes = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ModConnect = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_NarrativeNotes = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DevelNarrative = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Question = DefaultAttributeHelper.INSTANCE;
public NarrativePersistenceMgr ()
{
dummyNarrativeCode = (String)(HELPER_NarrativeCode.initialise (dummyNarrativeCode));
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
dummyGraphicNotes = (String)(HELPER_GraphicNotes.initialise (dummyGraphicNotes));
dummySummaryNotes = (String)(HELPER_SummaryNotes.initialise (dummySummaryNotes));
dummyModConnect = (String)(HELPER_ModConnect.initialise (dummyModConnect));
dummyNarrativeNotes = (String)(HELPER_NarrativeNotes.initialise (dummyNarrativeNotes));
dummyDevelNarrative = (String)(HELPER_DevelNarrative.initialise (dummyDevelNarrative));
dummyQuestion = (String)(HELPER_Question.initialise (dummyQuestion));
}
private String SELECT_COLUMNS = "{PREFIX}narrative.object_id as id, {PREFIX}narrative.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}narrative.object_CREATED_DATE as CREATED_DATE, {PREFIX}narrative.narrative_code, {PREFIX}narrative.narrative_desc, {PREFIX}narrative.graphic_notes, {PREFIX}narrative.exec_sum_notes, {PREFIX}narrative.mod_connect_flag, {PREFIX}narrative.narrative_notes, {PREFIX}narrative.devel_narrative, {PREFIX}narrative.question, {PREFIX}narrative.level_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, Narrative.REFERENCE_Narrative);
if (objectToReturn instanceof Narrative)
{
LogMgr.log (NarrativePersistence, 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 Narrative");
}
}
PersistentSet narrativePSet = allPSets.getPersistentSet(id, "narrative", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !narrativePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!narrativePSet.containsAttrib(Narrative.FIELD_NarrativeCode)||
!narrativePSet.containsAttrib(Narrative.FIELD_Description)||
!narrativePSet.containsAttrib(Narrative.FIELD_GraphicNotes)||
!narrativePSet.containsAttrib(Narrative.FIELD_SummaryNotes)||
!narrativePSet.containsAttrib(Narrative.FIELD_ModConnect)||
!narrativePSet.containsAttrib(Narrative.FIELD_NarrativeNotes)||
!narrativePSet.containsAttrib(Narrative.FIELD_DevelNarrative)||
!narrativePSet.containsAttrib(Narrative.FIELD_Question)||
!narrativePSet.containsAttrib(Narrative.SINGLEREFERENCE_Level))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (NarrativePersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
Narrative result = new Narrative ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}narrative " +
"WHERE " + SELECT_JOINS + "{PREFIX}narrative.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else
{
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 narrativePSet = allPSets.getPersistentSet(objectID, "narrative");
if (narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}narrative " +
"SET narrative_code = ?, narrative_desc = ?, graphic_notes = ?, exec_sum_notes = ?, mod_connect_flag = ?, narrative_notes = ?, devel_narrative = ?, question = ?, level_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE narrative.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, narrativePSet.getAttrib (Narrative.FIELD_NarrativeCode))).listEntry (HELPER_Description.getForSQL(dummyDescription, narrativePSet.getAttrib (Narrative.FIELD_Description))).listEntry (HELPER_GraphicNotes.getForSQL(dummyGraphicNotes, narrativePSet.getAttrib (Narrative.FIELD_GraphicNotes))).listEntry (HELPER_SummaryNotes.getForSQL(dummySummaryNotes, narrativePSet.getAttrib (Narrative.FIELD_SummaryNotes))).listEntry (HELPER_ModConnect.getForSQL(dummyModConnect, narrativePSet.getAttrib (Narrative.FIELD_ModConnect))).listEntry (HELPER_NarrativeNotes.getForSQL(dummyNarrativeNotes, narrativePSet.getAttrib (Narrative.FIELD_NarrativeNotes))).listEntry (HELPER_DevelNarrative.getForSQL(dummyDevelNarrative, narrativePSet.getAttrib (Narrative.FIELD_DevelNarrative))).listEntry (HELPER_Question.getForSQL(dummyQuestion, narrativePSet.getAttrib (Narrative.FIELD_Question))).listEntry (SQLManager.CheckNull((Long)(narrativePSet.getAttrib (Narrative.SINGLEREFERENCE_Level)))).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}narrative WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "narrative", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (NarrativePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "narrative");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:narrative for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (NarrativePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (NarrativePersistence, 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 narrativePSet = allPSets.getPersistentSet(objectID, "narrative");
LogMgr.log (NarrativePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}narrative " +
"WHERE narrative.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}narrative WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "narrative");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:narrative for row:" + objectID;
LogMgr.log (NarrativePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, Narrative> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (Narrative.REFERENCE_Narrative.getObjectIDSpace (), r.getLong ("id"));
Narrative 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, Narrative.REFERENCE_Narrative);
if (cachedElement instanceof Narrative)
{
LogMgr.log (NarrativePersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (Narrative)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a Narrative");
}
}
else
{
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new Narrative ();
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 (NarrativePersistence, 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}narrative " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (Narrative.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY narrative.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: narrative.object_id is not null
String preFilter = "(narrative.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}narrative " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative", PersistentSetStatus.FETCHED);
// Object Modified
narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
narrativePSet.setAttrib(Narrative.FIELD_NarrativeCode, HELPER_NarrativeCode.getFromRS(dummyNarrativeCode, r, "narrative_code"));
narrativePSet.setAttrib(Narrative.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "narrative_desc"));
narrativePSet.setAttrib(Narrative.FIELD_GraphicNotes, HELPER_GraphicNotes.getFromRS(dummyGraphicNotes, r, "graphic_notes"));
narrativePSet.setAttrib(Narrative.FIELD_SummaryNotes, HELPER_SummaryNotes.getFromRS(dummySummaryNotes, r, "exec_sum_notes"));
narrativePSet.setAttrib(Narrative.FIELD_ModConnect, HELPER_ModConnect.getFromRS(dummyModConnect, r, "mod_connect_flag"));
narrativePSet.setAttrib(Narrative.FIELD_NarrativeNotes, HELPER_NarrativeNotes.getFromRS(dummyNarrativeNotes, r, "narrative_notes"));
narrativePSet.setAttrib(Narrative.FIELD_DevelNarrative, HELPER_DevelNarrative.getFromRS(dummyDevelNarrative, r, "devel_narrative"));
narrativePSet.setAttrib(Narrative.FIELD_Question, HELPER_Question.getFromRS(dummyQuestion, r, "question"));
narrativePSet.setAttrib(Narrative.SINGLEREFERENCE_Level, r.getObject ("level_number"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative");
if (narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}narrative " +
" (narrative_code, narrative_desc, graphic_notes, exec_sum_notes, mod_connect_flag, narrative_notes, devel_narrative, question, level_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, narrativePSet.getAttrib (Narrative.FIELD_NarrativeCode))).listEntry (HELPER_Description.getForSQL(dummyDescription, narrativePSet.getAttrib (Narrative.FIELD_Description))).listEntry (HELPER_GraphicNotes.getForSQL(dummyGraphicNotes, narrativePSet.getAttrib (Narrative.FIELD_GraphicNotes))).listEntry (HELPER_SummaryNotes.getForSQL(dummySummaryNotes, narrativePSet.getAttrib (Narrative.FIELD_SummaryNotes))).listEntry (HELPER_ModConnect.getForSQL(dummyModConnect, narrativePSet.getAttrib (Narrative.FIELD_ModConnect))).listEntry (HELPER_NarrativeNotes.getForSQL(dummyNarrativeNotes, narrativePSet.getAttrib (Narrative.FIELD_NarrativeNotes))).listEntry (HELPER_DevelNarrative.getForSQL(dummyDevelNarrative, narrativePSet.getAttrib (Narrative.FIELD_DevelNarrative))).listEntry (HELPER_Question.getForSQL(dummyQuestion, narrativePSet.getAttrib (Narrative.FIELD_Question))) .listEntry (SQLManager.CheckNull((Long)(narrativePSet.getAttrib (Narrative.SINGLEREFERENCE_Level)))) .listEntry (objectID.longID ()).toList().toArray());
narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
<BUSINESSCLASS name="Question" package="performa.orm"> <BUSINESSCLASS name="Question" package="performa.orm">
<MULTIPLEREFERENCE name="Factors" type="FactorQuestionLink" backreferenceName="Question" />
<TABLE name="quest_lin" tablePrefix="object" polymorphic="FALSE"> <TABLE name="quest_lin" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="left_quest" length="80"/> <ATTRIB name="Description" type="String" dbcol="left_quest" length="80"/>
...@@ -12,6 +14,8 @@ ...@@ -12,6 +14,8 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="quest_lin.object_id is not null" orderBy="quest_lin.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -260,6 +260,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -260,6 +260,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
} }
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
...@@ -371,6 +375,44 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -371,6 +375,44 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (Question.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY quest_lin.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: quest_lin.object_id is not null
String preFilter = "(quest_lin.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}quest_lin " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="quest_hdr.object_id is not null" orderBy="quest_hdr.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -254,6 +254,10 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -254,6 +254,10 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
} }
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
...@@ -365,6 +369,44 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -365,6 +369,44 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (Section.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY quest_hdr.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: quest_hdr.object_id is not null
String preFilter = "(quest_hdr.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}quest_hdr " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
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