/** Recursively save all child elements and then call ObjBase to save itself. */
  @Override
  public synchronized boolean save(ClothoConnection conn) {
    System.out.println("============ Starting plasmidSample save");
    if (!isChanged()) {
      System.out.println("plasmidSample didn't require saving");
      return true;
    }

    if (Collector.isLocal(_pSampleDatum._plasmidUUID)) {
      Plasmid plas = getPlasmid();
      if (!plas.isInDatabase()) {
        if (!plas.save(conn)) {
          return false;
        }
      }
    }

    if (Collector.isLocal(_pSampleDatum._sourceStrainUUID)) {
      Strain st = getSourceStrain();
      if (!st.isInDatabase()) {
        if (!st.save(conn)) {
          return false;
        }
      }
    }

    return super.save(conn);
  }
示例#2
0
  @Override
  protected HashMap<String, HashMap<String, Object>> generateXml(
      HashMap<String, HashMap<String, Object>> allObjects) {
    // If the hash already has the object, skip adding anything
    if (allObjects.containsKey(getUUID())) {
      return allObjects;
    }

    // Fill in the individual fields
    HashMap<String, Object> datahash = new HashMap<String, Object>();
    datahash.put("objType", getType().toString());
    datahash.put("uuid", _plateDatum.uuid);
    datahash.put("name", _plateDatum.name);
    datahash.put("_dateCreated", getDateCreatedAsString());
    datahash.put("_lastModified", getLastModifiedAsString());

    datahash.put("_barcode", _plateDatum._barcode);
    datahash.put("_location", _plateDatum._location);
    datahash.put("_authorUUID", _plateDatum._authorUUID);
    datahash.put("_plateTypeUUID", _plateDatum._plateTypeUUID);

    datahash.put("numRows", Integer.toString(getNumRows()));
    datahash.put("numCols", Integer.toString(getNumCols()));

    ArrayList<String> containerlist = new ArrayList<String>();
    for (int i = 0; i < this.getNumRows(); i++) {
      for (int j = 0; j < this.getNumCols(); j++) {
        String conuuid = _plateDatum.myWells[i][j];
        Container acon = Collector.getContainer(conuuid);
        if (acon != null) {
          String aline = acon.getUUID() + "," + i + "," + j;
          containerlist.add(aline);
        }
      }
    }
    datahash.put("containers", containerlist);

    // Add the HashMap to the list
    allObjects.put(getUUID(), datahash);

    // Recursively gather the objects linked to this object
    allObjects = getPlateType().generateXml(allObjects);
    allObjects = getAuthor().generateXml(allObjects);
    for (int i = 0; i < this.getNumRows(); i++) {
      for (int j = 0; j < this.getNumCols(); j++) {
        String conuuid = _plateDatum.myWells[i][j];
        Container acon = Collector.getContainer(conuuid);
        if (acon != null) {
          allObjects = acon.generateXml(allObjects);
        }
      }
    }

    // Return the datahash
    return allObjects;
  }
示例#3
0
  /** Recursively save all child elements and then call ObjBase to save itself. */
  @Override
  public synchronized boolean save(ClothoConnection conn) {
    System.out.println("============ Starting plate save of " + getUUID());
    if (!isChanged()) {
      System.out.println("Collection didn't require saving");
      return true;
    }

    if (Collector.isLocal(this._plateDatum._authorUUID)) {
      if (!getAuthor().saveDefault()) {
        return false;
      }
    }
    if (!Collector.getCurrentUser().getUUID().equals(this.getAuthor().getUUID())) {
      if (!Collector.getCurrentUser().isAdmin()) {
        System.out.println(
            "Current user "
                + this.getAuthor().getDisplayName()
                + " does not have permission to modify "
                + this.getName());
        return false;
      }
    }
    if (!super.save(conn)) {
      return false;
    }

    for (int row = 0; row < getNumRows(); row++) {
      for (int col = 0; col < getNumCols(); col++) {
        String containerref = this.getContainerRefAt(row, col);
        if (!Collector.isLocal(containerref)) {
          continue;
        }
        Container acon = Collector.getContainer(containerref);
        System.out.println("plate about to save " + acon.getName());

        System.out.println(acon.getUUID());
        System.out.println(acon.getName());
        System.out.println(acon.getDateCreated());
        System.out.println(acon.getLastModified());
        System.out.println(acon.getRowAsInt());
        System.out.println(acon.getCol());
        System.out.println(acon.getBarcode());
        System.out.println(acon.isFixed());
        System.out.println(acon.getPlateLink());

        if (!acon.save(conn)) {
          return false;
        }
      }
    }
    return true;
  }
示例#4
0
 /**
  * returns the Container present in a well of the Plate as a Container object
  *
  * @param i
  * @param j
  * @return
  */
 public Container getContainerAt(int i, int j) {
   System.out.println("Plate retrieving row " + i + " col " + j);
   String containerref = getContainerRefAt(i, j);
   System.out.println("containerref is: " + containerref);
   if (containerref.equals("") || containerref.equals("null")) {
     return null;
   }
   return Collector.getContainer(containerref);
 }
  private void makePlateActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_makePlateActionPerformed
    // TODO add your handling code here:
    platetypeList = Collector.getAllLinksOf(ObjType.PLATE_TYPE);
    authorList = Collector.getAllLinksOf(ObjType.PERSON);
    int authorSelect = this.jComboBoxAuthor.getSelectedIndex();
    int plateTypeSelect = this.jComboBoxPlateType.getSelectedIndex();
    ObjLink plateLink = platetypeList.get(plateTypeSelect);
    ObjLink personLink = authorList.get(authorSelect);
    Person testPerson = Collector.getPerson(personLink.uuid);
    PlateType testType = Collector.getPlateType(plateLink.uuid);
    Plate testPlate = new Plate(this.plateName.getText(), testType, testPerson);

    if (this.location.getText() != null) {
      testPlate.setLocation(this.location.getText());
    }
    if (this.barCode.getText() != null) testPlate.setBarcode(this.barCode.getText());

    boolean didWork = testPlate.saveDefault();
    System.out.println("write plate to DB:" + didWork);
    this.parentFrame.setVisible(false);
    frame aframe = new frame(testPlate);
    hub.guis.add(new WeakReference(aframe));
  } // GEN-LAST:event_makePlateActionPerformed
 private void addPlateType() {
   platetypeList = Collector.getAllLinksOf(ObjType.PLATE_TYPE);
   Iterator i = platetypeList.iterator();
   while (i.hasNext()) this.jComboBoxPlateType.addItem(i.next());
 }
 private void addAuthor() {
   authorList = Collector.getAllLinksOf(ObjType.PERSON);
   Iterator i = authorList.iterator();
   while (i.hasNext()) this.jComboBoxAuthor.addItem(i.next());
 }
示例#8
0
 public Person getAuthor() {
   return Collector.getPerson(_plateDatum._authorUUID);
 }
示例#9
0
 public PlateType getPlateType() {
   return (PlateType) Collector.get(ObjType.PLATE_TYPE, _plateDatum._plateTypeUUID);
 }
 public Strain getSourceStrain() {
   return Collector.getStrain(_pSampleDatum._sourceStrainUUID);
 }
 public Plasmid getPlasmid() {
   return Collector.getPlasmid(_pSampleDatum._plasmidUUID);
 }
  public SequenceViewPartExport(SequenceView sv, JTextPane jtp) {
    initComponents();
    _sv = sv;
    //        addWindowListener(new WindowAdapter(){
    //        @Override
    //        public void windowClosing(WindowEvent we){
    //            ClothoDialogBox db = new ClothoDialogBox("Clotho: Exit Check", "Are you sure you
    // want to close the packager?");
    //
    //            if(db.show_optionDialog(javax.swing.JOptionPane.YES_NO_OPTION,
    // javax.swing.JOptionPane.QUESTION_MESSAGE) == javax.swing.JOptionPane.YES_OPTION)
    //                dispose();
    //            }
    //        });
    dataTextPane.setText(jtp.getText());
    if (jtp.getSelectedText() != null) {
      intervalRadioButton.setSelected(true);
      fromTextField.setText(Integer.toString(jtp.getSelectionStart()));
      fromTextField.getDocument().addDocumentListener(new SelectionListener());
      toTextField.setText(Integer.toString(jtp.getSelectionEnd()));
      toTextField.getDocument().addDocumentListener(new SelectionListener());
      try {
        //                dataTextPane.grabFocus();
        dataTextPane.select(jtp.getSelectionStart(), jtp.getSelectionEnd());
        dataTextPane
            .getHighlighter()
            .addHighlight(
                jtp.getSelectionStart(),
                jtp.getSelectionEnd(),
                new javax.swing.text.DefaultHighlighter.DefaultHighlightPainter(
                    dataTextPane.getSelectionColor()));
      } catch (Exception e) {
      }
    } else {
      try {
        //                dataTextPane.grabFocus();
        dataTextPane.selectAll();
        dataTextPane
            .getHighlighter()
            .addHighlight(
                0,
                dataTextPane.getText().length(),
                new javax.swing.text.DefaultHighlighter.DefaultHighlightPainter(
                    dataTextPane.getSelectionColor()));
      } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
      }
      fromTextField.setText("0");
      toTextField.setText(Integer.toString(jtp.getText().length()));
      wsRadioButton.setSelected(true);
      try {
        dataTextPane
            .getHighlighter()
            .addHighlight(
                0,
                dataTextPane.getText().length(),
                new javax.swing.text.DefaultHighlighter.DefaultHighlightPainter(
                    dataTextPane.getSelectionColor()));
        dataTextPane.grabFocus();
        dataTextPane.selectAll();
      } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
      }
    }
    ArrayList<ObjLink> collectionLinks = Collector.getAllLinksOf(ObjType.COLLECTION);
    collectionComboBox.removeAllItems();
    for (ObjLink oj : collectionLinks) {
      collectionComboBox.addItem(oj);
    }
    collectionComboBox.setSelectedIndex(-1);
    formatComboBox.removeAllItems();
    ArrayList<ObjLink> formatLinks = Collector.getAllLinksOf(ObjType.FORMAT);
    for (ObjLink oj : formatLinks) {
      formatComboBox.addItem(oj);
    }
    formatComboBox.setSelectedIndex(-1);
    objectTypeComboBox.removeAllItems();
    objectTypeComboBox.addItem("Feature");
    objectTypeComboBox.addItem("Oligo");
    objectTypeComboBox.addItem("Part");
    objectTypeComboBox.addItem("Vector");
    objectTypeComboBox.setSelectedIndex(-1);
    formatComboBox.setEnabled(false);
    formatLabel.setEnabled(false);

    this.setVisible(true);
  }
 private void saveButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveButtonActionPerformed
   String desc = _sv.getSequenceView().getOutputTextArea().getText();
   if (desc == null) {
     desc = "";
   }
   String name = nameTextField.getText();
   String seq = null;
   System.out.println("saving: " + name);
   if (intervalRadioButton.isSelected()) {
     try {
       if (dataTextPane.getText() != null) {
         seq =
             dataTextPane
                 .getText()
                 .substring(
                     Integer.parseInt(fromTextField.getText()),
                     Integer.parseInt(toTextField.getText()));
       }
     } catch (NumberFormatException e) {
       System.out.println("tried to use invalid sequence interval to generate Clotho object");
       return;
     }
   } else {
     seq = dataTextPane.getText();
   }
   Format form = null;
   Collection coll = null;
   if (objectTypeComboBox.getSelectedIndex() != 1 && objectTypeComboBox.getSelectedIndex() != 0) {
     if (formatComboBox.getSelectedIndex() == -1) {
       statusLabel.setText("Warning: format not set");
       return;
     }
     form = Collector.getFormat(((ObjLink) formatComboBox.getSelectedItem()).uuid);
   }
   if (collectionComboBox.getSelectedIndex() != -1) {
     coll = Collector.getCollection(((ObjLink) collectionComboBox.getSelectedItem()).uuid);
   } else {
     statusLabel.setText("Warning: collection not selected");
     return;
   }
   if (objectTypeComboBox.getSelectedIndex() == -1) {
     statusLabel.setText("Warning: object Type not set");
     return;
   }
   Boolean saved = false;
   ObjBase newObject = null;
   if (coll != null) {
     if (objectTypeComboBox.getSelectedIndex() == 0) {
       // feature
       if (seq.toUpperCase().indexOf("ATG") != -1) {
         newObject = Feature.generateFeature(name, seq, Collector.getCurrentUser(), true);
       } else {
         newObject = Feature.generateFeature(name, seq, Collector.getCurrentUser(), false);
       }
     } else if (objectTypeComboBox.getSelectedIndex() == 1) {
       newObject = new Oligo(name, desc, Collector.getCurrentUser(), seq);
     } else if (form != null && objectTypeComboBox.getSelectedIndex() == 2) {
       // part
       newObject = Part.generateBasic(name, desc, seq, form, Collector.getCurrentUser());
     } else if (form != null && objectTypeComboBox.getSelectedIndex() == 3) {
       Vector.generateVector(name, desc, seq, form, Collector.getCurrentUser());
     } else {
       statusLabel.setText("error saving new Clotho object, check selected fields");
       return;
     }
   } else {
     statusLabel.setText("Not all fields are filled");
     return;
   }
   if (newObject != null) {
     statusLabel.setText("saving: " + newObject.getName());
   }
   saved = newObject.saveDefault();
   coll.addObject(newObject);
   coll.saveDefault();
   Collector.add(newObject);
   if (saved) {
     statusLabel.setText("Successful save!");
     NucSeq.refreshFeatureTable();
     this.dispose();
   }
 } // GEN-LAST:event_saveButtonActionPerformed