Package pedro.model

Examples of pedro.model.RecordModel


    {
      final String schemaContext = "/" + iterator.next(); //$NON-NLS-1$;
      final int index = schemaContext.lastIndexOf( SEPARATOR );
      final String recordClassName = ( index == -1 ) ? schemaContext : schemaContext.substring( index + 1 );
 
      final RecordModel sampleRecordModel = recordModelFactory.createRecordModel( recordClassName );
     
      final Collection editFields = sampleRecordModel.getEditFields();
     
      for( Iterator iterator2 = editFields.iterator(); iterator2.hasNext(); )
      {
        final DataFieldModel dataFieldModel = (DataFieldModel)iterator2.next();
       
View Full Code Here


    final QueryResult[] queryResultTemplates = queryFeature.getQueryResultTemplates();
   
    for( int i = 0; i < queryResultTemplates.length; i++ )
    {
      final QueryResult queryResult = queryResultTemplates[ i ];
      RecordModel recordModel = queryResult.getRecordModel();
     
      if( recordModel == null )
      {
        recordModel= recordModelFactory.createRecordModel( queryResult.getRecordClassName() );
      }
     
      final Collection editFields = recordModel.getEditFields();
     
      for( Iterator iterator = editFields.iterator(); iterator.hasNext(); )
      {
        final DataFieldModel dataFieldModel = (DataFieldModel)iterator.next();
       
View Full Code Here

        try
        {
          final MicroscopeAssay assay = new SpotterParser().getAssay( file );
          final RecordNameProvider targetRecordNameProvider = node.getRecordNameProvider();
          RecordModel assayRecordModel = getAssayRecordModel(assay);
          navigationTree.pasteNode( targetRecordNameProvider, assayRecordModel);
          node = navigationTree.getNodeFromRecordNameProvider(assayRecordModel);
          navigationTree.updateUI();
 
        }
View Full Code Here

     * @param assay
     * @return RecordModel
     */
    private RecordModel getAssayRecordModel( final MicroscopeAssay assay )
    {
      final RecordModel assayRecordModel = recordModelFactory.createRecordModel( "Experimental_details" ); //$NON-NLS-1$
      final List plates = assay.getPlates();
     
      assayRecordModel.setValue( "spotter_file_name", assay.getFile().getAbsolutePath(), false ); //$NON-NLS-1$
      assayRecordModel.setValue( "spotterEquipmentInfo", assay.getSpotterType(), false ); //$NON-NLS-1$
      assayRecordModel.setValue( "numberOfDishes", Integer.toString( plates.size() ), false ); //$NON-NLS-1$

    for( int i = 0; i < plates.size(); i++ )
    {
      assayRecordModel.addChild( "Dish", getDish( (MicroscopePlate)plates.get( i ), i + 1 ), false ); //$NON-NLS-1$
      assayRecordModel.updateDisplayName();
    }
   
    return assayRecordModel;
    }
View Full Code Here

     * @param blockNumber
     * @return RecordModel
     */
    private RecordModel getDish( MicroscopePlate plate, int blockNumber )
    {
      final RecordModel dish = recordModelFactory.createRecordModel( "Dish" ); //$NON-NLS-1$
    dish.setValue( "dishNumber", Integer.toString( blockNumber ), false ); //$NON-NLS-1$
    dish.setValue( "numberOfRows", Integer.toString( plate.getNumberOfRows() ), false ); //$NON-NLS-1$
    dish.setValue( "numberOfColumns", Integer.toString( plate.getNumberOfColumns() ), false ); //$NON-NLS-1$
    dish.setValue( "columnInterSpotGap", Integer.toString( plate.getColumnPitch() ), false ); //$NON-NLS-1$
    dish.setValue( "rowInterSpotGap", Integer.toString( plate.getRowPitch() ), false ); //$NON-NLS-1$
    dish.setValue( "xOffset", Integer.toString( plate.getOffsetX() ), false ); //$NON-NLS-1$
    dish.setValue( "yOffset", Integer.toString( plate.getOffsetY() ), false ); //$NON-NLS-1$
    dish.setValue( "zLevel", Integer.toString( plate.getZLevel() ), false ); //$NON-NLS-1$

    for( int row = 0; row < plate.getNumberOfRows(); row++ )
    {
      for( int column = 0; column < plate.getNumberOfColumns(); column++ )
      {
        final Spot spot = plate.getValueAt( row, column );
       
        if( spot != null )
        {
          dish.addChild( "SpotReading", getSpotReading( spot, row, column ), false ); //$NON-NLS-1$
          dish.updateDisplayName();
        }
      }
    }
   
    return dish;
View Full Code Here

     * @param column
     * @return RecordModel
     */
    private RecordModel getSpotReading( Spot spot, int row, int column )
    {
      final RecordModel spotReading = recordModelFactory.createRecordModel( "SpotReading" ); //$NON-NLS-1$
    spotReading.setValue( "row", Integer.toString( row + 1 ), false ); //$NON-NLS-1$
    spotReading.setValue( "column", Integer.toString( column + 1), false ); //$NON-NLS-1$

    // can have many treatments per spot. I think that they are comma-delimited in the GAL file
    final RecordModel spotSampleRM = recordModelFactory.createRecordModel( "SpotSample" ); //$NON-NLS-1$
    final SpotReading reading = spot.getUserValue();
   
    for( Iterator iterator = ( (Collection)reading.getUserObject() ).iterator(); iterator.hasNext(); )
    {            
      final Plasmid plasmid = (Plasmid)iterator.next();
      spotSampleRM.addChild( "Plasmid", getPlasmid( plasmid ), false); //$NON-NLS-1$
   

    spotReading.addChild( "SpotSample", spotSampleRM, false ); //$NON-NLS-1$
    spotReading.updateDisplayName();
    return spotReading;
View Full Code Here

     * @param plasmid
     * @return RecordModel
     */
    private RecordModel getPlasmid( Plasmid plasmid )
    {
      final RecordModel recordModel = recordModelFactory.createRecordModel( "Plasmid" ); //$NON-NLS-1$
      recordModel.setValue( "name", plasmid.getName(), false ); //$NON-NLS-1$
      recordModel.setValue( "type", plasmid.getType(), false ); //$NON-NLS-1$

      if( plasmid.getAccessionNumber() != null )
      {
        recordModel.setValue( "accessionNumber", plasmid.getAccessionNumber(), false ); //$NON-NLS-1$
      }
   
      if( plasmid.getMaterialType() != null )
      {
        recordModel.setValue( "material_type", plasmid.getMaterialType(), false ); //$NON-NLS-1$
      }
     
      final RecordModel sampleSource = recordModelFactory.createRecordModel( "SampleSource" ); //$NON-NLS-1$
      final RecordModel bioMaterialSource = recordModelFactory.createRecordModel( "BioMaterialSource" ); //$NON-NLS-1$
      boolean needsBioMaterialSource = false;

      if( plasmid.getInstitution() != null )
      {
        bioMaterialSource.setValue( "institution", plasmid.getInstitution(), false ); //$NON-NLS-1$
        needsBioMaterialSource = true;
      }
     
      if( plasmid.getAddress() != null )
      {
        bioMaterialSource.setValue( "address", plasmid.getAddress(), false ); //$NON-NLS-1$
        needsBioMaterialSource = true;
      }
     
      if( plasmid.getCountry() != null )
      {
        bioMaterialSource.setValue( "country", plasmid.getCountry(), false ); //$NON-NLS-1$
        needsBioMaterialSource = true;
      }
     
      if( plasmid.getContactPerson() != null )
      {
        bioMaterialSource.setValue( "contact_person", plasmid.getContactPerson(), false ); //$NON-NLS-1$
        needsBioMaterialSource = true;
      }
     
      if( plasmid.getPhone() != null )
      {
        bioMaterialSource.setValue( "phone", plasmid.getPhone(), false ); //$NON-NLS-1$
        needsBioMaterialSource = true;
      }
     
      if( plasmid.getEmail() != null )
      {
        bioMaterialSource.setValue( "email", plasmid.getEmail(), false ); //$NON-NLS-1$
        needsBioMaterialSource = true;
      }
     
      recordModel.addChild( "SampleSource", sampleSource, false ); //$NON-NLS-1$
      recordModel.updateDisplayName();
View Full Code Here

        if (numberOfDishes==0) {
          numberOfDishes=1;
        }
        ExperimentDetailsFactory expFactory = new ExperimentDetailsFactory(file);
        ExperimentalDetails expDetails = expFactory.getExperimentalDetails();
        final RecordModel experimentalDetails = node.getRecordModel();
        final RecordNameProvider targetRecordNameProvider = node.getRecordNameProvider();
        experimentalDetails.setValue("equipment_file_name", expDetails.getFileName(), false); //$NON-NLS-1$
       
        // First let's set the number of dishes...
        experimentalDetails.setValue("numberOfDishes", Integer.toString(numberOfDishes), false); //$NON-NLS-1$
       
        //And get the dishes...
       
        ArrayList dishes = expDetails.getDishes();
       
        for (int i =0; i<dishes.size(); i++) {
          //We need a record model for this dish.
          RecordModel dishNode = recordModelFactory.createRecordModel("Dish"); //$NON-NLS-1$
          Dish currentDish = (Dish)dishes.get(i);
         
          //Sort out what we know about the dish
          ArrayList spotReadings = currentDish.getSpotReadings();
          Microscope microscope = currentDish.getMicroscope();
         
          //Set the top level nodes we can
          RecordModel microscopeNode = recordModelFactory.createRecordModel("Microscope"); //$NON-NLS-1$
          RecordModel objectiveNode = recordModelFactory.createRecordModel("Objective_Details"); //$NON-NLS-1$
         
          //Do the microscope:
          objectiveNode.setValue("name", microscope.getName(), false); //$NON-NLS-1$
          objectiveNode.setValue("lensNA", microscope.getLens(), false); //$NON-NLS-1$
          objectiveNode.setValue("magnification", microscope.getMagnification(), false); //$NON-NLS-1$
         
          //Assemble the node
          microscopeNode.addChild("Objective_Details", objectiveNode, false); //$NON-NLS-1$
         
          //Add it to the dish
          dishNode.addChild("Microscope", microscopeNode, false); //$NON-NLS-1$
          dishNode.setValue("dishNumber", Integer.toString(currentDish.getDishNumber()), false); //$NON-NLS-1$
         
          //And now the spot readings...
         
          for (int j =0; j<spotReadings.size();j++) {
            SpotReading currentSpot = (SpotReading)spotReadings.get(j);
           
            RecordModel spotNode = recordModelFactory.createRecordModel("LocationReading"); //$NON-NLS-1$
            RecordModel resultNode = recordModelFactory.createRecordModel("Result"); //$NON-NLS-1$
           
            //Need an empty spotsample node...
            RecordModel sampleNode = recordModelFactory.createRecordModel("LocationSample"); //$NON-NLS-1$
            sampleNode.setValue("description", "", false); //$NON-NLS-1$ //$NON-NLS-2$
           
            resultNode.setValue("results_file", currentSpot.getResultFile(), false); //$NON-NLS-1$
            spotNode.addChild("Result", resultNode, false); //$NON-NLS-1$
            spotNode.setValue("acquisition_time", currentSpot.getAcquisitionTime().toString(), false); //$NON-NLS-1$
            spotNode.updateDisplayName();
           
            //Last two things:
           
            ArrayList tracks=currentSpot.getTracks();
            ArrayList excitations=currentSpot.getExcitations();
           
            // Tracks first!
            for (int k=0; k<tracks.size();k++) {
              Track currentTrack = (Track)tracks.get(k);
              RecordModel trackNode = recordModelFactory.createRecordModel("Track"); //$NON-NLS-1$
              trackNode.setValue("id", currentTrack.getId(), false); //$NON-NLS-1$
              trackNode.setValue("name", currentTrack.getName(), false); //$NON-NLS-1$
              spotNode.addChild("Track", trackNode, false); //$NON-NLS-1$
            }
            // Excitations!
            for (int k=0; k<excitations.size(); k++) {
              Excitation currentExcitation = (Excitation)excitations.get(k);
              RecordModel excitationNode = recordModelFactory.createRecordModel("Excitation"); //$NON-NLS-1$
              RecordModel laserNode = recordModelFactory.createRecordModel("Laser"); //$NON-NLS-1$
              RecordModel excitationMeasurementNode = recordModelFactory.createRecordModel("Excitation_Measurement"); //$NON-NLS-1$
              excitationMeasurementNode.setValue("unit", "nM", false); //$NON-NLS-1$ //$NON-NLS-2$
              excitationMeasurementNode.setValue("value", Double.toString(currentExcitation.getPower()), false); //$NON-NLS-1$
              excitationMeasurementNode.updateDisplayName();
              laserNode.addChild("Excitation_Measurement", excitationMeasurementNode, false); //$NON-NLS-1$
              laserNode.setValue("id", currentExcitation.getLaser(),false); //$NON-NLS-1$
              laserNode.updateDisplayName();
              excitationNode.addChild("Excitation_choices", laserNode, false); //$NON-NLS-1$
              excitationNode.updateDisplayName();
View Full Code Here

  /**
   *
   */
  public void parse()
  {
    final RecordModel resultRecordModel = node.getRecordModel();
    //Want to leave the file name as the LSM file for now? Or do we want it to be the XML tracker output?
    resultRecordModel.setValue( "results_file", file.getAbsolutePath(), false ); //$NON-NLS-1$
    resultRecordModel.addChild( "File_Info", getFileInfoRecordModel(), false ); //$NON-NLS-1$ 
    resultRecordModel.addChild( "ResultTimeSeries", getTimeSeriesRecordModel(), false ); //$NON-NLS-1$
   
    /*
     * Need to get some plasmid names to pass to the next bit...
     * Two places they could be, either in LocationReading/LocationSample/Plasmid
     * (LocationReading is this node's parent)
     * OR in Dish, which is LocationReading's parent...
     */
    ArrayList plasmidNames = new ArrayList();
    RecordModel locSample=null;
    ArrayList locReadsListFields =resultRecordModel.getContainingListModel().getContainingRecord().getListFields();
    //LocationSample is list first list field..
    ListFieldModel tempListField =(ListFieldModel)locReadsListFields.get(0);
    locSample = (RecordModel)tempListField.getChildren().get(0);
    if (locSample !=null) {
      ArrayList locSampleListFields = locSample.getListFields();
      tempListField = (ListFieldModel)locSampleListFields.get(0);
        for (int j=0; j<tempListField.getChildren().size();j++) {
            RecordModel tempPlasmidRM = (RecordModel)tempListField.getChildren().get(j);
            EditFieldModel tempEditModel = (EditFieldModel) tempPlasmidRM.getField("name");
            plasmidNames.add(tempEditModel.getValue());
        }
       
    }   
   
    //And let's do the same thing for the dish
    ArrayList dishListFields = resultRecordModel.getContainingListModel().getContainingRecord().getContainingListModel().getContainingRecord().getListFields();
    //Element 5 should have the plasmids in it... For some reason getListFields() returns all fields, not just ListFields.
    tempListField=(ListFieldModel)dishListFields.get(5);
    for (int j=0; j<tempListField.getChildren().size();j++) {
      RecordModel tempPlasmidRM = (RecordModel)tempListField.getChildren().get(j);
      EditFieldModel tempEditModel = (EditFieldModel) tempPlasmidRM.getField("name");
      plasmidNames.add(tempEditModel.getValue());
    }
    plasmidNames.add("No Plasmid Associated");
    //Remove duplicate names
    Set set = new HashSet(plasmidNames);
View Full Code Here

            // This is a bit tricky as this branch of the tree has already been partially
            // populated by the GAL file loader

            // Put the raw MDB file as a child of the current node.
            // First get a complete copy of the current node
            final RecordModel array = node.getRecordModel();
            array.setValue( "equipment_file_name", file.getAbsolutePath(), false ); //$NON-NLS-1$

            // Go through the stored model and find the appropriate recording for each spot node at this scope is an Assay
            final NodeUtils nodeUtils = new NodeUtils();

            // Need the microscope recording object here in order to add a microscope:
          MicroscopeRecording recording =null;
         
          String lensNA =""; //$NON-NLS-1$
          String mag=""; //$NON-NLS-1$
          String lensName=""; //$NON-NLS-1$
            // Need to precompute the total number of spots on each dish and cache this   
            final int numberOfDishes = nodeUtils.getIntegerFieldValue( node, "numberOfDishes" ); //$NON-NLS-1$

            for( int i = 0; i < numberOfDishes; i++ )
            {
              final String dishDisplayName = "DISH:-" + ( i + 1 ); //$NON-NLS-1$

              RecordModel microscopeRecordModel = recordModelFactory.createRecordModel( "Microscope" ); //$NON-NLS-1$
              for( Enumeration assayChildren = node.children(); assayChildren.hasMoreElements(); )
              {
                NavigationTreeNode dishNode = (NavigationTreeNode)assayChildren.nextElement();

                if( dishNode.getDisplayName().trim().equals( dishDisplayName ) )
                {     
                  // should have got the appropriate dish by here
                  // Get number of rows/columns from this dish, as each dish could be different :-(
                  final int rows = nodeUtils.getIntegerFieldValue( dishNode, "numberOfRows" ); //$NON-NLS-1$
                  final int columns = nodeUtils.getIntegerFieldValue( dishNode, "numberOfColumns" ); //$NON-NLS-1$

                  final List selectedSpots = new ArrayList();
                  final Collection deselectedSpots = new ArrayList();

                  for( Enumeration spotNodes = dishNode.children(); spotNodes.hasMoreElements(); )
                  {
                    final NavigationTreeNode spotNode = (NavigationTreeNode)spotNodes.nextElement();
                    final int rowNumber = nodeUtils.getIntegerFieldValue( spotNode, "row" ); //$NON-NLS-1$
                    final int columnNumber = nodeUtils.getIntegerFieldValue( spotNode, "column" ); //$NON-NLS-1$

                    final Collection plasmids = new ArrayList();
                    final Spot spot = new Spot( new SpotReading( plasmids, plasmids ) );
                    spot.setRow( rowNumber );
                    spot.setColumn( columnNumber );

                    selectedSpots.add( spot );
                  }

                  // Ask the user about which spots they asked the microscope to track
                  getTrackedSpots( rows, columns, recordings.size(), selectedSpots, deselectedSpots );

                  final boolean deleteNonTrackedSpots = ( deselectedSpots.size() > 0 ) ? deleteNonTrackedSpots() : false;

                  for( Enumeration spotNodes = dishNode.children(); spotNodes.hasMoreElements(); )
                  {
                    final NavigationTreeNode spotNode = (NavigationTreeNode)spotNodes.nextElement();

                    if( spotNode.getDisplayName().trim().startsWith( "SPOTREADING" ) ) //$NON-NLS-1$
                    {
                      final int rowNumber = nodeUtils.getIntegerFieldValue( spotNode, "row" ); //$NON-NLS-1$
                      final int columnNumber = nodeUtils.getIntegerFieldValue( spotNode, "column" ); //$NON-NLS-1$

                      // Now get the appropriate Microscope model and add it to this spot:
                      recording = getRecording( recordings, selectedSpots, rowNumber, columnNumber );
                      final RecordModel spotRecordModel = spotNode.getRecordModel();         

                      if( recording != null )
                      {         
                        //$NON-NLS-1$   

                        lensNA=recording.getLensNA();
                        lensName=recording.getLensName();
                        mag=recording.getMagnification();

                        for( Iterator iterator = recording.getTracks().iterator(); iterator.hasNext(); )
                        {
                          addTrack( (UniqueObject)iterator.next(), recordModelFactory, spotRecordModel );
                        }

                        for( Iterator iterator = recording.getLasers().iterator(); iterator.hasNext(); )
                        {
                          addLaser( (Laser)iterator.next(), recordModelFactory, spotRecordModel );
                        }

                        spotRecordModel.setValue( "acquisition_time", recording.getAquisitionTime(), false ); //$NON-NLS-1$
                        spotRecordModel.updateDisplayName();

                        for( Iterator iterator = spotRecordModel.getFields().iterator(); iterator.hasNext(); )
                        {
                          final DataFieldModel dataFieldModel = (DataFieldModel)iterator.next();

                          if( dataFieldModel.getName().trim().equals( "Microscope" ) ) //$NON-NLS-1$
                          {
                            spotRecordModel.removeField( dataFieldModel )
                          }
                        }

                        // TODO: Work out why Microscope cannot be added.
                        // spotRecordModel.addChild( "Microscope", microscopeRecordModel, false ); //$NON-NLS-1$

                        // Add Results stub to this spot reading
                        final RecordModel resultRecordModel = recordModelFactory.createRecordModel( "Result" ); //$NON-NLS-1$

                        resultRecordModel.setValue( "results_file", recording.getName(), false ); //$NON-NLS-1$
                        resultRecordModel.updateDisplayName();

                        spotRecordModel.addChild( "Result", resultRecordModel, false ); //$NON-NLS-1$
                        spotRecordModel.updateDisplayName();         
                      }
                      else if( deleteNonTrackedSpots )
                      {
                        final NavigationTreeNode parentNode = (NavigationTreeNode)spotNode.getParent();
                        final RecordModel parentRecordModel = parentNode.getRecordModel();

                        for( Iterator iterator = parentRecordModel.getFields().iterator(); iterator.hasNext(); )
                        {
                          final DataFieldModel dataFieldModel = (DataFieldModel)iterator.next();

                          if( dataFieldModel.getName().trim().equals( "SpotReading" ) ) //$NON-NLS-1$
                          {
                            if( dataFieldModel instanceof ListFieldModel )
                            {
                              final ListFieldModel listFieldModel = (ListFieldModel)dataFieldModel;
                              listFieldModel.removeChild( spotRecordModel );
                            }
                          }
                        }
                      }
                    }
                    dishNode.updateDisplayName( (DefaultTreeModel)navigationTree.getModel() );
                  }
                }
                RecordModel dishRecordModel = dishNode.getRecordModel();
                addObjectiveDetails( lensName, lensNA, mag, recordModelFactory, microscopeRecordModel );
                dishRecordModel.addChild("Microscope", microscopeRecordModel, false); //$NON-NLS-1$
                dishNode.updateDisplayName( (DefaultTreeModel)navigationTree.getModel() );
              }

            }
            array.updateDisplayName();
View Full Code Here

TOP

Related Classes of pedro.model.RecordModel

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.