Пример #1
0
  private BenefitResult getBenefitAnalysisResult() {

    Long experimentid = getLong("experiment.id");
    EntityQuery query = new EntityQuery(BenefitResult.class, "result");
    query.add(new Condition("result.experiment.id=:experimentId", experimentid));
    // query.add(new Condition("result.student.code=:stdCode", getLoginName()));
    Student std = getLoginStudent();
    addStdCondition(query, "result", std);
    List results = entityService.search(query);

    BenefitResult result = null;
    if (results.isEmpty()) {
      result = new BenefitResult();
      result.setExperiment((Experiment) entityService.load(Experiment.class, experimentid));
      //			List studentList = (List)entityService.load(Student.class,"code",getLoginName());
      //			if (null != studentList && studentList.size()!=0){
      //				result.setStudent((Student)studentList.get(0));
      //			}
      if (std == null) {
        std = (Student) entityService.load(Student.class, getLong("std.id"));
      }
      result.setStudent(std);
    } else {
      result = (BenefitResult) results.get(0);
    }
    return result;
  }
Пример #2
0
 protected String saveAndForward(Entity entity) {
   BenefitItemResult itemResult = (BenefitItemResult) entity;
   if (itemResult.isVO()) {
     Long experimentid = getLong("experiment.id");
     EntityQuery query = new EntityQuery(BenefitResult.class, "result");
     query.add(new Condition("result.experiment.id=:experimentId", experimentid));
     query.add(new Condition("result.student.code=:stdCode", getLoginName()));
     List results = entityService.search(query);
     BenefitResult result = null;
     if (results.isEmpty()) {
       result = new BenefitResult();
       result.setExperiment((Experiment) entityService.load(Experiment.class, experimentid));
       List studentList = (List) entityService.load(Student.class, "code", getLoginName());
       if (null != studentList && studentList.size() != 0) {
         result.setStudent((Student) studentList.get(0));
       }
       // result.setForm(new Aim());
     } else {
       result = (BenefitResult) results.get(0);
     }
     itemResult.setResult(result);
     // result.getForm().getItmes().add(itemResult);
     result.getItems().add(itemResult);
     entityService.saveOrUpdate(result);
   } else {
     entityService.saveOrUpdate(itemResult);
   }
   return redirect("search", "info.save.success");
 }