Package uk.ac.bbsrc.tgac.miso.core.data

Examples of uk.ac.bbsrc.tgac.miso.core.data.Project


      Number newId = insert.executeAndReturnKey(params);
      study.setStudyId(newId.longValue());
      study.setName(name);
      */

      Project p = study.getProject();

      SimpleJdbcInsert pInsert = new SimpleJdbcInsert(template)
                            .withTableName("Project_Study");

      MapSqlParameterSource poParams = new MapSqlParameterSource();
      poParams.addValue("Project_projectId", p.getProjectId())
              .addValue("studies_studyId", study.getId());
      try {
        pInsert.execute(poParams);
      }
      catch(DuplicateKeyException dke) {
        //ignore
      }
    }
    else {
      try {
        if (namingScheme.validateField("name", study.getName())) {
          params.addValue("studyId", study.getId())
                .addValue("name", study.getName());
          NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
          namedTemplate.update(STUDY_UPDATE, params);
        }
        else {
          throw new IOException("Cannot save Study - invalid field:" + study.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Study - issue with naming scheme", e);
      }
      /*
      params.addValue("studyId", study.getStudyId())
              .addValue("name", study.getName());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(STUDY_UPDATE, params);
      */
    }

    if (this.cascadeType != null) {
      Project p = study.getProject();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (p!=null) projectDAO.save(p);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
        if (p != null) {
View Full Code Here


  public boolean remove(Study study) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (study.isDeletable() &&
           (namedTemplate.update(STUDY_DELETE,
                                 new MapSqlParameterSource().addValue("studyId", study.getId())) == 1)) {
      Project p = study.getProject();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (p!=null) projectDAO.save(p);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
        if (p != null) {
View Full Code Here

      //gets studies and experiments for the project that has been selected
      if (json.has("projectId") && !json.get("projectId").equals("")) {
        StringBuilder sb = new StringBuilder();
        Long projectId = json.getLong("projectId");

        Project p = requestManager.getProjectById(projectId);
        for (Study s : p.getStudies()) {
          Collection<Experiment> experiments = requestManager.listAllExperimentsByStudyId(s.getId());
          s.setExperiments(experiments);
        }
        //gets the runs for the project
        List<Run> runs = new ArrayList<Run>(requestManager.listAllRunsByProjectId(projectId));
        Collections.sort(runs);

        //creates HTML list of runs
        if (runs.size() > 0) {
          sb.append("<ul id='runList" + projectId + "'>");
          for (Run r : runs) {
            sb.append("<li>");
            sb.append("<a href='/miso/run/" + r.getId() + "'><b>" + r.getName() + "</b> : " + r.getAlias() + "</a>");
            sb.append("<input type='hidden' id='RUN_"+r.getId()+"' name='RUN_"+r.getId()+"' value='"+r.getId()+"'/>");
            sb.append("<ul>");

            //creates HTML list of partition containers for each run
            Collection<SequencerPartitionContainer<SequencerPoolPartition>> partitionContainers = requestManager.listSequencerPartitionContainersByRunId(r.getId());
            for (SequencerPartitionContainer<SequencerPoolPartition> partitionContainer : partitionContainers) {
              sb.append("<li>");
              sb.append("<b>" + partitionContainer.getIdentificationBarcode() + "</b> : " + partitionContainer.getId());
              sb.append("<ul>");

              //creates HTML list of partitions for each partition container
              Collection<SequencerPoolPartition> partitions = partitionContainer.getPartitions();
              for (SequencerPoolPartition part : partitions) {

                // Checks whether the partition was involved in the project.
                boolean partitionInvolved = false;
                if (part.getPool() != null) {
                  Collection<Experiment> exps = part.getPool().getExperiments();
                  List<String> involvedExperiments = new ArrayList<String>();
                  for (Experiment e : exps) {
                    if (e.getStudy().getProject().getProjectId().equals(p.getProjectId())) {
                      involvedExperiments.add(e.getStudy().getProject().getAlias());
                      partitionInvolved = true;
                    }
                  }
View Full Code Here

  @Override
  public Project get(long projectId) throws IOException {
    synchronized (projectmap) {
      if (!projectmap.containsKey(projectId)) {
        Project u = super.get(projectId);
        if (u != null) {
          projectmap.put(projectId, u);
        }
        return u;
      }
View Full Code Here

  @Override
  public Project lazyGet(long projectId) throws IOException {
    synchronized (lazyprojectmap) {
      if (!lazyprojectmap.containsKey(projectId)) {
        Project u = super.lazyGet(projectId);
        if (u != null) {
          lazyprojectmap.put(projectId, u);
        }
        return u;
      }
View Full Code Here

        }
      }
    }

    if (this.cascadeType != null) {
      Project p = sample.getProject();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (p!=null) {

          //set project progress to ACTIVE if in a prior waiting state (APPROVED)
          if (sample.getReceivedDate() != null && p.getProgress().equals(ProgressType.APPROVED)) {
            p.setProgress(ProgressType.ACTIVE);
          }

          projectDAO.save(p);
        }
      }
View Full Code Here

  public boolean remove(Sample sample) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (sample.isDeletable() &&
           (namedTemplate.update(SAMPLE_DELETE,
                                 new MapSqlParameterSource().addValue("sampleId", sample.getId())) == 1)) {
      Project p = sample.getProject();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (p!=null) projectDAO.save(p);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
        if (p != null) {
View Full Code Here

  public ModelAndView setupForm(@PathVariable Long studyId,
                                ModelMap model) throws IOException {
    try {
      User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName());
      Study study = requestManager.getStudyById(studyId);
      Project project;
      if (study != null) {
        if (!study.userCanRead(user)) {
          throw new SecurityException("Permission denied.");
        }
        project = study.getProject();
View Full Code Here

      else {
        study = requestManager.getStudyById(studyId);
        model.put("title", "Study "+studyId);
      }

      Project project = requestManager.getProjectById(projectId);
        model.addAttribute("project", project);
        study.setProject(project);
        if (Arrays.asList(user.getRoles()).contains("ROLE_TECH")) {
            SecurityProfile sp = new SecurityProfile(user);
            LimsUtils.inheritUsersAndGroups(study, project.getSecurityProfile());
            study.setSecurityProfile(sp);
        } else {
            study.inheritPermissions(project);
        }
View Full Code Here

      if (sampleId == AbstractSample.UNSAVED_ID) {
        sample = dataObjectFactory.getSample(user);
        model.put("title", "New Sample");

        if (projectId != null) {
          Project project = requestManager.getProjectById(projectId);
          model.addAttribute("project", project);
          sample.setProject(project);

          if (Arrays.asList(user.getRoles()).contains("ROLE_TECH")) {
            SecurityProfile sp = new SecurityProfile(user);
            LimsUtils.inheritUsersAndGroups(sample, project.getSecurityProfile());
            sample.setSecurityProfile(sp);
          }
          else {
            sample.inheritPermissions(project);
          }
        }
        else {
          model.put("accessibleProjects", populateProjects(null));
        }
      }
      else {
        sample = requestManager.getSampleById(sampleId);
        model.put("title", "Sample " + sampleId);

        if (projectId != null) {
          Project project = requestManager.getProjectById(projectId);
          model.addAttribute("project", project);
          sample.setProject(project);
          sample.inheritPermissions(project);
        }
        else {
View Full Code Here

TOP

Related Classes of uk.ac.bbsrc.tgac.miso.core.data.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.