Skip to content

Commit 8a9016b

Browse files
authored
Prawn25 (#575)
* Addressed #574 * Confirmed #574 fix, added initial Squid3Ink API * New version 1.7.1
1 parent 119d63a commit 8a9016b

File tree

15 files changed

+515
-102
lines changed

15 files changed

+515
-102
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.0'
9+
String mavenVersion = '1.7.1'
1010

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

squidAPI/build.gradle

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apply plugin: 'application'
2+
3+
mainClassName = 'org.cirdles.squid.SquidAPI'
4+
5+
repositories {
6+
jcenter()
7+
}
8+
9+
dependencies {
10+
compile project(":squidCore")
11+
testImplementation 'junit:junit:4.13'
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2021 James F. Bowring and CIRDLES.org.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.cirdles.squid;
17+
18+
import java.io.IOException;
19+
import java.nio.file.Path;
20+
import org.cirdles.squid.projects.Squid3ProjectBasicAPI;
21+
22+
/**
23+
*
24+
* @author bowring
25+
*/
26+
public interface Squid3API {
27+
28+
public Squid3ProjectBasicAPI getSquid3Project();
29+
30+
public void openSquid3Project(Path projectFilePath);
31+
32+
public void openDemonstrationSquid3Project();
33+
34+
public void generateAllSquid3ProjectReports()throws IOException;
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2021 James F. Bowring and CIRDLES.org.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.cirdles.squid;
17+
18+
import java.io.File;
19+
import java.io.IOException;
20+
import java.nio.file.Path;
21+
import org.cirdles.commons.util.ResourceExtractor;
22+
import org.cirdles.squid.projects.SquidProject;
23+
import org.cirdles.squid.utilities.stateUtilities.SquidSerializer;
24+
import org.cirdles.squid.projects.Squid3ProjectBasicAPI;
25+
import org.cirdles.squid.projects.Squid3ProjectReportingAPI;
26+
27+
/**
28+
* Provides specialized class to implement API for Squid3Ink Virtual Squid3.
29+
*
30+
* @author bowring
31+
*/
32+
public class Squid3Ink implements Squid3API {
33+
34+
private Squid3ProjectBasicAPI squid3Project;
35+
36+
@Override
37+
public Squid3ProjectBasicAPI getSquid3Project() {
38+
return squid3Project;
39+
}
40+
41+
private Squid3Ink() {
42+
}
43+
44+
public static Squid3API spillSquid3Ink() {
45+
return new Squid3Ink();
46+
}
47+
48+
/**
49+
* Loads existing Squid3 project file.
50+
*
51+
* @param projectFilePath
52+
* @return
53+
*/
54+
@Override
55+
public void openSquid3Project(Path projectFilePath) {
56+
squid3Project
57+
= (SquidProject) SquidSerializer.getSerializedObjectFromFile(projectFilePath.toString(), true);
58+
}
59+
60+
/**
61+
* Loads demonstration Squid3 project.
62+
*
63+
* @return SquidProject
64+
*/
65+
@Override
66+
public void openDemonstrationSquid3Project() {
67+
ResourceExtractor extractor = new ResourceExtractor(SquidProject.class);
68+
File testingModelFile = extractor.extractResourceAsFile("SQUID3_demo_file.squid");
69+
openSquid3Project(testingModelFile.toPath());
70+
}
71+
72+
@Override
73+
public void generateAllSquid3ProjectReports() throws IOException {
74+
((Squid3ProjectReportingAPI) squid3Project).generateAllReports();
75+
}
76+
77+
/**
78+
* @param args the command line arguments
79+
* @throws java.io.IOException
80+
*/
81+
public static void main(String[] args) throws IOException {
82+
Squid3API squid3Ink = Squid3Ink.spillSquid3Ink();
83+
squid3Ink.openDemonstrationSquid3Project();
84+
squid3Ink.generateAllSquid3ProjectReports();
85+
86+
System.out.println(squid3Ink.getSquid3Project().getProjectName());
87+
}
88+
}

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

+4-15
Original file line numberDiff line numberDiff line change
@@ -1424,21 +1424,10 @@ public void generateAllReportsAction(ActionEvent actionEvent) throws IOException
14241424
primaryStageWindow);
14251425
} else {
14261426
if (squidProject.hasReportsFolder()) {
1427-
File projectAuditFile = squidProject.getPrawnFileHandler().getReportsEngine().writeProjectAudit();
1428-
squidProject.getPrawnFileHandler().getReportsEngine().writeTaskAudit();
1429-
1430-
squidProject.getPrawnFileHandler().getReportsEngine().writeSummaryReportsForReferenceMaterials();
1431-
squidProject.produceReferenceMaterialPerSquid25CSV(true);
1432-
squidProject.produceSelectedReferenceMaterialReportCSV();
1433-
1434-
squidProject.getPrawnFileHandler().getReportsEngine().writeSummaryReportsForUnknowns();
1435-
squidProject.produceUnknownsPerSquid25CSV(true);
1436-
squidProject.produceUnknownsBySampleForETReduxCSV(true);
1437-
squidProject.produceSelectedUnknownsReportCSV();
1438-
squidProject.produceUnknownsWeightedMeanSortingFieldsCSV();
1439-
1440-
squidProject.getTask().producePerScanReportsToFiles();
1441-
SquidMessageDialog.showSavedAsDialog(projectAuditFile.getParentFile(), primaryStageWindow);
1427+
1428+
Path reportFolderPath = squidProject.generateAllReports();
1429+
1430+
SquidMessageDialog.showSavedAsDialog(reportFolderPath.toFile(), primaryStageWindow);
14421431
} else {
14431432
showReportsWarning();
14441433
}

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<items>
2222
<MenuItem fx:id="projectManagerMenuItem" mnemonicParsing="false" onAction="#projectManagerMenuItemAction" text="Manage Project" />
2323
<SeparatorMenuItem mnemonicParsing="false" />
24-
<Menu mnemonicParsing="false" text="New Squid GEOCHRON Project">
24+
<Menu mnemonicParsing="false" text="New Squid3 GEOCHRON Project">
2525
<items>
2626
<MenuItem fx:id="newSquidProjectMenuItem" mnemonicParsing="false" onAction="#newSquidProjectAction" text="From a single Prawn XML file" />
2727
<MenuItem fx:id="newSquidProjectFromZippedPrawnMenuItem" mnemonicParsing="false" onAction="#newSquidProjectFromZippedPrawnAction" text="From a single Zipped Prawn XML file" />
@@ -31,22 +31,22 @@
3131
<Menu fx:id="openRecentOPFileMenu" mnemonicParsing="false" text="(Beta) From Recent OP File" />
3232
</items>
3333
</Menu>
34-
<Menu mnemonicParsing="false" text="New Squid RATIO Project &lt;BETA&gt;">
34+
<Menu mnemonicParsing="false" text="New Squid3 RATIO Project &lt;BETA&gt;">
3535
<items>
3636
<MenuItem fx:id="newSquidRatioProjectMenuItem" mnemonicParsing="false" onAction="#newSquidRatioProjectAction" text="From a single Prawn XML file" />
3737
</items>
3838
</Menu>
3939
<SeparatorMenuItem mnemonicParsing="false" />
40-
<MenuItem fx:id="openSquidProjectMenuItem" mnemonicParsing="false" onAction="#openSquidProjectMenuItemAction" text="Open Squid Project" />
41-
<Menu fx:id="openRecentSquidProjectMenu" mnemonicParsing="false" text="Open Recent Squid Project" />
42-
<MenuItem mnemonicParsing="false" onAction="#openDemoSquiProjectAction" text="Open Demonstration Squid Project" />
40+
<MenuItem fx:id="openSquidProjectMenuItem" mnemonicParsing="false" onAction="#openSquidProjectMenuItemAction" text="Open Squid3 Project" />
41+
<Menu fx:id="openRecentSquidProjectMenu" mnemonicParsing="false" text="Open Recent Squid3 Project" />
42+
<MenuItem mnemonicParsing="false" onAction="#openDemoSquiProjectAction" text="Open Demonstration Squid3 Project" />
4343
<SeparatorMenuItem mnemonicParsing="false" />
44-
<MenuItem fx:id="saveSquidProjectMenuItem" mnemonicParsing="false" onAction="#saveSquidProjectMenuItemAction" text="Save Squid Project" />
45-
<MenuItem fx:id="saveAsSquidProjectMenuItem" mnemonicParsing="false" onAction="#saveAsSquidProjectMenuItemAction" text="Save Squid Project as ..." />
44+
<MenuItem fx:id="saveSquidProjectMenuItem" mnemonicParsing="false" onAction="#saveSquidProjectMenuItemAction" text="Save Squid3 Project" />
45+
<MenuItem fx:id="saveAsSquidProjectMenuItem" mnemonicParsing="false" onAction="#saveAsSquidProjectMenuItemAction" text="Save Squid3 Project as ..." />
4646
<SeparatorMenuItem mnemonicParsing="false" />
47-
<MenuItem fx:id="closeSquidProjectMenuItem" mnemonicParsing="false" onAction="#closeSquidProjectMenuItemClose" text="Close Squid Project" />
47+
<MenuItem fx:id="closeSquidProjectMenuItem" mnemonicParsing="false" onAction="#closeSquidProjectMenuItemClose" text="Close Squid3 Project" />
4848
<SeparatorMenuItem mnemonicParsing="false" />
49-
<MenuItem mnemonicParsing="false" onAction="#quitAction" text="Quit Squid" />
49+
<MenuItem mnemonicParsing="false" onAction="#quitAction" text="Quit Squid3" />
5050
</items>
5151
</Menu>
5252
<Menu fx:id="managePrawnFileMenu" mnemonicParsing="false" text="Data">

squidCore/src/main/java/org/cirdles/squid/core/CalamariReportsEngine.java

+11-18
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ public void produceReports(List<ShrimpFractionExpressionInterface> shrimpFractio
145145
}
146146
}
147147

148-
private String makeReportFolderStructure() {
149-
return File.separator + "Squid3ProjectReports-" + squidProject.getProjectName().replaceAll("\\s", "_")
150-
// + File.separator + "TASK-" + squidProject.getTask().getName()
148+
public String makeReportFolderStructure() throws IOException{
149+
return folderToWriteCalamariReports.getCanonicalPath()
150+
+ File.separator + "Squid3ProjectReports-"
151+
+ squidProject.getProjectName().replaceAll("\\s", "_")
151152
+ File.separator;
152153
}
153154

@@ -182,9 +183,7 @@ public File produceReports(
182183

183184
if (doWriteReportFiles) {
184185
folderToWriteCalamariReportsPath
185-
= folderToWriteCalamariReports.getCanonicalPath()
186-
+ makeReportFolderStructure()
187-
// + "PRAWN-" + nameOfPrawnSourceFile
186+
= makeReportFolderStructure()
188187
+ squidProject.getProjectName().replaceAll("\\s", "_") + "_PerScan"
189188
+ File.separator + sdfTime.format(new Date())
190189
+ reportParameterValues
@@ -978,8 +977,7 @@ public String produceCalamariReportByFlavor(CalamariReportFlavors flavor) {
978977

979978
public File writeReportTableFiles(String[][] report, String baseReportTableName) throws IOException {
980979
String reportsPath
981-
= folderToWriteCalamariReports.getCanonicalPath()
982-
+ makeReportFolderStructure();
980+
= makeReportFolderStructure();
983981
File reportsFolder = new File(reportsPath);
984982
if (!reportsFolder.mkdirs()) {
985983
//throw new IOException("Failed to delete reports folder '" + reportsPath + "'");
@@ -993,8 +991,7 @@ public File writeReportTableFiles(String[][] report, String baseReportTableName)
993991

994992
public File writeReportTableFilesPerSquid3(String[][] report, String baseReportTableName) throws IOException {
995993
String reportsPath
996-
= folderToWriteCalamariReports.getCanonicalPath()
997-
+ makeReportFolderStructure();
994+
= makeReportFolderStructure();
998995
File reportsFolder = new File(reportsPath);
999996
if (!reportsFolder.mkdirs()) {
1000997
//throw new IOException("Failed to delete reports folder '" + reportsPath + "'");
@@ -1153,8 +1150,7 @@ private void writeOutCSVSummaryCalc(PrintWriter writer, Expression exp) {
11531150

11541151
private File getFileForSummaryCalc(String baseSummaryCalcName) throws IOException {
11551152
String reportsPath
1156-
= folderToWriteCalamariReports.getCanonicalPath()
1157-
+ makeReportFolderStructure();
1153+
= makeReportFolderStructure();
11581154
File reportsFolder = new File(reportsPath);
11591155
if (!reportsFolder.mkdirs()) {
11601156
}
@@ -1164,8 +1160,7 @@ private File getFileForSummaryCalc(String baseSummaryCalcName) throws IOExceptio
11641160

11651161
public File writeTaskAudit() throws IOException {
11661162
String reportsPath
1167-
= folderToWriteCalamariReports.getCanonicalPath()
1168-
+ makeReportFolderStructure();
1163+
= makeReportFolderStructure();
11691164
File reportsFolder = new File(reportsPath);
11701165
if (!reportsFolder.mkdirs()) {
11711166
//throw new IOException("Failed to delete reports folder '" + reportsPath + "'");
@@ -1183,8 +1178,7 @@ public File writeTaskAudit() throws IOException {
11831178

11841179
public File writeProjectAudit() throws IOException {
11851180
String reportsPath
1186-
= folderToWriteCalamariReports.getCanonicalPath()
1187-
+ makeReportFolderStructure();
1181+
= makeReportFolderStructure();
11881182
File reportsFolder = new File(reportsPath);
11891183
if (!reportsFolder.mkdirs()) {
11901184
//throw new IOException("Failed to delete reports folder '" + reportsPath + "'");
@@ -1201,8 +1195,7 @@ public File writeProjectAudit() throws IOException {
12011195
}
12021196

12031197
public String getWeightedMeansReportPath() throws IOException {
1204-
return folderToWriteCalamariReports.getCanonicalPath()
1205-
+ makeReportFolderStructure();
1198+
return makeReportFolderStructure();
12061199
}
12071200

12081201
public File getWeightedMeansReportFile(String baseReportTableName) throws IOException {

0 commit comments

Comments
 (0)