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

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


  }

  public void buildSubmission() {
    //submittable.buildSubmission();

    Sample sample = (Sample)submittable;
    Element s = submission.createElementNS(null, "SAMPLE");

    s.setAttribute("alias", sample.getAlias());

    s.setAttribute("center_name", submissionProperties.getProperty("submission.centreName"));

    Element sampleTitle = submission.createElementNS(null, "TITLE");
    sampleTitle.setTextContent(sample.getAlias());
    s.appendChild(sampleTitle);

    Element sampleName = submission.createElementNS(null, "SAMPLE_NAME");
    Element sampleScientificName = submission.createElementNS(null, "SCIENTIFIC_NAME");
    sampleScientificName.setTextContent(sample.getScientificName());
    sampleName.appendChild(sampleScientificName);


    //2/11/2011 Antony Colles moved IF !=null statement, to help produce valid submission XML.
    Element sampleTaxonIdentifier = submission.createElementNS(null, "TAXON_ID");
    if (sample.getTaxonIdentifier() != null && !sample.getTaxonIdentifier().equals(""))
    {
      sampleTaxonIdentifier.setTextContent(sample.getTaxonIdentifier());
    }
    else
    {
      sampleTaxonIdentifier.setTextContent("000001");
    }
    sampleName.appendChild(sampleTaxonIdentifier);

    s.appendChild(sampleName);

    Element sampleDescription = submission.createElementNS(null, "DESCRIPTION");
    sampleDescription.setTextContent(sample.getDescription());
    s.appendChild(sampleDescription);

    if (submission.getElementsByTagName("SAMPLE_SET").item(0) != null) {
      submission.getElementsByTagName("SAMPLE_SET").item(0).appendChild(s);
    }
View Full Code Here


  }

  @Test
  public void testSampleNaming() throws MisoNamingException {
    //DefaultEntityNamingScheme<Sample> entityNameValidationScheme = new DefaultEntityNamingScheme(Sample.class);
    Sample s = dataObjectFactory.getSample();
    s.setId(1L);
    String name = sampleNamingScheme.generateNameFor("name", s);
    s.setName(name);
    Assert.assertTrue(sampleNamingScheme.validateField("name", s.getName()));

    s.setAlias("RD_S1_Foo.bar");
    Assert.assertTrue(sampleNamingScheme.validateField("alias", s.getAlias()));

    log.info("Sample naming scheme valid");
  }
View Full Code Here

    }
    else if (a.getJSONObject(0).getString("value").equals("Sample")) {
      for (JSONObject j : (Iterable<JSONObject>) a) {
        if (j.getString("name").equals("ids")) {
          try {
            Sample s = requestManager.getSampleById(new Long(j.getString("value")));
            if (s != null) {
              reportables.add(s);
            }
          }
          catch (IOException e) {
View Full Code Here

      }

      StringBuilder sb = new StringBuilder();
      if (e.getPool() != null) {
        for (Dilution dil : e.getPool().getDilutions()) {
          Sample s = dil.getLibrary().getSample();
          sb.append("<li><a href='/miso/sample/").append(s.getId()).append("'>").append(s.getName()).append("</a></li>");
        }

        /*
        if (e.getPlatform().getPlatformType().equals(PlatformType.ILLUMINA)) {
        }
View Full Code Here

  private List<Sample> generateSamples() {
    List<Sample> samples = new ArrayList<Sample>();
    DataObjectFactory dataObjectFactory = new TgacDataObjectFactory();

    for (int i = 1; i < 6; i++) {
      Sample s = dataObjectFactory.getSample();
      s.setId(i);
      s.setName("SAM"+i);
      s.setAlias("MI_S"+i+"_TestSample");
      s.setScientificName("F.bar");
      s.setIdentificationBarcode(s.getName() + "::" + s.getAlias());
      samples.add(s);
    }
    Collections.sort(samples);
    return samples;
  }
View Full Code Here

      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(SAMPLE_QC_UPDATE, params);
    }

    if (this.cascadeType != null) {
      Sample s = sampleQC.getSample();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (s!=null) sampleDAO.save(s);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
        if (s != null) {
View Full Code Here

  public boolean remove(SampleQC qc) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (qc.isDeletable() &&
           (namedTemplate.update(SAMPLE_QC_DELETE,
                                 new MapSqlParameterSource().addValue("qcId", qc.getId())) == 1)) {
      Sample s = qc.getSample();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (s!=null) sampleDAO.save(s);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
        if (s != null) {
View Full Code Here

  public void importSampleDeliveryFormSamples(List<Sample> samples, boolean checkTaxon) throws IOException {
    Map<String, String> foundTaxons = new HashMap<String, String>();
    if (importSampleDeliveryFormSamplesValidation(samples)) {
      log.info("Samples valid. Importing...");
      for (Sample s : samples) {
        Sample ms = requestManager.getSampleByBarcode(s.getIdentificationBarcode());
        if (ms != null) {
          //only process if there's a description
          if (s.getDescription() != null && !"".equals(s.getDescription())) {
            ms.setDescription(s.getDescription());
            log.info(ms.getName() + " : Set description -> " + ms.getDescription());

            if (s.getScientificName() != null && !"".equals(s.getScientificName())) {
              ms.setScientificName(s.getScientificName());
              log.info(ms.getName() + " : Set scientific name -> " + ms.getScientificName());
              if (checkTaxon) {
                if (foundTaxons.containsKey(s.getScientificName())) {
                  ms.setTaxonIdentifier(foundTaxons.get(s.getScientificName()));
                  log.info(ms.getName() + " : Set previously found taxon -> " + ms.getScientificName());
                }
                else {
                  String taxon = TaxonomyUtils.checkScientificNameAtNCBI(s.getScientificName());
                  if (taxon != null) {
                    foundTaxons.put(s.getScientificName(), taxon);
                    ms.setTaxonIdentifier(taxon);
                    log.info(ms.getName() + " : Set taxon -> " + ms.getScientificName());
                  }
                }
              }
            }

            //if (ms.getReceivedDate() == null) {
//              ms.setReceivedDate(new Date());
//            }

            if (!s.getNotes().isEmpty()) {
              for (Note n : s.getNotes()) {
                n.setOwner(ms.getSecurityProfile().getOwner());
              }
              ms.setNotes(s.getNotes());
            }

            requestManager.saveSample(ms);
          }
        }
View Full Code Here

TOP

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

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.