Commit 5666e3b8 by Harsh Shah

Right question related BO change

parent ef027e12
......@@ -8,10 +8,14 @@
<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="left_quest" type="String" nullable="true" length="80"/>
<column name="description" type="String" nullable="true" length="80"/>
<column name="is_right_quest" type="Boolean" nullable="true"/>
<column name="section_number" type="Long" length="11" nullable="true"/>
<column name="right_quest_number" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_section_number" isUnique="false"><column name="section_number"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_quest_lin" indexName="idx_tl_quest_lin_right_quest_number" isUnique="false"><column name="right_quest_number"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
......@@ -8,8 +8,10 @@ CREATE TABLE tl_quest_lin (
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
left_quest varchar(80) NULL,
section_number numeric(12) NULL
description varchar(80) NULL,
is_right_quest char(1) NULL,
section_number numeric(12) NULL,
right_quest_number numeric(12) NULL
);
......@@ -24,3 +26,6 @@ ALTER TABLE tl_quest_lin ADD
CREATE INDEX idx_tl_quest_lin_section_number
ON tl_quest_lin (section_number);
CREATE INDEX idx_tl_quest_lin_right_quest_number
ON tl_quest_lin (right_quest_number);
......@@ -9,8 +9,10 @@ CREATE TABLE tl_quest_lin (
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
left_quest varchar2(80) NULL,
section_number number(12) NULL
description varchar2(80) NULL,
is_right_quest char(1) NULL,
section_number number(12) NULL,
right_quest_number number(12) NULL
);
......@@ -25,3 +27,6 @@ ALTER TABLE tl_quest_lin ADD
CREATE INDEX idx_tl_quest_lin_section_number
ON tl_quest_lin (section_number);
CREATE INDEX idx_tl_quest_lin_right_quest_number
ON tl_quest_lin (right_quest_number);
......@@ -9,8 +9,10 @@ CREATE TABLE tl_quest_lin (
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
left_quest varchar(80) NULL,
section_number numeric(12) NULL
description varchar(80) NULL,
is_right_quest char(1) NULL,
section_number numeric(12) NULL,
right_quest_number numeric(12) NULL
);
......@@ -25,3 +27,6 @@ ALTER TABLE tl_quest_lin ADD
CREATE INDEX idx_tl_quest_lin_section_number
ON tl_quest_lin (section_number);
CREATE INDEX idx_tl_quest_lin_right_quest_number
ON tl_quest_lin (right_quest_number);
......@@ -5,12 +5,15 @@
<BUSINESSCLASS name="Question" package="performa.orm">
<MULTIPLEREFERENCE name="Factors" type="FactorQuestionLink" backreferenceName="Question" />
<MULTIPLEREFERENCE name="LeftQuestions" type="Question" backreferenceName="RightQuestion" /> <!-- Can't be greater than 1 -->
<TABLE name="tl_quest_lin" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Description" type="String" dbcol="left_quest" length="80"/>
<ATTRIB name="Description" type="String" dbcol="description" length="80"/>
<ATTRIB name="IsRightQuestion" type="Boolean" dbcol="is_right_quest" defaultValue="Boolean.FALSE"/>
<SINGLEREFERENCE name="Section" type="Section" dbcol="section_number" backreferenceName="Questions"/>
<SINGLEREFERENCE name="RightQuestion" type="Question" dbcol="right_quest_number" backreferenceName="LeftQuestions"/>
</TABLE>
......
......@@ -27,10 +27,12 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
// Private attributes corresponding to business object data
private String dummyDescription;
private Boolean dummyIsRightQuestion;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Description = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_IsRightQuestion = DefaultAttributeHelper.INSTANCE;
......@@ -38,10 +40,11 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
public QuestionPersistenceMgr ()
{
dummyDescription = (String)(HELPER_Description.initialise (dummyDescription));
dummyIsRightQuestion = (Boolean)(HELPER_IsRightQuestion.initialise (dummyIsRightQuestion));
}
private String SELECT_COLUMNS = "{PREFIX}tl_quest_lin.object_id as id, {PREFIX}tl_quest_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_quest_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_quest_lin.left_quest, {PREFIX}tl_quest_lin.section_number, 1 AS commasafe ";
private String SELECT_COLUMNS = "{PREFIX}tl_quest_lin.object_id as id, {PREFIX}tl_quest_lin.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_quest_lin.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_quest_lin.description, {PREFIX}tl_quest_lin.is_right_quest, {PREFIX}tl_quest_lin.section_number, {PREFIX}tl_quest_lin.right_quest_number, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
......@@ -93,7 +96,9 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
// Check for persistent sets already prefetched
if (false || !tl_quest_linPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_quest_linPSet.containsAttrib(Question.FIELD_Description)||
!tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_Section))
!tl_quest_linPSet.containsAttrib(Question.FIELD_IsRightQuestion)||
!tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_Section)||
!tl_quest_linPSet.containsAttrib(Question.SINGLEREFERENCE_RightQuestion))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
......@@ -149,6 +154,16 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
return results;
}
else if (refName.equals (Question.SINGLEREFERENCE_RightQuestion))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_quest_lin " +
"WHERE " + SELECT_JOINS + "right_quest_number = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
......@@ -173,10 +188,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_quest_lin " +
"SET left_quest = ?, section_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"SET description = ?, is_right_quest = ?, section_number = ? , right_quest_number = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_quest_lin.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (HELPER_IsRightQuestion.getForSQL(dummyIsRightQuestion, tl_quest_linPSet.getAttrib (Question.FIELD_IsRightQuestion))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_RightQuestion)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
......@@ -432,9 +447,11 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
// Object Created
tl_quest_linPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_quest_linPSet.setAttrib(Question.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "left_quest"));
tl_quest_linPSet.setAttrib(Question.FIELD_Description, HELPER_Description.getFromRS(dummyDescription, r, "description"));
tl_quest_linPSet.setAttrib(Question.FIELD_IsRightQuestion, HELPER_IsRightQuestion.getFromRS(dummyIsRightQuestion, r, "is_right_quest"));
tl_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_Section, r.getObject ("section_number"));
tl_quest_linPSet.setAttrib(Question.SINGLEREFERENCE_RightQuestion, r.getObject ("right_quest_number"));
}
......@@ -451,10 +468,10 @@ public class QuestionPersistenceMgr extends ObjectPersistenceMgr
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_quest_lin " +
" (left_quest, section_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
" (description, is_right_quest, section_number, right_quest_number, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))) .listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))) .listEntry (objectID.longID ()).toList().toArray());
" (?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Description.getForSQL(dummyDescription, tl_quest_linPSet.getAttrib (Question.FIELD_Description))).listEntry (HELPER_IsRightQuestion.getForSQL(dummyIsRightQuestion, tl_quest_linPSet.getAttrib (Question.FIELD_IsRightQuestion))) .listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_Section)))).listEntry (SQLManager.CheckNull((Long)(tl_quest_linPSet.getAttrib (Question.SINGLEREFERENCE_RightQuestion)))) .listEntry (objectID.longID ()).toList().toArray());
tl_quest_linPSet.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