Ejemplo n.º 1
0
 /** @see org.telscenter.sail.webapp.service.offering.RunService#endRun(Run) */
 @Transactional()
 public void endRun(Run run) {
   if (run.getEndtime() == null) {
     run.setEndtime(Calendar.getInstance().getTime());
     this.runDao.save(run);
   }
 }
Ejemplo n.º 2
0
 /** @see org.telscenter.sail.webapp.service.offering.RunService#startRun(Run) */
 @Transactional()
 public void startRun(Run run) {
   if (run.getEndtime() != null) {
     run.setEndtime(null);
     Calendar reminderCal = Calendar.getInstance();
     reminderCal.add(Calendar.DATE, 30);
     run.setArchiveReminderTime(reminderCal.getTime());
     this.runDao.save(run);
   }
 }
Ejemplo n.º 3
0
  /**
   * Creates a run based on input parameters provided.
   *
   * @param runParameters
   * @return The run created.
   * @throws CurnitNotFoundException
   */
  @Transactional(rollbackFor = {HttpStatusCodeException.class})
  public Run createRun(RunParameters runParameters) throws ObjectNotFoundException {
    Project project = runParameters.getProject();
    // Project projectCopy = projectService.copyProject(project);
    Run run = new RunImpl();
    run.setEndtime(null);
    run.setStarttime(Calendar.getInstance().getTime());
    run.setRuncode(generateUniqueRunCode());
    run.setOwners(runParameters.getOwners());
    run.setMaxWorkgroupSize(runParameters.getMaxWorkgroupSize());
    run.setProject(project);

    // use the project name for the run name
    run.setName("" + runParameters.getProject().getName());

    Calendar reminderCal = Calendar.getInstance();
    reminderCal.add(Calendar.DATE, 30);
    run.setArchiveReminderTime(reminderCal.getTime());
    if (!(run.getProject() instanceof ExternalProject)) {
      if (run.getProject().getProjectType() != ProjectType.ROLOO
          && run.getProject().getProjectType() != ProjectType.LD) {
        run.setSdsOffering(generateSdsOfferingFromParameters(runParameters));
      }
    }
    Set<String> periodNames = runParameters.getPeriodNames();
    if (periodNames != null) {
      Set<Group> periods = new TreeSet<Group>();
      for (String periodName : runParameters.getPeriodNames()) {
        Group group = new PersistentGroup();
        group.setName(periodName);
        this.groupDao.save(group);
        periods.add(group);
      }
      run.setPeriods(periods);
    }
    run.setPostLevel(runParameters.getPostLevel());

    /* if this is an LD project take snapshot of project for run and set versionId
    if(run.getProject().getProjectType()==ProjectType.LD){
    	String requester = run.getOwners().iterator().next().getUserDetails().getUsername();
    	String versionId = this.projectService.takeSnapshot(run.getProject(), requester, "For Run " + run.getName());
    	if(versionId==null || versionId.equals("failed")){
    		throw new ObjectNotFoundException("Snapshot of project failed when creating the run.", RunImpl.class);
    	} else{
    		run.setVersionId(versionId);
    	}
    }
    */

    this.runDao.save(run);
    this.aclService.addPermission(run, BasePermission.ADMINISTRATION);
    return run;
  }