Commit 595c3bd1 by Harsh Shah

BO Changes (Table renamed, IDSpace added)

parent 435b6daa
...@@ -4,13 +4,16 @@ ...@@ -4,13 +4,16 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">answer</tableName> <tableName factory="String">rs_answer</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="answer_number" type="Long" nullable="true"/> <column name="answer_number" type="Long" nullable="true"/>
<column name="section_number" type="Long" length="11" nullable="true"/>
<column name="candidate_id" type="Long" length="11" nullable="true"/> <column name="candidate_id" type="Long" length="11" nullable="true"/>
<column name="quest_number" type="Long" length="11" nullable="true"/> <column name="quest_number" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_answer" indexName="idx_rs_answer_candidate_id" isUnique="false"><column name="candidate_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,27 +4,14 @@ ...@@ -4,27 +4,14 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">candidate</tableName> <tableName factory="String">rs_candidate</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="first_name" type="String" nullable="true" length="30"/> <column name="first_name" type="String" nullable="true" length="30"/>
<column name="middle_name" type="String" nullable="true" length="30"/>
<column name="last_name" type="String" nullable="true" length="30"/>
<column name="preferred_name" type="String" nullable="true" length="30"/>
<column name="salutation" type="String" nullable="true" length="10"/>
<column name="position" type="String" nullable="true" length="30"/>
<column name="date_of_birth" type="Date" nullable="true"/>
<column name="date_registered" type="Date" nullable="true"/>
<column name="gender" type="String" nullable="true" length="10"/>
<column name="password" type="String" nullable="true" length="15"/>
<column name="date_taken" type="Date" nullable="true"/>
<column name="location" type="String" nullable="true" length="80"/>
<column name="contact_phone" type="String" nullable="true" length="80"/>
<column name="email" type="String" nullable="true" length="60"/>
<column name="test_input_id" type="Long" length="11" nullable="true"/> <column name="test_input_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="candidate" indexName="idx_candidate_test_input_id" isUnique="false"><column name="test_input_id"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_candidate" indexName="idx_rs_candidate_test_input_id" isUnique="false"><column name="test_input_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">factor</tableName> <tableName factory="String">rs_factor</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">factor_hdr</tableName> <tableName factory="String">rs_factor_hdr</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
<column name="factor_number" type="Long" length="11" nullable="true"/> <column name="factor_number" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="factor_hdr" indexName="idx_factor_hdr_level_number" isUnique="false"><column name="level_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_factor_hdr" indexName="idx_rs_factor_hdr_level_number" isUnique="false"><column name="level_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="factor_hdr" indexName="idx_factor_hdr_factor_number" isUnique="false"><column name="factor_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_factor_hdr" indexName="idx_rs_factor_hdr_factor_number" isUnique="false"><column name="factor_number"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">factor_lin</tableName> <tableName factory="String">rs_factor_lin</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<column name="quest_number" type="Long" length="11" nullable="true"/> <column name="quest_number" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="factor_lin" indexName="idx_factor_lin_factor_number" isUnique="false"><column name="factor_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_factor_lin" indexName="idx_rs_factor_lin_factor_number" isUnique="false"><column name="factor_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="factor_lin" indexName="idx_factor_lin_quest_number" isUnique="false"><column name="quest_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_factor_lin" indexName="idx_rs_factor_lin_quest_number" isUnique="false"><column name="quest_number"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,15 +4,19 @@ ...@@ -4,15 +4,19 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">score</tableName> <tableName factory="String">rs_score</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="score_number" type="Long" nullable="true"/> <column name="score_number" type="Long" nullable="true"/>
<column name="test_analysis_id" type="Long" length="11" nullable="true"/> <column name="test_analysis_id" type="Long" length="11" nullable="true"/>
<column name="factor_number" type="Long" length="11" nullable="true"/> <column name="factor_number" type="Long" length="11" nullable="true"/>
<column name="level_number" type="Long" length="11" nullable="true"/>
<column name="narrative_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="score" indexName="idx_score_test_analysis_id" isUnique="false"><column name="test_analysis_id"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_score" indexName="idx_rs_score_test_analysis_id" isUnique="false"><column name="test_analysis_id"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_score" indexName="idx_rs_score_narrative_id" isUnique="false"><column name="narrative_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">level_factor</tableName> <tableName factory="String">rs_level_factor</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
<column name="narrative_id" type="Long" length="11" nullable="true"/> <column name="narrative_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="level_factor" indexName="idx_level_factor_factor_number" isUnique="false"><column name="factor_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_level_factor" indexName="idx_rs_level_factor_factor_number" isUnique="false"><column name="factor_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="level_factor" indexName="idx_level_factor_level_number" isUnique="false"><column name="level_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_level_factor" indexName="idx_rs_level_factor_level_number" isUnique="false"><column name="level_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="level_factor" indexName="idx_level_factor_narrative_id" isUnique="false"><column name="narrative_id"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_level_factor" indexName="idx_rs_level_factor_narrative_id" isUnique="false"><column name="narrative_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">level</tableName> <tableName factory="String">rs_level</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">narrative</tableName> <tableName factory="String">rs_narrative</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
...@@ -19,4 +19,6 @@ ...@@ -19,4 +19,6 @@
<column name="level_number" type="Long" length="11" nullable="true"/> <column name="level_number" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_narrative" indexName="idx_rs_narrative_level_number" isUnique="false"><column name="level_number"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">quest_lin</tableName> <tableName factory="String">rs_quest_lin</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
...@@ -12,6 +12,6 @@ ...@@ -12,6 +12,6 @@
<column name="section_number" type="Long" length="11" nullable="true"/> <column name="section_number" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="quest_lin" indexName="idx_quest_lin_section_number" isUnique="false"><column name="section_number"/></NODE> <NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_quest_lin" indexName="idx_rs_quest_lin_section_number" isUnique="false"><column name="section_number"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">quest_hdr</tableName> <tableName factory="String">rs_quest_hdr</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector"> <OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation"> <NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">test_analysis</tableName> <tableName factory="String">rs_test_analysis</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
...@@ -12,4 +12,8 @@ ...@@ -12,4 +12,8 @@
<column name="candidate_id" type="Long" length="11" nullable="true"/> <column name="candidate_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_test_analysis" indexName="idx_rs_test_analysis_level_id" isUnique="false"><column name="level_id"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_test_analysis" indexName="idx_rs_test_analysis_candidate_id" isUnique="false"><column name="candidate_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">it_does_not_matter</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="xxxx" type="BLOB" nullable="false"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE answer; -- DROP TABLE rs_answer;
CREATE TABLE answer ( CREATE TABLE rs_answer (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, ,
answer_number numeric(12) NULL, answer_number numeric(12) NULL,
section_number numeric(12) NULL,
candidate_id numeric(12) NULL, candidate_id numeric(12) NULL,
quest_number numeric(12) NULL quest_number numeric(12) NULL
); );
ALTER TABLE answer ADD ALTER TABLE rs_answer ADD
CONSTRAINT PK_answer PRIMARY KEY CONSTRAINT PK_rs_answer PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_answer_candidate_id
ON rs_answer (candidate_id);
-- DROP TABLE candidate; -- DROP TABLE rs_candidate;
CREATE TABLE candidate ( CREATE TABLE rs_candidate (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, ,
first_name varchar(30) NULL, first_name varchar(30) NULL,
middle_name varchar(30) NULL,
last_name varchar(30) NULL,
preferred_name varchar(30) NULL,
salutation varchar(10) NULL,
position varchar(30) NULL,
date_of_birth datetime NULL,
date_registered datetime NULL,
gender varchar(10) NULL,
password varchar(15) NULL,
date_taken datetime NULL,
location varchar(80) NULL,
contact_phone varchar(80) NULL,
email varchar(60) NULL,
test_input_id numeric(12) NULL test_input_id numeric(12) NULL
); );
ALTER TABLE candidate ADD ALTER TABLE rs_candidate ADD
CONSTRAINT PK_candidate PRIMARY KEY CONSTRAINT PK_rs_candidate PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_candidate_test_input_id CREATE INDEX idx_rs_candidate_test_input_id
ON candidate (test_input_id); ON rs_candidate (test_input_id);
-- DROP TABLE factor; -- DROP TABLE rs_factor;
CREATE TABLE factor ( CREATE TABLE rs_factor (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -13,8 +13,8 @@ CREATE TABLE factor ( ...@@ -13,8 +13,8 @@ CREATE TABLE factor (
ALTER TABLE factor ADD ALTER TABLE rs_factor ADD
CONSTRAINT PK_factor PRIMARY KEY CONSTRAINT PK_rs_factor PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- DROP TABLE factor_hdr; -- DROP TABLE rs_factor_hdr;
CREATE TABLE factor_hdr ( CREATE TABLE rs_factor_hdr (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -20,16 +20,16 @@ CREATE TABLE factor_hdr ( ...@@ -20,16 +20,16 @@ CREATE TABLE factor_hdr (
ALTER TABLE factor_hdr ADD ALTER TABLE rs_factor_hdr ADD
CONSTRAINT PK_factor_hdr PRIMARY KEY CONSTRAINT PK_rs_factor_hdr PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_factor_hdr_level_number CREATE INDEX idx_rs_factor_hdr_level_number
ON factor_hdr (level_number); ON rs_factor_hdr (level_number);
CREATE INDEX idx_factor_hdr_factor_number CREATE INDEX idx_rs_factor_hdr_factor_number
ON factor_hdr (factor_number); ON rs_factor_hdr (factor_number);
-- DROP TABLE factor_lin; -- DROP TABLE rs_factor_lin;
CREATE TABLE factor_lin ( CREATE TABLE rs_factor_lin (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -15,16 +15,16 @@ CREATE TABLE factor_lin ( ...@@ -15,16 +15,16 @@ CREATE TABLE factor_lin (
ALTER TABLE factor_lin ADD ALTER TABLE rs_factor_lin ADD
CONSTRAINT PK_factor_lin PRIMARY KEY CONSTRAINT PK_rs_factor_lin PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_factor_lin_factor_number CREATE INDEX idx_rs_factor_lin_factor_number
ON factor_lin (factor_number); ON rs_factor_lin (factor_number);
CREATE INDEX idx_factor_lin_quest_number CREATE INDEX idx_rs_factor_lin_quest_number
ON factor_lin (quest_number); ON rs_factor_lin (quest_number);
-- DROP TABLE score; -- DROP TABLE rs_score;
CREATE TABLE score ( CREATE TABLE rs_score (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, ,
score_number numeric(12) NULL, score_number numeric(12) NULL,
test_analysis_id numeric(12) NULL, test_analysis_id numeric(12) NULL,
factor_number numeric(12) NULL factor_number numeric(12) NULL,
level_number numeric(12) NULL,
narrative_id numeric(12) NULL
); );
ALTER TABLE score ADD ALTER TABLE rs_score ADD
CONSTRAINT PK_score PRIMARY KEY CONSTRAINT PK_rs_score PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_score_test_analysis_id CREATE INDEX idx_rs_score_test_analysis_id
ON score (test_analysis_id); ON rs_score (test_analysis_id);
CREATE INDEX idx_rs_score_narrative_id
ON rs_score (narrative_id);
-- DROP TABLE level_factor; -- DROP TABLE rs_level_factor;
CREATE TABLE level_factor ( CREATE TABLE rs_level_factor (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -18,19 +18,19 @@ CREATE TABLE level_factor ( ...@@ -18,19 +18,19 @@ CREATE TABLE level_factor (
ALTER TABLE level_factor ADD ALTER TABLE rs_level_factor ADD
CONSTRAINT PK_level_factor PRIMARY KEY CONSTRAINT PK_rs_level_factor PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_level_factor_factor_number CREATE INDEX idx_rs_level_factor_factor_number
ON level_factor (factor_number); ON rs_level_factor (factor_number);
CREATE INDEX idx_level_factor_level_number CREATE INDEX idx_rs_level_factor_level_number
ON level_factor (level_number); ON rs_level_factor (level_number);
CREATE INDEX idx_level_factor_narrative_id CREATE INDEX idx_rs_level_factor_narrative_id
ON level_factor (narrative_id); ON rs_level_factor (narrative_id);
-- DROP TABLE level; -- DROP TABLE rs_level;
CREATE TABLE level ( CREATE TABLE rs_level (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -15,8 +15,8 @@ CREATE TABLE level ( ...@@ -15,8 +15,8 @@ CREATE TABLE level (
ALTER TABLE level ADD ALTER TABLE rs_level ADD
CONSTRAINT PK_level PRIMARY KEY CONSTRAINT PK_rs_level PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- DROP TABLE narrative; -- DROP TABLE rs_narrative;
CREATE TABLE narrative ( CREATE TABLE rs_narrative (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -21,11 +21,13 @@ CREATE TABLE narrative ( ...@@ -21,11 +21,13 @@ CREATE TABLE narrative (
ALTER TABLE narrative ADD ALTER TABLE rs_narrative ADD
CONSTRAINT PK_narrative PRIMARY KEY CONSTRAINT PK_rs_narrative PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_narrative_level_number
ON rs_narrative (level_number);
-- DROP TABLE quest_lin; -- DROP TABLE rs_quest_lin;
CREATE TABLE quest_lin ( CREATE TABLE rs_quest_lin (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -14,13 +14,13 @@ CREATE TABLE quest_lin ( ...@@ -14,13 +14,13 @@ CREATE TABLE quest_lin (
ALTER TABLE quest_lin ADD ALTER TABLE rs_quest_lin ADD
CONSTRAINT PK_quest_lin PRIMARY KEY CONSTRAINT PK_rs_quest_lin PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_quest_lin_section_number CREATE INDEX idx_rs_quest_lin_section_number
ON quest_lin (section_number); ON rs_quest_lin (section_number);
-- DROP TABLE quest_hdr; -- DROP TABLE rs_quest_hdr;
CREATE TABLE quest_hdr ( CREATE TABLE rs_quest_hdr (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -14,8 +14,8 @@ CREATE TABLE quest_hdr ( ...@@ -14,8 +14,8 @@ CREATE TABLE quest_hdr (
ALTER TABLE quest_hdr ADD ALTER TABLE rs_quest_hdr ADD
CONSTRAINT PK_quest_hdr PRIMARY KEY CONSTRAINT PK_rs_quest_hdr PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- DROP TABLE test_analysis; -- DROP TABLE rs_test_analysis;
CREATE TABLE test_analysis ( CREATE TABLE rs_test_analysis (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
...@@ -14,11 +14,16 @@ CREATE TABLE test_analysis ( ...@@ -14,11 +14,16 @@ CREATE TABLE test_analysis (
ALTER TABLE test_analysis ADD ALTER TABLE rs_test_analysis ADD
CONSTRAINT PK_test_analysis PRIMARY KEY CONSTRAINT PK_rs_test_analysis PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_test_analysis_level_id
ON rs_test_analysis (level_id);
CREATE INDEX idx_rs_test_analysis_candidate_id
ON rs_test_analysis (candidate_id);
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
xxxx image NOT NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE answer; -- DROP TABLE rs_answer;
CREATE TABLE answer ( CREATE TABLE rs_answer (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, ,
answer_number number(12) NULL, answer_number number(12) NULL,
section_number number(12) NULL,
candidate_id number(12) NULL, candidate_id number(12) NULL,
quest_number number(12) NULL quest_number number(12) NULL
); );
ALTER TABLE answer ADD ALTER TABLE rs_answer ADD
CONSTRAINT PK_answer PRIMARY KEY CONSTRAINT PK_rs_answer PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_answer_candidate_id
ON rs_answer (candidate_id);
-- DROP TABLE candidate; -- DROP TABLE rs_candidate;
CREATE TABLE candidate ( CREATE TABLE rs_candidate (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, ,
first_name varchar2(30) NULL, first_name varchar2(30) NULL,
middle_name varchar2(30) NULL,
last_name varchar2(30) NULL,
preferred_name varchar2(30) NULL,
salutation varchar2(10) NULL,
position varchar2(30) NULL,
date_of_birth date NULL,
date_registered date NULL,
gender varchar2(10) NULL,
password varchar2(15) NULL,
date_taken date NULL,
location varchar2(80) NULL,
contact_phone varchar2(80) NULL,
email varchar2(60) NULL,
test_input_id number(12) NULL test_input_id number(12) NULL
); );
ALTER TABLE candidate ADD ALTER TABLE rs_candidate ADD
CONSTRAINT PK_candidate PRIMARY KEY CONSTRAINT PK_rs_candidate PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_candidate_test_input_id CREATE INDEX idx_rs_candidate_test_input_id
ON candidate (test_input_id); ON rs_candidate (test_input_id);
-- DROP TABLE factor; -- DROP TABLE rs_factor;
CREATE TABLE factor ( CREATE TABLE rs_factor (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -14,8 +14,8 @@ CREATE TABLE factor ( ...@@ -14,8 +14,8 @@ CREATE TABLE factor (
ALTER TABLE factor ADD ALTER TABLE rs_factor ADD
CONSTRAINT PK_factor PRIMARY KEY CONSTRAINT PK_rs_factor PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- DROP TABLE factor_hdr; -- DROP TABLE rs_factor_hdr;
CREATE TABLE factor_hdr ( CREATE TABLE rs_factor_hdr (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -21,16 +21,16 @@ CREATE TABLE factor_hdr ( ...@@ -21,16 +21,16 @@ CREATE TABLE factor_hdr (
ALTER TABLE factor_hdr ADD ALTER TABLE rs_factor_hdr ADD
CONSTRAINT PK_factor_hdr PRIMARY KEY CONSTRAINT PK_rs_factor_hdr PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_factor_hdr_level_number CREATE INDEX idx_rs_factor_hdr_level_number
ON factor_hdr (level_number); ON rs_factor_hdr (level_number);
CREATE INDEX idx_factor_hdr_factor_number CREATE INDEX idx_rs_factor_hdr_factor_number
ON factor_hdr (factor_number); ON rs_factor_hdr (factor_number);
-- DROP TABLE factor_lin; -- DROP TABLE rs_factor_lin;
CREATE TABLE factor_lin ( CREATE TABLE rs_factor_lin (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -16,16 +16,16 @@ CREATE TABLE factor_lin ( ...@@ -16,16 +16,16 @@ CREATE TABLE factor_lin (
ALTER TABLE factor_lin ADD ALTER TABLE rs_factor_lin ADD
CONSTRAINT PK_factor_lin PRIMARY KEY CONSTRAINT PK_rs_factor_lin PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_factor_lin_factor_number CREATE INDEX idx_rs_factor_lin_factor_number
ON factor_lin (factor_number); ON rs_factor_lin (factor_number);
CREATE INDEX idx_factor_lin_quest_number CREATE INDEX idx_rs_factor_lin_quest_number
ON factor_lin (quest_number); ON rs_factor_lin (quest_number);
-- DROP TABLE score; -- DROP TABLE rs_score;
CREATE TABLE score ( CREATE TABLE rs_score (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, ,
score_number number(12) NULL, score_number number(12) NULL,
test_analysis_id number(12) NULL, test_analysis_id number(12) NULL,
factor_number number(12) NULL factor_number number(12) NULL,
level_number number(12) NULL,
narrative_id number(12) NULL
); );
ALTER TABLE score ADD ALTER TABLE rs_score ADD
CONSTRAINT PK_score PRIMARY KEY CONSTRAINT PK_rs_score PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_score_test_analysis_id CREATE INDEX idx_rs_score_test_analysis_id
ON score (test_analysis_id); ON rs_score (test_analysis_id);
CREATE INDEX idx_rs_score_narrative_id
ON rs_score (narrative_id);
-- DROP TABLE level_factor; -- DROP TABLE rs_level_factor;
CREATE TABLE level_factor ( CREATE TABLE rs_level_factor (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -19,19 +19,19 @@ CREATE TABLE level_factor ( ...@@ -19,19 +19,19 @@ CREATE TABLE level_factor (
ALTER TABLE level_factor ADD ALTER TABLE rs_level_factor ADD
CONSTRAINT PK_level_factor PRIMARY KEY CONSTRAINT PK_rs_level_factor PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_level_factor_factor_number CREATE INDEX idx_rs_level_factor_factor_number
ON level_factor (factor_number); ON rs_level_factor (factor_number);
CREATE INDEX idx_level_factor_level_number CREATE INDEX idx_rs_level_factor_level_number
ON level_factor (level_number); ON rs_level_factor (level_number);
CREATE INDEX idx_level_factor_narrative_id CREATE INDEX idx_rs_level_factor_narrative_id
ON level_factor (narrative_id); ON rs_level_factor (narrative_id);
-- DROP TABLE level; -- DROP TABLE rs_level;
CREATE TABLE level ( CREATE TABLE rs_level (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -16,8 +16,8 @@ CREATE TABLE level ( ...@@ -16,8 +16,8 @@ CREATE TABLE level (
ALTER TABLE level ADD ALTER TABLE rs_level ADD
CONSTRAINT PK_level PRIMARY KEY CONSTRAINT PK_rs_level PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- DROP TABLE narrative; -- DROP TABLE rs_narrative;
CREATE TABLE narrative ( CREATE TABLE rs_narrative (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -22,11 +22,13 @@ CREATE TABLE narrative ( ...@@ -22,11 +22,13 @@ CREATE TABLE narrative (
ALTER TABLE narrative ADD ALTER TABLE rs_narrative ADD
CONSTRAINT PK_narrative PRIMARY KEY CONSTRAINT PK_rs_narrative PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_narrative_level_number
ON rs_narrative (level_number);
-- DROP TABLE quest_lin; -- DROP TABLE rs_quest_lin;
CREATE TABLE quest_lin ( CREATE TABLE rs_quest_lin (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -15,13 +15,13 @@ CREATE TABLE quest_lin ( ...@@ -15,13 +15,13 @@ CREATE TABLE quest_lin (
ALTER TABLE quest_lin ADD ALTER TABLE rs_quest_lin ADD
CONSTRAINT PK_quest_lin PRIMARY KEY CONSTRAINT PK_rs_quest_lin PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_quest_lin_section_number CREATE INDEX idx_rs_quest_lin_section_number
ON quest_lin (section_number); ON rs_quest_lin (section_number);
-- DROP TABLE quest_hdr; -- DROP TABLE rs_quest_hdr;
CREATE TABLE quest_hdr ( CREATE TABLE rs_quest_hdr (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -15,8 +15,8 @@ CREATE TABLE quest_hdr ( ...@@ -15,8 +15,8 @@ CREATE TABLE quest_hdr (
ALTER TABLE quest_hdr ADD ALTER TABLE rs_quest_hdr ADD
CONSTRAINT PK_quest_hdr PRIMARY KEY CONSTRAINT PK_rs_quest_hdr PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- DROP TABLE test_analysis; -- DROP TABLE rs_test_analysis;
CREATE TABLE test_analysis ( CREATE TABLE rs_test_analysis (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
...@@ -15,11 +15,16 @@ CREATE TABLE test_analysis ( ...@@ -15,11 +15,16 @@ CREATE TABLE test_analysis (
ALTER TABLE test_analysis ADD ALTER TABLE rs_test_analysis ADD
CONSTRAINT PK_test_analysis PRIMARY KEY CONSTRAINT PK_rs_test_analysis PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_test_analysis_level_id
ON rs_test_analysis (level_id);
CREATE INDEX idx_rs_test_analysis_candidate_id
ON rs_test_analysis (candidate_id);
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
xxxx blob NOT NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun -- @AutoRun
-- drop table answer; -- drop table rs_answer;
CREATE TABLE answer ( CREATE TABLE rs_answer (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, ,
answer_number numeric(12) NULL, answer_number numeric(12) NULL,
section_number numeric(12) NULL,
candidate_id numeric(12) NULL, candidate_id numeric(12) NULL,
quest_number numeric(12) NULL quest_number numeric(12) NULL
); );
ALTER TABLE answer ADD ALTER TABLE rs_answer ADD
CONSTRAINT pk_answer PRIMARY KEY CONSTRAINT pk_rs_answer PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_answer_candidate_id
ON rs_answer (candidate_id);
-- @AutoRun -- @AutoRun
-- drop table candidate; -- drop table rs_candidate;
CREATE TABLE candidate ( CREATE TABLE rs_candidate (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, ,
first_name varchar(30) NULL, first_name varchar(30) NULL,
middle_name varchar(30) NULL,
last_name varchar(30) NULL,
preferred_name varchar(30) NULL,
salutation varchar(10) NULL,
position varchar(30) NULL,
date_of_birth timestamp NULL,
date_registered timestamp NULL,
gender varchar(10) NULL,
password varchar(15) NULL,
date_taken timestamp NULL,
location varchar(80) NULL,
contact_phone varchar(80) NULL,
email varchar(60) NULL,
test_input_id numeric(12) NULL test_input_id numeric(12) NULL
); );
ALTER TABLE candidate ADD ALTER TABLE rs_candidate ADD
CONSTRAINT pk_candidate PRIMARY KEY CONSTRAINT pk_rs_candidate PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_candidate_test_input_id CREATE INDEX idx_rs_candidate_test_input_id
ON candidate (test_input_id); ON rs_candidate (test_input_id);
-- @AutoRun -- @AutoRun
-- drop table factor; -- drop table rs_factor;
CREATE TABLE factor ( CREATE TABLE rs_factor (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -14,8 +14,8 @@ CREATE TABLE factor ( ...@@ -14,8 +14,8 @@ CREATE TABLE factor (
ALTER TABLE factor ADD ALTER TABLE rs_factor ADD
CONSTRAINT pk_factor PRIMARY KEY CONSTRAINT pk_rs_factor PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- @AutoRun -- @AutoRun
-- drop table factor_hdr; -- drop table rs_factor_hdr;
CREATE TABLE factor_hdr ( CREATE TABLE rs_factor_hdr (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -21,16 +21,16 @@ CREATE TABLE factor_hdr ( ...@@ -21,16 +21,16 @@ CREATE TABLE factor_hdr (
ALTER TABLE factor_hdr ADD ALTER TABLE rs_factor_hdr ADD
CONSTRAINT pk_factor_hdr PRIMARY KEY CONSTRAINT pk_rs_factor_hdr PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_factor_hdr_level_number CREATE INDEX idx_rs_factor_hdr_level_number
ON factor_hdr (level_number); ON rs_factor_hdr (level_number);
CREATE INDEX idx_factor_hdr_factor_number CREATE INDEX idx_rs_factor_hdr_factor_number
ON factor_hdr (factor_number); ON rs_factor_hdr (factor_number);
-- @AutoRun -- @AutoRun
-- drop table factor_lin; -- drop table rs_factor_lin;
CREATE TABLE factor_lin ( CREATE TABLE rs_factor_lin (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -16,16 +16,16 @@ CREATE TABLE factor_lin ( ...@@ -16,16 +16,16 @@ CREATE TABLE factor_lin (
ALTER TABLE factor_lin ADD ALTER TABLE rs_factor_lin ADD
CONSTRAINT pk_factor_lin PRIMARY KEY CONSTRAINT pk_rs_factor_lin PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_factor_lin_factor_number CREATE INDEX idx_rs_factor_lin_factor_number
ON factor_lin (factor_number); ON rs_factor_lin (factor_number);
CREATE INDEX idx_factor_lin_quest_number CREATE INDEX idx_rs_factor_lin_quest_number
ON factor_lin (quest_number); ON rs_factor_lin (quest_number);
-- @AutoRun -- @AutoRun
-- drop table score; -- drop table rs_score;
CREATE TABLE score ( CREATE TABLE rs_score (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, ,
score_number numeric(12) NULL, score_number numeric(12) NULL,
test_analysis_id numeric(12) NULL, test_analysis_id numeric(12) NULL,
factor_number numeric(12) NULL factor_number numeric(12) NULL,
level_number numeric(12) NULL,
narrative_id numeric(12) NULL
); );
ALTER TABLE score ADD ALTER TABLE rs_score ADD
CONSTRAINT pk_score PRIMARY KEY CONSTRAINT pk_rs_score PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_score_test_analysis_id CREATE INDEX idx_rs_score_test_analysis_id
ON score (test_analysis_id); ON rs_score (test_analysis_id);
CREATE INDEX idx_rs_score_narrative_id
ON rs_score (narrative_id);
-- @AutoRun -- @AutoRun
-- drop table level_factor; -- drop table rs_level_factor;
CREATE TABLE level_factor ( CREATE TABLE rs_level_factor (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -19,19 +19,19 @@ CREATE TABLE level_factor ( ...@@ -19,19 +19,19 @@ CREATE TABLE level_factor (
ALTER TABLE level_factor ADD ALTER TABLE rs_level_factor ADD
CONSTRAINT pk_level_factor PRIMARY KEY CONSTRAINT pk_rs_level_factor PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_level_factor_factor_number CREATE INDEX idx_rs_level_factor_factor_number
ON level_factor (factor_number); ON rs_level_factor (factor_number);
CREATE INDEX idx_level_factor_level_number CREATE INDEX idx_rs_level_factor_level_number
ON level_factor (level_number); ON rs_level_factor (level_number);
CREATE INDEX idx_level_factor_narrative_id CREATE INDEX idx_rs_level_factor_narrative_id
ON level_factor (narrative_id); ON rs_level_factor (narrative_id);
-- @AutoRun -- @AutoRun
-- drop table level; -- drop table rs_level;
CREATE TABLE level ( CREATE TABLE rs_level (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -16,8 +16,8 @@ CREATE TABLE level ( ...@@ -16,8 +16,8 @@ CREATE TABLE level (
ALTER TABLE level ADD ALTER TABLE rs_level ADD
CONSTRAINT pk_level PRIMARY KEY CONSTRAINT pk_rs_level PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- @AutoRun -- @AutoRun
-- drop table narrative; -- drop table rs_narrative;
CREATE TABLE narrative ( CREATE TABLE rs_narrative (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -22,11 +22,13 @@ CREATE TABLE narrative ( ...@@ -22,11 +22,13 @@ CREATE TABLE narrative (
ALTER TABLE narrative ADD ALTER TABLE rs_narrative ADD
CONSTRAINT pk_narrative PRIMARY KEY CONSTRAINT pk_rs_narrative PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_narrative_level_number
ON rs_narrative (level_number);
-- @AutoRun -- @AutoRun
-- drop table quest_lin; -- drop table rs_quest_lin;
CREATE TABLE quest_lin ( CREATE TABLE rs_quest_lin (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -15,13 +15,13 @@ CREATE TABLE quest_lin ( ...@@ -15,13 +15,13 @@ CREATE TABLE quest_lin (
ALTER TABLE quest_lin ADD ALTER TABLE rs_quest_lin ADD
CONSTRAINT pk_quest_lin PRIMARY KEY CONSTRAINT pk_rs_quest_lin PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_quest_lin_section_number CREATE INDEX idx_rs_quest_lin_section_number
ON quest_lin (section_number); ON rs_quest_lin (section_number);
-- @AutoRun -- @AutoRun
-- drop table quest_hdr; -- drop table rs_quest_hdr;
CREATE TABLE quest_hdr ( CREATE TABLE rs_quest_hdr (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -15,8 +15,8 @@ CREATE TABLE quest_hdr ( ...@@ -15,8 +15,8 @@ CREATE TABLE quest_hdr (
ALTER TABLE quest_hdr ADD ALTER TABLE rs_quest_hdr ADD
CONSTRAINT pk_quest_hdr PRIMARY KEY CONSTRAINT pk_rs_quest_hdr PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
-- @AutoRun -- @AutoRun
-- drop table test_analysis; -- drop table rs_test_analysis;
CREATE TABLE test_analysis ( CREATE TABLE rs_test_analysis (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
...@@ -15,11 +15,16 @@ CREATE TABLE test_analysis ( ...@@ -15,11 +15,16 @@ CREATE TABLE test_analysis (
ALTER TABLE test_analysis ADD ALTER TABLE rs_test_analysis ADD
CONSTRAINT pk_test_analysis PRIMARY KEY CONSTRAINT pk_rs_test_analysis PRIMARY KEY
( (
object_id object_id
) ; ) ;
CREATE INDEX idx_rs_test_analysis_level_id
ON rs_test_analysis (level_id);
CREATE INDEX idx_rs_test_analysis_candidate_id
ON rs_test_analysis (candidate_id);
-- @AutoRun
-- drop table it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
xxxx bytea NOT NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
...@@ -10,4 +10,10 @@ public class Answer extends BaseAnswer ...@@ -10,4 +10,10 @@ 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
public String getObjectIDSpace()
{
return "Answer";
}
} }
\ No newline at end of file
...@@ -4,17 +4,17 @@ ...@@ -4,17 +4,17 @@
<BUSINESSCLASS name="Answer" package="performa.orm"> <BUSINESSCLASS name="Answer" package="performa.orm">
<TABLE name="answer" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_answer" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="AnswerNo" type="Integer" dbcol="answer_number"/> <ATTRIB name="AnswerNo" type="Integer" dbcol="answer_number"/>
<!--<SINGLEREFERENCE name="Section" type="Section" dbcol="section_number" />--> <SINGLEREFERENCE name="Section" type="Section" dbcol="section_number" />
<SINGLEREFERENCE name="Candidate" type="Candidate" dbcol="candidate_id" /> <SINGLEREFERENCE name="Candidate" type="Candidate" dbcol="candidate_id" backreferenceName="Answers"/>
<SINGLEREFERENCE name="Question" type="Question" dbcol="quest_number" /> <SINGLEREFERENCE name="Question" type="Question" dbcol="quest_number" />
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="answer.object_id is not null" orderBy="answer.object_id" /> <SEARCH type="All" paramFilter="rs_answer.object_id is not null" orderBy="rs_answer.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -41,7 +41,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -41,7 +41,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}answer.object_id as id, {PREFIX}answer.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}answer.object_CREATED_DATE as CREATED_DATE, {PREFIX}answer.answer_number, {PREFIX}answer.candidate_id, {PREFIX}answer.quest_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_answer.object_id as id, {PREFIX}rs_answer.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_answer.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_answer.answer_number, {PREFIX}rs_answer.section_number, {PREFIX}rs_answer.candidate_id, {PREFIX}rs_answer.quest_number, 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
...@@ -86,15 +86,16 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -86,15 +86,16 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet answerPSet = allPSets.getPersistentSet(id, "answer", PersistentSetStatus.FETCHED); PersistentSet rs_answerPSet = allPSets.getPersistentSet(id, "rs_answer", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !answerPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_answerPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!answerPSet.containsAttrib(Answer.FIELD_AnswerNo)|| !rs_answerPSet.containsAttrib(Answer.FIELD_AnswerNo)||
!answerPSet.containsAttrib(Answer.SINGLEREFERENCE_Candidate)|| !rs_answerPSet.containsAttrib(Answer.SINGLEREFERENCE_Section)||
!answerPSet.containsAttrib(Answer.SINGLEREFERENCE_Question)) !rs_answerPSet.containsAttrib(Answer.SINGLEREFERENCE_Candidate)||
!rs_answerPSet.containsAttrib(Answer.SINGLEREFERENCE_Question))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -117,8 +118,8 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -117,8 +118,8 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}answer " + "FROM {PREFIX}rs_answer " +
"WHERE " + SELECT_JOINS + "{PREFIX}answer.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_answer.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -140,6 +141,16 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -140,6 +141,16 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException (); throw new RuntimeException ();
} }
else if (refName.equals (Answer.SINGLEREFERENCE_Candidate))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_answer " +
"WHERE " + SELECT_JOINS + "candidate_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);
...@@ -155,47 +166,47 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -155,47 +166,47 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet answerPSet = allPSets.getPersistentSet(objectID, "answer"); PersistentSet rs_answerPSet = allPSets.getPersistentSet(objectID, "rs_answer");
if (answerPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_answerPSet.getStatus () != PersistentSetStatus.PROCESSED &&
answerPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_answerPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}answer " + "UPDATE {PREFIX}rs_answer " +
"SET answer_number = ?, candidate_id = ? , quest_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET answer_number = ?, section_number = ? , candidate_id = ? , quest_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE answer.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_answer.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_AnswerNo.getForSQL(dummyAnswerNo, answerPSet.getAttrib (Answer.FIELD_AnswerNo))).listEntry (SQLManager.CheckNull((Long)(answerPSet.getAttrib (Answer.SINGLEREFERENCE_Candidate)))).listEntry (SQLManager.CheckNull((Long)(answerPSet.getAttrib (Answer.SINGLEREFERENCE_Question)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_AnswerNo.getForSQL(dummyAnswerNo, rs_answerPSet.getAttrib (Answer.FIELD_AnswerNo))).listEntry (SQLManager.CheckNull((Long)(rs_answerPSet.getAttrib (Answer.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(rs_answerPSet.getAttrib (Answer.SINGLEREFERENCE_Candidate)))).listEntry (SQLManager.CheckNull((Long)(rs_answerPSet.getAttrib (Answer.SINGLEREFERENCE_Question)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}answer WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_answer WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "answer", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_answer", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (AnswerPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (AnswerPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "answer"); throw new ConcurrentUpdateConflictException (obj, "rs_answer");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:answer for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_answer for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (AnswerPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (AnswerPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
answerPSet.setStatus (PersistentSetStatus.PROCESSED); rs_answerPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -210,42 +221,42 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -210,42 +221,42 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet answerPSet = allPSets.getPersistentSet(objectID, "answer"); PersistentSet rs_answerPSet = allPSets.getPersistentSet(objectID, "rs_answer");
LogMgr.log (AnswerPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (AnswerPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (answerPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_answerPSet.getStatus () != PersistentSetStatus.PROCESSED &&
answerPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_answerPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}answer " + "FROM {PREFIX}rs_answer " +
"WHERE answer.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_answer.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}answer WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_answer WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "answer"); throw new ConcurrentUpdateConflictException (obj, "rs_answer");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:answer for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_answer for row:" + objectID;
LogMgr.log (AnswerPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (AnswerPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
answerPSet.setStatus (PersistentSetStatus.PROCESSED); rs_answerPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -300,7 +311,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -300,7 +311,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet answerPSet = allPSets.getPersistentSet(objectID, "answer", PersistentSetStatus.FETCHED); PersistentSet rs_answerPSet = allPSets.getPersistentSet(objectID, "rs_answer", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -359,7 +370,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -359,7 +370,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}answer " + tables + "FROM {PREFIX}rs_answer " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -375,12 +386,12 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -375,12 +386,12 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY answer.object_id"; String orderBy = " ORDER BY rs_answer.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: answer.object_id is not null Object[] searchParams; // paramFilter: rs_answer.object_id is not null
String preFilter = "(answer.object_id is not null)" String preFilter = "(rs_answer.object_id is not null)"
+ " "; + " ";
...@@ -395,7 +406,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -395,7 +406,7 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}answer " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_answer " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -415,18 +426,19 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -415,18 +426,19 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet answerPSet = allPSets.getPersistentSet(objectID, "answer", PersistentSetStatus.FETCHED); PersistentSet rs_answerPSet = allPSets.getPersistentSet(objectID, "rs_answer", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
answerPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_answerPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
answerPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_answerPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
answerPSet.setAttrib(Answer.FIELD_AnswerNo, HELPER_AnswerNo.getFromRS(dummyAnswerNo, r, "answer_number")); rs_answerPSet.setAttrib(Answer.FIELD_AnswerNo, HELPER_AnswerNo.getFromRS(dummyAnswerNo, r, "answer_number"));
answerPSet.setAttrib(Answer.SINGLEREFERENCE_Candidate, r.getObject ("candidate_id")); rs_answerPSet.setAttrib(Answer.SINGLEREFERENCE_Section, r.getObject ("section_number"));
answerPSet.setAttrib(Answer.SINGLEREFERENCE_Question, r.getObject ("quest_number")); rs_answerPSet.setAttrib(Answer.SINGLEREFERENCE_Candidate, r.getObject ("candidate_id"));
rs_answerPSet.setAttrib(Answer.SINGLEREFERENCE_Question, r.getObject ("quest_number"));
} }
...@@ -434,21 +446,21 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -434,21 +446,21 @@ public class AnswerPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet answerPSet = allPSets.getPersistentSet(objectID, "answer"); PersistentSet rs_answerPSet = allPSets.getPersistentSet(objectID, "rs_answer");
if (answerPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_answerPSet.getStatus () != PersistentSetStatus.PROCESSED &&
answerPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_answerPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}answer " + "INSERT INTO {PREFIX}rs_answer " +
" (answer_number, candidate_id, quest_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (answer_number, section_number, candidate_id, quest_number, 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_AnswerNo.getForSQL(dummyAnswerNo, answerPSet.getAttrib (Answer.FIELD_AnswerNo))) .listEntry (SQLManager.CheckNull((Long)(answerPSet.getAttrib (Answer.SINGLEREFERENCE_Candidate)))).listEntry (SQLManager.CheckNull((Long)(answerPSet.getAttrib (Answer.SINGLEREFERENCE_Question)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_AnswerNo.getForSQL(dummyAnswerNo, rs_answerPSet.getAttrib (Answer.FIELD_AnswerNo))) .listEntry (SQLManager.CheckNull((Long)(rs_answerPSet.getAttrib (Answer.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(rs_answerPSet.getAttrib (Answer.SINGLEREFERENCE_Candidate)))).listEntry (SQLManager.CheckNull((Long)(rs_answerPSet.getAttrib (Answer.SINGLEREFERENCE_Question)))) .listEntry (objectID.longID ()).toList().toArray());
answerPSet.setStatus (PersistentSetStatus.PROCESSED); rs_answerPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -39,7 +39,9 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -39,7 +39,9 @@ public abstract class BaseAnswer extends BaseBusinessClass
// Static constants corresponding to field names // Static constants corresponding to field names
public static final String FIELD_AnswerNo = "AnswerNo"; public static final String FIELD_AnswerNo = "AnswerNo";
public static final String SINGLEREFERENCE_Section = "Section";
public static final String SINGLEREFERENCE_Candidate = "Candidate"; public static final String SINGLEREFERENCE_Candidate = "Candidate";
public static final String BACKREF_Candidate = "";
public static final String SINGLEREFERENCE_Question = "Question"; public static final String SINGLEREFERENCE_Question = "Question";
// Static constants corresponding to searches // Static constants corresponding to searches
...@@ -55,6 +57,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -55,6 +57,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
// Private attributes corresponding to single references // Private attributes corresponding to single references
private SingleAssociation<Answer, Section> _Section;
private SingleAssociation<Answer, Candidate> _Candidate; private SingleAssociation<Answer, Candidate> _Candidate;
private SingleAssociation<Answer, Question> _Question; private SingleAssociation<Answer, Question> _Question;
...@@ -77,9 +80,11 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -77,9 +80,11 @@ public abstract class BaseAnswer extends BaseBusinessClass
try try
{ {
String tmp_Candidate = Candidate.BACKREF_Answers;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Section();
setupAssocMetaData_Candidate(); setupAssocMetaData_Candidate();
setupAssocMetaData_Question(); setupAssocMetaData_Question();
FIELD_AnswerNo_Validators = (AttributeValidator[])setupAttribMetaData_AnswerNo(validatorMapping).toArray (new AttributeValidator[0]); FIELD_AnswerNo_Validators = (AttributeValidator[])setupAttribMetaData_AnswerNo(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -98,10 +103,25 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -98,10 +103,25 @@ public abstract class BaseAnswer extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Section()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "section_number");
metaInfo.put ("name", "Section");
metaInfo.put ("type", "Section");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Answer.Section:", metaInfo);
ATTRIBUTES_METADATA_Answer.put (SINGLEREFERENCE_Section, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Candidate() private static void setupAssocMetaData_Candidate()
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Answers");
metaInfo.put ("dbcol", "candidate_id"); metaInfo.put ("dbcol", "candidate_id");
metaInfo.put ("name", "Candidate"); metaInfo.put ("name", "Candidate");
metaInfo.put ("type", "Candidate"); metaInfo.put ("type", "Candidate");
...@@ -179,8 +199,9 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -179,8 +199,9 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Candidate = new SingleAssociation<Answer, Candidate> (this, SINGLEREFERENCE_Candidate, null, Candidate.REFERENCE_Candidate, "answer"); _Section = new SingleAssociation<Answer, Section> (this, SINGLEREFERENCE_Section, null, Section.REFERENCE_Section, "rs_answer");
_Question = new SingleAssociation<Answer, Question> (this, SINGLEREFERENCE_Question, null, Question.REFERENCE_Question, "answer"); _Candidate = new SingleAssociation<Answer, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_Answers, Candidate.REFERENCE_Candidate, "rs_answer");
_Question = new SingleAssociation<Answer, Question> (this, SINGLEREFERENCE_Question, null, Question.REFERENCE_Question, "rs_answer");
} }
...@@ -190,8 +211,9 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -190,8 +211,9 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Candidate = new SingleAssociation<Answer, Candidate> (this, SINGLEREFERENCE_Candidate, null, Candidate.REFERENCE_Candidate, "answer"); _Section = new SingleAssociation<Answer, Section> (this, SINGLEREFERENCE_Section, null, Section.REFERENCE_Section, "rs_answer");
_Question = new SingleAssociation<Answer, Question> (this, SINGLEREFERENCE_Question, null, Question.REFERENCE_Question, "answer"); _Candidate = new SingleAssociation<Answer, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_Answers, Candidate.REFERENCE_Candidate, "rs_answer");
_Question = new SingleAssociation<Answer, Question> (this, SINGLEREFERENCE_Question, null, Question.REFERENCE_Question, "rs_answer");
return this; return this;
...@@ -307,6 +329,8 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -307,6 +329,8 @@ public abstract class BaseAnswer extends BaseBusinessClass
List result = super.getSingleAssocs (); List result = super.getSingleAssocs ();
result.add("Section");
result.add("Candidate"); result.add("Candidate");
result.add("Question"); result.add("Question");
...@@ -322,7 +346,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -322,7 +346,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Candidate)) else if (assocName.equals (SINGLEREFERENCE_Section))
{
return _Section.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{ {
return _Candidate.getReferencedType (); return _Candidate.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Question)) }else if (assocName.equals (SINGLEREFERENCE_Question))
...@@ -342,9 +369,12 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -342,9 +369,12 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Candidate)) else if (assocName.equals (SINGLEREFERENCE_Section))
{ {
return null ; return null ;
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{
return Candidate.MULTIPLEREFERENCE_Answers ;
}else if (assocName.equals (SINGLEREFERENCE_Question)) }else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
return null ; return null ;
...@@ -362,7 +392,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -362,7 +392,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Candidate)) else if (assocName.equals (SINGLEREFERENCE_Section))
{
return getSection ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{ {
return getCandidate (); return getCandidate ();
}else if (assocName.equals (SINGLEREFERENCE_Question)) }else if (assocName.equals (SINGLEREFERENCE_Question))
...@@ -382,7 +415,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -382,7 +415,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Candidate)) else if (assocName.equals (SINGLEREFERENCE_Section))
{
return getSection (getType);
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{ {
return getCandidate (getType); return getCandidate (getType);
}else if (assocName.equals (SINGLEREFERENCE_Question)) }else if (assocName.equals (SINGLEREFERENCE_Question))
...@@ -402,7 +438,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -402,7 +438,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Candidate)) else if (assocName.equals (SINGLEREFERENCE_Section))
{
return getSectionID ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{ {
return getCandidateID (); return getCandidateID ();
}else if (assocName.equals (SINGLEREFERENCE_Question)) }else if (assocName.equals (SINGLEREFERENCE_Question))
...@@ -422,7 +461,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -422,7 +461,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Candidate)) else if (assocName.equals (SINGLEREFERENCE_Section))
{
setSection ((Section)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Candidate))
{ {
setCandidate ((Candidate)(newValue)); setCandidate ((Candidate)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Question)) }else if (assocName.equals (SINGLEREFERENCE_Question))
...@@ -438,6 +480,100 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -438,6 +480,100 @@ public abstract class BaseAnswer extends BaseBusinessClass
/** /**
* Get the reference Section
*/
public Section getSection () throws StorageException
{
assertValid();
try
{
return (Section)(_Section.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Answer:", this.getObjectID (), ", was trying to get Section:", getSectionID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Section.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Section getSection (Get getType) throws StorageException
{
assertValid();
return _Section.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getSectionID ()
{
assertValid();
if (_Section == null)
{
return null;
}
else
{
return _Section.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 preSectionChange (Section newSection) 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 postSectionChange () throws FieldException
{
}
public FieldWriteability getWriteability_Section ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Section. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setSection (Section newSection) throws StorageException, FieldException
{
if (_Section.wouldReferencedChange (newSection))
{
assertValid();
Debug.assertion (getWriteability_Section () != FieldWriteability.FALSE, "Assoc Section is not writeable");
preSectionChange (newSection);
_Section.set (newSection);
postSectionChange ();
}
}
/**
* Get the reference Candidate * Get the reference Candidate
*/ */
public Candidate getCandidate () throws StorageException public Candidate getCandidate () throws StorageException
...@@ -524,9 +660,22 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -524,9 +660,22 @@ public abstract class BaseAnswer extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Candidate () != FieldWriteability.FALSE, "Assoc Candidate is not writeable"); Debug.assertion (getWriteability_Candidate () != FieldWriteability.FALSE, "Assoc Candidate is not writeable");
preCandidateChange (newCandidate); preCandidateChange (newCandidate);
Candidate oldCandidate = getCandidate ();
if (oldCandidate != null)
{
// This is to stop validation from triggering when we are removed
_Candidate.set (null);
oldCandidate.removeFromAnswers ((Answer)(this));
}
_Candidate.set (newCandidate); _Candidate.set (newCandidate);
if (newCandidate != null)
{
newCandidate.addToAnswers ((Answer)(this));
}
postCandidateChange (); postCandidateChange ();
} }
} }
...@@ -723,6 +872,20 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -723,6 +872,20 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
try try
{ {
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Candidate.isLoaded () || getTransaction ().isObjectLoaded (_Candidate.getReferencedType (), getCandidateID ()))
{
Candidate referenced = getCandidate ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Answers from ", getObjectID (), " to ", referenced.getObjectID ());
_Candidate.set (null);
referenced.removeFromAnswers ((Answer)this);
}
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -759,7 +922,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -759,7 +922,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "answer"; return "rs_answer";
} }
...@@ -780,10 +943,11 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -780,10 +943,11 @@ public abstract class BaseAnswer extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet answerPSet = allSets.getPersistentSet (myID, "answer", myPSetStatus); PersistentSet rs_answerPSet = allSets.getPersistentSet (myID, "rs_answer", myPSetStatus);
answerPSet.setAttrib (FIELD_ObjectID, myID); rs_answerPSet.setAttrib (FIELD_ObjectID, myID);
answerPSet.setAttrib (FIELD_AnswerNo, HELPER_AnswerNo.toObject (_AnswerNo)); // rs_answerPSet.setAttrib (FIELD_AnswerNo, HELPER_AnswerNo.toObject (_AnswerNo)); //
_Section.getPersistentSets (allSets);
_Candidate.getPersistentSets (allSets); _Candidate.getPersistentSets (allSets);
_Question.getPersistentSets (allSets); _Question.getPersistentSets (allSets);
...@@ -798,9 +962,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -798,9 +962,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet answerPSet = allSets.getPersistentSet (objectID, "answer"); PersistentSet rs_answerPSet = allSets.getPersistentSet (objectID, "rs_answer");
_AnswerNo = (Integer)(HELPER_AnswerNo.fromObject (_AnswerNo, answerPSet.getAttrib (FIELD_AnswerNo))); // _AnswerNo = (Integer)(HELPER_AnswerNo.fromObject (_AnswerNo, rs_answerPSet.getAttrib (FIELD_AnswerNo))); //
_Section.setFromPersistentSets (objectID, allSets);
_Candidate.setFromPersistentSets (objectID, allSets); _Candidate.setFromPersistentSets (objectID, allSets);
_Question.setFromPersistentSets (objectID, allSets); _Question.setFromPersistentSets (objectID, allSets);
...@@ -859,6 +1024,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -859,6 +1024,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
BaseAnswer sourceAnswer = (BaseAnswer)(source); BaseAnswer sourceAnswer = (BaseAnswer)(source);
_Section.copyFrom (sourceAnswer._Section, linkToGhosts);
_Candidate.copyFrom (sourceAnswer._Candidate, linkToGhosts); _Candidate.copyFrom (sourceAnswer._Candidate, linkToGhosts);
_Question.copyFrom (sourceAnswer._Question, linkToGhosts); _Question.copyFrom (sourceAnswer._Question, linkToGhosts);
...@@ -898,6 +1064,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -898,6 +1064,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
super.readExternalData(vals); super.readExternalData(vals);
_AnswerNo = (Integer)(HELPER_AnswerNo.readExternal (_AnswerNo, vals.get(FIELD_AnswerNo))); // _AnswerNo = (Integer)(HELPER_AnswerNo.readExternal (_AnswerNo, vals.get(FIELD_AnswerNo))); //
_Section.readExternalData(vals.get(SINGLEREFERENCE_Section));
_Candidate.readExternalData(vals.get(SINGLEREFERENCE_Candidate)); _Candidate.readExternalData(vals.get(SINGLEREFERENCE_Candidate));
_Question.readExternalData(vals.get(SINGLEREFERENCE_Question)); _Question.readExternalData(vals.get(SINGLEREFERENCE_Question));
...@@ -912,6 +1079,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -912,6 +1079,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
super.writeExternalData(vals); super.writeExternalData(vals);
vals.put (FIELD_AnswerNo, HELPER_AnswerNo.writeExternal (_AnswerNo)); vals.put (FIELD_AnswerNo, HELPER_AnswerNo.writeExternal (_AnswerNo));
vals.put (SINGLEREFERENCE_Section, _Section.writeExternalData());
vals.put (SINGLEREFERENCE_Candidate, _Candidate.writeExternalData()); vals.put (SINGLEREFERENCE_Candidate, _Candidate.writeExternalData());
vals.put (SINGLEREFERENCE_Question, _Question.writeExternalData()); vals.put (SINGLEREFERENCE_Question, _Question.writeExternalData());
...@@ -933,6 +1101,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -933,6 +1101,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
} }
// Compare single assocs // Compare single assocs
_Section.compare (otherAnswer._Section, listener);
_Candidate.compare (otherAnswer._Candidate, listener); _Candidate.compare (otherAnswer._Candidate, listener);
_Question.compare (otherAnswer._Question, listener); _Question.compare (otherAnswer._Question, listener);
...@@ -956,6 +1125,7 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -956,6 +1125,7 @@ public abstract class BaseAnswer extends BaseBusinessClass
super.visitAttributes (visitor); super.visitAttributes (visitor);
visitor.visitField(this, FIELD_AnswerNo, HELPER_AnswerNo.toObject(getAnswerNo())); visitor.visitField(this, FIELD_AnswerNo, HELPER_AnswerNo.toObject(getAnswerNo()));
visitor.visitAssociation (_Section);
visitor.visitAssociation (_Candidate); visitor.visitAssociation (_Candidate);
visitor.visitAssociation (_Question); visitor.visitAssociation (_Question);
...@@ -966,6 +1136,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -966,6 +1136,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
super.visitAssociations (visitor, scope); super.visitAssociations (visitor, scope);
if (scope.includes (_Section))
{
visitor.visit (_Section);
}
if (scope.includes (_Candidate)) if (scope.includes (_Candidate))
{ {
visitor.visit (_Candidate); visitor.visit (_Candidate);
...@@ -1003,6 +1177,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -1003,6 +1177,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
return filter.matches (getAnswerNo ()); return filter.matches (getAnswerNo ());
} }
else if (attribName.equals (SINGLEREFERENCE_Section))
{
return filter.matches (getSection ());
}
else if (attribName.equals (SINGLEREFERENCE_Candidate)) else if (attribName.equals (SINGLEREFERENCE_Candidate))
{ {
return filter.matches (getCandidate ()); return filter.matches (getCandidate ());
...@@ -1025,38 +1203,44 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -1025,38 +1203,44 @@ public abstract class BaseAnswer extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "answer.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_answer.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "answer.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_answer.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "answer.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_answer.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andAnswerNo (QueryFilter<Integer> filter) public SearchAll andAnswerNo (QueryFilter<Integer> filter)
{ {
filter.addFilter (context, "answer.answer_number", "AnswerNo"); filter.addFilter (context, "rs_answer.answer_number", "AnswerNo");
return this;
}
public SearchAll andSection (QueryFilter<Section> filter)
{
filter.addFilter (context, "rs_answer.section_number", "Section");
return this; return this;
} }
public SearchAll andCandidate (QueryFilter<Candidate> filter) public SearchAll andCandidate (QueryFilter<Candidate> filter)
{ {
filter.addFilter (context, "answer.candidate_id", "Candidate"); filter.addFilter (context, "rs_answer.candidate_id", "Candidate");
return this; return this;
} }
public SearchAll andQuestion (QueryFilter<Question> filter) public SearchAll andQuestion (QueryFilter<Question> filter)
{ {
filter.addFilter (context, "answer.quest_number", "Question"); filter.addFilter (context, "rs_answer.quest_number", "Question");
return this; return this;
} }
...@@ -1157,6 +1341,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -1157,6 +1341,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
return getWriteability_AnswerNo (); return getWriteability_AnswerNo ();
} }
else if (fieldName.equals (SINGLEREFERENCE_Section))
{
return getWriteability_Section ();
}
else if (fieldName.equals (SINGLEREFERENCE_Candidate)) else if (fieldName.equals (SINGLEREFERENCE_Candidate))
{ {
return getWriteability_Candidate (); return getWriteability_Candidate ();
...@@ -1314,6 +1502,10 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -1314,6 +1502,10 @@ public abstract class BaseAnswer extends BaseBusinessClass
{ {
return toAnswerNo (); return toAnswerNo ();
} }
if (name.equals ("Section"))
{
return toSection ();
}
if (name.equals ("Candidate")) if (name.equals ("Candidate"))
{ {
return toCandidate (); return toCandidate ();
...@@ -1329,6 +1521,12 @@ public abstract class BaseAnswer extends BaseBusinessClass ...@@ -1329,6 +1521,12 @@ public abstract class BaseAnswer extends BaseBusinessClass
public PipeLine<From, Integer> toAnswerNo () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_AnswerNo)); } public PipeLine<From, Integer> toAnswerNo () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_AnswerNo)); }
public Section.SectionPipeLineFactory<From, Section> toSection () { return toSection (Filter.ALL); }
public Section.SectionPipeLineFactory<From, Section> toSection (Filter<Section> filter)
{
return Section.REFERENCE_Section.new SectionPipeLineFactory<From, Section> (this, new ORMSingleAssocPipe<Me, Section>(SINGLEREFERENCE_Section, filter));
}
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate () { return toCandidate (Filter.ALL); } public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate () { return toCandidate (Filter.ALL); }
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate (Filter<Candidate> filter) public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate (Filter<Candidate> filter)
...@@ -1372,6 +1570,20 @@ class DummyAnswer extends Answer ...@@ -1372,6 +1570,20 @@ class DummyAnswer extends Answer
} }
public Section getSection () throws StorageException
{
return (Section)(Section.DUMMY_Section);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getSectionID ()
{
return Section.DUMMY_Section.getObjectID();
}
public Candidate getCandidate () throws StorageException public Candidate getCandidate () throws StorageException
{ {
return (Candidate)(Candidate.DUMMY_Candidate); return (Candidate)(Candidate.DUMMY_Candidate);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -923,7 +923,7 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -923,7 +923,7 @@ public abstract class BaseFactor extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "factor"; return "rs_factor";
} }
...@@ -944,10 +944,10 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -944,10 +944,10 @@ public abstract class BaseFactor extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet factorPSet = allSets.getPersistentSet (myID, "factor", myPSetStatus); PersistentSet rs_factorPSet = allSets.getPersistentSet (myID, "rs_factor", myPSetStatus);
factorPSet.setAttrib (FIELD_ObjectID, myID); rs_factorPSet.setAttrib (FIELD_ObjectID, myID);
factorPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); // rs_factorPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
} }
...@@ -960,9 +960,9 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -960,9 +960,9 @@ public abstract class BaseFactor extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet factorPSet = allSets.getPersistentSet (objectID, "factor"); PersistentSet rs_factorPSet = allSets.getPersistentSet (objectID, "rs_factor");
_Description = (String)(HELPER_Description.fromObject (_Description, factorPSet.getAttrib (FIELD_Description))); // _Description = (String)(HELPER_Description.fromObject (_Description, rs_factorPSet.getAttrib (FIELD_Description))); //
} }
...@@ -1186,26 +1186,26 @@ public abstract class BaseFactor extends BaseBusinessClass ...@@ -1186,26 +1186,26 @@ public abstract class BaseFactor extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "factor.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_factor.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "factor.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_factor.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "factor.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_factor.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andDescription (QueryFilter<String> filter) public SearchAll andDescription (QueryFilter<String> filter)
{ {
filter.addFilter (context, "factor.factor_hdr_desc", "Description"); filter.addFilter (context, "rs_factor.factor_hdr_desc", "Description");
return this; return this;
} }
......
...@@ -308,8 +308,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -308,8 +308,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Factors, Level.REFERENCE_Level, "factor_hdr"); _Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Factors, Level.REFERENCE_Level, "rs_factor_hdr");
_Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Levels, Factor.REFERENCE_Factor, "factor_hdr"); _Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Levels, Factor.REFERENCE_Factor, "rs_factor_hdr");
} }
...@@ -319,8 +319,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -319,8 +319,8 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Factors, Level.REFERENCE_Level, "factor_hdr"); _Level = new SingleAssociation<FactorLevelLink, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Factors, Level.REFERENCE_Level, "rs_factor_hdr");
_Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Levels, Factor.REFERENCE_Factor, "factor_hdr"); _Factor = new SingleAssociation<FactorLevelLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Levels, Factor.REFERENCE_Factor, "rs_factor_hdr");
return this; return this;
...@@ -1432,7 +1432,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1432,7 +1432,7 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "factor_hdr"; return "rs_factor_hdr";
} }
...@@ -1453,15 +1453,15 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1453,15 +1453,15 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet factor_hdrPSet = allSets.getPersistentSet (myID, "factor_hdr", myPSetStatus); PersistentSet rs_factor_hdrPSet = allSets.getPersistentSet (myID, "rs_factor_hdr", myPSetStatus);
factor_hdrPSet.setAttrib (FIELD_ObjectID, myID); rs_factor_hdrPSet.setAttrib (FIELD_ObjectID, myID);
factor_hdrPSet.setAttrib (FIELD_ClassCode, HELPER_ClassCode.toObject (_ClassCode)); // rs_factor_hdrPSet.setAttrib (FIELD_ClassCode, HELPER_ClassCode.toObject (_ClassCode)); //
factor_hdrPSet.setAttrib (FIELD_Notes, HELPER_Notes.toObject (_Notes)); // rs_factor_hdrPSet.setAttrib (FIELD_Notes, HELPER_Notes.toObject (_Notes)); //
factor_hdrPSet.setAttrib (FIELD_LeftAnnot, HELPER_LeftAnnot.toObject (_LeftAnnot)); // rs_factor_hdrPSet.setAttrib (FIELD_LeftAnnot, HELPER_LeftAnnot.toObject (_LeftAnnot)); //
factor_hdrPSet.setAttrib (FIELD_RightAnnot, HELPER_RightAnnot.toObject (_RightAnnot)); // rs_factor_hdrPSet.setAttrib (FIELD_RightAnnot, HELPER_RightAnnot.toObject (_RightAnnot)); //
factor_hdrPSet.setAttrib (FIELD_ZScoreWeight, HELPER_ZScoreWeight.toObject (_ZScoreWeight)); // rs_factor_hdrPSet.setAttrib (FIELD_ZScoreWeight, HELPER_ZScoreWeight.toObject (_ZScoreWeight)); //
factor_hdrPSet.setAttrib (FIELD_ZScoreWeight2, HELPER_ZScoreWeight2.toObject (_ZScoreWeight2)); // rs_factor_hdrPSet.setAttrib (FIELD_ZScoreWeight2, HELPER_ZScoreWeight2.toObject (_ZScoreWeight2)); //
_Level.getPersistentSets (allSets); _Level.getPersistentSets (allSets);
_Factor.getPersistentSets (allSets); _Factor.getPersistentSets (allSets);
...@@ -1476,14 +1476,14 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1476,14 +1476,14 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet factor_hdrPSet = allSets.getPersistentSet (objectID, "factor_hdr"); PersistentSet rs_factor_hdrPSet = allSets.getPersistentSet (objectID, "rs_factor_hdr");
_ClassCode = (String)(HELPER_ClassCode.fromObject (_ClassCode, factor_hdrPSet.getAttrib (FIELD_ClassCode))); // _ClassCode = (String)(HELPER_ClassCode.fromObject (_ClassCode, rs_factor_hdrPSet.getAttrib (FIELD_ClassCode))); //
_Notes = (String)(HELPER_Notes.fromObject (_Notes, factor_hdrPSet.getAttrib (FIELD_Notes))); // _Notes = (String)(HELPER_Notes.fromObject (_Notes, rs_factor_hdrPSet.getAttrib (FIELD_Notes))); //
_LeftAnnot = (String)(HELPER_LeftAnnot.fromObject (_LeftAnnot, factor_hdrPSet.getAttrib (FIELD_LeftAnnot))); // _LeftAnnot = (String)(HELPER_LeftAnnot.fromObject (_LeftAnnot, rs_factor_hdrPSet.getAttrib (FIELD_LeftAnnot))); //
_RightAnnot = (String)(HELPER_RightAnnot.fromObject (_RightAnnot, factor_hdrPSet.getAttrib (FIELD_RightAnnot))); // _RightAnnot = (String)(HELPER_RightAnnot.fromObject (_RightAnnot, rs_factor_hdrPSet.getAttrib (FIELD_RightAnnot))); //
_ZScoreWeight = (Double)(HELPER_ZScoreWeight.fromObject (_ZScoreWeight, factor_hdrPSet.getAttrib (FIELD_ZScoreWeight))); // _ZScoreWeight = (Double)(HELPER_ZScoreWeight.fromObject (_ZScoreWeight, rs_factor_hdrPSet.getAttrib (FIELD_ZScoreWeight))); //
_ZScoreWeight2 = (Double)(HELPER_ZScoreWeight2.fromObject (_ZScoreWeight2, factor_hdrPSet.getAttrib (FIELD_ZScoreWeight2))); // _ZScoreWeight2 = (Double)(HELPER_ZScoreWeight2.fromObject (_ZScoreWeight2, rs_factor_hdrPSet.getAttrib (FIELD_ZScoreWeight2))); //
_Level.setFromPersistentSets (objectID, allSets); _Level.setFromPersistentSets (objectID, allSets);
_Factor.setFromPersistentSets (objectID, allSets); _Factor.setFromPersistentSets (objectID, allSets);
...@@ -1813,68 +1813,68 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass ...@@ -1813,68 +1813,68 @@ public abstract class BaseFactorLevelLink extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "factor_hdr.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_factor_hdr.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "factor_hdr.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_factor_hdr.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "factor_hdr.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_factor_hdr.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andClassCode (QueryFilter<String> filter) public SearchAll andClassCode (QueryFilter<String> filter)
{ {
filter.addFilter (context, "factor_hdr.class_code", "ClassCode"); filter.addFilter (context, "rs_factor_hdr.class_code", "ClassCode");
return this; return this;
} }
public SearchAll andNotes (QueryFilter<String> filter) public SearchAll andNotes (QueryFilter<String> filter)
{ {
filter.addFilter (context, "factor_hdr.factor_hdr_notes", "Notes"); filter.addFilter (context, "rs_factor_hdr.factor_hdr_notes", "Notes");
return this; return this;
} }
public SearchAll andLeftAnnot (QueryFilter<String> filter) public SearchAll andLeftAnnot (QueryFilter<String> filter)
{ {
filter.addFilter (context, "factor_hdr.left_annot", "LeftAnnot"); filter.addFilter (context, "rs_factor_hdr.left_annot", "LeftAnnot");
return this; return this;
} }
public SearchAll andRightAnnot (QueryFilter<String> filter) public SearchAll andRightAnnot (QueryFilter<String> filter)
{ {
filter.addFilter (context, "factor_hdr.right_annot", "RightAnnot"); filter.addFilter (context, "rs_factor_hdr.right_annot", "RightAnnot");
return this; return this;
} }
public SearchAll andZScoreWeight (QueryFilter<Double> filter) public SearchAll andZScoreWeight (QueryFilter<Double> filter)
{ {
filter.addFilter (context, "factor_hdr.z_score_wght", "ZScoreWeight"); filter.addFilter (context, "rs_factor_hdr.z_score_wght", "ZScoreWeight");
return this; return this;
} }
public SearchAll andZScoreWeight2 (QueryFilter<Double> filter) public SearchAll andZScoreWeight2 (QueryFilter<Double> filter)
{ {
filter.addFilter (context, "factor_hdr.z_score_wght_2", "ZScoreWeight2"); filter.addFilter (context, "rs_factor_hdr.z_score_wght_2", "ZScoreWeight2");
return this; return this;
} }
public SearchAll andLevel (QueryFilter<Level> filter) public SearchAll andLevel (QueryFilter<Level> filter)
{ {
filter.addFilter (context, "factor_hdr.level_number", "Level"); filter.addFilter (context, "rs_factor_hdr.level_number", "Level");
return this; return this;
} }
public SearchAll andFactor (QueryFilter<Factor> filter) public SearchAll andFactor (QueryFilter<Factor> filter)
{ {
filter.addFilter (context, "factor_hdr.factor_number", "Factor"); filter.addFilter (context, "rs_factor_hdr.factor_number", "Factor");
return this; return this;
} }
......
...@@ -185,8 +185,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -185,8 +185,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Questions, Factor.REFERENCE_Factor, "factor_lin"); _Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Questions, Factor.REFERENCE_Factor, "rs_factor_lin");
_Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, Question.MULTIPLEREFERENCE_Factors, Question.REFERENCE_Question, "factor_lin"); _Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, Question.MULTIPLEREFERENCE_Factors, Question.REFERENCE_Question, "rs_factor_lin");
} }
...@@ -196,8 +196,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -196,8 +196,8 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Questions, Factor.REFERENCE_Factor, "factor_lin"); _Factor = new SingleAssociation<FactorQuestionLink, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Questions, Factor.REFERENCE_Factor, "rs_factor_lin");
_Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, Question.MULTIPLEREFERENCE_Factors, Question.REFERENCE_Question, "factor_lin"); _Question = new SingleAssociation<FactorQuestionLink, Question> (this, SINGLEREFERENCE_Question, Question.MULTIPLEREFERENCE_Factors, Question.REFERENCE_Question, "rs_factor_lin");
return this; return this;
...@@ -819,7 +819,7 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -819,7 +819,7 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "factor_lin"; return "rs_factor_lin";
} }
...@@ -840,10 +840,10 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -840,10 +840,10 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet factor_linPSet = allSets.getPersistentSet (myID, "factor_lin", myPSetStatus); PersistentSet rs_factor_linPSet = allSets.getPersistentSet (myID, "rs_factor_lin", myPSetStatus);
factor_linPSet.setAttrib (FIELD_ObjectID, myID); rs_factor_linPSet.setAttrib (FIELD_ObjectID, myID);
factor_linPSet.setAttrib (FIELD_ReverseScore, HELPER_ReverseScore.toObject (_ReverseScore)); // rs_factor_linPSet.setAttrib (FIELD_ReverseScore, HELPER_ReverseScore.toObject (_ReverseScore)); //
_Factor.getPersistentSets (allSets); _Factor.getPersistentSets (allSets);
_Question.getPersistentSets (allSets); _Question.getPersistentSets (allSets);
...@@ -858,9 +858,9 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -858,9 +858,9 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet factor_linPSet = allSets.getPersistentSet (objectID, "factor_lin"); PersistentSet rs_factor_linPSet = allSets.getPersistentSet (objectID, "rs_factor_lin");
_ReverseScore = (Boolean)(HELPER_ReverseScore.fromObject (_ReverseScore, factor_linPSet.getAttrib (FIELD_ReverseScore))); // _ReverseScore = (Boolean)(HELPER_ReverseScore.fromObject (_ReverseScore, rs_factor_linPSet.getAttrib (FIELD_ReverseScore))); //
_Factor.setFromPersistentSets (objectID, allSets); _Factor.setFromPersistentSets (objectID, allSets);
_Question.setFromPersistentSets (objectID, allSets); _Question.setFromPersistentSets (objectID, allSets);
...@@ -1085,38 +1085,38 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass ...@@ -1085,38 +1085,38 @@ public abstract class BaseFactorQuestionLink extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "factor_lin.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_factor_lin.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "factor_lin.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_factor_lin.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "factor_lin.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_factor_lin.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andReverseScore (QueryFilter<Boolean> filter) public SearchAll andReverseScore (QueryFilter<Boolean> filter)
{ {
filter.addFilter (context, "factor_lin.reverse_score_flag", "ReverseScore"); filter.addFilter (context, "rs_factor_lin.reverse_score_flag", "ReverseScore");
return this; return this;
} }
public SearchAll andFactor (QueryFilter<Factor> filter) public SearchAll andFactor (QueryFilter<Factor> filter)
{ {
filter.addFilter (context, "factor_lin.factor_number", "Factor"); filter.addFilter (context, "rs_factor_lin.factor_number", "Factor");
return this; return this;
} }
public SearchAll andQuestion (QueryFilter<Question> filter) public SearchAll andQuestion (QueryFilter<Question> filter)
{ {
filter.addFilter (context, "factor_lin.quest_number", "Question"); filter.addFilter (context, "rs_factor_lin.quest_number", "Question");
return this; return this;
} }
......
...@@ -42,6 +42,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -42,6 +42,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass
public static final String SINGLEREFERENCE_TestAnalysis = "TestAnalysis"; public static final String SINGLEREFERENCE_TestAnalysis = "TestAnalysis";
public static final String BACKREF_TestAnalysis = ""; public static final String BACKREF_TestAnalysis = "";
public static final String SINGLEREFERENCE_Factor = "Factor"; public static final String SINGLEREFERENCE_Factor = "Factor";
public static final String SINGLEREFERENCE_Level = "Level";
public static final String SINGLEREFERENCE_Narrative = "Narrative";
public static final String BACKREF_Narrative = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -58,6 +61,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -58,6 +61,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
// Private attributes corresponding to single references // Private attributes corresponding to single references
private SingleAssociation<FactorScore, TestAnalysis> _TestAnalysis; private SingleAssociation<FactorScore, TestAnalysis> _TestAnalysis;
private SingleAssociation<FactorScore, Factor> _Factor; private SingleAssociation<FactorScore, Factor> _Factor;
private SingleAssociation<FactorScore, Level> _Level;
private SingleAssociation<FactorScore, Narrative> _Narrative;
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
...@@ -79,11 +84,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -79,11 +84,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
String tmp_TestAnalysis = TestAnalysis.BACKREF_FactorScores; String tmp_TestAnalysis = TestAnalysis.BACKREF_FactorScores;
String tmp_Narrative = Narrative.BACKREF_FactorScores;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_TestAnalysis(); setupAssocMetaData_TestAnalysis();
setupAssocMetaData_Factor(); setupAssocMetaData_Factor();
setupAssocMetaData_Level();
setupAssocMetaData_Narrative();
FIELD_Score_Validators = (AttributeValidator[])setupAttribMetaData_Score(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Score_Validators = (AttributeValidator[])setupAttribMetaData_Score(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -129,6 +137,35 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -129,6 +137,35 @@ public abstract class BaseFactorScore extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Level()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "level_number");
metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.Level:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (SINGLEREFERENCE_Level, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Narrative()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "FactorScores");
metaInfo.put ("dbcol", "narrative_id");
metaInfo.put ("name", "Narrative");
metaInfo.put ("type", "Narrative");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.Narrative:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (SINGLEREFERENCE_Narrative, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Score(Map validatorMapping) private static List setupAttribMetaData_Score(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -182,8 +219,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -182,8 +219,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_TestAnalysis = new SingleAssociation<FactorScore, TestAnalysis> (this, SINGLEREFERENCE_TestAnalysis, TestAnalysis.MULTIPLEREFERENCE_FactorScores, TestAnalysis.REFERENCE_TestAnalysis, "score"); _TestAnalysis = new SingleAssociation<FactorScore, TestAnalysis> (this, SINGLEREFERENCE_TestAnalysis, TestAnalysis.MULTIPLEREFERENCE_FactorScores, TestAnalysis.REFERENCE_TestAnalysis, "rs_score");
_Factor = new SingleAssociation<FactorScore, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "score"); _Factor = new SingleAssociation<FactorScore, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "rs_score");
_Level = new SingleAssociation<FactorScore, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "rs_score");
_Narrative = new SingleAssociation<FactorScore, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_FactorScores, Narrative.REFERENCE_Narrative, "rs_score");
} }
...@@ -193,8 +232,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -193,8 +232,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_TestAnalysis = new SingleAssociation<FactorScore, TestAnalysis> (this, SINGLEREFERENCE_TestAnalysis, TestAnalysis.MULTIPLEREFERENCE_FactorScores, TestAnalysis.REFERENCE_TestAnalysis, "score"); _TestAnalysis = new SingleAssociation<FactorScore, TestAnalysis> (this, SINGLEREFERENCE_TestAnalysis, TestAnalysis.MULTIPLEREFERENCE_FactorScores, TestAnalysis.REFERENCE_TestAnalysis, "rs_score");
_Factor = new SingleAssociation<FactorScore, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "score"); _Factor = new SingleAssociation<FactorScore, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "rs_score");
_Level = new SingleAssociation<FactorScore, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "rs_score");
_Narrative = new SingleAssociation<FactorScore, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_FactorScores, Narrative.REFERENCE_Narrative, "rs_score");
return this; return this;
...@@ -314,6 +355,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -314,6 +355,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass
result.add("Factor"); result.add("Factor");
result.add("Level");
result.add("Narrative");
return result; return result;
} }
...@@ -331,6 +376,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -331,6 +376,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Factor)) }else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return _Factor.getReferencedType (); return _Factor.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return _Level.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return _Narrative.getReferencedType ();
} }
else else
{ {
...@@ -351,6 +402,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -351,6 +402,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Factor)) }else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return null ; return null ;
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return null ;
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return Narrative.MULTIPLEREFERENCE_FactorScores ;
} }
else else
{ {
...@@ -371,6 +428,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -371,6 +428,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Factor)) }else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return getFactor (); return getFactor ();
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel ();
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return getNarrative ();
} }
else else
{ {
...@@ -391,6 +454,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -391,6 +454,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Factor)) }else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return getFactor (getType); return getFactor (getType);
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel (getType);
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return getNarrative (getType);
} }
else else
{ {
...@@ -411,6 +480,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -411,6 +480,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Factor)) }else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
return getFactorID (); return getFactorID ();
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevelID ();
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
return getNarrativeID ();
} }
else else
{ {
...@@ -431,6 +506,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -431,6 +506,12 @@ public abstract class BaseFactorScore extends BaseBusinessClass
}else if (assocName.equals (SINGLEREFERENCE_Factor)) }else if (assocName.equals (SINGLEREFERENCE_Factor))
{ {
setFactor ((Factor)(newValue)); setFactor ((Factor)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Level))
{
setLevel ((Level)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Narrative))
{
setNarrative ((Narrative)(newValue));
} }
else else
{ {
...@@ -642,6 +723,207 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -642,6 +723,207 @@ public abstract class BaseFactorScore extends BaseBusinessClass
} }
/** /**
* 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 FactorScore:", this.getObjectID (), ", was trying to get Level:", getLevelID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Level.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Level getLevel (Get getType) throws StorageException
{
assertValid();
return _Level.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getLevelID ()
{
assertValid();
if (_Level == null)
{
return null;
}
else
{
return _Level.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preLevelChange (Level newLevel) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postLevelChange () throws FieldException
{
}
public FieldWriteability getWriteability_Level ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Level. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setLevel (Level newLevel) throws StorageException, FieldException
{
if (_Level.wouldReferencedChange (newLevel))
{
assertValid();
Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable");
preLevelChange (newLevel);
_Level.set (newLevel);
postLevelChange ();
}
}
/**
* Get the reference Narrative
*/
public Narrative getNarrative () throws StorageException
{
assertValid();
try
{
return (Narrative)(_Narrative.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in FactorScore:", this.getObjectID (), ", was trying to get Narrative:", getNarrativeID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Narrative.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Narrative getNarrative (Get getType) throws StorageException
{
assertValid();
return _Narrative.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getNarrativeID ()
{
assertValid();
if (_Narrative == null)
{
return null;
}
else
{
return _Narrative.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preNarrativeChange (Narrative newNarrative) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postNarrativeChange () throws FieldException
{
}
public FieldWriteability getWriteability_Narrative ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Narrative. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setNarrative (Narrative newNarrative) throws StorageException, FieldException
{
if (_Narrative.wouldReferencedChange (newNarrative))
{
assertValid();
Debug.assertion (getWriteability_Narrative () != FieldWriteability.FALSE, "Assoc Narrative is not writeable");
preNarrativeChange (newNarrative);
Narrative oldNarrative = getNarrative ();
if (oldNarrative != null)
{
// This is to stop validation from triggering when we are removed
_Narrative.set (null);
oldNarrative.removeFromFactorScores ((FactorScore)(this));
}
_Narrative.set (newNarrative);
if (newNarrative != null)
{
newNarrative.addToFactorScores ((FactorScore)(this));
}
postNarrativeChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings. * A list of multi assoc names e.g. list of strings.
*/ */
public List<String> getMultiAssocs() public List<String> getMultiAssocs()
...@@ -753,6 +1035,20 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -753,6 +1035,20 @@ public abstract class BaseFactorScore extends BaseBusinessClass
} }
} }
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Narrative.isLoaded () || getTransaction ().isObjectLoaded (_Narrative.getReferencedType (), getNarrativeID ()))
{
Narrative referenced = getNarrative ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null FactorScores from ", getObjectID (), " to ", referenced.getObjectID ());
_Narrative.set (null);
referenced.removeFromFactorScores ((FactorScore)this);
}
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -789,7 +1085,7 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -789,7 +1085,7 @@ public abstract class BaseFactorScore extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "score"; return "rs_score";
} }
...@@ -810,12 +1106,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -810,12 +1106,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet scorePSet = allSets.getPersistentSet (myID, "score", myPSetStatus); PersistentSet rs_scorePSet = allSets.getPersistentSet (myID, "rs_score", myPSetStatus);
scorePSet.setAttrib (FIELD_ObjectID, myID); rs_scorePSet.setAttrib (FIELD_ObjectID, myID);
scorePSet.setAttrib (FIELD_Score, HELPER_Score.toObject (_Score)); // rs_scorePSet.setAttrib (FIELD_Score, HELPER_Score.toObject (_Score)); //
_TestAnalysis.getPersistentSets (allSets); _TestAnalysis.getPersistentSets (allSets);
_Factor.getPersistentSets (allSets); _Factor.getPersistentSets (allSets);
_Level.getPersistentSets (allSets);
_Narrative.getPersistentSets (allSets);
} }
...@@ -828,11 +1126,13 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -828,11 +1126,13 @@ public abstract class BaseFactorScore extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet scorePSet = allSets.getPersistentSet (objectID, "score"); PersistentSet rs_scorePSet = allSets.getPersistentSet (objectID, "rs_score");
_Score = (Integer)(HELPER_Score.fromObject (_Score, scorePSet.getAttrib (FIELD_Score))); // _Score = (Integer)(HELPER_Score.fromObject (_Score, rs_scorePSet.getAttrib (FIELD_Score))); //
_TestAnalysis.setFromPersistentSets (objectID, allSets); _TestAnalysis.setFromPersistentSets (objectID, allSets);
_Factor.setFromPersistentSets (objectID, allSets); _Factor.setFromPersistentSets (objectID, allSets);
_Level.setFromPersistentSets (objectID, allSets);
_Narrative.setFromPersistentSets (objectID, allSets);
} }
...@@ -891,6 +1191,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -891,6 +1191,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
_TestAnalysis.copyFrom (sourceFactorScore._TestAnalysis, linkToGhosts); _TestAnalysis.copyFrom (sourceFactorScore._TestAnalysis, linkToGhosts);
_Factor.copyFrom (sourceFactorScore._Factor, linkToGhosts); _Factor.copyFrom (sourceFactorScore._Factor, linkToGhosts);
_Level.copyFrom (sourceFactorScore._Level, linkToGhosts);
_Narrative.copyFrom (sourceFactorScore._Narrative, linkToGhosts);
} }
} }
...@@ -930,6 +1232,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -930,6 +1232,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
_Score = (Integer)(HELPER_Score.readExternal (_Score, vals.get(FIELD_Score))); // _Score = (Integer)(HELPER_Score.readExternal (_Score, vals.get(FIELD_Score))); //
_TestAnalysis.readExternalData(vals.get(SINGLEREFERENCE_TestAnalysis)); _TestAnalysis.readExternalData(vals.get(SINGLEREFERENCE_TestAnalysis));
_Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor)); _Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor));
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Narrative.readExternalData(vals.get(SINGLEREFERENCE_Narrative));
} }
...@@ -944,6 +1248,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -944,6 +1248,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
vals.put (FIELD_Score, HELPER_Score.writeExternal (_Score)); vals.put (FIELD_Score, HELPER_Score.writeExternal (_Score));
vals.put (SINGLEREFERENCE_TestAnalysis, _TestAnalysis.writeExternalData()); vals.put (SINGLEREFERENCE_TestAnalysis, _TestAnalysis.writeExternalData());
vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData()); vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData());
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (SINGLEREFERENCE_Narrative, _Narrative.writeExternalData());
} }
...@@ -965,6 +1271,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -965,6 +1271,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
// Compare single assocs // Compare single assocs
_TestAnalysis.compare (otherFactorScore._TestAnalysis, listener); _TestAnalysis.compare (otherFactorScore._TestAnalysis, listener);
_Factor.compare (otherFactorScore._Factor, listener); _Factor.compare (otherFactorScore._Factor, listener);
_Level.compare (otherFactorScore._Level, listener);
_Narrative.compare (otherFactorScore._Narrative, listener);
// Compare multiple assocs // Compare multiple assocs
...@@ -988,6 +1296,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -988,6 +1296,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
visitor.visitField(this, FIELD_Score, HELPER_Score.toObject(getScore())); visitor.visitField(this, FIELD_Score, HELPER_Score.toObject(getScore()));
visitor.visitAssociation (_TestAnalysis); visitor.visitAssociation (_TestAnalysis);
visitor.visitAssociation (_Factor); visitor.visitAssociation (_Factor);
visitor.visitAssociation (_Level);
visitor.visitAssociation (_Narrative);
} }
...@@ -1004,6 +1314,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1004,6 +1314,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
visitor.visit (_Factor); visitor.visit (_Factor);
} }
if (scope.includes (_Level))
{
visitor.visit (_Level);
}
if (scope.includes (_Narrative))
{
visitor.visit (_Narrative);
}
} }
...@@ -1041,6 +1359,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1041,6 +1359,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return filter.matches (getFactor ()); return filter.matches (getFactor ());
} }
else if (attribName.equals (SINGLEREFERENCE_Level))
{
return filter.matches (getLevel ());
}
else if (attribName.equals (SINGLEREFERENCE_Narrative))
{
return filter.matches (getNarrative ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -1055,38 +1381,50 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1055,38 +1381,50 @@ public abstract class BaseFactorScore extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "score.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_score.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "score.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_score.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "score.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_score.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andScore (QueryFilter<Integer> filter) public SearchAll andScore (QueryFilter<Integer> filter)
{ {
filter.addFilter (context, "score.score_number", "Score"); filter.addFilter (context, "rs_score.score_number", "Score");
return this; return this;
} }
public SearchAll andTestAnalysis (QueryFilter<TestAnalysis> filter) public SearchAll andTestAnalysis (QueryFilter<TestAnalysis> filter)
{ {
filter.addFilter (context, "score.test_analysis_id", "TestAnalysis"); filter.addFilter (context, "rs_score.test_analysis_id", "TestAnalysis");
return this; return this;
} }
public SearchAll andFactor (QueryFilter<Factor> filter) public SearchAll andFactor (QueryFilter<Factor> filter)
{ {
filter.addFilter (context, "score.factor_number", "Factor"); filter.addFilter (context, "rs_score.factor_number", "Factor");
return this;
}
public SearchAll andLevel (QueryFilter<Level> filter)
{
filter.addFilter (context, "rs_score.level_number", "Level");
return this;
}
public SearchAll andNarrative (QueryFilter<Narrative> filter)
{
filter.addFilter (context, "rs_score.narrative_id", "Narrative");
return this; return this;
} }
...@@ -1195,6 +1533,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1195,6 +1533,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return getWriteability_Factor (); return getWriteability_Factor ();
} }
else if (fieldName.equals (SINGLEREFERENCE_Level))
{
return getWriteability_Level ();
}
else if (fieldName.equals (SINGLEREFERENCE_Narrative))
{
return getWriteability_Narrative ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1352,6 +1698,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1352,6 +1698,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return toFactor (); return toFactor ();
} }
if (name.equals ("Level"))
{
return toLevel ();
}
if (name.equals ("Narrative"))
{
return toNarrative ();
}
return super.to(name); return super.to(name);
...@@ -1371,6 +1725,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1371,6 +1725,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return Factor.REFERENCE_Factor.new FactorPipeLineFactory<From, Factor> (this, new ORMSingleAssocPipe<Me, Factor>(SINGLEREFERENCE_Factor, filter)); return Factor.REFERENCE_Factor.new FactorPipeLineFactory<From, Factor> (this, new ORMSingleAssocPipe<Me, Factor>(SINGLEREFERENCE_Factor, filter));
} }
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 Narrative.NarrativePipeLineFactory<From, Narrative> toNarrative () { return toNarrative (Filter.ALL); }
public Narrative.NarrativePipeLineFactory<From, Narrative> toNarrative (Filter<Narrative> filter)
{
return Narrative.REFERENCE_Narrative.new NarrativePipeLineFactory<From, Narrative> (this, new ORMSingleAssocPipe<Me, Narrative>(SINGLEREFERENCE_Narrative, filter));
}
} }
...@@ -1430,6 +1796,34 @@ class DummyFactorScore extends FactorScore ...@@ -1430,6 +1796,34 @@ class DummyFactorScore extends FactorScore
return Factor.DUMMY_Factor.getObjectID(); return Factor.DUMMY_Factor.getObjectID();
} }
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 Narrative getNarrative () throws StorageException
{
return (Narrative)(Narrative.DUMMY_Narrative);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getNarrativeID ()
{
return Narrative.DUMMY_Narrative.getObjectID();
}
} }
...@@ -257,9 +257,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -257,9 +257,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Results, Factor.REFERENCE_Factor, "level_factor"); _Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Results, Factor.REFERENCE_Factor, "rs_level_factor");
_Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Results, Level.REFERENCE_Level, "level_factor"); _Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Results, Level.REFERENCE_Level, "rs_level_factor");
_Narrative = new SingleAssociation<FactorScoreResult, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_Results, Narrative.REFERENCE_Narrative, "level_factor"); _Narrative = new SingleAssociation<FactorScoreResult, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_Results, Narrative.REFERENCE_Narrative, "rs_level_factor");
} }
...@@ -269,9 +269,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -269,9 +269,9 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Results, Factor.REFERENCE_Factor, "level_factor"); _Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, Factor.MULTIPLEREFERENCE_Results, Factor.REFERENCE_Factor, "rs_level_factor");
_Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Results, Level.REFERENCE_Level, "level_factor"); _Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Results, Level.REFERENCE_Level, "rs_level_factor");
_Narrative = new SingleAssociation<FactorScoreResult, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_Results, Narrative.REFERENCE_Narrative, "level_factor"); _Narrative = new SingleAssociation<FactorScoreResult, Narrative> (this, SINGLEREFERENCE_Narrative, Narrative.MULTIPLEREFERENCE_Results, Narrative.REFERENCE_Narrative, "rs_level_factor");
return this; return this;
...@@ -1230,7 +1230,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1230,7 +1230,7 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "level_factor"; return "rs_level_factor";
} }
...@@ -1251,12 +1251,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1251,12 +1251,12 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet level_factorPSet = allSets.getPersistentSet (myID, "level_factor", myPSetStatus); PersistentSet rs_level_factorPSet = allSets.getPersistentSet (myID, "rs_level_factor", myPSetStatus);
level_factorPSet.setAttrib (FIELD_ObjectID, myID); rs_level_factorPSet.setAttrib (FIELD_ObjectID, myID);
level_factorPSet.setAttrib (FIELD_FromScore, HELPER_FromScore.toObject (_FromScore)); // rs_level_factorPSet.setAttrib (FIELD_FromScore, HELPER_FromScore.toObject (_FromScore)); //
level_factorPSet.setAttrib (FIELD_ToScore, HELPER_ToScore.toObject (_ToScore)); // rs_level_factorPSet.setAttrib (FIELD_ToScore, HELPER_ToScore.toObject (_ToScore)); //
level_factorPSet.setAttrib (FIELD_ColorCode, HELPER_ColorCode.toObject (_ColorCode)); // rs_level_factorPSet.setAttrib (FIELD_ColorCode, HELPER_ColorCode.toObject (_ColorCode)); //
_Factor.getPersistentSets (allSets); _Factor.getPersistentSets (allSets);
_Level.getPersistentSets (allSets); _Level.getPersistentSets (allSets);
_Narrative.getPersistentSets (allSets); _Narrative.getPersistentSets (allSets);
...@@ -1272,11 +1272,11 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1272,11 +1272,11 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet level_factorPSet = allSets.getPersistentSet (objectID, "level_factor"); PersistentSet rs_level_factorPSet = allSets.getPersistentSet (objectID, "rs_level_factor");
_FromScore = (Integer)(HELPER_FromScore.fromObject (_FromScore, level_factorPSet.getAttrib (FIELD_FromScore))); // _FromScore = (Integer)(HELPER_FromScore.fromObject (_FromScore, rs_level_factorPSet.getAttrib (FIELD_FromScore))); //
_ToScore = (Integer)(HELPER_ToScore.fromObject (_ToScore, level_factorPSet.getAttrib (FIELD_ToScore))); // _ToScore = (Integer)(HELPER_ToScore.fromObject (_ToScore, rs_level_factorPSet.getAttrib (FIELD_ToScore))); //
_ColorCode = (ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, level_factorPSet.getAttrib (FIELD_ColorCode))); // _ColorCode = (ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, rs_level_factorPSet.getAttrib (FIELD_ColorCode))); //
_Factor.setFromPersistentSets (objectID, allSets); _Factor.setFromPersistentSets (objectID, allSets);
_Level.setFromPersistentSets (objectID, allSets); _Level.setFromPersistentSets (objectID, allSets);
_Narrative.setFromPersistentSets (objectID, allSets); _Narrative.setFromPersistentSets (objectID, allSets);
...@@ -1557,56 +1557,56 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1557,56 +1557,56 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "level_factor.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_level_factor.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "level_factor.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_level_factor.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "level_factor.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_level_factor.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andFromScore (QueryFilter<Integer> filter) public SearchAll andFromScore (QueryFilter<Integer> filter)
{ {
filter.addFilter (context, "level_factor.from_score", "FromScore"); filter.addFilter (context, "rs_level_factor.from_score", "FromScore");
return this; return this;
} }
public SearchAll andToScore (QueryFilter<Integer> filter) public SearchAll andToScore (QueryFilter<Integer> filter)
{ {
filter.addFilter (context, "level_factor.to_score", "ToScore"); filter.addFilter (context, "rs_level_factor.to_score", "ToScore");
return this; return this;
} }
public SearchAll andColorCode (QueryFilter<ColorCode> filter) public SearchAll andColorCode (QueryFilter<ColorCode> filter)
{ {
filter.addFilter (context, "level_factor.color_code", "ColorCode"); filter.addFilter (context, "rs_level_factor.color_code", "ColorCode");
return this; return this;
} }
public SearchAll andFactor (QueryFilter<Factor> filter) public SearchAll andFactor (QueryFilter<Factor> filter)
{ {
filter.addFilter (context, "level_factor.factor_number", "Factor"); filter.addFilter (context, "rs_level_factor.factor_number", "Factor");
return this; return this;
} }
public SearchAll andLevel (QueryFilter<Level> filter) public SearchAll andLevel (QueryFilter<Level> filter)
{ {
filter.addFilter (context, "level_factor.level_number", "Level"); filter.addFilter (context, "rs_level_factor.level_number", "Level");
return this; return this;
} }
public SearchAll andNarrative (QueryFilter<Narrative> filter) public SearchAll andNarrative (QueryFilter<Narrative> filter)
{ {
filter.addFilter (context, "level_factor.narrative_id", "Narrative"); filter.addFilter (context, "rs_level_factor.narrative_id", "Narrative");
return this; return this;
} }
...@@ -1644,56 +1644,56 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1644,56 +1644,56 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
public SearchFactorScore andObjectID (QueryFilter<Long> filter) public SearchFactorScore andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "level_factor.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_level_factor.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchFactorScore andObjectCreated (QueryFilter<Date> filter) public SearchFactorScore andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "level_factor.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_level_factor.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchFactorScore andObjectLastModified (QueryFilter<Date> filter) public SearchFactorScore andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "level_factor.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_level_factor.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchFactorScore andFromScore (QueryFilter<Integer> filter) public SearchFactorScore andFromScore (QueryFilter<Integer> filter)
{ {
filter.addFilter (context, "level_factor.from_score", "FromScore"); filter.addFilter (context, "rs_level_factor.from_score", "FromScore");
return this; return this;
} }
public SearchFactorScore andToScore (QueryFilter<Integer> filter) public SearchFactorScore andToScore (QueryFilter<Integer> filter)
{ {
filter.addFilter (context, "level_factor.to_score", "ToScore"); filter.addFilter (context, "rs_level_factor.to_score", "ToScore");
return this; return this;
} }
public SearchFactorScore andColorCode (QueryFilter<ColorCode> filter) public SearchFactorScore andColorCode (QueryFilter<ColorCode> filter)
{ {
filter.addFilter (context, "level_factor.color_code", "ColorCode"); filter.addFilter (context, "rs_level_factor.color_code", "ColorCode");
return this; return this;
} }
public SearchFactorScore andFactor (QueryFilter<Factor> filter) public SearchFactorScore andFactor (QueryFilter<Factor> filter)
{ {
filter.addFilter (context, "level_factor.factor_number", "Factor"); filter.addFilter (context, "rs_level_factor.factor_number", "Factor");
return this; return this;
} }
public SearchFactorScore andLevel (QueryFilter<Level> filter) public SearchFactorScore andLevel (QueryFilter<Level> filter)
{ {
filter.addFilter (context, "level_factor.level_number", "Level"); filter.addFilter (context, "rs_level_factor.level_number", "Level");
return this; return this;
} }
public SearchFactorScore andNarrative (QueryFilter<Narrative> filter) public SearchFactorScore andNarrative (QueryFilter<Narrative> filter)
{ {
filter.addFilter (context, "level_factor.narrative_id", "Narrative"); filter.addFilter (context, "rs_level_factor.narrative_id", "Narrative");
return this; return this;
} }
......
...@@ -45,6 +45,10 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -45,6 +45,10 @@ public abstract class BaseLevel extends BaseBusinessClass
public static final String BACKREF_Factors = ""; public static final String BACKREF_Factors = "";
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_Narratives = "Narratives";
public static final String BACKREF_Narratives = "";
public static final String MULTIPLEREFERENCE_TestAnalysises = "TestAnalysises";
public static final String BACKREF_TestAnalysises = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -68,6 +72,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -68,6 +72,8 @@ public abstract class BaseLevel extends BaseBusinessClass
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
private MultipleAssociation<Level, FactorLevelLink> _Factors; private MultipleAssociation<Level, FactorLevelLink> _Factors;
private MultipleAssociation<Level, FactorScoreResult> _Results; private MultipleAssociation<Level, FactorScoreResult> _Results;
private MultipleAssociation<Level, Narrative> _Narratives;
private MultipleAssociation<Level, TestAnalysis> _TestAnalysises;
// Map of maps of metadata // Map of maps of metadata
...@@ -89,11 +95,15 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -89,11 +95,15 @@ public abstract class BaseLevel extends BaseBusinessClass
String tmp_Factors = FactorLevelLink.BACKREF_Level; String tmp_Factors = FactorLevelLink.BACKREF_Level;
String tmp_Results = FactorScoreResult.BACKREF_Level; String tmp_Results = FactorScoreResult.BACKREF_Level;
String tmp_Narratives = Narrative.BACKREF_Level;
String tmp_TestAnalysises = TestAnalysis.BACKREF_Level;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Factors(); setupAssocMetaData_Factors();
setupAssocMetaData_Results(); setupAssocMetaData_Results();
setupAssocMetaData_Narratives();
setupAssocMetaData_TestAnalysises();
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]);
...@@ -140,6 +150,34 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -140,6 +150,34 @@ public abstract class BaseLevel extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Narratives()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Level");
metaInfo.put ("name", "Narratives");
metaInfo.put ("type", "Narrative");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.Narratives:", metaInfo);
ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_Narratives, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_TestAnalysises()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Level");
metaInfo.put ("name", "TestAnalysises");
metaInfo.put ("type", "TestAnalysis");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.TestAnalysises:", metaInfo);
ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_TestAnalysises, 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 ();
...@@ -234,6 +272,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -234,6 +272,8 @@ public abstract class BaseLevel extends BaseBusinessClass
_Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink); _Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink);
_Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult); _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);
_TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis);
} }
...@@ -245,6 +285,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -245,6 +285,8 @@ public abstract class BaseLevel extends BaseBusinessClass
_Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink); _Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink);
_Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult); _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);
_TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis);
return this; return this;
...@@ -658,6 +700,10 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -658,6 +700,10 @@ public abstract class BaseLevel extends BaseBusinessClass
result.add("Results"); result.add("Results");
result.add("Narratives");
result.add("TestAnalysises");
return result; return result;
} }
...@@ -679,6 +725,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -679,6 +725,16 @@ public abstract class BaseLevel extends BaseBusinessClass
return FactorScoreResult.REFERENCE_FactorScoreResult ; return FactorScoreResult.REFERENCE_FactorScoreResult ;
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return Narrative.REFERENCE_Narrative ;
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
return TestAnalysis.REFERENCE_TestAnalysis ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -697,6 +753,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -697,6 +753,16 @@ public abstract class BaseLevel extends BaseBusinessClass
return FactorScoreResult.SINGLEREFERENCE_Level ; return FactorScoreResult.SINGLEREFERENCE_Level ;
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return Narrative.SINGLEREFERENCE_Level ;
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
return TestAnalysis.SINGLEREFERENCE_Level ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -718,6 +784,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -718,6 +784,16 @@ public abstract class BaseLevel extends BaseBusinessClass
return this.getResultsCount(); return this.getResultsCount();
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesCount();
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
return this.getTestAnalysisesCount();
}
return super.getMultiAssocCount(attribName); return super.getMultiAssocCount(attribName);
} }
...@@ -739,6 +815,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -739,6 +815,16 @@ public abstract class BaseLevel extends BaseBusinessClass
return this.getResultsAt(index); return this.getResultsAt(index);
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return this.getNarrativesAt(index);
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
return this.getTestAnalysisesAt(index);
}
return super.getMultiAssocAt(attribName, index); return super.getMultiAssocAt(attribName, index);
} }
...@@ -764,6 +850,20 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -764,6 +850,20 @@ public abstract class BaseLevel extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
addToNarratives((Narrative)newElement);
return;
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
addToTestAnalysises((TestAnalysis)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement); super.addToMultiAssoc(attribName, newElement);
} }
...@@ -788,6 +888,20 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -788,6 +888,20 @@ public abstract class BaseLevel extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
removeFromNarratives((Narrative)oldElement);
return;
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
removeFromTestAnalysises((TestAnalysis)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement); super.removeFromMultiAssoc(attribName, oldElement);
} }
...@@ -808,6 +922,18 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -808,6 +922,18 @@ public abstract class BaseLevel extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
_Narratives.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
_TestAnalysises.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements); super.__loadMultiAssoc(attribName, elements);
} }
...@@ -826,6 +952,16 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -826,6 +952,16 @@ public abstract class BaseLevel extends BaseBusinessClass
return _Results.isLoaded (); return _Results.isLoaded ();
} }
if (MULTIPLEREFERENCE_Narratives.equals(attribName))
{
return _Narratives.isLoaded ();
}
if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
{
return _TestAnalysises.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName); return super.__isMultiAssocLoaded(attribName);
} }
...@@ -970,6 +1106,144 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -970,6 +1106,144 @@ public abstract class BaseLevel extends BaseBusinessClass
return _Results.getSet (); return _Results.getSet ();
} }
public FieldWriteability getWriteability_Narratives ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getNarrativesCount () throws StorageException
{
assertValid();
return _Narratives.getReferencedObjectsCount ();
}
public void addToNarratives (Narrative newElement) throws StorageException
{
if (_Narratives.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (add)");
_Narratives.appendElement (newElement);
try
{
if (newElement.getLevel () != this)
{
newElement.setLevel ((Level)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromNarratives (Narrative elementToRemove) throws StorageException
{
if (_Narratives.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (remove)");
_Narratives.removeElement (elementToRemove);
try
{
if (elementToRemove.getLevel () != null)
{
elementToRemove.setLevel (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public Narrative getNarrativesAt (int index) throws StorageException
{
return (Narrative)(_Narratives.getElementAt (index));
}
public SortedSet<Narrative> getNarrativesSet () throws StorageException
{
return _Narratives.getSet ();
}
public FieldWriteability getWriteability_TestAnalysises ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getTestAnalysisesCount () throws StorageException
{
assertValid();
return _TestAnalysises.getReferencedObjectsCount ();
}
public void addToTestAnalysises (TestAnalysis newElement) throws StorageException
{
if (_TestAnalysises.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_TestAnalysises () != FieldWriteability.FALSE, "MultiAssoc TestAnalysises is not writeable (add)");
_TestAnalysises.appendElement (newElement);
try
{
if (newElement.getLevel () != this)
{
newElement.setLevel ((Level)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromTestAnalysises (TestAnalysis elementToRemove) throws StorageException
{
if (_TestAnalysises.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_TestAnalysises () != FieldWriteability.FALSE, "MultiAssoc TestAnalysises is not writeable (remove)");
_TestAnalysises.removeElement (elementToRemove);
try
{
if (elementToRemove.getLevel () != null)
{
elementToRemove.setLevel (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public TestAnalysis getTestAnalysisesAt (int index) throws StorageException
{
return (TestAnalysis)(_TestAnalysises.getElementAt (index));
}
public SortedSet<TestAnalysis> getTestAnalysisesSet () throws StorageException
{
return _TestAnalysises.getSet ();
}
public void onDelete () public void onDelete ()
...@@ -988,6 +1262,18 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -988,6 +1262,18 @@ public abstract class BaseLevel extends BaseBusinessClass
referenced.setLevel(null); referenced.setLevel(null);
} }
for(Narrative referenced : CollectionUtils.reverse(getNarrativesSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setLevel(null);
}
for(TestAnalysis referenced : CollectionUtils.reverse(getTestAnalysisesSet()))
{
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)
{ {
...@@ -1024,7 +1310,7 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1024,7 +1310,7 @@ public abstract class BaseLevel extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "level"; return "rs_level";
} }
...@@ -1045,12 +1331,12 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1045,12 +1331,12 @@ public abstract class BaseLevel extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet levelPSet = allSets.getPersistentSet (myID, "level", myPSetStatus); PersistentSet rs_levelPSet = allSets.getPersistentSet (myID, "rs_level", myPSetStatus);
levelPSet.setAttrib (FIELD_ObjectID, myID); rs_levelPSet.setAttrib (FIELD_ObjectID, myID);
levelPSet.setAttrib (FIELD_LevelDescription, HELPER_LevelDescription.toObject (_LevelDescription)); // rs_levelPSet.setAttrib (FIELD_LevelDescription, HELPER_LevelDescription.toObject (_LevelDescription)); //
levelPSet.setAttrib (FIELD_LevelNotes, HELPER_LevelNotes.toObject (_LevelNotes)); // rs_levelPSet.setAttrib (FIELD_LevelNotes, HELPER_LevelNotes.toObject (_LevelNotes)); //
levelPSet.setAttrib (FIELD_ReportHeader, HELPER_ReportHeader.toObject (_ReportHeader)); // rs_levelPSet.setAttrib (FIELD_ReportHeader, HELPER_ReportHeader.toObject (_ReportHeader)); //
} }
...@@ -1063,11 +1349,11 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1063,11 +1349,11 @@ public abstract class BaseLevel extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet levelPSet = allSets.getPersistentSet (objectID, "level"); PersistentSet rs_levelPSet = allSets.getPersistentSet (objectID, "rs_level");
_LevelDescription = (String)(HELPER_LevelDescription.fromObject (_LevelDescription, levelPSet.getAttrib (FIELD_LevelDescription))); // _LevelDescription = (String)(HELPER_LevelDescription.fromObject (_LevelDescription, rs_levelPSet.getAttrib (FIELD_LevelDescription))); //
_LevelNotes = (String)(HELPER_LevelNotes.fromObject (_LevelNotes, levelPSet.getAttrib (FIELD_LevelNotes))); // _LevelNotes = (String)(HELPER_LevelNotes.fromObject (_LevelNotes, rs_levelPSet.getAttrib (FIELD_LevelNotes))); //
_ReportHeader = (String)(HELPER_ReportHeader.fromObject (_ReportHeader, levelPSet.getAttrib (FIELD_ReportHeader))); // _ReportHeader = (String)(HELPER_ReportHeader.fromObject (_ReportHeader, rs_levelPSet.getAttrib (FIELD_ReportHeader))); //
} }
...@@ -1162,6 +1448,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1162,6 +1448,8 @@ public abstract class BaseLevel extends BaseBusinessClass
_Factors.copyFrom (sourceLevel._Factors, linkToGhosts); _Factors.copyFrom (sourceLevel._Factors, linkToGhosts);
_Results.copyFrom (sourceLevel._Results, linkToGhosts); _Results.copyFrom (sourceLevel._Results, linkToGhosts);
_Narratives.copyFrom (sourceLevel._Narratives, linkToGhosts);
_TestAnalysises.copyFrom (sourceLevel._TestAnalysises, linkToGhosts);
} }
} }
...@@ -1187,6 +1475,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1187,6 +1475,8 @@ public abstract class BaseLevel extends BaseBusinessClass
_ReportHeader = (String)(HELPER_ReportHeader.readExternal (_ReportHeader, vals.get(FIELD_ReportHeader))); // _ReportHeader = (String)(HELPER_ReportHeader.readExternal (_ReportHeader, vals.get(FIELD_ReportHeader))); //
_Factors.readExternalData(vals.get(MULTIPLEREFERENCE_Factors)); _Factors.readExternalData(vals.get(MULTIPLEREFERENCE_Factors));
_Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results)); _Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
_Narratives.readExternalData(vals.get(MULTIPLEREFERENCE_Narratives));
_TestAnalysises.readExternalData(vals.get(MULTIPLEREFERENCE_TestAnalysises));
} }
...@@ -1203,6 +1493,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1203,6 +1493,8 @@ public abstract class BaseLevel extends BaseBusinessClass
vals.put (FIELD_ReportHeader, HELPER_ReportHeader.writeExternal (_ReportHeader)); vals.put (FIELD_ReportHeader, HELPER_ReportHeader.writeExternal (_ReportHeader));
vals.put (MULTIPLEREFERENCE_Factors, _Factors.writeExternalData()); vals.put (MULTIPLEREFERENCE_Factors, _Factors.writeExternalData());
vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData()); vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
vals.put (MULTIPLEREFERENCE_Narratives, _Narratives.writeExternalData());
vals.put (MULTIPLEREFERENCE_TestAnalysises, _TestAnalysises.writeExternalData());
} }
...@@ -1235,6 +1527,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1235,6 +1527,8 @@ public abstract class BaseLevel extends BaseBusinessClass
// Compare multiple assocs // Compare multiple assocs
_Factors.compare (otherLevel._Factors, listener); _Factors.compare (otherLevel._Factors, listener);
_Results.compare (otherLevel._Results, listener); _Results.compare (otherLevel._Results, listener);
_Narratives.compare (otherLevel._Narratives, listener);
_TestAnalysises.compare (otherLevel._TestAnalysises, listener);
} }
} }
...@@ -1257,6 +1551,8 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1257,6 +1551,8 @@ public abstract class BaseLevel extends BaseBusinessClass
visitor.visitField(this, FIELD_ReportHeader, HELPER_ReportHeader.toObject(getReportHeader())); visitor.visitField(this, FIELD_ReportHeader, HELPER_ReportHeader.toObject(getReportHeader()));
visitor.visitAssociation (_Factors); visitor.visitAssociation (_Factors);
visitor.visitAssociation (_Results); visitor.visitAssociation (_Results);
visitor.visitAssociation (_Narratives);
visitor.visitAssociation (_TestAnalysises);
} }
...@@ -1273,6 +1569,14 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1273,6 +1569,14 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
visitor.visit (_Results); visitor.visit (_Results);
} }
if (scope.includes (_Narratives))
{
visitor.visit (_Narratives);
}
if (scope.includes (_TestAnalysises))
{
visitor.visit (_TestAnalysises);
}
} }
...@@ -1324,38 +1628,38 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1324,38 +1628,38 @@ public abstract class BaseLevel extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "level.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_level.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "level.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_level.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "level.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_level.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andLevelDescription (QueryFilter<String> filter) public SearchAll andLevelDescription (QueryFilter<String> filter)
{ {
filter.addFilter (context, "level.level_desc", "LevelDescription"); filter.addFilter (context, "rs_level.level_desc", "LevelDescription");
return this; return this;
} }
public SearchAll andLevelNotes (QueryFilter<String> filter) public SearchAll andLevelNotes (QueryFilter<String> filter)
{ {
filter.addFilter (context, "level.level_notes", "LevelNotes"); filter.addFilter (context, "rs_level.level_notes", "LevelNotes");
return this; return this;
} }
public SearchAll andReportHeader (QueryFilter<String> filter) public SearchAll andReportHeader (QueryFilter<String> filter)
{ {
filter.addFilter (context, "level.rpt_hdr", "ReportHeader"); filter.addFilter (context, "rs_level.rpt_hdr", "ReportHeader");
return this; return this;
} }
...@@ -1496,6 +1800,14 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1496,6 +1800,14 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
return getWriteability_Results (); return getWriteability_Results ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_Narratives))
{
return getWriteability_Narratives ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_TestAnalysises))
{
return getWriteability_TestAnalysises ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1697,6 +2009,14 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1697,6 +2009,14 @@ public abstract class BaseLevel extends BaseBusinessClass
{ {
return toResults (); return toResults ();
} }
if (name.equals ("Narratives"))
{
return toNarratives ();
}
if (name.equals ("TestAnalysises"))
{
return toTestAnalysises ();
}
if (name.equals ("LevelDescription")) if (name.equals ("LevelDescription"))
{ {
return toLevelDescription (); return toLevelDescription ();
...@@ -1732,6 +2052,18 @@ public abstract class BaseLevel extends BaseBusinessClass ...@@ -1732,6 +2052,18 @@ public abstract class BaseLevel 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 Narrative.NarrativePipeLineFactory<From, Narrative> toNarratives () { return toNarratives(Filter.ALL); }
public Narrative.NarrativePipeLineFactory<From, Narrative> toNarratives (Filter<Narrative> filter)
{
return Narrative.REFERENCE_Narrative.new NarrativePipeLineFactory<From, Narrative> (this, new ORMMultiAssocPipe<Me, Narrative>(MULTIPLEREFERENCE_Narratives, filter));
}
public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysises () { return toTestAnalysises(Filter.ALL); }
public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysises (Filter<TestAnalysis> filter)
{
return TestAnalysis.REFERENCE_TestAnalysis.new TestAnalysisPipeLineFactory<From, TestAnalysis> (this, new ORMMultiAssocPipe<Me, TestAnalysis>(MULTIPLEREFERENCE_TestAnalysises, filter));
}
} }
...@@ -1797,6 +2129,40 @@ class DummyLevel extends Level ...@@ -1797,6 +2129,40 @@ class DummyLevel extends Level
return new TreeSet(); return new TreeSet();
} }
public int getNarrativesCount () throws StorageException
{
return 0;
}
public Narrative getNarrativesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Narratives");
}
public SortedSet getNarrativesSet () throws StorageException
{
return new TreeSet();
}
public int getTestAnalysisesCount () throws StorageException
{
return 0;
}
public TestAnalysis getTestAnalysisesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association TestAnalysises");
}
public SortedSet getTestAnalysisesSet () throws StorageException
{
return new TreeSet();
}
} }
...@@ -47,8 +47,11 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -47,8 +47,11 @@ public abstract class BaseNarrative extends BaseBusinessClass
public static final String FIELD_DevelNarrative = "DevelNarrative"; public static final String FIELD_DevelNarrative = "DevelNarrative";
public static final String FIELD_Question = "Question"; public static final String FIELD_Question = "Question";
public static final String SINGLEREFERENCE_Level = "Level"; public static final String SINGLEREFERENCE_Level = "Level";
public static final String BACKREF_Level = "";
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_FactorScores = "FactorScores";
public static final String BACKREF_FactorScores = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -82,6 +85,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -82,6 +85,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
private MultipleAssociation<Narrative, FactorScoreResult> _Results; private MultipleAssociation<Narrative, FactorScoreResult> _Results;
private MultipleAssociation<Narrative, FactorScore> _FactorScores;
// Map of maps of metadata // Map of maps of metadata
...@@ -107,10 +111,13 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -107,10 +111,13 @@ public abstract class BaseNarrative extends BaseBusinessClass
{ {
String tmp_Results = FactorScoreResult.BACKREF_Narrative; String tmp_Results = FactorScoreResult.BACKREF_Narrative;
String tmp_FactorScores = FactorScore.BACKREF_Narrative;
String tmp_Level = Level.BACKREF_Narratives;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Results(); setupAssocMetaData_Results();
setupAssocMetaData_FactorScores();
setupAssocMetaData_Level(); setupAssocMetaData_Level();
FIELD_NarrativeCode_Validators = (AttributeValidator[])setupAttribMetaData_NarrativeCode(validatorMapping).toArray (new AttributeValidator[0]); FIELD_NarrativeCode_Validators = (AttributeValidator[])setupAttribMetaData_NarrativeCode(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -149,10 +156,25 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -149,10 +156,25 @@ public abstract class BaseNarrative extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_FactorScores()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Narrative");
metaInfo.put ("name", "FactorScores");
metaInfo.put ("type", "FactorScore");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Narrative.FactorScores:", metaInfo);
ATTRIBUTES_METADATA_Narrative.put (MULTIPLEREFERENCE_FactorScores, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Level() private static void setupAssocMetaData_Level()
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Narratives");
metaInfo.put ("dbcol", "level_number"); metaInfo.put ("dbcol", "level_number");
metaInfo.put ("name", "Level"); metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level"); metaInfo.put ("type", "Level");
...@@ -354,8 +376,9 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -354,8 +376,9 @@ public abstract class BaseNarrative extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Level = new SingleAssociation<Narrative, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "narrative"); _Level = new SingleAssociation<Narrative, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Narratives, Level.REFERENCE_Level, "rs_narrative");
_Results = new MultipleAssociation<Narrative, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Narrative, FactorScoreResult.REFERENCE_FactorScoreResult); _Results = new MultipleAssociation<Narrative, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Narrative, FactorScoreResult.REFERENCE_FactorScoreResult);
_FactorScores = new MultipleAssociation<Narrative, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_Narrative, FactorScore.REFERENCE_FactorScore);
} }
...@@ -365,8 +388,9 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -365,8 +388,9 @@ public abstract class BaseNarrative extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Level = new SingleAssociation<Narrative, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "narrative"); _Level = new SingleAssociation<Narrative, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_Narratives, Level.REFERENCE_Level, "rs_narrative");
_Results = new MultipleAssociation<Narrative, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Narrative, FactorScoreResult.REFERENCE_FactorScoreResult); _Results = new MultipleAssociation<Narrative, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Narrative, FactorScoreResult.REFERENCE_FactorScoreResult);
_FactorScores = new MultipleAssociation<Narrative, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_Narrative, FactorScore.REFERENCE_FactorScore);
return this; return this;
...@@ -1201,7 +1225,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1201,7 +1225,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
} }
else if (assocName.equals (SINGLEREFERENCE_Level)) else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return null ; return Level.MULTIPLEREFERENCE_Narratives ;
} }
else else
{ {
...@@ -1366,9 +1390,22 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1366,9 +1390,22 @@ public abstract class BaseNarrative extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable"); Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable");
preLevelChange (newLevel); preLevelChange (newLevel);
Level oldLevel = getLevel ();
if (oldLevel != null)
{
// This is to stop validation from triggering when we are removed
_Level.set (null);
oldLevel.removeFromNarratives ((Narrative)(this));
}
_Level.set (newLevel); _Level.set (newLevel);
if (newLevel != null)
{
newLevel.addToNarratives ((Narrative)(this));
}
postLevelChange (); postLevelChange ();
} }
} }
...@@ -1383,6 +1420,8 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1383,6 +1420,8 @@ public abstract class BaseNarrative extends BaseBusinessClass
result.add("Results"); result.add("Results");
result.add("FactorScores");
return result; return result;
} }
...@@ -1399,6 +1438,11 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1399,6 +1438,11 @@ public abstract class BaseNarrative extends BaseBusinessClass
return FactorScoreResult.REFERENCE_FactorScoreResult ; return FactorScoreResult.REFERENCE_FactorScoreResult ;
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return FactorScore.REFERENCE_FactorScore ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -1412,6 +1456,11 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1412,6 +1456,11 @@ public abstract class BaseNarrative extends BaseBusinessClass
return FactorScoreResult.SINGLEREFERENCE_Narrative ; return FactorScoreResult.SINGLEREFERENCE_Narrative ;
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return FactorScore.SINGLEREFERENCE_Narrative ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -1428,6 +1477,11 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1428,6 +1477,11 @@ public abstract class BaseNarrative extends BaseBusinessClass
return this.getResultsCount(); return this.getResultsCount();
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return this.getFactorScoresCount();
}
return super.getMultiAssocCount(attribName); return super.getMultiAssocCount(attribName);
} }
...@@ -1444,6 +1498,11 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1444,6 +1498,11 @@ public abstract class BaseNarrative extends BaseBusinessClass
return this.getResultsAt(index); return this.getResultsAt(index);
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return this.getFactorScoresAt(index);
}
return super.getMultiAssocAt(attribName, index); return super.getMultiAssocAt(attribName, index);
} }
...@@ -1462,6 +1521,13 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1462,6 +1521,13 @@ public abstract class BaseNarrative extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
addToFactorScores((FactorScore)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement); super.addToMultiAssoc(attribName, newElement);
} }
...@@ -1479,6 +1545,13 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1479,6 +1545,13 @@ public abstract class BaseNarrative extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
removeFromFactorScores((FactorScore)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement); super.removeFromMultiAssoc(attribName, oldElement);
} }
...@@ -1493,6 +1566,12 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1493,6 +1566,12 @@ public abstract class BaseNarrative extends BaseBusinessClass
return; return;
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
_FactorScores.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements); super.__loadMultiAssoc(attribName, elements);
} }
...@@ -1506,6 +1585,11 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1506,6 +1585,11 @@ public abstract class BaseNarrative extends BaseBusinessClass
return _Results.isLoaded (); return _Results.isLoaded ();
} }
if (MULTIPLEREFERENCE_FactorScores.equals(attribName))
{
return _FactorScores.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName); return super.__isMultiAssocLoaded(attribName);
} }
...@@ -1581,18 +1665,107 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1581,18 +1665,107 @@ public abstract class BaseNarrative extends BaseBusinessClass
return _Results.getSet (); return _Results.getSet ();
} }
public FieldWriteability getWriteability_FactorScores ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getFactorScoresCount () throws StorageException
{
assertValid();
return _FactorScores.getReferencedObjectsCount ();
}
public void addToFactorScores (FactorScore newElement) throws StorageException
{
if (_FactorScores.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_FactorScores () != FieldWriteability.FALSE, "MultiAssoc FactorScores is not writeable (add)");
_FactorScores.appendElement (newElement);
try
{
if (newElement.getNarrative () != this)
{
newElement.setNarrative ((Narrative)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromFactorScores (FactorScore elementToRemove) throws StorageException
{
if (_FactorScores.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_FactorScores () != FieldWriteability.FALSE, "MultiAssoc FactorScores is not writeable (remove)");
_FactorScores.removeElement (elementToRemove);
try
{
if (elementToRemove.getNarrative () != null)
{
elementToRemove.setNarrative (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public FactorScore getFactorScoresAt (int index) throws StorageException
{
return (FactorScore)(_FactorScores.getElementAt (index));
}
public SortedSet<FactorScore> getFactorScoresSet () throws StorageException
{
return _FactorScores.getSet ();
}
public void onDelete () public void onDelete ()
{ {
try 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 Narratives from ", getObjectID (), " to ", referenced.getObjectID ());
_Level.set (null);
referenced.removeFromNarratives ((Narrative)this);
}
}
for(FactorScoreResult referenced : CollectionUtils.reverse(getResultsSet())) for(FactorScoreResult referenced : CollectionUtils.reverse(getResultsSet()))
{ {
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Narrative from ", getObjectID (), " to ", referenced.getObjectID ()); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Narrative from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setNarrative(null); referenced.setNarrative(null);
} }
for(FactorScore referenced : CollectionUtils.reverse(getFactorScoresSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Narrative from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setNarrative(null);
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -1629,7 +1802,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1629,7 +1802,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "narrative"; return "rs_narrative";
} }
...@@ -1650,17 +1823,17 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1650,17 +1823,17 @@ public abstract class BaseNarrative extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet narrativePSet = allSets.getPersistentSet (myID, "narrative", myPSetStatus); PersistentSet rs_narrativePSet = allSets.getPersistentSet (myID, "rs_narrative", myPSetStatus);
narrativePSet.setAttrib (FIELD_ObjectID, myID); rs_narrativePSet.setAttrib (FIELD_ObjectID, myID);
narrativePSet.setAttrib (FIELD_NarrativeCode, HELPER_NarrativeCode.toObject (_NarrativeCode)); // rs_narrativePSet.setAttrib (FIELD_NarrativeCode, HELPER_NarrativeCode.toObject (_NarrativeCode)); //
narrativePSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); // rs_narrativePSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
narrativePSet.setAttrib (FIELD_GraphicNotes, HELPER_GraphicNotes.toObject (_GraphicNotes)); // rs_narrativePSet.setAttrib (FIELD_GraphicNotes, HELPER_GraphicNotes.toObject (_GraphicNotes)); //
narrativePSet.setAttrib (FIELD_SummaryNotes, HELPER_SummaryNotes.toObject (_SummaryNotes)); // rs_narrativePSet.setAttrib (FIELD_SummaryNotes, HELPER_SummaryNotes.toObject (_SummaryNotes)); //
narrativePSet.setAttrib (FIELD_ModConnect, HELPER_ModConnect.toObject (_ModConnect)); // rs_narrativePSet.setAttrib (FIELD_ModConnect, HELPER_ModConnect.toObject (_ModConnect)); //
narrativePSet.setAttrib (FIELD_NarrativeNotes, HELPER_NarrativeNotes.toObject (_NarrativeNotes)); // rs_narrativePSet.setAttrib (FIELD_NarrativeNotes, HELPER_NarrativeNotes.toObject (_NarrativeNotes)); //
narrativePSet.setAttrib (FIELD_DevelNarrative, HELPER_DevelNarrative.toObject (_DevelNarrative)); // rs_narrativePSet.setAttrib (FIELD_DevelNarrative, HELPER_DevelNarrative.toObject (_DevelNarrative)); //
narrativePSet.setAttrib (FIELD_Question, HELPER_Question.toObject (_Question)); // rs_narrativePSet.setAttrib (FIELD_Question, HELPER_Question.toObject (_Question)); //
_Level.getPersistentSets (allSets); _Level.getPersistentSets (allSets);
} }
...@@ -1674,16 +1847,16 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1674,16 +1847,16 @@ public abstract class BaseNarrative extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet narrativePSet = allSets.getPersistentSet (objectID, "narrative"); PersistentSet rs_narrativePSet = allSets.getPersistentSet (objectID, "rs_narrative");
_NarrativeCode = (String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, narrativePSet.getAttrib (FIELD_NarrativeCode))); // _NarrativeCode = (String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, rs_narrativePSet.getAttrib (FIELD_NarrativeCode))); //
_Description = (String)(HELPER_Description.fromObject (_Description, narrativePSet.getAttrib (FIELD_Description))); // _Description = (String)(HELPER_Description.fromObject (_Description, rs_narrativePSet.getAttrib (FIELD_Description))); //
_GraphicNotes = (String)(HELPER_GraphicNotes.fromObject (_GraphicNotes, narrativePSet.getAttrib (FIELD_GraphicNotes))); // _GraphicNotes = (String)(HELPER_GraphicNotes.fromObject (_GraphicNotes, rs_narrativePSet.getAttrib (FIELD_GraphicNotes))); //
_SummaryNotes = (String)(HELPER_SummaryNotes.fromObject (_SummaryNotes, narrativePSet.getAttrib (FIELD_SummaryNotes))); // _SummaryNotes = (String)(HELPER_SummaryNotes.fromObject (_SummaryNotes, rs_narrativePSet.getAttrib (FIELD_SummaryNotes))); //
_ModConnect = (String)(HELPER_ModConnect.fromObject (_ModConnect, narrativePSet.getAttrib (FIELD_ModConnect))); // _ModConnect = (String)(HELPER_ModConnect.fromObject (_ModConnect, rs_narrativePSet.getAttrib (FIELD_ModConnect))); //
_NarrativeNotes = (String)(HELPER_NarrativeNotes.fromObject (_NarrativeNotes, narrativePSet.getAttrib (FIELD_NarrativeNotes))); // _NarrativeNotes = (String)(HELPER_NarrativeNotes.fromObject (_NarrativeNotes, rs_narrativePSet.getAttrib (FIELD_NarrativeNotes))); //
_DevelNarrative = (String)(HELPER_DevelNarrative.fromObject (_DevelNarrative, narrativePSet.getAttrib (FIELD_DevelNarrative))); // _DevelNarrative = (String)(HELPER_DevelNarrative.fromObject (_DevelNarrative, rs_narrativePSet.getAttrib (FIELD_DevelNarrative))); //
_Question = (String)(HELPER_Question.fromObject (_Question, narrativePSet.getAttrib (FIELD_Question))); // _Question = (String)(HELPER_Question.fromObject (_Question, rs_narrativePSet.getAttrib (FIELD_Question))); //
_Level.setFromPersistentSets (objectID, allSets); _Level.setFromPersistentSets (objectID, allSets);
} }
...@@ -1829,6 +2002,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1829,6 +2002,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
BaseNarrative sourceNarrative = (BaseNarrative)(source); BaseNarrative sourceNarrative = (BaseNarrative)(source);
_Results.copyFrom (sourceNarrative._Results, linkToGhosts); _Results.copyFrom (sourceNarrative._Results, linkToGhosts);
_FactorScores.copyFrom (sourceNarrative._FactorScores, linkToGhosts);
} }
} }
...@@ -1859,6 +2033,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1859,6 +2033,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
_Question = (String)(HELPER_Question.readExternal (_Question, vals.get(FIELD_Question))); // _Question = (String)(HELPER_Question.readExternal (_Question, vals.get(FIELD_Question))); //
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level)); _Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results)); _Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
_FactorScores.readExternalData(vals.get(MULTIPLEREFERENCE_FactorScores));
} }
...@@ -1880,6 +2055,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1880,6 +2055,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
vals.put (FIELD_Question, HELPER_Question.writeExternal (_Question)); vals.put (FIELD_Question, HELPER_Question.writeExternal (_Question));
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData()); vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData()); vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
vals.put (MULTIPLEREFERENCE_FactorScores, _FactorScores.writeExternalData());
} }
...@@ -1932,6 +2108,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1932,6 +2108,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
// Compare multiple assocs // Compare multiple assocs
_Results.compare (otherNarrative._Results, listener); _Results.compare (otherNarrative._Results, listener);
_FactorScores.compare (otherNarrative._FactorScores, listener);
} }
} }
...@@ -1959,6 +2136,7 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1959,6 +2136,7 @@ public abstract class BaseNarrative extends BaseBusinessClass
visitor.visitField(this, FIELD_Question, HELPER_Question.toObject(getQuestion())); visitor.visitField(this, FIELD_Question, HELPER_Question.toObject(getQuestion()));
visitor.visitAssociation (_Level); visitor.visitAssociation (_Level);
visitor.visitAssociation (_Results); visitor.visitAssociation (_Results);
visitor.visitAssociation (_FactorScores);
} }
...@@ -1975,6 +2153,10 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -1975,6 +2153,10 @@ public abstract class BaseNarrative extends BaseBusinessClass
{ {
visitor.visit (_Results); visitor.visit (_Results);
} }
if (scope.includes (_FactorScores))
{
visitor.visit (_FactorScores);
}
} }
...@@ -2050,74 +2232,74 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -2050,74 +2232,74 @@ public abstract class BaseNarrative extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "narrative.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_narrative.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "narrative.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_narrative.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "narrative.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_narrative.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andNarrativeCode (QueryFilter<String> filter) public SearchAll andNarrativeCode (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.narrative_code", "NarrativeCode"); filter.addFilter (context, "rs_narrative.narrative_code", "NarrativeCode");
return this; return this;
} }
public SearchAll andDescription (QueryFilter<String> filter) public SearchAll andDescription (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.narrative_desc", "Description"); filter.addFilter (context, "rs_narrative.narrative_desc", "Description");
return this; return this;
} }
public SearchAll andGraphicNotes (QueryFilter<String> filter) public SearchAll andGraphicNotes (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.graphic_notes", "GraphicNotes"); filter.addFilter (context, "rs_narrative.graphic_notes", "GraphicNotes");
return this; return this;
} }
public SearchAll andSummaryNotes (QueryFilter<String> filter) public SearchAll andSummaryNotes (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.exec_sum_notes", "SummaryNotes"); filter.addFilter (context, "rs_narrative.exec_sum_notes", "SummaryNotes");
return this; return this;
} }
public SearchAll andModConnect (QueryFilter<String> filter) public SearchAll andModConnect (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.mod_connect_flag", "ModConnect"); filter.addFilter (context, "rs_narrative.mod_connect_flag", "ModConnect");
return this; return this;
} }
public SearchAll andNarrativeNotes (QueryFilter<String> filter) public SearchAll andNarrativeNotes (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.narrative_notes", "NarrativeNotes"); filter.addFilter (context, "rs_narrative.narrative_notes", "NarrativeNotes");
return this; return this;
} }
public SearchAll andDevelNarrative (QueryFilter<String> filter) public SearchAll andDevelNarrative (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.devel_narrative", "DevelNarrative"); filter.addFilter (context, "rs_narrative.devel_narrative", "DevelNarrative");
return this; return this;
} }
public SearchAll andQuestion (QueryFilter<String> filter) public SearchAll andQuestion (QueryFilter<String> filter)
{ {
filter.addFilter (context, "narrative.question", "Question"); filter.addFilter (context, "rs_narrative.question", "Question");
return this; return this;
} }
public SearchAll andLevel (QueryFilter<Level> filter) public SearchAll andLevel (QueryFilter<Level> filter)
{ {
filter.addFilter (context, "narrative.level_number", "Level"); filter.addFilter (context, "rs_narrative.level_number", "Level");
return this; return this;
} }
...@@ -2334,6 +2516,10 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -2334,6 +2516,10 @@ public abstract class BaseNarrative extends BaseBusinessClass
{ {
return getWriteability_Results (); return getWriteability_Results ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_FactorScores))
{
return getWriteability_FactorScores ();
}
else if (fieldName.equals (SINGLEREFERENCE_Level)) else if (fieldName.equals (SINGLEREFERENCE_Level))
{ {
return getWriteability_Level (); return getWriteability_Level ();
...@@ -2655,6 +2841,10 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -2655,6 +2841,10 @@ public abstract class BaseNarrative extends BaseBusinessClass
{ {
return toResults (); return toResults ();
} }
if (name.equals ("FactorScores"))
{
return toFactorScores ();
}
if (name.equals ("NarrativeCode")) if (name.equals ("NarrativeCode"))
{ {
return toNarrativeCode (); return toNarrativeCode ();
...@@ -2724,6 +2914,12 @@ public abstract class BaseNarrative extends BaseBusinessClass ...@@ -2724,6 +2914,12 @@ public abstract class BaseNarrative 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 FactorScore.FactorScorePipeLineFactory<From, FactorScore> toFactorScores () { return toFactorScores(Filter.ALL); }
public FactorScore.FactorScorePipeLineFactory<From, FactorScore> toFactorScores (Filter<FactorScore> filter)
{
return FactorScore.REFERENCE_FactorScore.new FactorScorePipeLineFactory<From, FactorScore> (this, new ORMMultiAssocPipe<Me, FactorScore>(MULTIPLEREFERENCE_FactorScores, filter));
}
} }
...@@ -2786,6 +2982,23 @@ class DummyNarrative extends Narrative ...@@ -2786,6 +2982,23 @@ class DummyNarrative extends Narrative
return new TreeSet(); return new TreeSet();
} }
public int getFactorScoresCount () throws StorageException
{
return 0;
}
public FactorScore getFactorScoresAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association FactorScores");
}
public SortedSet getFactorScoresSet () throws StorageException
{
return new TreeSet();
}
} }
...@@ -185,7 +185,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -185,7 +185,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "quest_lin"); _Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "rs_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);
} }
...@@ -196,7 +196,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -196,7 +196,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "quest_lin"); _Section = new SingleAssociation<Question, Section> (this, SINGLEREFERENCE_Section, Section.MULTIPLEREFERENCE_Questions, Section.REFERENCE_Section, "rs_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);
...@@ -800,7 +800,7 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -800,7 +800,7 @@ public abstract class BaseQuestion extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "quest_lin"; return "rs_quest_lin";
} }
...@@ -821,10 +821,10 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -821,10 +821,10 @@ public abstract class BaseQuestion extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet quest_linPSet = allSets.getPersistentSet (myID, "quest_lin", myPSetStatus); PersistentSet rs_quest_linPSet = allSets.getPersistentSet (myID, "rs_quest_lin", myPSetStatus);
quest_linPSet.setAttrib (FIELD_ObjectID, myID); rs_quest_linPSet.setAttrib (FIELD_ObjectID, myID);
quest_linPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); // rs_quest_linPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
_Section.getPersistentSets (allSets); _Section.getPersistentSets (allSets);
} }
...@@ -838,9 +838,9 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -838,9 +838,9 @@ public abstract class BaseQuestion extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet quest_linPSet = allSets.getPersistentSet (objectID, "quest_lin"); PersistentSet rs_quest_linPSet = allSets.getPersistentSet (objectID, "rs_quest_lin");
_Description = (String)(HELPER_Description.fromObject (_Description, quest_linPSet.getAttrib (FIELD_Description))); // _Description = (String)(HELPER_Description.fromObject (_Description, rs_quest_linPSet.getAttrib (FIELD_Description))); //
_Section.setFromPersistentSets (objectID, allSets); _Section.setFromPersistentSets (objectID, allSets);
} }
...@@ -1060,32 +1060,32 @@ public abstract class BaseQuestion extends BaseBusinessClass ...@@ -1060,32 +1060,32 @@ public abstract class BaseQuestion extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "quest_lin.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_quest_lin.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "quest_lin.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_quest_lin.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "quest_lin.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_quest_lin.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andDescription (QueryFilter<String> filter) public SearchAll andDescription (QueryFilter<String> filter)
{ {
filter.addFilter (context, "quest_lin.left_quest", "Description"); filter.addFilter (context, "rs_quest_lin.left_quest", "Description");
return this; return this;
} }
public SearchAll andSection (QueryFilter<Section> filter) public SearchAll andSection (QueryFilter<Section> filter)
{ {
filter.addFilter (context, "quest_lin.section_number", "Section"); filter.addFilter (context, "rs_quest_lin.section_number", "Section");
return this; return this;
} }
......
...@@ -762,7 +762,7 @@ public abstract class BaseSection extends BaseBusinessClass ...@@ -762,7 +762,7 @@ public abstract class BaseSection extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "quest_hdr"; return "rs_quest_hdr";
} }
...@@ -783,11 +783,11 @@ public abstract class BaseSection extends BaseBusinessClass ...@@ -783,11 +783,11 @@ public abstract class BaseSection extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet quest_hdrPSet = allSets.getPersistentSet (myID, "quest_hdr", myPSetStatus); PersistentSet rs_quest_hdrPSet = allSets.getPersistentSet (myID, "rs_quest_hdr", myPSetStatus);
quest_hdrPSet.setAttrib (FIELD_ObjectID, myID); rs_quest_hdrPSet.setAttrib (FIELD_ObjectID, myID);
quest_hdrPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); // rs_quest_hdrPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
quest_hdrPSet.setAttrib (FIELD_QuestionType, HELPER_QuestionType.toObject (_QuestionType)); // rs_quest_hdrPSet.setAttrib (FIELD_QuestionType, HELPER_QuestionType.toObject (_QuestionType)); //
} }
...@@ -800,10 +800,10 @@ public abstract class BaseSection extends BaseBusinessClass ...@@ -800,10 +800,10 @@ public abstract class BaseSection extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet quest_hdrPSet = allSets.getPersistentSet (objectID, "quest_hdr"); PersistentSet rs_quest_hdrPSet = allSets.getPersistentSet (objectID, "rs_quest_hdr");
_Description = (String)(HELPER_Description.fromObject (_Description, quest_hdrPSet.getAttrib (FIELD_Description))); // _Description = (String)(HELPER_Description.fromObject (_Description, rs_quest_hdrPSet.getAttrib (FIELD_Description))); //
_QuestionType = (QuestionType)(HELPER_QuestionType.fromObject (_QuestionType, quest_hdrPSet.getAttrib (FIELD_QuestionType))); // _QuestionType = (QuestionType)(HELPER_QuestionType.fromObject (_QuestionType, rs_quest_hdrPSet.getAttrib (FIELD_QuestionType))); //
} }
...@@ -1030,32 +1030,32 @@ public abstract class BaseSection extends BaseBusinessClass ...@@ -1030,32 +1030,32 @@ public abstract class BaseSection extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "quest_hdr.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_quest_hdr.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "quest_hdr.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_quest_hdr.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "quest_hdr.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_quest_hdr.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andDescription (QueryFilter<String> filter) public SearchAll andDescription (QueryFilter<String> filter)
{ {
filter.addFilter (context, "quest_hdr.quest_hdr_desc", "Description"); filter.addFilter (context, "rs_quest_hdr.quest_hdr_desc", "Description");
return this; return this;
} }
public SearchAll andQuestionType (QueryFilter<QuestionType> filter) public SearchAll andQuestionType (QueryFilter<QuestionType> filter)
{ {
filter.addFilter (context, "quest_hdr.quest_type_flag", "QuestionType"); filter.addFilter (context, "rs_quest_hdr.quest_type_flag", "QuestionType");
return this; return this;
} }
......
...@@ -39,7 +39,9 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -39,7 +39,9 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
// Static constants corresponding to field names // Static constants corresponding to field names
public static final String SINGLEREFERENCE_Level = "Level"; public static final String SINGLEREFERENCE_Level = "Level";
public static final String BACKREF_Level = "";
public static final String SINGLEREFERENCE_Candidate = "Candidate"; public static final String SINGLEREFERENCE_Candidate = "Candidate";
public static final String BACKREF_Candidate = "";
public static final String MULTIPLEREFERENCE_FactorScores = "FactorScores"; public static final String MULTIPLEREFERENCE_FactorScores = "FactorScores";
public static final String BACKREF_FactorScores = ""; public static final String BACKREF_FactorScores = "";
...@@ -77,6 +79,8 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -77,6 +79,8 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
{ {
String tmp_FactorScores = FactorScore.BACKREF_TestAnalysis; String tmp_FactorScores = FactorScore.BACKREF_TestAnalysis;
String tmp_Level = Level.BACKREF_TestAnalysises;
String tmp_Candidate = Candidate.BACKREF_TestAnalysises;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
...@@ -116,6 +120,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -116,6 +120,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "TestAnalysises");
metaInfo.put ("dbcol", "level_id"); metaInfo.put ("dbcol", "level_id");
metaInfo.put ("name", "Level"); metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level"); metaInfo.put ("type", "Level");
...@@ -130,6 +135,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -130,6 +135,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "TestAnalysises");
metaInfo.put ("dbcol", "candidate_id"); metaInfo.put ("dbcol", "candidate_id");
metaInfo.put ("name", "Candidate"); metaInfo.put ("name", "Candidate");
metaInfo.put ("type", "Candidate"); metaInfo.put ("type", "Candidate");
...@@ -174,8 +180,8 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -174,8 +180,8 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Level = new SingleAssociation<TestAnalysis, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "test_analysis"); _Level = new SingleAssociation<TestAnalysis, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_TestAnalysises, Level.REFERENCE_Level, "rs_test_analysis");
_Candidate = new SingleAssociation<TestAnalysis, Candidate> (this, SINGLEREFERENCE_Candidate, null, Candidate.REFERENCE_Candidate, "test_analysis"); _Candidate = new SingleAssociation<TestAnalysis, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_TestAnalysises, Candidate.REFERENCE_Candidate, "rs_test_analysis");
_FactorScores = new MultipleAssociation<TestAnalysis, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_TestAnalysis, FactorScore.REFERENCE_FactorScore); _FactorScores = new MultipleAssociation<TestAnalysis, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_TestAnalysis, FactorScore.REFERENCE_FactorScore);
} }
...@@ -186,8 +192,8 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -186,8 +192,8 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Level = new SingleAssociation<TestAnalysis, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "test_analysis"); _Level = new SingleAssociation<TestAnalysis, Level> (this, SINGLEREFERENCE_Level, Level.MULTIPLEREFERENCE_TestAnalysises, Level.REFERENCE_Level, "rs_test_analysis");
_Candidate = new SingleAssociation<TestAnalysis, Candidate> (this, SINGLEREFERENCE_Candidate, null, Candidate.REFERENCE_Candidate, "test_analysis"); _Candidate = new SingleAssociation<TestAnalysis, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_TestAnalysises, Candidate.REFERENCE_Candidate, "rs_test_analysis");
_FactorScores = new MultipleAssociation<TestAnalysis, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_TestAnalysis, FactorScore.REFERENCE_FactorScore); _FactorScores = new MultipleAssociation<TestAnalysis, FactorScore> (this, MULTIPLEREFERENCE_FactorScores, FactorScore.SINGLEREFERENCE_TestAnalysis, FactorScore.REFERENCE_FactorScore);
...@@ -243,10 +249,10 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -243,10 +249,10 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
} }
else if (assocName.equals (SINGLEREFERENCE_Level)) else if (assocName.equals (SINGLEREFERENCE_Level))
{ {
return null ; return Level.MULTIPLEREFERENCE_TestAnalysises ;
}else if (assocName.equals (SINGLEREFERENCE_Candidate)) }else if (assocName.equals (SINGLEREFERENCE_Candidate))
{ {
return null ; return Candidate.MULTIPLEREFERENCE_TestAnalysises ;
} }
else else
{ {
...@@ -423,9 +429,22 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -423,9 +429,22 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable"); Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable");
preLevelChange (newLevel); preLevelChange (newLevel);
Level oldLevel = getLevel ();
if (oldLevel != null)
{
// This is to stop validation from triggering when we are removed
_Level.set (null);
oldLevel.removeFromTestAnalysises ((TestAnalysis)(this));
}
_Level.set (newLevel); _Level.set (newLevel);
if (newLevel != null)
{
newLevel.addToTestAnalysises ((TestAnalysis)(this));
}
postLevelChange (); postLevelChange ();
} }
} }
...@@ -517,9 +536,22 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -517,9 +536,22 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
assertValid(); assertValid();
Debug.assertion (getWriteability_Candidate () != FieldWriteability.FALSE, "Assoc Candidate is not writeable"); Debug.assertion (getWriteability_Candidate () != FieldWriteability.FALSE, "Assoc Candidate is not writeable");
preCandidateChange (newCandidate); preCandidateChange (newCandidate);
Candidate oldCandidate = getCandidate ();
if (oldCandidate != null)
{
// This is to stop validation from triggering when we are removed
_Candidate.set (null);
oldCandidate.removeFromTestAnalysises ((TestAnalysis)(this));
}
_Candidate.set (newCandidate); _Candidate.set (newCandidate);
if (newCandidate != null)
{
newCandidate.addToTestAnalysises ((TestAnalysis)(this));
}
postCandidateChange (); postCandidateChange ();
} }
} }
...@@ -738,6 +770,34 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -738,6 +770,34 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
{ {
try 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 TestAnalysises from ", getObjectID (), " to ", referenced.getObjectID ());
_Level.set (null);
referenced.removeFromTestAnalysises ((TestAnalysis)this);
}
}
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_Candidate.isLoaded () || getTransaction ().isObjectLoaded (_Candidate.getReferencedType (), getCandidateID ()))
{
Candidate referenced = getCandidate ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null TestAnalysises from ", getObjectID (), " to ", referenced.getObjectID ());
_Candidate.set (null);
referenced.removeFromTestAnalysises ((TestAnalysis)this);
}
}
for(FactorScore referenced : CollectionUtils.reverse(getFactorScoresSet())) for(FactorScore referenced : CollectionUtils.reverse(getFactorScoresSet()))
{ {
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null TestAnalysis from ", getObjectID (), " to ", referenced.getObjectID ()); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null TestAnalysis from ", getObjectID (), " to ", referenced.getObjectID ());
...@@ -780,7 +840,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -780,7 +840,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "test_analysis"; return "rs_test_analysis";
} }
...@@ -801,9 +861,9 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -801,9 +861,9 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet test_analysisPSet = allSets.getPersistentSet (myID, "test_analysis", myPSetStatus); PersistentSet rs_test_analysisPSet = allSets.getPersistentSet (myID, "rs_test_analysis", myPSetStatus);
test_analysisPSet.setAttrib (FIELD_ObjectID, myID); rs_test_analysisPSet.setAttrib (FIELD_ObjectID, myID);
_Level.getPersistentSets (allSets); _Level.getPersistentSets (allSets);
_Candidate.getPersistentSets (allSets); _Candidate.getPersistentSets (allSets);
...@@ -818,7 +878,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -818,7 +878,7 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet test_analysisPSet = allSets.getPersistentSet (objectID, "test_analysis"); PersistentSet rs_test_analysisPSet = allSets.getPersistentSet (objectID, "rs_test_analysis");
_Level.setFromPersistentSets (objectID, allSets); _Level.setFromPersistentSets (objectID, allSets);
_Candidate.setFromPersistentSets (objectID, allSets); _Candidate.setFromPersistentSets (objectID, allSets);
...@@ -1032,32 +1092,32 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass ...@@ -1032,32 +1092,32 @@ public abstract class BaseTestAnalysis extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "test_analysis.object_id", FIELD_ObjectID); filter.addFilter (context, "rs_test_analysis.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "test_analysis.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "rs_test_analysis.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "test_analysis.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "rs_test_analysis.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andLevel (QueryFilter<Level> filter) public SearchAll andLevel (QueryFilter<Level> filter)
{ {
filter.addFilter (context, "test_analysis.level_id", "Level"); filter.addFilter (context, "rs_test_analysis.level_id", "Level");
return this; return this;
} }
public SearchAll andCandidate (QueryFilter<Candidate> filter) public SearchAll andCandidate (QueryFilter<Candidate> filter)
{ {
filter.addFilter (context, "test_analysis.candidate_id", "Candidate"); filter.addFilter (context, "rs_test_analysis.candidate_id", "Candidate");
return this; return this;
} }
......
...@@ -28,6 +28,7 @@ import oneit.utils.parsers.FieldException; ...@@ -28,6 +28,7 @@ import oneit.utils.parsers.FieldException;
import oneit.servlets.orm.*; import oneit.servlets.orm.*;
// __#BUILD_NO_TABLE_NAME#: No table name == No persistence manager and scripts required.
public abstract class BaseTestInput extends NonPersistentBO public abstract class BaseTestInput extends NonPersistentBO
{ {
...@@ -119,7 +120,6 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -119,7 +120,6 @@ public abstract class BaseTestInput extends NonPersistentBO
metaInfo.put ("attribHelper", "BLOBAttributeHelper"); metaInfo.put ("attribHelper", "BLOBAttributeHelper");
metaInfo.put ("attribHelperInstance", "BLOBAttributeHelper.INSTANCE"); metaInfo.put ("attribHelperInstance", "BLOBAttributeHelper.INSTANCE");
metaInfo.put ("binaryHandler", "loggedin"); metaInfo.put ("binaryHandler", "loggedin");
metaInfo.put ("dbcol", "xxxx");
metaInfo.put ("mandatory", "true"); metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "CSV"); metaInfo.put ("name", "CSV");
metaInfo.put ("type", "BinaryContent"); metaInfo.put ("type", "BinaryContent");
...@@ -642,7 +642,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -642,7 +642,7 @@ public abstract class BaseTestInput extends NonPersistentBO
public String getBaseSetName () public String getBaseSetName ()
{ {
return "it_does_not_matter"; return "";
} }
...@@ -663,10 +663,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -663,10 +663,10 @@ public abstract class BaseTestInput extends NonPersistentBO
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet it_does_not_matterPSet = allSets.getPersistentSet (myID, "it_does_not_matter", myPSetStatus); PersistentSet PSet = allSets.getPersistentSet (myID, "", myPSetStatus);
it_does_not_matterPSet.setAttrib (FIELD_ObjectID, myID); PSet.setAttrib (FIELD_ObjectID, myID);
it_does_not_matterPSet.setAttrib (FIELD_CSV, HELPER_CSV.toObject (_CSV)); // PSet.setAttrib (FIELD_CSV, HELPER_CSV.toObject (_CSV)); //
} }
...@@ -679,9 +679,9 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -679,9 +679,9 @@ public abstract class BaseTestInput extends NonPersistentBO
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet it_does_not_matterPSet = allSets.getPersistentSet (objectID, "it_does_not_matter"); PersistentSet PSet = allSets.getPersistentSet (objectID, "");
_CSV = (BinaryContent)(HELPER_CSV.fromObject (_CSV, it_does_not_matterPSet.getAttrib (FIELD_CSV))); // _CSV = (BinaryContent)(HELPER_CSV.fromObject (_CSV, PSet.getAttrib (FIELD_CSV))); //
} }
...@@ -973,6 +973,13 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -973,6 +973,13 @@ public abstract class BaseTestInput extends NonPersistentBO
super.putUnwriteable (fields); super.putUnwriteable (fields);
} }
// This generally means there's no specific persistence manager and we don't read or write from a table
public boolean hasNoTable()
{
return true;
}
public List<AbstractAttribute> getAttributes () public List<AbstractAttribute> getAttributes ()
{ {
List result = super.getAttributes (); List result = super.getAttributes ();
......
...@@ -10,4 +10,10 @@ public class Candidate extends BaseCandidate ...@@ -10,4 +10,10 @@ public class Candidate extends BaseCandidate
{ {
// 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
public String getObjectIDSpace()
{
return "Candidate";
}
} }
\ No newline at end of file
...@@ -4,28 +4,17 @@ ...@@ -4,28 +4,17 @@
<BUSINESSCLASS name="Candidate" package="performa.orm"> <BUSINESSCLASS name="Candidate" package="performa.orm">
<TABLE name="candidate" tablePrefix="object" polymorphic="FALSE"> <MULTIPLEREFERENCE name="TestAnalysises" type="TestAnalysis" backreferenceName="Candidate" />
<MULTIPLEREFERENCE name="Answers" type="Answer" backreferenceName="Candidate" />
<TABLE name="rs_candidate" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="FirstName" type="String" dbcol="first_name" length="30"/> <ATTRIB name="FirstName" type="String" dbcol="first_name" length="30"/>
<ATTRIB name="MiddleName" type="String" dbcol="middle_name" length="30"/>
<ATTRIB name="LastName" type="String" dbcol="last_name" length="30"/>
<ATTRIB name="PreferredName" type="String" dbcol="preferred_name" length="30"/>
<ATTRIB name="Salutation" type="String" dbcol="salutation" length="10"/>
<ATTRIB name="Position" type="String" dbcol="position" length="30"/>
<ATTRIB name="DateOfBirth" type="Date" dbcol="date_of_birth"/>
<ATTRIB name="DateRegistered" type="Date" dbcol="date_registered"/>
<ATTRIB name="Gender" type="String" dbcol="gender" length="10"/>
<ATTRIB name="Password" type="String" dbcol="password" length="15"/>
<ATTRIB name="DateTaken" type="Date" dbcol="date_taken"/>
<ATTRIB name="Location" type="String" dbcol="location" length="80"/>
<ATTRIB name="Phone" type="String" dbcol="contact_phone" length="80"/>
<ATTRIB name="Email" type="String" dbcol="email" length="60"/>
<SINGLEREFERENCE name="TestInput" type="TestInput" dbcol="test_input_id" backreferenceName="Candidates"/> <SINGLEREFERENCE name="TestInput" type="TestInput" dbcol="test_input_id" backreferenceName="Candidates"/>
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="candidate.object_id is not null" orderBy="candidate.object_id" /> <SEARCH type="All" paramFilter="rs_candidate.object_id is not null" orderBy="rs_candidate.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -27,36 +27,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -27,36 +27,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private String dummyFirstName; private String dummyFirstName;
private String dummyMiddleName;
private String dummyLastName;
private String dummyPreferredName;
private String dummySalutation;
private String dummyPosition;
private Date dummyDateOfBirth;
private Date dummyDateRegistered;
private String dummyGender;
private String dummyPassword;
private Date dummyDateTaken;
private String dummyLocation;
private String dummyPhone;
private String dummyEmail;
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_FirstName = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_FirstName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_MiddleName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_LastName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_PreferredName = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Salutation = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Position = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DateOfBirth = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DateRegistered = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Gender = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Password = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DateTaken = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Location = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Phone = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Email = DefaultAttributeHelper.INSTANCE;
...@@ -64,23 +38,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -64,23 +38,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
public CandidatePersistenceMgr () public CandidatePersistenceMgr ()
{ {
dummyFirstName = (String)(HELPER_FirstName.initialise (dummyFirstName)); dummyFirstName = (String)(HELPER_FirstName.initialise (dummyFirstName));
dummyMiddleName = (String)(HELPER_MiddleName.initialise (dummyMiddleName));
dummyLastName = (String)(HELPER_LastName.initialise (dummyLastName)); }
dummyPreferredName = (String)(HELPER_PreferredName.initialise (dummyPreferredName));
dummySalutation = (String)(HELPER_Salutation.initialise (dummySalutation)); private String SELECT_COLUMNS = "{PREFIX}rs_candidate.object_id as id, {PREFIX}rs_candidate.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_candidate.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_candidate.first_name, {PREFIX}rs_candidate.test_input_id, 1 AS commasafe ";
dummyPosition = (String)(HELPER_Position.initialise (dummyPosition));
dummyDateOfBirth = (Date)(HELPER_DateOfBirth.initialise (dummyDateOfBirth));
dummyDateRegistered = (Date)(HELPER_DateRegistered.initialise (dummyDateRegistered));
dummyGender = (String)(HELPER_Gender.initialise (dummyGender));
dummyPassword = (String)(HELPER_Password.initialise (dummyPassword));
dummyDateTaken = (Date)(HELPER_DateTaken.initialise (dummyDateTaken));
dummyLocation = (String)(HELPER_Location.initialise (dummyLocation));
dummyPhone = (String)(HELPER_Phone.initialise (dummyPhone));
dummyEmail = (String)(HELPER_Email.initialise (dummyEmail));
}
private String SELECT_COLUMNS = "{PREFIX}candidate.object_id as id, {PREFIX}candidate.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}candidate.object_CREATED_DATE as CREATED_DATE, {PREFIX}candidate.first_name, {PREFIX}candidate.middle_name, {PREFIX}candidate.last_name, {PREFIX}candidate.preferred_name, {PREFIX}candidate.salutation, {PREFIX}candidate.position, {PREFIX}candidate.date_of_birth, {PREFIX}candidate.date_registered, {PREFIX}candidate.gender, {PREFIX}candidate.password, {PREFIX}candidate.date_taken, {PREFIX}candidate.location, {PREFIX}candidate.contact_phone, {PREFIX}candidate.email, {PREFIX}candidate.test_input_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
...@@ -125,27 +86,14 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -125,27 +86,14 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet candidatePSet = allPSets.getPersistentSet(id, "candidate", PersistentSetStatus.FETCHED); PersistentSet rs_candidatePSet = allPSets.getPersistentSet(id, "rs_candidate", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !candidatePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_candidatePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!candidatePSet.containsAttrib(Candidate.FIELD_FirstName)|| !rs_candidatePSet.containsAttrib(Candidate.FIELD_FirstName)||
!candidatePSet.containsAttrib(Candidate.FIELD_MiddleName)|| !rs_candidatePSet.containsAttrib(Candidate.SINGLEREFERENCE_TestInput))
!candidatePSet.containsAttrib(Candidate.FIELD_LastName)||
!candidatePSet.containsAttrib(Candidate.FIELD_PreferredName)||
!candidatePSet.containsAttrib(Candidate.FIELD_Salutation)||
!candidatePSet.containsAttrib(Candidate.FIELD_Position)||
!candidatePSet.containsAttrib(Candidate.FIELD_DateOfBirth)||
!candidatePSet.containsAttrib(Candidate.FIELD_DateRegistered)||
!candidatePSet.containsAttrib(Candidate.FIELD_Gender)||
!candidatePSet.containsAttrib(Candidate.FIELD_Password)||
!candidatePSet.containsAttrib(Candidate.FIELD_DateTaken)||
!candidatePSet.containsAttrib(Candidate.FIELD_Location)||
!candidatePSet.containsAttrib(Candidate.FIELD_Phone)||
!candidatePSet.containsAttrib(Candidate.FIELD_Email)||
!candidatePSet.containsAttrib(Candidate.SINGLEREFERENCE_TestInput))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -168,8 +116,8 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -168,8 +116,8 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}candidate " + "FROM {PREFIX}rs_candidate " +
"WHERE " + SELECT_JOINS + "{PREFIX}candidate.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_candidate.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -194,7 +142,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -194,7 +142,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (Candidate.SINGLEREFERENCE_TestInput)) else if (refName.equals (Candidate.SINGLEREFERENCE_TestInput))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}candidate " + "FROM {PREFIX}rs_candidate " +
"WHERE " + SELECT_JOINS + "test_input_id = ?"; "WHERE " + SELECT_JOINS + "test_input_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -216,47 +164,47 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -216,47 +164,47 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet candidatePSet = allPSets.getPersistentSet(objectID, "candidate"); PersistentSet rs_candidatePSet = allPSets.getPersistentSet(objectID, "rs_candidate");
if (candidatePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_candidatePSet.getStatus () != PersistentSetStatus.PROCESSED &&
candidatePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_candidatePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}candidate " + "UPDATE {PREFIX}rs_candidate " +
"SET first_name = ?, middle_name = ?, last_name = ?, preferred_name = ?, salutation = ?, position = ?, date_of_birth = ?, date_registered = ?, gender = ?, password = ?, date_taken = ?, location = ?, contact_phone = ?, email = ?, test_input_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET first_name = ?, test_input_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE candidate.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_candidate.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_FirstName.getForSQL(dummyFirstName, candidatePSet.getAttrib (Candidate.FIELD_FirstName))).listEntry (HELPER_MiddleName.getForSQL(dummyMiddleName, candidatePSet.getAttrib (Candidate.FIELD_MiddleName))).listEntry (HELPER_LastName.getForSQL(dummyLastName, candidatePSet.getAttrib (Candidate.FIELD_LastName))).listEntry (HELPER_PreferredName.getForSQL(dummyPreferredName, candidatePSet.getAttrib (Candidate.FIELD_PreferredName))).listEntry (HELPER_Salutation.getForSQL(dummySalutation, candidatePSet.getAttrib (Candidate.FIELD_Salutation))).listEntry (HELPER_Position.getForSQL(dummyPosition, candidatePSet.getAttrib (Candidate.FIELD_Position))).listEntry (HELPER_DateOfBirth.getForSQL(dummyDateOfBirth, candidatePSet.getAttrib (Candidate.FIELD_DateOfBirth))).listEntry (HELPER_DateRegistered.getForSQL(dummyDateRegistered, candidatePSet.getAttrib (Candidate.FIELD_DateRegistered))).listEntry (HELPER_Gender.getForSQL(dummyGender, candidatePSet.getAttrib (Candidate.FIELD_Gender))).listEntry (HELPER_Password.getForSQL(dummyPassword, candidatePSet.getAttrib (Candidate.FIELD_Password))).listEntry (HELPER_DateTaken.getForSQL(dummyDateTaken, candidatePSet.getAttrib (Candidate.FIELD_DateTaken))).listEntry (HELPER_Location.getForSQL(dummyLocation, candidatePSet.getAttrib (Candidate.FIELD_Location))).listEntry (HELPER_Phone.getForSQL(dummyPhone, candidatePSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_Email.getForSQL(dummyEmail, candidatePSet.getAttrib (Candidate.FIELD_Email))).listEntry (SQLManager.CheckNull((Long)(candidatePSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FirstName.getForSQL(dummyFirstName, rs_candidatePSet.getAttrib (Candidate.FIELD_FirstName))).listEntry (SQLManager.CheckNull((Long)(rs_candidatePSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}candidate WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_candidate WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "candidate", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_candidate", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (CandidatePersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (CandidatePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "candidate"); throw new ConcurrentUpdateConflictException (obj, "rs_candidate");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:candidate for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_candidate for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CandidatePersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (CandidatePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
candidatePSet.setStatus (PersistentSetStatus.PROCESSED); rs_candidatePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -271,42 +219,42 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -271,42 +219,42 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet candidatePSet = allPSets.getPersistentSet(objectID, "candidate"); PersistentSet rs_candidatePSet = allPSets.getPersistentSet(objectID, "rs_candidate");
LogMgr.log (CandidatePersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (CandidatePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (candidatePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_candidatePSet.getStatus () != PersistentSetStatus.PROCESSED &&
candidatePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_candidatePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}candidate " + "FROM {PREFIX}rs_candidate " +
"WHERE candidate.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_candidate.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}candidate WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_candidate WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "candidate"); throw new ConcurrentUpdateConflictException (obj, "rs_candidate");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:candidate for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_candidate for row:" + objectID;
LogMgr.log (CandidatePersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (CandidatePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
candidatePSet.setStatus (PersistentSetStatus.PROCESSED); rs_candidatePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -361,7 +309,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -361,7 +309,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet candidatePSet = allPSets.getPersistentSet(objectID, "candidate", PersistentSetStatus.FETCHED); PersistentSet rs_candidatePSet = allPSets.getPersistentSet(objectID, "rs_candidate", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -420,7 +368,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -420,7 +368,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}candidate " + tables + "FROM {PREFIX}rs_candidate " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -436,12 +384,12 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -436,12 +384,12 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY candidate.object_id"; String orderBy = " ORDER BY rs_candidate.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: candidate.object_id is not null Object[] searchParams; // paramFilter: rs_candidate.object_id is not null
String preFilter = "(candidate.object_id is not null)" String preFilter = "(rs_candidate.object_id is not null)"
+ " "; + " ";
...@@ -456,7 +404,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -456,7 +404,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}candidate " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_candidate " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -476,30 +424,17 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -476,30 +424,17 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet candidatePSet = allPSets.getPersistentSet(objectID, "candidate", PersistentSetStatus.FETCHED); PersistentSet rs_candidatePSet = allPSets.getPersistentSet(objectID, "rs_candidate", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
candidatePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_candidatePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
candidatePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_candidatePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
candidatePSet.setAttrib(Candidate.FIELD_FirstName, HELPER_FirstName.getFromRS(dummyFirstName, r, "first_name")); rs_candidatePSet.setAttrib(Candidate.FIELD_FirstName, HELPER_FirstName.getFromRS(dummyFirstName, r, "first_name"));
candidatePSet.setAttrib(Candidate.FIELD_MiddleName, HELPER_MiddleName.getFromRS(dummyMiddleName, r, "middle_name"));
candidatePSet.setAttrib(Candidate.FIELD_LastName, HELPER_LastName.getFromRS(dummyLastName, r, "last_name"));
candidatePSet.setAttrib(Candidate.FIELD_PreferredName, HELPER_PreferredName.getFromRS(dummyPreferredName, r, "preferred_name"));
candidatePSet.setAttrib(Candidate.FIELD_Salutation, HELPER_Salutation.getFromRS(dummySalutation, r, "salutation"));
candidatePSet.setAttrib(Candidate.FIELD_Position, HELPER_Position.getFromRS(dummyPosition, r, "position"));
candidatePSet.setAttrib(Candidate.FIELD_DateOfBirth, HELPER_DateOfBirth.getFromRS(dummyDateOfBirth, r, "date_of_birth"));
candidatePSet.setAttrib(Candidate.FIELD_DateRegistered, HELPER_DateRegistered.getFromRS(dummyDateRegistered, r, "date_registered"));
candidatePSet.setAttrib(Candidate.FIELD_Gender, HELPER_Gender.getFromRS(dummyGender, r, "gender"));
candidatePSet.setAttrib(Candidate.FIELD_Password, HELPER_Password.getFromRS(dummyPassword, r, "password"));
candidatePSet.setAttrib(Candidate.FIELD_DateTaken, HELPER_DateTaken.getFromRS(dummyDateTaken, r, "date_taken"));
candidatePSet.setAttrib(Candidate.FIELD_Location, HELPER_Location.getFromRS(dummyLocation, r, "location"));
candidatePSet.setAttrib(Candidate.FIELD_Phone, HELPER_Phone.getFromRS(dummyPhone, r, "contact_phone"));
candidatePSet.setAttrib(Candidate.FIELD_Email, HELPER_Email.getFromRS(dummyEmail, r, "email"));
candidatePSet.setAttrib(Candidate.SINGLEREFERENCE_TestInput, r.getObject ("test_input_id")); rs_candidatePSet.setAttrib(Candidate.SINGLEREFERENCE_TestInput, r.getObject ("test_input_id"));
} }
...@@ -507,21 +442,21 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -507,21 +442,21 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet candidatePSet = allPSets.getPersistentSet(objectID, "candidate"); PersistentSet rs_candidatePSet = allPSets.getPersistentSet(objectID, "rs_candidate");
if (candidatePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_candidatePSet.getStatus () != PersistentSetStatus.PROCESSED &&
candidatePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_candidatePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}candidate " + "INSERT INTO {PREFIX}rs_candidate " +
" (first_name, middle_name, last_name, preferred_name, salutation, position, date_of_birth, date_registered, gender, password, date_taken, location, contact_phone, email, test_input_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (first_name, test_input_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_FirstName.getForSQL(dummyFirstName, candidatePSet.getAttrib (Candidate.FIELD_FirstName))).listEntry (HELPER_MiddleName.getForSQL(dummyMiddleName, candidatePSet.getAttrib (Candidate.FIELD_MiddleName))).listEntry (HELPER_LastName.getForSQL(dummyLastName, candidatePSet.getAttrib (Candidate.FIELD_LastName))).listEntry (HELPER_PreferredName.getForSQL(dummyPreferredName, candidatePSet.getAttrib (Candidate.FIELD_PreferredName))).listEntry (HELPER_Salutation.getForSQL(dummySalutation, candidatePSet.getAttrib (Candidate.FIELD_Salutation))).listEntry (HELPER_Position.getForSQL(dummyPosition, candidatePSet.getAttrib (Candidate.FIELD_Position))).listEntry (HELPER_DateOfBirth.getForSQL(dummyDateOfBirth, candidatePSet.getAttrib (Candidate.FIELD_DateOfBirth))).listEntry (HELPER_DateRegistered.getForSQL(dummyDateRegistered, candidatePSet.getAttrib (Candidate.FIELD_DateRegistered))).listEntry (HELPER_Gender.getForSQL(dummyGender, candidatePSet.getAttrib (Candidate.FIELD_Gender))).listEntry (HELPER_Password.getForSQL(dummyPassword, candidatePSet.getAttrib (Candidate.FIELD_Password))).listEntry (HELPER_DateTaken.getForSQL(dummyDateTaken, candidatePSet.getAttrib (Candidate.FIELD_DateTaken))).listEntry (HELPER_Location.getForSQL(dummyLocation, candidatePSet.getAttrib (Candidate.FIELD_Location))).listEntry (HELPER_Phone.getForSQL(dummyPhone, candidatePSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_Email.getForSQL(dummyEmail, candidatePSet.getAttrib (Candidate.FIELD_Email))) .listEntry (SQLManager.CheckNull((Long)(candidatePSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FirstName.getForSQL(dummyFirstName, rs_candidatePSet.getAttrib (Candidate.FIELD_FirstName))) .listEntry (SQLManager.CheckNull((Long)(rs_candidatePSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))) .listEntry (objectID.longID ()).toList().toArray());
candidatePSet.setStatus (PersistentSetStatus.PROCESSED); rs_candidatePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class Factor extends BaseFactor ...@@ -10,4 +10,10 @@ public class Factor extends BaseFactor
{ {
// 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
public String getObjectIDSpace()
{
return "Factor";
}
} }
\ No newline at end of file
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
<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" />
<TABLE name="factor" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_factor" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="factor_hdr_desc" length="30"/> <ATTRIB name="Description" type="String" dbcol="factor_hdr_desc" length="30"/>
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="factor.object_id is not null" orderBy="factor.object_id" /> <SEARCH type="All" paramFilter="rs_factor.object_id is not null" orderBy="rs_factor.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -10,4 +10,10 @@ public class FactorLevelLink extends BaseFactorLevelLink ...@@ -10,4 +10,10 @@ public class FactorLevelLink extends BaseFactorLevelLink
{ {
// 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
public String getObjectIDSpace()
{
return "FactorLevelLink";
}
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<BUSINESSCLASS name="FactorLevelLink" package="performa.orm"> <BUSINESSCLASS name="FactorLevelLink" package="performa.orm">
<TABLE name="factor_hdr" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_factor_hdr" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="ClassCode" type="String" dbcol="class_code" length="15"/> <ATTRIB name="ClassCode" type="String" dbcol="class_code" length="15"/>
<ATTRIB name="Notes" type="String" dbcol="factor_hdr_notes"/> <ATTRIB name="Notes" type="String" dbcol="factor_hdr_notes"/>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="factor_hdr.object_id is not null" orderBy="factor_hdr.object_id" /> <SEARCH type="All" paramFilter="rs_factor_hdr.object_id is not null" orderBy="factor_hdr.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -56,7 +56,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -56,7 +56,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}factor_hdr.object_id as id, {PREFIX}factor_hdr.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}factor_hdr.object_CREATED_DATE as CREATED_DATE, {PREFIX}factor_hdr.class_code, {PREFIX}factor_hdr.factor_hdr_notes, {PREFIX}factor_hdr.left_annot, {PREFIX}factor_hdr.right_annot, {PREFIX}factor_hdr.z_score_wght, {PREFIX}factor_hdr.z_score_wght_2, {PREFIX}factor_hdr.level_number, {PREFIX}factor_hdr.factor_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_factor_hdr.object_id as id, {PREFIX}rs_factor_hdr.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_factor_hdr.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_factor_hdr.class_code, {PREFIX}rs_factor_hdr.factor_hdr_notes, {PREFIX}rs_factor_hdr.left_annot, {PREFIX}rs_factor_hdr.right_annot, {PREFIX}rs_factor_hdr.z_score_wght, {PREFIX}rs_factor_hdr.z_score_wght_2, {PREFIX}rs_factor_hdr.level_number, {PREFIX}rs_factor_hdr.factor_number, 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
...@@ -101,20 +101,20 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -101,20 +101,20 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet factor_hdrPSet = allPSets.getPersistentSet(id, "factor_hdr", PersistentSetStatus.FETCHED); PersistentSet rs_factor_hdrPSet = allPSets.getPersistentSet(id, "rs_factor_hdr", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !factor_hdrPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_factor_hdrPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_ClassCode)|| !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_ClassCode)||
!factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_Notes)|| !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_Notes)||
!factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_LeftAnnot)|| !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_LeftAnnot)||
!factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_RightAnnot)|| !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_RightAnnot)||
!factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_ZScoreWeight)|| !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_ZScoreWeight)||
!factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_ZScoreWeight2)|| !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.FIELD_ZScoreWeight2)||
!factor_hdrPSet.containsAttrib(FactorLevelLink.SINGLEREFERENCE_Level)|| !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.SINGLEREFERENCE_Level)||
!factor_hdrPSet.containsAttrib(FactorLevelLink.SINGLEREFERENCE_Factor)) !rs_factor_hdrPSet.containsAttrib(FactorLevelLink.SINGLEREFERENCE_Factor))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -137,8 +137,8 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -137,8 +137,8 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_hdr " + "FROM {PREFIX}rs_factor_hdr " +
"WHERE " + SELECT_JOINS + "{PREFIX}factor_hdr.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_factor_hdr.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -163,7 +163,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -163,7 +163,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorLevelLink.SINGLEREFERENCE_Level)) else if (refName.equals (FactorLevelLink.SINGLEREFERENCE_Level))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_hdr " + "FROM {PREFIX}rs_factor_hdr " +
"WHERE " + SELECT_JOINS + "level_number = ?"; "WHERE " + SELECT_JOINS + "level_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -173,7 +173,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -173,7 +173,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorLevelLink.SINGLEREFERENCE_Factor)) else if (refName.equals (FactorLevelLink.SINGLEREFERENCE_Factor))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_hdr " + "FROM {PREFIX}rs_factor_hdr " +
"WHERE " + SELECT_JOINS + "factor_number = ?"; "WHERE " + SELECT_JOINS + "factor_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -195,47 +195,47 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -195,47 +195,47 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet factor_hdrPSet = allPSets.getPersistentSet(objectID, "factor_hdr"); PersistentSet rs_factor_hdrPSet = allPSets.getPersistentSet(objectID, "rs_factor_hdr");
if (factor_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factor_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factor_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factor_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}factor_hdr " + "UPDATE {PREFIX}rs_factor_hdr " +
"SET class_code = ?, factor_hdr_notes = ?, left_annot = ?, right_annot = ?, z_score_wght = ?, z_score_wght_2 = ?, level_number = ? , factor_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET class_code = ?, factor_hdr_notes = ?, left_annot = ?, right_annot = ?, z_score_wght = ?, z_score_wght_2 = ?, level_number = ? , factor_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE factor_hdr.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_factor_hdr.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_ClassCode.getForSQL(dummyClassCode, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ClassCode))).listEntry (HELPER_Notes.getForSQL(dummyNotes, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_Notes))).listEntry (HELPER_LeftAnnot.getForSQL(dummyLeftAnnot, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_LeftAnnot))).listEntry (HELPER_RightAnnot.getForSQL(dummyRightAnnot, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_RightAnnot))).listEntry (HELPER_ZScoreWeight.getForSQL(dummyZScoreWeight, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight))).listEntry (HELPER_ZScoreWeight2.getForSQL(dummyZScoreWeight2, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight2))).listEntry (SQLManager.CheckNull((Long)(factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Factor)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_ClassCode.getForSQL(dummyClassCode, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ClassCode))).listEntry (HELPER_Notes.getForSQL(dummyNotes, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_Notes))).listEntry (HELPER_LeftAnnot.getForSQL(dummyLeftAnnot, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_LeftAnnot))).listEntry (HELPER_RightAnnot.getForSQL(dummyRightAnnot, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_RightAnnot))).listEntry (HELPER_ZScoreWeight.getForSQL(dummyZScoreWeight, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight))).listEntry (HELPER_ZScoreWeight2.getForSQL(dummyZScoreWeight2, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight2))).listEntry (SQLManager.CheckNull((Long)(rs_factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Factor)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}factor_hdr WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_factor_hdr WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "factor_hdr", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_factor_hdr", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (FactorLevelLinkPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorLevelLinkPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "factor_hdr"); throw new ConcurrentUpdateConflictException (obj, "rs_factor_hdr");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:factor_hdr for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_factor_hdr for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (FactorLevelLinkPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorLevelLinkPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
factor_hdrPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factor_hdrPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -250,42 +250,42 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -250,42 +250,42 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet factor_hdrPSet = allPSets.getPersistentSet(objectID, "factor_hdr"); PersistentSet rs_factor_hdrPSet = allPSets.getPersistentSet(objectID, "rs_factor_hdr");
LogMgr.log (FactorLevelLinkPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (FactorLevelLinkPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (factor_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factor_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factor_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factor_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}factor_hdr " + "FROM {PREFIX}rs_factor_hdr " +
"WHERE factor_hdr.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_factor_hdr.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}factor_hdr WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_factor_hdr WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "factor_hdr"); throw new ConcurrentUpdateConflictException (obj, "rs_factor_hdr");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:factor_hdr for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_factor_hdr for row:" + objectID;
LogMgr.log (FactorLevelLinkPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (FactorLevelLinkPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
factor_hdrPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factor_hdrPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -340,7 +340,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -340,7 +340,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet factor_hdrPSet = allPSets.getPersistentSet(objectID, "factor_hdr", PersistentSetStatus.FETCHED); PersistentSet rs_factor_hdrPSet = allPSets.getPersistentSet(objectID, "rs_factor_hdr", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -399,7 +399,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -399,7 +399,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_hdr " + tables + "FROM {PREFIX}rs_factor_hdr " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -419,8 +419,8 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -419,8 +419,8 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: factor_hdr.object_id is not null Object[] searchParams; // paramFilter: rs_factor_hdr.object_id is not null
String preFilter = "(factor_hdr.object_id is not null)" String preFilter = "(rs_factor_hdr.object_id is not null)"
+ " "; + " ";
...@@ -435,7 +435,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -435,7 +435,7 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_hdr " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_factor_hdr " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -455,23 +455,23 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -455,23 +455,23 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet factor_hdrPSet = allPSets.getPersistentSet(objectID, "factor_hdr", PersistentSetStatus.FETCHED); PersistentSet rs_factor_hdrPSet = allPSets.getPersistentSet(objectID, "rs_factor_hdr", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
factor_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_factor_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
factor_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_factor_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_ClassCode, HELPER_ClassCode.getFromRS(dummyClassCode, r, "class_code")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_ClassCode, HELPER_ClassCode.getFromRS(dummyClassCode, r, "class_code"));
factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_Notes, HELPER_Notes.getFromRS(dummyNotes, r, "factor_hdr_notes")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_Notes, HELPER_Notes.getFromRS(dummyNotes, r, "factor_hdr_notes"));
factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_LeftAnnot, HELPER_LeftAnnot.getFromRS(dummyLeftAnnot, r, "left_annot")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_LeftAnnot, HELPER_LeftAnnot.getFromRS(dummyLeftAnnot, r, "left_annot"));
factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_RightAnnot, HELPER_RightAnnot.getFromRS(dummyRightAnnot, r, "right_annot")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_RightAnnot, HELPER_RightAnnot.getFromRS(dummyRightAnnot, r, "right_annot"));
factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_ZScoreWeight, HELPER_ZScoreWeight.getFromRS(dummyZScoreWeight, r, "z_score_wght")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_ZScoreWeight, HELPER_ZScoreWeight.getFromRS(dummyZScoreWeight, r, "z_score_wght"));
factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_ZScoreWeight2, HELPER_ZScoreWeight2.getFromRS(dummyZScoreWeight2, r, "z_score_wght_2")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.FIELD_ZScoreWeight2, HELPER_ZScoreWeight2.getFromRS(dummyZScoreWeight2, r, "z_score_wght_2"));
factor_hdrPSet.setAttrib(FactorLevelLink.SINGLEREFERENCE_Level, r.getObject ("level_number")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.SINGLEREFERENCE_Level, r.getObject ("level_number"));
factor_hdrPSet.setAttrib(FactorLevelLink.SINGLEREFERENCE_Factor, r.getObject ("factor_number")); rs_factor_hdrPSet.setAttrib(FactorLevelLink.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
} }
...@@ -479,21 +479,21 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -479,21 +479,21 @@ public class FactorLevelLinkPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet factor_hdrPSet = allPSets.getPersistentSet(objectID, "factor_hdr"); PersistentSet rs_factor_hdrPSet = allPSets.getPersistentSet(objectID, "rs_factor_hdr");
if (factor_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factor_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factor_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factor_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}factor_hdr " + "INSERT INTO {PREFIX}rs_factor_hdr " +
" (class_code, factor_hdr_notes, left_annot, right_annot, z_score_wght, z_score_wght_2, level_number, factor_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (class_code, factor_hdr_notes, left_annot, right_annot, z_score_wght, z_score_wght_2, level_number, factor_number, 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_ClassCode.getForSQL(dummyClassCode, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ClassCode))).listEntry (HELPER_Notes.getForSQL(dummyNotes, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_Notes))).listEntry (HELPER_LeftAnnot.getForSQL(dummyLeftAnnot, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_LeftAnnot))).listEntry (HELPER_RightAnnot.getForSQL(dummyRightAnnot, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_RightAnnot))).listEntry (HELPER_ZScoreWeight.getForSQL(dummyZScoreWeight, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight))).listEntry (HELPER_ZScoreWeight2.getForSQL(dummyZScoreWeight2, factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight2))) .listEntry (SQLManager.CheckNull((Long)(factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Factor)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_ClassCode.getForSQL(dummyClassCode, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ClassCode))).listEntry (HELPER_Notes.getForSQL(dummyNotes, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_Notes))).listEntry (HELPER_LeftAnnot.getForSQL(dummyLeftAnnot, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_LeftAnnot))).listEntry (HELPER_RightAnnot.getForSQL(dummyRightAnnot, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_RightAnnot))).listEntry (HELPER_ZScoreWeight.getForSQL(dummyZScoreWeight, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight))).listEntry (HELPER_ZScoreWeight2.getForSQL(dummyZScoreWeight2, rs_factor_hdrPSet.getAttrib (FactorLevelLink.FIELD_ZScoreWeight2))) .listEntry (SQLManager.CheckNull((Long)(rs_factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_factor_hdrPSet.getAttrib (FactorLevelLink.SINGLEREFERENCE_Factor)))) .listEntry (objectID.longID ()).toList().toArray());
factor_hdrPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factor_hdrPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -41,7 +41,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -41,7 +41,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}factor.object_id as id, {PREFIX}factor.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}factor.object_CREATED_DATE as CREATED_DATE, {PREFIX}factor.factor_hdr_desc, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_factor.object_id as id, {PREFIX}rs_factor.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_factor.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_factor.factor_hdr_desc, 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
...@@ -86,13 +86,13 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -86,13 +86,13 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet factorPSet = allPSets.getPersistentSet(id, "factor", PersistentSetStatus.FETCHED); PersistentSet rs_factorPSet = allPSets.getPersistentSet(id, "rs_factor", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !factorPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_factorPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!factorPSet.containsAttrib(Factor.FIELD_Description)) !rs_factorPSet.containsAttrib(Factor.FIELD_Description))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -115,8 +115,8 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -115,8 +115,8 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor " + "FROM {PREFIX}rs_factor " +
"WHERE " + SELECT_JOINS + "{PREFIX}factor.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_factor.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -153,47 +153,47 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -153,47 +153,47 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet factorPSet = allPSets.getPersistentSet(objectID, "factor"); PersistentSet rs_factorPSet = allPSets.getPersistentSet(objectID, "rs_factor");
if (factorPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factorPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factorPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factorPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}factor " + "UPDATE {PREFIX}rs_factor " +
"SET factor_hdr_desc = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET factor_hdr_desc = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE factor.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_factor.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, factorPSet.getAttrib (Factor.FIELD_Description))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_factorPSet.getAttrib (Factor.FIELD_Description))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}factor WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_factor WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "factor", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_factor", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (FactorPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "factor"); throw new ConcurrentUpdateConflictException (obj, "rs_factor");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:factor for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_factor for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (FactorPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
factorPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factorPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -208,42 +208,42 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -208,42 +208,42 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet factorPSet = allPSets.getPersistentSet(objectID, "factor"); PersistentSet rs_factorPSet = allPSets.getPersistentSet(objectID, "rs_factor");
LogMgr.log (FactorPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (FactorPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (factorPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factorPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factorPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factorPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}factor " + "FROM {PREFIX}rs_factor " +
"WHERE factor.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_factor.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}factor WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_factor WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "factor"); throw new ConcurrentUpdateConflictException (obj, "rs_factor");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:factor for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_factor for row:" + objectID;
LogMgr.log (FactorPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (FactorPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
factorPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factorPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -298,7 +298,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -298,7 +298,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet factorPSet = allPSets.getPersistentSet(objectID, "factor", PersistentSetStatus.FETCHED); PersistentSet rs_factorPSet = allPSets.getPersistentSet(objectID, "rs_factor", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -357,7 +357,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -357,7 +357,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor " + tables + "FROM {PREFIX}rs_factor " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -373,12 +373,12 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -373,12 +373,12 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY factor.object_id"; String orderBy = " ORDER BY rs_factor.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: factor.object_id is not null Object[] searchParams; // paramFilter: rs_factor.object_id is not null
String preFilter = "(factor.object_id is not null)" String preFilter = "(rs_factor.object_id is not null)"
+ " "; + " ";
...@@ -393,7 +393,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -393,7 +393,7 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_factor " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -413,15 +413,15 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -413,15 +413,15 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet factorPSet = allPSets.getPersistentSet(objectID, "factor", PersistentSetStatus.FETCHED); PersistentSet rs_factorPSet = allPSets.getPersistentSet(objectID, "rs_factor", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
factorPSet.setAttrib(Factor.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "factor_hdr_desc")); rs_factorPSet.setAttrib(Factor.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "factor_hdr_desc"));
} }
...@@ -430,21 +430,21 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr ...@@ -430,21 +430,21 @@ public class FactorPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet factorPSet = allPSets.getPersistentSet(objectID, "factor"); PersistentSet rs_factorPSet = allPSets.getPersistentSet(objectID, "rs_factor");
if (factorPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factorPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factorPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factorPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}factor " + "INSERT INTO {PREFIX}rs_factor " +
" (factor_hdr_desc, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (factor_hdr_desc, 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, factorPSet.getAttrib (Factor.FIELD_Description))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_factorPSet.getAttrib (Factor.FIELD_Description))) .listEntry (objectID.longID ()).toList().toArray());
factorPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factorPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class FactorQuestionLink extends BaseFactorQuestionLink ...@@ -10,4 +10,10 @@ public class FactorQuestionLink extends BaseFactorQuestionLink
{ {
// 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
public String getObjectIDSpace()
{
return "FactorQuestionLink";
}
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<BUSINESSCLASS name="FactorQuestionLink" package="performa.orm"> <BUSINESSCLASS name="FactorQuestionLink" package="performa.orm">
<TABLE name="factor_lin" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_factor_lin" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="ReverseScore" type="Boolean" dbcol="reverse_score_flag"/> <ATTRIB name="ReverseScore" type="Boolean" dbcol="reverse_score_flag"/>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="factor_lin.object_id is not null" orderBy="factor_lin.object_id" /> <SEARCH type="All" paramFilter="rs_factor_lin.object_id is not null" orderBy="rs_factor_lin.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -41,7 +41,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -41,7 +41,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}factor_lin.object_id as id, {PREFIX}factor_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}factor_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}factor_lin.reverse_score_flag, {PREFIX}factor_lin.factor_number, {PREFIX}factor_lin.quest_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_factor_lin.object_id as id, {PREFIX}rs_factor_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_factor_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_factor_lin.reverse_score_flag, {PREFIX}rs_factor_lin.factor_number, {PREFIX}rs_factor_lin.quest_number, 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
...@@ -86,15 +86,15 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -86,15 +86,15 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet factor_linPSet = allPSets.getPersistentSet(id, "factor_lin", PersistentSetStatus.FETCHED); PersistentSet rs_factor_linPSet = allPSets.getPersistentSet(id, "rs_factor_lin", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !factor_linPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_factor_linPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!factor_linPSet.containsAttrib(FactorQuestionLink.FIELD_ReverseScore)|| !rs_factor_linPSet.containsAttrib(FactorQuestionLink.FIELD_ReverseScore)||
!factor_linPSet.containsAttrib(FactorQuestionLink.SINGLEREFERENCE_Factor)|| !rs_factor_linPSet.containsAttrib(FactorQuestionLink.SINGLEREFERENCE_Factor)||
!factor_linPSet.containsAttrib(FactorQuestionLink.SINGLEREFERENCE_Question)) !rs_factor_linPSet.containsAttrib(FactorQuestionLink.SINGLEREFERENCE_Question))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -117,8 +117,8 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -117,8 +117,8 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_lin " + "FROM {PREFIX}rs_factor_lin " +
"WHERE " + SELECT_JOINS + "{PREFIX}factor_lin.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_factor_lin.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -143,7 +143,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -143,7 +143,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorQuestionLink.SINGLEREFERENCE_Factor)) else if (refName.equals (FactorQuestionLink.SINGLEREFERENCE_Factor))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_lin " + "FROM {PREFIX}rs_factor_lin " +
"WHERE " + SELECT_JOINS + "factor_number = ?"; "WHERE " + SELECT_JOINS + "factor_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -153,7 +153,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -153,7 +153,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorQuestionLink.SINGLEREFERENCE_Question)) else if (refName.equals (FactorQuestionLink.SINGLEREFERENCE_Question))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_lin " + "FROM {PREFIX}rs_factor_lin " +
"WHERE " + SELECT_JOINS + "quest_number = ?"; "WHERE " + SELECT_JOINS + "quest_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -175,47 +175,47 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -175,47 +175,47 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet factor_linPSet = allPSets.getPersistentSet(objectID, "factor_lin"); PersistentSet rs_factor_linPSet = allPSets.getPersistentSet(objectID, "rs_factor_lin");
if (factor_linPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factor_linPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factor_linPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factor_linPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}factor_lin " + "UPDATE {PREFIX}rs_factor_lin " +
"SET reverse_score_flag = ?, factor_number = ? , quest_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET reverse_score_flag = ?, factor_number = ? , quest_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE factor_lin.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_factor_lin.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_ReverseScore.getForSQL(dummyReverseScore, factor_linPSet.getAttrib (FactorQuestionLink.FIELD_ReverseScore))).listEntry (SQLManager.CheckNull((Long)(factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Question)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_ReverseScore.getForSQL(dummyReverseScore, rs_factor_linPSet.getAttrib (FactorQuestionLink.FIELD_ReverseScore))).listEntry (SQLManager.CheckNull((Long)(rs_factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Question)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}factor_lin WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_factor_lin WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "factor_lin", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_factor_lin", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (FactorQuestionLinkPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorQuestionLinkPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "factor_lin"); throw new ConcurrentUpdateConflictException (obj, "rs_factor_lin");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:factor_lin for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_factor_lin for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (FactorQuestionLinkPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorQuestionLinkPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
factor_linPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factor_linPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -230,42 +230,42 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -230,42 +230,42 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet factor_linPSet = allPSets.getPersistentSet(objectID, "factor_lin"); PersistentSet rs_factor_linPSet = allPSets.getPersistentSet(objectID, "rs_factor_lin");
LogMgr.log (FactorQuestionLinkPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (FactorQuestionLinkPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (factor_linPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factor_linPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factor_linPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factor_linPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}factor_lin " + "FROM {PREFIX}rs_factor_lin " +
"WHERE factor_lin.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_factor_lin.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}factor_lin WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_factor_lin WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "factor_lin"); throw new ConcurrentUpdateConflictException (obj, "rs_factor_lin");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:factor_lin for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_factor_lin for row:" + objectID;
LogMgr.log (FactorQuestionLinkPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (FactorQuestionLinkPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
factor_linPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factor_linPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -320,7 +320,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -320,7 +320,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet factor_linPSet = allPSets.getPersistentSet(objectID, "factor_lin", PersistentSetStatus.FETCHED); PersistentSet rs_factor_linPSet = allPSets.getPersistentSet(objectID, "rs_factor_lin", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -379,7 +379,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -379,7 +379,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_lin " + tables + "FROM {PREFIX}rs_factor_lin " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -395,12 +395,12 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -395,12 +395,12 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY factor_lin.object_id"; String orderBy = " ORDER BY rs_factor_lin.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: factor_lin.object_id is not null Object[] searchParams; // paramFilter: rs_factor_lin.object_id is not null
String preFilter = "(factor_lin.object_id is not null)" String preFilter = "(rs_factor_lin.object_id is not null)"
+ " "; + " ";
...@@ -415,7 +415,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -415,7 +415,7 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}factor_lin " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_factor_lin " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -435,18 +435,18 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -435,18 +435,18 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet factor_linPSet = allPSets.getPersistentSet(objectID, "factor_lin", PersistentSetStatus.FETCHED); PersistentSet rs_factor_linPSet = allPSets.getPersistentSet(objectID, "rs_factor_lin", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
factor_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_factor_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
factor_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_factor_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
factor_linPSet.setAttrib(FactorQuestionLink.FIELD_ReverseScore, HELPER_ReverseScore.getFromRS(dummyReverseScore, r, "reverse_score_flag")); rs_factor_linPSet.setAttrib(FactorQuestionLink.FIELD_ReverseScore, HELPER_ReverseScore.getFromRS(dummyReverseScore, r, "reverse_score_flag"));
factor_linPSet.setAttrib(FactorQuestionLink.SINGLEREFERENCE_Factor, r.getObject ("factor_number")); rs_factor_linPSet.setAttrib(FactorQuestionLink.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
factor_linPSet.setAttrib(FactorQuestionLink.SINGLEREFERENCE_Question, r.getObject ("quest_number")); rs_factor_linPSet.setAttrib(FactorQuestionLink.SINGLEREFERENCE_Question, r.getObject ("quest_number"));
} }
...@@ -454,21 +454,21 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr ...@@ -454,21 +454,21 @@ public class FactorQuestionLinkPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet factor_linPSet = allPSets.getPersistentSet(objectID, "factor_lin"); PersistentSet rs_factor_linPSet = allPSets.getPersistentSet(objectID, "rs_factor_lin");
if (factor_linPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_factor_linPSet.getStatus () != PersistentSetStatus.PROCESSED &&
factor_linPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_factor_linPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}factor_lin " + "INSERT INTO {PREFIX}rs_factor_lin " +
" (reverse_score_flag, factor_number, quest_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (reverse_score_flag, factor_number, quest_number, 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_ReverseScore.getForSQL(dummyReverseScore, factor_linPSet.getAttrib (FactorQuestionLink.FIELD_ReverseScore))) .listEntry (SQLManager.CheckNull((Long)(factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Question)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_ReverseScore.getForSQL(dummyReverseScore, rs_factor_linPSet.getAttrib (FactorQuestionLink.FIELD_ReverseScore))) .listEntry (SQLManager.CheckNull((Long)(rs_factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_factor_linPSet.getAttrib (FactorQuestionLink.SINGLEREFERENCE_Question)))) .listEntry (objectID.longID ()).toList().toArray());
factor_linPSet.setStatus (PersistentSetStatus.PROCESSED); rs_factor_linPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class FactorScore extends BaseFactorScore ...@@ -10,4 +10,10 @@ public class FactorScore extends BaseFactorScore
{ {
// 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
public String getObjectIDSpace()
{
return "FactorScore";
}
} }
\ No newline at end of file
...@@ -4,16 +4,18 @@ ...@@ -4,16 +4,18 @@
<BUSINESSCLASS name="FactorScore" package="performa.orm"> <BUSINESSCLASS name="FactorScore" package="performa.orm">
<TABLE name="score" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_score" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Score" type="Integer" dbcol="score_number"/> <ATTRIB name="Score" type="Integer" dbcol="score_number"/>
<SINGLEREFERENCE name="TestAnalysis" type="TestAnalysis" dbcol="test_analysis_id" backreferenceName="FactorScores"/> <SINGLEREFERENCE name="TestAnalysis" type="TestAnalysis" dbcol="test_analysis_id" backreferenceName="FactorScores"/>
<SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number"/> <SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number"/>
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_number"/>
<SINGLEREFERENCE name="Narrative" type="Narrative" dbcol="narrative_id" backreferenceName="FactorScores"/>
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="score.object_id is not null" orderBy="score.object_id" /> <SEARCH type="All" paramFilter="rs_score.object_id is not null" orderBy="rs_score.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -41,7 +41,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -41,7 +41,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}score.object_id as id, {PREFIX}score.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}score.object_CREATED_DATE as CREATED_DATE, {PREFIX}score.score_number, {PREFIX}score.test_analysis_id, {PREFIX}score.factor_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_score.object_id as id, {PREFIX}rs_score.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_score.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_score.score_number, {PREFIX}rs_score.test_analysis_id, {PREFIX}rs_score.factor_number, {PREFIX}rs_score.level_number, {PREFIX}rs_score.narrative_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -86,15 +86,17 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -86,15 +86,17 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet scorePSet = allPSets.getPersistentSet(id, "score", PersistentSetStatus.FETCHED); PersistentSet rs_scorePSet = allPSets.getPersistentSet(id, "rs_score", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !scorePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_scorePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!scorePSet.containsAttrib(FactorScore.FIELD_Score)|| !rs_scorePSet.containsAttrib(FactorScore.FIELD_Score)||
!scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis)|| !rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis)||
!scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Factor)) !rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Factor)||
!rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Level)||
!rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Narrative))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -117,8 +119,8 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -117,8 +119,8 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}score " + "FROM {PREFIX}rs_score " +
"WHERE " + SELECT_JOINS + "{PREFIX}score.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_score.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -143,13 +145,23 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -143,13 +145,23 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorScore.SINGLEREFERENCE_TestAnalysis)) else if (refName.equals (FactorScore.SINGLEREFERENCE_TestAnalysis))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}score " + "FROM {PREFIX}rs_score " +
"WHERE " + SELECT_JOINS + "test_analysis_id = ?"; "WHERE " + SELECT_JOINS + "test_analysis_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results; return results;
} }
else if (refName.equals (FactorScore.SINGLEREFERENCE_Narrative))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_score " +
"WHERE " + SELECT_JOINS + "narrative_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else else
{ {
throw new IllegalArgumentException ("Illegal reference type:" + refName); throw new IllegalArgumentException ("Illegal reference type:" + refName);
...@@ -165,47 +177,47 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -165,47 +177,47 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet scorePSet = allPSets.getPersistentSet(objectID, "score"); PersistentSet rs_scorePSet = allPSets.getPersistentSet(objectID, "rs_score");
if (scorePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_scorePSet.getStatus () != PersistentSetStatus.PROCESSED &&
scorePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_scorePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}score " + "UPDATE {PREFIX}rs_score " +
"SET score_number = ?, test_analysis_id = ? , factor_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET score_number = ?, test_analysis_id = ? , factor_number = ? , level_number = ? , narrative_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE score.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_score.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, scorePSet.getAttrib (FactorScore.FIELD_Score))).listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, rs_scorePSet.getAttrib (FactorScore.FIELD_Score))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Narrative)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}score WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_score WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "score", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_score", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (FactorScorePersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorScorePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "score"); throw new ConcurrentUpdateConflictException (obj, "rs_score");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:score for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_score for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (FactorScorePersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorScorePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
scorePSet.setStatus (PersistentSetStatus.PROCESSED); rs_scorePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -220,42 +232,42 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -220,42 +232,42 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet scorePSet = allPSets.getPersistentSet(objectID, "score"); PersistentSet rs_scorePSet = allPSets.getPersistentSet(objectID, "rs_score");
LogMgr.log (FactorScorePersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (FactorScorePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (scorePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_scorePSet.getStatus () != PersistentSetStatus.PROCESSED &&
scorePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_scorePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}score " + "FROM {PREFIX}rs_score " +
"WHERE score.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_score.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}score WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_score WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "score"); throw new ConcurrentUpdateConflictException (obj, "rs_score");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:score for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_score for row:" + objectID;
LogMgr.log (FactorScorePersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (FactorScorePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
scorePSet.setStatus (PersistentSetStatus.PROCESSED); rs_scorePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -310,7 +322,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -310,7 +322,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet scorePSet = allPSets.getPersistentSet(objectID, "score", PersistentSetStatus.FETCHED); PersistentSet rs_scorePSet = allPSets.getPersistentSet(objectID, "rs_score", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -369,7 +381,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -369,7 +381,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}score " + tables + "FROM {PREFIX}rs_score " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -385,12 +397,12 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -385,12 +397,12 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY score.object_id"; String orderBy = " ORDER BY rs_score.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: score.object_id is not null Object[] searchParams; // paramFilter: rs_score.object_id is not null
String preFilter = "(score.object_id is not null)" String preFilter = "(rs_score.object_id is not null)"
+ " "; + " ";
...@@ -405,7 +417,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -405,7 +417,7 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}score " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_score " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -425,18 +437,20 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -425,18 +437,20 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet scorePSet = allPSets.getPersistentSet(objectID, "score", PersistentSetStatus.FETCHED); PersistentSet rs_scorePSet = allPSets.getPersistentSet(objectID, "rs_score", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
scorePSet.setAttrib(FactorScore.FIELD_Score, HELPER_Score.getFromRS(dummyScore, r, "score_number")); rs_scorePSet.setAttrib(FactorScore.FIELD_Score, HELPER_Score.getFromRS(dummyScore, r, "score_number"));
scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis, r.getObject ("test_analysis_id")); rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis, r.getObject ("test_analysis_id"));
scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_Factor, r.getObject ("factor_number")); rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_Level, r.getObject ("level_number"));
rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_Narrative, r.getObject ("narrative_id"));
} }
...@@ -444,21 +458,21 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -444,21 +458,21 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet scorePSet = allPSets.getPersistentSet(objectID, "score"); PersistentSet rs_scorePSet = allPSets.getPersistentSet(objectID, "rs_score");
if (scorePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_scorePSet.getStatus () != PersistentSetStatus.PROCESSED &&
scorePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_scorePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}score " + "INSERT INTO {PREFIX}rs_score " +
" (score_number, test_analysis_id, factor_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (score_number, test_analysis_id, factor_number, level_number, narrative_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, scorePSet.getAttrib (FactorScore.FIELD_Score))) .listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, rs_scorePSet.getAttrib (FactorScore.FIELD_Score))) .listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Narrative)))) .listEntry (objectID.longID ()).toList().toArray());
scorePSet.setStatus (PersistentSetStatus.PROCESSED); rs_scorePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class FactorScoreResult extends BaseFactorScoreResult ...@@ -10,4 +10,10 @@ public class FactorScoreResult extends BaseFactorScoreResult
{ {
// 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
public String getObjectIDSpace()
{
return "FactorScoreResult";
}
} }
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<BUSINESSCLASS name="FactorScoreResult" package="performa.orm"> <BUSINESSCLASS name="FactorScoreResult" package="performa.orm">
<IMPORT value="performa.orm.types.*"/> <IMPORT value="performa.orm.types.*"/>
<TABLE name="level_factor" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_level_factor" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="FromScore" type="Integer" dbcol="from_score"/> <ATTRIB name="FromScore" type="Integer" dbcol="from_score"/>
<ATTRIB name="ToScore" type="Integer" dbcol="to_score"/> <ATTRIB name="ToScore" type="Integer" dbcol="to_score"/>
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="level_factor.object_id is not null" orderBy="level_factor.object_id" /> <SEARCH type="All" paramFilter="rs_level_factor.object_id is not null" orderBy="rs_level_factor.object_id" />
<SEARCH type="FactorScore" paramFilter="level_factor.object_id is not null" singleton="TRUE"/> <SEARCH type="FactorScore" paramFilter="rs_level_factor.object_id is not null" singleton="TRUE"/>
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -48,7 +48,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -48,7 +48,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}level_factor.object_id as id, {PREFIX}level_factor.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}level_factor.object_CREATED_DATE as CREATED_DATE, {PREFIX}level_factor.from_score, {PREFIX}level_factor.to_score, {PREFIX}level_factor.color_code, {PREFIX}level_factor.factor_number, {PREFIX}level_factor.level_number, {PREFIX}level_factor.narrative_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_level_factor.object_id as id, {PREFIX}rs_level_factor.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_level_factor.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_level_factor.from_score, {PREFIX}rs_level_factor.to_score, {PREFIX}rs_level_factor.color_code, {PREFIX}rs_level_factor.factor_number, {PREFIX}rs_level_factor.level_number, {PREFIX}rs_level_factor.narrative_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -93,18 +93,18 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -93,18 +93,18 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet level_factorPSet = allPSets.getPersistentSet(id, "level_factor", PersistentSetStatus.FETCHED); PersistentSet rs_level_factorPSet = allPSets.getPersistentSet(id, "rs_level_factor", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !level_factorPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_level_factorPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!level_factorPSet.containsAttrib(FactorScoreResult.FIELD_FromScore)|| !rs_level_factorPSet.containsAttrib(FactorScoreResult.FIELD_FromScore)||
!level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ToScore)|| !rs_level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ToScore)||
!level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ColorCode)|| !rs_level_factorPSet.containsAttrib(FactorScoreResult.FIELD_ColorCode)||
!level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Factor)|| !rs_level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Factor)||
!level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Level)|| !rs_level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Level)||
!level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Narrative)) !rs_level_factorPSet.containsAttrib(FactorScoreResult.SINGLEREFERENCE_Narrative))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -127,8 +127,8 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -127,8 +127,8 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " + "FROM {PREFIX}rs_level_factor " +
"WHERE " + SELECT_JOINS + "{PREFIX}level_factor.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_level_factor.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -153,7 +153,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -153,7 +153,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Factor)) else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Factor))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " + "FROM {PREFIX}rs_level_factor " +
"WHERE " + SELECT_JOINS + "factor_number = ?"; "WHERE " + SELECT_JOINS + "factor_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -163,7 +163,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -163,7 +163,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Level)) else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Level))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " + "FROM {PREFIX}rs_level_factor " +
"WHERE " + SELECT_JOINS + "level_number = ?"; "WHERE " + SELECT_JOINS + "level_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -173,7 +173,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -173,7 +173,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Narrative)) else if (refName.equals (FactorScoreResult.SINGLEREFERENCE_Narrative))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " + "FROM {PREFIX}rs_level_factor " +
"WHERE " + SELECT_JOINS + "narrative_id = ?"; "WHERE " + SELECT_JOINS + "narrative_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -195,47 +195,47 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -195,47 +195,47 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet level_factorPSet = allPSets.getPersistentSet(objectID, "level_factor"); PersistentSet rs_level_factorPSet = allPSets.getPersistentSet(objectID, "rs_level_factor");
if (level_factorPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_level_factorPSet.getStatus () != PersistentSetStatus.PROCESSED &&
level_factorPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_level_factorPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}level_factor " + "UPDATE {PREFIX}rs_level_factor " +
"SET from_score = ?, to_score = ?, color_code = ?, factor_number = ? , level_number = ? , narrative_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET from_score = ?, to_score = ?, color_code = ?, factor_number = ? , level_number = ? , narrative_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE level_factor.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_level_factor.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Narrative)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, rs_level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, rs_level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, rs_level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))).listEntry (SQLManager.CheckNull((Long)(rs_level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Narrative)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}level_factor WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_level_factor WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "level_factor", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_level_factor", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (FactorScoreResultPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorScoreResultPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "level_factor"); throw new ConcurrentUpdateConflictException (obj, "rs_level_factor");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:level_factor for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_level_factor for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (FactorScoreResultPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (FactorScoreResultPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
level_factorPSet.setStatus (PersistentSetStatus.PROCESSED); rs_level_factorPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -250,42 +250,42 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -250,42 +250,42 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet level_factorPSet = allPSets.getPersistentSet(objectID, "level_factor"); PersistentSet rs_level_factorPSet = allPSets.getPersistentSet(objectID, "rs_level_factor");
LogMgr.log (FactorScoreResultPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (FactorScoreResultPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (level_factorPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_level_factorPSet.getStatus () != PersistentSetStatus.PROCESSED &&
level_factorPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_level_factorPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}level_factor " + "FROM {PREFIX}rs_level_factor " +
"WHERE level_factor.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_level_factor.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}level_factor WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_level_factor WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "level_factor"); throw new ConcurrentUpdateConflictException (obj, "rs_level_factor");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:level_factor for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_level_factor for row:" + objectID;
LogMgr.log (FactorScoreResultPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (FactorScoreResultPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
level_factorPSet.setStatus (PersistentSetStatus.PROCESSED); rs_level_factorPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -344,7 +344,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -344,7 +344,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet level_factorPSet = allPSets.getPersistentSet(objectID, "level_factor", PersistentSetStatus.FETCHED); PersistentSet rs_level_factorPSet = allPSets.getPersistentSet(objectID, "rs_level_factor", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -403,7 +403,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -403,7 +403,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " + tables + "FROM {PREFIX}rs_level_factor " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -419,12 +419,12 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -419,12 +419,12 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY level_factor.object_id"; String orderBy = " ORDER BY rs_level_factor.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: level_factor.object_id is not null Object[] searchParams; // paramFilter: rs_level_factor.object_id is not null
String preFilter = "(level_factor.object_id is not null)" String preFilter = "(rs_level_factor.object_id is not null)"
+ " "; + " ";
...@@ -439,7 +439,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -439,7 +439,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_level_factor " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -461,8 +461,8 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -461,8 +461,8 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: level_factor.object_id is not null Object[] searchParams; // paramFilter: rs_level_factor.object_id is not null
String preFilter = "(level_factor.object_id is not null)" String preFilter = "(rs_level_factor.object_id is not null)"
+ " "; + " ";
...@@ -477,7 +477,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -477,7 +477,7 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level_factor " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_level_factor " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -497,21 +497,21 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -497,21 +497,21 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet level_factorPSet = allPSets.getPersistentSet(objectID, "level_factor", PersistentSetStatus.FETCHED); PersistentSet rs_level_factorPSet = allPSets.getPersistentSet(objectID, "rs_level_factor", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
level_factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_level_factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
level_factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_level_factorPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
level_factorPSet.setAttrib(FactorScoreResult.FIELD_FromScore, HELPER_FromScore.getFromRS(dummyFromScore, r, "from_score")); rs_level_factorPSet.setAttrib(FactorScoreResult.FIELD_FromScore, HELPER_FromScore.getFromRS(dummyFromScore, r, "from_score"));
level_factorPSet.setAttrib(FactorScoreResult.FIELD_ToScore, HELPER_ToScore.getFromRS(dummyToScore, r, "to_score")); rs_level_factorPSet.setAttrib(FactorScoreResult.FIELD_ToScore, HELPER_ToScore.getFromRS(dummyToScore, r, "to_score"));
level_factorPSet.setAttrib(FactorScoreResult.FIELD_ColorCode, HELPER_ColorCode.getFromRS(dummyColorCode, r, "color_code")); rs_level_factorPSet.setAttrib(FactorScoreResult.FIELD_ColorCode, HELPER_ColorCode.getFromRS(dummyColorCode, r, "color_code"));
level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Factor, r.getObject ("factor_number")); rs_level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Level, r.getObject ("level_number")); rs_level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Level, r.getObject ("level_number"));
level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Narrative, r.getObject ("narrative_id")); rs_level_factorPSet.setAttrib(FactorScoreResult.SINGLEREFERENCE_Narrative, r.getObject ("narrative_id"));
} }
...@@ -519,21 +519,21 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -519,21 +519,21 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet level_factorPSet = allPSets.getPersistentSet(objectID, "level_factor"); PersistentSet rs_level_factorPSet = allPSets.getPersistentSet(objectID, "rs_level_factor");
if (level_factorPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_level_factorPSet.getStatus () != PersistentSetStatus.PROCESSED &&
level_factorPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_level_factorPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}level_factor " + "INSERT INTO {PREFIX}rs_level_factor " +
" (from_score, to_score, color_code, factor_number, level_number, narrative_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (from_score, to_score, color_code, factor_number, level_number, narrative_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))) .listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Narrative)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FromScore.getForSQL(dummyFromScore, rs_level_factorPSet.getAttrib (FactorScoreResult.FIELD_FromScore))).listEntry (HELPER_ToScore.getForSQL(dummyToScore, rs_level_factorPSet.getAttrib (FactorScoreResult.FIELD_ToScore))).listEntry (HELPER_ColorCode.getForSQL(dummyColorCode, rs_level_factorPSet.getAttrib (FactorScoreResult.FIELD_ColorCode))) .listEntry (SQLManager.CheckNull((Long)(rs_level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_level_factorPSet.getAttrib (FactorScoreResult.SINGLEREFERENCE_Narrative)))) .listEntry (objectID.longID ()).toList().toArray());
level_factorPSet.setStatus (PersistentSetStatus.PROCESSED); rs_level_factorPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class Level extends BaseLevel ...@@ -10,4 +10,10 @@ public class Level extends BaseLevel
{ {
// 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
public String getObjectIDSpace()
{
return "Level";
}
} }
\ No newline at end of file
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
<MULTIPLEREFERENCE name="Factors" type="FactorLevelLink" backreferenceName="Level" /> <MULTIPLEREFERENCE name="Factors" type="FactorLevelLink" backreferenceName="Level" />
<MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Level" /> <MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Level" />
<MULTIPLEREFERENCE name="Narratives" type="Narrative" backreferenceName="Level" />
<MULTIPLEREFERENCE name="TestAnalysises" type="TestAnalysis" backreferenceName="Level" />
<TABLE name="level" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_level" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="LevelDescription" type="String" dbcol="level_desc" length="30"/> <ATTRIB name="LevelDescription" type="String" dbcol="level_desc" length="30"/>
<ATTRIB name="LevelNotes" type="String" dbcol="level_notes"/> <ATTRIB name="LevelNotes" type="String" dbcol="level_notes"/>
...@@ -15,7 +17,7 @@ ...@@ -15,7 +17,7 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="level.object_id is not null" orderBy="level.object_id" /> <SEARCH type="All" paramFilter="rs_level.object_id is not null" orderBy="rs_level.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -47,7 +47,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -47,7 +47,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}level.object_id as id, {PREFIX}level.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}level.object_CREATED_DATE as CREATED_DATE, {PREFIX}level.level_desc, {PREFIX}level.level_notes, {PREFIX}level.rpt_hdr, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_level.object_id as id, {PREFIX}rs_level.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_level.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_level.level_desc, {PREFIX}rs_level.level_notes, {PREFIX}rs_level.rpt_hdr, 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
...@@ -92,15 +92,15 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -92,15 +92,15 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet levelPSet = allPSets.getPersistentSet(id, "level", PersistentSetStatus.FETCHED); PersistentSet rs_levelPSet = allPSets.getPersistentSet(id, "rs_level", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !levelPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_levelPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!levelPSet.containsAttrib(Level.FIELD_LevelDescription)|| !rs_levelPSet.containsAttrib(Level.FIELD_LevelDescription)||
!levelPSet.containsAttrib(Level.FIELD_LevelNotes)|| !rs_levelPSet.containsAttrib(Level.FIELD_LevelNotes)||
!levelPSet.containsAttrib(Level.FIELD_ReportHeader)) !rs_levelPSet.containsAttrib(Level.FIELD_ReportHeader))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -123,8 +123,8 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -123,8 +123,8 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level " + "FROM {PREFIX}rs_level " +
"WHERE " + SELECT_JOINS + "{PREFIX}level.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_level.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -161,47 +161,47 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -161,47 +161,47 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet levelPSet = allPSets.getPersistentSet(objectID, "level"); PersistentSet rs_levelPSet = allPSets.getPersistentSet(objectID, "rs_level");
if (levelPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_levelPSet.getStatus () != PersistentSetStatus.PROCESSED &&
levelPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_levelPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}level " + "UPDATE {PREFIX}rs_level " +
"SET level_desc = ?, level_notes = ?, rpt_hdr = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET level_desc = ?, level_notes = ?, rpt_hdr = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE level.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_level.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_LevelDescription.getForSQL(dummyLevelDescription, levelPSet.getAttrib (Level.FIELD_LevelDescription))).listEntry (HELPER_LevelNotes.getForSQL(dummyLevelNotes, levelPSet.getAttrib (Level.FIELD_LevelNotes))).listEntry (HELPER_ReportHeader.getForSQL(dummyReportHeader, levelPSet.getAttrib (Level.FIELD_ReportHeader))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_LevelDescription.getForSQL(dummyLevelDescription, rs_levelPSet.getAttrib (Level.FIELD_LevelDescription))).listEntry (HELPER_LevelNotes.getForSQL(dummyLevelNotes, rs_levelPSet.getAttrib (Level.FIELD_LevelNotes))).listEntry (HELPER_ReportHeader.getForSQL(dummyReportHeader, rs_levelPSet.getAttrib (Level.FIELD_ReportHeader))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}level WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_level WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "level", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_level", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (LevelPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (LevelPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "level"); throw new ConcurrentUpdateConflictException (obj, "rs_level");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:level for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_level for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (LevelPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (LevelPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
levelPSet.setStatus (PersistentSetStatus.PROCESSED); rs_levelPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -216,42 +216,42 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -216,42 +216,42 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet levelPSet = allPSets.getPersistentSet(objectID, "level"); PersistentSet rs_levelPSet = allPSets.getPersistentSet(objectID, "rs_level");
LogMgr.log (LevelPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (LevelPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (levelPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_levelPSet.getStatus () != PersistentSetStatus.PROCESSED &&
levelPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_levelPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}level " + "FROM {PREFIX}rs_level " +
"WHERE level.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_level.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}level WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_level WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "level"); throw new ConcurrentUpdateConflictException (obj, "rs_level");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:level for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_level for row:" + objectID;
LogMgr.log (LevelPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (LevelPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
levelPSet.setStatus (PersistentSetStatus.PROCESSED); rs_levelPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -306,7 +306,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -306,7 +306,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet levelPSet = allPSets.getPersistentSet(objectID, "level", PersistentSetStatus.FETCHED); PersistentSet rs_levelPSet = allPSets.getPersistentSet(objectID, "rs_level", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -365,7 +365,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -365,7 +365,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level " + tables + "FROM {PREFIX}rs_level " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -381,12 +381,12 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -381,12 +381,12 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY level.object_id"; String orderBy = " ORDER BY rs_level.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: level.object_id is not null Object[] searchParams; // paramFilter: rs_level.object_id is not null
String preFilter = "(level.object_id is not null)" String preFilter = "(rs_level.object_id is not null)"
+ " "; + " ";
...@@ -401,7 +401,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -401,7 +401,7 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}level " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_level " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -421,17 +421,17 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -421,17 +421,17 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet levelPSet = allPSets.getPersistentSet(objectID, "level", PersistentSetStatus.FETCHED); PersistentSet rs_levelPSet = allPSets.getPersistentSet(objectID, "rs_level", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
levelPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_levelPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
levelPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_levelPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
levelPSet.setAttrib(Level.FIELD_LevelDescription, HELPER_LevelDescription.getFromRS(dummyLevelDescription, r, "level_desc")); rs_levelPSet.setAttrib(Level.FIELD_LevelDescription, HELPER_LevelDescription.getFromRS(dummyLevelDescription, r, "level_desc"));
levelPSet.setAttrib(Level.FIELD_LevelNotes, HELPER_LevelNotes.getFromRS(dummyLevelNotes, r, "level_notes")); rs_levelPSet.setAttrib(Level.FIELD_LevelNotes, HELPER_LevelNotes.getFromRS(dummyLevelNotes, r, "level_notes"));
levelPSet.setAttrib(Level.FIELD_ReportHeader, HELPER_ReportHeader.getFromRS(dummyReportHeader, r, "rpt_hdr")); rs_levelPSet.setAttrib(Level.FIELD_ReportHeader, HELPER_ReportHeader.getFromRS(dummyReportHeader, r, "rpt_hdr"));
} }
...@@ -440,21 +440,21 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr ...@@ -440,21 +440,21 @@ public class LevelPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet levelPSet = allPSets.getPersistentSet(objectID, "level"); PersistentSet rs_levelPSet = allPSets.getPersistentSet(objectID, "rs_level");
if (levelPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_levelPSet.getStatus () != PersistentSetStatus.PROCESSED &&
levelPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_levelPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}level " + "INSERT INTO {PREFIX}rs_level " +
" (level_desc, level_notes, rpt_hdr, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (level_desc, level_notes, rpt_hdr, 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_LevelDescription.getForSQL(dummyLevelDescription, levelPSet.getAttrib (Level.FIELD_LevelDescription))).listEntry (HELPER_LevelNotes.getForSQL(dummyLevelNotes, levelPSet.getAttrib (Level.FIELD_LevelNotes))).listEntry (HELPER_ReportHeader.getForSQL(dummyReportHeader, levelPSet.getAttrib (Level.FIELD_ReportHeader))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_LevelDescription.getForSQL(dummyLevelDescription, rs_levelPSet.getAttrib (Level.FIELD_LevelDescription))).listEntry (HELPER_LevelNotes.getForSQL(dummyLevelNotes, rs_levelPSet.getAttrib (Level.FIELD_LevelNotes))).listEntry (HELPER_ReportHeader.getForSQL(dummyReportHeader, rs_levelPSet.getAttrib (Level.FIELD_ReportHeader))) .listEntry (objectID.longID ()).toList().toArray());
levelPSet.setStatus (PersistentSetStatus.PROCESSED); rs_levelPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class Narrative extends BaseNarrative ...@@ -10,4 +10,10 @@ public class Narrative extends BaseNarrative
{ {
// 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
public String getObjectIDSpace()
{
return "Narrative";
}
} }
\ No newline at end of file
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
<BUSINESSCLASS name="Narrative" package="performa.orm"> <BUSINESSCLASS name="Narrative" package="performa.orm">
<MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Narrative" /> <MULTIPLEREFERENCE name="Results" type="FactorScoreResult" backreferenceName="Narrative" />
<MULTIPLEREFERENCE name="FactorScores" type="FactorScore" backreferenceName="Narrative" />
<TABLE name="narrative" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_narrative" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="NarrativeCode" type="String" dbcol="narrative_code" length="15" mandatory="true"/> <ATTRIB name="NarrativeCode" type="String" dbcol="narrative_code" length="15" mandatory="true"/>
<ATTRIB name="Description" type="String" dbcol="narrative_desc" length="30"/> <ATTRIB name="Description" type="String" dbcol="narrative_desc" length="30"/>
...@@ -17,11 +18,11 @@ ...@@ -17,11 +18,11 @@
<ATTRIB name="DevelNarrative" type="String" dbcol="devel_narrative" length="128"/> <ATTRIB name="DevelNarrative" type="String" dbcol="devel_narrative" length="128"/>
<ATTRIB name="Question" type="String" dbcol="question"/> <ATTRIB name="Question" type="String" dbcol="question"/>
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_number"/> <SINGLEREFERENCE name="Level" type="Level" dbcol="level_number" backreferenceName="Narratives"/>
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="narrative.object_id is not null" orderBy="narrative.object_id" /> <SEARCH type="All" paramFilter="rs_narrative.object_id is not null" orderBy="rs_narrative.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -62,7 +62,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -62,7 +62,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}narrative.object_id as id, {PREFIX}narrative.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}narrative.object_CREATED_DATE as CREATED_DATE, {PREFIX}narrative.narrative_code, {PREFIX}narrative.narrative_desc, {PREFIX}narrative.graphic_notes, {PREFIX}narrative.exec_sum_notes, {PREFIX}narrative.mod_connect_flag, {PREFIX}narrative.narrative_notes, {PREFIX}narrative.devel_narrative, {PREFIX}narrative.question, {PREFIX}narrative.level_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_narrative.object_id as id, {PREFIX}rs_narrative.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_narrative.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_narrative.narrative_code, {PREFIX}rs_narrative.narrative_desc, {PREFIX}rs_narrative.graphic_notes, {PREFIX}rs_narrative.exec_sum_notes, {PREFIX}rs_narrative.mod_connect_flag, {PREFIX}rs_narrative.narrative_notes, {PREFIX}rs_narrative.devel_narrative, {PREFIX}rs_narrative.question, {PREFIX}rs_narrative.level_number, 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
...@@ -107,21 +107,21 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -107,21 +107,21 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet narrativePSet = allPSets.getPersistentSet(id, "narrative", PersistentSetStatus.FETCHED); PersistentSet rs_narrativePSet = allPSets.getPersistentSet(id, "rs_narrative", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !narrativePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_narrativePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!narrativePSet.containsAttrib(Narrative.FIELD_NarrativeCode)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_NarrativeCode)||
!narrativePSet.containsAttrib(Narrative.FIELD_Description)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_Description)||
!narrativePSet.containsAttrib(Narrative.FIELD_GraphicNotes)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_GraphicNotes)||
!narrativePSet.containsAttrib(Narrative.FIELD_SummaryNotes)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_SummaryNotes)||
!narrativePSet.containsAttrib(Narrative.FIELD_ModConnect)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_ModConnect)||
!narrativePSet.containsAttrib(Narrative.FIELD_NarrativeNotes)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_NarrativeNotes)||
!narrativePSet.containsAttrib(Narrative.FIELD_DevelNarrative)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_DevelNarrative)||
!narrativePSet.containsAttrib(Narrative.FIELD_Question)|| !rs_narrativePSet.containsAttrib(Narrative.FIELD_Question)||
!narrativePSet.containsAttrib(Narrative.SINGLEREFERENCE_Level)) !rs_narrativePSet.containsAttrib(Narrative.SINGLEREFERENCE_Level))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -144,8 +144,8 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -144,8 +144,8 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}narrative " + "FROM {PREFIX}rs_narrative " +
"WHERE " + SELECT_JOINS + "{PREFIX}narrative.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_narrative.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -167,6 +167,16 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -167,6 +167,16 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException (); throw new RuntimeException ();
} }
else if (refName.equals (Narrative.SINGLEREFERENCE_Level))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_narrative " +
"WHERE " + SELECT_JOINS + "level_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else else
{ {
throw new IllegalArgumentException ("Illegal reference type:" + refName); throw new IllegalArgumentException ("Illegal reference type:" + refName);
...@@ -182,47 +192,47 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -182,47 +192,47 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative"); PersistentSet rs_narrativePSet = allPSets.getPersistentSet(objectID, "rs_narrative");
if (narrativePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
narrativePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}narrative " + "UPDATE {PREFIX}rs_narrative " +
"SET narrative_code = ?, narrative_desc = ?, graphic_notes = ?, exec_sum_notes = ?, mod_connect_flag = ?, narrative_notes = ?, devel_narrative = ?, question = ?, level_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET narrative_code = ?, narrative_desc = ?, graphic_notes = ?, exec_sum_notes = ?, mod_connect_flag = ?, narrative_notes = ?, devel_narrative = ?, question = ?, level_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE narrative.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_narrative.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, narrativePSet.getAttrib (Narrative.FIELD_NarrativeCode))).listEntry (HELPER_Description.getForSQL(dummyDescription, narrativePSet.getAttrib (Narrative.FIELD_Description))).listEntry (HELPER_GraphicNotes.getForSQL(dummyGraphicNotes, narrativePSet.getAttrib (Narrative.FIELD_GraphicNotes))).listEntry (HELPER_SummaryNotes.getForSQL(dummySummaryNotes, narrativePSet.getAttrib (Narrative.FIELD_SummaryNotes))).listEntry (HELPER_ModConnect.getForSQL(dummyModConnect, narrativePSet.getAttrib (Narrative.FIELD_ModConnect))).listEntry (HELPER_NarrativeNotes.getForSQL(dummyNarrativeNotes, narrativePSet.getAttrib (Narrative.FIELD_NarrativeNotes))).listEntry (HELPER_DevelNarrative.getForSQL(dummyDevelNarrative, narrativePSet.getAttrib (Narrative.FIELD_DevelNarrative))).listEntry (HELPER_Question.getForSQL(dummyQuestion, narrativePSet.getAttrib (Narrative.FIELD_Question))).listEntry (SQLManager.CheckNull((Long)(narrativePSet.getAttrib (Narrative.SINGLEREFERENCE_Level)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, rs_narrativePSet.getAttrib (Narrative.FIELD_NarrativeCode))).listEntry (HELPER_Description.getForSQL(dummyDescription, rs_narrativePSet.getAttrib (Narrative.FIELD_Description))).listEntry (HELPER_GraphicNotes.getForSQL(dummyGraphicNotes, rs_narrativePSet.getAttrib (Narrative.FIELD_GraphicNotes))).listEntry (HELPER_SummaryNotes.getForSQL(dummySummaryNotes, rs_narrativePSet.getAttrib (Narrative.FIELD_SummaryNotes))).listEntry (HELPER_ModConnect.getForSQL(dummyModConnect, rs_narrativePSet.getAttrib (Narrative.FIELD_ModConnect))).listEntry (HELPER_NarrativeNotes.getForSQL(dummyNarrativeNotes, rs_narrativePSet.getAttrib (Narrative.FIELD_NarrativeNotes))).listEntry (HELPER_DevelNarrative.getForSQL(dummyDevelNarrative, rs_narrativePSet.getAttrib (Narrative.FIELD_DevelNarrative))).listEntry (HELPER_Question.getForSQL(dummyQuestion, rs_narrativePSet.getAttrib (Narrative.FIELD_Question))).listEntry (SQLManager.CheckNull((Long)(rs_narrativePSet.getAttrib (Narrative.SINGLEREFERENCE_Level)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}narrative WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_narrative WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "narrative", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_narrative", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (NarrativePersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (NarrativePersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "narrative"); throw new ConcurrentUpdateConflictException (obj, "rs_narrative");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:narrative for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_narrative for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (NarrativePersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (NarrativePersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
narrativePSet.setStatus (PersistentSetStatus.PROCESSED); rs_narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -237,42 +247,42 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -237,42 +247,42 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative"); PersistentSet rs_narrativePSet = allPSets.getPersistentSet(objectID, "rs_narrative");
LogMgr.log (NarrativePersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (NarrativePersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (narrativePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
narrativePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}narrative " + "FROM {PREFIX}rs_narrative " +
"WHERE narrative.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_narrative.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}narrative WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_narrative WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "narrative"); throw new ConcurrentUpdateConflictException (obj, "rs_narrative");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:narrative for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_narrative for row:" + objectID;
LogMgr.log (NarrativePersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (NarrativePersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
narrativePSet.setStatus (PersistentSetStatus.PROCESSED); rs_narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -327,7 +337,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -327,7 +337,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative", PersistentSetStatus.FETCHED); PersistentSet rs_narrativePSet = allPSets.getPersistentSet(objectID, "rs_narrative", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -386,7 +396,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -386,7 +396,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}narrative " + tables + "FROM {PREFIX}rs_narrative " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -402,12 +412,12 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -402,12 +412,12 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY narrative.object_id"; String orderBy = " ORDER BY rs_narrative.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: narrative.object_id is not null Object[] searchParams; // paramFilter: rs_narrative.object_id is not null
String preFilter = "(narrative.object_id is not null)" String preFilter = "(rs_narrative.object_id is not null)"
+ " "; + " ";
...@@ -422,7 +432,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -422,7 +432,7 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}narrative " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_narrative " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -442,24 +452,24 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -442,24 +452,24 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative", PersistentSetStatus.FETCHED); PersistentSet rs_narrativePSet = allPSets.getPersistentSet(objectID, "rs_narrative", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_narrativePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
narrativePSet.setAttrib(Narrative.FIELD_NarrativeCode, HELPER_NarrativeCode.getFromRS(dummyNarrativeCode, r, "narrative_code")); rs_narrativePSet.setAttrib(Narrative.FIELD_NarrativeCode, HELPER_NarrativeCode.getFromRS(dummyNarrativeCode, r, "narrative_code"));
narrativePSet.setAttrib(Narrative.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "narrative_desc")); rs_narrativePSet.setAttrib(Narrative.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "narrative_desc"));
narrativePSet.setAttrib(Narrative.FIELD_GraphicNotes, HELPER_GraphicNotes.getFromRS(dummyGraphicNotes, r, "graphic_notes")); rs_narrativePSet.setAttrib(Narrative.FIELD_GraphicNotes, HELPER_GraphicNotes.getFromRS(dummyGraphicNotes, r, "graphic_notes"));
narrativePSet.setAttrib(Narrative.FIELD_SummaryNotes, HELPER_SummaryNotes.getFromRS(dummySummaryNotes, r, "exec_sum_notes")); rs_narrativePSet.setAttrib(Narrative.FIELD_SummaryNotes, HELPER_SummaryNotes.getFromRS(dummySummaryNotes, r, "exec_sum_notes"));
narrativePSet.setAttrib(Narrative.FIELD_ModConnect, HELPER_ModConnect.getFromRS(dummyModConnect, r, "mod_connect_flag")); rs_narrativePSet.setAttrib(Narrative.FIELD_ModConnect, HELPER_ModConnect.getFromRS(dummyModConnect, r, "mod_connect_flag"));
narrativePSet.setAttrib(Narrative.FIELD_NarrativeNotes, HELPER_NarrativeNotes.getFromRS(dummyNarrativeNotes, r, "narrative_notes")); rs_narrativePSet.setAttrib(Narrative.FIELD_NarrativeNotes, HELPER_NarrativeNotes.getFromRS(dummyNarrativeNotes, r, "narrative_notes"));
narrativePSet.setAttrib(Narrative.FIELD_DevelNarrative, HELPER_DevelNarrative.getFromRS(dummyDevelNarrative, r, "devel_narrative")); rs_narrativePSet.setAttrib(Narrative.FIELD_DevelNarrative, HELPER_DevelNarrative.getFromRS(dummyDevelNarrative, r, "devel_narrative"));
narrativePSet.setAttrib(Narrative.FIELD_Question, HELPER_Question.getFromRS(dummyQuestion, r, "question")); rs_narrativePSet.setAttrib(Narrative.FIELD_Question, HELPER_Question.getFromRS(dummyQuestion, r, "question"));
narrativePSet.setAttrib(Narrative.SINGLEREFERENCE_Level, r.getObject ("level_number")); rs_narrativePSet.setAttrib(Narrative.SINGLEREFERENCE_Level, r.getObject ("level_number"));
} }
...@@ -467,21 +477,21 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr ...@@ -467,21 +477,21 @@ public class NarrativePersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet narrativePSet = allPSets.getPersistentSet(objectID, "narrative"); PersistentSet rs_narrativePSet = allPSets.getPersistentSet(objectID, "rs_narrative");
if (narrativePSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_narrativePSet.getStatus () != PersistentSetStatus.PROCESSED &&
narrativePSet.getStatus () != PersistentSetStatus.DEFERRED) rs_narrativePSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}narrative " + "INSERT INTO {PREFIX}rs_narrative " +
" (narrative_code, narrative_desc, graphic_notes, exec_sum_notes, mod_connect_flag, narrative_notes, devel_narrative, question, level_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (narrative_code, narrative_desc, graphic_notes, exec_sum_notes, mod_connect_flag, narrative_notes, devel_narrative, question, level_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, narrativePSet.getAttrib (Narrative.FIELD_NarrativeCode))).listEntry (HELPER_Description.getForSQL(dummyDescription, narrativePSet.getAttrib (Narrative.FIELD_Description))).listEntry (HELPER_GraphicNotes.getForSQL(dummyGraphicNotes, narrativePSet.getAttrib (Narrative.FIELD_GraphicNotes))).listEntry (HELPER_SummaryNotes.getForSQL(dummySummaryNotes, narrativePSet.getAttrib (Narrative.FIELD_SummaryNotes))).listEntry (HELPER_ModConnect.getForSQL(dummyModConnect, narrativePSet.getAttrib (Narrative.FIELD_ModConnect))).listEntry (HELPER_NarrativeNotes.getForSQL(dummyNarrativeNotes, narrativePSet.getAttrib (Narrative.FIELD_NarrativeNotes))).listEntry (HELPER_DevelNarrative.getForSQL(dummyDevelNarrative, narrativePSet.getAttrib (Narrative.FIELD_DevelNarrative))).listEntry (HELPER_Question.getForSQL(dummyQuestion, narrativePSet.getAttrib (Narrative.FIELD_Question))) .listEntry (SQLManager.CheckNull((Long)(narrativePSet.getAttrib (Narrative.SINGLEREFERENCE_Level)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_NarrativeCode.getForSQL(dummyNarrativeCode, rs_narrativePSet.getAttrib (Narrative.FIELD_NarrativeCode))).listEntry (HELPER_Description.getForSQL(dummyDescription, rs_narrativePSet.getAttrib (Narrative.FIELD_Description))).listEntry (HELPER_GraphicNotes.getForSQL(dummyGraphicNotes, rs_narrativePSet.getAttrib (Narrative.FIELD_GraphicNotes))).listEntry (HELPER_SummaryNotes.getForSQL(dummySummaryNotes, rs_narrativePSet.getAttrib (Narrative.FIELD_SummaryNotes))).listEntry (HELPER_ModConnect.getForSQL(dummyModConnect, rs_narrativePSet.getAttrib (Narrative.FIELD_ModConnect))).listEntry (HELPER_NarrativeNotes.getForSQL(dummyNarrativeNotes, rs_narrativePSet.getAttrib (Narrative.FIELD_NarrativeNotes))).listEntry (HELPER_DevelNarrative.getForSQL(dummyDevelNarrative, rs_narrativePSet.getAttrib (Narrative.FIELD_DevelNarrative))).listEntry (HELPER_Question.getForSQL(dummyQuestion, rs_narrativePSet.getAttrib (Narrative.FIELD_Question))) .listEntry (SQLManager.CheckNull((Long)(rs_narrativePSet.getAttrib (Narrative.SINGLEREFERENCE_Level)))) .listEntry (objectID.longID ()).toList().toArray());
narrativePSet.setStatus (PersistentSetStatus.PROCESSED); rs_narrativePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class Question extends BaseQuestion ...@@ -10,4 +10,10 @@ public class Question extends BaseQuestion
{ {
// 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
public String getObjectIDSpace()
{
return "Question";
}
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<MULTIPLEREFERENCE name="Factors" type="FactorQuestionLink" backreferenceName="Question" /> <MULTIPLEREFERENCE name="Factors" type="FactorQuestionLink" backreferenceName="Question" />
<TABLE name="quest_lin" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_quest_lin" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="left_quest" length="80"/> <ATTRIB name="Description" type="String" dbcol="left_quest" length="80"/>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="quest_lin.object_id is not null" orderBy="quest_lin.object_id" /> <SEARCH type="All" paramFilter="rs_quest_lin.object_id is not null" orderBy="rs_quest_lin.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -41,7 +41,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -41,7 +41,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}quest_lin.object_id as id, {PREFIX}quest_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}quest_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}quest_lin.left_quest, {PREFIX}quest_lin.section_number, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_quest_lin.object_id as id, {PREFIX}rs_quest_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_quest_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_quest_lin.left_quest, {PREFIX}rs_quest_lin.section_number, 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
...@@ -86,14 +86,14 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -86,14 +86,14 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet quest_linPSet = allPSets.getPersistentSet(id, "quest_lin", PersistentSetStatus.FETCHED); PersistentSet rs_quest_linPSet = allPSets.getPersistentSet(id, "rs_quest_lin", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !quest_linPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_quest_linPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!quest_linPSet.containsAttrib(Question.FIELD_Description)|| !rs_quest_linPSet.containsAttrib(Question.FIELD_Description)||
!quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_Section)) !rs_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_Section))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -116,8 +116,8 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -116,8 +116,8 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}quest_lin " + "FROM {PREFIX}rs_quest_lin " +
"WHERE " + SELECT_JOINS + "{PREFIX}quest_lin.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_quest_lin.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -142,7 +142,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -142,7 +142,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
else if (refName.equals (Question.SINGLEREFERENCE_Section)) else if (refName.equals (Question.SINGLEREFERENCE_Section))
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}quest_lin " + "FROM {PREFIX}rs_quest_lin " +
"WHERE " + SELECT_JOINS + "section_number = ?"; "WHERE " + SELECT_JOINS + "section_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
...@@ -164,47 +164,47 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -164,47 +164,47 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet quest_linPSet = allPSets.getPersistentSet(objectID, "quest_lin"); PersistentSet rs_quest_linPSet = allPSets.getPersistentSet(objectID, "rs_quest_lin");
if (quest_linPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_quest_linPSet.getStatus () != PersistentSetStatus.PROCESSED &&
quest_linPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_quest_linPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}quest_lin " + "UPDATE {PREFIX}rs_quest_lin " +
"SET left_quest = ?, section_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET left_quest = ?, section_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE quest_lin.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_quest_lin.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (SQLManager.CheckNull((Long)(quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (SQLManager.CheckNull((Long)(rs_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}quest_lin WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_quest_lin WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "quest_lin", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_quest_lin", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (QuestionPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (QuestionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "quest_lin"); throw new ConcurrentUpdateConflictException (obj, "rs_quest_lin");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:quest_lin for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_quest_lin for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (QuestionPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (QuestionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
quest_linPSet.setStatus (PersistentSetStatus.PROCESSED); rs_quest_linPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -219,42 +219,42 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -219,42 +219,42 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet quest_linPSet = allPSets.getPersistentSet(objectID, "quest_lin"); PersistentSet rs_quest_linPSet = allPSets.getPersistentSet(objectID, "rs_quest_lin");
LogMgr.log (QuestionPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (QuestionPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (quest_linPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_quest_linPSet.getStatus () != PersistentSetStatus.PROCESSED &&
quest_linPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_quest_linPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}quest_lin " + "FROM {PREFIX}rs_quest_lin " +
"WHERE quest_lin.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_quest_lin.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}quest_lin WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_quest_lin WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "quest_lin"); throw new ConcurrentUpdateConflictException (obj, "rs_quest_lin");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:quest_lin for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_quest_lin for row:" + objectID;
LogMgr.log (QuestionPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (QuestionPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
quest_linPSet.setStatus (PersistentSetStatus.PROCESSED); rs_quest_linPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -309,7 +309,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -309,7 +309,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet quest_linPSet = allPSets.getPersistentSet(objectID, "quest_lin", PersistentSetStatus.FETCHED); PersistentSet rs_quest_linPSet = allPSets.getPersistentSet(objectID, "rs_quest_lin", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -368,7 +368,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -368,7 +368,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}quest_lin " + tables + "FROM {PREFIX}rs_quest_lin " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -384,12 +384,12 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -384,12 +384,12 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY quest_lin.object_id"; String orderBy = " ORDER BY rs_quest_lin.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: quest_lin.object_id is not null Object[] searchParams; // paramFilter: rs_quest_lin.object_id is not null
String preFilter = "(quest_lin.object_id is not null)" String preFilter = "(rs_quest_lin.object_id is not null)"
+ " "; + " ";
...@@ -404,7 +404,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -404,7 +404,7 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}quest_lin " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_quest_lin " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -424,17 +424,17 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -424,17 +424,17 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet quest_linPSet = allPSets.getPersistentSet(objectID, "quest_lin", PersistentSetStatus.FETCHED); PersistentSet rs_quest_linPSet = allPSets.getPersistentSet(objectID, "rs_quest_lin", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
quest_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_quest_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
quest_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_quest_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
quest_linPSet.setAttrib(Question.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "left_quest")); rs_quest_linPSet.setAttrib(Question.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "left_quest"));
quest_linPSet.setAttrib(Question.SINGLEREFERENCE_Section, r.getObject ("section_number")); rs_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_Section, r.getObject ("section_number"));
} }
...@@ -442,21 +442,21 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -442,21 +442,21 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet quest_linPSet = allPSets.getPersistentSet(objectID, "quest_lin"); PersistentSet rs_quest_linPSet = allPSets.getPersistentSet(objectID, "rs_quest_lin");
if (quest_linPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_quest_linPSet.getStatus () != PersistentSetStatus.PROCESSED &&
quest_linPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_quest_linPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}quest_lin " + "INSERT INTO {PREFIX}rs_quest_lin " +
" (left_quest, section_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (left_quest, section_number, 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, quest_linPSet.getAttrib (Question.FIELD_Description))) .listEntry (SQLManager.CheckNull((Long)(quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_quest_linPSet.getAttrib (Question.FIELD_Description))) .listEntry (SQLManager.CheckNull((Long)(rs_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))) .listEntry (objectID.longID ()).toList().toArray());
quest_linPSet.setStatus (PersistentSetStatus.PROCESSED); rs_quest_linPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class Section extends BaseSection ...@@ -10,4 +10,10 @@ public class Section extends BaseSection
{ {
// 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
public String getObjectIDSpace()
{
return "Section";
}
} }
\ No newline at end of file
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
<MULTIPLEREFERENCE name="Questions" type="Question" backreferenceName="Section" /> <MULTIPLEREFERENCE name="Questions" type="Question" backreferenceName="Section" />
<TABLE name="quest_hdr" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_quest_hdr" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="quest_hdr_desc" length="30"/> <ATTRIB name="Description" type="String" dbcol="quest_hdr_desc" length="30"/>
<ATTRIB name="QuestionType" type="QuestionType" dbcol="quest_type_flag" attribHelper="EnumeratedAttributeHelper" /> <ATTRIB name="QuestionType" type="QuestionType" dbcol="quest_type_flag" attribHelper="EnumeratedAttributeHelper" />
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="quest_hdr.object_id is not null" orderBy="quest_hdr.object_id" /> <SEARCH type="All" paramFilter="rs_quest_hdr.object_id is not null" orderBy="rs_quest_hdr.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -45,7 +45,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -45,7 +45,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}quest_hdr.object_id as id, {PREFIX}quest_hdr.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}quest_hdr.object_CREATED_DATE as CREATED_DATE, {PREFIX}quest_hdr.quest_hdr_desc, {PREFIX}quest_hdr.quest_type_flag, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_quest_hdr.object_id as id, {PREFIX}rs_quest_hdr.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_quest_hdr.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_quest_hdr.quest_hdr_desc, {PREFIX}rs_quest_hdr.quest_type_flag, 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
...@@ -90,14 +90,14 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -90,14 +90,14 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet quest_hdrPSet = allPSets.getPersistentSet(id, "quest_hdr", PersistentSetStatus.FETCHED); PersistentSet rs_quest_hdrPSet = allPSets.getPersistentSet(id, "rs_quest_hdr", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !quest_hdrPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_quest_hdrPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!quest_hdrPSet.containsAttrib(Section.FIELD_Description)|| !rs_quest_hdrPSet.containsAttrib(Section.FIELD_Description)||
!quest_hdrPSet.containsAttrib(Section.FIELD_QuestionType)) !rs_quest_hdrPSet.containsAttrib(Section.FIELD_QuestionType))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -120,8 +120,8 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -120,8 +120,8 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}quest_hdr " + "FROM {PREFIX}rs_quest_hdr " +
"WHERE " + SELECT_JOINS + "{PREFIX}quest_hdr.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_quest_hdr.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -158,47 +158,47 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -158,47 +158,47 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet quest_hdrPSet = allPSets.getPersistentSet(objectID, "quest_hdr"); PersistentSet rs_quest_hdrPSet = allPSets.getPersistentSet(objectID, "rs_quest_hdr");
if (quest_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_quest_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED &&
quest_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_quest_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}quest_hdr " + "UPDATE {PREFIX}rs_quest_hdr " +
"SET quest_hdr_desc = ?, quest_type_flag = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET quest_hdr_desc = ?, quest_type_flag = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE quest_hdr.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_quest_hdr.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, quest_hdrPSet.getAttrib (Section.FIELD_Description))).listEntry (HELPER_QuestionType.getForSQL(dummyQuestionType, quest_hdrPSet.getAttrib (Section.FIELD_QuestionType))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_quest_hdrPSet.getAttrib (Section.FIELD_Description))).listEntry (HELPER_QuestionType.getForSQL(dummyQuestionType, rs_quest_hdrPSet.getAttrib (Section.FIELD_QuestionType))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}quest_hdr WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_quest_hdr WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "quest_hdr", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_quest_hdr", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (SectionPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (SectionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "quest_hdr"); throw new ConcurrentUpdateConflictException (obj, "rs_quest_hdr");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:quest_hdr for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_quest_hdr for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (SectionPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (SectionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
quest_hdrPSet.setStatus (PersistentSetStatus.PROCESSED); rs_quest_hdrPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -213,42 +213,42 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -213,42 +213,42 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet quest_hdrPSet = allPSets.getPersistentSet(objectID, "quest_hdr"); PersistentSet rs_quest_hdrPSet = allPSets.getPersistentSet(objectID, "rs_quest_hdr");
LogMgr.log (SectionPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (SectionPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (quest_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_quest_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED &&
quest_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_quest_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}quest_hdr " + "FROM {PREFIX}rs_quest_hdr " +
"WHERE quest_hdr.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_quest_hdr.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}quest_hdr WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_quest_hdr WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "quest_hdr"); throw new ConcurrentUpdateConflictException (obj, "rs_quest_hdr");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:quest_hdr for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_quest_hdr for row:" + objectID;
LogMgr.log (SectionPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (SectionPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
quest_hdrPSet.setStatus (PersistentSetStatus.PROCESSED); rs_quest_hdrPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -303,7 +303,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -303,7 +303,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet quest_hdrPSet = allPSets.getPersistentSet(objectID, "quest_hdr", PersistentSetStatus.FETCHED); PersistentSet rs_quest_hdrPSet = allPSets.getPersistentSet(objectID, "rs_quest_hdr", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -362,7 +362,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -362,7 +362,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}quest_hdr " + tables + "FROM {PREFIX}rs_quest_hdr " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -378,12 +378,12 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -378,12 +378,12 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY quest_hdr.object_id"; String orderBy = " ORDER BY rs_quest_hdr.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: quest_hdr.object_id is not null Object[] searchParams; // paramFilter: rs_quest_hdr.object_id is not null
String preFilter = "(quest_hdr.object_id is not null)" String preFilter = "(rs_quest_hdr.object_id is not null)"
+ " "; + " ";
...@@ -398,7 +398,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -398,7 +398,7 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}quest_hdr " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_quest_hdr " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -418,16 +418,16 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -418,16 +418,16 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet quest_hdrPSet = allPSets.getPersistentSet(objectID, "quest_hdr", PersistentSetStatus.FETCHED); PersistentSet rs_quest_hdrPSet = allPSets.getPersistentSet(objectID, "rs_quest_hdr", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
quest_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_quest_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
quest_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_quest_hdrPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
quest_hdrPSet.setAttrib(Section.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "quest_hdr_desc")); rs_quest_hdrPSet.setAttrib(Section.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "quest_hdr_desc"));
quest_hdrPSet.setAttrib(Section.FIELD_QuestionType, HELPER_QuestionType.getFromRS(dummyQuestionType, r, "quest_type_flag")); rs_quest_hdrPSet.setAttrib(Section.FIELD_QuestionType, HELPER_QuestionType.getFromRS(dummyQuestionType, r, "quest_type_flag"));
} }
...@@ -436,21 +436,21 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr ...@@ -436,21 +436,21 @@ public class SectionPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet quest_hdrPSet = allPSets.getPersistentSet(objectID, "quest_hdr"); PersistentSet rs_quest_hdrPSet = allPSets.getPersistentSet(objectID, "rs_quest_hdr");
if (quest_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_quest_hdrPSet.getStatus () != PersistentSetStatus.PROCESSED &&
quest_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_quest_hdrPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}quest_hdr " + "INSERT INTO {PREFIX}rs_quest_hdr " +
" (quest_hdr_desc, quest_type_flag, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (quest_hdr_desc, quest_type_flag, 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, quest_hdrPSet.getAttrib (Section.FIELD_Description))).listEntry (HELPER_QuestionType.getForSQL(dummyQuestionType, quest_hdrPSet.getAttrib (Section.FIELD_QuestionType))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, rs_quest_hdrPSet.getAttrib (Section.FIELD_Description))).listEntry (HELPER_QuestionType.getForSQL(dummyQuestionType, rs_quest_hdrPSet.getAttrib (Section.FIELD_QuestionType))) .listEntry (objectID.longID ()).toList().toArray());
quest_hdrPSet.setStatus (PersistentSetStatus.PROCESSED); rs_quest_hdrPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -10,4 +10,10 @@ public class TestAnalysis extends BaseTestAnalysis ...@@ -10,4 +10,10 @@ public class TestAnalysis extends BaseTestAnalysis
{ {
// 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
public String getObjectIDSpace()
{
return "TestAnalysis";
}
} }
\ No newline at end of file
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
<MULTIPLEREFERENCE name="FactorScores" type="FactorScore" backreferenceName="TestAnalysis" /> <MULTIPLEREFERENCE name="FactorScores" type="FactorScore" backreferenceName="TestAnalysis" />
<TABLE name="test_analysis" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_test_analysis" tablePrefix="object" polymorphic="FALSE">
<SINGLEREFERENCE name="Level" type="Level" dbcol="level_id"/> <SINGLEREFERENCE name="Level" type="Level" dbcol="level_id" backreferenceName="TestAnalysises"/>
<SINGLEREFERENCE name="Candidate" type="Candidate" dbcol="candidate_id"/> <SINGLEREFERENCE name="Candidate" type="Candidate" dbcol="candidate_id" backreferenceName="TestAnalysises"/>
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="test_analysis.object_id is not null" orderBy="test_analysis.object_id" /> <SEARCH type="All" paramFilter="rs_test_analysis.object_id is not null" orderBy="rs_test_analysis.object_id" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -38,7 +38,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -38,7 +38,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}test_analysis.object_id as id, {PREFIX}test_analysis.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}test_analysis.object_CREATED_DATE as CREATED_DATE, {PREFIX}test_analysis.level_id, {PREFIX}test_analysis.candidate_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_test_analysis.object_id as id, {PREFIX}rs_test_analysis.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_test_analysis.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_test_analysis.level_id, {PREFIX}rs_test_analysis.candidate_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
...@@ -83,14 +83,14 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -83,14 +83,14 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet test_analysisPSet = allPSets.getPersistentSet(id, "test_analysis", PersistentSetStatus.FETCHED); PersistentSet rs_test_analysisPSet = allPSets.getPersistentSet(id, "rs_test_analysis", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !test_analysisPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_test_analysisPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!test_analysisPSet.containsAttrib(TestAnalysis.SINGLEREFERENCE_Level)|| !rs_test_analysisPSet.containsAttrib(TestAnalysis.SINGLEREFERENCE_Level)||
!test_analysisPSet.containsAttrib(TestAnalysis.SINGLEREFERENCE_Candidate)) !rs_test_analysisPSet.containsAttrib(TestAnalysis.SINGLEREFERENCE_Candidate))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -113,8 +113,8 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -113,8 +113,8 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}test_analysis " + "FROM {PREFIX}rs_test_analysis " +
"WHERE " + SELECT_JOINS + "{PREFIX}test_analysis.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}rs_test_analysis.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -136,6 +136,26 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -136,6 +136,26 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException (); throw new RuntimeException ();
} }
else if (refName.equals (TestAnalysis.SINGLEREFERENCE_Level))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_test_analysis " +
"WHERE " + SELECT_JOINS + "level_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else if (refName.equals (TestAnalysis.SINGLEREFERENCE_Candidate))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}rs_test_analysis " +
"WHERE " + SELECT_JOINS + "candidate_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);
...@@ -151,47 +171,47 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -151,47 +171,47 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis"); PersistentSet rs_test_analysisPSet = allPSets.getPersistentSet(objectID, "rs_test_analysis");
if (test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED &&
test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}test_analysis " + "UPDATE {PREFIX}rs_test_analysis " +
"SET level_id = ? , candidate_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET level_id = ? , candidate_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE test_analysis.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_test_analysis.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Candidate)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (SQLManager.CheckNull((Long)(rs_test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Candidate)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}test_analysis WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}rs_test_analysis WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "test_analysis", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "rs_test_analysis", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (TestAnalysisPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (TestAnalysisPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "test_analysis"); throw new ConcurrentUpdateConflictException (obj, "rs_test_analysis");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:test_analysis for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:rs_test_analysis for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (TestAnalysisPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (TestAnalysisPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED); rs_test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -206,42 +226,42 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -206,42 +226,42 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis"); PersistentSet rs_test_analysisPSet = allPSets.getPersistentSet(objectID, "rs_test_analysis");
LogMgr.log (TestAnalysisPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (TestAnalysisPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED &&
test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}test_analysis " + "FROM {PREFIX}rs_test_analysis " +
"WHERE test_analysis.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE rs_test_analysis.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}test_analysis WHERE object_id = ?", "SELECT object_id FROM {PREFIX}rs_test_analysis WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "test_analysis"); throw new ConcurrentUpdateConflictException (obj, "rs_test_analysis");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:test_analysis for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:rs_test_analysis for row:" + objectID;
LogMgr.log (TestAnalysisPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (TestAnalysisPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED); rs_test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -296,7 +316,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -296,7 +316,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis", PersistentSetStatus.FETCHED); PersistentSet rs_test_analysisPSet = allPSets.getPersistentSet(objectID, "rs_test_analysis", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
...@@ -355,7 +375,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -355,7 +375,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}test_analysis " + tables + "FROM {PREFIX}rs_test_analysis " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -371,12 +391,12 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -371,12 +391,12 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
String orderBy = " ORDER BY test_analysis.object_id"; String orderBy = " ORDER BY rs_test_analysis.object_id";
String tables = " "; String tables = " ";
Set<String> joinTableSet = new HashSet<String>(); Set<String> joinTableSet = new HashSet<String>();
String filter; String filter;
Object[] searchParams; // paramFilter: test_analysis.object_id is not null Object[] searchParams; // paramFilter: rs_test_analysis.object_id is not null
String preFilter = "(test_analysis.object_id is not null)" String preFilter = "(rs_test_analysis.object_id is not null)"
+ " "; + " ";
...@@ -391,7 +411,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -391,7 +411,7 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}test_analysis " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}rs_test_analysis " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -411,17 +431,17 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -411,17 +431,17 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis", PersistentSetStatus.FETCHED); PersistentSet rs_test_analysisPSet = allPSets.getPersistentSet(objectID, "rs_test_analysis", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
test_analysisPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); rs_test_analysisPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
test_analysisPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_test_analysisPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
test_analysisPSet.setAttrib(TestAnalysis.SINGLEREFERENCE_Level, r.getObject ("level_id")); rs_test_analysisPSet.setAttrib(TestAnalysis.SINGLEREFERENCE_Level, r.getObject ("level_id"));
test_analysisPSet.setAttrib(TestAnalysis.SINGLEREFERENCE_Candidate, r.getObject ("candidate_id")); rs_test_analysisPSet.setAttrib(TestAnalysis.SINGLEREFERENCE_Candidate, r.getObject ("candidate_id"));
} }
...@@ -429,21 +449,21 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr ...@@ -429,21 +449,21 @@ public class TestAnalysisPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet test_analysisPSet = allPSets.getPersistentSet(objectID, "test_analysis"); PersistentSet rs_test_analysisPSet = allPSets.getPersistentSet(objectID, "rs_test_analysis");
if (test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED && if (rs_test_analysisPSet.getStatus () != PersistentSetStatus.PROCESSED &&
test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED) rs_test_analysisPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}test_analysis " + "INSERT INTO {PREFIX}rs_test_analysis " +
" ( level_id, candidate_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " ( level_id, candidate_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 (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Candidate)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils .listEntry (SQLManager.CheckNull((Long)(rs_test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_test_analysisPSet.getAttrib (TestAnalysis.SINGLEREFERENCE_Candidate)))) .listEntry (objectID.longID ()).toList().toArray());
test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED); rs_test_analysisPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
<MULTIPLEREFERENCE name="Candidates" type="Candidate" backreferenceName="TestInput" owner="true"/> <MULTIPLEREFERENCE name="Candidates" type="Candidate" backreferenceName="TestInput" owner="true"/>
<TABLE name="it_does_not_matter" tablePrefix="OBJECT" polymorphic="FALSE"> <TABLE tablePrefix="OBJECT" polymorphic="FALSE">
<ATTRIB name="CSV" type="BinaryContent" dbcol="xxxx" binaryHandler="loggedin" mandatory="true" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" /> <ATTRIB name="CSV" type="BinaryContent" mandatory="true" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" binaryHandler="loggedin"/>
</TABLE> </TABLE>
......
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import oneit.servlets.orm.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class TestInputPersistenceMgr extends NonPersistentBOPersistenceMgr
{
private static final LoggingArea TestInputPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "TestInput");
// Private attributes corresponding to business object data
private BinaryContent dummyCSV;
// Static constants corresponding to attribute helpers
private static final BLOBAttributeHelper HELPER_CSV = BLOBAttributeHelper.INSTANCE;
public TestInputPersistenceMgr ()
{
dummyCSV = (BinaryContent)(HELPER_CSV.initialise (dummyCSV));
}
private String SELECT_COLUMNS = "{PREFIX}it_does_not_matter.OBJECT_id as id, {PREFIX}it_does_not_matter.OBJECT_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}it_does_not_matter.OBJECT_CREATED_DATE as CREATED_DATE, {PREFIX}it_does_not_matter.xxxx, 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, TestInput.REFERENCE_TestInput);
if (objectToReturn instanceof TestInput)
{
LogMgr.log (TestInputPersistence, 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 TestInput");
}
}
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(id, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !it_does_not_matterPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!it_does_not_matterPSet.containsAttrib(TestInput.FIELD_CSV))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (TestInputPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
TestInput result = new TestInput ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}it_does_not_matter " +
"WHERE " + SELECT_JOINS + "{PREFIX}it_does_not_matter.OBJECT_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}it_does_not_matter " +
"SET xxxx = ? , OBJECT_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE it_does_not_matter.OBJECT_id = ? AND " + getConcurrencyCheck (sqlMgr, "OBJECT_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_CSV.getForSQL(dummyCSV, it_does_not_matterPSet.getAttrib (TestInput.FIELD_CSV))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT OBJECT_id, OBJECT_LAST_UPDATED_DATE FROM {PREFIX}it_does_not_matter WHERE OBJECT_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "it_does_not_matter", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (TestInputPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:it_does_not_matter for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (TestInputPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (TestInputPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
LogMgr.log (TestInputPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}it_does_not_matter " +
"WHERE it_does_not_matter.OBJECT_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("OBJECT_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT OBJECT_id FROM {PREFIX}it_does_not_matter WHERE OBJECT_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:it_does_not_matter for row:" + objectID;
LogMgr.log (TestInputPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, TestInput> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (TestInput.REFERENCE_TestInput.getObjectIDSpace (), r.getLong ("id"));
TestInput 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, TestInput.REFERENCE_TestInput);
if (cachedElement instanceof TestInput)
{
LogMgr.log (TestInputPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (TestInput)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a TestInput");
}
}
else
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new TestInput ();
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 (TestInputPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}it_does_not_matter " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else
{
BaseBusinessClass[] resultsArray = super.find(searchType, allPSets, criteria, context, sqlMgr);
Vector results = new Vector ();
for (int x = 0 ; x < resultsArray.length ; ++x)
{
if (resultsArray[x] instanceof TestInput)
{
results.add (resultsArray[x]);
}
else
{
// Ignore
}
}
resultsArray = new BaseBusinessClass[results.size ()];
results.copyInto (resultsArray);
return resultsArray;
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Object Modified
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
it_does_not_matterPSet.setAttrib(TestInput.FIELD_CSV, HELPER_CSV.getFromRS(dummyCSV, r, "xxxx"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}it_does_not_matter " +
" (xxxx, OBJECT_id, OBJECT_LAST_UPDATED_DATE, OBJECT_CREATED_DATE) " +
"VALUES " +
" (?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_CSV.getForSQL(dummyCSV, it_does_not_matterPSet.getAttrib (TestInput.FIELD_CSV))) .listEntry (objectID.longID ()).toList().toArray());
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment