Commit 7fd2f4b7 by Harsh Shah

Analysis Engine Changes - weighted score calculation

parent 8610af15
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_level_type</tableName>
<column name="object_id" type="Long" nullable="true" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="type_flag" type="String" nullable="true" length="200"/>
<column name="level_number" type="Long" length="11" nullable="true"/>
<column name="factor_number" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_level_type" indexName="idx_tl_level_type_level_number" isUnique="false"><column name="level_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_level_type" indexName="idx_tl_level_type_factor_number" isUnique="false"><column name="factor_number"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
...@@ -12,10 +12,13 @@ ...@@ -12,10 +12,13 @@
<column name="is_right_quest" type="Boolean" nullable="true"/> <column name="is_right_quest" type="Boolean" nullable="true"/>
<column name="section_number" type="Long" length="11" nullable="true"/> <column name="section_number" type="Long" length="11" nullable="true"/>
<column name="right_quest_number" type="Long" length="11" nullable="true"/> <column name="right_quest_number" type="Long" length="11" nullable="true"/>
<column name="high_low_factor_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_section_number" isUnique="false"><column name="section_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_section_number" isUnique="false"><column name="section_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_right_quest_number" isUnique="false"><column name="right_quest_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_right_quest_number" isUnique="false"><column name="right_quest_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_high_low_factor_id" isUnique="false"><column name="high_low_factor_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_level_type;
CREATE TABLE tl_level_type (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
type_flag varchar(200) NULL,
level_number numeric(12) NULL,
factor_number numeric(12) NULL
);
ALTER TABLE tl_level_type ADD
CONSTRAINT PK_tl_level_type PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_level_type_level_number
ON tl_level_type (level_number);
CREATE INDEX idx_tl_level_type_factor_number
ON tl_level_type (factor_number);
...@@ -11,7 +11,8 @@ CREATE TABLE tl_quest_lin ( ...@@ -11,7 +11,8 @@ CREATE TABLE tl_quest_lin (
description varchar(80) NULL, description varchar(80) NULL,
is_right_quest char(1) NULL, is_right_quest char(1) NULL,
section_number numeric(12) NULL, section_number numeric(12) NULL,
right_quest_number numeric(12) NULL right_quest_number numeric(12) NULL,
high_low_factor_id numeric(12) NULL
); );
...@@ -29,3 +30,6 @@ ALTER TABLE tl_quest_lin ADD ...@@ -29,3 +30,6 @@ ALTER TABLE tl_quest_lin ADD
CREATE INDEX idx_tl_quest_lin_right_quest_number CREATE INDEX idx_tl_quest_lin_right_quest_number
ON tl_quest_lin (right_quest_number); ON tl_quest_lin (right_quest_number);
CREATE INDEX idx_tl_quest_lin_high_low_factor_id
ON tl_quest_lin (high_low_factor_id);
-- DROP TABLE tl_level_type;
CREATE TABLE tl_level_type (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
type_flag varchar2(200) NULL,
level_number number(12) NULL,
factor_number number(12) NULL
);
ALTER TABLE tl_level_type ADD
CONSTRAINT PK_tl_level_type PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_level_type_level_number
ON tl_level_type (level_number);
CREATE INDEX idx_tl_level_type_factor_number
ON tl_level_type (factor_number);
...@@ -12,7 +12,8 @@ CREATE TABLE tl_quest_lin ( ...@@ -12,7 +12,8 @@ CREATE TABLE tl_quest_lin (
description varchar2(80) NULL, description varchar2(80) NULL,
is_right_quest char(1) NULL, is_right_quest char(1) NULL,
section_number number(12) NULL, section_number number(12) NULL,
right_quest_number number(12) NULL right_quest_number number(12) NULL,
high_low_factor_id number(12) NULL
); );
...@@ -30,3 +31,6 @@ ALTER TABLE tl_quest_lin ADD ...@@ -30,3 +31,6 @@ ALTER TABLE tl_quest_lin ADD
CREATE INDEX idx_tl_quest_lin_right_quest_number CREATE INDEX idx_tl_quest_lin_right_quest_number
ON tl_quest_lin (right_quest_number); ON tl_quest_lin (right_quest_number);
CREATE INDEX idx_tl_quest_lin_high_low_factor_id
ON tl_quest_lin (high_low_factor_id);
-- @AutoRun
-- drop table tl_level_type;
CREATE TABLE tl_level_type (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
type_flag varchar(200) NULL,
level_number numeric(12) NULL,
factor_number numeric(12) NULL
);
ALTER TABLE tl_level_type ADD
CONSTRAINT pk_tl_level_type PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_level_type_level_number
ON tl_level_type (level_number);
CREATE INDEX idx_tl_level_type_factor_number
ON tl_level_type (factor_number);
...@@ -12,7 +12,8 @@ CREATE TABLE tl_quest_lin ( ...@@ -12,7 +12,8 @@ CREATE TABLE tl_quest_lin (
description varchar(80) NULL, description varchar(80) NULL,
is_right_quest char(1) NULL, is_right_quest char(1) NULL,
section_number numeric(12) NULL, section_number numeric(12) NULL,
right_quest_number numeric(12) NULL right_quest_number numeric(12) NULL,
high_low_factor_id numeric(12) NULL
); );
...@@ -30,3 +31,6 @@ ALTER TABLE tl_quest_lin ADD ...@@ -30,3 +31,6 @@ ALTER TABLE tl_quest_lin ADD
CREATE INDEX idx_tl_quest_lin_right_quest_number CREATE INDEX idx_tl_quest_lin_right_quest_number
ON tl_quest_lin (right_quest_number); ON tl_quest_lin (right_quest_number);
CREATE INDEX idx_tl_quest_lin_high_low_factor_id
ON tl_quest_lin (high_low_factor_id);
...@@ -4,12 +4,12 @@ import oneit.objstore.rdbms.filters.EqualsFilter; ...@@ -4,12 +4,12 @@ import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.utils.filter.CollectionFilter; import oneit.utils.filter.CollectionFilter;
import oneit.utils.filter.Filter; import oneit.utils.filter.Filter;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.types.QuestionType;
public class Answer extends BaseAnswer public class Answer extends BaseAnswer
{ {
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
private static final Integer MAX_ANSWER_NO = 7;
// This constructor should not be called // This constructor should not be called
public Answer () public Answer ()
...@@ -17,13 +17,14 @@ public class Answer extends BaseAnswer ...@@ -17,13 +17,14 @@ public class Answer extends BaseAnswer
// Do not add any code to this, always put it in initialiseNewObject // Do not add any code to this, always put it in initialiseNewObject
} }
@Override @Override
protected void postAnswerNoChange() throws FieldException public void setAnswerNo(Integer newAnswerNo) throws FieldException
{ {
super.postAnswerNoChange(); super.setAnswerNo(newAnswerNo);
if(getQuestion() != null) if(getAnswerNo() != null)
{
if(getQuestion() != null && getQuestion().getQuestionType() == QuestionType.IPSATIVE)
{ {
Question rightQuestion = getQuestion().getRightQuestion(); Question rightQuestion = getQuestion().getRightQuestion();
...@@ -35,19 +36,30 @@ public class Answer extends BaseAnswer ...@@ -35,19 +36,30 @@ public class Answer extends BaseAnswer
if(rightAnswer!=null) if(rightAnswer!=null)
{ {
rightAnswer.setAnswerNo(calculateRightAnswerNo()); rightAnswer.setAnswerNo(10 - getAnswerNo()); //Refer below calculation table
}
} }
} }
} }
} }
/**
public Integer calculateRightAnswerNo() *
* Ipsative answer logic as per Apollo:
*
* Submitted Left Answer Final Left Answer Final Right Answer
* 1 9 1
* 2 7 3
* 3 5 5
* 4 3 7
* 5 1 9
*/
public int getFinalAnswerValue(int index)
{ {
if(getAnswerNo()!=null) if(getQuestion() != null && getQuestion().getQuestionType() == QuestionType.IPSATIVE)
{ {
return MAX_ANSWER_NO - getAnswerNo(); return (10 - ((index * 2) - 1));
} }
return null; return index;
} }
} }
\ No newline at end of file
...@@ -45,6 +45,10 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -45,6 +45,10 @@ public abstract class BaseFactor extends BaseBusinessClass
public static final String BACKREF_Questions = ""; public static final String BACKREF_Questions = "";
public static final String MULTIPLEREFERENCE_Results = "Results"; public static final String MULTIPLEREFERENCE_Results = "Results";
public static final String BACKREF_Results = ""; public static final String BACKREF_Results = "";
public static final String MULTIPLEREFERENCE_HighLowQuestions = "HighLowQuestions";
public static final String BACKREF_HighLowQuestions = "";
public static final String MULTIPLEREFERENCE_LevelFactorTypes = "LevelFactorTypes";
public static final String BACKREF_LevelFactorTypes = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -65,6 +69,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -65,6 +69,8 @@ public abstract class BaseFactor extends BaseBusinessClass
private MultipleAssociation<Factor, FactorLevelLink> _Levels; private MultipleAssociation<Factor, FactorLevelLink> _Levels;
private MultipleAssociation<Factor, FactorQuestionLink> _Questions; private MultipleAssociation<Factor, FactorQuestionLink> _Questions;
private MultipleAssociation<Factor, FactorScoreResult> _Results; private MultipleAssociation<Factor, FactorScoreResult> _Results;
private MultipleAssociation<Factor, Question> _HighLowQuestions;
private MultipleAssociation<Factor, LevelFactorType> _LevelFactorTypes;
// Map of maps of metadata // Map of maps of metadata
...@@ -85,12 +91,16 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -85,12 +91,16 @@ public abstract class BaseFactor extends BaseBusinessClass
String tmp_Levels = FactorLevelLink.BACKREF_Factor; String tmp_Levels = FactorLevelLink.BACKREF_Factor;
String tmp_Questions = FactorQuestionLink.BACKREF_Factor; String tmp_Questions = FactorQuestionLink.BACKREF_Factor;
String tmp_Results = FactorScoreResult.BACKREF_Factor; String tmp_Results = FactorScoreResult.BACKREF_Factor;
String tmp_HighLowQuestions = Question.BACKREF_HighLowFactor;
String tmp_LevelFactorTypes = LevelFactorType.BACKREF_Factor;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Levels(); setupAssocMetaData_Levels();
setupAssocMetaData_Questions(); setupAssocMetaData_Questions();
setupAssocMetaData_Results(); setupAssocMetaData_Results();
setupAssocMetaData_HighLowQuestions();
setupAssocMetaData_LevelFactorTypes();
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -149,6 +159,34 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -149,6 +159,34 @@ public abstract class BaseFactor extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_HighLowQuestions()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "HighLowFactor");
metaInfo.put ("name", "HighLowQuestions");
metaInfo.put ("type", "Question");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.HighLowQuestions:", metaInfo);
ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_HighLowQuestions, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_LevelFactorTypes()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Factor");
metaInfo.put ("name", "LevelFactorTypes");
metaInfo.put ("type", "LevelFactorType");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.LevelFactorTypes:", metaInfo);
ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_LevelFactorTypes, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping) private static List setupAttribMetaData_Description(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -206,6 +244,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -206,6 +244,8 @@ public abstract class BaseFactor extends BaseBusinessClass
_Levels = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_Levels, 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); _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); _Results = new MultipleAssociation<Factor, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Factor, FactorScoreResult.REFERENCE_FactorScoreResult);
_HighLowQuestions = new MultipleAssociation<Factor, Question> (this, MULTIPLEREFERENCE_HighLowQuestions, Question.SINGLEREFERENCE_HighLowFactor, Question.REFERENCE_Question);
_LevelFactorTypes = new MultipleAssociation<Factor, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Factor, LevelFactorType.REFERENCE_LevelFactorType);
} }
...@@ -218,6 +258,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -218,6 +258,8 @@ public abstract class BaseFactor extends BaseBusinessClass
_Levels = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_Levels, 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); _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); _Results = new MultipleAssociation<Factor, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Factor, FactorScoreResult.REFERENCE_FactorScoreResult);
_HighLowQuestions = new MultipleAssociation<Factor, Question> (this, MULTIPLEREFERENCE_HighLowQuestions, Question.SINGLEREFERENCE_HighLowFactor, Question.REFERENCE_Question);
_LevelFactorTypes = new MultipleAssociation<Factor, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Factor, LevelFactorType.REFERENCE_LevelFactorType);
return this; return this;
...@@ -437,6 +479,10 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -437,6 +479,10 @@ public abstract class BaseFactor extends BaseBusinessClass
result.add("Results"); result.add("Results");
result.add("HighLowQuestions");
result.add("LevelFactorTypes");
return result; return result;
} }
...@@ -463,6 +509,16 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -463,6 +509,16 @@ public abstract class BaseFactor extends BaseBusinessClass
return FactorScoreResult.REFERENCE_FactorScoreResult ; return FactorScoreResult.REFERENCE_FactorScoreResult ;
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
return Question.REFERENCE_Question ;
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return LevelFactorType.REFERENCE_LevelFactorType ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -486,6 +542,16 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -486,6 +542,16 @@ public abstract class BaseFactor extends BaseBusinessClass
return FactorScoreResult.SINGLEREFERENCE_Factor ; return FactorScoreResult.SINGLEREFERENCE_Factor ;
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
return Question.SINGLEREFERENCE_HighLowFactor ;
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return LevelFactorType.SINGLEREFERENCE_Factor ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -512,6 +578,16 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -512,6 +578,16 @@ public abstract class BaseFactor extends BaseBusinessClass
return this.getResultsCount(); return this.getResultsCount();
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
return this.getHighLowQuestionsCount();
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return this.getLevelFactorTypesCount();
}
return super.getMultiAssocCount(attribName); return super.getMultiAssocCount(attribName);
} }
...@@ -538,6 +614,16 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -538,6 +614,16 @@ public abstract class BaseFactor extends BaseBusinessClass
return this.getResultsAt(index); return this.getResultsAt(index);
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
return this.getHighLowQuestionsAt(index);
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return this.getLevelFactorTypesAt(index);
}
return super.getMultiAssocAt(attribName, index); return super.getMultiAssocAt(attribName, index);
} }
...@@ -570,6 +656,20 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -570,6 +656,20 @@ public abstract class BaseFactor extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
addToHighLowQuestions((Question)newElement);
return;
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
addToLevelFactorTypes((LevelFactorType)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement); super.addToMultiAssoc(attribName, newElement);
} }
...@@ -601,6 +701,20 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -601,6 +701,20 @@ public abstract class BaseFactor extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
removeFromHighLowQuestions((Question)oldElement);
return;
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
removeFromLevelFactorTypes((LevelFactorType)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement); super.removeFromMultiAssoc(attribName, oldElement);
} }
...@@ -627,6 +741,18 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -627,6 +741,18 @@ public abstract class BaseFactor extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
_HighLowQuestions.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
_LevelFactorTypes.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements); super.__loadMultiAssoc(attribName, elements);
} }
...@@ -650,6 +776,16 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -650,6 +776,16 @@ public abstract class BaseFactor extends BaseBusinessClass
return _Results.isLoaded (); return _Results.isLoaded ();
} }
if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
{
return _HighLowQuestions.isLoaded ();
}
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return _LevelFactorTypes.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName); return super.__isMultiAssocLoaded(attribName);
} }
...@@ -863,6 +999,144 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -863,6 +999,144 @@ public abstract class BaseFactor extends BaseBusinessClass
return _Results.getSet (); return _Results.getSet ();
} }
public FieldWriteability getWriteability_HighLowQuestions ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getHighLowQuestionsCount () throws StorageException
{
assertValid();
return _HighLowQuestions.getReferencedObjectsCount ();
}
public void addToHighLowQuestions (Question newElement) throws StorageException
{
if (_HighLowQuestions.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_HighLowQuestions () != FieldWriteability.FALSE, "MultiAssoc HighLowQuestions is not writeable (add)");
_HighLowQuestions.appendElement (newElement);
try
{
if (newElement.getHighLowFactor () != this)
{
newElement.setHighLowFactor ((Factor)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromHighLowQuestions (Question elementToRemove) throws StorageException
{
if (_HighLowQuestions.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_HighLowQuestions () != FieldWriteability.FALSE, "MultiAssoc HighLowQuestions is not writeable (remove)");
_HighLowQuestions.removeElement (elementToRemove);
try
{
if (elementToRemove.getHighLowFactor () != null)
{
elementToRemove.setHighLowFactor (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public Question getHighLowQuestionsAt (int index) throws StorageException
{
return (Question)(_HighLowQuestions.getElementAt (index));
}
public SortedSet<Question> getHighLowQuestionsSet () throws StorageException
{
return _HighLowQuestions.getSet ();
}
public FieldWriteability getWriteability_LevelFactorTypes ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getLevelFactorTypesCount () throws StorageException
{
assertValid();
return _LevelFactorTypes.getReferencedObjectsCount ();
}
public void addToLevelFactorTypes (LevelFactorType newElement) throws StorageException
{
if (_LevelFactorTypes.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_LevelFactorTypes () != FieldWriteability.FALSE, "MultiAssoc LevelFactorTypes is not writeable (add)");
_LevelFactorTypes.appendElement (newElement);
try
{
if (newElement.getFactor () != this)
{
newElement.setFactor ((Factor)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromLevelFactorTypes (LevelFactorType elementToRemove) throws StorageException
{
if (_LevelFactorTypes.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_LevelFactorTypes () != FieldWriteability.FALSE, "MultiAssoc LevelFactorTypes is not writeable (remove)");
_LevelFactorTypes.removeElement (elementToRemove);
try
{
if (elementToRemove.getFactor () != null)
{
elementToRemove.setFactor (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public LevelFactorType getLevelFactorTypesAt (int index) throws StorageException
{
return (LevelFactorType)(_LevelFactorTypes.getElementAt (index));
}
public SortedSet<LevelFactorType> getLevelFactorTypesSet () throws StorageException
{
return _LevelFactorTypes.getSet ();
}
public void onDelete () public void onDelete ()
...@@ -887,6 +1161,18 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -887,6 +1161,18 @@ public abstract class BaseFactor extends BaseBusinessClass
referenced.setFactor(null); referenced.setFactor(null);
} }
for(Question referenced : CollectionUtils.reverse(getHighLowQuestionsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null HighLowFactor from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setHighLowFactor(null);
}
for(LevelFactorType referenced : CollectionUtils.reverse(getLevelFactorTypesSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factor from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setFactor(null);
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -1038,6 +1324,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1038,6 +1324,8 @@ public abstract class BaseFactor extends BaseBusinessClass
_Levels.copyFrom (sourceFactor._Levels, linkToGhosts); _Levels.copyFrom (sourceFactor._Levels, linkToGhosts);
_Questions.copyFrom (sourceFactor._Questions, linkToGhosts); _Questions.copyFrom (sourceFactor._Questions, linkToGhosts);
_Results.copyFrom (sourceFactor._Results, linkToGhosts); _Results.copyFrom (sourceFactor._Results, linkToGhosts);
_HighLowQuestions.copyFrom (sourceFactor._HighLowQuestions, linkToGhosts);
_LevelFactorTypes.copyFrom (sourceFactor._LevelFactorTypes, linkToGhosts);
} }
} }
...@@ -1062,6 +1350,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1062,6 +1350,8 @@ public abstract class BaseFactor extends BaseBusinessClass
_Levels.readExternalData(vals.get(MULTIPLEREFERENCE_Levels)); _Levels.readExternalData(vals.get(MULTIPLEREFERENCE_Levels));
_Questions.readExternalData(vals.get(MULTIPLEREFERENCE_Questions)); _Questions.readExternalData(vals.get(MULTIPLEREFERENCE_Questions));
_Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results)); _Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
_HighLowQuestions.readExternalData(vals.get(MULTIPLEREFERENCE_HighLowQuestions));
_LevelFactorTypes.readExternalData(vals.get(MULTIPLEREFERENCE_LevelFactorTypes));
} }
...@@ -1077,6 +1367,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1077,6 +1367,8 @@ public abstract class BaseFactor extends BaseBusinessClass
vals.put (MULTIPLEREFERENCE_Levels, _Levels.writeExternalData()); vals.put (MULTIPLEREFERENCE_Levels, _Levels.writeExternalData());
vals.put (MULTIPLEREFERENCE_Questions, _Questions.writeExternalData()); vals.put (MULTIPLEREFERENCE_Questions, _Questions.writeExternalData());
vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData()); vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
vals.put (MULTIPLEREFERENCE_HighLowQuestions, _HighLowQuestions.writeExternalData());
vals.put (MULTIPLEREFERENCE_LevelFactorTypes, _LevelFactorTypes.writeExternalData());
} }
...@@ -1102,6 +1394,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1102,6 +1394,8 @@ public abstract class BaseFactor extends BaseBusinessClass
_Levels.compare (otherFactor._Levels, listener); _Levels.compare (otherFactor._Levels, listener);
_Questions.compare (otherFactor._Questions, listener); _Questions.compare (otherFactor._Questions, listener);
_Results.compare (otherFactor._Results, listener); _Results.compare (otherFactor._Results, listener);
_HighLowQuestions.compare (otherFactor._HighLowQuestions, listener);
_LevelFactorTypes.compare (otherFactor._LevelFactorTypes, listener);
} }
} }
...@@ -1123,6 +1417,8 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1123,6 +1417,8 @@ public abstract class BaseFactor extends BaseBusinessClass
visitor.visitAssociation (_Levels); visitor.visitAssociation (_Levels);
visitor.visitAssociation (_Questions); visitor.visitAssociation (_Questions);
visitor.visitAssociation (_Results); visitor.visitAssociation (_Results);
visitor.visitAssociation (_HighLowQuestions);
visitor.visitAssociation (_LevelFactorTypes);
} }
...@@ -1143,6 +1439,14 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1143,6 +1439,14 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
visitor.visit (_Results); visitor.visit (_Results);
} }
if (scope.includes (_HighLowQuestions))
{
visitor.visit (_HighLowQuestions);
}
if (scope.includes (_LevelFactorTypes))
{
visitor.visit (_LevelFactorTypes);
}
} }
...@@ -1318,6 +1622,14 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1318,6 +1622,14 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
return getWriteability_Results (); return getWriteability_Results ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_HighLowQuestions))
{
return getWriteability_HighLowQuestions ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_LevelFactorTypes))
{
return getWriteability_LevelFactorTypes ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1475,6 +1787,14 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1475,6 +1787,14 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
return toResults (); return toResults ();
} }
if (name.equals ("HighLowQuestions"))
{
return toHighLowQuestions ();
}
if (name.equals ("LevelFactorTypes"))
{
return toLevelFactorTypes ();
}
if (name.equals ("Description")) if (name.equals ("Description"))
{ {
return toDescription (); return toDescription ();
...@@ -1504,6 +1824,18 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1504,6 +1824,18 @@ public abstract class BaseFactor extends BaseBusinessClass
{ {
return FactorScoreResult.REFERENCE_FactorScoreResult.new FactorScoreResultPipeLineFactory<From, FactorScoreResult> (this, new ORMMultiAssocPipe<Me, FactorScoreResult>(MULTIPLEREFERENCE_Results, filter)); return FactorScoreResult.REFERENCE_FactorScoreResult.new FactorScoreResultPipeLineFactory<From, FactorScoreResult> (this, new ORMMultiAssocPipe<Me, FactorScoreResult>(MULTIPLEREFERENCE_Results, filter));
} }
public Question.QuestionPipeLineFactory<From, Question> toHighLowQuestions () { return toHighLowQuestions(Filter.ALL); }
public Question.QuestionPipeLineFactory<From, Question> toHighLowQuestions (Filter<Question> filter)
{
return Question.REFERENCE_Question.new QuestionPipeLineFactory<From, Question> (this, new ORMMultiAssocPipe<Me, Question>(MULTIPLEREFERENCE_HighLowQuestions, filter));
}
public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes () { return toLevelFactorTypes(Filter.ALL); }
public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes (Filter<LevelFactorType> filter)
{
return LevelFactorType.REFERENCE_LevelFactorType.new LevelFactorTypePipeLineFactory<From, LevelFactorType> (this, new ORMMultiAssocPipe<Me, LevelFactorType>(MULTIPLEREFERENCE_LevelFactorTypes, filter));
}
} }
...@@ -1586,6 +1918,40 @@ class DummyFactor extends Factor ...@@ -1586,6 +1918,40 @@ class DummyFactor extends Factor
return new TreeSet(); return new TreeSet();
} }
public int getHighLowQuestionsCount () throws StorageException
{
return 0;
}
public Question getHighLowQuestionsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association HighLowQuestions");
}
public SortedSet getHighLowQuestionsSet () throws StorageException
{
return new TreeSet();
}
public int getLevelFactorTypesCount () throws StorageException
{
return 0;
}
public LevelFactorType getLevelFactorTypesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association LevelFactorTypes");
}
public SortedSet getLevelFactorTypesSet () throws StorageException
{
return new TreeSet();
}
} }
...@@ -49,6 +49,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -49,6 +49,8 @@ public abstract class BaseLevel extends BaseBusinessClass
public static final String BACKREF_Narratives = ""; public static final String BACKREF_Narratives = "";
public static final String MULTIPLEREFERENCE_TestAnalysises = "TestAnalysises"; public static final String MULTIPLEREFERENCE_TestAnalysises = "TestAnalysises";
public static final String BACKREF_TestAnalysises = ""; public static final String BACKREF_TestAnalysises = "";
public static final String MULTIPLEREFERENCE_LevelFactorTypes = "LevelFactorTypes";
public static final String BACKREF_LevelFactorTypes = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -75,6 +77,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -75,6 +77,7 @@ public abstract class BaseLevel extends BaseBusinessClass
private MultipleAssociation<Level, FactorScoreResult> _Results; private MultipleAssociation<Level, FactorScoreResult> _Results;
private MultipleAssociation<Level, Narrative> _Narratives; private MultipleAssociation<Level, Narrative> _Narratives;
private MultipleAssociation<Level, TestAnalysis> _TestAnalysises; private MultipleAssociation<Level, TestAnalysis> _TestAnalysises;
private MultipleAssociation<Level, LevelFactorType> _LevelFactorTypes;
// Map of maps of metadata // Map of maps of metadata
...@@ -98,6 +101,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -98,6 +101,7 @@ public abstract class BaseLevel extends BaseBusinessClass
String tmp_Results = FactorScoreResult.BACKREF_Level; String tmp_Results = FactorScoreResult.BACKREF_Level;
String tmp_Narratives = Narrative.BACKREF_Level; String tmp_Narratives = Narrative.BACKREF_Level;
String tmp_TestAnalysises = TestAnalysis.BACKREF_Level; String tmp_TestAnalysises = TestAnalysis.BACKREF_Level;
String tmp_LevelFactorTypes = LevelFactorType.BACKREF_Level;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
...@@ -105,6 +109,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -105,6 +109,7 @@ public abstract class BaseLevel extends BaseBusinessClass
setupAssocMetaData_Results(); setupAssocMetaData_Results();
setupAssocMetaData_Narratives(); setupAssocMetaData_Narratives();
setupAssocMetaData_TestAnalysises(); setupAssocMetaData_TestAnalysises();
setupAssocMetaData_LevelFactorTypes();
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]);
...@@ -179,6 +184,20 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -179,6 +184,20 @@ public abstract class BaseLevel extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_LevelFactorTypes()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Level");
metaInfo.put ("name", "LevelFactorTypes");
metaInfo.put ("type", "LevelFactorType");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.LevelFactorTypes:", metaInfo);
ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_LevelFactorTypes, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_LevelDescription(Map validatorMapping) private static List setupAttribMetaData_LevelDescription(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -275,6 +294,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -275,6 +294,7 @@ public abstract class BaseLevel extends BaseBusinessClass
_Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult); _Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult);
_Narratives = new MultipleAssociation<Level, Narrative> (this, MULTIPLEREFERENCE_Narratives, Narrative.SINGLEREFERENCE_Level, Narrative.REFERENCE_Narrative); _Narratives = new MultipleAssociation<Level, Narrative> (this, MULTIPLEREFERENCE_Narratives, Narrative.SINGLEREFERENCE_Level, Narrative.REFERENCE_Narrative);
_TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis); _TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis);
_LevelFactorTypes = new MultipleAssociation<Level, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Level, LevelFactorType.REFERENCE_LevelFactorType);
} }
...@@ -288,6 +308,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -288,6 +308,7 @@ public abstract class BaseLevel extends BaseBusinessClass
_Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult); _Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult);
_Narratives = new MultipleAssociation<Level, Narrative> (this, MULTIPLEREFERENCE_Narratives, Narrative.SINGLEREFERENCE_Level, Narrative.REFERENCE_Narrative); _Narratives = new MultipleAssociation<Level, Narrative> (this, MULTIPLEREFERENCE_Narratives, Narrative.SINGLEREFERENCE_Level, Narrative.REFERENCE_Narrative);
_TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis); _TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis);
_LevelFactorTypes = new MultipleAssociation<Level, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Level, LevelFactorType.REFERENCE_LevelFactorType);
return this; return this;
...@@ -705,6 +726,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -705,6 +726,8 @@ public abstract class BaseLevel extends BaseBusinessClass
result.add("TestAnalysises"); result.add("TestAnalysises");
result.add("LevelFactorTypes");
return result; return result;
} }
...@@ -736,6 +759,11 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -736,6 +759,11 @@ public abstract class BaseLevel extends BaseBusinessClass
return TestAnalysis.REFERENCE_TestAnalysis ; return TestAnalysis.REFERENCE_TestAnalysis ;
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return LevelFactorType.REFERENCE_LevelFactorType ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -764,6 +792,11 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -764,6 +792,11 @@ public abstract class BaseLevel extends BaseBusinessClass
return TestAnalysis.SINGLEREFERENCE_Level ; return TestAnalysis.SINGLEREFERENCE_Level ;
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return LevelFactorType.SINGLEREFERENCE_Level ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -795,6 +828,11 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -795,6 +828,11 @@ public abstract class BaseLevel extends BaseBusinessClass
return this.getTestAnalysisesCount(); return this.getTestAnalysisesCount();
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return this.getLevelFactorTypesCount();
}
return super.getMultiAssocCount(attribName); return super.getMultiAssocCount(attribName);
} }
...@@ -826,6 +864,11 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -826,6 +864,11 @@ public abstract class BaseLevel extends BaseBusinessClass
return this.getTestAnalysisesAt(index); return this.getTestAnalysisesAt(index);
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return this.getLevelFactorTypesAt(index);
}
return super.getMultiAssocAt(attribName, index); return super.getMultiAssocAt(attribName, index);
} }
...@@ -865,6 +908,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -865,6 +908,13 @@ public abstract class BaseLevel extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
addToLevelFactorTypes((LevelFactorType)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement); super.addToMultiAssoc(attribName, newElement);
} }
...@@ -903,6 +953,13 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -903,6 +953,13 @@ public abstract class BaseLevel extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
removeFromLevelFactorTypes((LevelFactorType)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement); super.removeFromMultiAssoc(attribName, oldElement);
} }
...@@ -935,6 +992,12 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -935,6 +992,12 @@ public abstract class BaseLevel extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
_LevelFactorTypes.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements); super.__loadMultiAssoc(attribName, elements);
} }
...@@ -963,6 +1026,11 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -963,6 +1026,11 @@ public abstract class BaseLevel extends BaseBusinessClass
return _TestAnalysises.isLoaded (); return _TestAnalysises.isLoaded ();
} }
if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
{
return _LevelFactorTypes.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName); return super.__isMultiAssocLoaded(attribName);
} }
...@@ -1245,6 +1313,75 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1245,6 +1313,75 @@ public abstract class BaseLevel extends BaseBusinessClass
return _TestAnalysises.getSet (); return _TestAnalysises.getSet ();
} }
public FieldWriteability getWriteability_LevelFactorTypes ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getLevelFactorTypesCount () throws StorageException
{
assertValid();
return _LevelFactorTypes.getReferencedObjectsCount ();
}
public void addToLevelFactorTypes (LevelFactorType newElement) throws StorageException
{
if (_LevelFactorTypes.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_LevelFactorTypes () != FieldWriteability.FALSE, "MultiAssoc LevelFactorTypes is not writeable (add)");
_LevelFactorTypes.appendElement (newElement);
try
{
if (newElement.getLevel () != this)
{
newElement.setLevel ((Level)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromLevelFactorTypes (LevelFactorType elementToRemove) throws StorageException
{
if (_LevelFactorTypes.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_LevelFactorTypes () != FieldWriteability.FALSE, "MultiAssoc LevelFactorTypes is not writeable (remove)");
_LevelFactorTypes.removeElement (elementToRemove);
try
{
if (elementToRemove.getLevel () != null)
{
elementToRemove.setLevel (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public LevelFactorType getLevelFactorTypesAt (int index) throws StorageException
{
return (LevelFactorType)(_LevelFactorTypes.getElementAt (index));
}
public SortedSet<LevelFactorType> getLevelFactorTypesSet () throws StorageException
{
return _LevelFactorTypes.getSet ();
}
public void onDelete () public void onDelete ()
...@@ -1275,6 +1412,12 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1275,6 +1412,12 @@ public abstract class BaseLevel extends BaseBusinessClass
referenced.setLevel(null); referenced.setLevel(null);
} }
for(LevelFactorType referenced : CollectionUtils.reverse(getLevelFactorTypesSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setLevel(null);
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -1451,6 +1594,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1451,6 +1594,7 @@ public abstract class BaseLevel extends BaseBusinessClass
_Results.copyFrom (sourceLevel._Results, linkToGhosts); _Results.copyFrom (sourceLevel._Results, linkToGhosts);
_Narratives.copyFrom (sourceLevel._Narratives, linkToGhosts); _Narratives.copyFrom (sourceLevel._Narratives, linkToGhosts);
_TestAnalysises.copyFrom (sourceLevel._TestAnalysises, linkToGhosts); _TestAnalysises.copyFrom (sourceLevel._TestAnalysises, linkToGhosts);
_LevelFactorTypes.copyFrom (sourceLevel._LevelFactorTypes, linkToGhosts);
} }
} }
...@@ -1478,6 +1622,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1478,6 +1622,7 @@ public abstract class BaseLevel extends BaseBusinessClass
_Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results)); _Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
_Narratives.readExternalData(vals.get(MULTIPLEREFERENCE_Narratives)); _Narratives.readExternalData(vals.get(MULTIPLEREFERENCE_Narratives));
_TestAnalysises.readExternalData(vals.get(MULTIPLEREFERENCE_TestAnalysises)); _TestAnalysises.readExternalData(vals.get(MULTIPLEREFERENCE_TestAnalysises));
_LevelFactorTypes.readExternalData(vals.get(MULTIPLEREFERENCE_LevelFactorTypes));
} }
...@@ -1496,6 +1641,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1496,6 +1641,7 @@ public abstract class BaseLevel extends BaseBusinessClass
vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData()); vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
vals.put (MULTIPLEREFERENCE_Narratives, _Narratives.writeExternalData()); vals.put (MULTIPLEREFERENCE_Narratives, _Narratives.writeExternalData());
vals.put (MULTIPLEREFERENCE_TestAnalysises, _TestAnalysises.writeExternalData()); vals.put (MULTIPLEREFERENCE_TestAnalysises, _TestAnalysises.writeExternalData());
vals.put (MULTIPLEREFERENCE_LevelFactorTypes, _LevelFactorTypes.writeExternalData());
} }
...@@ -1530,6 +1676,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1530,6 +1676,7 @@ public abstract class BaseLevel extends BaseBusinessClass
_Results.compare (otherLevel._Results, listener); _Results.compare (otherLevel._Results, listener);
_Narratives.compare (otherLevel._Narratives, listener); _Narratives.compare (otherLevel._Narratives, listener);
_TestAnalysises.compare (otherLevel._TestAnalysises, listener); _TestAnalysises.compare (otherLevel._TestAnalysises, listener);
_LevelFactorTypes.compare (otherLevel._LevelFactorTypes, listener);
} }
} }
...@@ -1554,6 +1701,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1554,6 +1701,7 @@ public abstract class BaseLevel extends BaseBusinessClass
visitor.visitAssociation (_Results); visitor.visitAssociation (_Results);
visitor.visitAssociation (_Narratives); visitor.visitAssociation (_Narratives);
visitor.visitAssociation (_TestAnalysises); visitor.visitAssociation (_TestAnalysises);
visitor.visitAssociation (_LevelFactorTypes);
} }
...@@ -1578,6 +1726,10 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1578,6 +1726,10 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
visitor.visit (_TestAnalysises); visitor.visit (_TestAnalysises);
} }
if (scope.includes (_LevelFactorTypes))
{
visitor.visit (_LevelFactorTypes);
}
} }
...@@ -1883,6 +2035,10 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1883,6 +2035,10 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
return getWriteability_TestAnalysises (); return getWriteability_TestAnalysises ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_LevelFactorTypes))
{
return getWriteability_LevelFactorTypes ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -2092,6 +2248,10 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -2092,6 +2248,10 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
return toTestAnalysises (); return toTestAnalysises ();
} }
if (name.equals ("LevelFactorTypes"))
{
return toLevelFactorTypes ();
}
if (name.equals ("LevelDescription")) if (name.equals ("LevelDescription"))
{ {
return toLevelDescription (); return toLevelDescription ();
...@@ -2139,6 +2299,12 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -2139,6 +2299,12 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
return TestAnalysis.REFERENCE_TestAnalysis.new TestAnalysisPipeLineFactory<From, TestAnalysis> (this, new ORMMultiAssocPipe<Me, TestAnalysis>(MULTIPLEREFERENCE_TestAnalysises, filter)); return TestAnalysis.REFERENCE_TestAnalysis.new TestAnalysisPipeLineFactory<From, TestAnalysis> (this, new ORMMultiAssocPipe<Me, TestAnalysis>(MULTIPLEREFERENCE_TestAnalysises, filter));
} }
public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes () { return toLevelFactorTypes(Filter.ALL); }
public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes (Filter<LevelFactorType> filter)
{
return LevelFactorType.REFERENCE_LevelFactorType.new LevelFactorTypePipeLineFactory<From, LevelFactorType> (this, new ORMMultiAssocPipe<Me, LevelFactorType>(MULTIPLEREFERENCE_LevelFactorTypes, filter));
}
} }
...@@ -2238,6 +2404,23 @@ class DummyLevel extends Level ...@@ -2238,6 +2404,23 @@ class DummyLevel extends Level
return new TreeSet(); return new TreeSet();
} }
public int getLevelFactorTypesCount () throws StorageException
{
return 0;
}
public LevelFactorType getLevelFactorTypesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association LevelFactorTypes");
}
public SortedSet getLevelFactorTypesSet () throws StorageException
{
return new TreeSet();
}
} }
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseLevelFactorType extends BaseBusinessClass
{
// Reference instance for the object
public static final LevelFactorType REFERENCE_LevelFactorType = new LevelFactorType ();
// Reference instance for the object
public static final LevelFactorType DUMMY_LevelFactorType = new DummyLevelFactorType ();
// Static constants corresponding to field names
public static final String FIELD_TypeFlag = "TypeFlag";
public static final String SINGLEREFERENCE_Level = "Level";
public static final String BACKREF_Level = "";
public static final String SINGLEREFERENCE_Factor = "Factor";
public static final String BACKREF_Factor = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final EnumeratedAttributeHelper<LevelFactorType, TypeFlag> HELPER_TypeFlag = new EnumeratedAttributeHelper<LevelFactorType, TypeFlag> (TypeFlag.FACTORY_TypeFlag);
// Private attributes corresponding to business object data
private TypeFlag _TypeFlag;
// Private attributes corresponding to single references
private SingleAssociation<LevelFactorType, Level> _Level;
private SingleAssociation<LevelFactorType, Factor> _Factor;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_LevelFactorType = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_TypeFlag_Validators;
// Arrays of behaviour decorators
private static final LevelFactorTypeBehaviourDecorator[] LevelFactorType_BehaviourDecorators;
static
{
try
{
String tmp_Level = Level.BACKREF_LevelFactorTypes;
String tmp_Factor = Factor.BACKREF_LevelFactorTypes;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Level();
setupAssocMetaData_Factor();
FIELD_TypeFlag_Validators = (AttributeValidator[])setupAttribMetaData_TypeFlag(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_LevelFactorType.initialiseReference ();
DUMMY_LevelFactorType.initialiseReference ();
LevelFactorType_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(LevelFactorType.class).toArray(new LevelFactorTypeBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_Level()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "LevelFactorTypes");
metaInfo.put ("dbcol", "level_number");
metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for LevelFactorType.Level:", metaInfo);
ATTRIBUTES_METADATA_LevelFactorType.put (SINGLEREFERENCE_Level, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Factor()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "LevelFactorTypes");
metaInfo.put ("dbcol", "factor_number");
metaInfo.put ("name", "Factor");
metaInfo.put ("type", "Factor");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for LevelFactorType.Factor:", metaInfo);
ATTRIBUTES_METADATA_LevelFactorType.put (SINGLEREFERENCE_Factor, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_TypeFlag(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "type_flag");
metaInfo.put ("name", "TypeFlag");
metaInfo.put ("type", "TypeFlag");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for LevelFactorType.TypeFlag:", metaInfo);
ATTRIBUTES_METADATA_LevelFactorType.put (FIELD_TypeFlag, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(LevelFactorType.class, "TypeFlag", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for LevelFactorType.TypeFlag:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseLevelFactorType ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return LevelFactorType_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_TypeFlag = (TypeFlag)(HELPER_TypeFlag.initialise (_TypeFlag));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_Level = new SingleAssociation<LevelFactorType, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_LevelFactorTypes, Level.REFERENCE_Level, "tl_level_type");
_Factor = new SingleAssociation<LevelFactorType, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_LevelFactorTypes, Factor.REFERENCE_Factor, "tl_level_type");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_Level = new SingleAssociation<LevelFactorType, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_LevelFactorTypes, Level.REFERENCE_Level, "tl_level_type");
_Factor = new SingleAssociation<LevelFactorType, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_LevelFactorTypes, Factor.REFERENCE_Factor, "tl_level_type");
return this;
}
/**
* Get the attribute TypeFlag
*/
public TypeFlag getTypeFlag ()
{
assertValid();
TypeFlag valToReturn = _TypeFlag;
for (LevelFactorTypeBehaviourDecorator bhd : LevelFactorType_BehaviourDecorators)
{
valToReturn = bhd.getTypeFlag ((LevelFactorType)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 preTypeFlagChange (TypeFlag newTypeFlag) 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 postTypeFlagChange () throws FieldException
{
}
public FieldWriteability getWriteability_TypeFlag ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute TypeFlag. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setTypeFlag (TypeFlag newTypeFlag) throws FieldException
{
boolean oldAndNewIdentical = HELPER_TypeFlag.compare (_TypeFlag, newTypeFlag);
try
{
for (LevelFactorTypeBehaviourDecorator bhd : LevelFactorType_BehaviourDecorators)
{
newTypeFlag = bhd.setTypeFlag ((LevelFactorType)this, newTypeFlag);
oldAndNewIdentical = HELPER_TypeFlag.compare (_TypeFlag, newTypeFlag);
}
if (FIELD_TypeFlag_Validators.length > 0)
{
Object newTypeFlagObj = HELPER_TypeFlag.toObject (newTypeFlag);
if (newTypeFlagObj != null)
{
int loopMax = FIELD_TypeFlag_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_LevelFactorType.get (FIELD_TypeFlag);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_TypeFlag_Validators[v].checkAttribute (this, FIELD_TypeFlag, metadata, newTypeFlagObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_TypeFlag () != FieldWriteability.FALSE, "Field TypeFlag is not writeable");
preTypeFlagChange (newTypeFlag);
markFieldChange (FIELD_TypeFlag);
_TypeFlag = newTypeFlag;
postFieldChange (FIELD_TypeFlag);
postTypeFlagChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("Level");
result.add("Factor");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return _Level.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return _Factor.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return Level.MULTIPLEREFERENCE_LevelFactorTypes ;
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return Factor.MULTIPLEREFERENCE_LevelFactorTypes ;
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel ();
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return getFactor ();
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel (getType);
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return getFactor (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevelID ();
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
return getFactorID ();
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_Level))
{
setLevel ((Level)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Factor))
{
setFactor ((Factor)(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 LevelFactorType:", 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 oldLevel = getLevel ();
if (oldLevel != null)
{
// This is to stop validation from triggering when we are removed
_Level.set (null);
oldLevel.removeFromLevelFactorTypes ((LevelFactorType)(this));
}
_Level.set (newLevel);
if (newLevel != null)
{
newLevel.addToLevelFactorTypes ((LevelFactorType)(this));
}
postLevelChange ();
}
}
/**
* Get the reference Factor
*/
public Factor getFactor () throws StorageException
{
assertValid();
try
{
return (Factor)(_Factor.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in LevelFactorType:", this.getObjectID (), ", was trying to get Factor:", getFactorID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Factor.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Factor getFactor (Get getType) throws StorageException
{
assertValid();
return _Factor.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getFactorID ()
{
assertValid();
if (_Factor == null)
{
return null;
}
else
{
return _Factor.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preFactorChange (Factor newFactor) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postFactorChange () throws FieldException
{
}
public FieldWriteability getWriteability_Factor ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Factor. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setFactor (Factor newFactor) throws StorageException, FieldException
{
if (_Factor.wouldReferencedChange (newFactor))
{
assertValid();
Debug.assertion (getWriteability_Factor () != FieldWriteability.FALSE, "Assoc Factor is not writeable");
preFactorChange (newFactor);
Factor oldFactor = getFactor ();
if (oldFactor != null)
{
// This is to stop validation from triggering when we are removed
_Factor.set (null);
oldFactor.removeFromLevelFactorTypes ((LevelFactorType)(this));
}
_Factor.set (newFactor);
if (newFactor != null)
{
newFactor.addToLevelFactorTypes ((LevelFactorType)(this));
}
postFactorChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
return super.__isMultiAssocLoaded(attribName);
}
public void onDelete ()
{
try
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_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 LevelFactorTypes from ", getObjectID (), " to ", referenced.getObjectID ());
_Level.set (null);
referenced.removeFromLevelFactorTypes ((LevelFactorType)this);
}
}
// 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 LevelFactorTypes from ", getObjectID (), " to ", referenced.getObjectID ());
_Factor.set (null);
referenced.removeFromLevelFactorTypes ((LevelFactorType)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public LevelFactorType newInstance ()
{
return new LevelFactorType ();
}
public LevelFactorType referenceInstance ()
{
return REFERENCE_LevelFactorType;
}
public LevelFactorType getInTransaction (ObjectTransaction t) throws StorageException
{
return getLevelFactorTypeByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_LevelFactorType;
}
public String getBaseSetName ()
{
return "tl_level_type";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_level_typePSet = allSets.getPersistentSet (myID, "tl_level_type", myPSetStatus);
tl_level_typePSet.setAttrib (FIELD_ObjectID, myID);
tl_level_typePSet.setAttrib (FIELD_TypeFlag, HELPER_TypeFlag.toObject (_TypeFlag)); //
_Level.getPersistentSets (allSets);
_Factor.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_level_typePSet = allSets.getPersistentSet (objectID, "tl_level_type");
_TypeFlag = (TypeFlag)(HELPER_TypeFlag.fromObject (_TypeFlag, tl_level_typePSet.getAttrib (FIELD_TypeFlag))); //
_Level.setFromPersistentSets (objectID, allSets);
_Factor.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof LevelFactorType)
{
LevelFactorType otherLevelFactorType = (LevelFactorType)other;
try
{
setTypeFlag (otherLevelFactorType.getTypeFlag ());
}
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 BaseLevelFactorType)
{
BaseLevelFactorType sourceLevelFactorType = (BaseLevelFactorType)(source);
_TypeFlag = sourceLevelFactorType._TypeFlag;
}
}
/**
* 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 BaseLevelFactorType)
{
BaseLevelFactorType sourceLevelFactorType = (BaseLevelFactorType)(source);
_Level.copyFrom (sourceLevelFactorType._Level, linkToGhosts);
_Factor.copyFrom (sourceLevelFactorType._Factor, linkToGhosts);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseLevelFactorType)
{
BaseLevelFactorType sourceLevelFactorType = (BaseLevelFactorType)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_TypeFlag = (TypeFlag)(HELPER_TypeFlag.readExternal (_TypeFlag, vals.get(FIELD_TypeFlag))); //
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_TypeFlag, HELPER_TypeFlag.writeExternal (_TypeFlag));
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseLevelFactorType)
{
BaseLevelFactorType otherLevelFactorType = (BaseLevelFactorType)(other);
if (!HELPER_TypeFlag.compare(this._TypeFlag, otherLevelFactorType._TypeFlag))
{
listener.notifyFieldChange(this, other, FIELD_TypeFlag, HELPER_TypeFlag.toObject(this._TypeFlag), HELPER_TypeFlag.toObject(otherLevelFactorType._TypeFlag));
}
// Compare single assocs
_Level.compare (otherLevelFactorType._Level, listener);
_Factor.compare (otherLevelFactorType._Factor, listener);
// Compare multiple assocs
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitField(this, FIELD_TypeFlag, HELPER_TypeFlag.toObject(getTypeFlag()));
visitor.visitAssociation (_Level);
visitor.visitAssociation (_Factor);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_Level))
{
visitor.visit (_Level);
}
if (scope.includes (_Factor))
{
visitor.visit (_Factor);
}
}
public static LevelFactorType createLevelFactorType (ObjectTransaction transaction) throws StorageException
{
LevelFactorType result = new LevelFactorType ();
result.initialiseNewObject (transaction);
return result;
}
public static LevelFactorType getLevelFactorTypeByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (LevelFactorType)(transaction.getObjectByID (REFERENCE_LevelFactorType, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_TypeFlag))
{
return filter.matches (getTypeFlag ());
}
else if (attribName.equals (SINGLEREFERENCE_Level))
{
return filter.matches (getLevel ());
}
else if (attribName.equals (SINGLEREFERENCE_Factor))
{
return filter.matches (getFactor ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<LevelFactorType>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_level_type.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_level_type.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_level_type.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andTypeFlag (QueryFilter<TypeFlag> filter)
{
filter.addFilter (context, "tl_level_type.type_flag", "TypeFlag");
return this;
}
public SearchAll andLevel (QueryFilter<Level> filter)
{
filter.addFilter (context, "tl_level_type.level_number", "Level");
return this;
}
public SearchAll andFactor (QueryFilter<Factor> filter)
{
filter.addFilter (context, "tl_level_type.factor_number", "Factor");
return this;
}
public LevelFactorType[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_LevelFactorType, SEARCH_All, criteria);
Set<LevelFactorType> typedResults = new LinkedHashSet <LevelFactorType> ();
for (BaseBusinessClass bbcResult : results)
{
LevelFactorType aResult = (LevelFactorType)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new LevelFactorType[0]);
}
}
public static LevelFactorType[]
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_TypeFlag))
{
return HELPER_TypeFlag.toObject (getTypeFlag ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_TypeFlag))
{
return HELPER_TypeFlag;
}
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_TypeFlag))
{
setTypeFlag ((TypeFlag)(HELPER_TypeFlag.fromObject (_TypeFlag, 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_TypeFlag))
{
return getWriteability_TypeFlag ();
}
else if (fieldName.equals (SINGLEREFERENCE_Level))
{
return getWriteability_Level ();
}
else if (fieldName.equals (SINGLEREFERENCE_Factor))
{
return getWriteability_Factor ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_TypeFlag () != FieldWriteability.TRUE)
{
fields.add (FIELD_TypeFlag);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_TypeFlag.getAttribObject (getClass (), _TypeFlag, false, FIELD_TypeFlag));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_LevelFactorType.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_LevelFactorType.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_LevelFactorType.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_LevelFactorType.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 LevelFactorTypeBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<LevelFactorType>
{
/**
* Get the attribute TypeFlag
*/
public TypeFlag getTypeFlag (LevelFactorType obj, TypeFlag original)
{
return original;
}
/**
* Change the value set for attribute TypeFlag.
* May modify the field beforehand
* Occurs before validation.
*/
public TypeFlag setTypeFlag (LevelFactorType obj, TypeFlag newTypeFlag) throws FieldException
{
return newTypeFlag;
}
}
public ORMPipeLine pipes()
{
return new LevelFactorTypePipeLineFactory<LevelFactorType, LevelFactorType> ((LevelFactorType)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public LevelFactorTypePipeLineFactory<LevelFactorType, LevelFactorType> pipelineLevelFactorType()
{
return (LevelFactorTypePipeLineFactory<LevelFactorType, LevelFactorType>) pipes();
}
public static LevelFactorTypePipeLineFactory<LevelFactorType, LevelFactorType> pipesLevelFactorType(Collection<LevelFactorType> items)
{
return REFERENCE_LevelFactorType.new LevelFactorTypePipeLineFactory<LevelFactorType, LevelFactorType> (items);
}
public static LevelFactorTypePipeLineFactory<LevelFactorType, LevelFactorType> pipesLevelFactorType(LevelFactorType[] _items)
{
return pipesLevelFactorType(Arrays.asList (_items));
}
public static LevelFactorTypePipeLineFactory<LevelFactorType, LevelFactorType> pipesLevelFactorType()
{
return pipesLevelFactorType((Collection)null);
}
public class LevelFactorTypePipeLineFactory<From extends BaseBusinessClass, Me extends LevelFactorType> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> LevelFactorTypePipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public LevelFactorTypePipeLineFactory (From seed)
{
super(seed);
}
public LevelFactorTypePipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("TypeFlag"))
{
return toTypeFlag ();
}
if (name.equals ("Level"))
{
return toLevel ();
}
if (name.equals ("Factor"))
{
return toFactor ();
}
return super.to(name);
}
public PipeLine<From, TypeFlag> toTypeFlag () { return pipe(new ORMAttributePipe<Me, TypeFlag>(FIELD_TypeFlag)); }
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 Factor.FactorPipeLineFactory<From, Factor> toFactor () { return toFactor (Filter.ALL); }
public Factor.FactorPipeLineFactory<From, Factor> toFactor (Filter<Factor> filter)
{
return Factor.REFERENCE_Factor.new FactorPipeLineFactory<From, Factor> (this, new ORMSingleAssocPipe<Me, Factor>(SINGLEREFERENCE_Factor, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyLevelFactorType extends LevelFactorType
{
// Default constructor primarily to support Externalisable
public DummyLevelFactorType()
{
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 Factor getFactor () throws StorageException
{
return (Factor)(Factor.DUMMY_Factor);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getFactorID ()
{
return Factor.DUMMY_Factor.getObjectID();
}
}
...@@ -44,6 +44,8 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -44,6 +44,8 @@ public abstract class BaseQuestion extends BaseBusinessClass
public static final String BACKREF_Section = ""; public static final String BACKREF_Section = "";
public static final String SINGLEREFERENCE_RightQuestion = "RightQuestion"; public static final String SINGLEREFERENCE_RightQuestion = "RightQuestion";
public static final String BACKREF_RightQuestion = ""; public static final String BACKREF_RightQuestion = "";
public static final String SINGLEREFERENCE_HighLowFactor = "HighLowFactor";
public static final String BACKREF_HighLowFactor = "";
public static final String MULTIPLEREFERENCE_Factors = "Factors"; public static final String MULTIPLEREFERENCE_Factors = "Factors";
public static final String BACKREF_Factors = ""; public static final String BACKREF_Factors = "";
public static final String MULTIPLEREFERENCE_LeftQuestions = "LeftQuestions"; public static final String MULTIPLEREFERENCE_LeftQuestions = "LeftQuestions";
...@@ -66,6 +68,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -66,6 +68,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
// Private attributes corresponding to single references // Private attributes corresponding to single references
private SingleAssociation<Question, Section> _Section; private SingleAssociation<Question, Section> _Section;
private SingleAssociation<Question, Question> _RightQuestion; private SingleAssociation<Question, Question> _RightQuestion;
private SingleAssociation<Question, Factor> _HighLowFactor;
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
...@@ -93,6 +96,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -93,6 +96,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
String tmp_LeftQuestions = Question.BACKREF_RightQuestion; String tmp_LeftQuestions = Question.BACKREF_RightQuestion;
String tmp_Section = Section.BACKREF_Questions; String tmp_Section = Section.BACKREF_Questions;
String tmp_RightQuestion = Question.BACKREF_LeftQuestions; String tmp_RightQuestion = Question.BACKREF_LeftQuestions;
String tmp_HighLowFactor = Factor.BACKREF_HighLowQuestions;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
...@@ -100,6 +104,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -100,6 +104,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
setupAssocMetaData_LeftQuestions(); setupAssocMetaData_LeftQuestions();
setupAssocMetaData_Section(); setupAssocMetaData_Section();
setupAssocMetaData_RightQuestion(); setupAssocMetaData_RightQuestion();
setupAssocMetaData_HighLowFactor();
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_IsRightQuestion_Validators = (AttributeValidator[])setupAttribMetaData_IsRightQuestion(validatorMapping).toArray (new AttributeValidator[0]); FIELD_IsRightQuestion_Validators = (AttributeValidator[])setupAttribMetaData_IsRightQuestion(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -175,6 +180,21 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -175,6 +180,21 @@ public abstract class BaseQuestion extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_HighLowFactor()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "HighLowQuestions");
metaInfo.put ("dbcol", "high_low_factor_id");
metaInfo.put ("name", "HighLowFactor");
metaInfo.put ("type", "Factor");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Question.HighLowFactor:", metaInfo);
ATTRIBUTES_METADATA_Question.put (SINGLEREFERENCE_HighLowFactor, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Description(Map validatorMapping) private static List setupAttribMetaData_Description(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -251,6 +271,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -251,6 +271,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
_Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "tl_quest_lin"); _Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "tl_quest_lin");
_RightQuestion = new SingleAssociation<Question, Question> (this, SINGLEREFERENCE_RightQuestion, Question.MULTIPLEREFERENCE_LeftQuestions, Question.REFERENCE_Question, "tl_quest_lin"); _RightQuestion = new SingleAssociation<Question, Question> (this, SINGLEREFERENCE_RightQuestion, Question.MULTIPLEREFERENCE_LeftQuestions, Question.REFERENCE_Question, "tl_quest_lin");
_HighLowFactor = new SingleAssociation<Question, Factor> (this, SINGLEREFERENCE_HighLowFactor, Factor.MULTIPLEREFERENCE_HighLowQuestions, Factor.REFERENCE_Factor, "tl_quest_lin");
_Factors = new MultipleAssociation<Question, FactorQuestionLink> (this, MULTIPLEREFERENCE_Factors, FactorQuestionLink.SINGLEREFERENCE_Question, FactorQuestionLink.REFERENCE_FactorQuestionLink); _Factors = new MultipleAssociation<Question, FactorQuestionLink> (this, MULTIPLEREFERENCE_Factors, FactorQuestionLink.SINGLEREFERENCE_Question, FactorQuestionLink.REFERENCE_FactorQuestionLink);
_LeftQuestions = new MultipleAssociation<Question, Question> (this, MULTIPLEREFERENCE_LeftQuestions, Question.SINGLEREFERENCE_RightQuestion, Question.REFERENCE_Question); _LeftQuestions = new MultipleAssociation<Question, Question> (this, MULTIPLEREFERENCE_LeftQuestions, Question.SINGLEREFERENCE_RightQuestion, Question.REFERENCE_Question);
...@@ -264,6 +285,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -264,6 +285,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
_Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "tl_quest_lin"); _Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "tl_quest_lin");
_RightQuestion = new SingleAssociation<Question, Question> (this, SINGLEREFERENCE_RightQuestion, Question.MULTIPLEREFERENCE_LeftQuestions, Question.REFERENCE_Question, "tl_quest_lin"); _RightQuestion = new SingleAssociation<Question, Question> (this, SINGLEREFERENCE_RightQuestion, Question.MULTIPLEREFERENCE_LeftQuestions, Question.REFERENCE_Question, "tl_quest_lin");
_HighLowFactor = new SingleAssociation<Question, Factor> (this, SINGLEREFERENCE_HighLowFactor, Factor.MULTIPLEREFERENCE_HighLowQuestions, Factor.REFERENCE_Factor, "tl_quest_lin");
_Factors = new MultipleAssociation<Question, FactorQuestionLink> (this, MULTIPLEREFERENCE_Factors, FactorQuestionLink.SINGLEREFERENCE_Question, FactorQuestionLink.REFERENCE_FactorQuestionLink); _Factors = new MultipleAssociation<Question, FactorQuestionLink> (this, MULTIPLEREFERENCE_Factors, FactorQuestionLink.SINGLEREFERENCE_Question, FactorQuestionLink.REFERENCE_FactorQuestionLink);
_LeftQuestions = new MultipleAssociation<Question, Question> (this, MULTIPLEREFERENCE_LeftQuestions, Question.SINGLEREFERENCE_RightQuestion, Question.REFERENCE_Question); _LeftQuestions = new MultipleAssociation<Question, Question> (this, MULTIPLEREFERENCE_LeftQuestions, Question.SINGLEREFERENCE_RightQuestion, Question.REFERENCE_Question);
...@@ -483,6 +505,8 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -483,6 +505,8 @@ public abstract class BaseQuestion extends BaseBusinessClass
result.add("RightQuestion"); result.add("RightQuestion");
result.add("HighLowFactor");
return result; return result;
} }
...@@ -500,6 +524,9 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -500,6 +524,9 @@ public abstract class BaseQuestion extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_RightQuestion)) }else if (assocName.equals (SINGLEREFERENCE_RightQuestion))
{ {
return _RightQuestion.getReferencedType (); return _RightQuestion.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_HighLowFactor))
{
return _HighLowFactor.getReferencedType ();
} }
else else
{ {
...@@ -520,6 +547,9 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -520,6 +547,9 @@ public abstract class BaseQuestion extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_RightQuestion)) }else if (assocName.equals (SINGLEREFERENCE_RightQuestion))
{ {
return Question.MULTIPLEREFERENCE_LeftQuestions ; return Question.MULTIPLEREFERENCE_LeftQuestions ;
}else if (assocName.equals (SINGLEREFERENCE_HighLowFactor))
{
return Factor.MULTIPLEREFERENCE_HighLowQuestions ;
} }
else else
{ {
...@@ -540,6 +570,9 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -540,6 +570,9 @@ public abstract class BaseQuestion extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_RightQuestion)) }else if (assocName.equals (SINGLEREFERENCE_RightQuestion))
{ {
return getRightQuestion (); return getRightQuestion ();
}else if (assocName.equals (SINGLEREFERENCE_HighLowFactor))
{
return getHighLowFactor ();
} }
else else
{ {
...@@ -560,6 +593,9 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -560,6 +593,9 @@ public abstract class BaseQuestion extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_RightQuestion)) }else if (assocName.equals (SINGLEREFERENCE_RightQuestion))
{ {
return getRightQuestion (getType); return getRightQuestion (getType);
}else if (assocName.equals (SINGLEREFERENCE_HighLowFactor))
{
return getHighLowFactor (getType);
} }
else else
{ {
...@@ -580,6 +616,9 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -580,6 +616,9 @@ public abstract class BaseQuestion extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_RightQuestion)) }else if (assocName.equals (SINGLEREFERENCE_RightQuestion))
{ {
return getRightQuestionID (); return getRightQuestionID ();
}else if (assocName.equals (SINGLEREFERENCE_HighLowFactor))
{
return getHighLowFactorID ();
} }
else else
{ {
...@@ -600,6 +639,9 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -600,6 +639,9 @@ public abstract class BaseQuestion extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_RightQuestion)) }else if (assocName.equals (SINGLEREFERENCE_RightQuestion))
{ {
setRightQuestion ((Question)(newValue)); setRightQuestion ((Question)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_HighLowFactor))
{
setHighLowFactor ((Factor)(newValue));
} }
else else
{ {
...@@ -824,6 +866,113 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -824,6 +866,113 @@ public abstract class BaseQuestion extends BaseBusinessClass
} }
/** /**
* Get the reference HighLowFactor
*/
public Factor getHighLowFactor () throws StorageException
{
assertValid();
try
{
return (Factor)(_HighLowFactor.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Question:", this.getObjectID (), ", was trying to get Factor:", getHighLowFactorID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _HighLowFactor.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Factor getHighLowFactor (Get getType) throws StorageException
{
assertValid();
return _HighLowFactor.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getHighLowFactorID ()
{
assertValid();
if (_HighLowFactor == null)
{
return null;
}
else
{
return _HighLowFactor.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 preHighLowFactorChange (Factor newHighLowFactor) 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 postHighLowFactorChange () throws FieldException
{
}
public FieldWriteability getWriteability_HighLowFactor ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference HighLowFactor. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setHighLowFactor (Factor newHighLowFactor) throws StorageException, FieldException
{
if (_HighLowFactor.wouldReferencedChange (newHighLowFactor))
{
assertValid();
Debug.assertion (getWriteability_HighLowFactor () != FieldWriteability.FALSE, "Assoc HighLowFactor is not writeable");
preHighLowFactorChange (newHighLowFactor);
Factor oldHighLowFactor = getHighLowFactor ();
if (oldHighLowFactor != null)
{
// This is to stop validation from triggering when we are removed
_HighLowFactor.set (null);
oldHighLowFactor.removeFromHighLowQuestions ((Question)(this));
}
_HighLowFactor.set (newHighLowFactor);
if (newHighLowFactor != null)
{
newHighLowFactor.addToHighLowQuestions ((Question)(this));
}
postHighLowFactorChange ();
}
}
/**
* 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()
...@@ -1181,6 +1330,20 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1181,6 +1330,20 @@ public abstract class BaseQuestion extends BaseBusinessClass
} }
} }
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_HighLowFactor.isLoaded () || getTransaction ().isObjectLoaded (_HighLowFactor.getReferencedType (), getHighLowFactorID ()))
{
Factor referenced = getHighLowFactor ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null HighLowQuestions from ", getObjectID (), " to ", referenced.getObjectID ());
_HighLowFactor.set (null);
referenced.removeFromHighLowQuestions ((Question)this);
}
}
for(FactorQuestionLink referenced : CollectionUtils.reverse(getFactorsSet())) for(FactorQuestionLink referenced : CollectionUtils.reverse(getFactorsSet()))
{ {
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Question from ", getObjectID (), " to ", referenced.getObjectID ()); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Question from ", getObjectID (), " to ", referenced.getObjectID ());
...@@ -1257,6 +1420,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1257,6 +1420,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
tl_quest_linPSet.setAttrib (FIELD_IsRightQuestion, HELPER_IsRightQuestion.toObject (_IsRightQuestion)); // tl_quest_linPSet.setAttrib (FIELD_IsRightQuestion, HELPER_IsRightQuestion.toObject (_IsRightQuestion)); //
_Section.getPersistentSets (allSets); _Section.getPersistentSets (allSets);
_RightQuestion.getPersistentSets (allSets); _RightQuestion.getPersistentSets (allSets);
_HighLowFactor.getPersistentSets (allSets);
} }
...@@ -1275,6 +1439,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1275,6 +1439,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
_IsRightQuestion = (Boolean)(HELPER_IsRightQuestion.fromObject (_IsRightQuestion, tl_quest_linPSet.getAttrib (FIELD_IsRightQuestion))); // _IsRightQuestion = (Boolean)(HELPER_IsRightQuestion.fromObject (_IsRightQuestion, tl_quest_linPSet.getAttrib (FIELD_IsRightQuestion))); //
_Section.setFromPersistentSets (objectID, allSets); _Section.setFromPersistentSets (objectID, allSets);
_RightQuestion.setFromPersistentSets (objectID, allSets); _RightQuestion.setFromPersistentSets (objectID, allSets);
_HighLowFactor.setFromPersistentSets (objectID, allSets);
} }
...@@ -1343,6 +1508,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1343,6 +1508,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
_Section.copyFrom (sourceQuestion._Section, linkToGhosts); _Section.copyFrom (sourceQuestion._Section, linkToGhosts);
_RightQuestion.copyFrom (sourceQuestion._RightQuestion, linkToGhosts); _RightQuestion.copyFrom (sourceQuestion._RightQuestion, linkToGhosts);
_HighLowFactor.copyFrom (sourceQuestion._HighLowFactor, linkToGhosts);
} }
} }
...@@ -1385,6 +1551,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1385,6 +1551,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
_IsRightQuestion = (Boolean)(HELPER_IsRightQuestion.readExternal (_IsRightQuestion, vals.get(FIELD_IsRightQuestion))); // _IsRightQuestion = (Boolean)(HELPER_IsRightQuestion.readExternal (_IsRightQuestion, vals.get(FIELD_IsRightQuestion))); //
_Section.readExternalData(vals.get(SINGLEREFERENCE_Section)); _Section.readExternalData(vals.get(SINGLEREFERENCE_Section));
_RightQuestion.readExternalData(vals.get(SINGLEREFERENCE_RightQuestion)); _RightQuestion.readExternalData(vals.get(SINGLEREFERENCE_RightQuestion));
_HighLowFactor.readExternalData(vals.get(SINGLEREFERENCE_HighLowFactor));
_Factors.readExternalData(vals.get(MULTIPLEREFERENCE_Factors)); _Factors.readExternalData(vals.get(MULTIPLEREFERENCE_Factors));
_LeftQuestions.readExternalData(vals.get(MULTIPLEREFERENCE_LeftQuestions)); _LeftQuestions.readExternalData(vals.get(MULTIPLEREFERENCE_LeftQuestions));
...@@ -1402,6 +1569,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1402,6 +1569,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
vals.put (FIELD_IsRightQuestion, HELPER_IsRightQuestion.writeExternal (_IsRightQuestion)); vals.put (FIELD_IsRightQuestion, HELPER_IsRightQuestion.writeExternal (_IsRightQuestion));
vals.put (SINGLEREFERENCE_Section, _Section.writeExternalData()); vals.put (SINGLEREFERENCE_Section, _Section.writeExternalData());
vals.put (SINGLEREFERENCE_RightQuestion, _RightQuestion.writeExternalData()); vals.put (SINGLEREFERENCE_RightQuestion, _RightQuestion.writeExternalData());
vals.put (SINGLEREFERENCE_HighLowFactor, _HighLowFactor.writeExternalData());
vals.put (MULTIPLEREFERENCE_Factors, _Factors.writeExternalData()); vals.put (MULTIPLEREFERENCE_Factors, _Factors.writeExternalData());
vals.put (MULTIPLEREFERENCE_LeftQuestions, _LeftQuestions.writeExternalData()); vals.put (MULTIPLEREFERENCE_LeftQuestions, _LeftQuestions.writeExternalData());
...@@ -1429,6 +1597,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1429,6 +1597,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
// Compare single assocs // Compare single assocs
_Section.compare (otherQuestion._Section, listener); _Section.compare (otherQuestion._Section, listener);
_RightQuestion.compare (otherQuestion._RightQuestion, listener); _RightQuestion.compare (otherQuestion._RightQuestion, listener);
_HighLowFactor.compare (otherQuestion._HighLowFactor, listener);
// Compare multiple assocs // Compare multiple assocs
...@@ -1455,6 +1624,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1455,6 +1624,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
visitor.visitField(this, FIELD_IsRightQuestion, HELPER_IsRightQuestion.toObject(getIsRightQuestion())); visitor.visitField(this, FIELD_IsRightQuestion, HELPER_IsRightQuestion.toObject(getIsRightQuestion()));
visitor.visitAssociation (_Section); visitor.visitAssociation (_Section);
visitor.visitAssociation (_RightQuestion); visitor.visitAssociation (_RightQuestion);
visitor.visitAssociation (_HighLowFactor);
visitor.visitAssociation (_Factors); visitor.visitAssociation (_Factors);
visitor.visitAssociation (_LeftQuestions); visitor.visitAssociation (_LeftQuestions);
...@@ -1473,6 +1643,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1473,6 +1643,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
visitor.visit (_RightQuestion); visitor.visit (_RightQuestion);
} }
if (scope.includes (_HighLowFactor))
{
visitor.visit (_HighLowFactor);
}
if (scope.includes (_Factors)) if (scope.includes (_Factors))
{ {
visitor.visit (_Factors); visitor.visit (_Factors);
...@@ -1522,6 +1696,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1522,6 +1696,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
return filter.matches (getRightQuestion ()); return filter.matches (getRightQuestion ());
} }
else if (attribName.equals (SINGLEREFERENCE_HighLowFactor))
{
return filter.matches (getHighLowFactor ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -1577,6 +1755,12 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1577,6 +1755,12 @@ public abstract class BaseQuestion extends BaseBusinessClass
return this; return this;
} }
public SearchAll andHighLowFactor (QueryFilter<Factor> filter)
{
filter.addFilter (context, "tl_quest_lin.high_low_factor_id", "HighLowFactor");
return this;
}
public Question[] public Question[]
search (ObjectTransaction transaction) throws StorageException search (ObjectTransaction transaction) throws StorageException
{ {
...@@ -1706,6 +1890,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1706,6 +1890,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
return getWriteability_RightQuestion (); return getWriteability_RightQuestion ();
} }
else if (fieldName.equals (SINGLEREFERENCE_HighLowFactor))
{
return getWriteability_HighLowFactor ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1899,6 +2087,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1899,6 +2087,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
return toRightQuestion (); return toRightQuestion ();
} }
if (name.equals ("HighLowFactor"))
{
return toHighLowFactor ();
}
return super.to(name); return super.to(name);
...@@ -1920,6 +2112,12 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1920,6 +2112,12 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
return Question.REFERENCE_Question.new QuestionPipeLineFactory<From, Question> (this, new ORMSingleAssocPipe<Me, Question>(SINGLEREFERENCE_RightQuestion, filter)); return Question.REFERENCE_Question.new QuestionPipeLineFactory<From, Question> (this, new ORMSingleAssocPipe<Me, Question>(SINGLEREFERENCE_RightQuestion, filter));
} }
public Factor.FactorPipeLineFactory<From, Factor> toHighLowFactor () { return toHighLowFactor (Filter.ALL); }
public Factor.FactorPipeLineFactory<From, Factor> toHighLowFactor (Filter<Factor> filter)
{
return Factor.REFERENCE_Factor.new FactorPipeLineFactory<From, Factor> (this, new ORMSingleAssocPipe<Me, Factor>(SINGLEREFERENCE_HighLowFactor, filter));
}
public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toFactors () { return toFactors(Filter.ALL); } public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toFactors () { return toFactors(Filter.ALL); }
public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toFactors (Filter<FactorQuestionLink> filter) public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toFactors (Filter<FactorQuestionLink> filter)
...@@ -1991,6 +2189,20 @@ class DummyQuestion extends Question ...@@ -1991,6 +2189,20 @@ class DummyQuestion extends Question
return Question.DUMMY_Question.getObjectID(); return Question.DUMMY_Question.getObjectID();
} }
public Factor getHighLowFactor () throws StorageException
{
return (Factor)(Factor.DUMMY_Factor);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getHighLowFactorID ()
{
return Factor.DUMMY_Factor.getObjectID();
}
public int getFactorsCount () throws StorageException public int getFactorsCount () throws StorageException
{ {
return 0; return 0;
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
<MULTIPLEREFERENCE name="Levels" type="FactorLevelLink" backreferenceName="Factor" /> <MULTIPLEREFERENCE name="Levels" type="FactorLevelLink" backreferenceName="Factor" />
<MULTIPLEREFERENCE name="Questions" type="FactorQuestionLink" backreferenceName="Factor" /> <MULTIPLEREFERENCE name="Questions" type="FactorQuestionLink" backreferenceName="Factor" />
<MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Factor" /> <MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Factor" />
<MULTIPLEREFERENCE name="HighLowQuestions" type="Question" backreferenceName="HighLowFactor" />
<MULTIPLEREFERENCE name="LevelFactorTypes" type="LevelFactorType" backreferenceName="Factor" />
<TABLE name="tl_factor" tablePrefix="object" polymorphic="FALSE"> <TABLE name="tl_factor" tablePrefix="object" polymorphic="FALSE">
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Level" /> <MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Level" />
<MULTIPLEREFERENCE name="Narratives" type="Narrative" backreferenceName="Level" /> <MULTIPLEREFERENCE name="Narratives" type="Narrative" backreferenceName="Level" />
<MULTIPLEREFERENCE name="TestAnalysises" type="TestAnalysis" backreferenceName="Level" /> <MULTIPLEREFERENCE name="TestAnalysises" type="TestAnalysis" backreferenceName="Level" />
<MULTIPLEREFERENCE name="LevelFactorTypes" type="LevelFactorType" backreferenceName="Level" />
<TABLE name="tl_level" tablePrefix="object" polymorphic="FALSE"> <TABLE name="tl_level" tablePrefix="object" polymorphic="FALSE">
......
package performa.orm;
public class LevelFactorType extends BaseLevelFactorType
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public LevelFactorType ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public String getObjectIDSpace()
{
return "LevelFactorType";
}
}
\ 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="LevelFactorType" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TABLE name="tl_level_type" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="TypeFlag" type="TypeFlag" dbcol="type_flag" attribHelper="EnumeratedAttributeHelper"/>
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_number" backreferenceName="LevelFactorTypes" />
<SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number" backreferenceName="LevelFactorTypes" />
</TABLE>
<SEARCH type="All" paramFilter="tl_level_type.object_id is not null" orderBy="tl_level_type.object_id"/>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import performa.orm.types.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class LevelFactorTypePersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea LevelFactorTypePersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "LevelFactorType");
// Private attributes corresponding to business object data
private TypeFlag dummyTypeFlag;
// Static constants corresponding to attribute helpers
private static final EnumeratedAttributeHelper HELPER_TypeFlag = new EnumeratedAttributeHelper (TypeFlag.FACTORY_TypeFlag);
public LevelFactorTypePersistenceMgr ()
{
dummyTypeFlag = (TypeFlag)(HELPER_TypeFlag.initialise (dummyTypeFlag));
}
private String SELECT_COLUMNS = "{PREFIX}tl_level_type.object_id as id, {PREFIX}tl_level_type.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_level_type.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_level_type.type_flag, {PREFIX}tl_level_type.level_number, {PREFIX}tl_level_type.factor_number, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, LevelFactorType.REFERENCE_LevelFactorType);
if (objectToReturn instanceof LevelFactorType)
{
LogMgr.log (LevelFactorTypePersistence, 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 LevelFactorType");
}
}
PersistentSet tl_level_typePSet = allPSets.getPersistentSet(id, "tl_level_type", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_level_typePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_level_typePSet.containsAttrib(LevelFactorType.FIELD_TypeFlag)||
!tl_level_typePSet.containsAttrib(LevelFactorType.SINGLEREFERENCE_Level)||
!tl_level_typePSet.containsAttrib(LevelFactorType.SINGLEREFERENCE_Factor))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (LevelFactorTypePersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
LevelFactorType result = new LevelFactorType ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_level_type " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_level_type.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else if (refName.equals (LevelFactorType.SINGLEREFERENCE_Level))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_level_type " +
"WHERE " + SELECT_JOINS + "level_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else if (refName.equals (LevelFactorType.SINGLEREFERENCE_Factor))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_level_type " +
"WHERE " + SELECT_JOINS + "factor_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_level_typePSet = allPSets.getPersistentSet(objectID, "tl_level_type");
if (tl_level_typePSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_level_typePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_level_type " +
"SET type_flag = ?, level_number = ? , factor_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_level_type.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_TypeFlag.getForSQL(dummyTypeFlag, tl_level_typePSet.getAttrib (LevelFactorType.FIELD_TypeFlag))).listEntry (SQLManager.CheckNull((Long)(tl_level_typePSet.getAttrib (LevelFactorType.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(tl_level_typePSet.getAttrib (LevelFactorType.SINGLEREFERENCE_Factor)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_level_type WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_level_type", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (LevelFactorTypePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_level_type");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_level_type for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (LevelFactorTypePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_level_typePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (LevelFactorTypePersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_level_typePSet = allPSets.getPersistentSet(objectID, "tl_level_type");
LogMgr.log (LevelFactorTypePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_level_typePSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_level_typePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_level_type " +
"WHERE tl_level_type.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_level_type WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_level_type");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_level_type for row:" + objectID;
LogMgr.log (LevelFactorTypePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_level_typePSet.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, LevelFactorType> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (LevelFactorType.REFERENCE_LevelFactorType.getObjectIDSpace (), r.getLong ("id"));
LevelFactorType 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, LevelFactorType.REFERENCE_LevelFactorType);
if (cachedElement instanceof LevelFactorType)
{
LogMgr.log (LevelFactorTypePersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (LevelFactorType)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a LevelFactorType");
}
}
else
{
PersistentSet tl_level_typePSet = allPSets.getPersistentSet(objectID, "tl_level_type", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new LevelFactorType ();
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 (LevelFactorTypePersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_level_type " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (LevelFactorType.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY tl_level_type.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_level_type.object_id is not null
String preFilter = "(tl_level_type.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_level_type " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_level_typePSet = allPSets.getPersistentSet(objectID, "tl_level_type", PersistentSetStatus.FETCHED);
// Object Modified
tl_level_typePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_level_typePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_level_typePSet.setAttrib(LevelFactorType.FIELD_TypeFlag, HELPER_TypeFlag.getFromRS(dummyTypeFlag, r, "type_flag"));
tl_level_typePSet.setAttrib(LevelFactorType.SINGLEREFERENCE_Level, r.getObject ("level_number"));
tl_level_typePSet.setAttrib(LevelFactorType.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_level_typePSet = allPSets.getPersistentSet(objectID, "tl_level_type");
if (tl_level_typePSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_level_typePSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_level_type " +
" (type_flag, level_number, factor_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_TypeFlag.getForSQL(dummyTypeFlag, tl_level_typePSet.getAttrib (LevelFactorType.FIELD_TypeFlag))) .listEntry (SQLManager.CheckNull((Long)(tl_level_typePSet.getAttrib (LevelFactorType.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(tl_level_typePSet.getAttrib (LevelFactorType.SINGLEREFERENCE_Factor)))) .listEntry (objectID.longID ()).toList().toArray());
tl_level_typePSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<SINGLEREFERENCE name="Section" type="Section" dbcol="section_number" backreferenceName="Questions"/> <SINGLEREFERENCE name="Section" type="Section" dbcol="section_number" backreferenceName="Questions"/>
<SINGLEREFERENCE name="RightQuestion" type="Question" dbcol="right_quest_number" backreferenceName="LeftQuestions"/> <SINGLEREFERENCE name="RightQuestion" type="Question" dbcol="right_quest_number" backreferenceName="LeftQuestions"/>
<SINGLEREFERENCE name="HighLowFactor" type="Factor" dbcol="high_low_factor_id" backreferenceName="HighLowQuestions"/> <!-- Using this to manage special case of Unusually High/Low Factor Calculation -->
</TABLE> </TABLE>
......
...@@ -44,7 +44,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -44,7 +44,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}tl_quest_lin.object_id as id, {PREFIX}tl_quest_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_quest_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_quest_lin.description, {PREFIX}tl_quest_lin.is_right_quest, {PREFIX}tl_quest_lin.section_number, {PREFIX}tl_quest_lin.right_quest_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_quest_lin.object_id as id, {PREFIX}tl_quest_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_quest_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_quest_lin.description, {PREFIX}tl_quest_lin.is_right_quest, {PREFIX}tl_quest_lin.section_number, {PREFIX}tl_quest_lin.right_quest_number, {PREFIX}tl_quest_lin.high_low_factor_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
...@@ -98,7 +98,8 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -98,7 +98,8 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
!tl_quest_linPSet.containsAttrib(Question.FIELD_Description)|| !tl_quest_linPSet.containsAttrib(Question.FIELD_Description)||
!tl_quest_linPSet.containsAttrib(Question.FIELD_IsRightQuestion)|| !tl_quest_linPSet.containsAttrib(Question.FIELD_IsRightQuestion)||
!tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_Section)|| !tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_Section)||
!tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_RightQuestion)) !tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_RightQuestion)||
!tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_HighLowFactor))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -164,6 +165,16 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -164,6 +165,16 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (refName.equals (Question.SINGLEREFERENCE_HighLowFactor))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_quest_lin " +
"WHERE " + SELECT_JOINS + "high_low_factor_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);
...@@ -188,10 +199,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -188,10 +199,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_quest_lin " + "UPDATE {PREFIX}tl_quest_lin " +
"SET description = ?, is_right_quest = ?, section_number = ? , right_quest_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET description = ?, is_right_quest = ?, section_number = ? , right_quest_number = ? , high_low_factor_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_quest_lin.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE tl_quest_lin.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (HELPER_IsRightQuestion.getForSQL(dummyIsRightQuestion, tl_quest_linPSet.getAttrib (Question.FIELD_IsRightQuestion))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_RightQuestion)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (HELPER_IsRightQuestion.getForSQL(dummyIsRightQuestion, tl_quest_linPSet.getAttrib (Question.FIELD_IsRightQuestion))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_RightQuestion)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_HighLowFactor)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -452,6 +463,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -452,6 +463,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
tl_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_Section, r.getObject ("section_number")); tl_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_Section, r.getObject ("section_number"));
tl_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_RightQuestion, r.getObject ("right_quest_number")); tl_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_RightQuestion, r.getObject ("right_quest_number"));
tl_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_HighLowFactor, r.getObject ("high_low_factor_id"));
} }
...@@ -468,10 +480,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -468,10 +480,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_quest_lin " + "INSERT INTO {PREFIX}tl_quest_lin " +
" (description, is_right_quest, section_number, right_quest_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (description, is_right_quest, section_number, right_quest_number, high_low_factor_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_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (HELPER_IsRightQuestion.getForSQL(dummyIsRightQuestion, tl_quest_linPSet.getAttrib (Question.FIELD_IsRightQuestion))) .listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_RightQuestion)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (HELPER_IsRightQuestion.getForSQL(dummyIsRightQuestion, tl_quest_linPSet.getAttrib (Question.FIELD_IsRightQuestion))) .listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_RightQuestion)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_HighLowFactor)))) .listEntry (objectID.longID ()).toList().toArray());
tl_quest_linPSet.setStatus (PersistentSetStatus.PROCESSED); tl_quest_linPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -35,16 +35,16 @@ public class ColorCode extends AbstractEnumerated ...@@ -35,16 +35,16 @@ public class ColorCode extends AbstractEnumerated
return allColorCodes; return allColorCodes;
} }
private transient Integer Weightage; private transient Integer ColorRank;
private ColorCode (String name, String value, String description, boolean disabled) private ColorCode (String name, String value, String description, boolean disabled)
{ {
super (name, value, description, disabled); super (name, value, description, disabled);
} }
public Integer getWeightage() public Integer getColorRank()
{ {
return Weightage; return ColorRank;
} }
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allColorCodes); public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allColorCodes);
...@@ -114,9 +114,9 @@ public class ColorCode extends AbstractEnumerated ...@@ -114,9 +114,9 @@ public class ColorCode extends AbstractEnumerated
public static void defineAdditionalData () public static void defineAdditionalData ()
{ {
RED.Weightage = 1; RED.ColorRank = 3;
AMBER.Weightage = 5; AMBER.ColorRank = 2;
GREEN.Weightage = 10; GREEN.ColorRank = 1;
} }
...@@ -144,7 +144,7 @@ public class ColorCode extends AbstractEnumerated ...@@ -144,7 +144,7 @@ public class ColorCode extends AbstractEnumerated
{ {
Map attribs = new HashMap (); Map attribs = new HashMap ();
attribs.put ("Weightage", ArrayFormatter.toObject(getWeightage())); attribs.put ("ColorRank", ArrayFormatter.toObject(getColorRank()));
return attribs; return attribs;
} }
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<ROOT> <ROOT>
<CONSTANT package="performa.orm.types" name="ColorCode"> <CONSTANT package="performa.orm.types" name="ColorCode">
<DATA name="Weightage" type="Integer"/> <DATA name="ColorRank" type="Integer"/>
<VALUE name="RED" value="RED" description="Red" Weightage="1"/> <VALUE name="RED" value="RED" description="Red" ColorRank="3"/>
<VALUE name="AMBER" value="AMBER" description="Amber" Weightage="5"/> <VALUE name="AMBER" value="AMBER" description="Amber" ColorRank="2"/>
<VALUE name="GREEN" value="GREEN" description="Green" Weightage="10"/> <VALUE name="GREEN" value="GREEN" description="Green" ColorRank="1"/>
</CONSTANT> </CONSTANT>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -15,44 +15,30 @@ import oneit.utils.*; ...@@ -15,44 +15,30 @@ import oneit.utils.*;
* e.g. constGen C:\...\sql FieldType * e.g. constGen C:\...\sql FieldType
*/ */
public class StateType extends AbstractEnumerated public class TypeFlag extends AbstractEnumerated
{ {
public static final EnumeratedFactory FACTORY_StateType = new StateTypeFactory(); public static final EnumeratedFactory FACTORY_TypeFlag = new TypeFlagFactory();
public static final StateType WA = new StateType ("WA", "WA", "Western Australia", false); public static final TypeFlag PRIMARY = new TypeFlag ("PRIMARY", "PRIMARY", "Primary", false);
public static final StateType NSW = new StateType ("NSW", "NSW", "New South Wales", false); public static final TypeFlag SECONDARY = new TypeFlag ("SECONDARY", "SECONDARY", "Secondary", false);
public static final StateType VIC = new StateType ("VIC", "VIC", "Victoria", false); private static final TypeFlag[] allTypeFlags =
new TypeFlag[] { PRIMARY,SECONDARY};
public static final StateType TAS = new StateType ("TAS", "TAS", "Tasmania", false);
public static final StateType QLD = new StateType ("QLD", "QLD", "Queensland", false); private static TypeFlag[] getAllTypeFlags ()
public static final StateType SA = new StateType ("SA", "SA", "South Australia", false);
public static final StateType ACT = new StateType ("ACT", "ACT", "Australian Capital Territory", false);
public static final StateType NT = new StateType ("NT", "NT", "Northern Territory", false);
public static final StateType OS = new StateType ("OS", "OS", "Outside Australia", false);
private static final StateType[] allStateTypes =
new StateType[] { WA,NSW,VIC,TAS,QLD,SA,ACT,NT,OS};
private static StateType[] getAllStateTypes ()
{ {
return allStateTypes; return allTypeFlags;
} }
private StateType (String name, String value, String description, boolean disabled) private TypeFlag (String name, String value, String description, boolean disabled)
{ {
super (name, value, description, disabled); super (name, value, description, disabled);
} }
public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allStateTypes); public static final Comparator COMPARE_BY_POSITION = new CompareEnumByPosition (allTypeFlags);
...@@ -61,45 +47,45 @@ public class StateType extends AbstractEnumerated ...@@ -61,45 +47,45 @@ public class StateType extends AbstractEnumerated
defineAdditionalData (); defineAdditionalData ();
} }
public boolean isEqual (StateType other) public boolean isEqual (TypeFlag other)
{ {
return this.name.equals (other.name); return this.name.equals (other.name);
} }
public Enumeration getAllInstances () public Enumeration getAllInstances ()
{ {
return StateType.getAll (); return TypeFlag.getAll ();
} }
private Object readResolve() throws java.io.ObjectStreamException private Object readResolve() throws java.io.ObjectStreamException
{ {
return StateType.forName (this.name); return TypeFlag.forName (this.name);
} }
public EnumeratedFactory getFactory () public EnumeratedFactory getFactory ()
{ {
return FACTORY_StateType; return FACTORY_TypeFlag;
} }
public static StateType forName (String name) public static TypeFlag forName (String name)
{ {
if (name == null) { return null; } if (name == null) { return null; }
StateType[] all = getAllStateTypes(); TypeFlag[] all = getAllTypeFlags();
int enumIndex = AbstractEnumerated.getIndexForName (all, name); int enumIndex = AbstractEnumerated.getIndexForName (all, name);
return all[enumIndex]; return all[enumIndex];
} }
public static StateType forValue (String value) public static TypeFlag forValue (String value)
{ {
if (value == null) { return null; } if (value == null) { return null; }
StateType[] all = getAllStateTypes(); TypeFlag[] all = getAllTypeFlags();
int enumIndex = AbstractEnumerated.getIndexForValue (getAllStateTypes (), value); int enumIndex = AbstractEnumerated.getIndexForValue (getAllTypeFlags (), value);
return all[enumIndex]; return all[enumIndex];
} }
...@@ -107,13 +93,13 @@ public class StateType extends AbstractEnumerated ...@@ -107,13 +93,13 @@ public class StateType extends AbstractEnumerated
public static java.util.Enumeration getAll () public static java.util.Enumeration getAll ()
{ {
return AbstractEnumerated.getAll (getAllStateTypes()); return AbstractEnumerated.getAll (getAllTypeFlags());
} }
public static StateType[] getStateTypeArray () public static TypeFlag[] getTypeFlagArray ()
{ {
return (StateType[])getAllStateTypes().clone (); return (TypeFlag[])getAllTypeFlags().clone ();
} }
...@@ -123,21 +109,21 @@ public class StateType extends AbstractEnumerated ...@@ -123,21 +109,21 @@ public class StateType extends AbstractEnumerated
} }
static class StateTypeFactory implements EnumeratedFactory static class TypeFlagFactory implements EnumeratedFactory
{ {
public AbstractEnumerated getForName (String name) public AbstractEnumerated getForName (String name)
{ {
return StateType.forName (name); return TypeFlag.forName (name);
} }
public AbstractEnumerated getForValue (String name) public AbstractEnumerated getForValue (String name)
{ {
return StateType.forValue (name); return TypeFlag.forValue (name);
} }
public Enumeration getAll () public Enumeration getAll ()
{ {
return StateType.getAll (); return TypeFlag.getAll ();
} }
} }
......
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CONSTANT package="performa.orm.types" name="TypeFlag">
<VALUE name="PRIMARY" description="Primary"/>
<VALUE name="SECONDARY" description="Secondary"/>
</CONSTANT>
</ROOT>
\ No newline at end of file
...@@ -4,7 +4,9 @@ import java.util.*; ...@@ -4,7 +4,9 @@ import java.util.*;
import oneit.logging.*; import oneit.logging.*;
import oneit.objstore.*; import oneit.objstore.*;
import oneit.objstore.rdbms.filters.*; import oneit.objstore.rdbms.filters.*;
import oneit.utils.*;
import oneit.utils.filter.Filter; import oneit.utils.filter.Filter;
import oneit.utils.math.Statistics;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.*; import performa.orm.*;
import performa.orm.types.*; import performa.orm.types.*;
...@@ -15,6 +17,8 @@ import performa.orm.types.*; ...@@ -15,6 +17,8 @@ import performa.orm.types.*;
*/ */
public class AnalysisEngine public class AnalysisEngine
{ {
private static final Long MAX_VALID_FACTOR_NUMBER = 49L; //Don't consider unusally high/low answer factors i.e 50/51
public static void analyseAnswers(JobApplication jobApplication) throws StorageException, FieldException public static void analyseAnswers(JobApplication jobApplication) throws StorageException, FieldException
{ {
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1, "Inside AnalysisEngine --> analyseAnswers"); LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1, "Inside AnalysisEngine --> analyseAnswers");
...@@ -27,6 +31,7 @@ public class AnalysisEngine ...@@ -27,6 +31,7 @@ public class AnalysisEngine
jobApplication.pipelineJobApplication().toProfileAssessmentAnswers().toQuestion().toSection().uniqueVals(); jobApplication.pipelineJobApplication().toProfileAssessmentAnswers().toQuestion().toSection().uniqueVals();
jobApplication.pipelineJobApplication().toProfileAssessmentAnswers().toQuestion().toFactors().toFactor().uniqueVals(); jobApplication.pipelineJobApplication().toProfileAssessmentAnswers().toQuestion().toFactors().toFactor().uniqueVals();
Factor.pipesFactor(levelFactors).toResults().uniqueVals(); Factor.pipesFactor(levelFactors).toResults().uniqueVals();
Factor.pipesFactor(levelFactors).toLevelFactorTypes().uniqueVals();
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1, "Processing Job Application ", jobApplication); LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1, "Processing Job Application ", jobApplication);
...@@ -41,6 +46,8 @@ public class AnalysisEngine ...@@ -41,6 +46,8 @@ public class AnalysisEngine
int factorScore = 0; int factorScore = 0;
Factor factor = link.getFactor(); Factor factor = link.getFactor();
if(factor.getID().longID() <= MAX_VALID_FACTOR_NUMBER) //Don't consider unusally high/low answer factors i.e 50/51
{
if(factorScoreMap.containsKey(factor)) if(factorScoreMap.containsKey(factor))
{ {
factorScore = factorScoreMap.get(factor); factorScore = factorScoreMap.get(factor);
...@@ -59,12 +66,28 @@ public class AnalysisEngine ...@@ -59,12 +66,28 @@ public class AnalysisEngine
} }
else else
{ {
factorScore += answer.getAnswerNo() != null ? answer.getAnswerNo() : 0; factorScore += StringUtils.subNulls(answer.getAnswerNo(), 0);
} }
factorScoreMap.put(factor, factorScore); factorScoreMap.put(factor, factorScore);
} }
} }
}
//Unusually High Answers/Unusually Low Answers
Filter<Question> questFilter = Question.SearchByAll().andHighLowFactor(new IsNotNullFilter());
MultiHashtable<Factor, Answer> highLowAnswersByFactor = new MultiHashtable();
highLowAnswersByFactor.groupValues(jobApplication.getProfileAssessmentAnswersSet(), Answer.pipesAnswer().toQuestion(questFilter).toHighLowFactor());
for(Factor factor : highLowAnswersByFactor.keySet())
{
if(factor != null)
{
double answerTotal = Statistics.sum(Answer.pipesAnswer(highLowAnswersByFactor.getValuesForKeyNN(factor)).toAnswerNo().vals());
factorScoreMap.put(factor, Double.valueOf(answerTotal).intValue());
}
}
TestAnalysis testAnalysis = TestAnalysis.createTestAnalysis(objTran); TestAnalysis testAnalysis = TestAnalysis.createTestAnalysis(objTran);
...@@ -93,11 +116,40 @@ public class AnalysisEngine ...@@ -93,11 +116,40 @@ public class AnalysisEngine
factorScore.setFactor(factor); factorScore.setFactor(factor);
factorScore.setLevel(jobApplication.getJob().getLevel()); factorScore.setLevel(jobApplication.getJob().getLevel());
factorScore.setScore(score); factorScore.setScore(score);
factorScore.setWghtdScore(score); //temp fix, to-do change later
factorScore.setColorCode(factorScoreResult.getColorCode()); factorScore.setColorCode(factorScoreResult.getColorCode());
factorScore.setColorRank(factorScoreResult.getColorCode() != null ? factorScoreResult.getColorCode().getWeightage() : 0); factorScore.setColorRank(factorScoreResult.getColorCode() != null ? factorScoreResult.getColorCode().getColorRank() : 0);
factorScore.setNarrative(factorScoreResult.getNarrative()); factorScore.setNarrative(factorScoreResult.getNarrative());
/**
* Weighted Score.
*
* 10 where color rank = 1 and flag = Primary
* 5 where color rank = 1 and flag = Secondary
* 4 where color rank = 2 and flag = Primary
* 2 where color rank = 2 and flag = Secondary
*/
Integer weightedScore = 0;
if(factorScoreResult.getColorCode() == ColorCode.GREEN || factorScoreResult.getColorCode() == ColorCode.AMBER)
{
Filter<LevelFactorType> levelFactorFilter = LevelFactorType.SearchByAll().andLevel(new EqualsFilter(jobApplication.getJob().getLevel()));
LevelFactorType levelFactorType = factor.pipelineFactor().toLevelFactorTypes(levelFactorFilter).val();
if(levelFactorType != null && levelFactorType.getTypeFlag() != null)
{
if(factorScoreResult.getColorCode() == ColorCode.GREEN)//Color Code: Green --> Color Rank = 1
{
weightedScore = (levelFactorType.getTypeFlag() == TypeFlag.PRIMARY) ? 10 : 5;
}
else //Color Code: Amber --> Color Rank = 2
{
weightedScore = (levelFactorType.getTypeFlag() == TypeFlag.PRIMARY) ? 4 : 2;
}
}
}
factorScore.setWghtdScore(weightedScore);
testAnalysis.addToFactorScores(factorScore); testAnalysis.addToFactorScores(factorScore);
jobApplication.getCandidate().addToFactorScores(factorScore); jobApplication.getCandidate().addToFactorScores(factorScore);
} }
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
%> %>
<li class="<%= activeStr %>"> <li class="<%= activeStr %>">
<a href="javascript:void(0);"> <a href="javascript:void(0);">
<input type="radio" name="<%= optionKey %>" id="<%= index %>" onchange="gotoNextQuestion();" class="answer_radio" value="<%= index %>" <%= selectedStr %>> <input type="radio" name="<%= optionKey %>" id="<%= index %>" onchange="gotoNextQuestion();" class="answer_radio" value="<%= answer.getFinalAnswerValue(index) %>" <%= selectedStr %>>
<label for="<%= index %>"><%= index %></label> <label for="<%= index %>"><%= index %></label>
</a> </a>
</li> </li>
......
<?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.RedefineTableOperation">
<tableName factory="String">tl_quest_lin</tableName>
<column name="high_low_factor_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_high_low_factor_id" isUnique="false"><column name="high_low_factor_id"/></NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
update tl_quest_lin set high_low_factor_id = 50 where object_id in (25, 118, 226, 240, 243, 246, 251, 253, 258, 261, 265, 310, 312, 340);
update tl_quest_lin set high_low_factor_id = 51 where object_id in (9, 10, 18, 30,138, 140,203, 207, 208, 224, 237, 264, 275, 280);
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_level_type</tableName>
<column name="object_id" type="Long" nullable="true" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="type_flag" type="String" nullable="true" length="200"/>
<column name="level_number" type="Long" length="11" nullable="true"/>
<column name="factor_number" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_level_type" indexName="idx_tl_level_type_level_number" isUnique="false"><column name="level_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_level_type" indexName="idx_tl_level_type_factor_number" isUnique="false"><column name="factor_number"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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