Ejemplo n.º 1
0
  /**
   * Based on the type of the project, the sds_curnit_map generation request url is different.
   *
   * @see
   *     net.sf.sail.webapp.service.offering.impl.OfferingServiceImpl#generateSdsOfferingFromParameters(net.sf.sail.webapp.domain.impl.OfferingParameters)
   */
  @Override
  protected SdsOffering generateSdsOfferingFromParameters(OfferingParameters offeringParameters)
      throws ObjectNotFoundException {
    RunParameters runParameters = (RunParameters) offeringParameters;
    SdsOffering sdsOffering = new SdsOffering();
    sdsOffering.setName(runParameters.getName());
    Curnit curnit = runParameters.getProject().getCurnit();
    sdsOffering.setSdsCurnit(curnit.getSdsCurnit());
    Jnlp jnlp = (Jnlp) runParameters.getProject().accept(new ProjectJnlpVisitor());

    if (jnlp == null) {
      List<Jnlp> jnlpList = this.jnlpDao.getList();
      jnlp = jnlpList.get(0);
    }
    sdsOffering.setSdsJnlp(jnlp.getSdsJnlp());

    // if this is an OTrunk project or POTrunk project, set the retrieveotmlurl
    // so that it gets passed to the generatecurnitmap request and the proper
    // curnitmap can be created.
    if (curnit instanceof OtmlModuleImpl) {
      sdsOffering.setRetrieveContentUrl(((OtmlModuleImpl) curnit).getRetrieveotmlurl());
    }

    this.sdsOfferingDao.save(sdsOffering);
    return sdsOffering;
  }
Ejemplo n.º 2
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;
  }