Commit 435b6daa by Nilu

Added candidate multiref to TestInput

parent 0d6d079a
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
<column name="location" type="String" nullable="true" length="80"/> <column name="location" type="String" nullable="true" length="80"/>
<column name="contact_phone" type="String" nullable="true" length="80"/> <column name="contact_phone" type="String" nullable="true" length="80"/>
<column name="email" type="String" nullable="true" length="60"/> <column name="email" type="String" nullable="true" length="60"/>
<column name="test_input_id" type="Long" length="11" nullable="true"/>
</NODE> </NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="candidate" indexName="idx_candidate_test_input_id" isUnique="false"><column name="test_input_id"/></NODE>
</NODE></OBJECTS> </NODE></OBJECTS>
\ No newline at end of file
...@@ -21,7 +21,8 @@ CREATE TABLE candidate ( ...@@ -21,7 +21,8 @@ CREATE TABLE candidate (
date_taken datetime NULL, date_taken datetime NULL,
location varchar(80) NULL, location varchar(80) NULL,
contact_phone varchar(80) NULL, contact_phone varchar(80) NULL,
email varchar(60) NULL email varchar(60) NULL,
test_input_id numeric(12) NULL
); );
...@@ -34,3 +35,5 @@ ALTER TABLE candidate ADD ...@@ -34,3 +35,5 @@ ALTER TABLE candidate ADD
CREATE INDEX idx_candidate_test_input_id
ON candidate (test_input_id);
...@@ -22,7 +22,8 @@ CREATE TABLE candidate ( ...@@ -22,7 +22,8 @@ CREATE TABLE candidate (
date_taken date NULL, date_taken date NULL,
location varchar2(80) NULL, location varchar2(80) NULL,
contact_phone varchar2(80) NULL, contact_phone varchar2(80) NULL,
email varchar2(60) NULL email varchar2(60) NULL,
test_input_id number(12) NULL
); );
...@@ -35,3 +36,5 @@ ALTER TABLE candidate ADD ...@@ -35,3 +36,5 @@ ALTER TABLE candidate ADD
CREATE INDEX idx_candidate_test_input_id
ON candidate (test_input_id);
...@@ -22,7 +22,8 @@ CREATE TABLE candidate ( ...@@ -22,7 +22,8 @@ CREATE TABLE candidate (
date_taken timestamp NULL, date_taken timestamp NULL,
location varchar(80) NULL, location varchar(80) NULL,
contact_phone varchar(80) NULL, contact_phone varchar(80) NULL,
email varchar(60) NULL email varchar(60) NULL,
test_input_id numeric(12) NULL
); );
...@@ -35,3 +36,5 @@ ALTER TABLE candidate ADD ...@@ -35,3 +36,5 @@ ALTER TABLE candidate ADD
CREATE INDEX idx_candidate_test_input_id
ON candidate (test_input_id);
...@@ -52,6 +52,8 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -52,6 +52,8 @@ public abstract class BaseCandidate extends BaseBusinessClass
public static final String FIELD_Location = "Location"; public static final String FIELD_Location = "Location";
public static final String FIELD_Phone = "Phone"; public static final String FIELD_Phone = "Phone";
public static final String FIELD_Email = "Email"; public static final String FIELD_Email = "Email";
public static final String SINGLEREFERENCE_TestInput = "TestInput";
public static final String BACKREF_TestInput = "";
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
...@@ -92,6 +94,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -92,6 +94,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
// Private attributes corresponding to single references // Private attributes corresponding to single references
private SingleAssociation<Candidate, TestInput> _TestInput;
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
...@@ -125,9 +128,11 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -125,9 +128,11 @@ public abstract class BaseCandidate extends BaseBusinessClass
try try
{ {
String tmp_TestInput = TestInput.BACKREF_Candidates;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_TestInput();
FIELD_FirstName_Validators = (AttributeValidator[])setupAttribMetaData_FirstName(validatorMapping).toArray (new AttributeValidator[0]); FIELD_FirstName_Validators = (AttributeValidator[])setupAttribMetaData_FirstName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_MiddleName_Validators = (AttributeValidator[])setupAttribMetaData_MiddleName(validatorMapping).toArray (new AttributeValidator[0]); FIELD_MiddleName_Validators = (AttributeValidator[])setupAttribMetaData_MiddleName(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_LastName_Validators = (AttributeValidator[])setupAttribMetaData_LastName(validatorMapping).toArray (new AttributeValidator[0]); FIELD_LastName_Validators = (AttributeValidator[])setupAttribMetaData_LastName(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -157,6 +162,21 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -157,6 +162,21 @@ public abstract class BaseCandidate extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_TestInput()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "Candidates");
metaInfo.put ("dbcol", "test_input_id");
metaInfo.put ("name", "TestInput");
metaInfo.put ("type", "TestInput");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Candidate.TestInput:", metaInfo);
ATTRIBUTES_METADATA_Candidate.put (SINGLEREFERENCE_TestInput, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_FirstName(Map validatorMapping) private static List setupAttribMetaData_FirstName(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -468,6 +488,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -468,6 +488,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_TestInput = new SingleAssociation<Candidate, TestInput> (this, SINGLEREFERENCE_TestInput, TestInput.MULTIPLEREFERENCE_Candidates, TestInput.REFERENCE_TestInput, "candidate");
} }
...@@ -477,6 +498,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -477,6 +498,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_TestInput = new SingleAssociation<Candidate, TestInput> (this, SINGLEREFERENCE_TestInput, TestInput.MULTIPLEREFERENCE_Candidates, TestInput.REFERENCE_TestInput, "candidate");
return this; return this;
...@@ -1866,6 +1888,8 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1866,6 +1888,8 @@ public abstract class BaseCandidate extends BaseBusinessClass
List result = super.getSingleAssocs (); List result = super.getSingleAssocs ();
result.add("TestInput");
return result; return result;
} }
...@@ -1877,7 +1901,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1877,7 +1901,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_TestInput))
{
return _TestInput.getReferencedType ();
}
else else
{ {
return super.getSingleAssocReferenceInstance (assocName); return super.getSingleAssocReferenceInstance (assocName);
...@@ -1891,7 +1918,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1891,7 +1918,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_TestInput))
{
return TestInput.MULTIPLEREFERENCE_Candidates ;
}
else else
{ {
return super.getSingleAssocBackReference (assocName); return super.getSingleAssocBackReference (assocName);
...@@ -1905,7 +1935,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1905,7 +1935,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_TestInput))
{
return getTestInput ();
}
else else
{ {
return super.getSingleAssoc (assocName); return super.getSingleAssoc (assocName);
...@@ -1919,7 +1952,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1919,7 +1952,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_TestInput))
{
return getTestInput (getType);
}
else else
{ {
return super.getSingleAssoc (assocName, getType); return super.getSingleAssoc (assocName, getType);
...@@ -1933,7 +1969,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1933,7 +1969,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_TestInput))
{
return getTestInputID ();
}
else else
{ {
return super.getSingleAssocID (assocName); return super.getSingleAssocID (assocName);
...@@ -1947,7 +1986,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1947,7 +1986,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_TestInput))
{
setTestInput ((TestInput)(newValue));
}
else else
{ {
super.setSingleAssoc (assocName, newValue); super.setSingleAssoc (assocName, newValue);
...@@ -1957,6 +1999,113 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -1957,6 +1999,113 @@ public abstract class BaseCandidate extends BaseBusinessClass
/** /**
* Get the reference TestInput
*/
public TestInput getTestInput () throws StorageException
{
assertValid();
try
{
return (TestInput)(_TestInput.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Candidate:", this.getObjectID (), ", was trying to get TestInput:", getTestInputID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _TestInput.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public TestInput getTestInput (Get getType) throws StorageException
{
assertValid();
return _TestInput.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getTestInputID ()
{
assertValid();
if (_TestInput == null)
{
return null;
}
else
{
return _TestInput.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 preTestInputChange (TestInput newTestInput) 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 postTestInputChange () throws FieldException
{
}
public FieldWriteability getWriteability_TestInput ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference TestInput. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setTestInput (TestInput newTestInput) throws StorageException, FieldException
{
if (_TestInput.wouldReferencedChange (newTestInput))
{
assertValid();
Debug.assertion (getWriteability_TestInput () != FieldWriteability.FALSE, "Assoc TestInput is not writeable");
preTestInputChange (newTestInput);
TestInput oldTestInput = getTestInput ();
if (oldTestInput != null)
{
// This is to stop validation from triggering when we are removed
_TestInput.set (null);
oldTestInput.removeFromCandidates ((Candidate)(this));
}
_TestInput.set (newTestInput);
if (newTestInput != null)
{
newTestInput.addToCandidates ((Candidate)(this));
}
postTestInputChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings. * A list of multi assoc names e.g. list of strings.
*/ */
public List<String> getMultiAssocs() public List<String> getMultiAssocs()
...@@ -2054,6 +2203,20 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2054,6 +2203,20 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
try try
{ {
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_TestInput.isLoaded () || getTransaction ().isObjectLoaded (_TestInput.getReferencedType (), getTestInputID ()))
{
TestInput referenced = getTestInput ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Candidates from ", getObjectID (), " to ", referenced.getObjectID ());
_TestInput.set (null);
referenced.removeFromCandidates ((Candidate)this);
}
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -2128,6 +2291,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2128,6 +2291,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
candidatePSet.setAttrib (FIELD_Location, HELPER_Location.toObject (_Location)); // candidatePSet.setAttrib (FIELD_Location, HELPER_Location.toObject (_Location)); //
candidatePSet.setAttrib (FIELD_Phone, HELPER_Phone.toObject (_Phone)); // candidatePSet.setAttrib (FIELD_Phone, HELPER_Phone.toObject (_Phone)); //
candidatePSet.setAttrib (FIELD_Email, HELPER_Email.toObject (_Email)); // candidatePSet.setAttrib (FIELD_Email, HELPER_Email.toObject (_Email)); //
_TestInput.getPersistentSets (allSets);
} }
...@@ -2156,6 +2320,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2156,6 +2320,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
_Location = (String)(HELPER_Location.fromObject (_Location, candidatePSet.getAttrib (FIELD_Location))); // _Location = (String)(HELPER_Location.fromObject (_Location, candidatePSet.getAttrib (FIELD_Location))); //
_Phone = (String)(HELPER_Phone.fromObject (_Phone, candidatePSet.getAttrib (FIELD_Phone))); // _Phone = (String)(HELPER_Phone.fromObject (_Phone, candidatePSet.getAttrib (FIELD_Phone))); //
_Email = (String)(HELPER_Email.fromObject (_Email, candidatePSet.getAttrib (FIELD_Email))); // _Email = (String)(HELPER_Email.fromObject (_Email, candidatePSet.getAttrib (FIELD_Email))); //
_TestInput.setFromPersistentSets (objectID, allSets);
} }
...@@ -2342,6 +2507,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2342,6 +2507,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
BaseCandidate sourceCandidate = (BaseCandidate)(source); BaseCandidate sourceCandidate = (BaseCandidate)(source);
_TestInput.copyFrom (sourceCandidate._TestInput, linkToGhosts);
} }
} }
...@@ -2392,6 +2558,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2392,6 +2558,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
_Location = (String)(HELPER_Location.readExternal (_Location, vals.get(FIELD_Location))); // _Location = (String)(HELPER_Location.readExternal (_Location, vals.get(FIELD_Location))); //
_Phone = (String)(HELPER_Phone.readExternal (_Phone, vals.get(FIELD_Phone))); // _Phone = (String)(HELPER_Phone.readExternal (_Phone, vals.get(FIELD_Phone))); //
_Email = (String)(HELPER_Email.readExternal (_Email, vals.get(FIELD_Email))); // _Email = (String)(HELPER_Email.readExternal (_Email, vals.get(FIELD_Email))); //
_TestInput.readExternalData(vals.get(SINGLEREFERENCE_TestInput));
} }
...@@ -2417,6 +2584,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2417,6 +2584,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
vals.put (FIELD_Location, HELPER_Location.writeExternal (_Location)); vals.put (FIELD_Location, HELPER_Location.writeExternal (_Location));
vals.put (FIELD_Phone, HELPER_Phone.writeExternal (_Phone)); vals.put (FIELD_Phone, HELPER_Phone.writeExternal (_Phone));
vals.put (FIELD_Email, HELPER_Email.writeExternal (_Email)); vals.put (FIELD_Email, HELPER_Email.writeExternal (_Email));
vals.put (SINGLEREFERENCE_TestInput, _TestInput.writeExternalData());
} }
...@@ -2488,6 +2656,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2488,6 +2656,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
} }
// Compare single assocs // Compare single assocs
_TestInput.compare (otherCandidate._TestInput, listener);
// Compare multiple assocs // Compare multiple assocs
...@@ -2522,6 +2691,7 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2522,6 +2691,7 @@ public abstract class BaseCandidate extends BaseBusinessClass
visitor.visitField(this, FIELD_Location, HELPER_Location.toObject(getLocation())); visitor.visitField(this, FIELD_Location, HELPER_Location.toObject(getLocation()));
visitor.visitField(this, FIELD_Phone, HELPER_Phone.toObject(getPhone())); visitor.visitField(this, FIELD_Phone, HELPER_Phone.toObject(getPhone()));
visitor.visitField(this, FIELD_Email, HELPER_Email.toObject(getEmail())); visitor.visitField(this, FIELD_Email, HELPER_Email.toObject(getEmail()));
visitor.visitAssociation (_TestInput);
} }
...@@ -2530,6 +2700,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2530,6 +2700,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
super.visitAssociations (visitor, scope); super.visitAssociations (visitor, scope);
if (scope.includes (_TestInput))
{
visitor.visit (_TestInput);
}
} }
...@@ -2611,6 +2785,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2611,6 +2785,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
return filter.matches (getEmail ()); return filter.matches (getEmail ());
} }
else if (attribName.equals (SINGLEREFERENCE_TestInput))
{
return filter.matches (getTestInput ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -2726,6 +2904,12 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -2726,6 +2904,12 @@ public abstract class BaseCandidate extends BaseBusinessClass
return this; return this;
} }
public SearchAll andTestInput (QueryFilter<TestInput> filter)
{
filter.addFilter (context, "candidate.test_input_id", "TestInput");
return this;
}
public Candidate[] public Candidate[]
search (ObjectTransaction transaction) throws StorageException search (ObjectTransaction transaction) throws StorageException
{ {
...@@ -3031,6 +3215,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -3031,6 +3215,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
return getWriteability_Email (); return getWriteability_Email ();
} }
else if (fieldName.equals (SINGLEREFERENCE_TestInput))
{
return getWriteability_TestInput ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -3544,6 +3732,10 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -3544,6 +3732,10 @@ public abstract class BaseCandidate extends BaseBusinessClass
{ {
return toEmail (); return toEmail ();
} }
if (name.equals ("TestInput"))
{
return toTestInput ();
}
return super.to(name); return super.to(name);
...@@ -3577,6 +3769,12 @@ public abstract class BaseCandidate extends BaseBusinessClass ...@@ -3577,6 +3769,12 @@ public abstract class BaseCandidate extends BaseBusinessClass
public PipeLine<From, String> toPhone () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Phone)); } public PipeLine<From, String> toPhone () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Phone)); }
public PipeLine<From, String> toEmail () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Email)); } public PipeLine<From, String> toEmail () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Email)); }
public TestInput.TestInputPipeLineFactory<From, TestInput> toTestInput () { return toTestInput (Filter.ALL); }
public TestInput.TestInputPipeLineFactory<From, TestInput> toTestInput (Filter<TestInput> filter)
{
return TestInput.REFERENCE_TestInput.new TestInputPipeLineFactory<From, TestInput> (this, new ORMSingleAssocPipe<Me, TestInput>(SINGLEREFERENCE_TestInput, filter));
}
} }
...@@ -3608,6 +3806,20 @@ class DummyCandidate extends Candidate ...@@ -3608,6 +3806,20 @@ class DummyCandidate extends Candidate
} }
public TestInput getTestInput () throws StorageException
{
return (TestInput)(TestInput.DUMMY_TestInput);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getTestInputID ()
{
return TestInput.DUMMY_TestInput.getObjectID();
}
} }
...@@ -40,6 +40,8 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -40,6 +40,8 @@ public abstract class BaseTestInput extends NonPersistentBO
// Static constants corresponding to field names // Static constants corresponding to field names
public static final String FIELD_CSV = "CSV"; public static final String FIELD_CSV = "CSV";
public static final String MULTIPLEREFERENCE_Candidates = "Candidates";
public static final String BACKREF_Candidates = "";
// Static constants corresponding to searches // Static constants corresponding to searches
...@@ -56,6 +58,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -56,6 +58,7 @@ public abstract class BaseTestInput extends NonPersistentBO
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
private MultipleAssociation<TestInput, Candidate> _Candidates;
// Map of maps of metadata // Map of maps of metadata
...@@ -73,9 +76,11 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -73,9 +76,11 @@ public abstract class BaseTestInput extends NonPersistentBO
try try
{ {
String tmp_Candidates = Candidate.BACKREF_TestInput;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Candidates();
FIELD_CSV_Validators = (AttributeValidator[])setupAttribMetaData_CSV(validatorMapping).toArray (new AttributeValidator[0]); FIELD_CSV_Validators = (AttributeValidator[])setupAttribMetaData_CSV(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -92,6 +97,21 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -92,6 +97,21 @@ public abstract class BaseTestInput extends NonPersistentBO
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Candidates()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "TestInput");
metaInfo.put ("name", "Candidates");
metaInfo.put ("owner", "true");
metaInfo.put ("type", "Candidate");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for TestInput.Candidates:", metaInfo);
ATTRIBUTES_METADATA_TestInput.put (MULTIPLEREFERENCE_Candidates, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_CSV(Map validatorMapping) private static List setupAttribMetaData_CSV(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -149,6 +169,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -149,6 +169,7 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Candidates = new MultipleAssociation<TestInput, Candidate> (this, MULTIPLEREFERENCE_Candidates, Candidate.SINGLEREFERENCE_TestInput, Candidate.REFERENCE_Candidate);
} }
...@@ -158,6 +179,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -158,6 +179,7 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
super.initialiseReference (); super.initialiseReference ();
_Candidates = new MultipleAssociation<TestInput, Candidate> (this, MULTIPLEREFERENCE_Candidates, Candidate.SINGLEREFERENCE_TestInput, Candidate.REFERENCE_Candidate);
return this; return this;
...@@ -372,6 +394,8 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -372,6 +394,8 @@ public abstract class BaseTestInput extends NonPersistentBO
List result = super.getMultiAssocs (); List result = super.getMultiAssocs ();
result.add("Candidates");
return result; return result;
} }
...@@ -383,6 +407,11 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -383,6 +407,11 @@ public abstract class BaseTestInput extends NonPersistentBO
public BaseBusinessClass getMultiAssocReferenceInstance(String attribName) public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
return Candidate.REFERENCE_Candidate ;
}
return super.getMultiAssocReferenceInstance(attribName); return super.getMultiAssocReferenceInstance(attribName);
} }
...@@ -391,6 +420,11 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -391,6 +420,11 @@ public abstract class BaseTestInput extends NonPersistentBO
public String getMultiAssocBackReference(String attribName) public String getMultiAssocBackReference(String attribName)
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
return Candidate.SINGLEREFERENCE_TestInput ;
}
return super.getMultiAssocBackReference(attribName); return super.getMultiAssocBackReference(attribName);
} }
...@@ -402,6 +436,11 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -402,6 +436,11 @@ public abstract class BaseTestInput extends NonPersistentBO
public int getMultiAssocCount(String attribName) throws StorageException public int getMultiAssocCount(String attribName) throws StorageException
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
return this.getCandidatesCount();
}
return super.getMultiAssocCount(attribName); return super.getMultiAssocCount(attribName);
} }
...@@ -413,6 +452,11 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -413,6 +452,11 @@ public abstract class BaseTestInput extends NonPersistentBO
public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
return this.getCandidatesAt(index);
}
return super.getMultiAssocAt(attribName, index); return super.getMultiAssocAt(attribName, index);
} }
...@@ -424,6 +468,13 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -424,6 +468,13 @@ public abstract class BaseTestInput extends NonPersistentBO
public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
addToCandidates((Candidate)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement); super.addToMultiAssoc(attribName, newElement);
} }
...@@ -434,6 +485,13 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -434,6 +485,13 @@ public abstract class BaseTestInput extends NonPersistentBO
public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
removeFromCandidates((Candidate)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement); super.removeFromMultiAssoc(attribName, oldElement);
} }
...@@ -442,6 +500,12 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -442,6 +500,12 @@ public abstract class BaseTestInput extends NonPersistentBO
protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements) protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
_Candidates.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements); super.__loadMultiAssoc(attribName, elements);
} }
...@@ -450,18 +514,98 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -450,18 +514,98 @@ public abstract class BaseTestInput extends NonPersistentBO
protected boolean __isMultiAssocLoaded (String attribName) protected boolean __isMultiAssocLoaded (String attribName)
{ {
if (MULTIPLEREFERENCE_Candidates.equals(attribName))
{
return _Candidates.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName); return super.__isMultiAssocLoaded(attribName);
} }
public FieldWriteability getWriteability_Candidates ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getCandidatesCount () throws StorageException
{
assertValid();
return _Candidates.getReferencedObjectsCount ();
}
public void addToCandidates (Candidate newElement) throws StorageException
{
if (_Candidates.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_Candidates () != FieldWriteability.FALSE, "MultiAssoc Candidates is not writeable (add)");
_Candidates.appendElement (newElement);
try
{
if (newElement.getTestInput () != this)
{
newElement.setTestInput ((TestInput)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromCandidates (Candidate elementToRemove) throws StorageException
{
if (_Candidates.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_Candidates () != FieldWriteability.FALSE, "MultiAssoc Candidates is not writeable (remove)");
_Candidates.removeElement (elementToRemove);
try
{
if (elementToRemove.getTestInput () != null)
{
elementToRemove.setTestInput (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public Candidate getCandidatesAt (int index) throws StorageException
{
return (Candidate)(_Candidates.getElementAt (index));
}
public SortedSet<Candidate> getCandidatesSet () throws StorageException
{
return _Candidates.getSet ();
}
public void onDelete () public void onDelete ()
{ {
try try
{ {
for(Candidate referenced : CollectionUtils.reverse(getCandidatesSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Cascading delete for Candidates from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.delete ();
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -610,6 +754,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -610,6 +754,7 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
BaseTestInput sourceTestInput = (BaseTestInput)(source); BaseTestInput sourceTestInput = (BaseTestInput)(source);
_Candidates.copyFrom (sourceTestInput._Candidates, linkToGhosts);
} }
} }
...@@ -631,6 +776,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -631,6 +776,7 @@ public abstract class BaseTestInput extends NonPersistentBO
super.readExternalData(vals); super.readExternalData(vals);
_CSV = (BinaryContent)(HELPER_CSV.readExternal (_CSV, vals.get(FIELD_CSV))); // _CSV = (BinaryContent)(HELPER_CSV.readExternal (_CSV, vals.get(FIELD_CSV))); //
_Candidates.readExternalData(vals.get(MULTIPLEREFERENCE_Candidates));
} }
...@@ -643,6 +789,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -643,6 +789,7 @@ public abstract class BaseTestInput extends NonPersistentBO
super.writeExternalData(vals); super.writeExternalData(vals);
vals.put (FIELD_CSV, HELPER_CSV.writeExternal (_CSV)); vals.put (FIELD_CSV, HELPER_CSV.writeExternal (_CSV));
vals.put (MULTIPLEREFERENCE_Candidates, _Candidates.writeExternalData());
} }
...@@ -665,6 +812,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -665,6 +812,7 @@ public abstract class BaseTestInput extends NonPersistentBO
// Compare multiple assocs // Compare multiple assocs
_Candidates.compare (otherTestInput._Candidates, listener);
} }
} }
...@@ -683,6 +831,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -683,6 +831,7 @@ public abstract class BaseTestInput extends NonPersistentBO
super.visitAttributes (visitor); super.visitAttributes (visitor);
visitor.visitField(this, FIELD_CSV, HELPER_CSV.toObject(getCSV())); visitor.visitField(this, FIELD_CSV, HELPER_CSV.toObject(getCSV()));
visitor.visitAssociation (_Candidates);
} }
...@@ -691,6 +840,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -691,6 +840,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
super.visitAssociations (visitor, scope); super.visitAssociations (visitor, scope);
if (scope.includes (_Candidates))
{
visitor.visit (_Candidates);
}
} }
...@@ -797,6 +950,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -797,6 +950,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
return getWriteability_CSV (); return getWriteability_CSV ();
} }
else if (fieldName.equals (MULTIPLEREFERENCE_Candidates))
{
return getWriteability_Candidates ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -960,6 +1117,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -960,6 +1117,10 @@ public abstract class BaseTestInput extends NonPersistentBO
public PipeLine<From, ? extends Object> to(String name) public PipeLine<From, ? extends Object> to(String name)
{ {
if (name.equals ("Candidates"))
{
return toCandidates ();
}
if (name.equals ("CSV")) if (name.equals ("CSV"))
{ {
return toCSV (); return toCSV ();
...@@ -971,6 +1132,12 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -971,6 +1132,12 @@ public abstract class BaseTestInput extends NonPersistentBO
public PipeLine<From, BinaryContent> toCSV () { return pipe(new ORMAttributePipe<Me, BinaryContent>(FIELD_CSV)); } public PipeLine<From, BinaryContent> toCSV () { return pipe(new ORMAttributePipe<Me, BinaryContent>(FIELD_CSV)); }
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidates () { return toCandidates(Filter.ALL); }
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidates (Filter<Candidate> filter)
{
return Candidate.REFERENCE_Candidate.new CandidatePipeLineFactory<From, Candidate> (this, new ORMMultiAssocPipe<Me, Candidate>(MULTIPLEREFERENCE_Candidates, filter));
}
} }
...@@ -1002,5 +1169,22 @@ class DummyTestInput extends TestInput ...@@ -1002,5 +1169,22 @@ class DummyTestInput extends TestInput
} }
public int getCandidatesCount () throws StorageException
{
return 0;
}
public Candidate getCandidatesAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association Candidates");
}
public SortedSet getCandidatesSet () throws StorageException
{
return new TreeSet();
}
} }
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
<ATTRIB name="Phone" type="String" dbcol="contact_phone" length="80"/> <ATTRIB name="Phone" type="String" dbcol="contact_phone" length="80"/>
<ATTRIB name="Email" type="String" dbcol="email" length="60"/> <ATTRIB name="Email" type="String" dbcol="email" length="60"/>
<SINGLEREFERENCE name="TestInput" type="TestInput" dbcol="test_input_id" backreferenceName="Candidates"/>
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="candidate.object_id is not null" orderBy="candidate.object_id" /> <SEARCH type="All" paramFilter="candidate.object_id is not null" orderBy="candidate.object_id" />
......
...@@ -80,7 +80,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -80,7 +80,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}candidate.object_id as id, {PREFIX}candidate.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}candidate.object_CREATED_DATE as CREATED_DATE, {PREFIX}candidate.first_name, {PREFIX}candidate.middle_name, {PREFIX}candidate.last_name, {PREFIX}candidate.preferred_name, {PREFIX}candidate.salutation, {PREFIX}candidate.position, {PREFIX}candidate.date_of_birth, {PREFIX}candidate.date_registered, {PREFIX}candidate.gender, {PREFIX}candidate.password, {PREFIX}candidate.date_taken, {PREFIX}candidate.location, {PREFIX}candidate.contact_phone, {PREFIX}candidate.email, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}candidate.object_id as id, {PREFIX}candidate.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}candidate.object_CREATED_DATE as CREATED_DATE, {PREFIX}candidate.first_name, {PREFIX}candidate.middle_name, {PREFIX}candidate.last_name, {PREFIX}candidate.preferred_name, {PREFIX}candidate.salutation, {PREFIX}candidate.position, {PREFIX}candidate.date_of_birth, {PREFIX}candidate.date_registered, {PREFIX}candidate.gender, {PREFIX}candidate.password, {PREFIX}candidate.date_taken, {PREFIX}candidate.location, {PREFIX}candidate.contact_phone, {PREFIX}candidate.email, {PREFIX}candidate.test_input_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -144,7 +144,8 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -144,7 +144,8 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
!candidatePSet.containsAttrib(Candidate.FIELD_DateTaken)|| !candidatePSet.containsAttrib(Candidate.FIELD_DateTaken)||
!candidatePSet.containsAttrib(Candidate.FIELD_Location)|| !candidatePSet.containsAttrib(Candidate.FIELD_Location)||
!candidatePSet.containsAttrib(Candidate.FIELD_Phone)|| !candidatePSet.containsAttrib(Candidate.FIELD_Phone)||
!candidatePSet.containsAttrib(Candidate.FIELD_Email)) !candidatePSet.containsAttrib(Candidate.FIELD_Email)||
!candidatePSet.containsAttrib(Candidate.SINGLEREFERENCE_TestInput))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -190,6 +191,16 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -190,6 +191,16 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException (); throw new RuntimeException ();
} }
else if (refName.equals (Candidate.SINGLEREFERENCE_TestInput))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}candidate " +
"WHERE " + SELECT_JOINS + "test_input_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
else else
{ {
throw new IllegalArgumentException ("Illegal reference type:" + refName); throw new IllegalArgumentException ("Illegal reference type:" + refName);
...@@ -214,10 +225,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -214,10 +225,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}candidate " + "UPDATE {PREFIX}candidate " +
"SET first_name = ?, middle_name = ?, last_name = ?, preferred_name = ?, salutation = ?, position = ?, date_of_birth = ?, date_registered = ?, gender = ?, password = ?, date_taken = ?, location = ?, contact_phone = ?, email = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET first_name = ?, middle_name = ?, last_name = ?, preferred_name = ?, salutation = ?, position = ?, date_of_birth = ?, date_registered = ?, gender = ?, password = ?, date_taken = ?, location = ?, contact_phone = ?, email = ?, test_input_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE candidate.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE candidate.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_FirstName.getForSQL(dummyFirstName, candidatePSet.getAttrib (Candidate.FIELD_FirstName))).listEntry (HELPER_MiddleName.getForSQL(dummyMiddleName, candidatePSet.getAttrib (Candidate.FIELD_MiddleName))).listEntry (HELPER_LastName.getForSQL(dummyLastName, candidatePSet.getAttrib (Candidate.FIELD_LastName))).listEntry (HELPER_PreferredName.getForSQL(dummyPreferredName, candidatePSet.getAttrib (Candidate.FIELD_PreferredName))).listEntry (HELPER_Salutation.getForSQL(dummySalutation, candidatePSet.getAttrib (Candidate.FIELD_Salutation))).listEntry (HELPER_Position.getForSQL(dummyPosition, candidatePSet.getAttrib (Candidate.FIELD_Position))).listEntry (HELPER_DateOfBirth.getForSQL(dummyDateOfBirth, candidatePSet.getAttrib (Candidate.FIELD_DateOfBirth))).listEntry (HELPER_DateRegistered.getForSQL(dummyDateRegistered, candidatePSet.getAttrib (Candidate.FIELD_DateRegistered))).listEntry (HELPER_Gender.getForSQL(dummyGender, candidatePSet.getAttrib (Candidate.FIELD_Gender))).listEntry (HELPER_Password.getForSQL(dummyPassword, candidatePSet.getAttrib (Candidate.FIELD_Password))).listEntry (HELPER_DateTaken.getForSQL(dummyDateTaken, candidatePSet.getAttrib (Candidate.FIELD_DateTaken))).listEntry (HELPER_Location.getForSQL(dummyLocation, candidatePSet.getAttrib (Candidate.FIELD_Location))).listEntry (HELPER_Phone.getForSQL(dummyPhone, candidatePSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_Email.getForSQL(dummyEmail, candidatePSet.getAttrib (Candidate.FIELD_Email))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FirstName.getForSQL(dummyFirstName, candidatePSet.getAttrib (Candidate.FIELD_FirstName))).listEntry (HELPER_MiddleName.getForSQL(dummyMiddleName, candidatePSet.getAttrib (Candidate.FIELD_MiddleName))).listEntry (HELPER_LastName.getForSQL(dummyLastName, candidatePSet.getAttrib (Candidate.FIELD_LastName))).listEntry (HELPER_PreferredName.getForSQL(dummyPreferredName, candidatePSet.getAttrib (Candidate.FIELD_PreferredName))).listEntry (HELPER_Salutation.getForSQL(dummySalutation, candidatePSet.getAttrib (Candidate.FIELD_Salutation))).listEntry (HELPER_Position.getForSQL(dummyPosition, candidatePSet.getAttrib (Candidate.FIELD_Position))).listEntry (HELPER_DateOfBirth.getForSQL(dummyDateOfBirth, candidatePSet.getAttrib (Candidate.FIELD_DateOfBirth))).listEntry (HELPER_DateRegistered.getForSQL(dummyDateRegistered, candidatePSet.getAttrib (Candidate.FIELD_DateRegistered))).listEntry (HELPER_Gender.getForSQL(dummyGender, candidatePSet.getAttrib (Candidate.FIELD_Gender))).listEntry (HELPER_Password.getForSQL(dummyPassword, candidatePSet.getAttrib (Candidate.FIELD_Password))).listEntry (HELPER_DateTaken.getForSQL(dummyDateTaken, candidatePSet.getAttrib (Candidate.FIELD_DateTaken))).listEntry (HELPER_Location.getForSQL(dummyLocation, candidatePSet.getAttrib (Candidate.FIELD_Location))).listEntry (HELPER_Phone.getForSQL(dummyPhone, candidatePSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_Email.getForSQL(dummyEmail, candidatePSet.getAttrib (Candidate.FIELD_Email))).listEntry (SQLManager.CheckNull((Long)(candidatePSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -488,6 +499,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -488,6 +499,7 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
candidatePSet.setAttrib(Candidate.FIELD_Phone, HELPER_Phone.getFromRS(dummyPhone, r, "contact_phone")); candidatePSet.setAttrib(Candidate.FIELD_Phone, HELPER_Phone.getFromRS(dummyPhone, r, "contact_phone"));
candidatePSet.setAttrib(Candidate.FIELD_Email, HELPER_Email.getFromRS(dummyEmail, r, "email")); candidatePSet.setAttrib(Candidate.FIELD_Email, HELPER_Email.getFromRS(dummyEmail, r, "email"));
candidatePSet.setAttrib(Candidate.SINGLEREFERENCE_TestInput, r.getObject ("test_input_id"));
} }
...@@ -504,10 +516,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr ...@@ -504,10 +516,10 @@ public class CandidatePersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}candidate " + "INSERT INTO {PREFIX}candidate " +
" (first_name, middle_name, last_name, preferred_name, salutation, position, date_of_birth, date_registered, gender, password, date_taken, location, contact_phone, email, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (first_name, middle_name, last_name, preferred_name, salutation, position, date_of_birth, date_registered, gender, password, date_taken, location, contact_phone, email, test_input_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_FirstName.getForSQL(dummyFirstName, candidatePSet.getAttrib (Candidate.FIELD_FirstName))).listEntry (HELPER_MiddleName.getForSQL(dummyMiddleName, candidatePSet.getAttrib (Candidate.FIELD_MiddleName))).listEntry (HELPER_LastName.getForSQL(dummyLastName, candidatePSet.getAttrib (Candidate.FIELD_LastName))).listEntry (HELPER_PreferredName.getForSQL(dummyPreferredName, candidatePSet.getAttrib (Candidate.FIELD_PreferredName))).listEntry (HELPER_Salutation.getForSQL(dummySalutation, candidatePSet.getAttrib (Candidate.FIELD_Salutation))).listEntry (HELPER_Position.getForSQL(dummyPosition, candidatePSet.getAttrib (Candidate.FIELD_Position))).listEntry (HELPER_DateOfBirth.getForSQL(dummyDateOfBirth, candidatePSet.getAttrib (Candidate.FIELD_DateOfBirth))).listEntry (HELPER_DateRegistered.getForSQL(dummyDateRegistered, candidatePSet.getAttrib (Candidate.FIELD_DateRegistered))).listEntry (HELPER_Gender.getForSQL(dummyGender, candidatePSet.getAttrib (Candidate.FIELD_Gender))).listEntry (HELPER_Password.getForSQL(dummyPassword, candidatePSet.getAttrib (Candidate.FIELD_Password))).listEntry (HELPER_DateTaken.getForSQL(dummyDateTaken, candidatePSet.getAttrib (Candidate.FIELD_DateTaken))).listEntry (HELPER_Location.getForSQL(dummyLocation, candidatePSet.getAttrib (Candidate.FIELD_Location))).listEntry (HELPER_Phone.getForSQL(dummyPhone, candidatePSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_Email.getForSQL(dummyEmail, candidatePSet.getAttrib (Candidate.FIELD_Email))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_FirstName.getForSQL(dummyFirstName, candidatePSet.getAttrib (Candidate.FIELD_FirstName))).listEntry (HELPER_MiddleName.getForSQL(dummyMiddleName, candidatePSet.getAttrib (Candidate.FIELD_MiddleName))).listEntry (HELPER_LastName.getForSQL(dummyLastName, candidatePSet.getAttrib (Candidate.FIELD_LastName))).listEntry (HELPER_PreferredName.getForSQL(dummyPreferredName, candidatePSet.getAttrib (Candidate.FIELD_PreferredName))).listEntry (HELPER_Salutation.getForSQL(dummySalutation, candidatePSet.getAttrib (Candidate.FIELD_Salutation))).listEntry (HELPER_Position.getForSQL(dummyPosition, candidatePSet.getAttrib (Candidate.FIELD_Position))).listEntry (HELPER_DateOfBirth.getForSQL(dummyDateOfBirth, candidatePSet.getAttrib (Candidate.FIELD_DateOfBirth))).listEntry (HELPER_DateRegistered.getForSQL(dummyDateRegistered, candidatePSet.getAttrib (Candidate.FIELD_DateRegistered))).listEntry (HELPER_Gender.getForSQL(dummyGender, candidatePSet.getAttrib (Candidate.FIELD_Gender))).listEntry (HELPER_Password.getForSQL(dummyPassword, candidatePSet.getAttrib (Candidate.FIELD_Password))).listEntry (HELPER_DateTaken.getForSQL(dummyDateTaken, candidatePSet.getAttrib (Candidate.FIELD_DateTaken))).listEntry (HELPER_Location.getForSQL(dummyLocation, candidatePSet.getAttrib (Candidate.FIELD_Location))).listEntry (HELPER_Phone.getForSQL(dummyPhone, candidatePSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_Email.getForSQL(dummyEmail, candidatePSet.getAttrib (Candidate.FIELD_Email))) .listEntry (SQLManager.CheckNull((Long)(candidatePSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))) .listEntry (objectID.longID ()).toList().toArray());
candidatePSet.setStatus (PersistentSetStatus.PROCESSED); candidatePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -5,8 +5,12 @@ ...@@ -5,8 +5,12 @@
<IMPORT value="oneit.servlets.orm.*"/> <IMPORT value="oneit.servlets.orm.*"/>
<MULTIPLEREFERENCE name="Candidates" type="Candidate" backreferenceName="TestInput" owner="true"/>
<TABLE name="it_does_not_matter" tablePrefix="OBJECT" polymorphic="FALSE"> <TABLE name="it_does_not_matter" tablePrefix="OBJECT" polymorphic="FALSE">
<ATTRIB name="CSV" type="BinaryContent" dbcol="xxxx" binaryHandler="loggedin" mandatory="true" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" /> <ATTRIB name="CSV" type="BinaryContent" dbcol="xxxx" binaryHandler="loggedin" mandatory="true" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" />
</TABLE> </TABLE>
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request); ORMProcessState process = (ORMProcessState) ProcessDecorator.getDefaultProcess(request);
ObjectTransaction objTran = process.getTransaction (); ObjectTransaction objTran = process.getTransaction ();
String module = "TestAnalysis"; String module = "TestAnalysis";
TestAnalysis testAnalysis = (TestAnalysis) process.getAttribute(module); TestInput testInput = (TestInput) process.getAttribute(module);
if(testAnalysis == null) if(testInput == null)
{ {
testAnalysis = TestAnalysis.createTestAnalysis(objTran); testInput = TestInput.createTestInput(objTran);
process.setAttribute(module, testAnalysis); process.setAttribute(module, testInput);
%><%@include file="/saferedirect.jsp"%><% %><%@include file="/saferedirect.jsp"%><%
} }
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<strong style="line-height: 30px">CSV : </strong> <strong style="line-height: 30px">CSV : </strong>
</oneit:layout_label> </oneit:layout_label>
<oneit:layout_field width="1"> <oneit:layout_field width="1">
<oneit:ormInput obj="<%= testAnalysis %>" attributeName="<%= TestAnalysis.FIELD_CSV %>" type="file" class="form-control" required="required" style="padding:4px;" accept=".csv"/> <oneit:ormInput obj="<%= testInput %>" attributeName="CSV" type="file" class="form-control" required="required" style="padding:4px;" accept=".csv"/>
</oneit:layout_field> </oneit:layout_field>
<oneit:layout_field width="1"> <oneit:layout_field width="1">
<oneit:button value="Import CSV" name="importCSV" cssClass="btn btn-primary" requestAttribs='<%= CollectionUtils.EMPTY_MAP %>'/> <oneit:button value="Import CSV" name="importCSV" cssClass="btn btn-primary" requestAttribs='<%= CollectionUtils.EMPTY_MAP %>'/>
......
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