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();