this.projectDao = projectDao;
}
public void updateProjectStatus(String projectId, String scorer, ScienceProjectStatusType spst) {
ScienceProject sp = projectDao.findById(projectId);
if(!ScienceProjectStatusType.Key.SCORINGINPROGRESS_KEY.equals(sp.getScienceProjectStatusType().getKey())) {
sp.setScienceProjectStatusType(spst);
sp.setStatusChangedBy(Integer.valueOf(scorer));
projectDao.saveScienceProject(sp);
}
else{
Calendar cal = Calendar.getInstance();
long timeDiff = cal.getTime().getTime() - sp.getStatusChangedOn().getTime() -300000;
if(!scorer.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(scorer));
}
else{
BusinessRuleException bre = new BusinessRuleException();
bre.addCodedMessage("scienceProject.error.scoringInProgress",new String[]{sp.getName()});
throw bre;
}
}
}
}