Commit 028f1b0d by Nilu

Input analysis completed

parent 595c3bd1
...@@ -11,8 +11,13 @@ import oneit.servlets.jsp.TableTag; ...@@ -11,8 +11,13 @@ 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.table.*; import oneit.utils.table.*;
import performa.orm.Answer;
import performa.orm.Candidate;
import performa.orm.Question;
import performa.orm.TestInput; import performa.orm.TestInput;
import performa.utils.AnalysisEngine;
/** /**
* *
...@@ -28,10 +33,11 @@ public class TestAnalysisFP extends ORMProcessFormProcessor ...@@ -28,10 +33,11 @@ public class TestAnalysisFP extends ORMProcessFormProcessor
TestInput testInput = (TestInput) process.getAttribute("TestAnalysis"); TestInput testInput = (TestInput) process.getAttribute("TestAnalysis");
ByteArrayOutputStream bos = new ByteArrayOutputStream (); ByteArrayOutputStream bos = new ByteArrayOutputStream ();
byte[] bytes; byte[] bytes;
//TO-DO -> "filecontent" processing
try try
{ {
loadData(testInput, process.getTransaction());
ExcelExporter.ExportAppender excelRenderer = getExportAppender(testInput.getCSV()); ExcelExporter.ExportAppender excelRenderer = getExportAppender(testInput.getCSV());
excelRenderer.export(bos); excelRenderer.export(bos);
bytes = bos.toByteArray(); bytes = bos.toByteArray();
...@@ -73,19 +79,103 @@ public class TestAnalysisFP extends ORMProcessFormProcessor ...@@ -73,19 +79,103 @@ public class TestAnalysisFP extends ORMProcessFormProcessor
return model; return model;
} }
public void loadData(TestInput testInput, ObjectTransaction objTran)
{
BufferedReader bReader = null;
String line = "";
String csvSeparator = ",";
boolean first = true;
List<Candidate> candidates = new ArrayList<>();
List<Answer> answers = new ArrayList<>();
try
{
bReader = new BufferedReader(new InputStreamReader(testInput.getCSV().getInputStream()));
while ((line = bReader.readLine()) != null)
{
String[] values = line.trim().split(csvSeparator);
if(first)
{
for (int i = 1; i < values.length ; i++)
{
Candidate candidate = Candidate.createCandidate(objTran);
candidate.setFirstName(values[i]);
candidate.setTestInput(testInput);
candidates.add(candidate);
}
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);
answer.setAnswerNo(Integer.parseInt(values[i]));
answer.setCandidate(candidates.get(i -1));
answer.setQuestion(question);
answers.add(answer);
}
}
}
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)
{
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);
throw new NestedException(ex);
}
finally
{
try
{
if (bReader != null)
{
bReader.close();
}
}
catch (IOException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING2, "UploadCSVFP loadData : IOException :" + ex);
throw new NestedException(ex);
}
}
}
@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
{ {
super.validate(process, submission, exceptions, params); super.validate(process, submission, exceptions, params);
TestInput testAnalysis = (TestInput) process.getAttribute("TestAnalysis"); TestInput testInput = (TestInput) process.getAttribute("TestAnalysis");
Debug.assertion(testAnalysis != null, "Test Analysis is null while Processing CSV File."); Debug.assertion(testInput != null, "Test Input is null while Processing CSV File.");
if(testAnalysis.getCSV() != null) if(testInput.getCSV() != null)
{ {
BusinessObjectParser.assertFieldCondition(SUPPORTED_TYPES.contains(testAnalysis.getCSV().getContentType()), testAnalysis, TestInput.FIELD_CSV, "invalid", exceptions, true, submission.getRequest()); BusinessObjectParser.assertFieldCondition(SUPPORTED_TYPES.contains(testInput.getCSV().getContentType()), testInput, TestInput.FIELD_CSV, "invalid", exceptions, true, submission.getRequest());
} }
} }
} }
...@@ -41,6 +41,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -41,6 +41,7 @@ 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 SINGLEREFERENCE_Level = "Level";
public static final String MULTIPLEREFERENCE_Candidates = "Candidates"; public static final String MULTIPLEREFERENCE_Candidates = "Candidates";
public static final String BACKREF_Candidates = ""; public static final String BACKREF_Candidates = "";
...@@ -56,6 +57,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -56,6 +57,7 @@ public abstract class BaseTestInput extends NonPersistentBO
// Private attributes corresponding to single references // Private attributes corresponding to single references
private SingleAssociation<TestInput, Level> _Level;
// Private attributes corresponding to multiple references // Private attributes corresponding to multiple references
...@@ -82,6 +84,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -82,6 +84,7 @@ public abstract class BaseTestInput extends NonPersistentBO
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping")); Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_Candidates(); setupAssocMetaData_Candidates();
setupAssocMetaData_Level();
FIELD_CSV_Validators = (AttributeValidator[])setupAttribMetaData_CSV(validatorMapping).toArray (new AttributeValidator[0]); FIELD_CSV_Validators = (AttributeValidator[])setupAttribMetaData_CSV(validatorMapping).toArray (new AttributeValidator[0]);
...@@ -113,6 +116,19 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -113,6 +116,19 @@ public abstract class BaseTestInput extends NonPersistentBO
// Meta Info setup // Meta Info setup
private static void setupAssocMetaData_Level()
{
Map metaInfo = new HashMap ();
metaInfo.put ("name", "Level");
metaInfo.put ("type", "Level");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for TestInput.Level:", metaInfo);
ATTRIBUTES_METADATA_TestInput.put (SINGLEREFERENCE_Level, 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 ();
...@@ -169,6 +185,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -169,6 +185,7 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_Level = new SingleAssociation<TestInput, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "");
_Candidates = new MultipleAssociation<TestInput, Candidate> (this, MULTIPLEREFERENCE_Candidates, Candidate.SINGLEREFERENCE_TestInput, Candidate.REFERENCE_Candidate); _Candidates = new MultipleAssociation<TestInput, Candidate> (this, MULTIPLEREFERENCE_Candidates, Candidate.SINGLEREFERENCE_TestInput, Candidate.REFERENCE_Candidate);
} }
...@@ -179,6 +196,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -179,6 +196,7 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
super.initialiseReference (); super.initialiseReference ();
_Level = new SingleAssociation<TestInput, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "");
_Candidates = new MultipleAssociation<TestInput, Candidate> (this, MULTIPLEREFERENCE_Candidates, Candidate.SINGLEREFERENCE_TestInput, Candidate.REFERENCE_Candidate); _Candidates = new MultipleAssociation<TestInput, Candidate> (this, MULTIPLEREFERENCE_Candidates, Candidate.SINGLEREFERENCE_TestInput, Candidate.REFERENCE_Candidate);
...@@ -296,6 +314,8 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -296,6 +314,8 @@ public abstract class BaseTestInput extends NonPersistentBO
List result = super.getSingleAssocs (); List result = super.getSingleAssocs ();
result.add("Level");
return result; return result;
} }
...@@ -307,7 +327,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -307,7 +327,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return _Level.getReferencedType ();
}
else else
{ {
return super.getSingleAssocReferenceInstance (assocName); return super.getSingleAssocReferenceInstance (assocName);
...@@ -321,7 +344,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -321,7 +344,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return null ;
}
else else
{ {
return super.getSingleAssocBackReference (assocName); return super.getSingleAssocBackReference (assocName);
...@@ -335,7 +361,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -335,7 +361,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel ();
}
else else
{ {
return super.getSingleAssoc (assocName); return super.getSingleAssoc (assocName);
...@@ -349,7 +378,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -349,7 +378,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevel (getType);
}
else else
{ {
return super.getSingleAssoc (assocName, getType); return super.getSingleAssoc (assocName, getType);
...@@ -363,7 +395,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -363,7 +395,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Level))
{
return getLevelID ();
}
else else
{ {
return super.getSingleAssocID (assocName); return super.getSingleAssocID (assocName);
...@@ -377,7 +412,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -377,7 +412,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
throw new RuntimeException ("Game over == null!"); throw new RuntimeException ("Game over == null!");
} }
else if (assocName.equals (SINGLEREFERENCE_Level))
{
setLevel ((Level)(newValue));
}
else else
{ {
super.setSingleAssoc (assocName, newValue); super.setSingleAssoc (assocName, newValue);
...@@ -387,6 +425,100 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -387,6 +425,100 @@ public abstract class BaseTestInput extends NonPersistentBO
/** /**
* Get the reference Level
*/
public Level getLevel () throws StorageException
{
assertValid();
try
{
return (Level)(_Level.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in TestInput:", this.getObjectID (), ", was trying to get Level:", getLevelID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Level.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Level getLevel (Get getType) throws StorageException
{
assertValid();
return _Level.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getLevelID ()
{
assertValid();
if (_Level == null)
{
return null;
}
else
{
return _Level.getID ();
}
}
/**
* Called prior to the assoc changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preLevelChange (Level newLevel) throws FieldException
{
}
/**
* Called after the assoc changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postLevelChange () throws FieldException
{
}
public FieldWriteability getWriteability_Level ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference Level. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setLevel (Level newLevel) throws StorageException, FieldException
{
if (_Level.wouldReferencedChange (newLevel))
{
assertValid();
Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable");
preLevelChange (newLevel);
_Level.set (newLevel);
postLevelChange ();
}
}
/**
* 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()
...@@ -667,6 +799,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -667,6 +799,7 @@ public abstract class BaseTestInput extends NonPersistentBO
PSet.setAttrib (FIELD_ObjectID, myID); PSet.setAttrib (FIELD_ObjectID, myID);
PSet.setAttrib (FIELD_CSV, HELPER_CSV.toObject (_CSV)); // PSet.setAttrib (FIELD_CSV, HELPER_CSV.toObject (_CSV)); //
_Level.getPersistentSets (allSets);
} }
...@@ -682,6 +815,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -682,6 +815,7 @@ public abstract class BaseTestInput extends NonPersistentBO
PersistentSet PSet = allSets.getPersistentSet (objectID, ""); PersistentSet PSet = allSets.getPersistentSet (objectID, "");
_CSV = (BinaryContent)(HELPER_CSV.fromObject (_CSV, PSet.getAttrib (FIELD_CSV))); // _CSV = (BinaryContent)(HELPER_CSV.fromObject (_CSV, PSet.getAttrib (FIELD_CSV))); //
_Level.setFromPersistentSets (objectID, allSets);
} }
...@@ -738,6 +872,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -738,6 +872,7 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
BaseTestInput sourceTestInput = (BaseTestInput)(source); BaseTestInput sourceTestInput = (BaseTestInput)(source);
_Level.copyFrom (sourceTestInput._Level, linkToGhosts);
} }
} }
...@@ -776,6 +911,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -776,6 +911,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))); //
_Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
_Candidates.readExternalData(vals.get(MULTIPLEREFERENCE_Candidates)); _Candidates.readExternalData(vals.get(MULTIPLEREFERENCE_Candidates));
} }
...@@ -789,6 +925,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -789,6 +925,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 (SINGLEREFERENCE_Level, _Level.writeExternalData());
vals.put (MULTIPLEREFERENCE_Candidates, _Candidates.writeExternalData()); vals.put (MULTIPLEREFERENCE_Candidates, _Candidates.writeExternalData());
} }
...@@ -809,6 +946,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -809,6 +946,7 @@ public abstract class BaseTestInput extends NonPersistentBO
} }
// Compare single assocs // Compare single assocs
_Level.compare (otherTestInput._Level, listener);
// Compare multiple assocs // Compare multiple assocs
...@@ -831,6 +969,7 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -831,6 +969,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 (_Level);
visitor.visitAssociation (_Candidates); visitor.visitAssociation (_Candidates);
} }
...@@ -840,6 +979,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -840,6 +979,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
super.visitAssociations (visitor, scope); super.visitAssociations (visitor, scope);
if (scope.includes (_Level))
{
visitor.visit (_Level);
}
if (scope.includes (_Candidates)) if (scope.includes (_Candidates))
{ {
visitor.visit (_Candidates); visitor.visit (_Candidates);
...@@ -873,6 +1016,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -873,6 +1016,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
return filter.matches (getCSV ()); return filter.matches (getCSV ());
} }
else if (attribName.equals (SINGLEREFERENCE_Level))
{
return filter.matches (getLevel ());
}
else else
{ {
return super.testFilter (attribName, filter); return super.testFilter (attribName, filter);
...@@ -954,6 +1101,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -954,6 +1101,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
return getWriteability_Candidates (); return getWriteability_Candidates ();
} }
else if (fieldName.equals (SINGLEREFERENCE_Level))
{
return getWriteability_Level ();
}
else else
{ {
return super.getWriteable (fieldName); return super.getWriteable (fieldName);
...@@ -1132,6 +1283,10 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -1132,6 +1283,10 @@ public abstract class BaseTestInput extends NonPersistentBO
{ {
return toCSV (); return toCSV ();
} }
if (name.equals ("Level"))
{
return toLevel ();
}
return super.to(name); return super.to(name);
...@@ -1139,6 +1294,12 @@ public abstract class BaseTestInput extends NonPersistentBO ...@@ -1139,6 +1294,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 Level.LevelPipeLineFactory<From, Level> toLevel () { return toLevel (Filter.ALL); }
public Level.LevelPipeLineFactory<From, Level> toLevel (Filter<Level> filter)
{
return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_Level, filter));
}
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidates () { return toCandidates(Filter.ALL); } public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidates () { return toCandidates(Filter.ALL); }
public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidates (Filter<Candidate> filter) public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidates (Filter<Candidate> filter)
...@@ -1176,6 +1337,20 @@ class DummyTestInput extends TestInput ...@@ -1176,6 +1337,20 @@ class DummyTestInput extends TestInput
} }
public Level getLevel () throws StorageException
{
return (Level)(Level.DUMMY_Level);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getLevelID ()
{
return Level.DUMMY_Level.getObjectID();
}
public int getCandidatesCount () throws StorageException public int getCandidatesCount () throws StorageException
{ {
return 0; return 0;
......
...@@ -16,4 +16,10 @@ public class Level extends BaseLevel ...@@ -16,4 +16,10 @@ public class Level extends BaseLevel
{ {
return "Level"; return "Level";
} }
@Override
public String getToString()
{
return getLevelDescription();
}
} }
\ No newline at end of file
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
<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"/>
</TABLE> </TABLE>
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -24,7 +24,7 @@ import performa.orm.Level; ...@@ -24,7 +24,7 @@ import performa.orm.Level;
public class AnalysisEngine public class AnalysisEngine
{ {
public void analyseAnswers(Answer[] answers, Level level) public static void analyseAnswers(Answer[] answers, Level level)
{ {
ObjectTransaction objTran = level.getTransaction(); ObjectTransaction objTran = level.getTransaction();
...@@ -70,12 +70,13 @@ public class AnalysisEngine ...@@ -70,12 +70,13 @@ public class AnalysisEngine
FactorScoreResult result = FactorScoreResult.SearchByFactorScore() FactorScoreResult result = FactorScoreResult.SearchByFactorScore()
.andFactor(new EqualsFilter<>(factor)) .andFactor(new EqualsFilter<>(factor))
.andLevel(new EqualsFilter<>(level)) .andLevel(new EqualsFilter<>(level))
.andFromScore(new GreaterThanEqualFilter<>(factorScore)) .andFromScore(new LessThanEqualFilter<>(factorScore))
.andToScore(new LessThanEqualFilter<>(factorScore)) .andToScore(new GreaterThanEqualFilter<>(factorScore))
.search(objTran); .search(objTran);
int score = result.getColorCode().getWeightage();
int score = result != null ? result.getColorCode().getWeightage() : 0;
System.out.println("score :: " + score);
// TODO: calculate normalised score based on importance // TODO: calculate normalised score based on importance
} }
......
/*
* 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;
import oneit.objstore.BaseBusinessClass;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.rdbms.filters.ILikeFilter;
import oneit.servlets.jsp.ORMTextSearcher;
import performa.orm.Level;
/**
*
* @author nilu
*/
public class LevelSearcher implements ORMTextSearcher
{
@Override
public BaseBusinessClass[] search(ObjectTransaction tx, String searchTerm)
{
return Level.SearchByAll().andLevelDescription(new ILikeFilter(searchTerm, "%", "%")).search(tx);
}
}
\ No newline at end of file
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
<INHERITS factory="Named" nodename="CoreORMAdmin"/> <INHERITS factory="Named" nodename="CoreORMAdmin"/>
<FORM name="*.testAnalysis" factory="Participant" class="performa.form.TestAnalysisFP"/> <FORM name="*.testAnalysis" factory="Participant" class="performa.form.TestAnalysisFP"/>
</NODE> </NODE>
</OBJECTS> </OBJECTS>
\ No newline at end of file
...@@ -13,4 +13,8 @@ ...@@ -13,4 +13,8 @@
</NODE> </NODE>
<NODE name="StorageMappings::Performa">
<MAP code="TestInput" class="performa.orm.TestInput"/>
</NODE>
</OBJECTS> </OBJECTS>
\ No newline at end of file
...@@ -25,7 +25,14 @@ ...@@ -25,7 +25,14 @@
<%@include file="/editor/header.jsp"%> <%@include file="/editor/header.jsp"%>
<oneit:layout_total widths="<%= new double[] {1, 4, 7} %>" skin="bootstrap"> <style>
.ui-autocomplete-input
{
width: 80%;
}
</style>
<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">
<strong style="line-height: 30px">CSV : </strong> <strong style="line-height: 30px">CSV : </strong>
...@@ -33,8 +40,14 @@ ...@@ -33,8 +40,14 @@
<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">
<strong style="line-height: 30px">Level : </strong>
</oneit:layout_label>
<oneit:layout_field width="1">
<tagfile:ormsingleasso_autocomplete obj="<%= testInput %>" assocName="Level" searcher="<%= new LevelSearcher() %>"/>
</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="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>
......
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