Commit f0380bcc by Harsh Shah

Test analysis changes (Model code moved to separate method, approach changed)

parent 566bac43
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="score_number" type="Long" nullable="true"/> <column name="score_number" type="Long" nullable="true"/>
<column name="color_rank" type="Long" nullable="true"/>
<column name="wghtd_score" type="Long" nullable="true"/>
<column name="test_analysis_id" type="Long" length="11" nullable="true"/> <column name="test_analysis_id" type="Long" length="11" nullable="true"/>
<column name="factor_number" type="Long" length="11" nullable="true"/> <column name="factor_number" type="Long" length="11" nullable="true"/>
<column name="level_number" type="Long" length="11" nullable="true"/> <column name="level_number" type="Long" length="11" nullable="true"/>
......
...@@ -9,6 +9,8 @@ CREATE TABLE rs_score ( ...@@ -9,6 +9,8 @@ CREATE TABLE rs_score (
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, ,
score_number numeric(12) NULL, score_number numeric(12) NULL,
color_rank numeric(12) NULL,
wghtd_score numeric(12) NULL,
test_analysis_id numeric(12) NULL, test_analysis_id numeric(12) NULL,
factor_number numeric(12) NULL, factor_number numeric(12) NULL,
level_number numeric(12) NULL, level_number numeric(12) NULL,
......
...@@ -10,6 +10,8 @@ CREATE TABLE rs_score ( ...@@ -10,6 +10,8 @@ CREATE TABLE rs_score (
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, ,
score_number number(12) NULL, score_number number(12) NULL,
color_rank number(12) NULL,
wghtd_score number(12) NULL,
test_analysis_id number(12) NULL, test_analysis_id number(12) NULL,
factor_number number(12) NULL, factor_number number(12) NULL,
level_number number(12) NULL, level_number number(12) NULL,
......
...@@ -10,6 +10,8 @@ CREATE TABLE rs_score ( ...@@ -10,6 +10,8 @@ CREATE TABLE rs_score (
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, ,
score_number numeric(12) NULL, score_number numeric(12) NULL,
color_rank numeric(12) NULL,
wghtd_score numeric(12) NULL,
test_analysis_id numeric(12) NULL, test_analysis_id numeric(12) NULL,
factor_number numeric(12) NULL, factor_number numeric(12) NULL,
level_number numeric(12) NULL, level_number numeric(12) NULL,
......
...@@ -6,17 +6,15 @@ import javax.servlet.http.*; ...@@ -6,17 +6,15 @@ import javax.servlet.http.*;
import oneit.logging.*; import oneit.logging.*;
import oneit.objstore.*; import oneit.objstore.*;
import oneit.objstore.parser.BusinessObjectParser; import oneit.objstore.parser.BusinessObjectParser;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.servlets.forms.*; import oneit.servlets.forms.*;
import oneit.servlets.jsp.TableTag; import oneit.servlets.jsp.TableTag;
import oneit.servlets.portability.FileDownloader; import oneit.servlets.portability.FileDownloader;
import oneit.servlets.process.*; import oneit.servlets.process.*;
import oneit.utils.*; import oneit.utils.*;
import oneit.utils.parsers.FieldException; import oneit.utils.filter.Filter;
import oneit.utils.table.*; import oneit.utils.table.*;
import performa.orm.Answer; import performa.orm.*;
import performa.orm.Candidate;
import performa.orm.Question;
import performa.orm.TestInput;
import performa.utils.AnalysisEngine; import performa.utils.AnalysisEngine;
/** /**
...@@ -25,7 +23,8 @@ import performa.utils.AnalysisEngine; ...@@ -25,7 +23,8 @@ import performa.utils.AnalysisEngine;
*/ */
public class TestAnalysisFP extends ORMProcessFormProcessor public class TestAnalysisFP extends ORMProcessFormProcessor
{ {
private static final List<String> SUPPORTED_TYPES = new ArrayList<>(Arrays.asList("text/csv", "text/plain")); private static final List<String> SUPPORTED_TYPES = new ArrayList<>(Arrays.asList("text/csv", "text/plain"));
private static final int COLS_PER_CANDIDATE = 3;
@Override @Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
...@@ -34,62 +33,98 @@ public class TestAnalysisFP extends ORMProcessFormProcessor ...@@ -34,62 +33,98 @@ public class TestAnalysisFP extends ORMProcessFormProcessor
ByteArrayOutputStream bos = new ByteArrayOutputStream (); ByteArrayOutputStream bos = new ByteArrayOutputStream ();
byte[] bytes; byte[] bytes;
LogMgr.log(TestInput.LOG, LogLevel.PROCESSING1, "Inside TestAnalysisFP");
loadData(testInput, process.getTransaction());
AnalysisEngine.analyseAnswers(testInput);
try try
{ {
SingleValueTableModel model = loadData(testInput, process.getTransaction()); ExcelExporter.ExportAppender excelRenderer = getExportAppender(getSingleValueTableModel(testInput));
ExcelExporter.ExportAppender excelRenderer = getExportAppender(model);
excelRenderer.export(bos); excelRenderer.export(bos);
bytes = bos.toByteArray(); bytes = bos.toByteArray();
} }
catch(IOException ioe) catch(IOException ioe)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ioe, "Exception occurred while Creating Excel File."); LogMgr.log(TestInput.LOG, LogLevel.PROCESSING1, ioe, "Exception occurred while Creating Excel File.");
throw new BusinessException(ioe.getMessage()); throw new BusinessException(ioe.getMessage());
} }
LogMgr.log(TestInput.LOG, LogLevel.PROCESSING1, "TestAnalysisFP completed");
return (HttpServletRequest request, HttpServletResponse response) -> return (HttpServletRequest request, HttpServletResponse response) ->
{ {
FileDownloader.writeData(request, response, bytes, TableTag.EXCEL_MIME_TYPE, "Result.xls", false); FileDownloader.writeData(request, response, bytes, TableTag.EXCEL_MIME_TYPE, "Result.xls", false);
}; };
} }
private static ExcelExporter.ExportAppender getExportAppender(SingleValueTableModel model) throws IOException private ExcelExporter.ExportAppender getExportAppender(SingleValueTableModel model) throws IOException
{ {
Properties props = new Properties(); Properties props = new Properties();
props.load(TestAnalysisFP.class.getClassLoader().getResourceAsStream("excel-styles.properties"));
props.put("subheader.font-style", "bold"); props.put("subheader.font-style", "bold");
props.put("header.horizontal-alignment", "center"); props.put("header.horizontal-alignment", "center");
props.put("header.font-style", "bold"); props.put("header.font-style", "bold");
props.put("header.cell-background", "black");
ExcelExporter.ExportAppender exportAppender = new ExcelExporter(props).getAppender(); ExcelExporter.ExportAppender exportAppender = new ExcelExporter(props).getAppender();
exportAppender.appendTable("New Sheet", 0, model); exportAppender.appendTable("Analysis Sheet", 0, model);
return exportAppender; return exportAppender;
} }
private static SingleValueTableModel getExcelContent(BinaryContent file) private SingleValueTableModel getSingleValueTableModel(TestInput testInput)
{ {
SingleValueTableModel model = new SingleValueTableModel(); // TO-DO Converting To Excel SingleValueTableModel model = new SingleValueTableModel();
model.addCell(0, 0, new SingleValueTableModel.CellModel(file.getName(), ""));
int rowNumber = 0;
int colNumber = 1;
for (Candidate candidate : testInput.getCandidatesSet())
{
model.addCell(rowNumber, colNumber, new SingleValueTableModel.CellModel(1, COLS_PER_CANDIDATE, candidate.getFirstName(), "header"));
colNumber += COLS_PER_CANDIDATE;
}
for(Factor factor : testInput.getRelatedFactors())
{
Filter<FactorScore> scoreFilter = FactorScore.SearchByAll().andFactor(new EqualsFilter(factor));
colNumber = 0;
rowNumber++;
model.addCell(rowNumber, colNumber++, new SingleValueTableModel.CellModel(factor.getDescription(), "subheader"));
for (Candidate candidate : testInput.getCandidatesSet())
{
List<FactorScore> factorScores = (List<FactorScore>)candidate.pipelineCandidate().toTestAnalysises().toFactorScores(scoreFilter).vals();
if(factorScores != null && !factorScores.isEmpty())
{
FactorScore factorScore = factorScores.get(0);
//model.addCell(rowNumber, colNumber++, new SingleValueTableModel.CellModel(factorScore.getScore(), "EscapeHTML", ""));
model.addCell(rowNumber, colNumber++, new SingleValueTableModel.CellModel(factorScore.getColorRank(), "EscapeHTML", ""));
model.addCell(rowNumber, colNumber++, new SingleValueTableModel.CellModel(factorScore.getColorCode(), "EscapeHTML", ""));
model.addCell(rowNumber, colNumber++, new SingleValueTableModel.CellModel(factorScore.getNarrative(), "EscapeHTML", ""));
}
else
{
colNumber += COLS_PER_CANDIDATE;
}
}
}
return model; return model;
} }
public void loadData(TestInput testInput, ObjectTransaction objTran) throws BusinessException
public SingleValueTableModel loadData(TestInput testInput, ObjectTransaction objTran)
{ {
SingleValueTableModel model = null;
BufferedReader bReader = null; BufferedReader bReader = null;
String line = ""; String line = "";
String csvSeparator = ","; String csvSeparator = ",";
boolean first = true; boolean first = true;
List<Candidate> candidates = new ArrayList<>();
List<Answer> answers = new ArrayList<>();
try try
{ {
...@@ -97,55 +132,46 @@ public class TestAnalysisFP extends ORMProcessFormProcessor ...@@ -97,55 +132,46 @@ public class TestAnalysisFP extends ORMProcessFormProcessor
while ((line = bReader.readLine()) != null) while ((line = bReader.readLine()) != null)
{ {
String[] values = line.trim().split(csvSeparator); String[] values = line.trim().split(csvSeparator);
if(first) if(values != null && values.length > 0)
{ {
for (int i = 1; i < values.length ; i++) if(first)
{ {
Candidate candidate = Candidate.createCandidate(objTran); for (int i = 1; i < values.length ; i++)
{
candidate.setFirstName(values[i]); Candidate candidate = Candidate.createCandidate(objTran);
candidate.setTestInput(testInput);
candidates.add(candidate); candidate.setFirstName(values[i]);
testInput.addToCandidates(candidate);
}
first = false;
} }
else
first = false;
}
else
{
Question question = Question.getQuestionByID(objTran, Long.valueOf(values[0]));
for (int i = 1; i < values.length ; i++)
{ {
Answer answer = Answer.createAnswer(objTran); Question question = Question.getQuestionByID(objTran, Long.valueOf(values[0]));
answer.setAnswerNo(Integer.parseInt(values[i])); if(question == null)
answer.setCandidate(candidates.get(i -1)); {
answer.setQuestion(question); throw new BusinessException("Question doesnot exist with ID:" + values[0]);
}
answers.add(answer); for (int i = 1; i < values.length ; i++)
{
Answer answer = Answer.createAnswer(objTran);
answer.setAnswerNo(Integer.parseInt(values[i]));
answer.setQuestion(question);
testInput.getCandidatesAt(i -1).addToAnswers(answer);
}
} }
} }
} }
model = AnalysisEngine.analyseAnswers(answers.toArray(new Answer[0]), testInput.getLevel());
}
catch (FileNotFoundException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING2, "UploadCSVFP loadData : FileNotFoundException :" + ex);
throw new NestedException(ex);
} }
catch (IOException ex) catch (IOException | NumberFormatException | StorageException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING2, "UploadCSVFP loadData : IOException :" + ex);
throw new NestedException(ex);
}
catch (FieldException ex)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING2, "UploadCSVFP loadData : FieldException :" + ex); LogMgr.log(TestInput.LOG, LogLevel.PROCESSING2, ex, "TestAnalysisFP error occured in loadData");
throw new NestedException(ex); throw new BusinessException("Error occurred when processing CSV file: " + ex.getMessage());
} }
finally finally
{ {
...@@ -158,14 +184,11 @@ public class TestAnalysisFP extends ORMProcessFormProcessor ...@@ -158,14 +184,11 @@ public class TestAnalysisFP extends ORMProcessFormProcessor
} }
catch (IOException ex) catch (IOException ex)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING2, "UploadCSVFP loadData : IOException :" + ex); LogMgr.log(TestInput.LOG, LogLevel.PROCESSING2, "TestAnalysisFP loadData finally: IOException :" + ex);
throw new NestedException(ex); throw new BusinessException("Error occurred when processing CSV file");
} }
} }
return model;
} }
@Override @Override
public void validate(ORMProcessState process, SubmissionDetails submission, MultiException exceptions, Map params) throws StorageException public void validate(ORMProcessState process, SubmissionDetails submission, MultiException exceptions, Map params) throws StorageException
......
...@@ -26,6 +26,8 @@ import oneit.utils.filter.Filter; ...@@ -26,6 +26,8 @@ import oneit.utils.filter.Filter;
import oneit.utils.transform.*; import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseFactorScore extends BaseBusinessClass public abstract class BaseFactorScore extends BaseBusinessClass
...@@ -39,6 +41,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -39,6 +41,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass
// Static constants corresponding to field names // Static constants corresponding to field names
public static final String FIELD_Score = "Score"; public static final String FIELD_Score = "Score";
public static final String FIELD_ColorRank = "ColorRank";
public static final String FIELD_WghtdScore = "WghtdScore";
public static final String FIELD_ColorCode = "ColorCode";
public static final String SINGLEREFERENCE_TestAnalysis = "TestAnalysis"; public static final String SINGLEREFERENCE_TestAnalysis = "TestAnalysis";
public static final String BACKREF_TestAnalysis = ""; public static final String BACKREF_TestAnalysis = "";
public static final String SINGLEREFERENCE_Factor = "Factor"; public static final String SINGLEREFERENCE_Factor = "Factor";
...@@ -52,10 +57,16 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -52,10 +57,16 @@ public abstract class BaseFactorScore extends BaseBusinessClass
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<FactorScore> HELPER_Score = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper<FactorScore> HELPER_Score = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<FactorScore> HELPER_ColorRank = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<FactorScore> HELPER_WghtdScore = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<FactorScore, ColorCode> HELPER_ColorCode = new EnumeratedAttributeHelper<FactorScore, ColorCode> (ColorCode.FACTORY_ColorCode);
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private Integer _Score; private Integer _Score;
private Integer _ColorRank;
private Integer _WghtdScore;
private ColorCode _ColorCode;
// Private attributes corresponding to single references // Private attributes corresponding to single references
...@@ -72,7 +83,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -72,7 +83,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass
private static final Map ATTRIBUTES_METADATA_FactorScore = new HashMap (); private static final Map ATTRIBUTES_METADATA_FactorScore = new HashMap ();
// Arrays of validators for each attribute // Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_ColorCode_Validators;
private static final AttributeValidator[] FIELD_Score_Validators; private static final AttributeValidator[] FIELD_Score_Validators;
private static final AttributeValidator[] FIELD_ColorRank_Validators;
private static final AttributeValidator[] FIELD_WghtdScore_Validators;
// Arrays of behaviour decorators // Arrays of behaviour decorators
...@@ -92,7 +106,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -92,7 +106,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass
setupAssocMetaData_Factor(); setupAssocMetaData_Factor();
setupAssocMetaData_Level(); setupAssocMetaData_Level();
setupAssocMetaData_Narrative(); setupAssocMetaData_Narrative();
FIELD_ColorCode_Validators = (AttributeValidator[])setupAttribMetaData_ColorCode(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Score_Validators = (AttributeValidator[])setupAttribMetaData_Score(validatorMapping).toArray (new AttributeValidator[0]); FIELD_Score_Validators = (AttributeValidator[])setupAttribMetaData_Score(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ColorRank_Validators = (AttributeValidator[])setupAttribMetaData_ColorRank(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_WghtdScore_Validators = (AttributeValidator[])setupAttribMetaData_WghtdScore(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_FactorScore.initialiseReference (); REFERENCE_FactorScore.initialiseReference ();
...@@ -166,6 +183,24 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -166,6 +183,24 @@ public abstract class BaseFactorScore extends BaseBusinessClass
// Meta Info setup // Meta Info setup
private static List setupAttribMetaData_ColorCode(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("name", "ColorCode");
metaInfo.put ("type", "ColorCode");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.ColorCode:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (FIELD_ColorCode, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(FactorScore.class, "ColorCode", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for FactorScore.ColorCode:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_Score(Map validatorMapping) private static List setupAttribMetaData_Score(Map validatorMapping)
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
...@@ -183,6 +218,42 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -183,6 +218,42 @@ public abstract class BaseFactorScore extends BaseBusinessClass
return validators; return validators;
} }
// Meta Info setup
private static List setupAttribMetaData_ColorRank(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "color_rank");
metaInfo.put ("name", "ColorRank");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.ColorRank:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (FIELD_ColorRank, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(FactorScore.class, "ColorRank", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for FactorScore.ColorRank:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_WghtdScore(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "wghtd_score");
metaInfo.put ("name", "WghtdScore");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScore.WghtdScore:", metaInfo);
ATTRIBUTES_METADATA_FactorScore.put (FIELD_WghtdScore, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(FactorScore.class, "WghtdScore", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for FactorScore.WghtdScore:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION // END OF STATIC METADATA DEFINITION
...@@ -211,6 +282,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -211,6 +282,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass
_Score = (Integer)(HELPER_Score.initialise (_Score)); _Score = (Integer)(HELPER_Score.initialise (_Score));
_ColorRank = (Integer)(HELPER_ColorRank.initialise (_ColorRank));
_WghtdScore = (Integer)(HELPER_WghtdScore.initialise (_WghtdScore));
_ColorCode = (ColorCode)(HELPER_ColorCode.initialise (_ColorCode));
} }
...@@ -341,6 +415,300 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -341,6 +415,300 @@ public abstract class BaseFactorScore extends BaseBusinessClass
} }
} }
/**
* Get the attribute ColorRank
*/
public Integer getColorRank ()
{
assertValid();
Integer valToReturn = _ColorRank;
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
valToReturn = bhd.getColorRank ((FactorScore)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 preColorRankChange (Integer newColorRank) 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 postColorRankChange () throws FieldException
{
}
public FieldWriteability getWriteability_ColorRank ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ColorRank. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setColorRank (Integer newColorRank) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ColorRank.compare (_ColorRank, newColorRank);
try
{
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
newColorRank = bhd.setColorRank ((FactorScore)this, newColorRank);
oldAndNewIdentical = HELPER_ColorRank.compare (_ColorRank, newColorRank);
}
if (FIELD_ColorRank_Validators.length > 0)
{
Object newColorRankObj = HELPER_ColorRank.toObject (newColorRank);
if (newColorRankObj != null)
{
int loopMax = FIELD_ColorRank_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_FactorScore.get (FIELD_ColorRank);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ColorRank_Validators[v].checkAttribute (this, FIELD_ColorRank, metadata, newColorRankObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ColorRank () != FieldWriteability.FALSE, "Field ColorRank is not writeable");
preColorRankChange (newColorRank);
markFieldChange (FIELD_ColorRank);
_ColorRank = newColorRank;
postFieldChange (FIELD_ColorRank);
postColorRankChange ();
}
}
/**
* Get the attribute WghtdScore
*/
public Integer getWghtdScore ()
{
assertValid();
Integer valToReturn = _WghtdScore;
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
valToReturn = bhd.getWghtdScore ((FactorScore)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 preWghtdScoreChange (Integer newWghtdScore) 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 postWghtdScoreChange () throws FieldException
{
}
public FieldWriteability getWriteability_WghtdScore ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute WghtdScore. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setWghtdScore (Integer newWghtdScore) throws FieldException
{
boolean oldAndNewIdentical = HELPER_WghtdScore.compare (_WghtdScore, newWghtdScore);
try
{
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
newWghtdScore = bhd.setWghtdScore ((FactorScore)this, newWghtdScore);
oldAndNewIdentical = HELPER_WghtdScore.compare (_WghtdScore, newWghtdScore);
}
if (FIELD_WghtdScore_Validators.length > 0)
{
Object newWghtdScoreObj = HELPER_WghtdScore.toObject (newWghtdScore);
if (newWghtdScoreObj != null)
{
int loopMax = FIELD_WghtdScore_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_FactorScore.get (FIELD_WghtdScore);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_WghtdScore_Validators[v].checkAttribute (this, FIELD_WghtdScore, metadata, newWghtdScoreObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_WghtdScore () != FieldWriteability.FALSE, "Field WghtdScore is not writeable");
preWghtdScoreChange (newWghtdScore);
markFieldChange (FIELD_WghtdScore);
_WghtdScore = newWghtdScore;
postFieldChange (FIELD_WghtdScore);
postWghtdScoreChange ();
}
}
/**
* Get the attribute ColorCode
*/
public ColorCode getColorCode ()
{
assertValid();
ColorCode valToReturn = _ColorCode;
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
valToReturn = bhd.getColorCode ((FactorScore)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 preColorCodeChange (ColorCode newColorCode) 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 postColorCodeChange () throws FieldException
{
}
public FieldWriteability getWriteability_ColorCode ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ColorCode. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setColorCode (ColorCode newColorCode) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ColorCode.compare (_ColorCode, newColorCode);
try
{
for (FactorScoreBehaviourDecorator bhd : FactorScore_BehaviourDecorators)
{
newColorCode = bhd.setColorCode ((FactorScore)this, newColorCode);
oldAndNewIdentical = HELPER_ColorCode.compare (_ColorCode, newColorCode);
}
if (FIELD_ColorCode_Validators.length > 0)
{
Object newColorCodeObj = HELPER_ColorCode.toObject (newColorCode);
if (newColorCodeObj != null)
{
int loopMax = FIELD_ColorCode_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_FactorScore.get (FIELD_ColorCode);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ColorCode_Validators[v].checkAttribute (this, FIELD_ColorCode, metadata, newColorCodeObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ColorCode () != FieldWriteability.FALSE, "Field ColorCode is not writeable");
preColorCodeChange (newColorCode);
markFieldChange (FIELD_ColorCode);
_ColorCode = newColorCode;
postFieldChange (FIELD_ColorCode);
postColorCodeChange ();
}
}
/** /**
...@@ -1110,6 +1478,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1110,6 +1478,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
rs_scorePSet.setAttrib (FIELD_ObjectID, myID); rs_scorePSet.setAttrib (FIELD_ObjectID, myID);
rs_scorePSet.setAttrib (FIELD_Score, HELPER_Score.toObject (_Score)); // rs_scorePSet.setAttrib (FIELD_Score, HELPER_Score.toObject (_Score)); //
rs_scorePSet.setAttrib (FIELD_ColorRank, HELPER_ColorRank.toObject (_ColorRank)); //
rs_scorePSet.setAttrib (FIELD_WghtdScore, HELPER_WghtdScore.toObject (_WghtdScore)); //
_TestAnalysis.getPersistentSets (allSets); _TestAnalysis.getPersistentSets (allSets);
_Factor.getPersistentSets (allSets); _Factor.getPersistentSets (allSets);
_Level.getPersistentSets (allSets); _Level.getPersistentSets (allSets);
...@@ -1129,6 +1499,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1129,6 +1499,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
PersistentSet rs_scorePSet = allSets.getPersistentSet (objectID, "rs_score"); PersistentSet rs_scorePSet = allSets.getPersistentSet (objectID, "rs_score");
_Score = (Integer)(HELPER_Score.fromObject (_Score, rs_scorePSet.getAttrib (FIELD_Score))); // _Score = (Integer)(HELPER_Score.fromObject (_Score, rs_scorePSet.getAttrib (FIELD_Score))); //
_ColorRank = (Integer)(HELPER_ColorRank.fromObject (_ColorRank, rs_scorePSet.getAttrib (FIELD_ColorRank))); //
_WghtdScore = (Integer)(HELPER_WghtdScore.fromObject (_WghtdScore, rs_scorePSet.getAttrib (FIELD_WghtdScore))); //
_TestAnalysis.setFromPersistentSets (objectID, allSets); _TestAnalysis.setFromPersistentSets (objectID, allSets);
_Factor.setFromPersistentSets (objectID, allSets); _Factor.setFromPersistentSets (objectID, allSets);
_Level.setFromPersistentSets (objectID, allSets); _Level.setFromPersistentSets (objectID, allSets);
...@@ -1157,6 +1529,24 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1157,6 +1529,24 @@ public abstract class BaseFactorScore extends BaseBusinessClass
e.addException (ex); e.addException (ex);
} }
try
{
setColorRank (otherFactorScore.getColorRank ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setWghtdScore (otherFactorScore.getWghtdScore ());
}
catch (FieldException ex)
{
e.addException (ex);
}
} }
} }
...@@ -1173,6 +1563,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1173,6 +1563,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass
BaseFactorScore sourceFactorScore = (BaseFactorScore)(source); BaseFactorScore sourceFactorScore = (BaseFactorScore)(source);
_Score = sourceFactorScore._Score; _Score = sourceFactorScore._Score;
_ColorRank = sourceFactorScore._ColorRank;
_WghtdScore = sourceFactorScore._WghtdScore;
_ColorCode = sourceFactorScore._ColorCode;
} }
} }
...@@ -1230,6 +1623,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1230,6 +1623,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass
super.readExternalData(vals); super.readExternalData(vals);
_Score = (Integer)(HELPER_Score.readExternal (_Score, vals.get(FIELD_Score))); // _Score = (Integer)(HELPER_Score.readExternal (_Score, vals.get(FIELD_Score))); //
_ColorRank = (Integer)(HELPER_ColorRank.readExternal (_ColorRank, vals.get(FIELD_ColorRank))); //
_WghtdScore = (Integer)(HELPER_WghtdScore.readExternal (_WghtdScore, vals.get(FIELD_WghtdScore))); //
_ColorCode = (ColorCode)(HELPER_ColorCode.readExternal (_ColorCode, vals.get(FIELD_ColorCode))); //
_TestAnalysis.readExternalData(vals.get(SINGLEREFERENCE_TestAnalysis)); _TestAnalysis.readExternalData(vals.get(SINGLEREFERENCE_TestAnalysis));
_Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor)); _Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor));
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level)); _Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
...@@ -1246,6 +1642,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1246,6 +1642,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass
super.writeExternalData(vals); super.writeExternalData(vals);
vals.put (FIELD_Score, HELPER_Score.writeExternal (_Score)); vals.put (FIELD_Score, HELPER_Score.writeExternal (_Score));
vals.put (FIELD_ColorRank, HELPER_ColorRank.writeExternal (_ColorRank));
vals.put (FIELD_WghtdScore, HELPER_WghtdScore.writeExternal (_WghtdScore));
vals.put (FIELD_ColorCode, HELPER_ColorCode.writeExternal (_ColorCode));
vals.put (SINGLEREFERENCE_TestAnalysis, _TestAnalysis.writeExternalData()); vals.put (SINGLEREFERENCE_TestAnalysis, _TestAnalysis.writeExternalData());
vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData()); vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData());
vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData()); vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
...@@ -1267,6 +1666,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1267,6 +1666,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
listener.notifyFieldChange(this, other, FIELD_Score, HELPER_Score.toObject(this._Score), HELPER_Score.toObject(otherFactorScore._Score)); listener.notifyFieldChange(this, other, FIELD_Score, HELPER_Score.toObject(this._Score), HELPER_Score.toObject(otherFactorScore._Score));
} }
if (!HELPER_ColorRank.compare(this._ColorRank, otherFactorScore._ColorRank))
{
listener.notifyFieldChange(this, other, FIELD_ColorRank, HELPER_ColorRank.toObject(this._ColorRank), HELPER_ColorRank.toObject(otherFactorScore._ColorRank));
}
if (!HELPER_WghtdScore.compare(this._WghtdScore, otherFactorScore._WghtdScore))
{
listener.notifyFieldChange(this, other, FIELD_WghtdScore, HELPER_WghtdScore.toObject(this._WghtdScore), HELPER_WghtdScore.toObject(otherFactorScore._WghtdScore));
}
// Compare single assocs // Compare single assocs
_TestAnalysis.compare (otherFactorScore._TestAnalysis, listener); _TestAnalysis.compare (otherFactorScore._TestAnalysis, listener);
...@@ -1285,6 +1692,7 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1285,6 +1692,7 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
super.visitAttributes (visitor); super.visitAttributes (visitor);
visitor.visitField(this, FIELD_ColorCode, HELPER_ColorCode.toObject(getColorCode()));
} }
...@@ -1294,6 +1702,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1294,6 +1702,8 @@ public abstract class BaseFactorScore extends BaseBusinessClass
super.visitAttributes (visitor); super.visitAttributes (visitor);
visitor.visitField(this, FIELD_Score, HELPER_Score.toObject(getScore())); visitor.visitField(this, FIELD_Score, HELPER_Score.toObject(getScore()));
visitor.visitField(this, FIELD_ColorRank, HELPER_ColorRank.toObject(getColorRank()));
visitor.visitField(this, FIELD_WghtdScore, HELPER_WghtdScore.toObject(getWghtdScore()));
visitor.visitAssociation (_TestAnalysis); visitor.visitAssociation (_TestAnalysis);
visitor.visitAssociation (_Factor); visitor.visitAssociation (_Factor);
visitor.visitAssociation (_Level); visitor.visitAssociation (_Level);
...@@ -1351,6 +1761,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1351,6 +1761,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return filter.matches (getScore ()); return filter.matches (getScore ());
} }
else if (attribName.equals (FIELD_ColorRank))
{
return filter.matches (getColorRank ());
}
else if (attribName.equals (FIELD_WghtdScore))
{
return filter.matches (getWghtdScore ());
}
else if (attribName.equals (SINGLEREFERENCE_TestAnalysis)) else if (attribName.equals (SINGLEREFERENCE_TestAnalysis))
{ {
return filter.matches (getTestAnalysis ()); return filter.matches (getTestAnalysis ());
...@@ -1404,6 +1822,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1404,6 +1822,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass
return this; return this;
} }
public SearchAll andColorRank (QueryFilter<Integer> filter)
{
filter.addFilter (context, "rs_score.color_rank", "ColorRank");
return this;
}
public SearchAll andWghtdScore (QueryFilter<Integer> filter)
{
filter.addFilter (context, "rs_score.wghtd_score", "WghtdScore");
return this;
}
public SearchAll andTestAnalysis (QueryFilter<TestAnalysis> filter) public SearchAll andTestAnalysis (QueryFilter<TestAnalysis> filter)
{ {
filter.addFilter (context, "rs_score.test_analysis_id", "TestAnalysis"); filter.addFilter (context, "rs_score.test_analysis_id", "TestAnalysis");
...@@ -1467,6 +1897,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1467,6 +1897,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return HELPER_Score.toObject (getScore ()); return HELPER_Score.toObject (getScore ());
} }
else if (attribName.equals (FIELD_ColorRank))
{
return HELPER_ColorRank.toObject (getColorRank ());
}
else if (attribName.equals (FIELD_WghtdScore))
{
return HELPER_WghtdScore.toObject (getWghtdScore ());
}
else if (attribName.equals (FIELD_ColorCode))
{
return HELPER_ColorCode.toObject (getColorCode ());
}
else else
{ {
return super.getAttribute (attribName); return super.getAttribute (attribName);
...@@ -1484,6 +1926,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1484,6 +1926,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return HELPER_Score; return HELPER_Score;
} }
else if (attribName.equals (FIELD_ColorRank))
{
return HELPER_ColorRank;
}
else if (attribName.equals (FIELD_WghtdScore))
{
return HELPER_WghtdScore;
}
else if (attribName.equals (FIELD_ColorCode))
{
return HELPER_ColorCode;
}
else else
{ {
return super.getAttributeHelper (attribName); return super.getAttributeHelper (attribName);
...@@ -1501,6 +1955,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1501,6 +1955,18 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
setScore ((Integer)(HELPER_Score.fromObject (_Score, attribValue))); setScore ((Integer)(HELPER_Score.fromObject (_Score, attribValue)));
} }
else if (attribName.equals (FIELD_ColorRank))
{
setColorRank ((Integer)(HELPER_ColorRank.fromObject (_ColorRank, attribValue)));
}
else if (attribName.equals (FIELD_WghtdScore))
{
setWghtdScore ((Integer)(HELPER_WghtdScore.fromObject (_WghtdScore, attribValue)));
}
else if (attribName.equals (FIELD_ColorCode))
{
setColorCode ((ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, attribValue)));
}
else else
{ {
super.setAttribute (attribName, attribValue); super.setAttribute (attribName, attribValue);
...@@ -1525,6 +1991,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1525,6 +1991,14 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return getWriteability_Score (); return getWriteability_Score ();
} }
else if (fieldName.equals (FIELD_ColorRank))
{
return getWriteability_ColorRank ();
}
else if (fieldName.equals (FIELD_WghtdScore))
{
return getWriteability_WghtdScore ();
}
else if (fieldName.equals (SINGLEREFERENCE_TestAnalysis)) else if (fieldName.equals (SINGLEREFERENCE_TestAnalysis))
{ {
return getWriteability_TestAnalysis (); return getWriteability_TestAnalysis ();
...@@ -1541,6 +2015,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1541,6 +2015,10 @@ public abstract class BaseFactorScore extends BaseBusinessClass
{ {
return getWriteability_Narrative (); return getWriteability_Narrative ();
} }
else if (fieldName.equals (FIELD_ColorCode))
{
return getWriteability_ColorCode ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1556,6 +2034,21 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1556,6 +2034,21 @@ public abstract class BaseFactorScore extends BaseBusinessClass
fields.add (FIELD_Score); fields.add (FIELD_Score);
} }
if (getWriteability_ColorRank () != FieldWriteability.TRUE)
{
fields.add (FIELD_ColorRank);
}
if (getWriteability_WghtdScore () != FieldWriteability.TRUE)
{
fields.add (FIELD_WghtdScore);
}
if (getWriteability_ColorCode () != FieldWriteability.TRUE)
{
fields.add (FIELD_ColorCode);
}
super.putUnwriteable (fields); super.putUnwriteable (fields);
} }
...@@ -1566,6 +2059,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1566,6 +2059,9 @@ public abstract class BaseFactorScore extends BaseBusinessClass
result.add(HELPER_Score.getAttribObject (getClass (), _Score, false, FIELD_Score)); result.add(HELPER_Score.getAttribObject (getClass (), _Score, false, FIELD_Score));
result.add(HELPER_ColorRank.getAttribObject (getClass (), _ColorRank, false, FIELD_ColorRank));
result.add(HELPER_WghtdScore.getAttribObject (getClass (), _WghtdScore, false, FIELD_WghtdScore));
result.add(HELPER_ColorCode.getAttribObject (getClass (), _ColorCode, false, FIELD_ColorCode));
return result; return result;
} }
...@@ -1634,6 +2130,60 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1634,6 +2130,60 @@ public abstract class BaseFactorScore extends BaseBusinessClass
return newScore; return newScore;
} }
/**
* Get the attribute ColorRank
*/
public Integer getColorRank (FactorScore obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute ColorRank.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setColorRank (FactorScore obj, Integer newColorRank) throws FieldException
{
return newColorRank;
}
/**
* Get the attribute WghtdScore
*/
public Integer getWghtdScore (FactorScore obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute WghtdScore.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setWghtdScore (FactorScore obj, Integer newWghtdScore) throws FieldException
{
return newWghtdScore;
}
/**
* Get the attribute ColorCode
*/
public ColorCode getColorCode (FactorScore obj, ColorCode original)
{
return original;
}
/**
* Change the value set for attribute ColorCode.
* May modify the field beforehand
* Occurs before validation.
*/
public ColorCode setColorCode (FactorScore obj, ColorCode newColorCode) throws FieldException
{
return newColorCode;
}
} }
...@@ -1686,10 +2236,22 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1686,10 +2236,22 @@ public abstract class BaseFactorScore extends BaseBusinessClass
public PipeLine<From, ? extends Object> to(String name) public PipeLine<From, ? extends Object> to(String name)
{ {
if (name.equals ("ColorCode"))
{
return toColorCode ();
}
if (name.equals ("Score")) if (name.equals ("Score"))
{ {
return toScore (); return toScore ();
} }
if (name.equals ("ColorRank"))
{
return toColorRank ();
}
if (name.equals ("WghtdScore"))
{
return toWghtdScore ();
}
if (name.equals ("TestAnalysis")) if (name.equals ("TestAnalysis"))
{ {
return toTestAnalysis (); return toTestAnalysis ();
...@@ -1712,7 +2274,13 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1712,7 +2274,13 @@ public abstract class BaseFactorScore extends BaseBusinessClass
} }
public PipeLine<From, ColorCode> toColorCode () { return pipe(new ORMAttributePipe<Me, ColorCode>(FIELD_ColorCode)); }
public PipeLine<From, Integer> toScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_Score)); } public PipeLine<From, Integer> toScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_Score)); }
public PipeLine<From, Integer> toColorRank () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ColorRank)); }
public PipeLine<From, Integer> toWghtdScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_WghtdScore)); }
public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysis () { return toTestAnalysis (Filter.ALL); } public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysis () { return toTestAnalysis (Filter.ALL); }
public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysis (Filter<TestAnalysis> filter) public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysis (Filter<TestAnalysis> filter)
...@@ -1743,6 +2311,11 @@ public abstract class BaseFactorScore extends BaseBusinessClass ...@@ -1743,6 +2311,11 @@ public abstract class BaseFactorScore extends BaseBusinessClass
public boolean isTransientAttrib(String attribName) public boolean isTransientAttrib(String attribName)
{ {
if(CollectionUtils.equals(attribName, "ColorCode"))
{
return true;
}
return super.isTransientAttrib(attribName); return super.isTransientAttrib(attribName);
} }
......
...@@ -52,7 +52,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -52,7 +52,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
public static final String SEARCH_FactorScore = "FactorScore";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -1637,91 +1636,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass ...@@ -1637,91 +1636,6 @@ public abstract class BaseFactorScoreResult extends BaseBusinessClass
.search (transaction); .search (transaction);
} }
public static SearchFactorScore SearchByFactorScore () { return new SearchFactorScore (); }
public static class SearchFactorScore extends SearchObject<FactorScoreResult>
{
public SearchFactorScore andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "rs_level_factor.object_id", FIELD_ObjectID);
return this;
}
public SearchFactorScore andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_level_factor.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchFactorScore andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "rs_level_factor.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchFactorScore andFromScore (QueryFilter<Integer> filter)
{
filter.addFilter (context, "rs_level_factor.from_score", "FromScore");
return this;
}
public SearchFactorScore andToScore (QueryFilter<Integer> filter)
{
filter.addFilter (context, "rs_level_factor.to_score", "ToScore");
return this;
}
public SearchFactorScore andColorCode (QueryFilter<ColorCode> filter)
{
filter.addFilter (context, "rs_level_factor.color_code", "ColorCode");
return this;
}
public SearchFactorScore andFactor (QueryFilter<Factor> filter)
{
filter.addFilter (context, "rs_level_factor.factor_number", "Factor");
return this;
}
public SearchFactorScore andLevel (QueryFilter<Level> filter)
{
filter.addFilter (context, "rs_level_factor.level_number", "Level");
return this;
}
public SearchFactorScore andNarrative (QueryFilter<Narrative> filter)
{
filter.addFilter (context, "rs_level_factor.narrative_id", "Narrative");
return this;
}
public FactorScoreResult search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_FactorScoreResult, SEARCH_FactorScore, criteria);
Set<FactorScoreResult> typedResults = new LinkedHashSet <FactorScoreResult> ();
for (BaseBusinessClass bbcResult : results)
{
FactorScoreResult aResult = (FactorScoreResult)bbcResult;
typedResults.add (aResult);
}
return (FactorScoreResult)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "FactorScoreResult", "");
}
}
public static FactorScoreResult searchFactorScore (ObjectTransaction transaction) throws StorageException
{
return SearchByFactorScore ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
......
...@@ -120,6 +120,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -120,6 +120,7 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
Map metaInfo = new HashMap (); Map metaInfo = new HashMap ();
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Level"); metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level"); metaInfo.put ("type", "Level");
...@@ -504,6 +505,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -504,6 +505,7 @@ public abstract class BaseTestInput extends NonPersistentBO
*/ */
public void setLevel (Level newLevel) throws StorageException, FieldException public void setLevel (Level newLevel) throws StorageException, FieldException
{ {
BusinessObjectParser.assertFieldCondition (newLevel != null, this, SINGLEREFERENCE_Level, "mandatory");
if (_Level.wouldReferencedChange (newLevel)) if (_Level.wouldReferencedChange (newLevel))
...@@ -900,6 +902,8 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -900,6 +902,8 @@ public abstract class BaseTestInput extends NonPersistentBO
super.validate (context); super.validate (context);
context.check (getLevelID() != null, this, SINGLEREFERENCE_Level, "mandatory");
} }
......
...@@ -3,10 +3,16 @@ ...@@ -3,10 +3,16 @@
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'> <ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="FactorScore" package="performa.orm"> <BUSINESSCLASS name="FactorScore" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TRANSIENT name="ColorCode" type="ColorCode" attribHelper="EnumeratedAttributeHelper"/>
<TABLE name="rs_score" tablePrefix="object" polymorphic="FALSE"> <TABLE name="rs_score" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Score" type="Integer" dbcol="score_number"/> <ATTRIB name="Score" type="Integer" dbcol="score_number"/>
<ATTRIB name="ColorRank" type="Integer" dbcol="color_rank" />
<ATTRIB name="WghtdScore" type="Integer" dbcol="wghtd_score" />
<SINGLEREFERENCE name="TestAnalysis" type="TestAnalysis" dbcol="test_analysis_id" backreferenceName="FactorScores"/> <SINGLEREFERENCE name="TestAnalysis" type="TestAnalysis" dbcol="test_analysis_id" backreferenceName="FactorScores"/>
<SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number"/> <SINGLEREFERENCE name="Factor" type="Factor" dbcol="factor_number"/>
......
...@@ -14,6 +14,7 @@ import oneit.sql.*; ...@@ -14,6 +14,7 @@ import oneit.sql.*;
import oneit.utils.resource.*; import oneit.utils.resource.*;
import oneit.utils.*; import oneit.utils.*;
import oneit.utils.threading.*; import oneit.utils.threading.*;
import performa.orm.types.*;
...@@ -27,10 +28,14 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -27,10 +28,14 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
// Private attributes corresponding to business object data // Private attributes corresponding to business object data
private Integer dummyScore; private Integer dummyScore;
private Integer dummyColorRank;
private Integer dummyWghtdScore;
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Score = DefaultAttributeHelper.INSTANCE; private static final DefaultAttributeHelper HELPER_Score = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ColorRank = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_WghtdScore = DefaultAttributeHelper.INSTANCE;
...@@ -38,10 +43,12 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -38,10 +43,12 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
public FactorScorePersistenceMgr () public FactorScorePersistenceMgr ()
{ {
dummyScore = (Integer)(HELPER_Score.initialise (dummyScore)); dummyScore = (Integer)(HELPER_Score.initialise (dummyScore));
dummyColorRank = (Integer)(HELPER_ColorRank.initialise (dummyColorRank));
dummyWghtdScore = (Integer)(HELPER_WghtdScore.initialise (dummyWghtdScore));
} }
private String SELECT_COLUMNS = "{PREFIX}rs_score.object_id as id, {PREFIX}rs_score.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_score.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_score.score_number, {PREFIX}rs_score.test_analysis_id, {PREFIX}rs_score.factor_number, {PREFIX}rs_score.level_number, {PREFIX}rs_score.narrative_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}rs_score.object_id as id, {PREFIX}rs_score.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}rs_score.object_CREATED_DATE as CREATED_DATE, {PREFIX}rs_score.score_number, {PREFIX}rs_score.color_rank, {PREFIX}rs_score.wghtd_score, {PREFIX}rs_score.test_analysis_id, {PREFIX}rs_score.factor_number, {PREFIX}rs_score.level_number, {PREFIX}rs_score.narrative_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -93,6 +100,8 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -93,6 +100,8 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || !rs_scorePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || if (false || !rs_scorePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!rs_scorePSet.containsAttrib(FactorScore.FIELD_Score)|| !rs_scorePSet.containsAttrib(FactorScore.FIELD_Score)||
!rs_scorePSet.containsAttrib(FactorScore.FIELD_ColorRank)||
!rs_scorePSet.containsAttrib(FactorScore.FIELD_WghtdScore)||
!rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis)|| !rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis)||
!rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Factor)|| !rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Factor)||
!rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Level)|| !rs_scorePSet.containsAttrib(FactorScore.SINGLEREFERENCE_Level)||
...@@ -186,10 +195,10 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -186,10 +195,10 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}rs_score " + "UPDATE {PREFIX}rs_score " +
"SET score_number = ?, test_analysis_id = ? , factor_number = ? , level_number = ? , narrative_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET score_number = ?, color_rank = ?, wghtd_score = ?, test_analysis_id = ? , factor_number = ? , level_number = ? , narrative_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE rs_score.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE rs_score.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, rs_scorePSet.getAttrib (FactorScore.FIELD_Score))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Narrative)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, rs_scorePSet.getAttrib (FactorScore.FIELD_Score))).listEntry (HELPER_ColorRank.getForSQL(dummyColorRank, rs_scorePSet.getAttrib (FactorScore.FIELD_ColorRank))).listEntry (HELPER_WghtdScore.getForSQL(dummyWghtdScore, rs_scorePSet.getAttrib (FactorScore.FIELD_WghtdScore))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Narrative)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
...@@ -446,6 +455,8 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -446,6 +455,8 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
rs_scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE")); rs_scorePSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
rs_scorePSet.setAttrib(FactorScore.FIELD_Score, HELPER_Score.getFromRS(dummyScore, r, "score_number")); rs_scorePSet.setAttrib(FactorScore.FIELD_Score, HELPER_Score.getFromRS(dummyScore, r, "score_number"));
rs_scorePSet.setAttrib(FactorScore.FIELD_ColorRank, HELPER_ColorRank.getFromRS(dummyColorRank, r, "color_rank"));
rs_scorePSet.setAttrib(FactorScore.FIELD_WghtdScore, HELPER_WghtdScore.getFromRS(dummyWghtdScore, r, "wghtd_score"));
rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis, r.getObject ("test_analysis_id")); rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_TestAnalysis, r.getObject ("test_analysis_id"));
rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_Factor, r.getObject ("factor_number")); rs_scorePSet.setAttrib(FactorScore.SINGLEREFERENCE_Factor, r.getObject ("factor_number"));
...@@ -467,10 +478,10 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr ...@@ -467,10 +478,10 @@ public class FactorScorePersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}rs_score " + "INSERT INTO {PREFIX}rs_score " +
" (score_number, test_analysis_id, factor_number, level_number, narrative_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " + " (score_number, color_rank, wghtd_score, test_analysis_id, factor_number, level_number, narrative_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")", " (?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, rs_scorePSet.getAttrib (FactorScore.FIELD_Score))) .listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Narrative)))) .listEntry (objectID.longID ()).toList().toArray()); CollectionUtils.listEntry (HELPER_Score.getForSQL(dummyScore, rs_scorePSet.getAttrib (FactorScore.FIELD_Score))).listEntry (HELPER_ColorRank.getForSQL(dummyColorRank, rs_scorePSet.getAttrib (FactorScore.FIELD_ColorRank))).listEntry (HELPER_WghtdScore.getForSQL(dummyWghtdScore, rs_scorePSet.getAttrib (FactorScore.FIELD_WghtdScore))) .listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_TestAnalysis)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Factor)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Level)))).listEntry (SQLManager.CheckNull((Long)(rs_scorePSet.getAttrib (FactorScore.SINGLEREFERENCE_Narrative)))) .listEntry (objectID.longID ()).toList().toArray());
rs_scorePSet.setStatus (PersistentSetStatus.PROCESSED); rs_scorePSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="rs_level_factor.object_id is not null" orderBy="rs_level_factor.object_id" /> <SEARCH type="All" paramFilter="rs_level_factor.object_id is not null" orderBy="rs_level_factor.object_id" />
<SEARCH type="FactorScore" paramFilter="rs_level_factor.object_id is not null" singleton="TRUE"/>
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -295,10 +295,6 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -295,10 +295,6 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException ("NOT implemented: executeSearchQueryAll"); throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
} }
public ResultSet executeSearchQueryFactorScore (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryFactorScore");
}
...@@ -448,44 +444,6 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr ...@@ -448,44 +444,6 @@ public class FactorScoreResultPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (FactorScoreResult.SEARCH_FactorScore))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: rs_level_factor.object_id is not null
String preFilter = "(rs_level_factor.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}rs_level_factor " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
package performa.orm; package performa.orm;
import oneit.utils.StringUtils;
public class Narrative extends BaseNarrative public class Narrative extends BaseNarrative
{ {
...@@ -16,4 +18,10 @@ public class Narrative extends BaseNarrative ...@@ -16,4 +18,10 @@ public class Narrative extends BaseNarrative
{ {
return "Narrative"; return "Narrative";
} }
@Override
public String getToString()
{
return StringUtils.subNulls(getGraphicNotes(), "");
}
} }
\ No newline at end of file
package performa.orm; package performa.orm;
import performa.orm.types.QuestionType;
public class Question extends BaseQuestion public class Question extends BaseQuestion
{ {
...@@ -16,4 +18,13 @@ public class Question extends BaseQuestion ...@@ -16,4 +18,13 @@ public class Question extends BaseQuestion
{ {
return "Question"; return "Question";
} }
public QuestionType getQuestionType()
{
if(getSection() != null)
{
return getSection().getQuestionType();
}
return null;
}
} }
\ No newline at end of file
package performa.orm; package performa.orm;
import java.util.*;
import oneit.logging.LoggingArea;
import oneit.objstore.rdbms.filters.InFilter;
import oneit.objstore.utils.ObjstoreUtils;
import oneit.utils.*;
import oneit.utils.filter.Filter;
public class TestInput extends BaseTestInput public class TestInput extends BaseTestInput
{ {
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
public static final LoggingArea LOG = LoggingArea.createLoggingArea("TestAnalysis");
// This constructor should not be called // This constructor should not be called
public TestInput () public TestInput ()
{ {
// 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 List<Factor> getRelatedFactors()
{
Set<Factor> levelFactors = pipelineTestInput().toLevel().toFactors().toFactor().uniqueVals();
Filter<FactorQuestionLink> factorFilter = FactorQuestionLink.SearchByAll().andFactor(new InFilter(levelFactors));
return ObjstoreUtils.sort(pipelineTestInput().toCandidates().toAnswers().toQuestion().toFactors(factorFilter).toFactor().uniqueVals(),
new ObjectTransform[]{Factor.pipesFactor().toDescription()},
new Comparator[]{CollectionUtils.DEFAULT_COMPARATOR});
}
} }
\ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<ATTRIB name="CSV" type="BinaryContent" mandatory="true" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" binaryHandler="loggedin"/> <ATTRIB name="CSV" type="BinaryContent" mandatory="true" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" binaryHandler="loggedin"/>
<SINGLEREFERENCE name="Level" type="Level"/> <SINGLEREFERENCE name="Level" type="Level" mandatory="true"/>
</TABLE> </TABLE>
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package performa.utils; package performa.utils;
import java.util.HashMap; import java.util.*;
import java.util.Map; import oneit.logging.*;
import oneit.objstore.ObjectTransaction; import oneit.objstore.*;
import oneit.objstore.rdbms.filters.EqualsFilter; import oneit.objstore.rdbms.filters.*;
import oneit.objstore.rdbms.filters.GreaterThanEqualFilter; import oneit.utils.filter.Filter;
import oneit.objstore.rdbms.filters.LessThanEqualFilter; import oneit.utils.parsers.FieldException;
import oneit.utils.MultiHashtable; import performa.orm.*;
import oneit.utils.table.SingleValueTableModel; import performa.orm.types.*;
import performa.orm.Answer;
import performa.orm.Candidate;
import performa.orm.Factor;
import performa.orm.FactorQuestionLink;
import performa.orm.FactorScoreResult;
import performa.orm.Level;
import performa.orm.types.QuestionType;
/** /**
* *
...@@ -27,46 +15,42 @@ import performa.orm.types.QuestionType; ...@@ -27,46 +15,42 @@ import performa.orm.types.QuestionType;
*/ */
public class AnalysisEngine public class AnalysisEngine
{ {
public static void analyseAnswers(TestInput testInput) throws StorageException, FieldException
public static SingleValueTableModel analyseAnswers(Answer[] answers, Level level)
{ {
LogMgr.log(TestInput.LOG, LogLevel.PROCESSING1, "Inside AnalysisEngine --> analyseAnswers");
SingleValueTableModel model = new SingleValueTableModel();
ObjectTransaction objTran = level.getTransaction();
MultiHashtable<Candidate, Answer> answersByCandidate = new MultiHashtable<>();
answersByCandidate.groupValues(answers, Answer.pipesAnswer().toCandidate()); ObjectTransaction objTran = testInput.getTransaction();
Set<Factor> levelFactors = testInput.pipelineTestInput().toLevel().toFactors().toFactor().uniqueVals();
Filter<FactorQuestionLink> factorFilter = FactorQuestionLink.SearchByAll().andFactor(new InFilter(levelFactors));
int index = 0; //Preloading Data
testInput.pipelineTestInput().toCandidates().toAnswers().toQuestion().toSection().uniqueVals();
testInput.pipelineTestInput().toCandidates().toAnswers().toQuestion().toFactors().toFactor().uniqueVals();
Factor.pipesFactor(levelFactors).toResults().uniqueVals();
for (Candidate candidate : answersByCandidate.keySet()) for (Candidate candidate : testInput.getCandidatesSet())
{ {
int rowNumber = 0; LogMgr.log(TestInput.LOG, LogLevel.PROCESSING1, "Processing candidate ", candidate);
int colNumber = ( index * 3 ) + 1;
Map<Factor, Integer> factorScoreMap = new HashMap<>();
model.addCell(rowNumber++, colNumber, new SingleValueTableModel.CellModel(candidate.getFirstName(), "")); Map<Factor, Integer> factorScoreMap = new HashMap();
for (Answer answer : answersByCandidate.getValuesForKey(candidate)) for (Answer answer : candidate.getAnswersSet())
{ {
FactorQuestionLink[] links = FactorQuestionLink.SearchByAll() Set<FactorQuestionLink> links = answer.pipelineAnswer().toQuestion().toFactors(factorFilter).uniqueVals();
.andQuestion(new EqualsFilter<>(answer.getQuestion()))
.search(objTran); for (FactorQuestionLink link : links)
int factorScore = 0;
for (FactorQuestionLink link: links)
{ {
Factor factor = link.getFactor(); int factorScore = 0;
Factor factor = link.getFactor();
if(factorScoreMap.containsKey(factor)) if(factorScoreMap.containsKey(factor))
{ {
factorScore += factorScoreMap.get(factor); factorScore = factorScoreMap.get(factor);
} }
if(link.getReverseScore()) if(link.isTrue(link.getReverseScore()))
{ {
if(answer.getQuestion().getSection().getQuestionType() == QuestionType.IPSATIVE) if(answer.getQuestion().getQuestionType() == QuestionType.IPSATIVE)
{ {
factorScore += (10 - answer.getAnswerNo()); factorScore += (10 - answer.getAnswerNo());
} }
...@@ -79,42 +63,42 @@ public class AnalysisEngine ...@@ -79,42 +63,42 @@ public class AnalysisEngine
{ {
factorScore += answer.getAnswerNo(); factorScore += answer.getAnswerNo();
} }
factorScoreMap.put(factor, factorScore); factorScoreMap.put(factor, factorScore);
} }
} }
TestAnalysis testAnalysis = TestAnalysis.createTestAnalysis(objTran);
for (Map.Entry<Factor, Integer> entrySet : factorScoreMap.entrySet()) testInput.getLevel().addToTestAnalysises(testAnalysis);
candidate.addToTestAnalysises(testAnalysis);
for(Factor factor : factorScoreMap.keySet())
{ {
Factor factor = entrySet.getKey(); int score = factorScoreMap.get(factor);
Integer factorScore = entrySet.getValue();
if(index == 0)
{
model.addCell(rowNumber, 0, new SingleValueTableModel.CellModel(factor.getDescription(), ""));
}
FactorScoreResult result = FactorScoreResult.SearchByFactorScore() LogMgr.log(TestInput.LOG, LogLevel.PROCESSING1, "Candidate:", candidate, " Factor:", factor, " Score:", score);
.andFactor(new EqualsFilter<>(factor))
.andLevel(new EqualsFilter<>(level)) Filter<FactorScoreResult> factorScoreFilter = FactorScoreResult.SearchByAll().andLevel(new EqualsFilter<>(testInput.getLevel()))
.andFromScore(new LessThanEqualFilter<>(factorScore)) .andFromScore(new LessThanEqualFilter<>(score))
.andToScore(new GreaterThanEqualFilter<>(factorScore)) .andToScore(new GreaterThanEqualFilter<>(score));
.search(objTran);
List<FactorScoreResult> factorScoreResults = (List<FactorScoreResult>) factor.pipelineFactor().toResults(factorScoreFilter).vals();
int score = result != null ? result.getColorCode().getWeightage() : 0;
// TODO: calculate normalised score based on importance if(factorScoreResults != null && !factorScoreResults.isEmpty())
{
FactorScoreResult factorScoreResult = factorScoreResults.get(0);
FactorScore factorScore = FactorScore.createFactorScore(objTran);
model.addCell(rowNumber, colNumber, new SingleValueTableModel.CellModel(String.valueOf(score), "")); factorScore.setFactor(factor);
model.addCell(rowNumber, colNumber + 1, new SingleValueTableModel.CellModel(result != null ? result.getColorCode().getDescription() : "", "")); factorScore.setScore(score);
model.addCell(rowNumber++, colNumber + 2, new SingleValueTableModel.CellModel(result != null ? result.getNarrative().getGraphicNotes(): "", "")); factorScore.setColorCode(factorScoreResult.getColorCode());
factorScore.setColorRank(factorScoreResult.getColorCode() != null ? factorScoreResult.getColorCode().getWeightage() : 0);
factorScore.setNarrative(factorScoreResult.getNarrative());
testAnalysis.addToFactorScores(factorScore);
}
} }
index++;
} }
LogMgr.log(TestInput.LOG, LogLevel.PROCESSING1, "AnalysisEngine --> analyseAnswers completed");
return model;
} }
} }
\ No newline at end of file
...@@ -34,20 +34,16 @@ ...@@ -34,20 +34,16 @@
<oneit:layout_total widths="<%= new double[] {1, 4, 1, 4, 2} %>" skin="bootstrap"> <oneit:layout_total widths="<%= new double[] {1, 4, 1, 4, 2} %>" skin="bootstrap">
<oneit:skin tagName="layout_row"> <oneit:skin tagName="layout_row">
<oneit:layout_label width="1"> <oneit:layout_label width="1"><oneit:ormlabel obj="<%= testInput %>" field="CSV" /></oneit:layout_label>
<strong style="line-height: 30px">CSV : </strong>
</oneit:layout_label>
<oneit:layout_field width="1"> <oneit:layout_field width="1">
<oneit:ormInput obj="<%= testInput %>" attributeName="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_label width="1"> <oneit:layout_label width="1"><oneit:ormlabel obj="<%= testInput %>" field="Level" /></oneit:layout_label>
<strong style="line-height: 30px">Level : </strong>
</oneit:layout_label>
<oneit:layout_field width="1"> <oneit:layout_field width="1">
<tagfile:ormsingleasso_autocomplete obj="<%= testInput %>" assocName="Level" searcher="<%= new LevelSearcher() %>"/> <tagfile:ormsingleasso_autocomplete obj="<%= testInput %>" assocName="Level" searcher="<%= new LevelSearcher() %>"/>
</oneit:layout_field> </oneit:layout_field>
<oneit:layout_field width="1"> <oneit:layout_field width="1">
<oneit:button value="Import CSV" name="testAnalysis" cssClass="btn btn-primary" requestAttribs='<%= CollectionUtils.EMPTY_MAP %>'/> <oneit:button value="Generate" name="testAnalysis" cssClass="btn btn-primary" requestAttribs='<%= CollectionUtils.EMPTY_MAP %>'/>
</oneit:layout_field> </oneit:layout_field>
</oneit:skin> </oneit:skin>
</oneit:layout_total> </oneit:layout_total>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">rs_score</tableName>
<column name="test_analysis_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_score" indexName="idx_rs_score_test_analysis_id" isUnique="false"><column name="test_analysis_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">rs_test_analysis</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="level_id" type="Long" length="11" nullable="true"/>
<column name="candidate_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_test_analysis" indexName="idx_rs_test_analysis_level_id" isUnique="false"><column name="level_id"/></NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="rs_test_analysis" indexName="idx_rs_test_analysis_candidate_id" isUnique="false"><column name="candidate_id"/></NODE>
</NODE></OBJECTS>
\ 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