Double.valueOf(spvo.getProjectScore16())+
Double.valueOf(spvo.getProjectScore17())+
Double.valueOf(spvo.getProjectScore18())+
Double.valueOf(spvo.getProjectScore19());
ScienceProject sp = projectDao.findById(spvo.getProjectId());
if(ScienceProjectStatusType.Key.SCORINGINPROGRESS_KEY.equals(sp.getScienceProjectStatusType().getKey())) {
Calendar cal = Calendar.getInstance();
long timeDiff = cal.getTime().getTime() - sp.getStatusChangedOn().getTime() -300000;
if(!spvo.getScorer().equalsIgnoreCase(sp.getStatusChangedBy().toString())){
if(timeDiff>0){
// 5 minutes over for the scorer who set the scoring in progress, now this user can set it to in progress
sp.setScienceProjectStatusType(ScienceProjectStatusType.forKey(ScienceProjectStatusType.Key.SCORINGINPROGRESS_KEY));
sp.setStatusChangedBy(Integer.valueOf(spvo.getScorer()));
}
else{
BusinessRuleException bre = new BusinessRuleException();
bre.addCodedMessage("scienceProject.error.scoringInProgress",new String[]{sp.getName()});
throw bre;
}
}
}
if(sp.getScore()!= null){
sp.getScore().setScore(scoreValue);
}
else{
Score score = new Score();
score.setScore(scoreValue);
projectDao.saveProjectScore(score);
sp.setScore(score);
}
AwardType awtp = TypeUtil.forKey(AwardType.class, spvo.getAwardType());
Award aw = new Award();
aw.setAwardType(awtp);
projectDao.saveAward(aw);
Set<Award> awards = sp.getAwards();
TreeSet<Award> noDups = new TreeSet<Award>(new Comparator<Award>() {
public int compare(Award o1, Award o2) {
return o1.getAwardType().getKey().compareTo(o2.getAwardType().getKey());
}
});
noDups.addAll(awards);
noDups.add(aw);
sp.setAwards(noDups);
ScienceProjectStatusType spstScored = ScienceProjectStatusType.forKey(ScienceProjectStatusType.Key.SCORED_KEY);
sp.setScienceProjectStatusType(spstScored);
sp.setStatusChangedBy(Integer.valueOf(spvo.getScorer()));
projectDao.saveScienceProject(sp);
}