Skip to content

Commit 1706e0b

Browse files
authored
Fixed Issue #685 (#687)
* Refactor * Refined UI for invalid SBM counts * Added trap for missing spot names by inserting NO.NAME
1 parent d41eaf3 commit 1706e0b

File tree

11 files changed

+96
-70
lines changed

11 files changed

+96
-70
lines changed

common.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apply plugin: 'maven-publish'
77

88

99
String mavenGroupId = 'org.cirdles'
10-
String mavenVersion = '1.9.8'
10+
String mavenVersion = '1.9.9'
1111

1212
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
1313

@@ -80,7 +80,7 @@ publishing {
8080
licenses {
8181
license {
8282
name = 'The Apache License, Version 2.0'
83-
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
83+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
8484
}
8585
}
8686
}

squidAPI/src/main/java/org/cirdles/squid/Squid3Ink.java

-3
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,6 @@ public void updateSpotName(String oldSpotName, String spotName) {
529529
if (spot.getPar().get(0).getValue().compareToIgnoreCase(oldSpotName) == 0) {
530530
spot.getPar().get(0).setValue(spotName.trim());
531531
squid3Project.processPrawnSessionForDuplicateSpotNames();
532-
squid3Project.divideSamples();
533-
squid3Project.generatePrefixTreeFromSpotNames();
534-
535532
squid3Project.getTask().setChanged(true);
536533
squid3Project.getTask().setPrawnChanged(true);
537534
SquidProject.setProjectChanged(true);

squidApp/src/main/java/org/cirdles/squid/gui/ProjectManagerController.java

+50-19
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
import javafx.scene.layout.HBox;
2626
import javafx.util.StringConverter;
2727
import org.cirdles.squid.constants.Squid3Constants;
28-
import org.cirdles.squid.gui.dialogs.SquidMessageDialog;
2928
import org.cirdles.squid.exceptions.SquidException;
29+
import org.cirdles.squid.gui.dialogs.SquidMessageDialog;
3030
import org.cirdles.squid.parameters.parameterModels.ParametersModel;
3131
import org.cirdles.squid.projects.SquidProject;
32+
import org.cirdles.squid.tasks.Task;
3233
import org.cirdles.squid.tasks.TaskInterface;
3334
import org.cirdles.squid.tasks.taskDesign.TaskDesign;
3435
import org.cirdles.squid.utilities.squidPrefixTree.SquidPrefixTree;
@@ -82,6 +83,10 @@ public class ProjectManagerController implements Initializable {
8283
@FXML
8384
private ToggleGroup toggleGroupSBM;
8485
@FXML
86+
private Label invalidSBMCounts;
87+
@FXML
88+
private Label invalidSBMCountsDescription;
89+
@FXML
8590
private RadioButton linearRegressionRatioCalcRadioButton;
8691
@FXML
8792
private RadioButton spotAverageRatioCalcRadioButton;
@@ -131,7 +136,15 @@ public void initialize(URL url, ResourceBundle rb) {
131136

132137
if (task != null) {
133138
// roundingSquid3.setSelected(task.isRoundingForSquid3());
134-
try{setUpParametersModelsComboBoxes();}catch(SquidException squidException){ SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow); }
139+
try {
140+
setUpParametersModelsComboBoxes();
141+
} catch (SquidException squidException) {
142+
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
143+
}
144+
145+
invalidSBMCounts.setText("" + ((Task)task).getCountOfShrimpFractionsWithInvalidSBMcounts());
146+
invalidSBMCounts.setVisible(((Task)task).getCountOfShrimpFractionsWithInvalidSBMcounts() > 0);
147+
invalidSBMCountsDescription.setVisible(((Task)task).getCountOfShrimpFractionsWithInvalidSBMcounts() > 0);
135148
if (squidProject.isUseSBM()) {
136149
yesSBMRadioButton.setSelected(true);
137150
} else {
@@ -161,7 +174,7 @@ public void initialize(URL url, ResourceBundle rb) {
161174
titleLabel.setStyle(STYLE_MANAGER_TITLE);
162175
}
163176

164-
private void setUpParametersModelsComboBoxes() throws SquidException{
177+
private void setUpParametersModelsComboBoxes() throws SquidException {
165178

166179
// PhysicalConstantsModels
167180
physConstModelComboBox.setConverter(new ParameterModelStringConverter());
@@ -174,9 +187,11 @@ private void setUpParametersModelsComboBoxes() throws SquidException{
174187
SquidProject.setProjectChanged(true);
175188
task.setChanged(true);
176189
if (task.getReferenceMaterialSpots().size() > 0) {
177-
try{ task.setupSquidSessionSpecsAndReduceAndReport(false);} catch (SquidException squidException){
178-
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
179-
}
190+
try {
191+
task.setupSquidSessionSpecsAndReduceAndReport(false);
192+
} catch (SquidException squidException) {
193+
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
194+
}
180195
}
181196
});
182197

@@ -192,8 +207,9 @@ private void setUpParametersModelsComboBoxes() throws SquidException{
192207
SquidProject.setProjectChanged(true);
193208
task.setChanged(true);
194209
if (task.getReferenceMaterialSpots().size() > 0) {
195-
try{
196-
task.setupSquidSessionSpecsAndReduceAndReport(false);} catch (SquidException squidException){
210+
try {
211+
task.setupSquidSessionSpecsAndReduceAndReport(false);
212+
} catch (SquidException squidException) {
197213
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
198214
}
199215
}
@@ -309,8 +325,13 @@ private void yesSBMRadioButtonAction(ActionEvent event) {
309325
SquidProject.setProjectChanged(true);
310326
task.setUseSBM(true);
311327
task.setChanged(true);
312-
try{task.setupSquidSessionSpecsAndReduceAndReport(true);} catch (SquidException squidException){
313-
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
328+
try {
329+
task.setupSquidSessionSpecsAndReduceAndReport(true);
330+
} catch (SquidException squidException) {
331+
boolean chooseNoSBM = SquidMessageDialog.showChoiceDialog(squidException.getMessage(), primaryStageWindow);
332+
if (chooseNoSBM){
333+
noSBMRadioButton.setSelected(true);
334+
}
314335
}
315336
}
316337

@@ -320,7 +341,9 @@ private void noSBMRadioButtonActions(ActionEvent event) {
320341
SquidProject.setProjectChanged(true);
321342
task.setUseSBM(false);
322343
task.setChanged(true);
323-
try{task.setupSquidSessionSpecsAndReduceAndReport(true);} catch (SquidException squidException){
344+
try {
345+
task.setupSquidSessionSpecsAndReduceAndReport(true);
346+
} catch (SquidException squidException) {
324347
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
325348
}
326349
}
@@ -331,9 +354,11 @@ private void linearRegressionRatioCalcRadioButtonAction(ActionEvent event) {
331354
SquidProject.setProjectChanged(true);
332355
task.setUserLinFits(true);
333356
task.setChanged(true);
334-
try{ task.setupSquidSessionSpecsAndReduceAndReport(true);} catch (SquidException squidException){
335-
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
336-
}
357+
try {
358+
task.setupSquidSessionSpecsAndReduceAndReport(true);
359+
} catch (SquidException squidException) {
360+
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
361+
}
337362
}
338363

339364
@FXML
@@ -342,7 +367,9 @@ private void spotAverageRatioCalcRadioButtonAction(ActionEvent event) {
342367
SquidProject.setProjectChanged(true);
343368
task.setUserLinFits(false);
344369
task.setChanged(true);
345-
try{task.setupSquidSessionSpecsAndReduceAndReport(true);} catch (SquidException squidException){
370+
try {
371+
task.setupSquidSessionSpecsAndReduceAndReport(true);
372+
} catch (SquidException squidException) {
346373
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
347374
}
348375
}
@@ -373,7 +400,9 @@ private void autoExcludeSpotsCheckBoxAction(ActionEvent event) {
373400
// this will cause weighted mean expressions to be changed with boolean flag
374401
squidProject.setSquidAllowsAutoExclusionOfSpots(autoExcludeSpotsCheckBox.isSelected());
375402
SquidProject.setProjectChanged(true);
376-
try{task.updateRefMatCalibConstWMeanExpressions(autoExcludeSpotsCheckBox.isSelected());} catch (SquidException squidException){
403+
try {
404+
task.updateRefMatCalibConstWMeanExpressions(autoExcludeSpotsCheckBox.isSelected());
405+
} catch (SquidException squidException) {
377406
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
378407
}
379408
}
@@ -409,9 +438,11 @@ private void parametersSetDefaultsOnAction(ActionEvent actionEvent) {
409438

410439
@FXML
411440
private void refreshModelsAction(ActionEvent event) {
412-
try{ task.refreshParametersFromModels(squidProject.isTypeGeochron(), true, false);} catch (SquidException squidException){
413-
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
414-
}
441+
try {
442+
task.refreshParametersFromModels(squidProject.isTypeGeochron(), true, false);
443+
} catch (SquidException squidException) {
444+
SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
445+
}
415446
}
416447

417448
static class ParameterModelStringConverter extends StringConverter<ParametersModel> {

squidApp/src/main/java/org/cirdles/squid/gui/SpotManagerController.java

-2
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,6 @@ private void saveSpotNameAction(ActionEvent event) {
656656
if (saveSpotNameButton.getUserData() != null) {
657657
((PrawnFile.Run) saveSpotNameButton.getUserData()).getPar().get(0).setValue(selectedSpotNameText.getText().trim());
658658
squidProject.processPrawnSessionForDuplicateSpotNames();
659-
squidProject.divideSamples();
660-
squidProject.generatePrefixTreeFromSpotNames();
661659
shrimpFractionList.refresh();
662660
shrimpRefMatList.refresh();
663661
shrimpConcentrationRefMatList.refresh();

squidApp/src/main/java/org/cirdles/squid/gui/dialogs/SquidMessageDialog.java

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.awt.*;
2525
import java.io.File;
2626
import java.io.IOException;
27+
import java.util.Optional;
2728
import java.util.regex.Pattern;
2829

2930
/**
@@ -72,6 +73,17 @@ public static void showInfoDialog(String message, Window owner) {
7273
alert.showAndWait();
7374
}
7475

76+
public static boolean showChoiceDialog(String message, Window owner) {
77+
Alert alert = new SquidMessageDialog(
78+
Alert.AlertType.CONFIRMATION,
79+
message,
80+
"Squid3 informs you:", owner);
81+
alert.getButtonTypes().setAll(ButtonType.NO, ButtonType.OK);
82+
Optional<ButtonType> result = alert.showAndWait();
83+
84+
return (result.get() == ButtonType.OK);
85+
}
86+
7587
public static void showSavedAsDialog(File file, Window owner) {
7688
if (file == null) {
7789
Alert dialog = new SquidMessageDialog(Alert.AlertType.WARNING,

squidApp/src/main/resources/org/cirdles/squid/gui/ProjectManager.fxml

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
</toggleGroup>
138138
</RadioButton>
139139
<RadioButton fx:id="noSBMRadioButton" mnemonicParsing="false" onAction="#noSBMRadioButtonActions" text="No" toggleGroup="$toggleGroupSBM" />
140+
<Label fx:id="invalidSBMCounts" style="-fx-font-size: 12; -fx-font-weight: bold; -fx-text-fill: #c53d13;" text="0" />
141+
<Label fx:id="invalidSBMCountsDescription" layoutX="113.0" layoutY="11.0" style="-fx-font-size: 12; -fx-font-weight: bold; -fx-text-fill: #c53d13;" text="spots detected with invalid SBM counts" />
140142
</children>
141143
</HBox>
142144
<HBox alignment="CENTER_LEFT" spacing="10.0" GridPane.columnIndex="1" GridPane.rowIndex="1">

squidCore/src/main/java/org/cirdles/squid/projects/SquidProject.java

+8
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,10 @@ public void processPrawnSessionForDuplicateSpotNames() {
730730
Map<String, Integer> spotNameCountMap = new HashMap<>();
731731
for (int i = 0; i < runs.size(); i++) {
732732
String spotName = runs.get(i).getPar().get(0).getValue().trim();
733+
if (spotName.isEmpty()){
734+
spotName = "NO.NAME";
735+
runs.get(i).getPar().get(0).setValue(spotName);
736+
}
733737
String spotNameKey = spotName.toUpperCase(Locale.ENGLISH);
734738
// remove existing duplicate label in case editing occurred
735739
int indexDUP = spotName.indexOf("-DUP");
@@ -747,6 +751,10 @@ public void processPrawnSessionForDuplicateSpotNames() {
747751
spotNameCountMap.put(spotNameKey, 0);
748752
}
749753
}
754+
755+
// reprocess to handle any changes to spot names from here or caller
756+
divideSamples();
757+
generatePrefixTreeFromSpotNames();
750758
}
751759

752760
public void preProcessPrawnSession() {

squidCore/src/main/java/org/cirdles/squid/tasks/Task.java

+21-34
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public class Task implements TaskInterface, Serializable, XMLSerializerInterface
123123
protected String provenance;
124124
protected long dateRevised;
125125
protected boolean useSBM;
126+
protected int countOfShrimpFractionsWithInvalidSBMcounts;
126127
protected boolean userLinFits;
127128
// comes from prawn file mass station
128129
protected int indexOfBackgroundSpecies;
@@ -217,6 +218,10 @@ public Task(String name, CalamariReportsEngine reportsEngine) throws SquidExcept
217218
this(name, null, reportsEngine);
218219
}
219220

221+
public int getCountOfShrimpFractionsWithInvalidSBMcounts() {
222+
return countOfShrimpFractionsWithInvalidSBMcounts;
223+
}
224+
220225
/**
221226
* @param name
222227
* @param prawnFile
@@ -239,11 +244,13 @@ public Task(String name, ShrimpDataFileInterface prawnFile, CalamariReportsEngin
239244
this.authorName = taskDesign.getAuthorName();
240245
this.labName = taskDesign.getLabName();
241246
this.provenance = "";
242-
this.dateRevised = 0l;
247+
this.dateRevised = 0L;
243248
this.filterForRefMatSpotNames = "";
244249
this.filterForConcRefMatSpotNames = "";
245250
this.filtersForUnknownNames = new HashMap<>();
246251

252+
this.countOfShrimpFractionsWithInvalidSBMcounts = 0;
253+
247254
this.indexOfBackgroundSpecies = -1;
248255
this.indexOfTaskBackgroundMass = -1;
249256
this.parentNuclide = taskDesign.getParentNuclide();// "238";
@@ -340,16 +347,6 @@ public Task(String name, ShrimpDataFileInterface prawnFile, CalamariReportsEngin
340347
generateSpotMetaDataFields();
341348
}
342349

343-
// public static void main(String[] args) {
344-
// SquidProject sp = new SquidProject(GEOCHRON);
345-
// TaskInterface task = sp.getTask();
346-
// task.setNominalMasses(REQUIRED_NOMINAL_MASSES);
347-
// task.setRatioNames(REQUIRED_RATIO_NAMES);
348-
//
349-
// ((XMLSerializerInterface) task).serializeXMLObject("TASK.xml");
350-
//
351-
// }
352-
353350
public boolean synchronizeTaskVersion() throws SquidException {
354351
boolean retVal = false;
355352
if (taskSquidVersion == null) {
@@ -364,10 +361,6 @@ public boolean synchronizeTaskVersion() throws SquidException {
364361
return retVal;
365362
}
366363

367-
public void saveTaskToXML(File taskFileXML) {
368-
serializeXMLObject(taskFileXML.getAbsolutePath());
369-
}
370-
371364
public List<ParametersModel> verifySquidLabDataParameters() throws SquidException {
372365
List<ParametersModel> retVal = new ArrayList<>(3);
373366

@@ -475,7 +468,7 @@ public void updateTaskFromTaskDesign(TaskDesign taskDesign, boolean taskSkeleton
475468
}
476469
allMasses.addAll(nominalMasses);
477470
nominalMasses = allMasses;
478-
Collections.sort(nominalMasses, new IntuitiveStringComparator<>());
471+
nominalMasses.sort(new IntuitiveStringComparator<>());
479472

480473
nominalMasses.remove(DEFAULT_BACKGROUND_MASS_LABEL);
481474
indexOfTaskBackgroundMass = indexOfBackgroundSpecies;
@@ -486,7 +479,7 @@ public void updateTaskFromTaskDesign(TaskDesign taskDesign, boolean taskSkeleton
486479
}
487480
allRatios.addAll(ratioNames);
488481
ratioNames = allRatios;
489-
Collections.sort(ratioNames, new IntuitiveStringComparator<>());
482+
ratioNames.sort(new IntuitiveStringComparator<>());
490483

491484
setChanged(true);
492485
if (!taskSkeleton) {
@@ -555,13 +548,11 @@ public void updateTaskDesignFromTask(TaskDesign taskDesign, boolean includeCusto
555548
}
556549

557550
// housekeeping
558-
List<String> myNominalMasses = new ArrayList<>();
559-
myNominalMasses.addAll(nominalMasses);
551+
List<String> myNominalMasses = new ArrayList<>(nominalMasses);
560552
myNominalMasses.removeAll(REQUIRED_NOMINAL_MASSES);
561553
taskDesign.setNominalMasses(myNominalMasses);
562554

563-
List<String> myRatioNames = new ArrayList<>();
564-
myRatioNames.addAll(ratioNames);
555+
List<String> myRatioNames = new ArrayList<>(ratioNames);
565556
myRatioNames.removeAll(REQUIRED_RATIO_NAMES);
566557
taskDesign.setRatioNames(myRatioNames);
567558

@@ -1005,7 +996,7 @@ public void refreshParametersFromModels(
1005996
boolean refreshPhysicalConstantsModel,
1006997
boolean refreshReferenceMaterialsModel) throws SquidException {
1007998

1008-
List<ParametersModel> models = null;
999+
List<ParametersModel> models;
10091000

10101001
if (refreshCommonLeadModel) {
10111002
models = squidLabData.getCommonPbModels();
@@ -1950,7 +1941,7 @@ public String customizeXML(String xml) {
19501941
public List<ShrimpFractionExpressionInterface> processRunFractions(ShrimpDataFileInterface prawnFile, SquidSessionModel squidSessionSpecs)
19511942
throws SquidException {
19521943
shrimpFractions = new ArrayList<>();
1953-
int countOfShrimpFractionsWithInvalidSBMcounts = 0;
1944+
countOfShrimpFractionsWithInvalidSBMcounts = 0;
19541945

19551946
ShrimpFraction shrimpFraction = null;
19561947
for (int f = 0; f < prawnFile.extractCountOfRuns(); f++) {
@@ -1975,12 +1966,13 @@ public List<ShrimpFractionExpressionInterface> processRunFractions(ShrimpDataFil
19751966

19761967
// June 2019 per issue #340
19771968
if (useSBM && (countOfShrimpFractionsWithInvalidSBMcounts > 0)) {
1978-
throw new SquidException("Squid3 detected that " + countOfShrimpFractionsWithInvalidSBMcounts + " spots contain invalid SBM counts. \n\n"
1979-
+ "Squid3 recommends switching SBM normalisation OFF until you diagnose the problem.");
1980-
// SquidMessageDialog.showWarningDialog(
1981-
// "Squid3 detected that " + countOfShrimpFractionsWithInvalidSBMcounts + " spots contain invalid SBM counts. \n\n"
1982-
// + "Squid3 recommends switching SBM normalisation OFF until you diagnose the problem.",
1983-
// null);
1969+
// this first case is for creating a new project from data file
1970+
if (unknownSpots.isEmpty()) {
1971+
useSBM = false;
1972+
} else {
1973+
throw new SquidException("Squid3 detected that " + countOfShrimpFractionsWithInvalidSBMcounts + " spots contain invalid SBM counts. \n\n"
1974+
+ "Squid3 recommends switching SBM normalisation OFF until you diagnose the problem.");
1975+
}
19841976
}
19851977

19861978
// prepare for task expressions to be evaluated
@@ -3389,11 +3381,6 @@ public IndexIsoptopesEnum getSelectedIndexIsotope() {
33893381
@Override
33903382
public void setSelectedIndexIsotope(IndexIsoptopesEnum selectedIndexIsotope) {
33913383
this.selectedIndexIsotope = selectedIndexIsotope;
3392-
// try {
3393-
// changed = true;
3394-
// setupSquidSessionSpecsAndReduceAndReport(false);
3395-
// } catch (SquidException squidException) {
3396-
// }
33973384
}
33983385

33993386
@Override

0 commit comments

Comments
 (0)