Skip to content

Commit a8b472c

Browse files
authored
Improved SquidInkAPI and fixed a bug. (#590)
* Added reports to SquidInkAPI * Added more reports to SquidInkAPI * Fixed #589 * Updated demo project
1 parent 4c4c25e commit a8b472c

File tree

8 files changed

+215
-52
lines changed

8 files changed

+215
-52
lines changed

common.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply plugin: 'java'
66
apply plugin: 'maven'
77

88
String mavenGroupId = 'org.cirdles'
9-
String mavenVersion = '1.7.3'
9+
String mavenVersion = '1.7.4'
1010

1111
sourceCompatibility = '1.8'
1212
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

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

+41-6
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ public interface Squid3API {
3838
public Squid3ProjectBasicAPI getSquid3Project();
3939

4040
/**
41-
*
41+
*
4242
* @param prawnXMLFileSourcePath
4343
* @throws IOException
4444
* @throws JAXBException
4545
* @throws SAXException
46-
* @throws SquidException
46+
* @throws SquidException
4747
*/
4848
public void newSquid3GeochronProjectFromPrawnXML(Path prawnXMLFileSourcePath)
4949
throws IOException, JAXBException, SAXException, SquidException;
50-
50+
5151
/**
52-
*
52+
*
5353
* @param prawnXMLFileSourcePath
5454
* @throws IOException
5555
* @throws JAXBException
5656
* @throws SAXException
57-
* @throws SquidException
57+
* @throws SquidException
5858
*/
5959
public void newSquid3GeochronProjectFromZippedPrawnXML(Path prawnXMLFileSourcePath)
6060
throws IOException, JAXBException, SAXException, SquidException;
@@ -93,10 +93,45 @@ public void newSquid3GeochronProjectFromZippedPrawnXML(Path prawnXMLFileSourcePa
9393
public void saveAsSquid3Project(File squid3ProjectFileTarget) throws IOException, SquidException;
9494

9595
// reports management ++++++++++++++++++++++++++++++++++++++++++++++++++++++
96+
/**
97+
*
98+
* @return
99+
* @throws IOException
100+
*/
101+
public Path generateReferenceMaterialSummaryExpressionsReport() throws IOException;
102+
103+
/**
104+
*
105+
* @return
106+
* @throws IOException
107+
*/
108+
public Path generateUnknownsSummaryExpressionsReport() throws IOException;
109+
110+
/**
111+
*
112+
* @return
113+
* @throws IOException
114+
*/
115+
public Path generateTaskSummaryReport() throws IOException;
116+
117+
/**
118+
*
119+
* @return
120+
* @throws IOException
121+
*/
122+
public Path generateProjectAuditReport() throws IOException;
123+
124+
/**
125+
*
126+
* @return
127+
* @throws IOException
128+
*/
129+
public Path generatePerScanReports() throws IOException;
130+
96131
/**
97132
*
98133
* @throws IOException
99134
*/
100-
public void generateAllSquid3ProjectReports() throws IOException;
135+
public Path generateAllSquid3ProjectReports() throws IOException;
101136

102137
}

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

+66-16
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
import java.io.IOException;
2020
import java.nio.file.Path;
2121
import java.util.List;
22+
import javafx.event.ActionEvent;
23+
import javafx.fxml.FXML;
2224
import javax.xml.bind.JAXBException;
2325
import static org.cirdles.squid.constants.Squid3Constants.DEMO_SQUID_PROJECTS_FOLDER;
2426
import static org.cirdles.squid.constants.Squid3Constants.TaskTypeEnum.GEOCHRON;
27+
import org.cirdles.squid.dialogs.SquidMessageDialog;
2528
import org.cirdles.squid.exceptions.SquidException;
2629
import org.cirdles.squid.parameters.ParametersModelComparator;
2730
import org.cirdles.squid.parameters.parameterModels.commonPbModels.CommonPbModel;
@@ -264,15 +267,58 @@ public void saveAsSquid3Project(File squid3ProjectFileTarget) throws IOException
264267

265268
// REPORTS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
266269
/**
267-
* This method first checks to see if reports folder is initialized
268270
*
269-
* @throws IOException
271+
* @return @throws IOException
270272
*/
271273
@Override
272-
public void generateAllSquid3ProjectReports() throws IOException {
273-
if (squid3Project.hasReportsFolder()) {
274-
((Squid3ProjectReportingAPI) squid3Project).generateAllReports();
275-
}
274+
public Path generateReferenceMaterialSummaryExpressionsReport() throws IOException {
275+
return ((Squid3ProjectReportingAPI) squid3Project).generateReferenceMaterialSummaryExpressionsReport();
276+
}
277+
278+
/**
279+
*
280+
* @return @throws IOException
281+
*/
282+
@Override
283+
public Path generateUnknownsSummaryExpressionsReport() throws IOException {
284+
return ((Squid3ProjectReportingAPI) squid3Project).generateUnknownsSummaryExpressionsReport();
285+
}
286+
287+
/**
288+
*
289+
* @return @throws IOException
290+
*/
291+
@Override
292+
public Path generateTaskSummaryReport() throws IOException {
293+
return ((Squid3ProjectReportingAPI) squid3Project).generateTaskSummaryReport();
294+
}
295+
296+
/**
297+
*
298+
* @return @throws IOException
299+
*/
300+
@Override
301+
public Path generateProjectAuditReport() throws IOException {
302+
return ((Squid3ProjectReportingAPI) squid3Project).generateProjectAuditReport();
303+
}
304+
305+
/**
306+
*
307+
* @return @throws IOException
308+
*/
309+
@Override
310+
public Path generateAllSquid3ProjectReports() throws IOException {
311+
return ((Squid3ProjectReportingAPI) squid3Project).generateAllReports();
312+
}
313+
314+
/**
315+
*
316+
* @return
317+
* @throws IOException
318+
*/
319+
@Override
320+
public Path generatePerScanReports() throws IOException {
321+
return ((Squid3ProjectReportingAPI) squid3Project).generatePerScanReports();
276322
}
277323

278324
/**
@@ -285,20 +331,24 @@ public void generateAllSquid3ProjectReports() throws IOException {
285331
public static void main(String[] args) throws IOException, SquidException, JAXBException, SAXException {
286332
Squid3API squid3Ink = Squid3Ink.spillSquid3Ink();
287333

288-
//squid3Ink.openDemonstrationSquid3Project();
334+
squid3Ink.openDemonstrationSquid3Project();
289335
// squid3Ink.newSquid3GeochronProjectFromPrawnXML(
290336
// (new File("Squid3_Resources/ExamplePrawnXMLFiles/836_1_2016_Nov_28_09.50.xml")).toPath());
291-
squid3Ink.newSquid3GeochronProjectFromZippedPrawnXML(
292-
(new File("zippy/836_1_2016_Nov_28_09.50.xml.zip")).toPath());
293-
337+
// squid3Ink.newSquid3GeochronProjectFromZippedPrawnXML(
338+
// (new File("zippy/836_1_2016_Nov_28_09.50.xml.zip")).toPath());
339+
//
294340
squid3Ink.generateAllSquid3ProjectReports();
295341
System.out.println(squid3Ink.getSquid3Project().getProjectName()
296-
+ " " + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());
297-
298-
squid3Ink.saveAsSquid3Project(new File("XXXXXX.squid"));
299-
squid3Ink.generateAllSquid3ProjectReports();
300-
System.out.println(squid3Ink.getSquid3Project().getProjectName()
301-
+ " " + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());
342+
+ "\n" + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());
343+
try {
344+
System.out.println(squid3Ink.generateReferenceMaterialSummaryExpressionsReport().toString());
345+
System.out.println(squid3Ink.generatePerScanReports().toString());
346+
} catch (IOException iOException) {
347+
}
348+
// squid3Ink.saveAsSquid3Project(new File("XXXXXX.squid"));
349+
// squid3Ink.generateAllSquid3ProjectReports();
350+
// System.out.println(squid3Ink.getSquid3Project().getProjectName()
351+
// + " " + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());
302352

303353
System.out.println(squid3Ink.retrieveSquid3ProjectListMRU());
304354
}

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

+69
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,74 @@
1414
*/
1515
public interface Squid3ProjectReportingAPI {
1616

17+
public default boolean generateReportsValid() {
18+
return (!((SquidProject) this).getTask().getNominalMasses().isEmpty())
19+
&& ((SquidProject) this).hasReportsFolder()
20+
&& ((SquidProject) this).prawnFileExists();
21+
}
22+
23+
public default Path generateReferenceMaterialSummaryExpressionsReport() throws IOException {
24+
Path summaryFilePath = null;
25+
if (generateReportsValid()) {
26+
summaryFilePath
27+
= ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeSummaryReportsForReferenceMaterials().toPath();
28+
}
29+
if (summaryFilePath == null) {
30+
throw new IOException("Squid3 unable to generateReferenceMaterialSummaryExpressionsReport");
31+
} else {
32+
return summaryFilePath;
33+
}
34+
}
35+
36+
public default Path generateUnknownsSummaryExpressionsReport() throws IOException {
37+
Path summaryFilePath = null;
38+
if (generateReportsValid()) {
39+
summaryFilePath
40+
= ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeSummaryReportsForUnknowns().toPath();
41+
}
42+
if (summaryFilePath == null) {
43+
throw new IOException("Squid3 unable to generateUnknownsSummaryExpressionsReport");
44+
} else {
45+
return summaryFilePath;
46+
}
47+
}
48+
49+
public default Path generateTaskSummaryReport() throws IOException {
50+
Path taskAuditFilePath = null;
51+
if (generateReportsValid()) {
52+
taskAuditFilePath = ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeTaskAudit().toPath();
53+
}
54+
if (taskAuditFilePath == null) {
55+
throw new IOException("Squid3 unable to generateTaskSummaryReport");
56+
} else {
57+
return taskAuditFilePath;
58+
}
59+
}
60+
61+
public default Path generateProjectAuditReport() throws IOException {
62+
Path projectAuditFilePath = null;
63+
if (generateReportsValid()) {
64+
projectAuditFilePath = ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeProjectAudit().toPath();
65+
}
66+
if (projectAuditFilePath == null) {
67+
throw new IOException("Squid3 unable to generateProjectAuditReport");
68+
} else {
69+
return projectAuditFilePath;
70+
}
71+
}
72+
73+
public default Path generatePerScanReports() throws IOException {
74+
Path projectScanReportsPath = null;
75+
if (generateReportsValid()) {
76+
projectScanReportsPath = ((SquidProject) this).getTask().producePerScanReportsToFiles().toPath();
77+
}
78+
if (projectScanReportsPath == null) {
79+
throw new IOException("Squid3 unable to generatePerScanReports");
80+
} else {
81+
return projectScanReportsPath;
82+
}
83+
}
84+
1785
public Path generateAllReports() throws IOException;
86+
1887
}

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

+17-15
Original file line numberDiff line numberDiff line change
@@ -873,27 +873,29 @@ public String[] splitPrawnFileAtRun(Run run, boolean useOriginalData)
873873
return retVal;
874874
}
875875

876+
@Override
876877
public Path generateAllReports() throws IOException {
877-
if (prawnFileExists()) {
878-
if (filterForConcRefMatSpotNames.length() > 0) {
879-
prawnFileHandler.getReportsEngine().writeProjectAudit();
880-
prawnFileHandler.getReportsEngine().writeTaskAudit();
881-
882-
prawnFileHandler.getReportsEngine().writeSummaryReportsForReferenceMaterials();
883-
produceReferenceMaterialPerSquid25CSV(true);
884-
produceSelectedReferenceMaterialReportCSV();
885-
886-
prawnFileHandler.getReportsEngine().writeSummaryReportsForUnknowns();
887-
produceUnknownsPerSquid25CSV(true);
888-
produceUnknownsBySampleForETReduxCSV(true);
889-
produceSelectedUnknownsReportCSV();
890-
produceUnknownsWeightedMeanSortingFieldsCSV();
891-
}
892878

879+
if (prawnFileExists()) {
893880
// these are raw data reports
894881
getTask().producePerScanReportsToFiles();
895882
}
896883

884+
if (generateReportsValid()) {
885+
prawnFileHandler.getReportsEngine().writeProjectAudit();
886+
prawnFileHandler.getReportsEngine().writeTaskAudit();
887+
888+
prawnFileHandler.getReportsEngine().writeSummaryReportsForReferenceMaterials();
889+
produceReferenceMaterialPerSquid25CSV(true);
890+
produceSelectedReferenceMaterialReportCSV();
891+
892+
prawnFileHandler.getReportsEngine().writeSummaryReportsForUnknowns();
893+
produceUnknownsPerSquid25CSV(true);
894+
produceUnknownsBySampleForETReduxCSV(true);
895+
produceSelectedUnknownsReportCSV();
896+
produceUnknownsWeightedMeanSortingFieldsCSV();
897+
}
898+
897899
return (new File(prawnFileHandler.getReportsEngine().makeReportFolderStructure())).toPath();
898900
}
899901

squidCore/src/main/java/org/cirdles/squid/squidReports/squidReportColumns/SquidReportColumn.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.cirdles.squid.tasks.expressions.expressionTrees.ExpressionTree;
2424
import org.cirdles.squid.tasks.expressions.expressionTrees.ExpressionTreeInterface;
2525
import org.cirdles.squid.tasks.expressions.isotopes.ShrimpSpeciesNode;
26-
import org.cirdles.squid.tasks.expressions.operations.Divide;
2726
import org.cirdles.squid.tasks.expressions.spots.SpotFieldNode;
2827
import org.cirdles.squid.tasks.expressions.variables.VariableNodeForSummary;
2928

@@ -37,7 +36,6 @@
3736
import static org.cirdles.squid.squidReports.squidReportColumns.SquidReportColumnInterface.formatBigDecimalForPublicationSigDigMode;
3837
import static org.cirdles.squid.squidReports.squidReportTables.SquidReportTable.DEFAULT_COUNT_OF_SIGNIFICANT_DIGITS;
3938
import static org.cirdles.squid.squidReports.squidReportTables.SquidReportTable.HEADER_ROW_COUNT;
40-
import static org.cirdles.squid.tasks.expressions.builtinExpressions.BuiltInExpressionsDataDictionary.R204PB_206PB;
4139

4240
/**
4341
* @author James F. Bowring, CIRDLES.org, and Earth-Time.org
@@ -121,11 +119,11 @@ public void initReportColumn(TaskInterface task) {
121119
expressionNameCustom = "total_" + expressionName + "_cts_/sec";
122120
}
123121

124-
amIsotopicRatio = false;
125-
if (((ExpressionTree) expTree).getLeftET() instanceof ShrimpSpeciesNode) {
126-
// Check for isotopic ratios
127-
amIsotopicRatio = (((ExpressionTree) expTree).getOperation() instanceof Divide);
128-
}
122+
amIsotopicRatio = ((ExpressionTree) expTree).amIsotopicRatio();
123+
// if (((ExpressionTree) expTree).getLeftET() instanceof ShrimpSpeciesNode) {
124+
// // Check for isotopic ratios
125+
// amIsotopicRatio = (((ExpressionTree) expTree).getOperation() instanceof Divide);
126+
// }
129127

130128
// propose column headers by splitting on underscores in name
131129
// row 0 is reserved for category displayname
@@ -180,7 +178,7 @@ public void initReportColumn(TaskInterface task) {
180178

181179
uncertaintyColumn = null;
182180
if ((uncertaintyDirective.length() == 0)
183-
&& expTree.builtAsValueModel()
181+
&& ( expTree.builtAsValueModel() || amIsotopicRatio)
184182
// && (!expressionName.toUpperCase().contains("PCT"))
185183
// && (!expressionName.toUpperCase().contains("ERR"))
186184
// && (!expressionName.toUpperCase().contains("CONCEN"))

0 commit comments

Comments
 (0)