Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved SquidInkAPI and fixed a bug. #590

Merged
merged 4 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'java'
apply plugin: 'maven'

String mavenGroupId = 'org.cirdles'
String mavenVersion = '1.7.3'
String mavenVersion = '1.7.4'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
Expand Down
47 changes: 41 additions & 6 deletions squidAPI/src/main/java/org/cirdles/squid/Squid3API.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ public interface Squid3API {
public Squid3ProjectBasicAPI getSquid3Project();

/**
*
*
* @param prawnXMLFileSourcePath
* @throws IOException
* @throws JAXBException
* @throws SAXException
* @throws SquidException
* @throws SquidException
*/
public void newSquid3GeochronProjectFromPrawnXML(Path prawnXMLFileSourcePath)
throws IOException, JAXBException, SAXException, SquidException;

/**
*
*
* @param prawnXMLFileSourcePath
* @throws IOException
* @throws JAXBException
* @throws SAXException
* @throws SquidException
* @throws SquidException
*/
public void newSquid3GeochronProjectFromZippedPrawnXML(Path prawnXMLFileSourcePath)
throws IOException, JAXBException, SAXException, SquidException;
Expand Down Expand Up @@ -93,10 +93,45 @@ public void newSquid3GeochronProjectFromZippedPrawnXML(Path prawnXMLFileSourcePa
public void saveAsSquid3Project(File squid3ProjectFileTarget) throws IOException, SquidException;

// reports management ++++++++++++++++++++++++++++++++++++++++++++++++++++++
/**
*
* @return
* @throws IOException
*/
public Path generateReferenceMaterialSummaryExpressionsReport() throws IOException;

/**
*
* @return
* @throws IOException
*/
public Path generateUnknownsSummaryExpressionsReport() throws IOException;

/**
*
* @return
* @throws IOException
*/
public Path generateTaskSummaryReport() throws IOException;

/**
*
* @return
* @throws IOException
*/
public Path generateProjectAuditReport() throws IOException;

/**
*
* @return
* @throws IOException
*/
public Path generatePerScanReports() throws IOException;

/**
*
* @throws IOException
*/
public void generateAllSquid3ProjectReports() throws IOException;
public Path generateAllSquid3ProjectReports() throws IOException;

}
82 changes: 66 additions & 16 deletions squidAPI/src/main/java/org/cirdles/squid/Squid3Ink.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javax.xml.bind.JAXBException;
import static org.cirdles.squid.constants.Squid3Constants.DEMO_SQUID_PROJECTS_FOLDER;
import static org.cirdles.squid.constants.Squid3Constants.TaskTypeEnum.GEOCHRON;
import org.cirdles.squid.dialogs.SquidMessageDialog;
import org.cirdles.squid.exceptions.SquidException;
import org.cirdles.squid.parameters.ParametersModelComparator;
import org.cirdles.squid.parameters.parameterModels.commonPbModels.CommonPbModel;
Expand Down Expand Up @@ -264,15 +267,58 @@ public void saveAsSquid3Project(File squid3ProjectFileTarget) throws IOException

// REPORTS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/**
* This method first checks to see if reports folder is initialized
*
* @throws IOException
* @return @throws IOException
*/
@Override
public void generateAllSquid3ProjectReports() throws IOException {
if (squid3Project.hasReportsFolder()) {
((Squid3ProjectReportingAPI) squid3Project).generateAllReports();
}
public Path generateReferenceMaterialSummaryExpressionsReport() throws IOException {
return ((Squid3ProjectReportingAPI) squid3Project).generateReferenceMaterialSummaryExpressionsReport();
}

/**
*
* @return @throws IOException
*/
@Override
public Path generateUnknownsSummaryExpressionsReport() throws IOException {
return ((Squid3ProjectReportingAPI) squid3Project).generateUnknownsSummaryExpressionsReport();
}

/**
*
* @return @throws IOException
*/
@Override
public Path generateTaskSummaryReport() throws IOException {
return ((Squid3ProjectReportingAPI) squid3Project).generateTaskSummaryReport();
}

/**
*
* @return @throws IOException
*/
@Override
public Path generateProjectAuditReport() throws IOException {
return ((Squid3ProjectReportingAPI) squid3Project).generateProjectAuditReport();
}

/**
*
* @return @throws IOException
*/
@Override
public Path generateAllSquid3ProjectReports() throws IOException {
return ((Squid3ProjectReportingAPI) squid3Project).generateAllReports();
}

/**
*
* @return
* @throws IOException
*/
@Override
public Path generatePerScanReports() throws IOException {
return ((Squid3ProjectReportingAPI) squid3Project).generatePerScanReports();
}

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

//squid3Ink.openDemonstrationSquid3Project();
squid3Ink.openDemonstrationSquid3Project();
// squid3Ink.newSquid3GeochronProjectFromPrawnXML(
// (new File("Squid3_Resources/ExamplePrawnXMLFiles/836_1_2016_Nov_28_09.50.xml")).toPath());
squid3Ink.newSquid3GeochronProjectFromZippedPrawnXML(
(new File("zippy/836_1_2016_Nov_28_09.50.xml.zip")).toPath());

// squid3Ink.newSquid3GeochronProjectFromZippedPrawnXML(
// (new File("zippy/836_1_2016_Nov_28_09.50.xml.zip")).toPath());
//
squid3Ink.generateAllSquid3ProjectReports();
System.out.println(squid3Ink.getSquid3Project().getProjectName()
+ " " + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());

squid3Ink.saveAsSquid3Project(new File("XXXXXX.squid"));
squid3Ink.generateAllSquid3ProjectReports();
System.out.println(squid3Ink.getSquid3Project().getProjectName()
+ " " + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());
+ "\n" + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());
try {
System.out.println(squid3Ink.generateReferenceMaterialSummaryExpressionsReport().toString());
System.out.println(squid3Ink.generatePerScanReports().toString());
} catch (IOException iOException) {
}
// squid3Ink.saveAsSquid3Project(new File("XXXXXX.squid"));
// squid3Ink.generateAllSquid3ProjectReports();
// System.out.println(squid3Ink.getSquid3Project().getProjectName()
// + " " + squid3Ink.getSquid3Project().getPrawnFileHandler().getReportsEngine().makeReportFolderStructure());

System.out.println(squid3Ink.retrieveSquid3ProjectListMRU());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,74 @@
*/
public interface Squid3ProjectReportingAPI {

public default boolean generateReportsValid() {
return (!((SquidProject) this).getTask().getNominalMasses().isEmpty())
&& ((SquidProject) this).hasReportsFolder()
&& ((SquidProject) this).prawnFileExists();
}

public default Path generateReferenceMaterialSummaryExpressionsReport() throws IOException {
Path summaryFilePath = null;
if (generateReportsValid()) {
summaryFilePath
= ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeSummaryReportsForReferenceMaterials().toPath();
}
if (summaryFilePath == null) {
throw new IOException("Squid3 unable to generateReferenceMaterialSummaryExpressionsReport");
} else {
return summaryFilePath;
}
}

public default Path generateUnknownsSummaryExpressionsReport() throws IOException {
Path summaryFilePath = null;
if (generateReportsValid()) {
summaryFilePath
= ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeSummaryReportsForUnknowns().toPath();
}
if (summaryFilePath == null) {
throw new IOException("Squid3 unable to generateUnknownsSummaryExpressionsReport");
} else {
return summaryFilePath;
}
}

public default Path generateTaskSummaryReport() throws IOException {
Path taskAuditFilePath = null;
if (generateReportsValid()) {
taskAuditFilePath = ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeTaskAudit().toPath();
}
if (taskAuditFilePath == null) {
throw new IOException("Squid3 unable to generateTaskSummaryReport");
} else {
return taskAuditFilePath;
}
}

public default Path generateProjectAuditReport() throws IOException {
Path projectAuditFilePath = null;
if (generateReportsValid()) {
projectAuditFilePath = ((SquidProject) this).getPrawnFileHandler().getReportsEngine().writeProjectAudit().toPath();
}
if (projectAuditFilePath == null) {
throw new IOException("Squid3 unable to generateProjectAuditReport");
} else {
return projectAuditFilePath;
}
}

public default Path generatePerScanReports() throws IOException {
Path projectScanReportsPath = null;
if (generateReportsValid()) {
projectScanReportsPath = ((SquidProject) this).getTask().producePerScanReportsToFiles().toPath();
}
if (projectScanReportsPath == null) {
throw new IOException("Squid3 unable to generatePerScanReports");
} else {
return projectScanReportsPath;
}
}

public Path generateAllReports() throws IOException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -873,27 +873,29 @@ public String[] splitPrawnFileAtRun(Run run, boolean useOriginalData)
return retVal;
}

@Override
public Path generateAllReports() throws IOException {
if (prawnFileExists()) {
if (filterForConcRefMatSpotNames.length() > 0) {
prawnFileHandler.getReportsEngine().writeProjectAudit();
prawnFileHandler.getReportsEngine().writeTaskAudit();

prawnFileHandler.getReportsEngine().writeSummaryReportsForReferenceMaterials();
produceReferenceMaterialPerSquid25CSV(true);
produceSelectedReferenceMaterialReportCSV();

prawnFileHandler.getReportsEngine().writeSummaryReportsForUnknowns();
produceUnknownsPerSquid25CSV(true);
produceUnknownsBySampleForETReduxCSV(true);
produceSelectedUnknownsReportCSV();
produceUnknownsWeightedMeanSortingFieldsCSV();
}

if (prawnFileExists()) {
// these are raw data reports
getTask().producePerScanReportsToFiles();
}

if (generateReportsValid()) {
prawnFileHandler.getReportsEngine().writeProjectAudit();
prawnFileHandler.getReportsEngine().writeTaskAudit();

prawnFileHandler.getReportsEngine().writeSummaryReportsForReferenceMaterials();
produceReferenceMaterialPerSquid25CSV(true);
produceSelectedReferenceMaterialReportCSV();

prawnFileHandler.getReportsEngine().writeSummaryReportsForUnknowns();
produceUnknownsPerSquid25CSV(true);
produceUnknownsBySampleForETReduxCSV(true);
produceSelectedUnknownsReportCSV();
produceUnknownsWeightedMeanSortingFieldsCSV();
}

return (new File(prawnFileHandler.getReportsEngine().makeReportFolderStructure())).toPath();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.cirdles.squid.tasks.expressions.expressionTrees.ExpressionTree;
import org.cirdles.squid.tasks.expressions.expressionTrees.ExpressionTreeInterface;
import org.cirdles.squid.tasks.expressions.isotopes.ShrimpSpeciesNode;
import org.cirdles.squid.tasks.expressions.operations.Divide;
import org.cirdles.squid.tasks.expressions.spots.SpotFieldNode;
import org.cirdles.squid.tasks.expressions.variables.VariableNodeForSummary;

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

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

amIsotopicRatio = false;
if (((ExpressionTree) expTree).getLeftET() instanceof ShrimpSpeciesNode) {
// Check for isotopic ratios
amIsotopicRatio = (((ExpressionTree) expTree).getOperation() instanceof Divide);
}
amIsotopicRatio = ((ExpressionTree) expTree).amIsotopicRatio();
// if (((ExpressionTree) expTree).getLeftET() instanceof ShrimpSpeciesNode) {
// // Check for isotopic ratios
// amIsotopicRatio = (((ExpressionTree) expTree).getOperation() instanceof Divide);
// }

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

uncertaintyColumn = null;
if ((uncertaintyDirective.length() == 0)
&& expTree.builtAsValueModel()
&& ( expTree.builtAsValueModel() || amIsotopicRatio)
// && (!expressionName.toUpperCase().contains("PCT"))
// && (!expressionName.toUpperCase().contains("ERR"))
// && (!expressionName.toUpperCase().contains("CONCEN"))
Expand Down
Loading