Commit 6881ffbc by nilu

diversity changes

parent ed157008
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_answer_option</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="candidate_answer_id" type="Long" length="11" nullable="false"/>
<column name="answer_id" type="Long" length="11" nullable="false"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_answer_option" indexName="idx_tl_answer_option_candidate_answer_id" isUnique="false"><column name="candidate_answer_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<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_id" type="Long" length="11" nullable="false"/>
<column name="question_id" type="Long" length="11" nullable="false"/> <column name="question_id" type="Long" length="11" nullable="false"/>
<column name="candidate_id" type="Long" length="11" nullable="false"/> <column name="candidate_id" type="Long" length="11" nullable="false"/>
</NODE> </NODE>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<column name="question_code" type="CLOB" nullable="false"/> <column name="question_code" type="CLOB" nullable="false"/>
<column name="question_text" type="CLOB" nullable="false"/> <column name="question_text" type="CLOB" nullable="false"/>
<column name="australia_only" type="Boolean" nullable="true"/> <column name="australia_only" type="Boolean" nullable="true"/>
<column name="multiple_answers" type="Boolean" nullable="true"/>
</NODE> </NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE tl_answer_option;
CREATE TABLE tl_answer_option (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
candidate_answer_id numeric(12) NOT NULL,
answer_id numeric(12) NOT NULL
);
ALTER TABLE tl_answer_option ADD
CONSTRAINT PK_tl_answer_option PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_answer_option_candidate_answer_id
ON tl_answer_option (candidate_answer_id);
...@@ -8,7 +8,6 @@ CREATE TABLE tl_candidate_diversity_answer ( ...@@ -8,7 +8,6 @@ CREATE TABLE tl_candidate_diversity_answer (
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_id numeric(12) NOT NULL,
question_id numeric(12) NOT NULL, question_id numeric(12) NOT NULL,
candidate_id numeric(12) NOT NULL candidate_id numeric(12) NOT NULL
); );
......
...@@ -10,7 +10,8 @@ CREATE TABLE tl_diversity_question ( ...@@ -10,7 +10,8 @@ CREATE TABLE tl_diversity_question (
, ,
question_code text NOT NULL, question_code text NOT NULL,
question_text text NOT NULL, question_text text NOT NULL,
australia_only char(1) NULL australia_only char(1) NULL,
multiple_answers char(1) NULL
); );
......
-- DROP TABLE tl_answer_option;
CREATE TABLE tl_answer_option (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
candidate_answer_id number(12) NOT NULL,
answer_id number(12) NOT NULL
);
ALTER TABLE tl_answer_option ADD
CONSTRAINT PK_tl_answer_option PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_answer_option_candidate_answer_id
ON tl_answer_option (candidate_answer_id);
...@@ -9,7 +9,6 @@ CREATE TABLE tl_candidate_diversity_answer ( ...@@ -9,7 +9,6 @@ CREATE TABLE tl_candidate_diversity_answer (
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_id number(12) NOT NULL,
question_id number(12) NOT NULL, question_id number(12) NOT NULL,
candidate_id number(12) NOT NULL candidate_id number(12) NOT NULL
); );
......
...@@ -11,7 +11,8 @@ CREATE TABLE tl_diversity_question ( ...@@ -11,7 +11,8 @@ CREATE TABLE tl_diversity_question (
, ,
question_code clob NOT NULL, question_code clob NOT NULL,
question_text clob NOT NULL, question_text clob NOT NULL,
australia_only char(1) NULL australia_only char(1) NULL,
multiple_answers char(1) NULL
); );
......
-- @AutoRun
-- drop table tl_answer_option;
CREATE TABLE tl_answer_option (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
candidate_answer_id numeric(12) NOT NULL,
answer_id numeric(12) NOT NULL
);
ALTER TABLE tl_answer_option ADD
CONSTRAINT pk_tl_answer_option PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_answer_option_candidate_answer_id
ON tl_answer_option (candidate_answer_id);
...@@ -9,7 +9,6 @@ CREATE TABLE tl_candidate_diversity_answer ( ...@@ -9,7 +9,6 @@ CREATE TABLE tl_candidate_diversity_answer (
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_id numeric(12) NOT NULL,
question_id numeric(12) NOT NULL, question_id numeric(12) NOT NULL,
candidate_id numeric(12) NOT NULL candidate_id numeric(12) NOT NULL
); );
......
...@@ -11,7 +11,8 @@ CREATE TABLE tl_diversity_question ( ...@@ -11,7 +11,8 @@ CREATE TABLE tl_diversity_question (
, ,
question_code text NOT NULL, question_code text NOT NULL,
question_text text NOT NULL, question_text text NOT NULL,
australia_only char(1) NULL australia_only char(1) NULL,
multiple_answers char(1) NULL
); );
......
...@@ -8,6 +8,7 @@ import oneit.logging.*; ...@@ -8,6 +8,7 @@ import oneit.logging.*;
import oneit.objstore.ObjectTransaction; import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException; import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser; import oneit.objstore.parser.BusinessObjectParser;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.security.SecUser; import oneit.security.SecUser;
import oneit.servlets.forms.*; import oneit.servlets.forms.*;
import oneit.servlets.process.*; import oneit.servlets.process.*;
...@@ -64,6 +65,14 @@ public class SendVerificationMailFP extends SaveFP ...@@ -64,6 +65,14 @@ public class SendVerificationMailFP extends SaveFP
BusinessObjectParser.assertFieldCondition(candidate.getGoogleAddressText() != null, candidate, Candidate.FIELD_GoogleAddressText, "mandatory", exceptions, true, request); BusinessObjectParser.assertFieldCondition(candidate.getGoogleAddressText() != null, candidate, Candidate.FIELD_GoogleAddressText, "mandatory", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(candidate.isTrue(candidate.getHasValidAddress()), candidate, Candidate.FIELD_GoogleAddressText, "invalid", exceptions, true, request); BusinessObjectParser.assertFieldCondition(candidate.isTrue(candidate.getHasValidAddress()), candidate, Candidate.FIELD_GoogleAddressText, "invalid", exceptions, true, request);
if(candidate.getAnsweredDiversity())
{
for(HTDiversityQuestion htQuestion : job.getDiversityQuestions())
{
BusinessObjectParser.assertFieldCondition(candidate.hasAnswer(htQuestion), candidate, Candidate.MULTIPLEREFERENCE_DiversityAnswers, "mandatory", exceptions, true, request);
}
}
} }
super.validate(process, submission, exceptions, params); super.validate(process, submission, exceptions, params);
......
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
public class AnswerOption extends BaseAnswerOption
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public AnswerOption ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="AnswerOption" package="performa.orm">
<TABLE name="tl_answer_option" tablePrefix="object" polymorphic="FALSE">
<SINGLEREFERENCE name="CandidateAnswer" type="CandidateDiversityAnswer" dbcol="candidate_answer_id" mandatory="true" backreferenceName="Answers"/>
<SINGLEREFERENCE name="Answer" type="DiversityAnswer" dbcol="answer_id" mandatory="true" />
</TABLE>
<SEARCH type="All" paramFilter="tl_answer_option.object_id is not null" orderBy="tl_answer_option.object_id" />
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class AnswerOptionPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea AnswerOptionPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "AnswerOption");
// Private attributes corresponding to business object data
// Static constants corresponding to attribute helpers
public AnswerOptionPersistenceMgr ()
{
}
private String SELECT_COLUMNS = "{PREFIX}tl_answer_option.object_id as id, {PREFIX}tl_answer_option.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_answer_option.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_answer_option.candidate_answer_id, {PREFIX}tl_answer_option.answer_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, AnswerOption.REFERENCE_AnswerOption);
if (objectToReturn instanceof AnswerOption)
{
LogMgr.log (AnswerOptionPersistence, 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 AnswerOption");
}
}
PersistentSet tl_answer_optionPSet = allPSets.getPersistentSet(id, "tl_answer_option", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_answer_optionPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_answer_optionPSet.containsAttrib(AnswerOption.SINGLEREFERENCE_CandidateAnswer)||
!tl_answer_optionPSet.containsAttrib(AnswerOption.SINGLEREFERENCE_Answer))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (AnswerOptionPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
AnswerOption result = new AnswerOption ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_answer_option " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_answer_option.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else if (refName.equals (AnswerOption.SINGLEREFERENCE_CandidateAnswer))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_answer_option " +
"WHERE " + SELECT_JOINS + "candidate_answer_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet tl_answer_optionPSet = allPSets.getPersistentSet(objectID, "tl_answer_option");
if (tl_answer_optionPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_answer_optionPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_answer_option " +
"SET candidate_answer_id = ? , answer_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_answer_option.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (SQLManager.CheckNull((Long)(tl_answer_optionPSet.getAttrib (AnswerOption.SINGLEREFERENCE_CandidateAnswer)))).listEntry (SQLManager.CheckNull((Long)(tl_answer_optionPSet.getAttrib (AnswerOption.SINGLEREFERENCE_Answer)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_answer_option WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_answer_option", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (AnswerOptionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_answer_option");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_answer_option for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (AnswerOptionPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_answer_optionPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (AnswerOptionPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_answer_optionPSet = allPSets.getPersistentSet(objectID, "tl_answer_option");
LogMgr.log (AnswerOptionPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_answer_optionPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_answer_optionPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_answer_option " +
"WHERE tl_answer_option.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_answer_option WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_answer_option");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_answer_option for row:" + objectID;
LogMgr.log (AnswerOptionPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_answer_optionPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, AnswerOption> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (AnswerOption.REFERENCE_AnswerOption.getObjectIDSpace (), r.getLong ("id"));
AnswerOption 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, AnswerOption.REFERENCE_AnswerOption);
if (cachedElement instanceof AnswerOption)
{
LogMgr.log (AnswerOptionPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (AnswerOption)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a AnswerOption");
}
}
else
{
PersistentSet tl_answer_optionPSet = allPSets.getPersistentSet(objectID, "tl_answer_option", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new AnswerOption ();
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 (AnswerOptionPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_answer_option " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (AnswerOption.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY tl_answer_option.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_answer_option.object_id is not null
String preFilter = "(tl_answer_option.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_answer_option " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_answer_optionPSet = allPSets.getPersistentSet(objectID, "tl_answer_option", PersistentSetStatus.FETCHED);
// Object Modified
tl_answer_optionPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_answer_optionPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_answer_optionPSet.setAttrib(AnswerOption.SINGLEREFERENCE_CandidateAnswer, r.getObject ("candidate_answer_id"));
tl_answer_optionPSet.setAttrib(AnswerOption.SINGLEREFERENCE_Answer, r.getObject ("answer_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_answer_optionPSet = allPSets.getPersistentSet(objectID, "tl_answer_option");
if (tl_answer_optionPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_answer_optionPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_answer_option " +
" ( candidate_answer_id, answer_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" ( ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils .listEntry (SQLManager.CheckNull((Long)(tl_answer_optionPSet.getAttrib (AnswerOption.SINGLEREFERENCE_CandidateAnswer)))).listEntry (SQLManager.CheckNull((Long)(tl_answer_optionPSet.getAttrib (AnswerOption.SINGLEREFERENCE_Answer)))) .listEntry (objectID.longID ()).toList().toArray());
tl_answer_optionPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
public abstract class BaseAnswerOption extends BaseBusinessClass
{
// Reference instance for the object
public static final AnswerOption REFERENCE_AnswerOption = new AnswerOption ();
// Reference instance for the object
public static final AnswerOption DUMMY_AnswerOption = new DummyAnswerOption ();
// Static constants corresponding to field names
public static final String SINGLEREFERENCE_CandidateAnswer = "CandidateAnswer";
public static final String BACKREF_CandidateAnswer = "";
public static final String SINGLEREFERENCE_Answer = "Answer";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
// Private attributes corresponding to business object data
// Private attributes corresponding to single references
private SingleAssociation<AnswerOption, CandidateDiversityAnswer> _CandidateAnswer;
private SingleAssociation<AnswerOption, DiversityAnswer> _Answer;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_AnswerOption = new HashMap ();
// Arrays of validators for each attribute
// Arrays of behaviour decorators
private static final AnswerOptionBehaviourDecorator[] AnswerOption_BehaviourDecorators;
static
{
try
{
String tmp_CandidateAnswer = CandidateDiversityAnswer.BACKREF_Answers;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_CandidateAnswer();
setupAssocMetaData_Answer();
REFERENCE_AnswerOption.initialiseReference ();
DUMMY_AnswerOption.initialiseReference ();
AnswerOption_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(AnswerOption.class).toArray(new AnswerOptionBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_CandidateAnswer()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Answers");
metaInfo.put ("dbcol", "candidate_answer_id");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "CandidateAnswer");
metaInfo.put ("type", "CandidateDiversityAnswer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AnswerOption.CandidateAnswer:", metaInfo);
ATTRIBUTES_METADATA_AnswerOption.put (SINGLEREFERENCE_CandidateAnswer, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_Answer()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "answer_id");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Answer");
metaInfo.put ("type", "DiversityAnswer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AnswerOption.Answer:", metaInfo);
ATTRIBUTES_METADATA_AnswerOption.put (SINGLEREFERENCE_Answer, Collections.unmodifiableMap (metaInfo));
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseAnswerOption ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return AnswerOption_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_CandidateAnswer = new SingleAssociation<AnswerOption, CandidateDiversityAnswer> (this, SINGLEREFERENCE_CandidateAnswer, CandidateDiversityAnswer.MULTIPLEREFERENCE_Answers, CandidateDiversityAnswer.REFERENCE_CandidateDiversityAnswer, "tl_answer_option");
_Answer = new SingleAssociation<AnswerOption, DiversityAnswer> (this, SINGLEREFERENCE_Answer, null, DiversityAnswer.REFERENCE_DiversityAnswer, "tl_answer_option");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_CandidateAnswer = new SingleAssociation<AnswerOption, CandidateDiversityAnswer> (this, SINGLEREFERENCE_CandidateAnswer, CandidateDiversityAnswer.MULTIPLEREFERENCE_Answers, CandidateDiversityAnswer.REFERENCE_CandidateDiversityAnswer, "tl_answer_option");
_Answer = new SingleAssociation<AnswerOption, DiversityAnswer> (this, SINGLEREFERENCE_Answer, null, DiversityAnswer.REFERENCE_DiversityAnswer, "tl_answer_option");
return this;
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("CandidateAnswer");
result.add("Answer");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CandidateAnswer))
{
return _CandidateAnswer.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Answer))
{
return _Answer.getReferencedType ();
}
else
{
return super.getSingleAssocReferenceInstance (assocName);
}
}
public String getSingleAssocBackReference(String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CandidateAnswer))
{
return CandidateDiversityAnswer.MULTIPLEREFERENCE_Answers ;
}else if (assocName.equals (SINGLEREFERENCE_Answer))
{
return null ;
}
else
{
return super.getSingleAssocBackReference (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CandidateAnswer))
{
return getCandidateAnswer ();
}else if (assocName.equals (SINGLEREFERENCE_Answer))
{
return getAnswer ();
}
else
{
return super.getSingleAssoc (assocName);
}
}
public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CandidateAnswer))
{
return getCandidateAnswer (getType);
}else if (assocName.equals (SINGLEREFERENCE_Answer))
{
return getAnswer (getType);
}
else
{
return super.getSingleAssoc (assocName, getType);
}
}
public Long getSingleAssocID (String assocName) throws StorageException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CandidateAnswer))
{
return getCandidateAnswerID ();
}else if (assocName.equals (SINGLEREFERENCE_Answer))
{
return getAnswerID ();
}
else
{
return super.getSingleAssocID (assocName);
}
}
public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_CandidateAnswer))
{
setCandidateAnswer ((CandidateDiversityAnswer)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Answer))
{
setAnswer ((DiversityAnswer)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference CandidateAnswer
*/
public CandidateDiversityAnswer getCandidateAnswer () throws StorageException
{
assertValid();
try
{
return (CandidateDiversityAnswer)(_CandidateAnswer.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in AnswerOption:", this.getObjectID (), ", was trying to get CandidateDiversityAnswer:", getCandidateAnswerID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _CandidateAnswer.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public CandidateDiversityAnswer getCandidateAnswer (Get getType) throws StorageException
{
assertValid();
return _CandidateAnswer.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCandidateAnswerID ()
{
assertValid();
if (_CandidateAnswer == null)
{
return null;
}
else
{
return _CandidateAnswer.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 preCandidateAnswerChange (CandidateDiversityAnswer newCandidateAnswer) 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 postCandidateAnswerChange () throws FieldException
{
}
public FieldWriteability getWriteability_CandidateAnswer ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference CandidateAnswer. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setCandidateAnswer (CandidateDiversityAnswer newCandidateAnswer) throws StorageException, FieldException
{
BusinessObjectParser.assertFieldCondition (newCandidateAnswer != null, this, SINGLEREFERENCE_CandidateAnswer, "mandatory");
if (_CandidateAnswer.wouldReferencedChange (newCandidateAnswer))
{
assertValid();
Debug.assertion (getWriteability_CandidateAnswer () != FieldWriteability.FALSE, "Assoc CandidateAnswer is not writeable");
preCandidateAnswerChange (newCandidateAnswer);
CandidateDiversityAnswer oldCandidateAnswer = getCandidateAnswer ();
if (oldCandidateAnswer != null)
{
// This is to stop validation from triggering when we are removed
_CandidateAnswer.set (null);
oldCandidateAnswer.removeFromAnswers ((AnswerOption)(this));
}
_CandidateAnswer.set (newCandidateAnswer);
if (newCandidateAnswer != null)
{
newCandidateAnswer.addToAnswers ((AnswerOption)(this));
}
postCandidateAnswerChange ();
}
}
/**
* Get the reference Answer
*/
public DiversityAnswer getAnswer () throws StorageException
{
assertValid();
try
{
return (DiversityAnswer)(_Answer.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in AnswerOption:", this.getObjectID (), ", was trying to get DiversityAnswer:", getAnswerID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Answer.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public DiversityAnswer getAnswer (Get getType) throws StorageException
{
assertValid();
return _Answer.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getAnswerID ()
{
assertValid();
if (_Answer == null)
{
return null;
}
else
{
return _Answer.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 preAnswerChange (DiversityAnswer newAnswer) 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 postAnswerChange () throws FieldException
{
}
public FieldWriteability getWriteability_Answer ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Answer. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setAnswer (DiversityAnswer newAnswer) throws StorageException, FieldException
{
BusinessObjectParser.assertFieldCondition (newAnswer != null, this, SINGLEREFERENCE_Answer, "mandatory");
if (_Answer.wouldReferencedChange (newAnswer))
{
assertValid();
Debug.assertion (getWriteability_Answer () != FieldWriteability.FALSE, "Assoc Answer is not writeable");
preAnswerChange (newAnswer);
_Answer.set (newAnswer);
postAnswerChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getMultiAssocs()
{
List result = super.getMultiAssocs ();
return result;
}
/**
* Get the reference instance for the multi assoc name.
*/
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{
return super.getMultiAssocReferenceInstance(attribName);
}
public String getMultiAssocBackReference(String attribName)
{
return super.getMultiAssocBackReference(attribName);
}
/**
* Get the assoc count for the multi assoc name.
*/
public int getMultiAssocCount(String attribName) throws StorageException
{
return super.getMultiAssocCount(attribName);
}
/**
* Get the assoc at a particular index
*/
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{
return super.getMultiAssocAt(attribName, index);
}
/**
* Add to a multi assoc by attribute name
*/
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{
super.addToMultiAssoc(attribName, newElement);
}
/**
* Remove from a multi assoc by attribute name
*/
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{
super.removeFromMultiAssoc(attribName, oldElement);
}
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{
super.__loadMultiAssoc(attribName, elements);
}
protected boolean __isMultiAssocLoaded (String attribName)
{
return super.__isMultiAssocLoaded(attribName);
}
public void onDelete ()
{
try
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_CandidateAnswer.isLoaded () || getTransaction ().isObjectLoaded (_CandidateAnswer.getReferencedType (), getCandidateAnswerID ()))
{
CandidateDiversityAnswer referenced = getCandidateAnswer ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Answers from ", getObjectID (), " to ", referenced.getObjectID ());
_CandidateAnswer.set (null);
referenced.removeFromAnswers ((AnswerOption)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public AnswerOption newInstance ()
{
return new AnswerOption ();
}
public AnswerOption referenceInstance ()
{
return REFERENCE_AnswerOption;
}
public AnswerOption getInTransaction (ObjectTransaction t) throws StorageException
{
return getAnswerOptionByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_AnswerOption;
}
public String getBaseSetName ()
{
return "tl_answer_option";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_answer_optionPSet = allSets.getPersistentSet (myID, "tl_answer_option", myPSetStatus);
tl_answer_optionPSet.setAttrib (FIELD_ObjectID, myID);
_CandidateAnswer.getPersistentSets (allSets);
_Answer.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_answer_optionPSet = allSets.getPersistentSet (objectID, "tl_answer_option");
_CandidateAnswer.setFromPersistentSets (objectID, allSets);
_Answer.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof AnswerOption)
{
AnswerOption otherAnswerOption = (AnswerOption)other;
}
}
/**
* Set the attributes in this to copies of the attributes in source.
*/
public void copyAttributesFrom (BaseBusinessClass source)
{
super.copyAttributesFrom (source);
if (source instanceof BaseAnswerOption)
{
BaseAnswerOption sourceAnswerOption = (BaseAnswerOption)(source);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copySingleAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseAnswerOption)
{
BaseAnswerOption sourceAnswerOption = (BaseAnswerOption)(source);
_CandidateAnswer.copyFrom (sourceAnswerOption._CandidateAnswer, linkToGhosts);
_Answer.copyFrom (sourceAnswerOption._Answer, linkToGhosts);
}
}
/**
* Set the associations in this to copies of the attributes in source.
*/
public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
{
super.copyAssociationsFrom (source, linkToGhosts);
if (source instanceof BaseAnswerOption)
{
BaseAnswerOption sourceAnswerOption = (BaseAnswerOption)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
context.check (getCandidateAnswerID() != null, this, SINGLEREFERENCE_CandidateAnswer, "mandatory");
context.check (getAnswerID() != null, this, SINGLEREFERENCE_Answer, "mandatory");
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_CandidateAnswer.readExternalData(vals.get(SINGLEREFERENCE_CandidateAnswer));
_Answer.readExternalData(vals.get(SINGLEREFERENCE_Answer));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (SINGLEREFERENCE_CandidateAnswer, _CandidateAnswer.writeExternalData());
vals.put (SINGLEREFERENCE_Answer, _Answer.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseAnswerOption)
{
BaseAnswerOption otherAnswerOption = (BaseAnswerOption)(other);
// Compare single assocs
_CandidateAnswer.compare (otherAnswerOption._CandidateAnswer, listener);
_Answer.compare (otherAnswerOption._Answer, listener);
// Compare multiple assocs
}
}
public void visitTransients (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
}
public void visitAttributes (AttributeVisitor visitor) throws StorageException
{
super.visitAttributes (visitor);
visitor.visitAssociation (_CandidateAnswer);
visitor.visitAssociation (_Answer);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_CandidateAnswer))
{
visitor.visit (_CandidateAnswer);
}
if (scope.includes (_Answer))
{
visitor.visit (_Answer);
}
}
public static AnswerOption createAnswerOption (ObjectTransaction transaction) throws StorageException
{
AnswerOption result = new AnswerOption ();
result.initialiseNewObject (transaction);
return result;
}
public static AnswerOption getAnswerOptionByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (AnswerOption)(transaction.getObjectByID (REFERENCE_AnswerOption, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (SINGLEREFERENCE_CandidateAnswer))
{
return filter.matches (getCandidateAnswer ());
}
else if (attribName.equals (SINGLEREFERENCE_Answer))
{
return filter.matches (getAnswer ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<AnswerOption>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_answer_option.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_answer_option.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_answer_option.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andCandidateAnswer (QueryFilter<CandidateDiversityAnswer> filter)
{
filter.addFilter (context, "tl_answer_option.candidate_answer_id", "CandidateAnswer");
return this;
}
public SearchAll andAnswer (QueryFilter<DiversityAnswer> filter)
{
filter.addFilter (context, "tl_answer_option.answer_id", "Answer");
return this;
}
public AnswerOption[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_AnswerOption, SEARCH_All, criteria);
Set<AnswerOption> typedResults = new LinkedHashSet <AnswerOption> ();
for (BaseBusinessClass bbcResult : results)
{
AnswerOption aResult = (AnswerOption)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new AnswerOption[0]);
}
}
public static AnswerOption[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else
{
return super.getAttributeHelper (attribName);
}
}
public void setAttribute (String attribName, Object attribValue) throws FieldException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else
{
super.setAttribute (attribName, attribValue);
}
}
public boolean isWriteable (String fieldName)
{
return getWriteable (fieldName) == FieldWriteability.TRUE;
}
public FieldWriteability getWriteable (String fieldName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (fieldName.equals (SINGLEREFERENCE_CandidateAnswer))
{
return getWriteability_CandidateAnswer ();
}
else if (fieldName.equals (SINGLEREFERENCE_Answer))
{
return getWriteability_Answer ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_AnswerOption.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_AnswerOption.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_AnswerOption.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_AnswerOption.get (attribute)).get(metadata);
}
else
{
return super.getAttributeMetadata (attribute, metadata);
}
}
public void preCommit (boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
}
}
public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
{
return super.getBinaryContentHandler(attribName);
}
public static class AnswerOptionBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<AnswerOption>
{
}
public ORMPipeLine pipes()
{
return new AnswerOptionPipeLineFactory<AnswerOption, AnswerOption> ((AnswerOption)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public AnswerOptionPipeLineFactory<AnswerOption, AnswerOption> pipelineAnswerOption()
{
return (AnswerOptionPipeLineFactory<AnswerOption, AnswerOption>) pipes();
}
public static AnswerOptionPipeLineFactory<AnswerOption, AnswerOption> pipesAnswerOption(Collection<AnswerOption> items)
{
return REFERENCE_AnswerOption.new AnswerOptionPipeLineFactory<AnswerOption, AnswerOption> (items);
}
public static AnswerOptionPipeLineFactory<AnswerOption, AnswerOption> pipesAnswerOption(AnswerOption[] _items)
{
return pipesAnswerOption(Arrays.asList (_items));
}
public static AnswerOptionPipeLineFactory<AnswerOption, AnswerOption> pipesAnswerOption()
{
return pipesAnswerOption((Collection)null);
}
public class AnswerOptionPipeLineFactory<From extends BaseBusinessClass, Me extends AnswerOption> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> AnswerOptionPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public AnswerOptionPipeLineFactory (From seed)
{
super(seed);
}
public AnswerOptionPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("CandidateAnswer"))
{
return toCandidateAnswer ();
}
if (name.equals ("Answer"))
{
return toAnswer ();
}
return super.to(name);
}
public CandidateDiversityAnswer.CandidateDiversityAnswerPipeLineFactory<From, CandidateDiversityAnswer> toCandidateAnswer () { return toCandidateAnswer (Filter.ALL); }
public CandidateDiversityAnswer.CandidateDiversityAnswerPipeLineFactory<From, CandidateDiversityAnswer> toCandidateAnswer (Filter<CandidateDiversityAnswer> filter)
{
return CandidateDiversityAnswer.REFERENCE_CandidateDiversityAnswer.new CandidateDiversityAnswerPipeLineFactory<From, CandidateDiversityAnswer> (this, new ORMSingleAssocPipe<Me, CandidateDiversityAnswer>(SINGLEREFERENCE_CandidateAnswer, filter));
}
public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswer () { return toAnswer (Filter.ALL); }
public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswer (Filter<DiversityAnswer> filter)
{
return DiversityAnswer.REFERENCE_DiversityAnswer.new DiversityAnswerPipeLineFactory<From, DiversityAnswer> (this, new ORMSingleAssocPipe<Me, DiversityAnswer>(SINGLEREFERENCE_Answer, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyAnswerOption extends AnswerOption
{
// Default constructor primarily to support Externalisable
public DummyAnswerOption()
{
super();
}
public void assertValid ()
{
}
public CandidateDiversityAnswer getCandidateAnswer () throws StorageException
{
return (CandidateDiversityAnswer)(CandidateDiversityAnswer.DUMMY_CandidateDiversityAnswer);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getCandidateAnswerID ()
{
return CandidateDiversityAnswer.DUMMY_CandidateDiversityAnswer.getObjectID();
}
public DiversityAnswer getAnswer () throws StorageException
{
return (DiversityAnswer)(DiversityAnswer.DUMMY_DiversityAnswer);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getAnswerID ()
{
return DiversityAnswer.DUMMY_DiversityAnswer.getObjectID();
}
}
...@@ -38,10 +38,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -38,10 +38,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
// Static constants corresponding to field names // Static constants corresponding to field names
public static final String SINGLEREFERENCE_Answer = "Answer";
public static final String SINGLEREFERENCE_Question = "Question"; public static final String SINGLEREFERENCE_Question = "Question";
public static final String SINGLEREFERENCE_Candidate = "Candidate"; public static final String SINGLEREFERENCE_Candidate = "Candidate";
public static final String BACKREF_Candidate = ""; public static final String BACKREF_Candidate = "";
public static final String MULTIPLEREFERENCE_Answers = "Answers";
public static final String BACKREF_Answers = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -54,12 +55,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -54,12 +55,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
// Private attributes corresponding to single references // Private attributes corresponding to single references
private SingleAssociation<CandidateDiversityAnswer, DiversityAnswer> _Answer;
private SingleAssociation<CandidateDiversityAnswer, DiversityQuestion> _Question; private SingleAssociation<CandidateDiversityAnswer, DiversityQuestion> _Question;
private SingleAssociation<CandidateDiversityAnswer, Candidate> _Candidate; private SingleAssociation<CandidateDiversityAnswer, Candidate> _Candidate;
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
private MultipleAssociation<CandidateDiversityAnswer, AnswerOption> _Answers;
// Map of maps of metadata // Map of maps of metadata
...@@ -76,11 +77,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -76,11 +77,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
try try
{ {
String tmp_Answers = AnswerOption.BACKREF_CandidateAnswer;
String tmp_Candidate = Candidate.BACKREF_DiversityAnswers; String tmp_Candidate = Candidate.BACKREF_DiversityAnswers;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Answer(); setupAssocMetaData_Answers();
setupAssocMetaData_Question(); setupAssocMetaData_Question();
setupAssocMetaData_Candidate(); setupAssocMetaData_Candidate();
...@@ -98,17 +100,16 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -98,17 +100,16 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Answer() private static void setupAssocMetaData_Answers()
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "answer_id"); metaInfo.put ("backreferenceName", "CandidateAnswer");
metaInfo.put ("mandatory", "true"); metaInfo.put ("name", "Answers");
metaInfo.put ("name", "Answer"); metaInfo.put ("type", "AnswerOption");
metaInfo.put ("type", "DiversityAnswer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CandidateDiversityAnswer.Answer:", metaInfo); LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CandidateDiversityAnswer.Answers:", metaInfo);
ATTRIBUTES_METADATA_CandidateDiversityAnswer.put (SINGLEREFERENCE_Answer, Collections.unmodifiableMap (metaInfo)); ATTRIBUTES_METADATA_CandidateDiversityAnswer.put (MULTIPLEREFERENCE_Answers, Collections.unmodifiableMap (metaInfo));
} }
...@@ -178,9 +179,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -178,9 +179,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Answer = new SingleAssociation<CandidateDiversityAnswer, DiversityAnswer> (this, SINGLEREFERENCE_Answer, null, DiversityAnswer.REFERENCE_DiversityAnswer, "tl_candidate_diversity_answer");
_Question = new SingleAssociation<CandidateDiversityAnswer, DiversityQuestion> (this, SINGLEREFERENCE_Question, null, DiversityQuestion.REFERENCE_DiversityQuestion, "tl_candidate_diversity_answer"); _Question = new SingleAssociation<CandidateDiversityAnswer, DiversityQuestion> (this, SINGLEREFERENCE_Question, null, DiversityQuestion.REFERENCE_DiversityQuestion, "tl_candidate_diversity_answer");
_Candidate = new SingleAssociation<CandidateDiversityAnswer, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_DiversityAnswers, Candidate.REFERENCE_Candidate, "tl_candidate_diversity_answer"); _Candidate = new SingleAssociation<CandidateDiversityAnswer, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_DiversityAnswers, Candidate.REFERENCE_Candidate, "tl_candidate_diversity_answer");
_Answers = new MultipleAssociation<CandidateDiversityAnswer, AnswerOption> (this, MULTIPLEREFERENCE_Answers, AnswerOption.SINGLEREFERENCE_CandidateAnswer, AnswerOption.REFERENCE_AnswerOption);
} }
...@@ -190,9 +191,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -190,9 +191,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_Answer = new SingleAssociation<CandidateDiversityAnswer, DiversityAnswer> (this, SINGLEREFERENCE_Answer, null, DiversityAnswer.REFERENCE_DiversityAnswer, "tl_candidate_diversity_answer");
_Question = new SingleAssociation<CandidateDiversityAnswer, DiversityQuestion> (this, SINGLEREFERENCE_Question, null, DiversityQuestion.REFERENCE_DiversityQuestion, "tl_candidate_diversity_answer"); _Question = new SingleAssociation<CandidateDiversityAnswer, DiversityQuestion> (this, SINGLEREFERENCE_Question, null, DiversityQuestion.REFERENCE_DiversityQuestion, "tl_candidate_diversity_answer");
_Candidate = new SingleAssociation<CandidateDiversityAnswer, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_DiversityAnswers, Candidate.REFERENCE_Candidate, "tl_candidate_diversity_answer"); _Candidate = new SingleAssociation<CandidateDiversityAnswer, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_DiversityAnswers, Candidate.REFERENCE_Candidate, "tl_candidate_diversity_answer");
_Answers = new MultipleAssociation<CandidateDiversityAnswer, AnswerOption> (this, MULTIPLEREFERENCE_Answers, AnswerOption.SINGLEREFERENCE_CandidateAnswer, AnswerOption.REFERENCE_AnswerOption);
return this; return this;
...@@ -210,8 +211,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -210,8 +211,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
List result = super.getSingleAssocs (); List result = super.getSingleAssocs ();
result.add("Answer");
result.add("Question"); result.add("Question");
result.add("Candidate"); result.add("Candidate");
...@@ -227,10 +226,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -227,10 +226,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Answer)) else if (assocName.equals (SINGLEREFERENCE_Question))
{
return _Answer.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
return _Question.getReferencedType (); return _Question.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate)) }else if (assocName.equals (SINGLEREFERENCE_Candidate))
...@@ -250,10 +246,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -250,10 +246,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Answer)) else if (assocName.equals (SINGLEREFERENCE_Question))
{
return null ;
}else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
return null ; return null ;
}else if (assocName.equals (SINGLEREFERENCE_Candidate)) }else if (assocName.equals (SINGLEREFERENCE_Candidate))
...@@ -273,10 +266,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -273,10 +266,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Answer)) else if (assocName.equals (SINGLEREFERENCE_Question))
{
return getAnswer ();
}else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
return getQuestion (); return getQuestion ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate)) }else if (assocName.equals (SINGLEREFERENCE_Candidate))
...@@ -296,10 +286,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -296,10 +286,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Answer)) else if (assocName.equals (SINGLEREFERENCE_Question))
{
return getAnswer (getType);
}else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
return getQuestion (getType); return getQuestion (getType);
}else if (assocName.equals (SINGLEREFERENCE_Candidate)) }else if (assocName.equals (SINGLEREFERENCE_Candidate))
...@@ -319,10 +306,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -319,10 +306,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Answer)) else if (assocName.equals (SINGLEREFERENCE_Question))
{
return getAnswerID ();
}else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
return getQuestionID (); return getQuestionID ();
}else if (assocName.equals (SINGLEREFERENCE_Candidate)) }else if (assocName.equals (SINGLEREFERENCE_Candidate))
...@@ -342,10 +326,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -342,10 +326,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Answer)) else if (assocName.equals (SINGLEREFERENCE_Question))
{
setAnswer ((DiversityAnswer)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Question))
{ {
setQuestion ((DiversityQuestion)(newValue)); setQuestion ((DiversityQuestion)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_Candidate)) }else if (assocName.equals (SINGLEREFERENCE_Candidate))
...@@ -361,101 +342,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -361,101 +342,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
/** /**
* Get the reference Answer
*/
public DiversityAnswer getAnswer () throws StorageException
{
assertValid();
try
{
return (DiversityAnswer)(_Answer.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CandidateDiversityAnswer:", this.getObjectID (), ", was trying to get DiversityAnswer:", getAnswerID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Answer.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public DiversityAnswer getAnswer (Get getType) throws StorageException
{
assertValid();
return _Answer.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getAnswerID ()
{
assertValid();
if (_Answer == null)
{
return null;
}
else
{
return _Answer.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 preAnswerChange (DiversityAnswer newAnswer) 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 postAnswerChange () throws FieldException
{
}
public FieldWriteability getWriteability_Answer ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Answer. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setAnswer (DiversityAnswer newAnswer) throws StorageException, FieldException
{
BusinessObjectParser.assertFieldCondition (newAnswer != null, this, SINGLEREFERENCE_Answer, "mandatory");
if (_Answer.wouldReferencedChange (newAnswer))
{
assertValid();
Debug.assertion (getWriteability_Answer () != FieldWriteability.FALSE, "Assoc Answer is not writeable");
preAnswerChange (newAnswer);
_Answer.set (newAnswer);
postAnswerChange ();
}
}
/**
* Get the reference Question * Get the reference Question
*/ */
public DiversityQuestion getQuestion () throws StorageException public DiversityQuestion getQuestion () throws StorageException
...@@ -666,6 +552,8 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -666,6 +552,8 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
List result = super.getMultiAssocs (); List result = super.getMultiAssocs ();
result.add("Answers");
return result; return result;
} }
...@@ -677,6 +565,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -677,6 +565,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName) public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
return AnswerOption.REFERENCE_AnswerOption ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -685,6 +578,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -685,6 +578,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
public String getMultiAssocBackReference(String attribName) public String getMultiAssocBackReference(String attribName)
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
return AnswerOption.SINGLEREFERENCE_CandidateAnswer ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -696,6 +594,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -696,6 +594,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
public int getMultiAssocCount(String attribName) throws StorageException public int getMultiAssocCount(String attribName) throws StorageException
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
return this.getAnswersCount();
}
return super.getMultiAssocCount(attribName); return super.getMultiAssocCount(attribName);
} }
...@@ -707,6 +610,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -707,6 +610,11 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
return this.getAnswersAt(index);
}
return super.getMultiAssocAt(attribName, index); return super.getMultiAssocAt(attribName, index);
} }
...@@ -718,6 +626,13 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -718,6 +626,13 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
addToAnswers((AnswerOption)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement); super.addToMultiAssoc(attribName, newElement);
} }
...@@ -728,6 +643,13 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -728,6 +643,13 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
removeFromAnswers((AnswerOption)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement); super.removeFromMultiAssoc(attribName, oldElement);
} }
...@@ -736,6 +658,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -736,6 +658,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements) protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
_Answers.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements); super.__loadMultiAssoc(attribName, elements);
} }
...@@ -744,12 +672,86 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -744,12 +672,86 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
protected boolean __isMultiAssocLoaded (String attribName) protected boolean __isMultiAssocLoaded (String attribName)
{ {
if (MULTIPLEREFERENCE_Answers.equals(attribName))
{
return _Answers.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName); return super.__isMultiAssocLoaded(attribName);
} }
public FieldWriteability getWriteability_Answers ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getAnswersCount () throws StorageException
{
assertValid();
return _Answers.getReferencedObjectsCount ();
}
public void addToAnswers (AnswerOption newElement) throws StorageException
{
if (_Answers.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Answers () != FieldWriteability.FALSE, "MultiAssoc Answers is not writeable (add)");
_Answers.appendElement (newElement);
try
{
if (newElement.getCandidateAnswer () != this)
{
newElement.setCandidateAnswer ((CandidateDiversityAnswer)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromAnswers (AnswerOption elementToRemove) throws StorageException
{
if (_Answers.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Answers () != FieldWriteability.FALSE, "MultiAssoc Answers is not writeable (remove)");
_Answers.removeElement (elementToRemove);
try
{
if (elementToRemove.getCandidateAnswer () != null)
{
elementToRemove.setCandidateAnswer (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public AnswerOption getAnswersAt (int index) throws StorageException
{
return (AnswerOption)(_Answers.getElementAt (index));
}
public SortedSet<AnswerOption> getAnswersSet () throws StorageException
{
return _Answers.getSet ();
}
public void onDelete () public void onDelete ()
...@@ -770,6 +772,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -770,6 +772,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
} }
} }
for(AnswerOption referenced : CollectionUtils.reverse(getAnswersSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CandidateAnswer from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setCandidateAnswer(null);
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -830,7 +838,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -830,7 +838,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
PersistentSet tl_candidate_diversity_answerPSet = allSets.getPersistentSet (myID, "tl_candidate_diversity_answer", myPSetStatus); PersistentSet tl_candidate_diversity_answerPSet = allSets.getPersistentSet (myID, "tl_candidate_diversity_answer", myPSetStatus);
tl_candidate_diversity_answerPSet.setAttrib (FIELD_ObjectID, myID); tl_candidate_diversity_answerPSet.setAttrib (FIELD_ObjectID, myID);
_Answer.getPersistentSets (allSets);
_Question.getPersistentSets (allSets); _Question.getPersistentSets (allSets);
_Candidate.getPersistentSets (allSets); _Candidate.getPersistentSets (allSets);
...@@ -847,7 +854,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -847,7 +854,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
PersistentSet tl_candidate_diversity_answerPSet = allSets.getPersistentSet (objectID, "tl_candidate_diversity_answer"); PersistentSet tl_candidate_diversity_answerPSet = allSets.getPersistentSet (objectID, "tl_candidate_diversity_answer");
_Answer.setFromPersistentSets (objectID, allSets);
_Question.setFromPersistentSets (objectID, allSets); _Question.setFromPersistentSets (objectID, allSets);
_Candidate.setFromPersistentSets (objectID, allSets); _Candidate.setFromPersistentSets (objectID, allSets);
...@@ -896,7 +902,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -896,7 +902,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
BaseCandidateDiversityAnswer sourceCandidateDiversityAnswer = (BaseCandidateDiversityAnswer)(source); BaseCandidateDiversityAnswer sourceCandidateDiversityAnswer = (BaseCandidateDiversityAnswer)(source);
_Answer.copyFrom (sourceCandidateDiversityAnswer._Answer, linkToGhosts);
_Question.copyFrom (sourceCandidateDiversityAnswer._Question, linkToGhosts); _Question.copyFrom (sourceCandidateDiversityAnswer._Question, linkToGhosts);
_Candidate.copyFrom (sourceCandidateDiversityAnswer._Candidate, linkToGhosts); _Candidate.copyFrom (sourceCandidateDiversityAnswer._Candidate, linkToGhosts);
...@@ -915,6 +920,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -915,6 +920,7 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
BaseCandidateDiversityAnswer sourceCandidateDiversityAnswer = (BaseCandidateDiversityAnswer)(source); BaseCandidateDiversityAnswer sourceCandidateDiversityAnswer = (BaseCandidateDiversityAnswer)(source);
_Answers.copyFrom (sourceCandidateDiversityAnswer._Answers, linkToGhosts);
} }
} }
...@@ -925,8 +931,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -925,8 +931,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
super.validate (context); super.validate (context);
context.check (getAnswerID() != null, this, SINGLEREFERENCE_Answer, "mandatory");
context.check (getQuestionID() != null, this, SINGLEREFERENCE_Question, "mandatory"); context.check (getQuestionID() != null, this, SINGLEREFERENCE_Question, "mandatory");
context.check (getCandidateID() != null, this, SINGLEREFERENCE_Candidate, "mandatory"); context.check (getCandidateID() != null, this, SINGLEREFERENCE_Candidate, "mandatory");
...@@ -941,9 +945,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -941,9 +945,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
super.readExternalData(vals); super.readExternalData(vals);
_Answer.readExternalData(vals.get(SINGLEREFERENCE_Answer));
_Question.readExternalData(vals.get(SINGLEREFERENCE_Question)); _Question.readExternalData(vals.get(SINGLEREFERENCE_Question));
_Candidate.readExternalData(vals.get(SINGLEREFERENCE_Candidate)); _Candidate.readExternalData(vals.get(SINGLEREFERENCE_Candidate));
_Answers.readExternalData(vals.get(MULTIPLEREFERENCE_Answers));
} }
...@@ -955,9 +959,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -955,9 +959,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
super.writeExternalData(vals); super.writeExternalData(vals);
vals.put (SINGLEREFERENCE_Answer, _Answer.writeExternalData());
vals.put (SINGLEREFERENCE_Question, _Question.writeExternalData()); vals.put (SINGLEREFERENCE_Question, _Question.writeExternalData());
vals.put (SINGLEREFERENCE_Candidate, _Candidate.writeExternalData()); vals.put (SINGLEREFERENCE_Candidate, _Candidate.writeExternalData());
vals.put (MULTIPLEREFERENCE_Answers, _Answers.writeExternalData());
} }
...@@ -973,12 +977,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -973,12 +977,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
// Compare single assocs // Compare single assocs
_Answer.compare (otherCandidateDiversityAnswer._Answer, listener);
_Question.compare (otherCandidateDiversityAnswer._Question, listener); _Question.compare (otherCandidateDiversityAnswer._Question, listener);
_Candidate.compare (otherCandidateDiversityAnswer._Candidate, listener); _Candidate.compare (otherCandidateDiversityAnswer._Candidate, listener);
// Compare multiple assocs // Compare multiple assocs
_Answers.compare (otherCandidateDiversityAnswer._Answers, listener);
} }
} }
...@@ -996,9 +1000,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -996,9 +1000,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
super.visitAttributes (visitor); super.visitAttributes (visitor);
visitor.visitAssociation (_Answer);
visitor.visitAssociation (_Question); visitor.visitAssociation (_Question);
visitor.visitAssociation (_Candidate); visitor.visitAssociation (_Candidate);
visitor.visitAssociation (_Answers);
} }
...@@ -1007,10 +1011,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1007,10 +1011,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
super.visitAssociations (visitor, scope); super.visitAssociations (visitor, scope);
if (scope.includes (_Answer))
{
visitor.visit (_Answer);
}
if (scope.includes (_Question)) if (scope.includes (_Question))
{ {
visitor.visit (_Question); visitor.visit (_Question);
...@@ -1019,6 +1019,10 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1019,6 +1019,10 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
visitor.visit (_Candidate); visitor.visit (_Candidate);
} }
if (scope.includes (_Answers))
{
visitor.visit (_Answers);
}
} }
...@@ -1044,10 +1048,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1044,10 +1048,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over man!!"); throw new RuntimeException ("Game over man!!");
} }
else if (attribName.equals (SINGLEREFERENCE_Answer))
{
return filter.matches (getAnswer ());
}
else if (attribName.equals (SINGLEREFERENCE_Question)) else if (attribName.equals (SINGLEREFERENCE_Question))
{ {
return filter.matches (getQuestion ()); return filter.matches (getQuestion ());
...@@ -1087,12 +1087,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1087,12 +1087,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
} }
public SearchAll andAnswer (QueryFilter<DiversityAnswer> filter)
{
filter.addFilter (context, "tl_candidate_diversity_answer.answer_id", "Answer");
return this;
}
public SearchAll andQuestion (QueryFilter<DiversityQuestion> filter) public SearchAll andQuestion (QueryFilter<DiversityQuestion> filter)
{ {
filter.addFilter (context, "tl_candidate_diversity_answer.question_id", "Question"); filter.addFilter (context, "tl_candidate_diversity_answer.question_id", "Question");
...@@ -1186,9 +1180,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1186,9 +1180,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over man!!"); throw new RuntimeException ("Game over man!!");
} }
else if (fieldName.equals (SINGLEREFERENCE_Answer)) else if (fieldName.equals (MULTIPLEREFERENCE_Answers))
{ {
return getWriteability_Answer (); return getWriteability_Answers ();
} }
else if (fieldName.equals (SINGLEREFERENCE_Question)) else if (fieldName.equals (SINGLEREFERENCE_Question))
{ {
...@@ -1319,9 +1313,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1319,9 +1313,9 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
public PipeLine<From, ? extends Object> to(String name) public PipeLine<From, ? extends Object> to(String name)
{ {
if (name.equals ("Answer")) if (name.equals ("Answers"))
{ {
return toAnswer (); return toAnswers ();
} }
if (name.equals ("Question")) if (name.equals ("Question"))
{ {
...@@ -1336,12 +1330,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1336,12 +1330,6 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
return super.to(name); return super.to(name);
} }
public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswer () { return toAnswer (Filter.ALL); }
public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswer (Filter<DiversityAnswer> filter)
{
return DiversityAnswer.REFERENCE_DiversityAnswer.new DiversityAnswerPipeLineFactory<From, DiversityAnswer> (this, new ORMSingleAssocPipe<Me, DiversityAnswer>(SINGLEREFERENCE_Answer, filter));
}
public DiversityQuestion.DiversityQuestionPipeLineFactory<From, DiversityQuestion> toQuestion () { return toQuestion (Filter.ALL); } public DiversityQuestion.DiversityQuestionPipeLineFactory<From, DiversityQuestion> toQuestion () { return toQuestion (Filter.ALL); }
public DiversityQuestion.DiversityQuestionPipeLineFactory<From, DiversityQuestion> toQuestion (Filter<DiversityQuestion> filter) public DiversityQuestion.DiversityQuestionPipeLineFactory<From, DiversityQuestion> toQuestion (Filter<DiversityQuestion> filter)
...@@ -1354,6 +1342,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass ...@@ -1354,6 +1342,12 @@ public abstract class BaseCandidateDiversityAnswer extends BaseBusinessClass
{ {
return Candidate.REFERENCE_Candidate.new CandidatePipeLineFactory<From, Candidate> (this, new ORMSingleAssocPipe<Me, Candidate>(SINGLEREFERENCE_Candidate, filter)); return Candidate.REFERENCE_Candidate.new CandidatePipeLineFactory<From, Candidate> (this, new ORMSingleAssocPipe<Me, Candidate>(SINGLEREFERENCE_Candidate, filter));
} }
public AnswerOption.AnswerOptionPipeLineFactory<From, AnswerOption> toAnswers () { return toAnswers(Filter.ALL); }
public AnswerOption.AnswerOptionPipeLineFactory<From, AnswerOption> toAnswers (Filter<AnswerOption> filter)
{
return AnswerOption.REFERENCE_AnswerOption.new AnswerOptionPipeLineFactory<From, AnswerOption> (this, new ORMMultiAssocPipe<Me, AnswerOption>(MULTIPLEREFERENCE_Answers, filter));
}
} }
...@@ -1385,20 +1379,6 @@ class DummyCandidateDiversityAnswer extends CandidateDiversityAnswer ...@@ -1385,20 +1379,6 @@ class DummyCandidateDiversityAnswer extends CandidateDiversityAnswer
} }
public DiversityAnswer getAnswer () throws StorageException
{
return (DiversityAnswer)(DiversityAnswer.DUMMY_DiversityAnswer);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getAnswerID ()
{
return DiversityAnswer.DUMMY_DiversityAnswer.getObjectID();
}
public DiversityQuestion getQuestion () throws StorageException public DiversityQuestion getQuestion () throws StorageException
{ {
return (DiversityQuestion)(DiversityQuestion.DUMMY_DiversityQuestion); return (DiversityQuestion)(DiversityQuestion.DUMMY_DiversityQuestion);
...@@ -1427,6 +1407,23 @@ class DummyCandidateDiversityAnswer extends CandidateDiversityAnswer ...@@ -1427,6 +1407,23 @@ class DummyCandidateDiversityAnswer extends CandidateDiversityAnswer
return Candidate.DUMMY_Candidate.getObjectID(); return Candidate.DUMMY_Candidate.getObjectID();
} }
public int getAnswersCount () throws StorageException
{
return 0;
}
public AnswerOption getAnswersAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Answers");
}
public SortedSet getAnswersSet () throws StorageException
{
return new TreeSet();
}
} }
...@@ -41,6 +41,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -41,6 +41,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
public static final String FIELD_Code = "Code"; public static final String FIELD_Code = "Code";
public static final String FIELD_QuestionText = "QuestionText"; public static final String FIELD_QuestionText = "QuestionText";
public static final String FIELD_AustraliaOnly = "AustraliaOnly"; public static final String FIELD_AustraliaOnly = "AustraliaOnly";
public static final String FIELD_MultipleAnswers = "MultipleAnswers";
public static final String MULTIPLEREFERENCE_Answers = "Answers"; public static final String MULTIPLEREFERENCE_Answers = "Answers";
public static final String BACKREF_Answers = ""; public static final String BACKREF_Answers = "";
...@@ -52,12 +53,14 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -52,12 +53,14 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
private static final DefaultAttributeHelper<DiversityQuestion> HELPER_Code = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<DiversityQuestion> HELPER_Code = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<DiversityQuestion> HELPER_QuestionText = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<DiversityQuestion> HELPER_QuestionText = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<DiversityQuestion> HELPER_AustraliaOnly = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<DiversityQuestion> HELPER_AustraliaOnly = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<DiversityQuestion> HELPER_MultipleAnswers = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private String _Code; private String _Code;
private String _QuestionText; private String _QuestionText;
private Boolean _AustraliaOnly; private Boolean _AustraliaOnly;
private Boolean _MultipleAnswers;
// Private attributes corresponding to single references // Private attributes corresponding to single references
...@@ -74,6 +77,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -74,6 +77,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
private static final AttributeValidator[] FIELD_Code_Validators; private static final AttributeValidator[] FIELD_Code_Validators;
private static final AttributeValidator[] FIELD_QuestionText_Validators; private static final AttributeValidator[] FIELD_QuestionText_Validators;
private static final AttributeValidator[] FIELD_AustraliaOnly_Validators; private static final AttributeValidator[] FIELD_AustraliaOnly_Validators;
private static final AttributeValidator[] FIELD_MultipleAnswers_Validators;
// Arrays of behaviour decorators // Arrays of behaviour decorators
...@@ -92,6 +96,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -92,6 +96,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
FIELD_Code_Validators = (AttributeValidator[])setupAttribMetaData_Code(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Code_Validators = (AttributeValidator[])setupAttribMetaData_Code(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_QuestionText_Validators = (AttributeValidator[])setupAttribMetaData_QuestionText(validatorMapping).toArray (new AttributeValidator[0]); FIELD_QuestionText_Validators = (AttributeValidator[])setupAttribMetaData_QuestionText(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_AustraliaOnly_Validators = (AttributeValidator[])setupAttribMetaData_AustraliaOnly(validatorMapping).toArray (new AttributeValidator[0]); FIELD_AustraliaOnly_Validators = (AttributeValidator[])setupAttribMetaData_AustraliaOnly(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_MultipleAnswers_Validators = (AttributeValidator[])setupAttribMetaData_MultipleAnswers(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_DiversityQuestion.initialiseReference (); REFERENCE_DiversityQuestion.initialiseReference ();
...@@ -177,6 +182,25 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -177,6 +182,25 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
return validators; return validators;
} }
// Meta Info setup
private static List setupAttribMetaData_MultipleAnswers(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "multiple_answers");
metaInfo.put ("defaultValue", "Boolean.FALSE");
metaInfo.put ("name", "MultipleAnswers");
metaInfo.put ("type", "Boolean");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for DiversityQuestion.MultipleAnswers:", metaInfo);
ATTRIBUTES_METADATA_DiversityQuestion.put (FIELD_MultipleAnswers, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(DiversityQuestion.class, "MultipleAnswers", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for DiversityQuestion.MultipleAnswers:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION // END OF STATIC METADATA DEFINITION
...@@ -207,6 +231,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -207,6 +231,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
_Code = (String)(HELPER_Code.initialise (_Code)); _Code = (String)(HELPER_Code.initialise (_Code));
_QuestionText = (String)(HELPER_QuestionText.initialise (_QuestionText)); _QuestionText = (String)(HELPER_QuestionText.initialise (_QuestionText));
_AustraliaOnly = (Boolean)(Boolean.FALSE); _AustraliaOnly = (Boolean)(Boolean.FALSE);
_MultipleAnswers = (Boolean)(Boolean.FALSE);
} }
...@@ -529,6 +554,104 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -529,6 +554,104 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
} }
} }
/**
* Get the attribute MultipleAnswers
*/
public Boolean getMultipleAnswers ()
{
assertValid();
Boolean valToReturn = _MultipleAnswers;
for (DiversityQuestionBehaviourDecorator bhd : DiversityQuestion_BehaviourDecorators)
{
valToReturn = bhd.getMultipleAnswers ((DiversityQuestion)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preMultipleAnswersChange (Boolean newMultipleAnswers) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postMultipleAnswersChange () throws FieldException
{
}
public FieldWriteability getWriteability_MultipleAnswers ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute MultipleAnswers. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setMultipleAnswers (Boolean newMultipleAnswers) throws FieldException
{
boolean oldAndNewIdentical = HELPER_MultipleAnswers.compare (_MultipleAnswers, newMultipleAnswers);
try
{
for (DiversityQuestionBehaviourDecorator bhd : DiversityQuestion_BehaviourDecorators)
{
newMultipleAnswers = bhd.setMultipleAnswers ((DiversityQuestion)this, newMultipleAnswers);
oldAndNewIdentical = HELPER_MultipleAnswers.compare (_MultipleAnswers, newMultipleAnswers);
}
if (FIELD_MultipleAnswers_Validators.length > 0)
{
Object newMultipleAnswersObj = HELPER_MultipleAnswers.toObject (newMultipleAnswers);
if (newMultipleAnswersObj != null)
{
int loopMax = FIELD_MultipleAnswers_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_DiversityQuestion.get (FIELD_MultipleAnswers);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_MultipleAnswers_Validators[v].checkAttribute (this, FIELD_MultipleAnswers, metadata, newMultipleAnswersObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_MultipleAnswers () != FieldWriteability.FALSE, "Field MultipleAnswers is not writeable");
preMultipleAnswersChange (newMultipleAnswers);
markFieldChange (FIELD_MultipleAnswers);
_MultipleAnswers = newMultipleAnswers;
postFieldChange (FIELD_MultipleAnswers);
postMultipleAnswersChange ();
}
}
/** /**
...@@ -912,6 +1035,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -912,6 +1035,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
tl_diversity_questionPSet.setAttrib (FIELD_Code, HELPER_Code.toObject (_Code)); // tl_diversity_questionPSet.setAttrib (FIELD_Code, HELPER_Code.toObject (_Code)); //
tl_diversity_questionPSet.setAttrib (FIELD_QuestionText, HELPER_QuestionText.toObject (_QuestionText)); // tl_diversity_questionPSet.setAttrib (FIELD_QuestionText, HELPER_QuestionText.toObject (_QuestionText)); //
tl_diversity_questionPSet.setAttrib (FIELD_AustraliaOnly, HELPER_AustraliaOnly.toObject (_AustraliaOnly)); // tl_diversity_questionPSet.setAttrib (FIELD_AustraliaOnly, HELPER_AustraliaOnly.toObject (_AustraliaOnly)); //
tl_diversity_questionPSet.setAttrib (FIELD_MultipleAnswers, HELPER_MultipleAnswers.toObject (_MultipleAnswers)); //
} }
...@@ -929,6 +1053,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -929,6 +1053,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
_Code = (String)(HELPER_Code.fromObject (_Code, tl_diversity_questionPSet.getAttrib (FIELD_Code))); // _Code = (String)(HELPER_Code.fromObject (_Code, tl_diversity_questionPSet.getAttrib (FIELD_Code))); //
_QuestionText = (String)(HELPER_QuestionText.fromObject (_QuestionText, tl_diversity_questionPSet.getAttrib (FIELD_QuestionText))); // _QuestionText = (String)(HELPER_QuestionText.fromObject (_QuestionText, tl_diversity_questionPSet.getAttrib (FIELD_QuestionText))); //
_AustraliaOnly = (Boolean)(HELPER_AustraliaOnly.fromObject (_AustraliaOnly, tl_diversity_questionPSet.getAttrib (FIELD_AustraliaOnly))); // _AustraliaOnly = (Boolean)(HELPER_AustraliaOnly.fromObject (_AustraliaOnly, tl_diversity_questionPSet.getAttrib (FIELD_AustraliaOnly))); //
_MultipleAnswers = (Boolean)(HELPER_MultipleAnswers.fromObject (_MultipleAnswers, tl_diversity_questionPSet.getAttrib (FIELD_MultipleAnswers))); //
} }
...@@ -971,6 +1096,15 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -971,6 +1096,15 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
e.addException (ex); e.addException (ex);
} }
try
{
setMultipleAnswers (otherDiversityQuestion.getMultipleAnswers ());
}
catch (FieldException ex)
{
e.addException (ex);
}
} }
} }
...@@ -989,6 +1123,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -989,6 +1123,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
_Code = sourceDiversityQuestion._Code; _Code = sourceDiversityQuestion._Code;
_QuestionText = sourceDiversityQuestion._QuestionText; _QuestionText = sourceDiversityQuestion._QuestionText;
_AustraliaOnly = sourceDiversityQuestion._AustraliaOnly; _AustraliaOnly = sourceDiversityQuestion._AustraliaOnly;
_MultipleAnswers = sourceDiversityQuestion._MultipleAnswers;
} }
} }
...@@ -1045,6 +1180,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1045,6 +1180,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
_Code = (String)(HELPER_Code.readExternal (_Code, vals.get(FIELD_Code))); // _Code = (String)(HELPER_Code.readExternal (_Code, vals.get(FIELD_Code))); //
_QuestionText = (String)(HELPER_QuestionText.readExternal (_QuestionText, vals.get(FIELD_QuestionText))); // _QuestionText = (String)(HELPER_QuestionText.readExternal (_QuestionText, vals.get(FIELD_QuestionText))); //
_AustraliaOnly = (Boolean)(HELPER_AustraliaOnly.readExternal (_AustraliaOnly, vals.get(FIELD_AustraliaOnly))); // _AustraliaOnly = (Boolean)(HELPER_AustraliaOnly.readExternal (_AustraliaOnly, vals.get(FIELD_AustraliaOnly))); //
_MultipleAnswers = (Boolean)(HELPER_MultipleAnswers.readExternal (_MultipleAnswers, vals.get(FIELD_MultipleAnswers))); //
_Answers.readExternalData(vals.get(MULTIPLEREFERENCE_Answers)); _Answers.readExternalData(vals.get(MULTIPLEREFERENCE_Answers));
} }
...@@ -1060,6 +1196,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1060,6 +1196,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
vals.put (FIELD_Code, HELPER_Code.writeExternal (_Code)); vals.put (FIELD_Code, HELPER_Code.writeExternal (_Code));
vals.put (FIELD_QuestionText, HELPER_QuestionText.writeExternal (_QuestionText)); vals.put (FIELD_QuestionText, HELPER_QuestionText.writeExternal (_QuestionText));
vals.put (FIELD_AustraliaOnly, HELPER_AustraliaOnly.writeExternal (_AustraliaOnly)); vals.put (FIELD_AustraliaOnly, HELPER_AustraliaOnly.writeExternal (_AustraliaOnly));
vals.put (FIELD_MultipleAnswers, HELPER_MultipleAnswers.writeExternal (_MultipleAnswers));
vals.put (MULTIPLEREFERENCE_Answers, _Answers.writeExternalData()); vals.put (MULTIPLEREFERENCE_Answers, _Answers.writeExternalData());
} }
...@@ -1086,6 +1223,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1086,6 +1223,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
{ {
listener.notifyFieldChange(this, other, FIELD_AustraliaOnly, HELPER_AustraliaOnly.toObject(this._AustraliaOnly), HELPER_AustraliaOnly.toObject(otherDiversityQuestion._AustraliaOnly)); listener.notifyFieldChange(this, other, FIELD_AustraliaOnly, HELPER_AustraliaOnly.toObject(this._AustraliaOnly), HELPER_AustraliaOnly.toObject(otherDiversityQuestion._AustraliaOnly));
} }
if (!HELPER_MultipleAnswers.compare(this._MultipleAnswers, otherDiversityQuestion._MultipleAnswers))
{
listener.notifyFieldChange(this, other, FIELD_MultipleAnswers, HELPER_MultipleAnswers.toObject(this._MultipleAnswers), HELPER_MultipleAnswers.toObject(otherDiversityQuestion._MultipleAnswers));
}
// Compare single assocs // Compare single assocs
...@@ -1112,6 +1253,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1112,6 +1253,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
visitor.visitField(this, FIELD_Code, HELPER_Code.toObject(getCode())); visitor.visitField(this, FIELD_Code, HELPER_Code.toObject(getCode()));
visitor.visitField(this, FIELD_QuestionText, HELPER_QuestionText.toObject(getQuestionText())); visitor.visitField(this, FIELD_QuestionText, HELPER_QuestionText.toObject(getQuestionText()));
visitor.visitField(this, FIELD_AustraliaOnly, HELPER_AustraliaOnly.toObject(getAustraliaOnly())); visitor.visitField(this, FIELD_AustraliaOnly, HELPER_AustraliaOnly.toObject(getAustraliaOnly()));
visitor.visitField(this, FIELD_MultipleAnswers, HELPER_MultipleAnswers.toObject(getMultipleAnswers()));
visitor.visitAssociation (_Answers); visitor.visitAssociation (_Answers);
} }
...@@ -1162,6 +1304,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1162,6 +1304,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
{ {
return filter.matches (getAustraliaOnly ()); return filter.matches (getAustraliaOnly ());
} }
else if (attribName.equals (FIELD_MultipleAnswers))
{
return filter.matches (getMultipleAnswers ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -1211,6 +1357,12 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1211,6 +1357,12 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
return this; return this;
} }
public SearchAll andMultipleAnswers (QueryFilter<Boolean> filter)
{
filter.addFilter (context, "tl_diversity_question.multiple_answers", "MultipleAnswers");
return this;
}
public DiversityQuestion[] public DiversityQuestion[]
search (ObjectTransaction transaction) throws StorageException search (ObjectTransaction transaction) throws StorageException
{ {
...@@ -1258,6 +1410,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1258,6 +1410,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
{ {
return HELPER_AustraliaOnly.toObject (getAustraliaOnly ()); return HELPER_AustraliaOnly.toObject (getAustraliaOnly ());
} }
else if (attribName.equals (FIELD_MultipleAnswers))
{
return HELPER_MultipleAnswers.toObject (getMultipleAnswers ());
}
else else
{ {
return super.getAttribute (attribName); return super.getAttribute (attribName);
...@@ -1283,6 +1439,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1283,6 +1439,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
{ {
return HELPER_AustraliaOnly; return HELPER_AustraliaOnly;
} }
else if (attribName.equals (FIELD_MultipleAnswers))
{
return HELPER_MultipleAnswers;
}
else else
{ {
return super.getAttributeHelper (attribName); return super.getAttributeHelper (attribName);
...@@ -1308,6 +1468,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1308,6 +1468,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
{ {
setAustraliaOnly ((Boolean)(HELPER_AustraliaOnly.fromObject (_AustraliaOnly, attribValue))); setAustraliaOnly ((Boolean)(HELPER_AustraliaOnly.fromObject (_AustraliaOnly, attribValue)));
} }
else if (attribName.equals (FIELD_MultipleAnswers))
{
setMultipleAnswers ((Boolean)(HELPER_MultipleAnswers.fromObject (_MultipleAnswers, attribValue)));
}
else else
{ {
super.setAttribute (attribName, attribValue); super.setAttribute (attribName, attribValue);
...@@ -1340,6 +1504,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1340,6 +1504,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
{ {
return getWriteability_AustraliaOnly (); return getWriteability_AustraliaOnly ();
} }
else if (fieldName.equals (FIELD_MultipleAnswers))
{
return getWriteability_MultipleAnswers ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_Answers)) else if (fieldName.equals (MULTIPLEREFERENCE_Answers))
{ {
return getWriteability_Answers (); return getWriteability_Answers ();
...@@ -1369,6 +1537,11 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1369,6 +1537,11 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
fields.add (FIELD_AustraliaOnly); fields.add (FIELD_AustraliaOnly);
} }
if (getWriteability_MultipleAnswers () != FieldWriteability.TRUE)
{
fields.add (FIELD_MultipleAnswers);
}
super.putUnwriteable (fields); super.putUnwriteable (fields);
} }
...@@ -1381,6 +1554,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1381,6 +1554,7 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
result.add(HELPER_Code.getAttribObject (getClass (), _Code, true, FIELD_Code)); result.add(HELPER_Code.getAttribObject (getClass (), _Code, true, FIELD_Code));
result.add(HELPER_QuestionText.getAttribObject (getClass (), _QuestionText, true, FIELD_QuestionText)); result.add(HELPER_QuestionText.getAttribObject (getClass (), _QuestionText, true, FIELD_QuestionText));
result.add(HELPER_AustraliaOnly.getAttribObject (getClass (), _AustraliaOnly, false, FIELD_AustraliaOnly)); result.add(HELPER_AustraliaOnly.getAttribObject (getClass (), _AustraliaOnly, false, FIELD_AustraliaOnly));
result.add(HELPER_MultipleAnswers.getAttribObject (getClass (), _MultipleAnswers, false, FIELD_MultipleAnswers));
return result; return result;
} }
...@@ -1485,6 +1659,24 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1485,6 +1659,24 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
return newAustraliaOnly; return newAustraliaOnly;
} }
/**
* Get the attribute MultipleAnswers
*/
public Boolean getMultipleAnswers (DiversityQuestion obj, Boolean original)
{
return original;
}
/**
* Change the value set for attribute MultipleAnswers.
* May modify the field beforehand
* Occurs before validation.
*/
public Boolean setMultipleAnswers (DiversityQuestion obj, Boolean newMultipleAnswers) throws FieldException
{
return newMultipleAnswers;
}
} }
...@@ -1553,6 +1745,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1553,6 +1745,10 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
{ {
return toAustraliaOnly (); return toAustraliaOnly ();
} }
if (name.equals ("MultipleAnswers"))
{
return toMultipleAnswers ();
}
return super.to(name); return super.to(name);
...@@ -1564,6 +1760,8 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass ...@@ -1564,6 +1760,8 @@ public abstract class BaseDiversityQuestion extends BaseBusinessClass
public PipeLine<From, String> toQuestionText () { return pipe(new ORMAttributePipe<Me, String>(FIELD_QuestionText)); } public PipeLine<From, String> toQuestionText () { return pipe(new ORMAttributePipe<Me, String>(FIELD_QuestionText)); }
public PipeLine<From, Boolean> toAustraliaOnly () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_AustraliaOnly)); } public PipeLine<From, Boolean> toAustraliaOnly () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_AustraliaOnly)); }
public PipeLine<From, Boolean> toMultipleAnswers () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_MultipleAnswers)); }
public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswers () { return toAnswers(Filter.ALL); } public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswers () { return toAnswers(Filter.ALL); }
public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswers (Filter<DiversityAnswer> filter) public DiversityAnswer.DiversityAnswerPipeLineFactory<From, DiversityAnswer> toAnswers (Filter<DiversityAnswer> filter)
......
...@@ -216,4 +216,11 @@ public class Candidate extends BaseCandidate ...@@ -216,4 +216,11 @@ public class Candidate extends BaseCandidate
return Boolean.FALSE; return Boolean.FALSE;
} }
public Boolean hasAnswer(HTDiversityQuestion htQuestion)
{
return Boolean.FALSE;
}
} }
\ No newline at end of file
package performa.orm; package performa.orm;
import oneit.utils.CollectionUtils;
public class CandidateDiversityAnswer extends BaseCandidateDiversityAnswer public class CandidateDiversityAnswer extends BaseCandidateDiversityAnswer
{ {
...@@ -10,4 +12,24 @@ public class CandidateDiversityAnswer extends BaseCandidateDiversityAnswer ...@@ -10,4 +12,24 @@ public class CandidateDiversityAnswer extends BaseCandidateDiversityAnswer
{ {
// Do not add any code to this, always put it in initialiseNewObject // Do not add any code to this, always put it in initialiseNewObject
} }
public CandidateDiversityAnswer getAnswerForQuestion(HTDiversityQuestion htQuestion)
{
CandidateDiversityAnswer answer = null;
if(htQuestion != null)
{
for(CultureCriteria cc: htQuestion.getQ)
{
if(CollectionUtils.equals(cc.getCultureElement(), getCultureElement()))
{
criteria = cc;
break;
}
}
}
return answer;
}
} }
\ No newline at end of file
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
<BUSINESSCLASS name="CandidateDiversityAnswer" package="performa.orm"> <BUSINESSCLASS name="CandidateDiversityAnswer" package="performa.orm">
<MULTIPLEREFERENCE name="Answers" type="AnswerOption" backreferenceName="CandidateAnswer" />
<TABLE name="tl_candidate_diversity_answer" tablePrefix="object" polymorphic="FALSE"> <TABLE name="tl_candidate_diversity_answer" tablePrefix="object" polymorphic="FALSE">
<SINGLEREFERENCE name="Answer" type="DiversityAnswer" dbcol="answer_id" mandatory="true" />
<SINGLEREFERENCE name="Question" type="DiversityQuestion" dbcol="question_id" mandatory="true" /> <SINGLEREFERENCE name="Question" type="DiversityQuestion" dbcol="question_id" mandatory="true" />
<SINGLEREFERENCE name="Candidate" type="Candidate" dbcol="candidate_id" mandatory="true" backreferenceName="DiversityAnswers" /> <SINGLEREFERENCE name="Candidate" type="Candidate" dbcol="candidate_id" mandatory="true" backreferenceName="DiversityAnswers" />
......
...@@ -38,7 +38,7 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -38,7 +38,7 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}tl_candidate_diversity_answer.object_id as id, {PREFIX}tl_candidate_diversity_answer.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_candidate_diversity_answer.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_candidate_diversity_answer.answer_id, {PREFIX}tl_candidate_diversity_answer.question_id, {PREFIX}tl_candidate_diversity_answer.candidate_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_candidate_diversity_answer.object_id as id, {PREFIX}tl_candidate_diversity_answer.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_candidate_diversity_answer.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_candidate_diversity_answer.question_id, {PREFIX}tl_candidate_diversity_answer.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
...@@ -89,7 +89,6 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -89,7 +89,6 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !tl_candidate_diversity_answerPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !tl_candidate_diversity_answerPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_candidate_diversity_answerPSet.containsAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Answer)||
!tl_candidate_diversity_answerPSet.containsAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Question)|| !tl_candidate_diversity_answerPSet.containsAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Question)||
!tl_candidate_diversity_answerPSet.containsAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Candidate)) !tl_candidate_diversity_answerPSet.containsAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Candidate))
{ {
...@@ -171,10 +170,10 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -171,10 +170,10 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_candidate_diversity_answer " + "UPDATE {PREFIX}tl_candidate_diversity_answer " +
"SET answer_id = ? , question_id = ? , candidate_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET question_id = ? , candidate_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_candidate_diversity_answer.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE tl_candidate_diversity_answer.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Answer)))).listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Question)))).listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Candidate)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Question)))).listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Candidate)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -431,7 +430,6 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -431,7 +430,6 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr
tl_candidate_diversity_answerPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); tl_candidate_diversity_answerPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_candidate_diversity_answerPSet.setAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Answer, r.getObject ("answer_id"));
tl_candidate_diversity_answerPSet.setAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Question, r.getObject ("question_id")); tl_candidate_diversity_answerPSet.setAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Question, r.getObject ("question_id"));
tl_candidate_diversity_answerPSet.setAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Candidate, r.getObject ("candidate_id")); tl_candidate_diversity_answerPSet.setAttrib(CandidateDiversityAnswer.SINGLEREFERENCE_Candidate, r.getObject ("candidate_id"));
...@@ -450,10 +448,10 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr ...@@ -450,10 +448,10 @@ public class CandidateDiversityAnswerPersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_candidate_diversity_answer " + "INSERT INTO {PREFIX}tl_candidate_diversity_answer " +
" ( answer_id, question_id, candidate_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " ( question_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)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Answer)))).listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Question)))).listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Candidate)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils .listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Question)))).listEntry (SQLManager.CheckNull((Long)(tl_candidate_diversity_answerPSet.getAttrib (CandidateDiversityAnswer.SINGLEREFERENCE_Candidate)))) .listEntry (objectID.longID ()).toList().toArray());
tl_candidate_diversity_answerPSet.setStatus (PersistentSetStatus.PROCESSED); tl_candidate_diversity_answerPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<ATTRIB name="Code" type="String" dbcol="question_code" mandatory="true"/> <ATTRIB name="Code" type="String" dbcol="question_code" mandatory="true"/>
<ATTRIB name="QuestionText" type="String" dbcol="question_text" mandatory="true"/> <ATTRIB name="QuestionText" type="String" dbcol="question_text" mandatory="true"/>
<ATTRIB name="AustraliaOnly" type="Boolean" dbcol="australia_only" defaultValue="Boolean.FALSE" /> <ATTRIB name="AustraliaOnly" type="Boolean" dbcol="australia_only" defaultValue="Boolean.FALSE" />
<ATTRIB name="MultipleAnswers" type="Boolean" dbcol="multiple_answers" defaultValue="Boolean.FALSE" />
</TABLE> </TABLE>
......
...@@ -29,12 +29,14 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -29,12 +29,14 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr
private String dummyCode; private String dummyCode;
private String dummyQuestionText; private String dummyQuestionText;
private Boolean dummyAustraliaOnly; private Boolean dummyAustraliaOnly;
private Boolean dummyMultipleAnswers;
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Code = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_Code = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_QuestionText = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_QuestionText = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_AustraliaOnly = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_AustraliaOnly = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_MultipleAnswers = DefaultAttributeHelper.INSTANCE;
...@@ -44,10 +46,11 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -44,10 +46,11 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr
dummyCode = (String)(HELPER_Code.initialise (dummyCode)); dummyCode = (String)(HELPER_Code.initialise (dummyCode));
dummyQuestionText = (String)(HELPER_QuestionText.initialise (dummyQuestionText)); dummyQuestionText = (String)(HELPER_QuestionText.initialise (dummyQuestionText));
dummyAustraliaOnly = (Boolean)(HELPER_AustraliaOnly.initialise (dummyAustraliaOnly)); dummyAustraliaOnly = (Boolean)(HELPER_AustraliaOnly.initialise (dummyAustraliaOnly));
dummyMultipleAnswers = (Boolean)(HELPER_MultipleAnswers.initialise (dummyMultipleAnswers));
} }
private String SELECT_COLUMNS = "{PREFIX}tl_diversity_question.object_id as id, {PREFIX}tl_diversity_question.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_diversity_question.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_diversity_question.question_code, {PREFIX}tl_diversity_question.question_text, {PREFIX}tl_diversity_question.australia_only, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_diversity_question.object_id as id, {PREFIX}tl_diversity_question.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_diversity_question.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_diversity_question.question_code, {PREFIX}tl_diversity_question.question_text, {PREFIX}tl_diversity_question.australia_only, {PREFIX}tl_diversity_question.multiple_answers, 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
...@@ -100,7 +103,8 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -100,7 +103,8 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr
if (false || !tl_diversity_questionPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !tl_diversity_questionPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_diversity_questionPSet.containsAttrib(DiversityQuestion.FIELD_Code)|| !tl_diversity_questionPSet.containsAttrib(DiversityQuestion.FIELD_Code)||
!tl_diversity_questionPSet.containsAttrib(DiversityQuestion.FIELD_QuestionText)|| !tl_diversity_questionPSet.containsAttrib(DiversityQuestion.FIELD_QuestionText)||
!tl_diversity_questionPSet.containsAttrib(DiversityQuestion.FIELD_AustraliaOnly)) !tl_diversity_questionPSet.containsAttrib(DiversityQuestion.FIELD_AustraliaOnly)||
!tl_diversity_questionPSet.containsAttrib(DiversityQuestion.FIELD_MultipleAnswers))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -170,10 +174,10 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -170,10 +174,10 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_diversity_question " + "UPDATE {PREFIX}tl_diversity_question " +
"SET question_code = ?, question_text = ?, australia_only = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET question_code = ?, question_text = ?, australia_only = ?, multiple_answers = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_diversity_question.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE tl_diversity_question.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Code.getForSQL(dummyCode, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_Code))).listEntry (HELPER_QuestionText.getForSQL(dummyQuestionText, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_QuestionText))).listEntry (HELPER_AustraliaOnly.getForSQL(dummyAustraliaOnly, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_AustraliaOnly))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Code.getForSQL(dummyCode, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_Code))).listEntry (HELPER_QuestionText.getForSQL(dummyQuestionText, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_QuestionText))).listEntry (HELPER_AustraliaOnly.getForSQL(dummyAustraliaOnly, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_AustraliaOnly))).listEntry (HELPER_MultipleAnswers.getForSQL(dummyMultipleAnswers, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_MultipleAnswers))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -432,6 +436,7 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -432,6 +436,7 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr
tl_diversity_questionPSet.setAttrib(DiversityQuestion.FIELD_Code, HELPER_Code.getFromRS(dummyCode, r, "question_code")); tl_diversity_questionPSet.setAttrib(DiversityQuestion.FIELD_Code, HELPER_Code.getFromRS(dummyCode, r, "question_code"));
tl_diversity_questionPSet.setAttrib(DiversityQuestion.FIELD_QuestionText, HELPER_QuestionText.getFromRS(dummyQuestionText, r, "question_text")); tl_diversity_questionPSet.setAttrib(DiversityQuestion.FIELD_QuestionText, HELPER_QuestionText.getFromRS(dummyQuestionText, r, "question_text"));
tl_diversity_questionPSet.setAttrib(DiversityQuestion.FIELD_AustraliaOnly, HELPER_AustraliaOnly.getFromRS(dummyAustraliaOnly, r, "australia_only")); tl_diversity_questionPSet.setAttrib(DiversityQuestion.FIELD_AustraliaOnly, HELPER_AustraliaOnly.getFromRS(dummyAustraliaOnly, r, "australia_only"));
tl_diversity_questionPSet.setAttrib(DiversityQuestion.FIELD_MultipleAnswers, HELPER_MultipleAnswers.getFromRS(dummyMultipleAnswers, r, "multiple_answers"));
} }
...@@ -449,10 +454,10 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr ...@@ -449,10 +454,10 @@ public class DiversityQuestionPersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_diversity_question " + "INSERT INTO {PREFIX}tl_diversity_question " +
" (question_code, question_text, australia_only, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (question_code, question_text, australia_only, multiple_answers, 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_Code.getForSQL(dummyCode, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_Code))).listEntry (HELPER_QuestionText.getForSQL(dummyQuestionText, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_QuestionText))).listEntry (HELPER_AustraliaOnly.getForSQL(dummyAustraliaOnly, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_AustraliaOnly))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Code.getForSQL(dummyCode, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_Code))).listEntry (HELPER_QuestionText.getForSQL(dummyQuestionText, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_QuestionText))).listEntry (HELPER_AustraliaOnly.getForSQL(dummyAustraliaOnly, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_AustraliaOnly))).listEntry (HELPER_MultipleAnswers.getForSQL(dummyMultipleAnswers, tl_diversity_questionPSet.getAttrib (DiversityQuestion.FIELD_MultipleAnswers))) .listEntry (objectID.longID ()).toList().toArray());
tl_diversity_questionPSet.setStatus (PersistentSetStatus.PROCESSED); tl_diversity_questionPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -818,4 +818,13 @@ public class Job extends BaseJob ...@@ -818,4 +818,13 @@ public class Job extends BaseJob
return getDiversityIncluded() && getHiringTeam().showHasDiversity() && pipelineJob().toHiringTeam().toDiversityQuestions(filter).uniqueVals().size() > 0; return getDiversityIncluded() && getHiringTeam().showHasDiversity() && pipelineJob().toHiringTeam().toDiversityQuestions(filter).uniqueVals().size() > 0;
} }
public Set<HTDiversityQuestion> getDiversityQuestions()
{
if(getDiversityIncluded())
{
return pipelineJob().toHiringTeam().toDiversityQuestions(HTDiversityQuestion.SearchByAll().andIsApplicable(new EqualsFilter<>(Boolean.TRUE))).uniqueVals();
}
return null;
}
} }
\ No newline at end of file
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<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_id" type="Long" length="11" nullable="false"/>
<column name="question_id" type="Long" length="11" nullable="false"/> <column name="question_id" type="Long" length="11" nullable="false"/>
<column name="candidate_id" type="Long" length="11" nullable="false"/> <column name="candidate_id" type="Long" length="11" nullable="false"/>
</NODE> </NODE>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<column name="question_code" type="CLOB" nullable="false"/> <column name="question_code" type="CLOB" nullable="false"/>
<column name="question_text" type="CLOB" nullable="false"/> <column name="question_text" type="CLOB" nullable="false"/>
<column name="australia_only" type="Boolean" nullable="true"/> <column name="australia_only" type="Boolean" nullable="true"/>
<column name="multiple_answers" type="Boolean" nullable="true"/>
</NODE> </NODE>
</NODE> </NODE>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<value name='object_last_updated_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/> <value name='object_last_updated_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/>
<value name='object_created_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/> <value name='object_created_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/>
<value name='australia_only' factory='Boolean'>true</value> <value name='australia_only' factory='Boolean'>true</value>
<value name='multiple_answers' factory='Boolean'>true</value>
<value name='question_text' factory='String'>Do you identify as a person of Aboriginal or Torres Strait Islander origin?</value> <value name='question_text' factory='String'>Do you identify as a person of Aboriginal or Torres Strait Islander origin?</value>
<value name='question_code' factory='String'>ATSI</value> <value name='question_code' factory='String'>ATSI</value>
</NODE> </NODE>
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
<value name='object_last_updated_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/> <value name='object_last_updated_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/>
<value name='object_created_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/> <value name='object_created_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/>
<value name='australia_only' factory='Boolean'>false</value> <value name='australia_only' factory='Boolean'>false</value>
<value name='multiple_answers' factory='Boolean'>false</value>
<value name='question_text' factory='String'>Do you identify as a person living with a disability?</value> <value name='question_text' factory='String'>Do you identify as a person living with a disability?</value>
<value name='question_code' factory='String'>DISABLED</value> <value name='question_code' factory='String'>DISABLED</value>
</NODE> </NODE>
...@@ -27,6 +29,7 @@ ...@@ -27,6 +29,7 @@
<value name='object_last_updated_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/> <value name='object_last_updated_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/>
<value name='object_created_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/> <value name='object_created_date' class="oneit.sql.transfer.DBTransferer$Timestamp"/>
<value name='australia_only' factory='Boolean'>false</value> <value name='australia_only' factory='Boolean'>false</value>
<value name='multiple_answers' factory='Boolean'>false</value>
<value name='question_text' factory='String'>I identify by gender as</value> <value name='question_text' factory='String'>I identify by gender as</value>
<value name='question_code' factory='String'>GENDER</value> <value name='question_code' factory='String'>GENDER</value>
</NODE> </NODE>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">tl_answer_option</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="candidate_answer_id" type="Long" length="11" nullable="false"/>
<column name="answer_id" type="Long" length="11" nullable="false"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_answer_option" indexName="idx_tl_answer_option_candidate_answer_id" isUnique="false">
<column name="candidate_answer_id"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
...@@ -60,81 +60,17 @@ ...@@ -60,81 +60,17 @@
} }
candidate.setHasValidAddress(candidate.getGoogleAddressText() != null); candidate.setHasValidAddress(candidate.getGoogleAddressText() != null);
candidate.setAnsweredDiversity(true);
process.setAttribute("JobApplication", jobApplication); process.setAttribute("JobApplication", jobApplication);
%> %>
<oneit:script> <oneit:form name="diversity" method="post" enctype="multipart/form-data">
<oneit:script src="/scripts/password_strength_lightweight.js"/>
</oneit:script>
<style>
button[disabled] {
opacity: 0.6;
background-color: #0582ba;
}
.email input[name$="Email"] {
opacity: 0;
position: absolute;
}
</style>
<oneit:form name="signIn" method="post" enctype="multipart/form-data">
<script type="text/javascript"> <script type="text/javascript">
$(document.body).addClass('bg-color'); $(document.body).addClass('bg-color');
var interval ;
$(document).ready(function() { $(document).ready(function() {
recalcFunction = setupRecalc ($("form#signIn"), {'recalcOnError':true}); recalcFunction = setupRecalc ($("form#diversity"), {'recalcOnError':true});
$(".fileLink").hide();
interval = setInterval(function() { validate(); }, 500);
validate();
$('input').on('change keyup', function() { validate(); });
});
function validate() {
var empty = false;
$('input[required]').each(function() {
if ($( this ).val() == '') {
empty = true;
if ($( this ).css('background-color') == 'rgb(250, 255, 189)') {
empty = false;
}
}
});
if (empty) {
$('.verify-btn').attr('disabled', 'disabled');
} else {
$('.verify-btn').removeAttr('disabled');
clearInterval(interval);
}
}
</script>
<script type="text/javascript">
$(document.body).addClass('bg-color');
$(document).ready(function(){
$('.attach-icon-btn').click(function(){
$(this).parent().find("input").click();
});
$("input:file").change(function (){
var fullPath = $(this).val();
var filename = fullPath.replace(/^.*[\\\/]/, '');
if (filename)
{
$(this).parents(".fileInput").siblings(".new-file-link").text(filename);
$(this).parents(".fileInput").siblings(".new-file-link").removeAttr("href");
}
});
}); });
</script> </script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=AIzaSyCaBh-MsMb8BBYJD_NcFzoCmygQbt5-QSw"></script>
<oneit:script>
<oneit:script src="/scripts/google_address.js"/>
</oneit:script>
<oneit:dynInclude page="/extensions/applicantportal/inc/multifieldtext.jsp" data="<%= CollectionUtils.EMPTY_MAP%>"/> <oneit:dynInclude page="/extensions/applicantportal/inc/multifieldtext.jsp" data="<%= CollectionUtils.EMPTY_MAP%>"/>
<div class="apply-job-logo-header signinpage"> <div class="apply-job-logo-header signinpage">
<div class="box-sizing-border-box"> <div class="box-sizing-border-box">
...@@ -157,162 +93,16 @@ ...@@ -157,162 +93,16 @@
</div> </div>
</div> </div>
<div class="main-verify-identity"> <div class="main-verify-identity">
<div class="pl-confirm text-center">Please confirm your details to continue</div>
<div class="main-box-layout main-verify-step-2">
<div class="form-group text-left">
<label>Email Address</label>
<%
if(secUser.getEmail() == null)
{
%>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control" style="text-transform: lowercase" required="true"/>
<%
}
else
{
%>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control second-style" disabled="true" readonly="true"/>
<%
}
%>
</div>
<% <%
for(HTDiversityQuestion question : job.getDiversityQuestions())
if(!candidate.isTrue(candidate.getIsPasswordChanged()))
{ {
String passkey = Utils.getPwdKeyOfSecUser(request, secUser, true);
%>
<script type="text/javascript">
$(document).ready(function() {
$('#myPassword').strength_meter({
"inputName" : "<%= passkey %>"
});
});
</script>
<div class="form-group text-left email">
<label style="display: none;"><oneit:ormlabel obj="<%= secUser %>" field="Email" /></label>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control"/>
</div>
<div class="form-group text-left" id="myPassword">
<label>Password</label>
</div>
<div class="form-group text-left">
<label>Confirm password</label>
<oneit:input type="password" name="<%= passkey + 2 %>" class="form-control second-style reset-pw"/>
</div>
<%
}
%> %>
<div class="row">
<div class="form-group text-left col-sm-6 col-xs-12">
<label><oneit:ormlabel obj="<%= secUser %>" field="FirstName" /></label>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="FirstName" cssClass="form-control second-style" required="true"/>
</div>
<div class="form-group text-left col-sm-6 col-xs-12">
<label><oneit:ormlabel obj="<%= secUser %>" field="LastName" /></label>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="LastName" cssClass="form-control second-style" required="true"/>
</div>
</div>
<div class="form-group text-left"> <div class="form-group text-left">
<label><oneit:ormlabel obj="<%= candidate %>" field="Phone" /></label> <label><%= question.getQuestionText() %></label>
<oneit:ormInput obj="<%= candidate %>" type="text" attributeName="Phone" cssClass="form-control second-style" required="true"/>
</div>
<%
if(job.getRequireCV())
{
%>
<div class="form-group text-left relative-parent ">
<label>Upload your CV, required (PDF preferred)</label>
<div class="form-control second-style">
<a target='blank' class="new-file-link" href='<%= request.getContextPath() + "/" + BinaryContentHandler.getRelativeURL(request, jobApplication, "CV", jobApplication.getCV(), true) %>'>
<%= jobApplication.getCV() != null ? "Click to View File" : "" %>
</a>
<oneit:ormInput obj="<%= jobApplication %>" type="file" attributeName="CV" cssClass="hide"/>
<div class="attach-icon-btn"></div>
</div>
</div>
<div class="form-group text-left relative-parent">
<label>Upload your Cover Letter, optional (PDF preferred)</label>
<div class="form-control second-style">
<a target='blank' class="new-file-link" href='<%= request.getContextPath() + "/" + BinaryContentHandler.getRelativeURL(request, jobApplication, "CoverLetter", jobApplication.getCoverLetter(), true) %>'>
<%= jobApplication.getCoverLetter() != null ? "Click to View File" : "" %>
</a>
<oneit:ormInput obj="<%= jobApplication %>" type="file" attributeName="CoverLetter" cssClass="hide"/>
<div class="attach-icon-btn"></div>
</div>
</div> </div>
<% <%
} }
%> %>
<hr class="seperate-line">
<div class="form-group text-left">
<label>Location</label>
<div class="googleAddress">
<oneit:ormInput obj="<%= candidate %>" class="has-valid-address" attributeName="HasValidAddress" type="checkbox"/>
<oneit:ormInput obj="<%= candidate %>" type="text" attributeName="GoogleAddressText" class="autoAddress" id="<%= "gAddress_"+candidate.getObjectID() %>" placeholder="Enter your address" cssClass="form-control" />
</div>
</div>
<div class="form-group text-left" style="margin-top: 30px;">
<div class="styled_checkboxes">
<div class="checkbox checkbox-primary">
<oneit:ormInput obj="<%= jobApplication %>" id="prefer-remote" attributeName="PreferRemote" type="checkbox"/>
<oneit:recalcClass htmlTag="span" classScript="jobApplication.getPreferRemote() ? 'checked': 'unchecked'" jobApplication="<%= jobApplication %>">
<label for="prefer-remote">
<oneit:label GUIName="I would prefer to work remotely" />
</label>
</oneit:recalcClass>
</div>
</div>
</div>
<oneit:recalcClass htmlTag="div" classScript="jobApplication.isFarFromJob() ? 'show': 'hide'" jobApplication="<%= jobApplication %>">
<div class="relocate-warning-box">
<p>
We noticed that your location is different to the location of the job (<%= job.getGoogleAddressText() %>).
</p>
<p>
Are you prepared to relocate for this position?
</p>
<div class="styled_checkboxes">
<div class="checkbox checkbox-primary">
<oneit:ormInput obj="<%= jobApplication %>" id="happy-to-relocate" attributeName="HappyToRelocate" type="checkbox" />
<oneit:recalcClass htmlTag="span" classScript="jobApplication.getHappyToRelocate() ? 'checked': 'unchecked'" jobApplication="<%= jobApplication %>">
<label for="happy-to-relocate">
<oneit:label GUIName="Yes, I am happy to relocate"/>
</label>
</oneit:recalcClass>
</div>
</div>
<span class="warning-icon"></span>
</div>
</oneit:recalcClass>
<div class="form-group text-left">
<div class="styled_checkboxes">
<div class="checkbox checkbox-primary">
<oneit:ormInput obj="<%= candidate %>" id="privacy-policy-agreed" attributeName="PrivacyPolicyAgreed" type="checkbox" />
<oneit:recalcClass htmlTag="span" classScript="candidate.showPrivacyPolicyAgreed() ? 'checked': 'unchecked'" candidate="<%= candidate %>">
<label for="privacy-policy-agreed">
<oneit:label GUIName="I have read and agree to the " />
<a href="https://www.matchd.com/privacy/" target="_blank" class="privacy-link">Privacy Policy</a>
</label>
</oneit:recalcClass>
</div>
</div>
</div>
<div class="form-group text-left">
<div class="styled_checkboxes">
<div class="checkbox checkbox-primary">
<oneit:ormInput obj="<%= candidate %>" id="conditions-agreed" attributeName="ConditionsAgreed" type="checkbox" />
<oneit:recalcClass htmlTag="span" classScript="candidate.showConditionsAgreed() ? 'checked': 'unchecked'" candidate="<%= candidate %>">
<label for="conditions-agreed">
<oneit:label GUIName="I have read and agree to the " />
<a href="https://www.matchd.com/terms-of-service/" target="_blank" class="privacy-link">Terms & Conditions</a>
</label>
</oneit:recalcClass>
</div>
</div>
</div>
<div class="text-center"> <div class="text-center">
<oneit:button value="Submit" name="sendVerificationMail" cssClass="box-btn send-link-btn" <oneit:button value="Submit" name="sendVerificationMail" cssClass="box-btn send-link-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", successPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", successPage)
...@@ -323,9 +113,5 @@ ...@@ -323,9 +113,5 @@
.toMap() %>"/> .toMap() %>"/>
</div> </div>
</div> </div>
</div>
<script>
addGoogleAddressListener('#<%= "gAddress_"+ candidate.getObjectID() %>');
</script>
</oneit:form> </oneit:form>
</oneit:dynIncluded> </oneit:dynIncluded>
\ No newline at end of file
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