//Get the GAL file and populate part of the model
SpotterImporter spotterImporter = new SpotterImporter(recordModelFactory, navigationTree, node1);
if (spotterImporter.process()) {
final NavigationTreeNode node = spotterImporter.getNode();
// Get the Zeiss MDB file:
final File file = new FileChooserUtils().getFile( "mdb" ); //$NON-NLS-1$
if( file != null )
{
try
{
final List recordings = new ArrayList();
new ExperimentFactory().getInstance( file, recordings );
// 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();