diff --git a/.gitignore b/.gitignore index 27657948..a3193bbc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,11 @@ dependency-reduced-pom.xml # Generated *.txt +*.html +*.xml +*.svg +*.densityplotter +*.csv # MACOS .DS_Store diff --git a/README.md b/README.md index 8b619580..e76a589e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,36 @@ ET_Redux -======== +=== + +**ET_Redux** is the flagship cyber infrastructure product of [CIRDLES](http://cirdles.org), +the Cyber Infrastructure Research and Development Lab for the Earth Sciences, +an undergraduate research +lab at the College of Charleston in Charleston, South Carolina. **ET_Redux** was +previously known as U-Pb_Redux, but in January of 2015, was renamed to +reflect its expanding functionality and its sponsor, EARTHTIME (EARTH-TIME.org). + +**ET_Redux** currently serves the ID-TIMS and LAICP-MS U-Pb geochronology communities +as described [here](http://cirdles.org/sites/default/files/Downloads/ggge1933.pdf) and +[here](http://cirdles.org/sites/default/files/Downloads/ggge1932.pdf). + +We have recently received NSF funding to extend the architecture to Uranium series +analyses, as explained +[here](http://earthcube.org/group/cyberinfrastructure-u-series-geochronologic-data). + +As of March 2015, we are migrating our content from CIRDLES.org to this site, with +the goal of stimulating community involvement. + +Getting Started for Users: +--- +You will always find the latest release +[here](https://github.com/CIRDLES/ET_Redux/releases) - it consists of one file that can be +saved and executed from anywhere on your 64-bit machine - Unix, Linux, Mac, and Windows. +Be sure you have the latest Java Runtime Environment (JRE), found +[here](http://www.oracle.com/technetwork/java/javase/downloads/index.html). + +Getting Started for Developers: +--- +Join Github by getting an account. Fork the repository and explore the code. We value +your contributions, whether they are to the code, documentation, tests, help engine, +issues, or planning. If you want more involvement, please contact +[Jim Bowring](mailto://bowringj@cofc.edu). + diff --git a/pom.xml b/pom.xml index 9e97910e..408e6115 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,27 @@ + 4.0.0 org.cirdles ET_Redux ET_Redux - 3.0.1 + 3.0.4 Successor to U-Pb_Redux https://cirdles.org 2006 @@ -21,9 +38,11 @@ - James Bowring + James F. Bowring bowringj.people.cofc.edu + bowring@gmail.com CIRDLES + https://www.cirdles.org/ @@ -58,7 +77,7 @@ com.google.guava guava - 14.0.1 + 17.0 org.apache.xmlgraphics @@ -162,6 +181,31 @@ batik-transcoder 1.7 + + com.google.jimfs + jimfs + 1.0 + + + org.apache.httpcomponents + httpclient + 4.4 + + + org.apache.httpcomponents + httpclient-cache + 4.4 + + + org.apache.httpcomponents + httpmime + 4.4 + + + org.apache.httpcomponents + fluent-hc + 4.4 + diff --git a/src/main/java/org/earthtime/ETRedux.java b/src/main/java/org/earthtime/ETRedux.java index cf7a85e9..3f34158e 100644 --- a/src/main/java/org/earthtime/ETRedux.java +++ b/src/main/java/org/earthtime/ETRedux.java @@ -44,12 +44,12 @@ public class ETRedux { /** * Version 3.0.0 initiates switch to ET_Redux from U-Pb_Redux */ - public static String VERSION = "3.0.1"; + public static String VERSION = "3.0.4"; /** * */ - public static String RELEASE_DATE = "22 January 2015"; + public static String RELEASE_DATE = "22 March 2015"; /** * Creates a new instance of UPbRedux @@ -114,7 +114,7 @@ public static void main(String[] args) { // File reduxFile = new File(evt.getFilename()); // JOptionPane.showMessageDialog(null, // new String[]{evt.getFilename()}, -// "U-Pb Redux Warning", +// "ET Redux Warning", // JOptionPane.WARNING_MESSAGE); // if (reduxFile.exists()) { // new ETRedux(reduxFile); diff --git a/src/main/java/org/earthtime/ETReduxFrame.form b/src/main/java/org/earthtime/ETReduxFrame.form index 2c9920e9..643a2b80 100644 --- a/src/main/java/org/earthtime/ETReduxFrame.form +++ b/src/main/java/org/earthtime/ETReduxFrame.form @@ -111,12 +111,22 @@ - + + + + + + + + + + + @@ -623,7 +633,7 @@ - + @@ -639,7 +649,7 @@ - + @@ -647,7 +657,7 @@ - + @@ -681,6 +691,14 @@ + + + + + + + + diff --git a/src/main/java/org/earthtime/ETReduxFrame.java b/src/main/java/org/earthtime/ETReduxFrame.java index 919ccfa3..08198fcf 100644 --- a/src/main/java/org/earthtime/ETReduxFrame.java +++ b/src/main/java/org/earthtime/ETReduxFrame.java @@ -71,6 +71,7 @@ import org.earthtime.UPb_Redux.dialogs.ReportSettingsManager; import org.earthtime.UPb_Redux.dialogs.fractionManagers.UPbFractionEditorDialog; import org.earthtime.UPb_Redux.dialogs.projectManagers.ProjectManagerFor_LAICPMS_FromRawData; +import org.earthtime.UPb_Redux.dialogs.projectManagers.exportManagers.GeochronProjectExportManager; import org.earthtime.UPb_Redux.dialogs.projectManagers.projectLegacyManagers.AbstractProjectOfLegacySamplesDataManagerDialog; import org.earthtime.UPb_Redux.dialogs.projectManagers.projectLegacyManagers.ProjectOfLegacySamplesDataManagerDialogForGenericUPb_A; import org.earthtime.UPb_Redux.dialogs.projectManagers.projectLegacyManagers.ProjectOfLegacySamplesDataManagerDialogForUCSB_LASS_A; @@ -128,6 +129,7 @@ import org.earthtime.projects.EarthTimeSerializedFileInterface; import org.earthtime.projects.Project; import org.earthtime.projects.projectImporters.ProjectOfLegacySamplesImporterFromCSVFile_GenericUPbIsotopic_A; +import org.earthtime.projects.projectImporters.ProjectOfLegacySamplesImporterFromCSVFile_UCSB_LASS_A; import org.earthtime.ratioDataModels.AbstractRatiosDataModel; import org.earthtime.ratioDataModels.mineralStandardModels.MineralStandardUPbModel; import org.earthtime.utilities.FileHelper; @@ -179,7 +181,7 @@ public class ETReduxFrame extends javax.swing.JFrame implements ReportPainterI, /** * */ - protected JLayeredPane messagePane = null; + protected JLayeredPane announcementPane = null; private final Timer liveUpdateTimer; //// private int DATATABLE_TOP_HEIGHT = 62;//72;//62 private DialogEditor myProjectManager; @@ -222,7 +224,7 @@ public ETReduxFrame( this.myLabData = myLabData; initComponents(); - messagePane = new AnnouncementPane(); + announcementPane = new AnnouncementPane(); // TODO: refactor these things into another init method // load resources @@ -357,7 +359,7 @@ private void changeContentOfTopPanel(ReduxConstants.TOP_PANEL_CONTENTS contents) visitCIRDLESbutton.setFont(ReduxConstants.sansSerif_12_Bold); visitCIRDLESbutton.setBounds(400, 75, 350, 25); visitCIRDLESbutton.addActionListener(new ActionListenerForGotoCirdles()); - messagePane.add(visitCIRDLESbutton); + announcementPane.add(visitCIRDLESbutton); JTextArea announce = new JTextArea(// "ANNOUNCEMENT: 2015 brings changes to this project. "// @@ -370,7 +372,8 @@ private void changeContentOfTopPanel(ReduxConstants.TOP_PANEL_CONTENTS contents) announce.setWrapStyleWord(true); announce.setAlignmentX(CENTER_ALIGNMENT); announce.setAlignmentY(CENTER_ALIGNMENT); - messagePane.add(announce); + announce.setOpaque(true); + announcementPane.add(announce); JButton visitTOPSOIL = new ET_JButton("Checkout Topsoil - the Isoplot replacement project that you can join at github.com/CIRDLES/topsoil"); visitTOPSOIL.setFont(ReduxConstants.sansSerif_12_Bold); @@ -381,7 +384,7 @@ public void actionPerformed(ActionEvent e) { BrowserControl.displayURL("https://github.com/CIRDLES/topsoil"); } }); - messagePane.add(visitTOPSOIL); + announcementPane.add(visitTOPSOIL); JButton releaseNotes = new ET_JButton("Click to see Latest Release Notes."); releaseNotes.setFont(ReduxConstants.sansSerif_10_Bold); @@ -393,11 +396,11 @@ public void actionPerformed(ActionEvent e) { } }); - theFractionTableScrollPane.setViewportView(messagePane); + theFractionTableScrollPane.setViewportView(announcementPane); break; case WAITING: - ((AnnouncementPane) messagePane).initializeAnnouncementPane("Waiting"); - theFractionTableScrollPane.setViewportView(messagePane); + ((AnnouncementPane) announcementPane).initializeAnnouncementPane("Waiting"); + theFractionTableScrollPane.setViewportView(announcementPane); break; case FRACTIONS: theFractionTableScrollPane.setViewportView(theFractionTable); @@ -437,7 +440,7 @@ public boolean askAndSaveReduxPersistentState() { */ public void quickSaveReduxPersistentState() { try { - ETSerializer.SerializeObjectToFile(getMyState(), ReduxPersistentState.getMySerializedName()); + ETSerializer.SerializeObjectToFile(myState, ReduxPersistentState.getMySerializedName()); } catch (ETException eTException) { } @@ -480,12 +483,15 @@ private void sampleMenuOnTrueProjectMenuOnFalse(boolean sampleTrueProjectFalse) isTripolized = superSample.isAnalysisTypeTripolized(); } } + // project open manageProject_menuItem.setEnabled(!sampleTrueProjectFalse && isTripolized); manageRawData_menuItem.setEnabled(!sampleTrueProjectFalse && isTripolized); saveProjectFile_menuItem.setEnabled(!sampleTrueProjectFalse); saveProjectFileAs_menuItem.setEnabled(!sampleTrueProjectFalse); closeProjectFile_menuItem.setEnabled(!sampleTrueProjectFalse); + exportProjectSamples.setEnabled(!sampleTrueProjectFalse); + exportProjectSamplesToGeochron.setEnabled(!sampleTrueProjectFalse); // sample open manageSampleModel_menuItem.setEnabled(sampleTrueProjectFalse); @@ -600,7 +606,7 @@ private boolean checkSavedStatusTheProject() { new String[]{"The current Project " + theProject.getProjectName() + " has been changed.", "Do you want to Save it before proceeding ?" }, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); switch (response) { @@ -627,7 +633,7 @@ private boolean checkSavedStatusTheProject() { private void saveTheProject() throws BadLabDataException { if (theProject != null) { - getMyState().getReduxPreferences().setDefaultSampleAnalysisPurpose(theProject.getAnalysisPurpose()); + myState.getReduxPreferences().setDefaultSampleAnalysisPurpose(theProject.getAnalysisPurpose()); theProject.saveTheProjectAsSerializedReduxFile(); setUpTheProject(false); } @@ -878,6 +884,17 @@ private void exportProjectSamples() { } } + private void exportProjectSamplesToGeochron() { + + theProject.prepareSamplesForExport(); + + // launch manager + DialogEditor geochronProjectExportManager = // + new GeochronProjectExportManager(this, true, theProject, myState); + + geochronProjectExportManager.setVisible(true); + } + // ********* end ***************** P R O J E C T S ****************************** private boolean checkSavedStatusTheSample() { boolean retval = true; @@ -888,7 +905,7 @@ private boolean checkSavedStatusTheSample() { new String[]{"The current Sample " + theSample.getSampleName() + " has been changed.", "Do you want to Save it before proceeding ?" }, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION,//.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); switch (response) { @@ -1206,7 +1223,7 @@ private void saveTheSampleOrProject() throws BadLabDataException { */ private void saveTheSample() throws BadLabDataException { if (theSample != null) { - getMyState().getReduxPreferences().setDefaultSampleAnalysisPurpose(theSample.getAnalysisPurpose()); + myState.getReduxPreferences().setDefaultSampleAnalysisPurpose(theSample.getAnalysisPurpose()); theSample.saveTheSampleAsSerializedReduxFile(); setUpTheSample(false); } @@ -1841,6 +1858,7 @@ private void initComponents() { manageRawData_menuItem = new javax.swing.JMenuItem(); jSeparator5 = new javax.swing.JPopupMenu.Separator(); exportProjectSamples = new javax.swing.JMenuItem(); + exportProjectSamplesToGeochron = new javax.swing.JMenuItem(); jSeparator10 = new javax.swing.JPopupMenu.Separator(); openProjectFile_menuItem = new javax.swing.JMenuItem(); saveProjectFile_menuItem = new javax.swing.JMenuItem(); @@ -1915,6 +1933,7 @@ private void initComponents() { reduxPreferences = new javax.swing.JMenuItem(); templatesForLegacyProjects_menu = new javax.swing.JMenu(); writeCSVFileOfGenericUPbIsotopicLegacyDataSampleFieldNames_A = new javax.swing.JMenuItem(); + writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_A = new javax.swing.JMenuItem(); templatesForLegacySample_menu = new javax.swing.JMenu(); writeCSVFileOfIDTIMSLegacyDataSampleFieldNames_MIT = new javax.swing.JMenuItem(); writeCSVFileOfLAICPMSLegacyDataSampleFieldNames_MC_USA = new javax.swing.JMenuItem(); @@ -2220,13 +2239,23 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { project_menu.add(manageRawData_menuItem); project_menu.add(jSeparator5); - exportProjectSamples.setText("Export Project Samples"); + exportProjectSamples.setText("Export Project Samples to Local Folder"); + exportProjectSamples.setEnabled(false); exportProjectSamples.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exportProjectSamplesActionPerformed(evt); } }); project_menu.add(exportProjectSamples); + + exportProjectSamplesToGeochron.setText("Export Project Samples to Geochron"); + exportProjectSamplesToGeochron.setEnabled(false); + exportProjectSamplesToGeochron.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exportProjectSamplesToGeochronActionPerformed(evt); + } + }); + project_menu.add(exportProjectSamplesToGeochron); project_menu.add(jSeparator10); openProjectFile_menuItem.setText("Open Project File"); @@ -2717,7 +2746,7 @@ public void menuCanceled(javax.swing.event.MenuEvent evt) { } }); - visitCIRDLES.setText("CIRDLES"); + visitCIRDLES.setText("CIRDLES.org"); visitCIRDLES.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { visitCIRDLESActionPerformed(evt); @@ -2733,7 +2762,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); earthTimeWebSiteMenu.add(visitEarthTimeOrg); - visitGeochron.setText("Geochron"); + visitGeochron.setText("Geochron.org"); visitGeochron.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { visitGeochronActionPerformed(evt); @@ -2741,7 +2770,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); earthTimeWebSiteMenu.add(visitGeochron); - visitGeoSamplesOrg.setText("SESAR (IGSN)"); + visitGeoSamplesOrg.setText("SESAR (geoSamples.org)"); visitGeoSamplesOrg.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { visitGeoSamplesOrgActionPerformed(evt); @@ -2771,6 +2800,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); templatesForLegacyProjects_menu.add(writeCSVFileOfGenericUPbIsotopicLegacyDataSampleFieldNames_A); + writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_A.setText("Open CSV File of UPb Isotopic Legacy Data Sample Field Names UCSB LASS (A)"); + writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_A.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_AActionPerformed(evt); + } + }); + templatesForLegacyProjects_menu.add(writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_A); + toolsMenu.add(templatesForLegacyProjects_menu); templatesForLegacySample_menu.setText("Templates for Legacy Data for Single Samples"); @@ -3782,6 +3819,14 @@ private void manageLAICPMSLabDefaultsActionPerformed(java.awt.event.ActionEvent } // TODO add your handling code here: }//GEN-LAST:event_manageLAICPMSLabDefaultsActionPerformed + private void exportProjectSamplesToGeochronActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportProjectSamplesToGeochronActionPerformed + exportProjectSamplesToGeochron(); + }//GEN-LAST:event_exportProjectSamplesToGeochronActionPerformed + + private void writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_AActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_AActionPerformed + ProjectOfLegacySamplesImporterFromCSVFile_UCSB_LASS_A.writeAndOpenCSVFileOfLegacyDataSampleFieldNames(); + }//GEN-LAST:event_writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_AActionPerformed + private void helpMenuItemActionPerformed(java.awt.event.ActionEvent evt) { //Needed for having a nice look in windows... weird ETReduxFrame.setDefaultLookAndFeelDecorated(false); @@ -3822,6 +3867,7 @@ private void helpMenuItemActionPerformed(java.awt.event.ActionEvent evt) { private javax.swing.JSeparator exitSeparator; private javax.swing.JMenuItem exit_menuItem; private javax.swing.JMenuItem exportProjectSamples; + private javax.swing.JMenuItem exportProjectSamplesToGeochron; private javax.swing.JMenu fractionsMenu; private javax.swing.JLayeredPane fractionsTabulatedResultsLayeredPane; private javax.swing.JMenuItem gCubedPaperReductionEquations_menuItem; @@ -3913,6 +3959,7 @@ private void helpMenuItemActionPerformed(java.awt.event.ActionEvent evt) { private javax.swing.JMenuItem writeCSVFileOfLAICPMSLegacyDataSampleFieldNames_NIGL; private javax.swing.JMenuItem writeCSVFileOfLAICPMSLegacyDataSampleFieldNames_SC_WSU_vA; private javax.swing.JMenuItem writeCSVFileOfLAICPMSLegacyDataSampleFieldNames_SC_WSU_vB; + private javax.swing.JMenuItem writeCSVFileOfProjectLegacyDataSampleFieldNames_UCSB_LASS_A; // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/org/earthtime/Tripoli/dataViews/AbstractRawDataView.java b/src/main/java/org/earthtime/Tripoli/dataViews/AbstractRawDataView.java index e0e19dbd..b4d7ff95 100644 --- a/src/main/java/org/earthtime/Tripoli/dataViews/AbstractRawDataView.java +++ b/src/main/java/org/earthtime/Tripoli/dataViews/AbstractRawDataView.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import javax.swing.JLayeredPane; import javax.swing.event.MouseInputListener; +import org.earthtime.ETReduxFrame; import org.earthtime.Tripoli.dataModels.DataModelInterface; import org.earthtime.Tripoli.dataModels.sessionModels.AbstractSessionForStandardDataModel; import org.earthtime.Tripoli.dataViews.dataMonitorViews.AbstractDataMonitorView; @@ -50,7 +51,6 @@ import org.earthtime.Tripoli.fractions.TripoliFractionIncludeChangeInterface; import org.earthtime.Tripoli.sessions.TripoliSessionFractionationCalculatorInterface; import org.earthtime.UPb_Redux.ReduxConstants; -import org.earthtime.ETReduxFrame; import org.earthtime.UPb_Redux.fractions.UPbReduxFractions.UPbFractionI; import org.earthtime.dataDictionaries.DataPresentationModeEnum; import org.earthtime.dataDictionaries.IncludedTypeEnum; @@ -1136,21 +1136,21 @@ public void updateReportTable() { System.out.println("UPDATETABLE ABSTRACTRAWDATA SESSION"); } - if (uPbReduxFrame == null) { - uPbReduxFrame = ((AbstractRawDataView) sampleSessionDataView).getuPbReduxFrame(); - uPbReduxFrame.updateReportTable(true); - } + updateReportTableView(); -// try { -// uPbReduxFrame.updateReportTable(true); -// } catch (Exception e) { -// } if (sampleSessionDataView instanceof AbstractDataMonitorView) { ((AbstractDataMonitorView) sampleSessionDataView).prepareConcordia(); } } + public void updateReportTableView() { + if (uPbReduxFrame == null) { + uPbReduxFrame = ((AbstractRawDataView) sampleSessionDataView).getuPbReduxFrame(); + uPbReduxFrame.updateReportTable(true); + } + } + /** * @return the notShownDueToBelowDetectionFlag */ diff --git a/src/main/java/org/earthtime/Tripoli/dataViews/overlayViews/TripoliSessionRawDataView.java b/src/main/java/org/earthtime/Tripoli/dataViews/overlayViews/TripoliSessionRawDataView.java index 2b553c49..1ac5da08 100644 --- a/src/main/java/org/earthtime/Tripoli/dataViews/overlayViews/TripoliSessionRawDataView.java +++ b/src/main/java/org/earthtime/Tripoli/dataViews/overlayViews/TripoliSessionRawDataView.java @@ -632,7 +632,7 @@ public void preparePanel() { boolean atLeastOneStandard = false; for (int f = 0; f < (fractionCountForHorizontalLayout); f++) {// fractionMap.length; f ++) { - if (fractionMap[f].isStandard()) { + if (fractionMap[f].isStandard() && fractionMap[f].isIncluded()) { // atLeastOneStandard = true; // if ( ! rawDataModelViews[i][f].isNotShownDueToBelowDetectionFlag() ) { atLeastOneStandard = true; diff --git a/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/DataPresentationModeChooserPanel.java b/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/DataPresentationModeChooserPanel.java index 94a6feb2..27910bab 100644 --- a/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/DataPresentationModeChooserPanel.java +++ b/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/DataPresentationModeChooserPanel.java @@ -166,6 +166,9 @@ public void actionPerformed ( ActionEvent e ) { ((TripoliSessionRawDataView) sampleSessionDataView).getTripoliSession().applyMaskingArray(); ((TripoliSessionRawDataView) sampleSessionDataView).getTripoliSession().reFitAllFractions(); + + // jan 2015 force refit after applying shade + ((TripoliSessionRawDataView) sampleSessionDataView).getTripoliSession().calculateSessionFitFunctionsForPrimaryStandard(); ((AbstractRawDataView) sampleSessionDataView).refreshPanel(); diff --git a/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/FractionInfoPanel.java b/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/FractionInfoPanel.java index e9cae6b0..bb7fcb34 100644 --- a/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/FractionInfoPanel.java +++ b/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/FractionInfoPanel.java @@ -33,6 +33,7 @@ import org.earthtime.Tripoli.dataViews.simpleViews.usedByReflection.FitFunctionsOnRatioDataView; import org.earthtime.Tripoli.fractions.TripoliFraction; import org.earthtime.Tripoli.fractions.TripoliFractionIncludeChangeInterface; +import org.earthtime.Tripoli.sessions.TripoliSessionFractionationCalculatorInterface; import org.earthtime.UPb_Redux.fractions.UPbReduxFractions.UPbFractionI; import org.earthtime.beans.ET_JButton; import org.earthtime.utilities.TimeToString; @@ -164,10 +165,16 @@ public void actionPerformed(ActionEvent arg0) { //if ( ! tripoliFraction.isStandard() ) { ((UPbFractionI) tripoliFraction.getuPbFraction()).setRejected(!isSelected); - if (isSelected) { - tripoliFraction.updateInterceptFitFunctionsIncludingCommonLead(); +// if (isSelected) { +// tripoliFraction.updateInterceptFitFunctionsIncludingCommonLead(); +// } + // jan 2015 + if (tripoliFraction.isStandard()) { + ((TripoliSessionFractionationCalculatorInterface) sampleSessionDataView).calculateSessionFitFunctionsForPrimaryStandard(); + updateReportTable(); + } else { + updateReportTableView(); } - updateReportTable(); //} } diff --git a/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/SessionOfStandardView.java b/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/SessionOfStandardView.java index a1a054b2..1a6bad97 100644 --- a/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/SessionOfStandardView.java +++ b/src/main/java/org/earthtime/Tripoli/dataViews/simpleViews/SessionOfStandardView.java @@ -527,6 +527,7 @@ public void actionPerformed(ActionEvent arg0) { ((TripoliSessionFractionationCalculatorInterface) sampleSessionDataView).calculateSessionFitFunctionsForPrimaryStandard(); //((AbstractRawDataView) sampleSessionDataView).refreshPanel(); } catch (Exception e) { + System.out.println(">>>>>>>>>>>>trouble at standard exclude"); } updateReportTable(); ((AbstractRawDataView) sampleSessionDataView).refreshPanel(); @@ -546,6 +547,7 @@ public void actionPerformed(ActionEvent arg0) { ((TripoliSessionFractionationCalculatorInterface) sampleSessionDataView).calculateSessionFitFunctionsForPrimaryStandard(); //((AbstractRawDataView) sampleSessionDataView).refreshPanel(); } catch (Exception e) { + System.out.println(">>>>>>>>>>>>trouble at standard include"); } updateReportTable(); ((AbstractRawDataView) sampleSessionDataView).refreshPanel(); diff --git a/src/main/java/org/earthtime/Tripoli/fractions/TripoliFraction.java b/src/main/java/org/earthtime/Tripoli/fractions/TripoliFraction.java index c393e37b..61bccb30 100644 --- a/src/main/java/org/earthtime/Tripoli/fractions/TripoliFraction.java +++ b/src/main/java/org/earthtime/Tripoli/fractions/TripoliFraction.java @@ -415,14 +415,12 @@ public Matrix calculateUncertaintyPbcCorrections() { } AbstractFunctionOfX FofX = null; -// try { + FofX = ((DataModelFitFunctionInterface) rr).getSelectedFitFunction(); if (FofX != null) { Matrix JacobianYInterceptLogRatioXY = FofX.getMatrixJacobianYInterceptLogRatioXY(); JacobianYInterceptLogRatioAll.setMatrix(totalRatiosUsed, totalRatiosUsed, totalColumnsUsed, totalColumnsUsed + columnsCount - 1, JacobianYInterceptLogRatioXY); } -// } catch (Exception e) { -// } totalColumnsUsed += columnsCount; totalRatiosUsed += 1; } @@ -483,46 +481,6 @@ public int compare(Integer i1, Integer i2) { SlogRatioAll.setMatrix(columnsCount, columnsCount, 0 + 3 * columnsCount, +3 * columnsCount + matrixIndex - 1, Sopbclr_206CorrectedCols); SlogRatioAll.setMatrix(0, 0, matrixIndex + 3 * columnsCount, 2 * matrixIndex + 3 * columnsCount - 1, Sopbclr_207CorrectedCols); - -// // compute the intersection of indices -// ArrayList selectedIndexes = new ArrayList<>(); -// -// int index = 0; -// for (int i = 0; i < rr.getDataActiveMap().length; i++) { -// if (rr.getDataActiveMap()[i] && savedCommonLeadDataActiveMap[i]) { -// selectedIndexes.add(index); -// index++; -// } -// } -// // TODO check for a different count -// // -// // remove rows for below diagonal -// Matrix Sopbclr_206CorrectedRows = new Matrix(selectedIndexes.size(), Sopbclr_206.getColumnDimension(), 0.0); -// Matrix Sopbclr_207CorrectedRows = new Matrix(selectedIndexes.size(), Sopbclr_207.getColumnDimension(), 0.0); -// for (int i = 0; i < selectedIndexes.size(); i++) { -// index = selectedIndexes.get(i); -// Sopbclr_206CorrectedRows.setMatrix(i, i, 0, columnsCount - 1, Sopbclr_206.getMatrix(index, index, 0, columnsCount - 1)); -// Sopbclr_207CorrectedRows.setMatrix(i, i, 0, columnsCount - 1, Sopbclr_207.getMatrix(index, index, 0, columnsCount - 1)); -// } -// -// SlogRatioAll.setMatrix(0 + 3 * columnsCount, selectedIndexes.size() + 3 * columnsCount - 1, 0, columnsCount - 1, Sopbclr_206CorrectedRows); -// SlogRatioAll.setMatrix(0 + 3 * columnsCount, selectedIndexes.size() + 3 * columnsCount - 1, columnsCount, 2 * columnsCount - 1, Sopbclr_206CorrectedRows); -// -// SlogRatioAll.setMatrix(selectedIndexes.size() + 3 * columnsCount, 2 * selectedIndexes.size() + 3 * columnsCount - 1, 0, columnsCount - 1, Sopbclr_207CorrectedRows); -// -// // remove cols for above diagonal -// Matrix Sopbclr_206CorrectedCols = new Matrix(Sopbclr_206.getRowDimension(), selectedIndexes.size(), 0.0); -// Matrix Sopbclr_207CorrectedCols = new Matrix(Sopbclr_207.getRowDimension(), selectedIndexes.size(), 0.0); -// for (int i = 0; i < selectedIndexes.size(); i++) { -// index = selectedIndexes.get(i); -// Sopbclr_206CorrectedCols.setMatrix(0, columnsCount - 1, i, i, Sopbclr_206.getMatrix(0, columnsCount - 1, index, index)); -// Sopbclr_207CorrectedCols.setMatrix(0, columnsCount - 1, i, i, Sopbclr_207.getMatrix(0, columnsCount - 1, index, index)); -// } -// -// SlogRatioAll.setMatrix(0, 0, 0 + 3 * columnsCount, +3 * columnsCount + selectedIndexes.size() - 1, Sopbclr_206CorrectedRows); -// SlogRatioAll.setMatrix(columnsCount, columnsCount, 0 + 3 * columnsCount, +3 * columnsCount + selectedIndexes.size() - 1, Sopbclr_206CorrectedRows); -// -// SlogRatioAll.setMatrix(0, 0, selectedIndexes.size() + 3 * columnsCount, 2 * selectedIndexes.size() + 3 * columnsCount - 1, Sopbclr_207CorrectedRows); } if (rr.getRawRatioModelName().compareTo(RawRatioNames.r208_232w) == 0) { @@ -563,47 +521,12 @@ public int compare(Integer i1, Integer i2) { SlogRatioAll.setMatrix(2 * columnsCount, 3 * columnsCount - 1, 3 * columnsCount + 2 * matrixIndex, 3 * columnsCount + 3 * matrixIndex - 1, Sopbclr_208CorrectedCols); -// Matrix Sopbclr_208 = ((RawRatioDataModel) rr).getTopSopbclr(); -// // compute the intersection of indices -// ArrayList selectedIndexes = new ArrayList<>(); -// -// int index = 0; -// for (int i = 0; i < rr.getDataActiveMap().length; i++) { -// if (rr.getDataActiveMap()[i] && savedCommonLeadDataActiveMap[i]) { -// selectedIndexes.add(index); -// index++; -// } -// } -// -// // TODO check for a different count -// // -// // remove rows for below diagonal -// Matrix Sopbclr_208CorrectedRows = new Matrix(selectedIndexes.size(), Sopbclr_208.getColumnDimension(), 0.0); -// for (int i = 0; i < selectedIndexes.size(); i++) { -// index = selectedIndexes.get(i); -// Sopbclr_208CorrectedRows.setMatrix(i, i, 0, columnsCount - 1, Sopbclr_208.getMatrix(index, index, 0, columnsCount - 1)); -// } -// -// SlogRatioAll.setMatrix(3 * columnsCount + 2 * selectedIndexes.size(), 3 * columnsCount + 3 * selectedIndexes.size() - 1, 2 * columnsCount, 3 * columnsCount - 1, Sopbclr_208CorrectedRows); -// -// // remove cols for above diagonal -// Matrix Sopbclr_208CorrectedCols = new Matrix(Sopbclr_208.getRowDimension(), selectedIndexes.size(), 0.0); -// for (int i = 0; i < selectedIndexes.size(); i++) { -// index = selectedIndexes.get(i); -// Sopbclr_208CorrectedCols.setMatrix(0, columnsCount - 1, i, i, Sopbclr_208.getMatrix(0, columnsCount - 1, index, index)); -// } -// -// SlogRatioAll.setMatrix(2 * columnsCount, 3 * columnsCount - 1, 3 * columnsCount + 2 * selectedIndexes.size(), 3 * columnsCount + 3 * selectedIndexes.size() - 1, Sopbclr_208CorrectedCols); } } Matrix Sfci = JacobianYInterceptLogRatioAll.times(SlogRatioAll).times(JacobianYInterceptLogRatioAll.transpose()); - // moved here from abstractmassspecu Nov 2014 -// for (DataModelInterface rr : rawRatios) { -//////// ((DataModelFitFunctionInterface) rr).cleanupUnctCalcs(); -// } System.gc(); return Sfci; @@ -619,6 +542,12 @@ public void toggleAllData(boolean included) { for (int i = 0; i < dataActiveMap.length; i++) { toggleOneDataAquisition(i, included); } + + // jan 2015 + // force masking array + if (included) { + applyMaskingArray(); + } } /** diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/AbstractRawDataFileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/AbstractRawDataFileHandler.java index f3c9fe8d..a54c8b2f 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/AbstractRawDataFileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/AbstractRawDataFileHandler.java @@ -398,7 +398,7 @@ public ArrayList parseFractionsIntoSamples() { Iterator sampleFractionsIterator = sampleFractions.iterator(); // save off the standards - SortedSet standardsToMoveMap = new TreeSet(); + SortedSet standardsToMoveMap = new TreeSet<>(); while (sampleFractionsIterator.hasNext()) { tf = sampleFractionsIterator.next(); diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/KoslerAgilent7700FileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/KoslerAgilent7700FileHandler.java index 2b2a35ce..f8058454 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/KoslerAgilent7700FileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/KoslerAgilent7700FileHandler.java @@ -30,7 +30,7 @@ import org.earthtime.Tripoli.fractions.TripoliFraction; import org.earthtime.Tripoli.sessions.TripoliSessionInterface; import org.earthtime.utilities.FileHelper; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * @@ -121,7 +121,7 @@ public boolean accept(File dir, String name) { JOptionPane.showMessageDialog( null, new String[]{"Selected raw data folder does not contain valid files."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); rawDataFile = null; diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/LaserchronElement2SingleCollFileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/LaserchronElement2SingleCollFileHandler.java index 04041a23..ca5adce4 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/LaserchronElement2SingleCollFileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/LaserchronElement2SingleCollFileHandler.java @@ -27,7 +27,7 @@ import org.earthtime.Tripoli.fractions.TripoliFraction; import org.earthtime.Tripoli.sessions.TripoliSessionInterface; import org.earthtime.utilities.FileHelper; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * @@ -119,7 +119,7 @@ public boolean accept(File dir, String name) { JOptionPane.showMessageDialog( null, new String[]{"Selected raw data folder does not contain valid files."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); rawDataFile = null; diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayFileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayFileHandler.java index bd82c541..2e03a805 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayFileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayFileHandler.java @@ -47,7 +47,7 @@ import org.earthtime.UPb_Redux.filters.txtFileFilter; import org.earthtime.utilities.FileHelper; import org.earthtime.utilities.TimeToString; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * @@ -185,7 +185,7 @@ public int compare(File f1, File f2) { JOptionPane.showMessageDialog( null, new String[]{"Selected raw data file was not valid."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } @@ -321,7 +321,7 @@ protected boolean loadDataSetupParametersFromRawDataFileHeader(AbstractAcquisiti JOptionPane.showMessageDialog( null, new String[]{"Selected raw data file was not valid."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); retVal = false; diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayTRAFileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayTRAFileHandler.java index b4fb0c39..0a885be4 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayTRAFileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollFaradayTRAFileHandler.java @@ -44,7 +44,7 @@ import org.earthtime.UPb_Redux.filters.txtFileFilter; import org.earthtime.utilities.FileHelper; import org.earthtime.utilities.TimeToString; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * @@ -68,8 +68,10 @@ public NUPlasmaMultiCollFaradayTRAFileHandler() { NAME = "NU Plasma MC Faraday TRA File"; - aboutInfo = "Details: This is the default protocol for handling files produced at the Arizona Laserchron Center "// - + " for Faraday analysis on the NU-Plasma with TRA (time-resolved analysis.) "; + aboutInfo = "Details: This is the default protocol for handling files produced at "// + + "the Arizona Laserchron Center "// + + "for Faraday analysis on the NU-Plasma with TRA (time-resolved analysis.) "// + + "Pattern of aquisitions dated 21 July 2014."; } @@ -184,7 +186,7 @@ public File validateAndGetHeaderDataFromRawIntensityFile(File tripoliRawDataFold JOptionPane.showMessageDialog( null, new String[]{"Selected raw data file was not valid."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } @@ -247,6 +249,7 @@ public boolean isStandardFractionID(String fractionID) { /** * * @param acquisitionModel + * @return */ protected boolean loadDataSetupParametersFromRawDataFileHeader(AbstractAcquisitionModel acquisitionModel) { boolean retVal = true; @@ -263,7 +266,7 @@ protected boolean loadDataSetupParametersFromRawDataFileHeader(AbstractAcquisiti // OCT 2012 // customize massspec setup for this data aquisition // extract gains and deadtimes - String[] headerDetails = headerData[0].trim().split("\n"); +// String[] headerDetails = headerData[0].trim().split("\n"); // // march 2014 to handle possible tab delimiters such as 20 analysis runs // String gainsPass1 = headerDetails[1].split(":")[1]; @@ -295,7 +298,7 @@ protected boolean loadDataSetupParametersFromRawDataFileHeader(AbstractAcquisiti // String[] deadTimes = headerDetails[3].split(":")[1].split(dataDelimiter); // build gains models Map collectorNameToDeadTimesMap = new TreeMap<>(); - for (int i = 0; i < NUPlasmaCollectorsEnum.getIonCounterCollectorNames().length; i++) { + for (String ionCounterCollectorName : NUPlasmaCollectorsEnum.getIonCounterCollectorNames()) { double deadTime = 0.0; // try { // deadTime = Double.valueOf(deadTimes[i + 1]); @@ -303,8 +306,8 @@ protected boolean loadDataSetupParametersFromRawDataFileHeader(AbstractAcquisiti // } // in order try { - collectorNameToDeadTimesMap.put(NUPlasmaCollectorsEnum.getIonCounterCollectorNames()[i], deadTime); - } catch (Exception e) { + collectorNameToDeadTimesMap.put(ionCounterCollectorName, deadTime); + }catch (Exception e) { } } @@ -320,7 +323,7 @@ protected boolean loadDataSetupParametersFromRawDataFileHeader(AbstractAcquisiti JOptionPane.showMessageDialog( null, new String[]{"Selected raw data file was not valid."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); retVal = false; @@ -400,39 +403,44 @@ protected SortedSet loadRawDataFile(SwingWorker loadDataTask, b final int limit = ((100 * (i)) / (rawAcquisitions.length)); loadDataTask.firePropertyChange("progress", 0, limit); + // this hard-wired specification from the lab dated july 21 2014 if (fractionCounter < 133) { String[] rawIntensities = rawAcquisitions[i].split(","); double i238 = Double.parseDouble(rawIntensities[0]); boolean isStandard = false; if (fractionCounter < 5) { isStandard = true; - } else if (fractionCounter == 124) { + } else if (((fractionCounter - 4) % 6) == 0){// (fractionCounter == 124) { isStandard = true; - } else if (fractionCounter > 129) { + } else if (fractionCounter >= 130) { isStandard = true; } - // test if have pair of background and peak = comppleted fraction + // test if have pair of background and peak = completed fraction if (readingPeaks && (i238 <= 0.001)) { // process new fraction and reset data collectors ************* int readCountBackgroundAcquisitions = backgroundAcquisitions.size(); int readCountPeakAcquisitions = peakAcquisitions.size(); // trim front and back of data - for (int c = 0; c < 15; c++) { + int trimCountFront = 5; + for (int c = 0; c < trimCountFront; c++) { backgroundAcquisitions.remove(0); peakAcquisitions.remove(0); } - for (int c = 0; c < 15; c++) { + int trimCountBack =15; + for (int c = 0; c < trimCountBack; c++) { backgroundAcquisitions.remove(backgroundAcquisitions.size() - 1); peakAcquisitions.remove(peakAcquisitions.size() - 1); } System.out.println("read in fraction " + fractionCounter + " " + backgroundAcquisitions.size() + " " + peakAcquisitions.size()); - String theFractionID = sampleRunName + "-" + String.valueOf(fractionCounter); + String theFractionID; if (isStandard) { - theFractionID += "-STD"; + theFractionID = sampleRunName + "-STD." + String.valueOf(fractionCounter); + } else { + theFractionID = sampleRunName + "-" + String.valueOf(fractionCounter); } // nov 2014 broke into steps to provide cleaner logic diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollIonCounterFileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollIonCounterFileHandler.java index 9d545fbb..42e33b3e 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollIonCounterFileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/NUPlasmaMultiCollIonCounterFileHandler.java @@ -39,7 +39,7 @@ import org.earthtime.UPb_Redux.filters.txtFileFilter; import org.earthtime.utilities.FileHelper; import org.earthtime.utilities.TimeToString; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * @@ -107,7 +107,7 @@ public File validateAndGetHeaderDataFromRawIntensityFile(File tripoliRawDataFold JOptionPane.showMessageDialog( null, new String[]{"Selected raw data file was not valid."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } @@ -236,7 +236,7 @@ protected boolean loadDataSetupParametersFromRawDataFileHeader(AbstractAcquisiti JOptionPane.showMessageDialog( null, new String[]{"Selected raw data file was not valid."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); retVal = false; diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/RittnerAgilent7700FileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/RittnerAgilent7700FileHandler.java index b7d75bdd..9cee4d56 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/RittnerAgilent7700FileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/RittnerAgilent7700FileHandler.java @@ -29,7 +29,7 @@ import javax.swing.SwingWorker; import org.earthtime.Tripoli.fractions.TripoliFraction; import org.earthtime.utilities.FileHelper; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * @@ -127,7 +127,7 @@ public boolean accept(File dir, String name) { JOptionPane.showMessageDialog( null, new String[]{"Selected raw data folder does not contain valid files."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); rawDataFile = null; diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/WashStateElement2SingleCollFileHandler.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/WashStateElement2SingleCollFileHandler.java index 5688d4c4..5412f523 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/WashStateElement2SingleCollFileHandler.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/handlers/WashStateElement2SingleCollFileHandler.java @@ -27,7 +27,7 @@ import org.earthtime.Tripoli.fractions.TripoliFraction; import org.earthtime.Tripoli.sessions.TripoliSessionInterface; import org.earthtime.utilities.FileHelper; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * @@ -120,7 +120,7 @@ public boolean accept(File dir, String name) { JOptionPane.showMessageDialog( null, new String[]{"Selected raw data folder does not contain valid files."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); rawDataFile = null; diff --git a/src/main/java/org/earthtime/Tripoli/rawDataFiles/templates/NUPlasmaMultiCollFaradayTRARawDataTemplate.java b/src/main/java/org/earthtime/Tripoli/rawDataFiles/templates/NUPlasmaMultiCollFaradayTRARawDataTemplate.java index 1f043890..9c9ddd5b 100644 --- a/src/main/java/org/earthtime/Tripoli/rawDataFiles/templates/NUPlasmaMultiCollFaradayTRARawDataTemplate.java +++ b/src/main/java/org/earthtime/Tripoli/rawDataFiles/templates/NUPlasmaMultiCollFaradayTRARawDataTemplate.java @@ -48,7 +48,7 @@ private NUPlasmaMultiCollFaradayTRARawDataTemplate () { this.blockStartOffset = 0; // not used this.blockSize = 0;// determined from data values; not constant this.standardIDs = new String[]// - {"SL"}; + {"SL","R33"}; this.timeZone = TimeZone.getTimeZone( "MST" ); this.defaultParsingOfFractionsBehavior = 1; diff --git a/src/main/java/org/earthtime/UPb_Redux/aliquots/UPbReduxAliquot.java b/src/main/java/org/earthtime/UPb_Redux/aliquots/UPbReduxAliquot.java index 37961547..4195274a 100644 --- a/src/main/java/org/earthtime/UPb_Redux/aliquots/UPbReduxAliquot.java +++ b/src/main/java/org/earthtime/UPb_Redux/aliquots/UPbReduxAliquot.java @@ -78,7 +78,7 @@ import org.earthtime.ratioDataModels.physicalConstantsModels.PhysicalConstantsModelXMLConverter; import org.earthtime.ratioDataModels.tracers.TracerUPbModel; import org.earthtime.ratioDataModels.tracers.TracerUPbModelXMLConverter; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/concordia/ConcordiaGraphPanel.java b/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/concordia/ConcordiaGraphPanel.java index 14f71905..f054b44b 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/concordia/ConcordiaGraphPanel.java +++ b/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/concordia/ConcordiaGraphPanel.java @@ -497,7 +497,7 @@ public void paint(Graphics2D g2d, boolean svgStyle) { for (Fraction f : excludedFractions) { if (!((UPbFractionI) f).isRejected() && !(isDisplay_PbcCorr() && !((UPbFractionI) f).isCommonLeadLossCorrected())) { // determine aliquot for colors etc. - String aliquotName = sample.getAliquotByNumber(((UPbFractionI) f).getAliquotNumber()).getAliquotName(); + String aliquotName = sample.getNameOfAliquotFromSample(((UPbFractionI) f).getAliquotNumber()); Map myAliquotOptions = getAliquotOptions().get(aliquotName); Color excludedFillColor = new Color(255, 255, 255); @@ -535,7 +535,7 @@ public void paint(Graphics2D g2d, boolean svgStyle) { for (Fraction f : excludedFractions) { if (!((UPbFractionI) f).isRejected() && !(isDisplay_PbcCorr() && !((UPbFractionI) f).isCommonLeadLossCorrected())) { // determine aliquot for colors etc. - String aliquotName = sample.getAliquotByNumber(((UPbFractionI) f).getAliquotNumber()).getAliquotName(); + String aliquotName = sample.getNameOfAliquotFromSample(((UPbFractionI) f).getAliquotNumber()); Map myAliquotOptions = getAliquotOptions().get(aliquotName); float excludedBorderWeight = 1.5f; @@ -583,7 +583,7 @@ public void paint(Graphics2D g2d, boolean svgStyle) { for (Fraction f : selectedFractions) { if (!((UPbFractionI) f).isRejected() && !(isDisplay_PbcCorr() && !((UPbFractionI) f).isCommonLeadLossCorrected())) { // determine aliquot for colors etc. - String aliquotName = sample.getAliquotByNumber(((UPbFractionI) f).getAliquotNumber()).getAliquotName(); + String aliquotName = sample.getNameOfAliquotFromSample(((UPbFractionI) f).getAliquotNumber()); Map myAliquotOptions = (Map) getAliquotOptions().get(aliquotName); Color includedFillColor = new Color(255, 255, 255); @@ -623,7 +623,7 @@ public void paint(Graphics2D g2d, boolean svgStyle) { for (Fraction f : selectedFractions) { if (!((UPbFractionI) f).isRejected() && !(isDisplay_PbcCorr() && !((UPbFractionI) f).isCommonLeadLossCorrected())) { // determine aliquot for colors etc. - String aliquotName = sample.getAliquotByNumber(((UPbFractionI) f).getAliquotNumber()).getAliquotName(); + String aliquotName = sample.getNameOfAliquotFromSample(((UPbFractionI) f).getAliquotNumber()); Map myAliquotOptions = getAliquotOptions().get(aliquotName); float includedBorderWeight = 1.5f; @@ -3077,7 +3077,7 @@ public void setCurrentGraphAxesSetup(GraphAxesSetup currentGraphAxesSetup) { currentGraphAxesSetup.setLambda238(lambda238.getValue().doubleValue()); currentGraphAxesSetup.setDefaultR238_235s( // - getSample().getMyReduxLabData().getDefaultR238_235s().getValue().doubleValue()); + sample.getMyReduxLabData().getDefaultR238_235s().getValue().doubleValue()); } /** diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/DialogEditor.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/DialogEditor.java index 983a38f6..1dc10499 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/DialogEditor.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/DialogEditor.java @@ -277,7 +277,9 @@ public void insertString(int offset, try { double tempVal = Double.parseDouble(newValue); - if ((maxValue > 0.0)){//jan 2014 removed positive constraint && (tempVal > maxValue)) { +// if ((maxValue > 0.0)){//jan 2014 removed positive constraint && (tempVal > maxValue)) { + // jan 2015 repalced to original + if ((maxValue > 0.0) && (tempVal > maxValue)) { string = Double.toString(maxValue); offset = 0; textF.setText(""); diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/LabDataEditorDialog.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/LabDataEditorDialog.java index eb9cc049..fd2d5288 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/LabDataEditorDialog.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/LabDataEditorDialog.java @@ -416,7 +416,7 @@ private synchronized boolean checkIsSavedStatusOfTracerModelEdit() int response = JOptionPane.showConfirmDialog(this, new String[]{"You have not saved the edited Tracer UPb Model ... Proceed anyway ?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); retval = (response == JOptionPane.YES_OPTION); @@ -543,7 +543,7 @@ private synchronized void readAndRegisterTracerModel(File returnFile) { JOptionPane.showConfirmDialog( null, new String[]{"This Tracer could not be imported...please confirm it conforms to the schema."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } @@ -731,7 +731,7 @@ private synchronized boolean CheckIsSavedStatusOfAlphaUModelEdit() //setVisible(false); int response = JOptionPane.showConfirmDialog(this, new String[]{"You have not saved the edited Alpha U Model ... Proceed anyway ?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); retval = (response == JOptionPane.YES_OPTION); @@ -869,7 +869,7 @@ private synchronized void ReadAndRegisterAlphaUModel(File returnFile) { = JOptionPane.showConfirmDialog( null, new String[]{"This AlphaUModel could not be imported...please confirm it conforms to the schema."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } @@ -1016,7 +1016,7 @@ private synchronized boolean CheckIsSavedStatusOfAlphaPbModelEdit() //setVisible(false); int response = JOptionPane.showConfirmDialog(this, new String[]{"You have not saved the edited Alpha U Model ... Proceed anyway ?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); retval = (response == JOptionPane.YES_OPTION); @@ -1309,7 +1309,7 @@ private synchronized boolean checkIsSavedStatusOfPbBlankModelEdit() int response = JOptionPane.showConfirmDialog(this, new String[]{"You have not saved the new Pb Blank Model ... Proceed anyway?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); retval = (response == JOptionPane.YES_OPTION); @@ -1438,7 +1438,7 @@ private synchronized void readAndRegisterPbBlankModel(File returnFile) { JOptionPane.showConfirmDialog( null, new String[]{"This PbBlank Model could not be imported...please confirm it conforms to the schema."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } @@ -1625,7 +1625,7 @@ private synchronized boolean checkIsSavedStatusOfInitialPbModelEdit() if (newEmptyInitialPbModel != null) { int response = JOptionPane.showConfirmDialog(this, new String[]{"You have not saved the new Initial Pb Model ... Proceed anyway?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); retval = (response == JOptionPane.YES_OPTION); @@ -1767,7 +1767,7 @@ private synchronized void readAndRegisterInitialPbModel(File returnFile) { JOptionPane.showConfirmDialog( null, new String[]{"This Initial Pb Model could not be imported...please confirm it conforms to the schema."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } @@ -1916,7 +1916,7 @@ private synchronized boolean checkIsSavedStatusOfPhysicalConstantsModelEdit() int response = JOptionPane.showConfirmDialog(this, new String[]{"You have not saved the edited Physical Constants Model ... Proceed anyway ?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); retval = (response == JOptionPane.YES_OPTION); @@ -2183,7 +2183,7 @@ private synchronized boolean checkIsSavedStatusOfMineralStandardModelEdit() int response = JOptionPane.showConfirmDialog(this, new String[]{"You have not saved the new Mineral Standard Model ... Proceed anyway?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); retval = (response == JOptionPane.YES_OPTION); @@ -2315,7 +2315,7 @@ private synchronized void readAndRegisterMineralStandardModel(File returnFile) { JOptionPane.showConfirmDialog( null, new String[]{"This Mineral Standard could not be imported...please confirm it conforms to the schema."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.form b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.form index a1c03e32..b18748ca 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.form +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.form @@ -86,8 +86,8 @@ - - + + diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.java index 6f492b54..b9aa272a 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorDialog.java @@ -33,18 +33,13 @@ import java.awt.event.ItemListener; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.math.RoundingMode; -import java.net.URL; -import java.net.URLEncoder; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; @@ -52,8 +47,6 @@ import java.util.Scanner; import java.util.Set; import java.util.Vector; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; import javax.imageio.ImageIO; import javax.swing.AbstractAction; import javax.swing.AbstractButton; @@ -73,8 +66,6 @@ import javax.swing.event.ChangeListener; import javax.swing.filechooser.FileFilter; import javax.swing.text.JTextComponent; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.earthtime.ETReduxFrame; import org.earthtime.UPb_Redux.ReduxConstants; @@ -100,10 +91,13 @@ import org.earthtime.UPb_Redux.reports.reportViews.TabbedReportViews; import org.earthtime.UPb_Redux.samples.Sample; import org.earthtime.UPb_Redux.utilities.BrowserControl; -import org.earthtime.UPb_Redux.utilities.ClientHttpRequest; import org.earthtime.UPb_Redux.utilities.Thumbnail; import org.earthtime.UPb_Redux.utilities.UPbReduxFocusTraversalPolicy; import org.earthtime.UPb_Redux.valueModels.ValueModel; +import org.earthtime.archivingTools.GeochronUploadImagesHelper; +import org.earthtime.archivingTools.GeochronUploaderUtility; +import org.earthtime.archivingTools.IEDACredentialsValidator; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.dataDictionaries.AnalysisImageTypes; import org.earthtime.dataDictionaries.AnalysisMeasures; import org.earthtime.dataDictionaries.DataDictionary; @@ -119,15 +113,12 @@ import org.earthtime.ratioDataModels.mineralStandardModels.MineralStandardUPbModel; import org.earthtime.ratioDataModels.tracers.TracerUPbModel; import org.earthtime.utilities.FileHelper; -import org.earthtime.utilities.GeochronUploadImagesHelper; -import org.earthtime.utilities.URIHelper; import org.earthtime.xmlUtilities.SimpleTransform; import org.jdesktop.layout.GroupLayout.ParallelGroup; import org.jdesktop.layout.GroupLayout.SequentialGroup; import org.w3c.dom.DOMException; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; /** * @@ -1242,8 +1233,8 @@ public void windowClosing(java.awt.event.WindowEvent evt) { title_panel.add(aliquotName_text, new org.netbeans.lib.awtextra.AbsoluteConstraints(55, 5, 172, -1)); SampleIGSN_label.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N - SampleIGSN_label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); - SampleIGSN_label.setText("Sample Identifier:"); + SampleIGSN_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + SampleIGSN_label.setText("Sample IGSN:"); title_panel.add(SampleIGSN_label, new org.netbeans.lib.awtextra.AbsoluteConstraints(233, 0, 60, 38)); analystName_label.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N @@ -1908,7 +1899,7 @@ public void actionPerformed(ActionEvent e) { = JOptionPane.showConfirmDialog( null, new String[]{"You must first save the Aliquot ... proceed?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); if (result == JOptionPane.OK_OPTION) { proceed = true; @@ -2203,7 +2194,7 @@ protected void initAliquot() { // JOptionPane.showMessageDialog( // null, // new String[]{"Duplicate Fraction ID, please use another."}, -// "U-Pb Redux Warning", +// "ET Redux Warning", // JOptionPane.WARNING_MESSAGE); // // } else { @@ -4639,16 +4630,18 @@ public void adjustmentValueChanged(AdjustmentEvent evt) { */ private void validateGeochronCredentials(boolean isVerbose) { + String userCode = ""; boolean valid; try { - valid = ((ETReduxFrame) parent).getMyState().validateGeochronCredentials(// + userCode = IEDACredentialsValidator.validateGeochronCredentials(// geochronUserName_text.getText().trim(),// new String(geochronPassword_passwordField.getPassword()), isVerbose); } catch (Exception e) { valid = false; } + valid = (userCode.trim().length() > 0); showArchiveNote(getMyAliquot(), valid); if (valid) { @@ -4871,92 +4864,101 @@ public void uploadAliquotToGeochronZip() throws ETException { saveAliquot(); // proceed with upload of Aliquot - String content = getMyAliquot().serializeXMLObject(); - // Construct data - // June 2010 added overwrite and public choices - String isPublic = geochronPublicRecord_chkBox.isSelected() ? "yes" : "no"; - String overWrite = geochronOverwrite_chkBox.isSelected() ? "yes" : "no"; - try { - data - = URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(userName, "UTF-8"); - data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"); - data += "&" + URLEncoder.encode("public", "UTF-8") + "=" + URLEncoder.encode(isPublic, "UTF-8"); - data += "&" + URLEncoder.encode("content", "UTF-8") + "=" + URLEncoder.encode(content, "UTF-8"); - data += "&" + URLEncoder.encode("overwrite", "UTF-8") + "=" + URLEncoder.encode(overWrite, "UTF-8"); - } catch (UnsupportedEncodingException unsupportedEncodingException) { - } - - // april 2009 move to zipping for improved upload performance - // http://www.exampledepot.com/egs/java.util.zip/CreateZip.html - // These are the files to include in the ZIP file - // geochron expects this file name exactly - String fileName = "tempDataForAliquotUpload"; - - // Create a buffer for reading the files - byte[] buf = new byte[2048]; - - try { - // Create the ZIP file - String outFilename = "tempDataForAliquotUploadzip"; - ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename)); - - // Compress the file - //FileInputStream in = new FileInputStream(fileName); - InputStream in = new ByteArrayInputStream(data.getBytes()); - - // Add ZIP entry to output stream. - out.putNextEntry(new ZipEntry(fileName)); - - // Transfer bytes from the file to the ZIP file - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - - // Complete the entry - out.closeEntry(); - in.close(); - - // Complete the ZIP file - out.close(); - } catch (IOException e) { - } - - File uploadFile = new File("tempDataForAliquotUploadzip"); - - InputStream response = null; - try { - response = ClientHttpRequest.post(// - new URL("http://www.geochron.org/redux_service.php"),// - "filetoupload", - uploadFile); - } catch (IOException iOException) { - } - - org.w3c.dom.Document doc = null; - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(false); - try { - doc = factory.newDocumentBuilder().parse(response); - } catch (ParserConfigurationException | SAXException | IOException parserConfigurationException) { - } - - String error = "no"; - String message = ""; - if (doc != null) { - if (doc.getElementsByTagName("error").getLength() > 0) { - error = doc.getElementsByTagName("error").item(0).getTextContent(); - message = doc.getElementsByTagName("message").item(0).getTextContent(); - } - } - - sample.setArchivedInRegistry(error.equalsIgnoreCase("no")); - - JOptionPane.showMessageDialog(this, - new String[]{ - !error.equalsIgnoreCase("no") ? "Failure!\n" : "Success!\n", - message + " " + myAliquot.getSampleIGSN() + "::" + myAliquot.getAliquotName() - }); + // feb 2015 refactored to another class + GeochronUploaderUtility.uploadAliquotToGeochron(// + sample, myAliquot, // + userName, // + password, // + geochronPublicRecord_chkBox.isSelected(), // + geochronOverwrite_chkBox.isSelected()); + +//// String content = ((UPbReduxAliquot)myAliquot).serializeXMLObject(); +//// // Construct data +//// // June 2010 added overwrite and public choices +//// String isPublic = geochronPublicRecord_chkBox.isSelected() ? "yes" : "no"; +//// String overWrite = geochronOverwrite_chkBox.isSelected() ? "yes" : "no"; +//// +//// try { +//// data +//// = URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(userName, "UTF-8"); +//// data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"); +//// data += "&" + URLEncoder.encode("public", "UTF-8") + "=" + URLEncoder.encode(isPublic, "UTF-8"); +//// data += "&" + URLEncoder.encode("content", "UTF-8") + "=" + URLEncoder.encode(content, "UTF-8"); +//// data += "&" + URLEncoder.encode("overwrite", "UTF-8") + "=" + URLEncoder.encode(overWrite, "UTF-8"); +//// } catch (UnsupportedEncodingException unsupportedEncodingException) { +//// } +//// +//// // april 2009 move to zipping for improved upload performance +//// // http://www.exampledepot.com/egs/java.util.zip/CreateZip.html +//// // These are the files to include in the ZIP file +//// // geochron expects this file name exactly +//// String fileName = "tempDataForAliquotUpload"; +//// +//// // Create a buffer for reading the files +//// byte[] buf = new byte[2048]; +//// +//// try { +//// // Create the ZIP file +//// String outFilename = "tempDataForAliquotUploadzip"; +//// ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename)); +//// +//// // Compress the file +//// //FileInputStream in = new FileInputStream(fileName); +//// InputStream in = new ByteArrayInputStream(data.getBytes()); +//// +//// // Add ZIP entry to output stream. +//// out.putNextEntry(new ZipEntry(fileName)); +//// +//// // Transfer bytes from the file to the ZIP file +//// int len; +//// while ((len = in.read(buf)) > 0) { +//// out.write(buf, 0, len); +//// } +//// +//// // Complete the entry +//// out.closeEntry(); +//// in.close(); +//// +//// // Complete the ZIP file +//// out.close(); +//// } catch (IOException e) { +//// } +//// +//// File uploadFile = new File("tempDataForAliquotUploadzip"); +//// +//// InputStream response = null; +//// try { +//// response = ClientHttpRequest.post(// +//// new URL("http://www.geochron.org/redux_service.php"),// +//// "filetoupload", +//// uploadFile); +//// } catch (IOException iOException) { +//// } +//// +//// org.w3c.dom.Document doc = null; +//// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); +//// factory.setValidating(false); +//// try { +//// doc = factory.newDocumentBuilder().parse(response); +//// } catch (ParserConfigurationException | SAXException | IOException parserConfigurationException) { +//// } +//// +//// String error = "no"; +//// String message = ""; +//// if (doc != null) { +//// if (doc.getElementsByTagName("error").getLength() > 0) { +//// error = doc.getElementsByTagName("error").item(0).getTextContent(); +//// message = doc.getElementsByTagName("message").item(0).getTextContent(); +//// } +//// } +//// +//// sample.setArchivedInRegistry(error.equalsIgnoreCase("no")); +//// +//// JOptionPane.showMessageDialog(this, +//// new String[]{ +//// !error.equalsIgnoreCase("no") ? "Failure!\n" : "Success!\n", +//// message + " " + myAliquot.getSampleIGSN() + "::" + myAliquot.getAliquotName() +//// }); } diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorForLAICPMS.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorForLAICPMS.java index c6a04f46..2b2f1728 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorForLAICPMS.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotEditorForLAICPMS.java @@ -263,7 +263,7 @@ public void initAliquot() { // JOptionPane.showMessageDialog( // null, // new String[]{"Duplicate Fraction ID, please use another."}, -// "U-Pb Redux Warning", +// "ET Redux Warning", // JOptionPane.WARNING_MESSAGE ); // // } else { @@ -858,7 +858,7 @@ public void actionPerformed(ActionEvent e) { = JOptionPane.showConfirmDialog( null, new String[]{"You must first save the Aliquot ... proceed?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); if (result == JOptionPane.OK_OPTION) { proceed = true; diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForIDTIMS.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForIDTIMS.java index a9df9724..5d6936d9 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForIDTIMS.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForIDTIMS.java @@ -1105,7 +1105,7 @@ public void actionPerformed ( ActionEvent e ) { JOptionPane.showConfirmDialog( null, new String[]{"You must first save the Aliquot ... proceed?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE ); if ( result == JOptionPane.OK_OPTION ) { proceed = true; diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForLAICPMS.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForLAICPMS.java index 684f5b47..2c1ce88a 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForLAICPMS.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/aliquotManagers/AliquotLegacyEditorForLAICPMS.java @@ -267,7 +267,7 @@ public void initAliquot () { // JOptionPane.showMessageDialog( // null, // new String[]{"Duplicate Fraction ID, please use another."}, -// "U-Pb Redux Warning", +// "ET Redux Warning", // JOptionPane.WARNING_MESSAGE ); // // } else { @@ -884,7 +884,7 @@ public void actionPerformed ( ActionEvent e ) { JOptionPane.showConfirmDialog( null, new String[]{"You must first save the Aliquot ... proceed?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE ); if ( result == JOptionPane.OK_OPTION ) { proceed = true; diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbFractionEditorDialog.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbFractionEditorDialog.java index 0df143f2..202a63b4 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbFractionEditorDialog.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbFractionEditorDialog.java @@ -52,8 +52,8 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.filechooser.FileFilter; -import org.earthtime.UPb_Redux.ReduxConstants; import org.earthtime.ETReduxFrame; +import org.earthtime.UPb_Redux.ReduxConstants; import org.earthtime.UPb_Redux.aliquots.Aliquot; import org.earthtime.UPb_Redux.aliquots.UPbReduxAliquot; import org.earthtime.UPb_Redux.beans.ValueModelClump; @@ -185,8 +185,10 @@ public UPbFractionEditorDialog( showDates = new boolean[]{true, true, true}; // inAutoUraniumMode = false; - ((UPbFraction) myFraction).setInAutoUraniumMode(false); - + try { + ((UPbFraction) myFraction).setInAutoUraniumMode(false); + } catch (Exception e) { + } initComponents(); toggleStartStopLiveUpdate_button.setText(((ETReduxFrame) parent).getupdateSample_buttonText()); @@ -218,7 +220,7 @@ public UPbFractionEditorDialog( } // add the not-rejected fractions for (Fraction f : ((UPbReduxAliquot) aliquot).getAliquotFractions()) { - if (!((UPbFraction) f).isRejected()) { + if (!((UPbFractionI) f).isRejected()) { fraction_Chooser.addItem(f); } } @@ -250,9 +252,11 @@ public void actionPerformed(ActionEvent e) { } // reset input estimated age for auto uranium mode to date 207/206 - ((UPbFraction) myFraction).// - setInputDate206_238r(myFraction.getRadiogenicIsotopeDateByName(RadDates.age207_206r).getValue()); - + try { + ((UPbFraction) myFraction).// + setInputDate206_238r(myFraction.getRadiogenicIsotopeDateByName(RadDates.age207_206r).getValue()); + } catch (Exception e) { + } InitializeFractionData(myFraction); // fraction_Chooser.setSelectedItem( myFraction ); @@ -278,7 +282,7 @@ public void InitializeFractionData(final Fraction myFraction) { // if this is an added default fraction, the isdeleted field is true and // hence we do not need the button active - delete_button.setEnabled(!((UPbFraction) myFraction).isDeleted() && !isCompiled()); + delete_button.setEnabled(!((UPbFractionI) myFraction).isDeleted() && !isCompiled()); InitializeTextBoxes(myFraction); showSavedData(myFraction); @@ -1006,15 +1010,13 @@ private void InitializeTextBoxes(final Fraction myFraction) { // Determine whether the Pb and U data are editable based on presence of source files // April 2009 decided to make this more restrictive boolean editablePb - = !((UPbFraction) myFraction).hasXMLPbSourceFile() - && //(((UPbFraction) myFraction).getMeanAlphaPb().compareTo(BigDecimal.ZERO) == 0) && - !isCompiled(); + = !((UPbFractionI) myFraction).hasXMLPbSourceFile() + && !isCompiled(); boolean editableU - = !((UPbFraction) myFraction).hasXMLUSourceFile() - && //(((UPbFraction) myFraction).getMeanAlphaU().compareTo(BigDecimal.ZERO) == 0) && - !isCompiled(); + = !((UPbFractionI) myFraction).hasXMLUSourceFile() + && !isCompiled(); // Determine whether fraction is a metal or oxide for editing - boolean fractionIsOxide = ((UPbFraction) myFraction).isAnOxide(); + boolean fractionIsOxide = ((UPbFractionI) myFraction).isAnOxide(); // set properties of text boxes // top panel @@ -1132,7 +1134,7 @@ private void InitializeTextBoxes(final Fraction myFraction) { // aug 2010 oxide correction refinements r18O_16OUsed_textOnUTab.setDocument(new BigDecimalDocument(r18O_16OUsed_textOnUTab, true)); - fractionIsMetal_rb.setEnabled(!((UPbFraction) myFraction).hasXMLUSourceFile()); + fractionIsMetal_rb.setEnabled(!((UPbFractionI) myFraction).hasXMLUSourceFile()); fractionIsMetal_rb.addActionListener(new ActionListener() { @Override @@ -1165,7 +1167,7 @@ public void actionPerformed(ActionEvent e) { } }); - if (((UPbFraction) myFraction).isAnOxide()) { + if (((UPbFractionI) myFraction).isAnOxide()) { fractionIsOxide_rb.setSelected(true); } else { fractionIsMetal_rb.setSelected(true); @@ -2182,7 +2184,7 @@ private boolean ExportUPbFractionPerInputSchema(Fraction myFraction) { // first check on saving int response = JOptionPane.showConfirmDialog(this, new String[]{"Save data and continue with export ?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.NO_OPTION) { @@ -4421,7 +4423,7 @@ private void delete_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN int response = JOptionPane.showConfirmDialog( this, new String[]{"Are you sure you want to delete this fraction?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); switch (response) { diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbLegacyFractionEditorDialog.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbLegacyFractionEditorDialog.java index 19a9e7c5..49948d16 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbLegacyFractionEditorDialog.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/fractionManagers/UPbLegacyFractionEditorDialog.java @@ -324,7 +324,7 @@ private void Save() //// //// int response = JOptionPane.showConfirmDialog(this, //// new String[]{"Save data and continue with export ?"}, -//// "U-Pb Redux Warning", +//// "ET Redux Warning", //// JOptionPane.YES_NO_OPTION, //// JOptionPane.WARNING_MESSAGE); //// if (response == JOptionPane.NO_OPTION) { @@ -667,7 +667,7 @@ private void delete_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN int response = JOptionPane.showConfirmDialog( this, new String[]{"Are you sure you want to delete this fraction?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); switch (response) { diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.form b/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.form index 60fd38d0..3a27391e 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.form +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.form @@ -1,4 +1,4 @@ - +
@@ -21,6 +21,7 @@ + @@ -37,130 +38,134 @@ - - - - - - - - - - + + - - - - - - + + + + + + + + + - + - - + + + - - + + + + + + + + + + + + + + + + - + - + + + - - - - - - + + + + - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + - - - - - - diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.java index 7306f90f..77337014 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/graphManagers/GraphAxesDialog.java @@ -120,7 +120,7 @@ public GraphAxesDialog( // initComponents(); - setSize(560, 680); + setSize(560, 780); //Get the screen size Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); @@ -967,7 +967,7 @@ private void apply_buttonActionPerformed (java.awt.event.ActionEvent evt) {//GEN saveSettings(); - ((ConcordiaGraphPanel) concordiaGraphPanel).repaint(); + concordiaGraphPanel.repaint(); }//GEN-LAST:event_apply_buttonActionPerformed private void snapXConcordiaToDiagonal_buttonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_snapXConcordiaToDiagonal_buttonActionPerformed yDateMin_text.setText(xDateMin_text.getText()); diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/projectManagers/exportManagers/GeochronProjectExportManager.form b/src/main/java/org/earthtime/UPb_Redux/dialogs/projectManagers/exportManagers/GeochronProjectExportManager.form new file mode 100644 index 00000000..ef97674f --- /dev/null +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/projectManagers/exportManagers/GeochronProjectExportManager.form @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/projectManagers/exportManagers/GeochronProjectExportManager.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/projectManagers/exportManagers/GeochronProjectExportManager.java new file mode 100644 index 00000000..0883d49f --- /dev/null +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/projectManagers/exportManagers/GeochronProjectExportManager.java @@ -0,0 +1,378 @@ +/* + * GeochronProjectExportManager.java + * + * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.UPb_Redux.dialogs.projectManagers.exportManagers; + +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.ArrayList; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLayeredPane; +import javax.swing.JPanel; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import org.earthtime.UPb_Redux.dialogs.DialogEditor; +import org.earthtime.UPb_Redux.reports.ReportPainterI; +import org.earthtime.UPb_Redux.samples.SampleI; +import org.earthtime.UPb_Redux.user.ReduxPersistentState; +import org.earthtime.archivingTools.GeochronAliquotManager; +import org.earthtime.archivingTools.IEDACredentialsValidator; +import org.earthtime.beans.ET_JButton; +import org.earthtime.projects.ProjectI; + +/** + * + * @author sbowring + */ +public class GeochronProjectExportManager extends DialogEditor { + + private ReportPainterI parent; + private ReduxPersistentState myState; + private ProjectI project; + private String userCode; + private String sesarUserCodeForConfirm; + private boolean userIsValidated; + private boolean samplesAreLoaded; + private ArrayList sampleShowConcordiaButtons; + private ArrayList sampleShowPDFButtons; + private ArrayList samplePublicCheckBoxes; + + private ArrayList sampleUploadButtons; + + /** + * Creates new form GeochronProjectExportManager + * + * @param parent the value of parent + * @param modal the value of modal + * @param project the value of project + * @param myState the value of myState + */ + public GeochronProjectExportManager(ReportPainterI parent, boolean modal, ProjectI project, ReduxPersistentState myState) { + super((Frame) parent, modal); + + this.parent = parent; + this.myState = myState; + this.project = project; + this.userCode = ""; + this.sesarUserCodeForConfirm = ""; + this.userIsValidated = false; + this.samplesAreLoaded = false; + + initComponents(); + setSize(1200, 750); + + initGeochron(); + + processUserValidation(); + + } + + private void initGeochron() { + + geochronUserName_text.setDocument(new UnDoAbleDocument(geochronUserName_text, true)); + geochronUserName_text.setText(myState.getReduxPreferences().getGeochronUserName()); + + geochronPassword_passwordField.setDocument(new UnDoAbleDocument(geochronPassword_passwordField, true)); + geochronPassword_passwordField.setText(myState.getReduxPreferences().getGeochronPassWord()); + + validateGeochronAndSESARCredentials(false); + + } + + private void initSamplesDisplay() { + aliquotsLayeredPane.removeAll(); + + sampleShowConcordiaButtons = new ArrayList<>(); + sampleShowPDFButtons = new ArrayList<>(); + samplePublicCheckBoxes = new ArrayList<>(); + sampleUploadButtons = new ArrayList<>(); + + int leftMargin = 40; + int topMarginForSampleDetails = 10; + + int row = 0; + for (SampleI sample : project.getProjectSamples()) { + JPanel geochronAliquotManager = // + new GeochronAliquotManager(// + project,// needs to be interfaced + sample, // + myState.getReduxPreferences().getGeochronUserName(), // + myState.getReduxPreferences().getGeochronPassWord(), // + userCode, // + leftMargin, // + topMarginForSampleDetails + row * 100, 1100, 100); + aliquotsLayeredPane.add(geochronAliquotManager, JLayeredPane.DEFAULT_LAYER); + geochronAliquotManager.repaint(); + + row++; + } + + aliquotsLayeredPane.setPreferredSize(new Dimension(1100, topMarginForSampleDetails + (row + 1) * 100)); + aliquotsLayeredPane.validate(); + + instructionsTextPane.addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (Desktop.isDesktopSupported()) { + try { + Desktop.getDesktop().browse(e.getURL().toURI()); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (URISyntaxException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + }); + + } + +// private void updateValidSampleDisplay(int row, boolean visible) { +// sampleShowConcordiaButtons.get(row).setVisible(visible); +// sampleShowPDFButtons.get(row).setVisible(visible); +// samplePublicCheckBoxes.get(row).setVisible(visible); +// +// sampleUploadButtons.get(row).setVisible(visible); +// } + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + exportManagerLayeredPane = new javax.swing.JLayeredPane(); + geochronPassword_passwordField = new javax.swing.JPasswordField(); + geochronUserName_text = new javax.swing.JTextField(); + geochronCredentialsValidReport_label = new javax.swing.JLabel(); + validateGeochronAndSesarCredentials_button = new ET_JButton(); + userNameGeochron_label = new javax.swing.JLabel(); + passwordGeochron_label = new javax.swing.JLabel(); + step1_label = new javax.swing.JLabel(); + credentialSummaryLabel = new javax.swing.JLabel(); + step2_label = new javax.swing.JLabel(); + sesarCredentialsValidReport_label = new javax.swing.JLabel(); + instructionsScrollPane = new javax.swing.JScrollPane(); + instructionsTextPane = new javax.swing.JTextPane(); + aliquotsScrollPane = new javax.swing.JScrollPane(); + aliquotsLayeredPane = new javax.swing.JLayeredPane(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentResized(java.awt.event.ComponentEvent evt) { + formComponentResized(evt); + } + }); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + getContentPane().setLayout(null); + + exportManagerLayeredPane.setBackground(new java.awt.Color(245, 255, 255)); + exportManagerLayeredPane.setOpaque(true); + exportManagerLayeredPane.setPreferredSize(new java.awt.Dimension(1000, 600)); + + geochronPassword_passwordField.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + geochronPassword_passwordField.setText("############"); + exportManagerLayeredPane.add(geochronPassword_passwordField); + geochronPassword_passwordField.setBounds(380, 160, 150, 25); + + geochronUserName_text.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + geochronUserName_text.setText("username"); + exportManagerLayeredPane.add(geochronUserName_text); + geochronUserName_text.setBounds(380, 130, 150, 25); + + geochronCredentialsValidReport_label.setBackground(new java.awt.Color(255, 255, 255)); + geochronCredentialsValidReport_label.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N + geochronCredentialsValidReport_label.setForeground(new java.awt.Color(102, 204, 0)); + geochronCredentialsValidReport_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + geochronCredentialsValidReport_label.setText("GeoChron credentials are NOT valid."); + geochronCredentialsValidReport_label.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + geochronCredentialsValidReport_label.setOpaque(true); + geochronCredentialsValidReport_label.setPreferredSize(new java.awt.Dimension(255, 25)); + exportManagerLayeredPane.add(geochronCredentialsValidReport_label); + geochronCredentialsValidReport_label.setBounds(710, 130, 360, 25); + + validateGeochronAndSesarCredentials_button.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + validateGeochronAndSesarCredentials_button.setForeground(new java.awt.Color(255, 51, 51)); + validateGeochronAndSesarCredentials_button.setText("\n

Validate credentials at Geochron and SESAR

\n"); + validateGeochronAndSesarCredentials_button.setActionCommand("\n

Validate credentials at Geochron and SESAR

\n"); + validateGeochronAndSesarCredentials_button.setName("false"); // NOI18N + validateGeochronAndSesarCredentials_button.setPreferredSize(new java.awt.Dimension(255, 25)); + validateGeochronAndSesarCredentials_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + validateGeochronAndSesarCredentials_buttonActionPerformed(evt); + } + }); + exportManagerLayeredPane.add(validateGeochronAndSesarCredentials_button); + validateGeochronAndSesarCredentials_button.setBounds(530, 130, 180, 55); + + userNameGeochron_label.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N + userNameGeochron_label.setText("user name:"); + exportManagerLayeredPane.add(userNameGeochron_label); + userNameGeochron_label.setBounds(300, 130, 68, 25); + + passwordGeochron_label.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N + passwordGeochron_label.setText("password:"); + exportManagerLayeredPane.add(passwordGeochron_label); + passwordGeochron_label.setBounds(300, 160, 63, 25); + + step1_label.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N + step1_label.setText("Step 1) Validate GeoPass credentials:"); + exportManagerLayeredPane.add(step1_label); + step1_label.setBounds(10, 130, 280, 25); + + credentialSummaryLabel.setFont(new java.awt.Font("SansSerif", 3, 14)); // NOI18N + credentialSummaryLabel.setText("Note: your user code is XXXXX and your IGSNs will be of the form XXXXXNNNN, where N is any digit or any capital letter."); + exportManagerLayeredPane.add(credentialSummaryLabel); + credentialSummaryLabel.setBounds(190, 190, 880, 25); + + step2_label.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N + step2_label.setText("Step 2) Confirm Sample Details and upload to Geochron.org (Note - uploads overwrite previous uploads):"); + exportManagerLayeredPane.add(step2_label); + step2_label.setBounds(10, 220, 830, 25); + + sesarCredentialsValidReport_label.setBackground(new java.awt.Color(255, 255, 255)); + sesarCredentialsValidReport_label.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N + sesarCredentialsValidReport_label.setForeground(new java.awt.Color(102, 204, 0)); + sesarCredentialsValidReport_label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + sesarCredentialsValidReport_label.setText("SESAR credentials are NOT valid."); + sesarCredentialsValidReport_label.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + sesarCredentialsValidReport_label.setOpaque(true); + sesarCredentialsValidReport_label.setPreferredSize(new java.awt.Dimension(255, 25)); + exportManagerLayeredPane.add(sesarCredentialsValidReport_label); + sesarCredentialsValidReport_label.setBounds(710, 160, 360, 25); + + instructionsScrollPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + instructionsScrollPane.setFont(new java.awt.Font("Serif", 0, 12)); // NOI18N + + instructionsTextPane.setEditable(false); + instructionsTextPane.setContentType("text/html"); // NOI18N + instructionsTextPane.setText("\n \n\n \n \n

\n Instructions: We want you to uniquely register your samples and aliquots by giving them an IGSN (International Geo Sample Number). \n\tTo do so, you need credentials -username and password - established \n\tat GeoPass. \n\tYou use these credentials to register at Geochron and at SEASAR.\n\tAt SESAR, you will choose a 5-letter user code (3-letter codes are grandfathered) that will be the prefix used for the IGSNs for every sample you register.\n\tFor each sample you register, you will specify (or ask SESAR to generate) a 4-character code (6 characters if you have 3-letter user code) using any combination\n\tof digits and capital letters. For example, if your user code is JAMES, then an IGSN might be JAMES09AZ. You will assign each Aliquot \n\tan IGSN in the same way and it will be a child of the parent sample's IGSN. While you can specify any IGSN for the parent - say you have a piece of a sample from a colleague -\n\tyour Aliquot or child IGSNs will always have your user code as a prefix.\n

\n \n\n"); + instructionsScrollPane.setViewportView(instructionsTextPane); + + exportManagerLayeredPane.add(instructionsScrollPane); + instructionsScrollPane.setBounds(10, 10, 1180, 110); + + aliquotsLayeredPane.setBackground(new java.awt.Color(245, 255, 255)); + aliquotsLayeredPane.setOpaque(true); + aliquotsScrollPane.setViewportView(aliquotsLayeredPane); + + exportManagerLayeredPane.add(aliquotsScrollPane); + aliquotsScrollPane.setBounds(10, 250, 1180, 450); + + getContentPane().add(exportManagerLayeredPane); + exportManagerLayeredPane.setBounds(0, 0, 1200, 700); + + pack(); + }//
//GEN-END:initComponents + + private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized + exportManagerLayeredPane.setSize(this.getSize()); + }//GEN-LAST:event_formComponentResized + + private void validateGeochronAndSesarCredentials_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_validateGeochronAndSesarCredentials_buttonActionPerformed + validateGeochronAndSESARCredentials(false); + }//GEN-LAST:event_validateGeochronAndSesarCredentials_buttonActionPerformed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + parent.loadAndShowReportTableData(); + }//GEN-LAST:event_formWindowClosing + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLayeredPane aliquotsLayeredPane; + private javax.swing.JScrollPane aliquotsScrollPane; + private javax.swing.JLabel credentialSummaryLabel; + private javax.swing.JLayeredPane exportManagerLayeredPane; + private javax.swing.JLabel geochronCredentialsValidReport_label; + private javax.swing.JPasswordField geochronPassword_passwordField; + private javax.swing.JTextField geochronUserName_text; + private javax.swing.JScrollPane instructionsScrollPane; + private javax.swing.JTextPane instructionsTextPane; + private javax.swing.JLabel passwordGeochron_label; + private javax.swing.JLabel sesarCredentialsValidReport_label; + private javax.swing.JLabel step1_label; + private javax.swing.JLabel step2_label; + private javax.swing.JLabel userNameGeochron_label; + private javax.swing.JButton validateGeochronAndSesarCredentials_button; + // End of variables declaration//GEN-END:variables + + private void validateGeochronAndSESARCredentials(boolean isVerbose) { + userCode = // + IEDACredentialsValidator.validateGeochronCredentials(// + geochronUserName_text.getText().trim(),// + new String(geochronPassword_passwordField.getPassword()), isVerbose); + + boolean valid = (userCode.trim().length() > 0); + if (valid) { + geochronCredentialsValidReport_label.setText("GeoChron credentials are VALID. User Code = " + userCode); + } else { + geochronCredentialsValidReport_label.setText("GeoChron credentials are NOT valid."); + } + + sesarUserCodeForConfirm = // + IEDACredentialsValidator.validateSesarCredentials(// + geochronUserName_text.getText().trim(),// + new String(geochronPassword_passwordField.getPassword()), isVerbose); + + boolean validSesar = (sesarUserCodeForConfirm.trim().length() > 0); + if (validSesar) { + sesarCredentialsValidReport_label.setText("SESAR Credentials are VALID. User Code = " + sesarUserCodeForConfirm); + } else { + sesarCredentialsValidReport_label.setText("SESAR Credentials are NOT valid."); + } + + if ((userCode.length() > 0) && (userCode.compareToIgnoreCase(sesarUserCodeForConfirm) == 0)) { + credentialSummaryLabel.setText(// + "Note: your user code is " + userCode + " and your IGSNs will be of the form " // + + userCode + "NNNNNNN".substring(0, (9 - userCode.length())) + ", where N is any digit or any capital letter." // + ); + userIsValidated = true; + } else { + userIsValidated = false; + } + + samplesAreLoaded = false; + + processUserValidation(); + } + + private void processUserValidation() { + credentialSummaryLabel.setVisible(userIsValidated); + step2_label.setVisible(userIsValidated); + + aliquotsScrollPane.setVisible(userIsValidated); + if (userIsValidated && !samplesAreLoaded) { + initSamplesDisplay(); + samplesAreLoaded = true; + } + } + + +} diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/analysisManagers/SampleAnalysisWorkflowManagerIDTIMS.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/analysisManagers/SampleAnalysisWorkflowManagerIDTIMS.java index 23ed6c68..08edecf2 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/analysisManagers/SampleAnalysisWorkflowManagerIDTIMS.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/analysisManagers/SampleAnalysisWorkflowManagerIDTIMS.java @@ -243,7 +243,7 @@ public void initSampleAliquots() { new UnDoAbleDocument(aliquotName_text, true)); aliquotName_text.setText("Aliquot Name"); - aliquotList = new ArrayList(); + aliquotList = new ArrayList<>(); if (mySample.getUPbFractions().size() > 0) { for (int i = 0; i < mySample.getAliquots().size(); i++) { // only show aliquots with fractions because removed aliquots still exist with zero fraction diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.form b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.form index 3b14bf01..a755edae 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.form +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.form @@ -31,7 +31,7 @@ - +
@@ -39,7 +39,7 @@ - + @@ -62,74 +62,8 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -139,6 +73,11 @@
+ + + + + @@ -148,6 +87,11 @@ + + + + + @@ -156,12 +100,22 @@ + + + + + + + + + + @@ -170,8 +124,18 @@ + + + + + + + + + + @@ -196,6 +160,11 @@ + + + + + @@ -217,9 +186,9 @@ - - - + + + @@ -236,7 +205,7 @@ - + @@ -322,7 +291,7 @@ - + @@ -420,6 +389,11 @@ + + + + + @@ -439,7 +413,7 @@ - + @@ -502,7 +476,7 @@ - + diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.java index 85b32511..d90e36c1 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/compilationManagers/SampleCompilationManagerDialog.java @@ -29,39 +29,40 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; -import org.earthtime.ETReduxFrame; import org.earthtime.UPb_Redux.dialogs.DialogEditor; import org.earthtime.UPb_Redux.exceptions.BadLabDataException; import org.earthtime.UPb_Redux.samples.Sample; +import org.earthtime.UPb_Redux.user.ReduxPersistentState; import org.earthtime.UPb_Redux.utilities.BrowserControl; import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException; +import org.earthtime.archivingTools.IEDACredentialsValidator; import org.earthtime.exceptions.ETException; /** * - * @author James F. Bowring + * @author James F. Bowring */ public class SampleCompilationManagerDialog extends DialogEditor { private Sample mySample = null; private File importFractionFolderMRU; private boolean initialized = false; - private boolean automaticFractionCreation = false; - private Frame parent; + private final boolean automaticFractionCreation = false; + private final Frame parent; /** - * + * * @return */ - public boolean isNewSample () { + public boolean isNewSample() { return newSample; } /** - * + * * @param newSample */ - public void setNewSample ( boolean newSample ) { + public void setNewSample(boolean newSample) { this.newSample = newSample; } @@ -79,17 +80,18 @@ private enum fractionDestinations { /** * Creates new form SampleManagerDialog + * * @param parent - * @param modal + * @param modal * @param importFractionFolderMRU - * @param sample + * @param sample */ - public SampleCompilationManagerDialog ( + public SampleCompilationManagerDialog( java.awt.Frame parent, boolean modal, Sample sample, - File importFractionFolderMRU ) { - super( parent, modal ); + File importFractionFolderMRU) { + super(parent, modal); this.parent = parent; @@ -97,134 +99,132 @@ public SampleCompilationManagerDialog ( initComponents(); - - //Register listeners for the radio buttons. sourceOfFractionsListener mySourceOfFractionsListener = new sourceOfFractionsListener(); - sourceFolder_jRadioButton.addActionListener( mySourceOfFractionsListener ); - sourceSingle_jRadioButton.addActionListener( mySourceOfFractionsListener ); - sourceGeochron_jRadioButton.addActionListener( mySourceOfFractionsListener ); + sourceFolder_jRadioButton.addActionListener(mySourceOfFractionsListener); + sourceSingle_jRadioButton.addActionListener(mySourceOfFractionsListener); + sourceGeochron_jRadioButton.addActionListener(mySourceOfFractionsListener); this.mySample = sample; InitSampleFields(); - credentialsValidReport_label.setVisible( false); + credentialsValidReport_label.setVisible(false); } class automaticFractionsListener implements ItemListener { - public void itemStateChanged ( ItemEvent e ) { + public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); - sourceFolder_jRadioButton.setEnabled( automaticFractionCreation ); - sourceSingle_jRadioButton.setEnabled( automaticFractionCreation ); - sourceGeochron_jRadioButton.setEnabled( automaticFractionCreation ); + sourceFolder_jRadioButton.setEnabled(automaticFractionCreation); + sourceSingle_jRadioButton.setEnabled(automaticFractionCreation); + sourceGeochron_jRadioButton.setEnabled(automaticFractionCreation); } } class sourceOfFractionsListener implements ActionListener { - public void actionPerformed ( ActionEvent evt ) { - System.out.println( evt.getActionCommand() ); - fractionSource = fractionSources.valueOf( evt.getActionCommand() ); + public void actionPerformed(ActionEvent evt) { + System.out.println(evt.getActionCommand()); + fractionSource = fractionSources.valueOf(evt.getActionCommand()); } } /** - * + * */ - public void setSize () { - setSize( 480, 660 ); + public void setSize() { + setSize(480, 660); } /** - * + * * @return */ - public File getImportFractionFolderMRU () { + public File getImportFractionFolderMRU() { return importFractionFolderMRU; } /** - * + * * @param importFractionFolderMRU */ - public void setImportFractionFolderMRU ( File importFractionFolderMRU ) { + public void setImportFractionFolderMRU(File importFractionFolderMRU) { this.importFractionFolderMRU = importFractionFolderMRU; } - private void InitSampleFields () { + private void InitSampleFields() { // init input fields // sample name is fixed once populated with fractions sampleName_text.setDocument( - new UnDoAbleDocument( sampleName_text, true ) ); - sampleName_text.setText( getMySample().getSampleName() ); + new UnDoAbleDocument(sampleName_text, true)); + sampleName_text.setText(getMySample().getSampleName()); - sampleNotes_textArea.setDocument( new UnDoAbleDocument( sampleNotes_textArea, true ) ); - sampleNotes_textArea.setText( getMySample().getSampleAnnotations() ); + sampleNotes_textArea.setDocument(new UnDoAbleDocument(sampleNotes_textArea, true)); + sampleNotes_textArea.setText(getMySample().getSampleAnnotations()); // init display fields - html allows multi-line sampleReduxFileName_label.setText( - "

" + getMySample().getReduxSampleFilePath() + "

" ); + "

" + getMySample().getReduxSampleFilePath() + "

"); - geochronUserName_text.setDocument( new UnDoAbleDocument( geochronUserName_text, true ) ); - geochronUserName_text.setText(((ETReduxFrame) parent).getMyState().getReduxPreferences().getGeochronUserName() ); + geochronUserName_text.setDocument(new UnDoAbleDocument(geochronUserName_text, true)); + geochronUserName_text.setText(ReduxPersistentState.getExistingPersistentState().getReduxPreferences().getGeochronUserName()); - geochronPassword_passwordField.setDocument( new UnDoAbleDocument( geochronPassword_passwordField, true ) ); - geochronPassword_passwordField.setText(((ETReduxFrame) parent).getMyState().getReduxPreferences().getGeochronPassWord() ); + geochronPassword_passwordField.setDocument(new UnDoAbleDocument(geochronPassword_passwordField, true)); + geochronPassword_passwordField.setText(ReduxPersistentState.getExistingPersistentState().getReduxPreferences().getGeochronPassWord()); } - private void SaveSampleData () + private void SaveSampleData() throws ETException, FileNotFoundException, BadLabDataException, IOException, BadOrMissingXMLSchemaException { // TODO: validate fields - make this more sophisticated - if ( sampleName_text.getText().length() == 0 ) { + if (sampleName_text.getText().length() == 0) { return; } else { - setVisible( false ); + setVisible(false); String success = ""; // get aliquots as specified switch (fractionSource) { case SINGLE_LOCAL: - success = getMySample().importAliquotLocalXMLDataFile( importFractionFolderMRU ); - if ( ! success.equalsIgnoreCase( "" ) ) { - getMySample().setSampleName( sampleName_text.getText() ); + success = getMySample().importAliquotLocalXMLDataFile(importFractionFolderMRU); + if (!success.equalsIgnoreCase("")) { + getMySample().setSampleName(sampleName_text.getText()); - getMySample().setSampleAnnotations( sampleNotes_textArea.getText() ); + getMySample().setSampleAnnotations(sampleNotes_textArea.getText()); - setImportFractionFolderMRU( new File( success ) ); + setImportFractionFolderMRU(new File(success)); - setInitialized( true ); + setInitialized(true); } break; case FOLDER_LOCAL: break; case ONE_OR_MORE_GEOCHRON: success = getMySample().importOneOrMoreGeochronAliquotXMLDataFiles(); - if ( success.contains( "Found" ) ) { - getMySample().setSampleName( sampleName_text.getText() ); + if (success.contains("Found")) { + getMySample().setSampleName(sampleName_text.getText()); - getMySample().setSampleAnnotations( sampleNotes_textArea.getText() ); + getMySample().setSampleAnnotations(sampleNotes_textArea.getText()); - setInitialized( true ); + setInitialized(true); } - if ( success.contains( "Missing" ) ) { - System.out.println( success ); - JOptionPane.showMessageDialog( this, + if (success.contains("Missing")) { + System.out.println(success); + JOptionPane.showMessageDialog(this, success, "Geochron Warning", - JOptionPane.WARNING_MESSAGE ); + JOptionPane.WARNING_MESSAGE); } break; } @@ -232,41 +232,41 @@ private void SaveSampleData () } /** - * + * * @return */ - public Sample getMySample () { + public Sample getMySample() { return mySample; } /** - * + * * @param mySample */ - public void setMySample ( Sample mySample ) { + public void setMySample(Sample mySample) { this.mySample = mySample; } /** - * + * * @return */ - public boolean isInitialized () { + public boolean isInitialized() { return initialized; } /** - * + * * @param isSaved */ - public void setInitialized ( boolean isSaved ) { + public void setInitialized(boolean isSaved) { this.initialized = isSaved; } - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { @@ -305,27 +305,41 @@ private void initComponents() { jPanel1.setBackground(new java.awt.Color(245, 236, 206)); jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); jPanel1.setMaximumSize(new java.awt.Dimension(480, 620)); + jPanel1.setLayout(null); sampleName_label.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N sampleName_label.setText("Lab's Name for this Compilation Sample:"); + jPanel1.add(sampleName_label); + sampleName_label.setBounds(8, 63, 224, 14); sampleName_text.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N sampleName_text.setHorizontalAlignment(javax.swing.JTextField.CENTER); sampleName_text.setText("Sample Name"); + jPanel1.add(sampleName_text); + sampleName_text.setBounds(238, 56, 218, 27); sampleReduxFile_label.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N sampleReduxFile_label.setText("File path for this Sample:"); + jPanel1.add(sampleReduxFile_label); + sampleReduxFile_label.setBounds(8, 447, 139, 14); sampleReduxFileName_label.setText(""); sampleReduxFileName_label.setVerticalAlignment(javax.swing.SwingConstants.TOP); + jPanel1.add(sampleReduxFileName_label); + sampleReduxFileName_label.setBounds(28, 467, 428, 64); sampleNotes_label.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N sampleNotes_label.setText("Notes about this Sample:"); + jPanel1.add(sampleNotes_label); + sampleNotes_label.setBounds(8, 337, 141, 14); sampleNotes_textArea.setColumns(20); sampleNotes_textArea.setRows(5); sampleNotes_scrollPane.setViewportView(sampleNotes_textArea); + jPanel1.add(sampleNotes_scrollPane); + sampleNotes_scrollPane.setBounds(32, 357, 440, 84); + jPanel3.setBackground(new java.awt.Color(255, 255, 224)); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Source of Aliquots", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Grande", 0, 13), new java.awt.Color(204, 0, 0))); // NOI18N @@ -356,7 +370,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { sourceOfFractionsOptions_buttonGroup.add(sourceGeochron_jRadioButton); sourceGeochron_jRadioButton.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N - sourceGeochron_jRadioButton.setText("Import one or more Aliquots from Geochron database"); + sourceGeochron_jRadioButton.setText("Import one or more Aliquots from Geochron.org database"); sourceGeochron_jRadioButton.setActionCommand(fractionSource.ONE_OR_MORE_GEOCHRON.toString()); sourceGeochron_jRadioButton.setContentAreaFilled(false); sourceGeochron_jRadioButton.addActionListener(new java.awt.event.ActionListener() { @@ -422,9 +436,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .add(geochronPassword_passwordField) .add(geochronUserName_text)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) - .add(credentialsValidReport_label, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 211, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(validateGeochronCredentials_button, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(credentialsValidReport_label, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 217, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(validateGeochronCredentials_button, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .add(jPanel3Layout.createSequentialGroup() .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(sourceSingle_jRadioButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) @@ -433,11 +447,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .add(jPanel3Layout.createSequentialGroup() .add(102, 102, 102) .add(visitGeochron_button, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 208, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(18, Short.MAX_VALUE)) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - - jPanel3Layout.linkSize(new java.awt.Component[] {credentialsValidReport_label, validateGeochronCredentials_button}, org.jdesktop.layout.GroupLayout.HORIZONTAL); - jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup() @@ -463,63 +474,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .add(visitGeochron_button)) ); + jPanel1.add(jPanel3); + jPanel3.setBounds(31, 109, 440, 210); + sampleName_label1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N sampleName_label1.setText("Note: Compilation mode provides a mechanism to load in various
aliquots from the same or different Samples and to view and save them
as a single ET_Redux sample\n file."); - - org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .add(sampleNotes_label) - .addContainerGap(350, Short.MAX_VALUE)) - .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup() - .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) - .add(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jPanel1Layout.createSequentialGroup() - .add(sampleName_label) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(sampleName_text, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)) - .add(sampleName_label1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 448, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup() - .add(29, 29, 29) - .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup() - .add(30, 30, 30) - .add(sampleNotes_scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)) - .add(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(sampleReduxFile_label) - .add(jPanel1Layout.createSequentialGroup() - .add(20, 20, 20) - .add(sampleReduxFileName_label, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE))))) - .add(43, 43, 43)) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jPanel1Layout.createSequentialGroup() - .addContainerGap() - .add(sampleName_label1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(10, 10, 10) - .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(sampleName_text, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(sampleName_label)) - .add(26, 26, 26) - .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(18, 18, 18) - .add(sampleNotes_label) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(sampleNotes_scrollPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(sampleReduxFile_label) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(sampleReduxFileName_label, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 64, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); + jPanel1.add(sampleName_label1); + sampleName_label1.setBounds(8, 8, 448, 38); jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); @@ -551,7 +512,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap() .add(saveAndCloseAndProceedToAliquotChooser_button, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 242, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(cancel_button, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE) + .add(cancel_button, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) .addContainerGap()) ); jPanel2Layout.setVerticalGroup( @@ -572,7 +533,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { sampleType_panel.setLayout(sampleType_panelLayout); sampleType_panelLayout.setHorizontalGroup( sampleType_panelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(sampleType_label, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE) + .add(sampleType_label, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE) ); sampleType_panelLayout.setVerticalGroup( sampleType_panelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) @@ -585,14 +546,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(sampleType_panel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(jPanel1, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(jPanel1, 0, 490, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(sampleType_panel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 501, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) ); @@ -608,36 +569,34 @@ private void saveAndCloseAndProceedToAliquotChooser_buttonActionPerformed(java.a SaveSampleData(); close(); } catch (FileNotFoundException ex) { - Logger.getLogger( SampleCompilationManagerDialog.class.getName() ).log( Level.SEVERE, null, ex ); - } catch (BadLabDataException ex) { - Logger.getLogger( SampleCompilationManagerDialog.class.getName() ).log( Level.SEVERE, null, ex ); - } catch (IOException ex) { - Logger.getLogger( SampleCompilationManagerDialog.class.getName() ).log( Level.SEVERE, null, ex ); - } catch (BadOrMissingXMLSchemaException ex) { - Logger.getLogger( SampleCompilationManagerDialog.class.getName() ).log( Level.SEVERE, null, ex ); + Logger.getLogger(SampleCompilationManagerDialog.class.getName()).log(Level.SEVERE, null, ex); + } catch (BadLabDataException | BadOrMissingXMLSchemaException | IOException ex) { + Logger.getLogger(SampleCompilationManagerDialog.class.getName()).log(Level.SEVERE, null, ex); } catch (ETException ex) { } }//GEN-LAST:event_saveAndCloseAndProceedToAliquotChooser_buttonActionPerformed - private void validateGeochronCredentials (boolean isVerbose) { - boolean valid = ((ETReduxFrame) parent).getMyState().validateGeochronCredentials(// - geochronUserName_text.getText().trim(),// - new String( geochronPassword_passwordField.getPassword() ), isVerbose ); + private void validateGeochronCredentials(boolean isVerbose) { + String userCode = // + IEDACredentialsValidator.validateGeochronCredentials(// + geochronUserName_text.getText().trim(),// + new String(geochronPassword_passwordField.getPassword()), isVerbose); - if ( valid ) { - credentialsValidReport_label.setText( "Credentials are VALID." ); + boolean valid = (userCode.trim().length() > 0); + if (valid) { + credentialsValidReport_label.setText("Credentials are VALID."); } else { - credentialsValidReport_label.setText( "Credentials are NOT valid." ); + credentialsValidReport_label.setText("Credentials are NOT valid."); } - saveAndCloseAndProceedToAliquotChooser_button.setEnabled( valid ); - credentialsValidReport_label.setVisible( true); + saveAndCloseAndProceedToAliquotChooser_button.setEnabled(valid); + credentialsValidReport_label.setVisible(true); } private void sourceSingle_jRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sourceSingle_jRadioButtonActionPerformed - saveAndCloseAndProceedToAliquotChooser_button.setEnabled( true ); + saveAndCloseAndProceedToAliquotChooser_button.setEnabled(true); }//GEN-LAST:event_sourceSingle_jRadioButtonActionPerformed private void validateGeochronCredentials_buttonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_validateGeochronCredentials_buttonActionPerformed @@ -645,7 +604,7 @@ private void validateGeochronCredentials_buttonActionPerformed (java.awt.event.A }//GEN-LAST:event_validateGeochronCredentials_buttonActionPerformed private void visitGeochron_buttonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visitGeochron_buttonActionPerformed - BrowserControl.displayURL( "http://www.geochron.org/" ); + BrowserControl.displayURL("http://www.geochron.org/"); }//GEN-LAST:event_visitGeochron_buttonActionPerformed private void sourceGeochron_jRadioButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sourceGeochron_jRadioButtonActionPerformed @@ -653,7 +612,7 @@ private void sourceGeochron_jRadioButtonActionPerformed (java.awt.event.ActionEv }//GEN-LAST:event_sourceGeochron_jRadioButtonActionPerformed private void sourceFolder_jRadioButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sourceFolder_jRadioButtonActionPerformed - saveAndCloseAndProceedToAliquotChooser_button.setEnabled( true ); + saveAndCloseAndProceedToAliquotChooser_button.setEnabled(true); }//GEN-LAST:event_sourceFolder_jRadioButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancel_button; diff --git a/src/main/java/org/earthtime/UPb_Redux/fractions/AnalysisFraction.java b/src/main/java/org/earthtime/UPb_Redux/fractions/AnalysisFraction.java index 492d3d68..49c814bc 100644 --- a/src/main/java/org/earthtime/UPb_Redux/fractions/AnalysisFraction.java +++ b/src/main/java/org/earthtime/UPb_Redux/fractions/AnalysisFraction.java @@ -37,7 +37,7 @@ import org.earthtime.exceptions.ETException; import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelET; import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelETXMLConverter; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFraction.java b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFraction.java index c1dd6973..f4b876b9 100644 --- a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFraction.java +++ b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFraction.java @@ -84,7 +84,7 @@ import org.earthtime.ratioDataModels.tracers.TracerUPbModel; import org.earthtime.ratioDataModels.tracers.TracerUPbModelXMLConverter; import org.earthtime.utilities.CollectionHelpers; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionI.java b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionI.java index 22451109..36df0ac2 100644 --- a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionI.java +++ b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionI.java @@ -325,4 +325,10 @@ public interface UPbFractionI { public void calculateTeraWasserburgRho(); public boolean isCommonLeadLossCorrected(); + + public boolean hasXMLUSourceFile (); + + public boolean hasXMLPbSourceFile (); + + public boolean isAnOxide(); } diff --git a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionTableModel.java b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionTableModel.java index 42de6542..4e4ad1f4 100644 --- a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionTableModel.java +++ b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbFractionTableModel.java @@ -33,8 +33,8 @@ import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.table.AbstractTableModel; -import org.earthtime.UPb_Redux.ReduxConstants; import org.earthtime.ETReduxFrame; +import org.earthtime.UPb_Redux.ReduxConstants; import org.earthtime.UPb_Redux.dialogs.fractionManagers.FractionNotesDialog; import org.earthtime.UPb_Redux.fractions.Fraction; import org.earthtime.UPb_Redux.renderers.EditFractionButton; @@ -178,13 +178,6 @@ public final void refreshTableData() { Vector myFractions = getFractionsSorted(); for (int row = 0; row < myFractions.size(); row++) { -//// if (performReduction) { -//// // perform data reduction on flag -//// Fraction fraction = myFractions.get(row); -//// -//// UPbFractionReducer.fullFractionReduce(fraction, true); -//// -//// } Object[] myFractionData = ((UPbFractionI) myFractions.get(row)).getFractionTableRowData(); data.add(myFractionData); diff --git a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLAICPMSFraction.java b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLAICPMSFraction.java index 5a83293b..c8da5907 100644 --- a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLAICPMSFraction.java +++ b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLAICPMSFraction.java @@ -1457,4 +1457,19 @@ public boolean isCorrectedForPbc() { public void setCorrectedForPbc(boolean correctedForPbc) { this.correctedForPbc = correctedForPbc; } + + @Override + public boolean hasXMLUSourceFile() { + return false; + } + + @Override + public boolean hasXMLPbSourceFile() { + return false; + } + + @Override + public boolean isAnOxide(){ + return false; + } } diff --git a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLegacyFraction.java b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLegacyFraction.java index 70b72386..8648eb65 100644 --- a/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLegacyFraction.java +++ b/src/main/java/org/earthtime/UPb_Redux/fractions/UPbReduxFractions/UPbLegacyFraction.java @@ -709,4 +709,19 @@ public void setStandard(boolean standard) { public boolean isCommonLeadLossCorrected() { return false; // dec 2014 until we learn that this is the case } + + @Override + public boolean hasXMLUSourceFile() { + return false; + } + + @Override + public boolean hasXMLPbSourceFile() { + return false; + } + + @Override + public boolean isAnOxide() { + return false; + } } diff --git a/src/main/java/org/earthtime/UPb_Redux/initialPbModels/InitialPbModel.java b/src/main/java/org/earthtime/UPb_Redux/initialPbModels/InitialPbModel.java index d37844ac..4b428770 100644 --- a/src/main/java/org/earthtime/UPb_Redux/initialPbModels/InitialPbModel.java +++ b/src/main/java/org/earthtime/UPb_Redux/initialPbModels/InitialPbModel.java @@ -39,7 +39,7 @@ import org.earthtime.ratioDataModels.AbstractRatiosDataModel; import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelET; import org.earthtime.utilities.DateHelpers; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/mineralStandardModels/MineralStandardModel.java b/src/main/java/org/earthtime/UPb_Redux/mineralStandardModels/MineralStandardModel.java index 2e0e4c13..3163f1de 100644 --- a/src/main/java/org/earthtime/UPb_Redux/mineralStandardModels/MineralStandardModel.java +++ b/src/main/java/org/earthtime/UPb_Redux/mineralStandardModels/MineralStandardModel.java @@ -45,7 +45,7 @@ import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelET; import org.earthtime.ratioDataModels.mineralStandardModels.MineralStandardUPbModel; import org.earthtime.utilities.DateHelpers; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/pbBlanks/PbBlank.java b/src/main/java/org/earthtime/UPb_Redux/pbBlanks/PbBlank.java index a69d974d..50b08794 100644 --- a/src/main/java/org/earthtime/UPb_Redux/pbBlanks/PbBlank.java +++ b/src/main/java/org/earthtime/UPb_Redux/pbBlanks/PbBlank.java @@ -39,7 +39,7 @@ import org.earthtime.ratioDataModels.AbstractRatiosDataModel; import org.earthtime.ratioDataModels.pbBlankICModels.PbBlankICModel; import org.earthtime.utilities.DateHelpers; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/reduxLabData/ReduxLabDataList.java b/src/main/java/org/earthtime/UPb_Redux/reduxLabData/ReduxLabDataList.java index ac89ec58..b3cf3003 100644 --- a/src/main/java/org/earthtime/UPb_Redux/reduxLabData/ReduxLabDataList.java +++ b/src/main/java/org/earthtime/UPb_Redux/reduxLabData/ReduxLabDataList.java @@ -168,7 +168,7 @@ public boolean registerElement ( Object element, boolean isVerbose ) { JOptionPane.showMessageDialog( null, new String[]{listTypeName + " "// + ((ReduxLabDataListElementI) element).getReduxLabDataElementName() + " is already registered with LabData."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE ); } } else { diff --git a/src/main/java/org/earthtime/UPb_Redux/reports/ReportSettings.java b/src/main/java/org/earthtime/UPb_Redux/reports/ReportSettings.java index f07d5aeb..5f10907b 100644 --- a/src/main/java/org/earthtime/UPb_Redux/reports/ReportSettings.java +++ b/src/main/java/org/earthtime/UPb_Redux/reports/ReportSettings.java @@ -48,7 +48,7 @@ import org.earthtime.dataDictionaries.RadDates; import org.earthtime.dataDictionaries.ReportSpecifications; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/samples/SESARSampleMetadata.java b/src/main/java/org/earthtime/UPb_Redux/samples/SESARSampleMetadata.java index cfa2e31b..da83ff89 100644 --- a/src/main/java/org/earthtime/UPb_Redux/samples/SESARSampleMetadata.java +++ b/src/main/java/org/earthtime/UPb_Redux/samples/SESARSampleMetadata.java @@ -34,7 +34,7 @@ import org.earthtime.UPb_Redux.user.UPbReduxConfigurator; import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/samples/Sample.java b/src/main/java/org/earthtime/UPb_Redux/samples/Sample.java index 4458054b..a4d9fe8f 100644 --- a/src/main/java/org/earthtime/UPb_Redux/samples/Sample.java +++ b/src/main/java/org/earthtime/UPb_Redux/samples/Sample.java @@ -661,6 +661,24 @@ public Aliquot getAliquotByNumber(int aliquotNum) { return retAliquot; } + + /** + * Feb 2015 This method handles the messy situation where a project refers to each of its aliquots + * by index 1...n but to upload project aliquots individually to Geochron with concordia etc + * means there is only one aliquot per sample and we ignore its number. + * @param aliquotnum + * @return + */ + public String getNameOfAliquotFromSample(int aliquotNum){ + String retval; + if (aliquots.size() == 1){ + retval = aliquots.get(0).getAliquotName(); + } else { + retval = aliquots.get(aliquotNum - 1).getAliquotName(); + } + + return retval; + } /** * finds the Aliquot named file in the array @@ -844,6 +862,7 @@ private void initializeDefaultUPbFraction(Fraction defFraction) addUPbFraction(defFraction); } + //TODO: refactor these edit methods out of sample - MVC !! /** * opens aliquot modal editor for the Fraction indicated by * argument fraction and opened to the editing tab indicated by @@ -883,7 +902,8 @@ public void editUPbFraction(Fraction fraction, int selectedTab) { selectedTab, false); } else if (sampleAnalysisType.equalsIgnoreCase(SampleAnalysisTypesEnum.IDTIMS.getName()) - || (sampleType.equalsIgnoreCase(SampleTypesEnum.COMPILATION.getName()))) { + || (sampleType.equalsIgnoreCase(SampleTypesEnum.COMPILATION.getName()))){ +// TODO: Need kwiki page for LAICPMS || (sampleType.equalsIgnoreCase(SampleTypesEnum.PROJECT.getName()))) { myFractionEditor = new UPbFractionEditorDialog( @@ -1045,9 +1065,9 @@ public void importAliquotFromAnotherSample(Aliquot aliquot) { fraction); ((UPbFractionI) fraction).setAliquotNumber(aliquotNumber); - ((UPbReduxAliquot) importedAliquot).getAliquotFractions().add(fraction);//nextFraction ); + ((UPbReduxAliquot) importedAliquot).getAliquotFractions().add(fraction); - UPbFractions.add(fraction);//nextFraction ); + UPbFractions.add(fraction); } aliquots.add(importedAliquot); @@ -1585,7 +1605,7 @@ public boolean importAliquotFolder(File[] fractions, int aliquotNumber, boolean if (f < (fractions.length - 1)) { int response = JOptionPane.showConfirmDialog(null, new String[]{"Continue to process folder?"}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.NO_OPTION) { @@ -2031,7 +2051,6 @@ public void setSampleName(String sampleName) { if (isChanged()) { updateSampleFractionsWithSampleName(sampleName); - } } @@ -2585,9 +2604,9 @@ public void setAliquots(Vector aliquots) { */ public void repairAliquotNumberingDec2011() { // walk aliquots and remove empty ones - ArrayList aliquotsToDelete = new ArrayList(); + ArrayList aliquotsToDelete = new ArrayList<>(); for (int i = 0; i < aliquots.size(); i++) { - Aliquot aliquot = getAliquotByNumber(i + 1); + Aliquot aliquot = aliquots.get(i);// Feb 2015 getAliquotByNumber(i + 1); if (((UPbReduxAliquot) aliquot).getAliquotFractions().isEmpty()) { // save aliquot for later deletion aliquotsToDelete.add(aliquot); diff --git a/src/main/java/org/earthtime/UPb_Redux/samples/SampleI.java b/src/main/java/org/earthtime/UPb_Redux/samples/SampleI.java index b79ec3c3..2e08788c 100644 --- a/src/main/java/org/earthtime/UPb_Redux/samples/SampleI.java +++ b/src/main/java/org/earthtime/UPb_Redux/samples/SampleI.java @@ -746,4 +746,7 @@ public interface SampleI { */ public void setReportSettingsModel(ReportSettings reportSettingsModel); + public void setLegacyStatusForReportTable(); + + public String getNameOfAliquotFromSample(int aliquotNum); } diff --git a/src/main/java/org/earthtime/UPb_Redux/samples/SampleMetaData.java b/src/main/java/org/earthtime/UPb_Redux/samples/SampleMetaData.java index 9ababc74..13eba5a8 100644 --- a/src/main/java/org/earthtime/UPb_Redux/samples/SampleMetaData.java +++ b/src/main/java/org/earthtime/UPb_Redux/samples/SampleMetaData.java @@ -33,7 +33,7 @@ import org.earthtime.UPb_Redux.user.UPbReduxConfigurator; import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/tracers/Tracer.java b/src/main/java/org/earthtime/UPb_Redux/tracers/Tracer.java index 986a0623..64b5c0a8 100644 --- a/src/main/java/org/earthtime/UPb_Redux/tracers/Tracer.java +++ b/src/main/java/org/earthtime/UPb_Redux/tracers/Tracer.java @@ -43,7 +43,7 @@ import org.earthtime.ratioDataModels.AbstractRatiosDataModel; import org.earthtime.ratioDataModels.tracers.TracerUPbModel; import org.earthtime.utilities.DateHelpers; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/user/ReduxPersistentState.java b/src/main/java/org/earthtime/UPb_Redux/user/ReduxPersistentState.java index 5edd5f82..75618345 100644 --- a/src/main/java/org/earthtime/UPb_Redux/user/ReduxPersistentState.java +++ b/src/main/java/org/earthtime/UPb_Redux/user/ReduxPersistentState.java @@ -23,15 +23,11 @@ import java.io.File; import java.io.IOException; import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.ArrayList; -import javax.swing.JOptionPane; import org.earthtime.UPb_Redux.ReduxConstants; import static org.earthtime.UPb_Redux.ReduxConstants.myUsersUPbReduxDataFolderName; import org.earthtime.UPb_Redux.utilities.ETSerializer; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; /** * @@ -42,6 +38,7 @@ public class ReduxPersistentState implements Serializable { // class variables private static final long serialVersionUID = -2957701651505126654L; + private static ReduxPersistentState instance = null; private static final String persistentStateFileName = "ReduxPersistentState.ser"; private static int MRU_COUNT = 10; // instance variables @@ -106,7 +103,7 @@ public ReduxPersistentState() { serializeSelf(); } - private void serializeSelf() { + public void serializeSelf() { // save off initial persistent state serialized file try { ETSerializer.SerializeObjectToFile(this, getMySerializedName()); @@ -194,134 +191,21 @@ public static ReduxPersistentState getExistingPersistentState() { dataFolder.mkdir(); } - ReduxPersistentState retval; - retval = (ReduxPersistentState) ETSerializer.GetSerializedObjectFromFile(ReduxPersistentState.getMySerializedName()); - if (retval == null) { + //instance = (ReduxPersistentState) ETSerializer.GetSerializedObjectFromFile(getMySerializedName()); + if (instance == null) { // test for transition to ET_Redux from U-Pb_Redux // jan 2015 check if old U-Pb_Redux folder exists and copy file from there File dataFolderUPbRedux = new File( File.separator + System.getProperty("user.home") + File.separator + myUsersUPbReduxDataFolderName); if (dataFolderUPbRedux.exists()) { - try { - retval = (ReduxPersistentState) ETSerializer.GetSerializedObjectFromFile(dataFolderUPbRedux.getCanonicalPath() + File.separator + persistentStateFileName); - } catch (IOException iOException) { - } + instance = (ReduxPersistentState) ETSerializer.GetSerializedObjectFromFile(getMySerializedName()); } - if (retval == null) { - retval = new ReduxPersistentState(); + if (instance == null) { + instance = new ReduxPersistentState(); } } - return retval; - } - - /** - * - * http://www.geochronportal.org/post_to_credentials_service.html - * - * @param username - * @param password - * @param isVerbose - * @return - */ - public boolean validateGeochronCredentials(String username, String password, boolean isVerbose) { - - String geochronCredentialsService = "http://www.geochron.org/credentials_service.php"; - boolean valid = false; - - getReduxPreferences().setGeochronUserName(username); - getReduxPreferences().setGeochronPassWord(password); - - String data = null; - try { - data = // - URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8"); - data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"); - } catch (UnsupportedEncodingException unsupportedEncodingException) { - } - - File fileOut = URIHelper.HTTP_PostAndResponse(// - geochronCredentialsService, - data); - - if (fileOut != null) { - org.w3c.dom.Document doc = URIHelper.ConvertXMLTextToDOMdocument(fileOut); - - if (doc != null) { - if (doc.getElementsByTagName("valid").getLength() > 0) { - valid = doc.getElementsByTagName("valid").item(0).getTextContent().trim().equalsIgnoreCase("yes"); - System.out.println("valid = " + valid); - } - } - if (isVerbose) { - JOptionPane.showMessageDialog(null, - new String[]{ - valid ? "Geochron Credentials are VALID!\n" : "Credentials NOT valid!\n" - }); - } - } else { - if (isVerbose) { - JOptionPane.showMessageDialog(null, - new String[]{"Credentials Server " + geochronCredentialsService + " cannot be located.\n" - }); - } - } - return valid; - } - - /** - * - * http://www.geosamples.org/post_to_credentials_service.html - * - * @param username - * @param password - * @param isVerbose - * @return - */ - public boolean validateSESARCredentials(String username, String password, boolean isVerbose) { - String SESARCredentialsService = "http://www.geosamples.org/credentials_service.php"; - boolean valid = false; - - getReduxPreferences().setSesarUserName(username); - getReduxPreferences().setSesarPassWord(password); - - String data = null; - try { - data = // - URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(username, "UTF-8"); - data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"); - } catch (UnsupportedEncodingException unsupportedEncodingException) { - } - - File fileOut = URIHelper.HTTP_PostAndResponse(// - SESARCredentialsService, - data); - if (fileOut != null) { - org.w3c.dom.Document doc = URIHelper.ConvertXMLTextToDOMdocument(fileOut); - - if (doc != null) { - if (doc.getElementsByTagName("valid").getLength() > 0) { - valid = doc.getElementsByTagName("valid").item(0).getTextContent().trim().equalsIgnoreCase("yes"); - System.out.println("valid = " + valid); - } - } - - if (isVerbose) { - JOptionPane.showMessageDialog(null, - new String[]{ - valid ? "SESAR Credentials are VALID!\n" : "Credentials NOT valid!\n" - }); - } - - } else { - if (isVerbose) { - JOptionPane.showMessageDialog(null, - new String[]{"Credentials Server " + SESARCredentialsService + " cannot be located.\n" - }); - } - } - - return valid; + return instance; } //properties diff --git a/src/main/java/org/earthtime/UPb_Redux/user/ReduxPreferences.java b/src/main/java/org/earthtime/UPb_Redux/user/ReduxPreferences.java index 724206a1..13ab4b00 100644 --- a/src/main/java/org/earthtime/UPb_Redux/user/ReduxPreferences.java +++ b/src/main/java/org/earthtime/UPb_Redux/user/ReduxPreferences.java @@ -37,12 +37,12 @@ public class ReduxPreferences implements Serializable { private URI tripoliSubscriptionFile; private String geochronUserName; private String geochronPassWord; - private String sesarUserName; - private String sesarPassWord ; private ANALYSIS_PURPOSE defaultSampleAnalysisPurpose; - /** Creates a new instance of ReduxPreferences */ - public ReduxPreferences () { + /** + * Creates a new instance of ReduxPreferences + */ + public ReduxPreferences() { this.fractionDataOverriddenOnImport = true; this.tripoliSubscriptionFile = null; @@ -51,48 +51,44 @@ public ReduxPreferences () { this.geochronPassWord = "longpassword"; - this.sesarUserName = "username"; - - this.sesarPassWord = "longpassword"; - this.defaultSampleAnalysisPurpose = ANALYSIS_PURPOSE.NONE; } /** - * + * * @return */ - public boolean isFractionDataOverriddenOnImport () { + public boolean isFractionDataOverriddenOnImport() { return fractionDataOverriddenOnImport; } /** - * + * * @param fractionDataOverriddenOnImport */ - public void setFractionDataOverriddenOnImport ( boolean fractionDataOverriddenOnImport ) { + public void setFractionDataOverriddenOnImport(boolean fractionDataOverriddenOnImport) { this.fractionDataOverriddenOnImport = fractionDataOverriddenOnImport; } /** * @return the tripoliSubscriptionFile */ - public URI getTripoliSubscriptionFile () { + public URI getTripoliSubscriptionFile() { return tripoliSubscriptionFile; } /** * @param tripoliSubscriptionFile the tripoliSubscriptionFile to set */ - public void setTripoliSubscriptionFile ( URI tripoliSubscriptionFile ) { + public void setTripoliSubscriptionFile(URI tripoliSubscriptionFile) { this.tripoliSubscriptionFile = tripoliSubscriptionFile; } /** * @return the geochronUserName */ - public String getGeochronUserName () { - if ( geochronUserName == null ) { + public String getGeochronUserName() { + if (geochronUserName == null) { geochronUserName = "username"; } return geochronUserName; @@ -101,15 +97,15 @@ public String getGeochronUserName () { /** * @param geochronUserName the geochronUserName to set */ - public void setGeochronUserName ( String geochronUserName ) { + public void setGeochronUserName(String geochronUserName) { this.geochronUserName = geochronUserName; } /** * @return the geochronPassWord */ - public String getGeochronPassWord () { - if ( geochronPassWord == null ) { + public String getGeochronPassWord() { + if (geochronPassWord == null) { geochronPassWord = "longpassword"; } return geochronPassWord; @@ -118,58 +114,25 @@ public String getGeochronPassWord () { /** * @param geochronPassWord the geochronPassWord to set */ - public void setGeochronPassWord ( String geochronPassWord ) { + public void setGeochronPassWord(String geochronPassWord) { this.geochronPassWord = geochronPassWord; } - /** - * @return the sesarUserName - */ - public String getSesarUserName () { - if ( sesarUserName == null ) { - sesarUserName = "username"; - } - return sesarUserName; - } - - /** - * @param sesarUserName the sesarUserName to set - */ - public void setSesarUserName ( String sesarUserName ) { - this.sesarUserName = sesarUserName; - } - - /** - * @return the sesarPassWord - */ - public String getSesarPassWord () { - if ( sesarPassWord == null ) { - sesarPassWord = "longpassword"; - } - return sesarPassWord; - } - - /** - * @param sesarPassWord the sesarPassWord to set - */ - public void setSesarPassWord ( String sesarPassWord ) { - this.sesarPassWord = sesarPassWord; - } - /** * @return the defaultSampleAnalysisPurpose */ - public ANALYSIS_PURPOSE getDefaultSampleAnalysisPurpose () { - if (defaultSampleAnalysisPurpose == null){ + public ANALYSIS_PURPOSE getDefaultSampleAnalysisPurpose() { + if (defaultSampleAnalysisPurpose == null) { defaultSampleAnalysisPurpose = ANALYSIS_PURPOSE.NONE; } return defaultSampleAnalysisPurpose; } /** - * @param defaultSampleAnalysisPurpose the defaultSampleAnalysisPurpose to set + * @param defaultSampleAnalysisPurpose the defaultSampleAnalysisPurpose to + * set */ - public void setDefaultSampleAnalysisPurpose ( ANALYSIS_PURPOSE defaultSampleAnalysisPurpose ) { + public void setDefaultSampleAnalysisPurpose(ANALYSIS_PURPOSE defaultSampleAnalysisPurpose) { this.defaultSampleAnalysisPurpose = defaultSampleAnalysisPurpose; } } diff --git a/src/main/java/org/earthtime/UPb_Redux/utilities/AnnouncementPane.java b/src/main/java/org/earthtime/UPb_Redux/utilities/AnnouncementPane.java index effac3f3..8386fed5 100644 --- a/src/main/java/org/earthtime/UPb_Redux/utilities/AnnouncementPane.java +++ b/src/main/java/org/earthtime/UPb_Redux/utilities/AnnouncementPane.java @@ -25,8 +25,8 @@ import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; -import org.earthtime.UPb_Redux.ReduxConstants; import org.earthtime.ETRedux; +import org.earthtime.UPb_Redux.ReduxConstants; /** * @@ -92,7 +92,7 @@ public void initializeAnnouncementPane(String message) { ((MessagePanel) this.messagePanel).setMessage(message); - this.add(messagePanel); + this.add(messagePanel, DEFAULT_LAYER); } diff --git a/src/main/java/org/earthtime/UPb_Redux/valueModelViews/AbstractValueModelView.java b/src/main/java/org/earthtime/UPb_Redux/valueModelViews/AbstractValueModelView.java index e404930d..a0201049 100644 --- a/src/main/java/org/earthtime/UPb_Redux/valueModelViews/AbstractValueModelView.java +++ b/src/main/java/org/earthtime/UPb_Redux/valueModelViews/AbstractValueModelView.java @@ -27,6 +27,7 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.math.BigDecimal; +import java.math.RoundingMode; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JTextField; @@ -120,7 +121,7 @@ public AbstractValueModelView ( ValueModel valueModel ) { */ protected void initTextBoxes ( boolean editable ) { valueTextBox.setDocument( new DialogEditor.BigDecimalDocument( valueTextBox, editable ) ); - valueTextBox.setText( valueModel.getValue().toString() ); + valueTextBox.setText( valueModel.getValue().setScale(15, RoundingMode.HALF_UP).toPlainString() ); uncertaintyTextBox.setDocument( new DialogEditor.BigDecimalDocument( uncertaintyTextBox, editable ) ); @@ -173,9 +174,9 @@ public void focusLost ( FocusEvent e ) { private void displayOneSigmaPerMode () { if ( isShowOneSigmaAsPerCent() ) { - uncertaintyTextBox.setText( valueModel.getOneSigmaPct().toString() ); + uncertaintyTextBox.setText( valueModel.getOneSigmaPct().setScale(15, RoundingMode.HALF_UP).toPlainString() ); } else { - uncertaintyTextBox.setText( valueModel.getOneSigmaAbs().toString() ); + uncertaintyTextBox.setText( valueModel.getOneSigmaAbs().setScale(15, RoundingMode.HALF_UP).toPlainString() ); } } diff --git a/src/main/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel.java b/src/main/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel.java index bd1c884f..f7ccf341 100644 --- a/src/main/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel.java +++ b/src/main/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel.java @@ -27,7 +27,7 @@ import org.earthtime.UPb_Redux.ReduxConstants; import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModel.java b/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModel.java index dcecd677..2561114c 100644 --- a/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModel.java +++ b/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModel.java @@ -57,7 +57,7 @@ import org.earthtime.dataDictionaries.DataDictionary; import org.earthtime.dataDictionaries.RatioNamePrettyPrinter; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; import org.w3c.dom.Document; import org.xml.sax.SAXException; diff --git a/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced.java b/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced.java index 836ab1df..8c8cc5dc 100644 --- a/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced.java +++ b/src/main/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced.java @@ -32,7 +32,7 @@ import org.earthtime.UPb_Redux.ReduxConstants; import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/archivingTools/GeochronAliquotManager.java b/src/main/java/org/earthtime/archivingTools/GeochronAliquotManager.java new file mode 100644 index 00000000..f409bcec --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/GeochronAliquotManager.java @@ -0,0 +1,695 @@ +/* + * Copyright 2015 CIRDLES. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.archivingTools; + +import java.awt.Color; +import java.awt.Desktop; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.IOException; +import java.util.Map; +import java.util.Vector; +import javax.swing.InputVerifier; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JLayeredPane; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import org.earthtime.UPb_Redux.ReduxConstants; +import org.earthtime.UPb_Redux.aliquots.Aliquot; +import org.earthtime.UPb_Redux.dateInterpretation.DateProbabilityDensityPanel; +import org.earthtime.UPb_Redux.dateInterpretation.concordia.ConcordiaGraphPanel; +import org.earthtime.UPb_Redux.dateInterpretation.graphPersistence.GraphAxesSetup; +import org.earthtime.UPb_Redux.dialogs.DialogEditor; +import org.earthtime.UPb_Redux.reduxLabData.ReduxLabData; +import org.earthtime.UPb_Redux.samples.Sample; +import org.earthtime.UPb_Redux.samples.SampleI; +import org.earthtime.archivingTools.forSESAR.SesarSample; +import org.earthtime.archivingTools.forSESAR.SesarSampleManager; +import org.earthtime.beans.ET_JButton; +import org.earthtime.dataDictionaries.RadDates; +import org.earthtime.projects.ProjectI; + +/** + * + * @author James F. Bowring + */ +public class GeochronAliquotManager extends JPanel { + + private ProjectI project; + private SampleI sample; + private final String userName; + private final String password; + private String userCode; + private String sampleIGSN; + private final int height; + private final int width; + private final static int ROW_HEIGHT = 25; + private final int LEFT_MARGIN = 5; + private final int TOP_MARGIN = 5; + private JTextField sampleNameText; + private JTextField sampleIGSNText; + private SesarSample sesarSample; + private SesarSample[] sesarAliquots; + private JButton saveButton; + private JButton registerNewSampleButton; + private JButton viewSampleRecordButton; + private JLabel checkMarkForValidSampleIGSN; + private JLabel xMarkForInValidSampleIGSN; + // aliquot fields + private Vector activeAliquots; + private JTextField[] aliquotName_TextFields; + private JTextField[] aliquotIGSN_TextFields; + private JLabel[] checkMarkForValidAliquotIGSNs; + private JLabel[] xMarkForInValidAliqutIGSNs; + private JButton[] aliquotUploadButtons; + private String[] aliquotIGSNs; + private JButton[] registerNewAliquotButtons; + private JButton[] viewAliquotRecordButtons; + private JLabel[] childStatusLabels; + private JButton[] showConcordiaButtons; + private JButton[] showPDFButtons; + private JCheckBox []publicOptionCheckBoxes; + + + + public GeochronAliquotManager(ProjectI project, SampleI sample, String userName, String password, String userCode, int x, int y, int width, int height) { + this.project = project; + this.sample = sample; + this.userName = userName; + this.password = password; + this.userCode = userCode; + this.height = height; + this.width = width; + + this.sampleIGSN = "IGSN"; + this.sesarSample = new SesarSample(userCode, userName, password, false); + + setOpaque(true); + setBackground(Color.white); + setBorder(null); + setBounds(x, y, this.width, this.height); + + setLayout(null); + + initSampleView(); + } + + private void initSampleView() { + String sampleName = sample.getSampleName(); + sampleIGSN = sample.getSampleIGSN(); + + int cumulativeWidth = LEFT_MARGIN; + add(labelFactory("Sample Name:", cumulativeWidth, TOP_MARGIN, 100)); + cumulativeWidth += 100; + + sampleNameText = new JTextField(sampleName); + sampleNameText.setBounds(cumulativeWidth, TOP_MARGIN, 150, ROW_HEIGHT); + sampleNameText.setFont(ReduxConstants.sansSerif_12_Bold); + add(sampleNameText); + sampleNameText.setInputVerifier(new InputVerifier() { + + @Override + public boolean verify(JComponent input) { + JTextField textField = (JTextField) input; + if (textField.getText().trim().length() == 0) { + textField.setText(sample.getSampleName()); + } + return true; + } + }); + cumulativeWidth += 150; + + add(labelFactory("IGSN:", cumulativeWidth, TOP_MARGIN, 35)); + cumulativeWidth += 35; + + sampleIGSNText = new JTextField(sampleIGSN); + sampleIGSNText.setBounds(cumulativeWidth, TOP_MARGIN, 90, ROW_HEIGHT); + sampleIGSNText.setFont(ReduxConstants.sansSerif_12_Bold); + add(sampleIGSNText); + sampleIGSNText.setInputVerifier(new SampleIGSNVerifier()); + sampleIGSNText.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + if ((key == KeyEvent.VK_ENTER) || (key == KeyEvent.VK_TAB)) { + sampleIGSNText.getInputVerifier().verify(sampleIGSNText); + } + } + } + ); + cumulativeWidth += 90; + + // next two occupy same space and show depending on condition + checkMarkForValidSampleIGSN = new JLabel(); + checkMarkForValidSampleIGSN.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/earthtime/UPb_Redux/images/check_icon.png"))); + checkMarkForValidSampleIGSN.setToolTipText("Sample IGSN is VALID."); + checkMarkForValidSampleIGSN.setIconTextGap(0); + checkMarkForValidSampleIGSN.setBounds(cumulativeWidth, TOP_MARGIN, 35, 25); + checkMarkForValidSampleIGSN.setVisible(false); + add(checkMarkForValidSampleIGSN); + + xMarkForInValidSampleIGSN = new JLabel(); + xMarkForInValidSampleIGSN.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/earthtime/UPb_Redux/images/icon_red_x.png"))); // NOI18N + xMarkForInValidSampleIGSN.setToolTipText("Sample IGSN is NOT valid."); + xMarkForInValidSampleIGSN.setIconTextGap(0); + xMarkForInValidSampleIGSN.setBounds(cumulativeWidth, TOP_MARGIN, 35, 25); + xMarkForInValidSampleIGSN.setVisible(false); + add(xMarkForInValidSampleIGSN); + cumulativeWidth += 40; + + // next two occupy same space and show depending on condition + registerNewSampleButton = new ET_JButton("Register New Sample"); + registerNewSampleButton.setBounds(cumulativeWidth, TOP_MARGIN, 135, 25); + registerNewSampleButton.setFont(ReduxConstants.sansSerif_12_Bold); + registerNewSampleButton.setVisible(false); + add(registerNewSampleButton); + registerNewSampleButton.addActionListener((ActionEvent e) -> { + saveSample(); + sesarSample.setIGSN(userCode); + sesarSample.setName(sample.getSampleName()); + DialogEditor sesarSampleManager = // + new SesarSampleManager(null, true, sesarSample, true); + sesarSampleManager.setVisible(true); + sample.setSampleIGSN(sesarSample.getIGSN()); + sampleIGSNText.setText(sesarSample.getIGSN()); + sampleIGSNText.getInputVerifier().verify(sampleIGSNText); + saveSample(); + }); + + viewSampleRecordButton = new ET_JButton("View Existing Record"); + viewSampleRecordButton.setBounds(cumulativeWidth, TOP_MARGIN, 135, 25); + viewSampleRecordButton.setFont(ReduxConstants.sansSerif_12_Bold); + viewSampleRecordButton.setVisible(false); + add(viewSampleRecordButton); + viewSampleRecordButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + saveSample(); + // get the igsn record and create a SesarSample to view + SesarSample mySesarSample = SesarSample.createSesarSampleFromSesarRecord(sample.getSampleIGSN()); + if (mySesarSample != null) { + sesarSample = mySesarSample; + sesarSample.setNameOfLocalSample(sample.getSampleName()); + DialogEditor sesarSampleManager = // + new SesarSampleManager(null, true, sesarSample, false); + sesarSampleManager.setVisible(true); + } else { + JOptionPane.showMessageDialog( + null, + new String[]{"Could not retrieve sample details."}, + "ET Redux Warning", + JOptionPane.WARNING_MESSAGE); + } + } + }); + cumulativeWidth += 135; + + saveButton = new ET_JButton("Save"); + saveButton.setBounds((int) (getBounds().getWidth() - 75.0), TOP_MARGIN, 73, 25); + saveButton.setFont(ReduxConstants.sansSerif_12_Bold); + saveButton.setVisible(false); + add(saveButton); + saveButton.addActionListener((ActionEvent e) -> { + saveSample(); + }); + + sampleIGSNText.getInputVerifier().verify(sampleIGSNText); + + initAliquotsOfSampleViews(); + } + + private void initAliquotsOfSampleViews() { + // aliquots + // the initial working assumption is one aliquot per sample, but we will eventually support n aliquots per sample + activeAliquots = sample.getActiveAliquots(); + int aliquotCount = activeAliquots.size(); + aliquotName_TextFields = new JTextField[aliquotCount]; + aliquotUploadButtons = new JButton[aliquotCount]; + aliquotIGSN_TextFields = new JTextField[aliquotCount]; + checkMarkForValidAliquotIGSNs = new JLabel[aliquotCount]; + xMarkForInValidAliqutIGSNs = new JLabel[aliquotCount]; + aliquotIGSNs = new String[aliquotCount]; + registerNewAliquotButtons = new JButton[aliquotCount]; + viewAliquotRecordButtons = new JButton[aliquotCount]; + sesarAliquots = new SesarSample[aliquotCount]; + childStatusLabels = new JLabel[aliquotCount]; + showConcordiaButtons = new JButton[aliquotCount]; + + for (int i = 0; i < aliquotCount; i++) { + System.out.println(sample.getSampleName() + " > " + activeAliquots.get(i).getAliquotName()); + Aliquot aliquot = activeAliquots.get(i); + String aliquotName = aliquot.getAliquotName(); + aliquotIGSNs[i] = aliquot.getAliquotIGSN(); + sesarAliquots[i] = new SesarSample(userCode, userName, password, true); + final SesarSample sesarAliquot = sesarAliquots[i]; + + int cumulativeWidth = LEFT_MARGIN; + add(labelFactory("Aliquot Name:", cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 100)); + cumulativeWidth += 100; + + aliquotName_TextFields[i] = new JTextField(aliquotName); + aliquotName_TextFields[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 150, ROW_HEIGHT); + aliquotName_TextFields[i].setFont(ReduxConstants.sansSerif_12_Bold); + add(aliquotName_TextFields[i]); + aliquotName_TextFields[i].setInputVerifier(new InputVerifier() { + + @Override + public boolean verify(JComponent input) { + JTextField textField = (JTextField) input; + if (textField.getText().trim().length() == 0) { + textField.setText(aliquotName); + } + return true; + } + }); + cumulativeWidth += 150; + + JTextField aliquotName_TextField = aliquotName_TextFields[i]; + + add(labelFactory("IGSN:", cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 35)); + cumulativeWidth += 35; + + aliquotIGSN_TextFields[i] = new JTextField(aliquotIGSNs[i]); + aliquotIGSN_TextFields[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 90, ROW_HEIGHT); + aliquotIGSN_TextFields[i].setFont(ReduxConstants.sansSerif_12_Bold); + add(aliquotIGSN_TextFields[i]); + aliquotIGSN_TextFields[i].setInputVerifier(new AliquotIGSNVerifier(i)); + aliquotIGSN_TextFields[i].addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + JTextField textField = (JTextField) e.getSource(); + int key = e.getKeyCode(); + if ((key == KeyEvent.VK_ENTER) || (key == KeyEvent.VK_TAB)) { + textField.getInputVerifier().verify(textField); + } + } + } + ); + JTextField aliquotIGSN_TextField = aliquotIGSN_TextFields[i]; + cumulativeWidth += 90; + + // next two occupy same space and show depending on condition + checkMarkForValidAliquotIGSNs[i] = new JLabel(); + checkMarkForValidAliquotIGSNs[i].setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/earthtime/UPb_Redux/images/check_icon.png"))); + checkMarkForValidAliquotIGSNs[i].setToolTipText("Aliquot IGSN is VALID."); + checkMarkForValidAliquotIGSNs[i].setIconTextGap(0); + checkMarkForValidAliquotIGSNs[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 35, 25); + checkMarkForValidAliquotIGSNs[i].setVisible(false); + add(checkMarkForValidAliquotIGSNs[i]); + + xMarkForInValidAliqutIGSNs[i] = new JLabel(); + xMarkForInValidAliqutIGSNs[i].setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/earthtime/UPb_Redux/images/icon_red_x.png"))); // NOI18N + xMarkForInValidAliqutIGSNs[i].setToolTipText("Aliquot IGSN is NOT valid."); + xMarkForInValidAliqutIGSNs[i].setIconTextGap(0); + xMarkForInValidAliqutIGSNs[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 35, 25); + xMarkForInValidAliqutIGSNs[i].setVisible(false); + add(xMarkForInValidAliqutIGSNs[i]); + cumulativeWidth += 40; + + // next two occupy same space and show depending on condition + registerNewAliquotButtons[i] = new ET_JButton("Register New Aliquot"); + registerNewAliquotButtons[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 135, 25); + registerNewAliquotButtons[i].setFont(ReduxConstants.sansSerif_12_Bold); + registerNewAliquotButtons[i].setVisible(false); + add(registerNewAliquotButtons[i]); + registerNewAliquotButtons[i].addActionListener((ActionEvent e) -> { + saveAliquot(aliquot, aliquotIGSN_TextField.getText(), aliquotName_TextField); + sesarAliquot.setIGSN(userCode); + sesarAliquot.setName(aliquot.getAliquotName()); + DialogEditor sesarSampleManager = // + new SesarSampleManager(null, true, sesarAliquot, true); + sesarSampleManager.setVisible(true); + aliquot.setAliquotIGSN(sesarAliquot.getIGSN()); + aliquotIGSN_TextField.setText(sesarAliquot.getIGSN()); + aliquotIGSN_TextField.getInputVerifier().verify(aliquotIGSN_TextField); + saveAliquot(aliquot, aliquotIGSN_TextField.getText(), aliquotName_TextField); + }); + + viewAliquotRecordButtons[i] = new ET_JButton("View Existing Record"); + viewAliquotRecordButtons[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 135, 25); + viewAliquotRecordButtons[i].setFont(ReduxConstants.sansSerif_12_Bold); + viewAliquotRecordButtons[i].setVisible(false); + add(viewAliquotRecordButtons[i]); + viewAliquotRecordButtons[i].addActionListener((ActionEvent e) -> { + saveAliquot(aliquot, aliquotIGSN_TextField.getText(), aliquotName_TextField); + // get the igsn record and create a SesarSample to view + SesarSample mySesarAliquot = SesarSample.createSesarSampleFromSesarRecord(aliquot.getAliquotIGSN()); + if (mySesarAliquot != null) { + //sesarAliquot = mySesarAliquot; + mySesarAliquot.setNameOfLocalSample(aliquot.getAliquotName()); + DialogEditor sesarSampleManager = // + new SesarSampleManager(null, true, mySesarAliquot, false); + sesarSampleManager.setVisible(true); + } else { + JOptionPane.showMessageDialog( + null, + new String[]{"Could not retrieve aliquot details."}, + "ET Redux Warning", + JOptionPane.WARNING_MESSAGE); + } + }); + cumulativeWidth += 140; + + childStatusLabels[i] = new JLabel("Aliquot IGSN is not a valid child of Sample IGSN."); + childStatusLabels[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 300, 25); + childStatusLabels[i].setFont(ReduxConstants.sansSerif_12_Bold); + childStatusLabels[i].setForeground(Color.red); + add(childStatusLabels[i]); + //cumulativeWidth += 202; + + showConcordiaButtons[i] = new ET_JButton("View Concordia in browser"); + showConcordiaButtons[i].setBounds(cumulativeWidth, TOP_MARGIN + 30 * (i + 1), 150, 25); + showConcordiaButtons[i].setFont(ReduxConstants.sansSerif_10_Bold); + showConcordiaButtons[i].setVisible(false); + add(showConcordiaButtons[i], JLayeredPane.DEFAULT_LAYER); + showConcordiaButtons[i].addActionListener((ActionEvent e) -> { + produceConcordiaGraph(sample); + }); + +// JButton showPDFButton = new ET_JButton("View PDF in browser"); +// showPDFButton.setBounds(leftMargin + 150 + 100 + 50 + 2 + 150 + 2, topMarginForSampleDetails + row * 25, 150, 25); +// showPDFButton.setFont(ReduxConstants.sansSerif_10_Bold); +// showPDFButton.setName(String.valueOf(row)); +// showPDFButton.setVisible(false); +// sampleShowPDFButtons.add(showPDFButton); +// exportManagerLayeredPane.add(showPDFButton, JLayeredPane.DEFAULT_LAYER); +// showPDFButton.addActionListener((ActionEvent e) -> { +// EarthTimeSerializedFileInterface deserializedFile = // +// (EarthTimeSerializedFileInterface) ETSerializer.GetSerializedObjectFromFile(ss.getSampleReduxFilePath().toString()); +// Sample sample = (Sample) deserializedFile; +// producePDFImage(sample); +// }); +// +// JCheckBox publicOptionCheckBox = new JCheckBox("Public ?"); +// publicOptionCheckBox.setBounds(leftMargin + 150 + 100 + 50 + 2 + 150 + 2 + 150 + 2, topMarginForSampleDetails + row * 25, 100, 25); +// publicOptionCheckBox.setFont(ReduxConstants.sansSerif_10_Bold); +// publicOptionCheckBox.setName(String.valueOf(row)); +// publicOptionCheckBox.setVisible(false); +// samplePublicCheckBoxes.add(publicOptionCheckBox); +// exportManagerLayeredPane.add(publicOptionCheckBox, JLayeredPane.DEFAULT_LAYER); +//// +// +// +// + aliquotUploadButtons[i] = new ET_JButton("Upload"); + aliquotUploadButtons[i].setBounds(LEFT_MARGIN + 800, TOP_MARGIN + 30 * (i + 1), 75, 25); + aliquotUploadButtons[i].setFont(ReduxConstants.sansSerif_12_Bold); + aliquotUploadButtons[i].setVisible(false); + add(aliquotUploadButtons[i]); + aliquotUploadButtons[i].addActionListener((ActionEvent e) -> { + aliquot.setSampleIGSN("SSR." + sampleIGSN.trim()); + GeochronUploaderUtility.uploadAliquotToGeochron(// + (Sample) sample, aliquot, // + userName, // + password, // + true, true); + }); + + aliquotIGSN_TextFields[i].getInputVerifier().verify(aliquotIGSN_TextFields[i]); + + } + + } + + private void saveSample() { + sample.setSampleIGSN(sampleIGSN.trim().toUpperCase()); + // rename supersample aliquots with new sample name + Vector aliquots = project.getCompiledSuperSample().getAliquots(); + aliquots.stream().forEach((aliquot) -> { + String aliquotName = aliquot.getAliquotName(); + String sName = sample.getSampleName().trim(); + if (aliquotName.startsWith(sName + "::")) { + aliquotName = aliquotName.replace(sName + "::", sampleNameText.getText().trim() + "::"); + aliquot.setAliquotName(aliquotName); + } + }); + sample.setSampleName(sampleNameText.getText().trim()); + } + + private void saveAliquot(Aliquot myAliquot, String aliquotIGSN, JTextField aliquotName_TextField) { + myAliquot.setAliquotIGSN(aliquotIGSN); + // rename supersample aliquot also + Vector aliquots = project.getCompiledSuperSample().getAliquots(); + aliquots.stream().forEach((aliquot) -> { + String aliquotName = aliquot.getAliquotName(); + String aName = myAliquot.getAliquotName().trim(); + if (aliquotName.endsWith("::" + aName)) { + aliquotName = aliquotName.replace("::" + aName, "::" + aliquotName_TextField.getText().trim()); + aliquot.setAliquotName(aliquotName); + } + }); + + myAliquot.setAliquotName(aliquotName_TextField.getText().trim()); + } + + private JLabel labelFactory(String text, int x, int y, int width) { + JLabel label = new JLabel(text); + label.setBounds(x, y, width, ROW_HEIGHT); + label.setFont(ReduxConstants.sansSerif_12_Bold); + + return label; + } + + private void updateValidSampleDisplay(boolean valid) { + checkMarkForValidSampleIGSN.setVisible(valid); + xMarkForInValidSampleIGSN.setVisible(!valid); + + viewSampleRecordButton.setVisible(valid); + registerNewSampleButton.setVisible(!valid); + +// saveButton.setVisible(valid); + } + + private void updateValidAliquotDisplay(int index, boolean valid) { + checkMarkForValidAliquotIGSNs[index].setVisible(valid); + xMarkForInValidAliqutIGSNs[index].setVisible(!valid); + + viewAliquotRecordButtons[index].setVisible(valid); + registerNewAliquotButtons[index].setVisible(!valid); + + childStatusLabels[index].setVisible(!valid); + showConcordiaButtons[index].setVisible(valid); + +// +// saveButton.setVisible(valid); + //uploadButton.setVisible(valid); + } + + private class SampleIGSNVerifier extends InputVerifier { + + public boolean verify(JComponent input) { + JTextField textField = (JTextField) input; + String proposedIGSN = textField.getText().toUpperCase(); + textField.setText(proposedIGSN); + if (SesarSample.validateSampleIGSNatSESAR(proposedIGSN)) { + sampleIGSN = proposedIGSN.trim().toUpperCase(); + saveSample(); + updateValidSampleDisplay(true); + } else { + if (userCode.trim().length() == 0) { + xMarkForInValidSampleIGSN.setToolTipText("Please validate credentials above."); + } else { + xMarkForInValidSampleIGSN.setToolTipText("SESAR does not have a record of IGSN " + proposedIGSN); + } + + sampleIGSN = "IGSN"; + updateValidSampleDisplay(false); + } + return true; + } + } + + private class AliquotIGSNVerifier extends InputVerifier { + + private int index; + + public AliquotIGSNVerifier(int index) { + this.index = index; + } + + public boolean verify(JComponent input) { + JTextField textField = (JTextField) input; + String proposedIGSN = textField.getText().toUpperCase(); + textField.setText(proposedIGSN); + if (SesarSample.validateAliquotIGSNatSESAR(proposedIGSN, sample.getSampleIGSN())) { + aliquotIGSNs[index] = proposedIGSN.trim().toUpperCase(); + saveAliquot(activeAliquots.get(index), aliquotIGSN_TextFields[index].getText(), aliquotName_TextFields[index]); + updateValidAliquotDisplay(index, true); + } else { + if (userCode.trim().length() == 0) { + xMarkForInValidAliqutIGSNs[index].setToolTipText("Please validate credentials above."); + } else if (!proposedIGSN.toUpperCase().startsWith(userCode.toUpperCase())) { + xMarkForInValidAliqutIGSNs[index].setToolTipText(proposedIGSN + " uses incorrect User Code. Your User Code is: " + userCode); + } else { + xMarkForInValidAliqutIGSNs[index].setToolTipText("SESAR does not have a record of IGSN " + proposedIGSN); + } + + aliquotIGSNs[index] = "IGSN"; + updateValidAliquotDisplay(index, false); + } + return true; + } + } + + private void produceConcordiaGraph(SampleI sample) { + // feb 2015 code copied and modified from aliquot manager for user interface prototyping + // TODO: refactor both locations to smaple and make more robust + // TODO: use create virtual file system + +// try { +// FileSystem virtualFileSystem = Jimfs.newFileSystem(Configuration.unix()); +// Path virtualPathToSVG = virtualFileSystem.getPath("", sample.getSampleName() + ".svg"); +// +// } catch (Exception e) { +// System.out.println("JIMFS Worked"); +// } + File tempConcordiaSVG = new File(sample.getSampleName() + "_tempConcordia.svg"); + sample.setMyReduxLabData(ReduxLabData.getInstance()); + + ConcordiaGraphPanel concordiaGraphPanel = new ConcordiaGraphPanel((Sample)sample, null); + + sample.getSampleDateInterpretationGUISettings().// + setConcordiaOptions(concordiaGraphPanel.getConcordiaOptions()); + concordiaGraphPanel.// + setFadedDeselectedFractions(false); + + // set choices per options code copied (TODO: REFACTOR ME) from SampleDateInterpretations + Map CGO = concordiaGraphPanel.getConcordiaOptions(); + if (CGO.containsKey("showEllipseLabels")) { + concordiaGraphPanel.setShowEllipseLabels(false); + } + if (CGO.containsKey("showExcludedEllipses")) { + concordiaGraphPanel.setShowExcludedEllipses(true); + } + + concordiaGraphPanel.setSelectedFractions(sample.getUPbFractions()); + + concordiaGraphPanel.setBounds(510, 0, 580, 405); + concordiaGraphPanel.setCurrentGraphAxesSetup(new GraphAxesSetup("C", 2)); + concordiaGraphPanel.setGraphWidth(565 - GraphAxesSetup.DEFAULT_GRAPH_LEFT_MARGIN_VERTICAL_LABELS); + concordiaGraphPanel.setGraphHeight(385); + + concordiaGraphPanel.setYorkFitLine(null); + concordiaGraphPanel.getDeSelectedFractions().clear(); + concordiaGraphPanel.setPreferredDatePanel(null); + + concordiaGraphPanel.setShowTightToEdges(true); + + concordiaGraphPanel.refreshPanel(); + + concordiaGraphPanel.setShowTightToEdges(false); + + boolean saveShowTitleBox = concordiaGraphPanel.isShowTitleBox(); + concordiaGraphPanel.setShowTitleBox(false); + concordiaGraphPanel.setUploadToGeochronMode(true); + + concordiaGraphPanel.outputToSVG(tempConcordiaSVG); + // concordiaGraphPanel.outputToSVG(virtualPathToSVG.toFile()); + + concordiaGraphPanel.setShowTitleBox(saveShowTitleBox); + concordiaGraphPanel.setUploadToGeochronMode(false); + + // show in a browser +// Desktop.getDesktop().browse(virtualPathToSVG.toUri()); + try { + Desktop.getDesktop().browse(tempConcordiaSVG.toURI()); + } catch (IOException iOException) { + System.out.println("Browser issue " + iOException.getMessage()); + } + + } + + private void producePDFImage(Sample sample) { + File tempProbabilitySVG = new File(sample.getSampleName() + "_tempProbabilityDensity.svg"); + sample.setMyReduxLabData(ReduxLabData.getInstance()); + + DateProbabilityDensityPanel probabilityPanel = new DateProbabilityDensityPanel(sample); + + // use default if user has not initialized + if (probabilityPanel.getSelectedFractions().isEmpty()) { + probabilityPanel.// + setSelectedFractions(sample.getUpbFractionsUnknown()); + probabilityPanel.// + getDeSelectedFractions().clear(); + + probabilityPanel.setGraphWidth(565); + probabilityPanel.setGraphHeight(385); + + probabilityPanel.setSelectedHistogramBinCount(5); + + if (sample.isTypeLegacy() & sample.getAnalysisPurpose().equals(ReduxConstants.ANALYSIS_PURPOSE.DetritalSpectrum)) { + probabilityPanel.setChosenDateName(RadDates.bestAge.getName()); + } else { + probabilityPanel.setChosenDateName(RadDates.age207_206r.getName()); + } + + probabilityPanel.showTight(); + + } else { + probabilityPanel.setGraphWidth(565); + probabilityPanel.setGraphHeight(385); + } + + probabilityPanel.setUploadToGeochronMode(true); + + probabilityPanel.outputToSVG(tempProbabilitySVG); + + probabilityPanel.setUploadToGeochronMode(false); + + try { + Desktop.getDesktop().browse(tempProbabilitySVG.toURI()); + } catch (IOException iOException) { + System.out.println("Browser issue " + iOException.getMessage()); + } + + } + /** + * + * @param g + */ + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + paint((Graphics2D) g); + } + + /** + * + * @param g2d + */ + public void paint(Graphics2D g2d) { + + RenderingHints rh = g2d.getRenderingHints(); + rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + g2d.setRenderingHints(rh); + + // bottom border + g2d.setColor(Color.black); + // g2d.drawRect(0, getBounds().height - 1, getWidth() - 1, getBounds().height - 1); + g2d.drawRect(1, 1, getBounds().width - 2, getBounds().height - 2); + } +} diff --git a/src/main/java/org/earthtime/utilities/GeochronUploadImagesHelper.java b/src/main/java/org/earthtime/archivingTools/GeochronUploadImagesHelper.java similarity index 98% rename from src/main/java/org/earthtime/utilities/GeochronUploadImagesHelper.java rename to src/main/java/org/earthtime/archivingTools/GeochronUploadImagesHelper.java index f1b78da3..0d0d8455 100644 --- a/src/main/java/org/earthtime/utilities/GeochronUploadImagesHelper.java +++ b/src/main/java/org/earthtime/archivingTools/GeochronUploadImagesHelper.java @@ -18,7 +18,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.earthtime.utilities; +package org.earthtime.archivingTools; import java.io.File; import java.io.IOException; diff --git a/src/main/java/org/earthtime/archivingTools/GeochronUploaderUtility.java b/src/main/java/org/earthtime/archivingTools/GeochronUploaderUtility.java new file mode 100644 index 00000000..44a0091d --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/GeochronUploaderUtility.java @@ -0,0 +1,138 @@ +/* + * GeochronUploaderUtility.java + * + * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.archivingTools; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLEncoder; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; +import javax.swing.JOptionPane; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.earthtime.UPb_Redux.aliquots.Aliquot; +import org.earthtime.UPb_Redux.aliquots.UPbReduxAliquot; +import org.earthtime.UPb_Redux.samples.Sample; +import org.earthtime.UPb_Redux.utilities.ClientHttpRequest; +import org.xml.sax.SAXException; + +/** + * + * @author James F. Bowring + */ +public class GeochronUploaderUtility { + + + public static void uploadAliquotToGeochron(Sample sample, Aliquot aliquot, String userName, String password, boolean isPublic, boolean overWrite) { + // feb 2015 part of refactoring effort ... this code cduplicate code in AliquotManager + //TODO: complete refactoring + + String content = ((UPbReduxAliquot)aliquot).serializeXMLObject(); + + // Construct data + String isPublicString = isPublic ? "yes" : "no"; + String overWriteString = overWrite ? "yes" : "no"; + String data = ""; + try { + data = URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode(userName, "UTF-8"); + data += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8"); + data += "&" + URLEncoder.encode("public", "UTF-8") + "=" + URLEncoder.encode(isPublicString, "UTF-8"); + data += "&" + URLEncoder.encode("content", "UTF-8") + "=" + URLEncoder.encode(content, "UTF-8"); + data += "&" + URLEncoder.encode("overwrite", "UTF-8") + "=" + URLEncoder.encode(overWriteString, "UTF-8"); + } catch (UnsupportedEncodingException unsupportedEncodingException) { + } + + // april 2009 move to zipping for improved upload performance + // http://www.exampledepot.com/egs/java.util.zip/CreateZip.html + // These are the files to include in the ZIP file + // geochron expects this file name exactly + String fileName = "tempDataForAliquotUpload"; + + // Create a buffer for reading the files + byte[] buf = new byte[2048]; + + try { + // Create the ZIP file + String outFilename = "tempDataForAliquotUploadzip"; + ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename)); + + // Compress the file + //FileInputStream in = new FileInputStream(fileName); + InputStream in = new ByteArrayInputStream(data.getBytes()); + + // Add ZIP entry to output stream. + out.putNextEntry(new ZipEntry(fileName)); + + // Transfer bytes from the file to the ZIP file + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + + // Complete the entry + out.closeEntry(); + in.close(); + + // Complete the ZIP file + out.close(); + } catch (IOException e) { + } + + File uploadFile = new File("tempDataForAliquotUploadzip"); + + InputStream response = null; + try { + response = ClientHttpRequest.post(// + new URL("http://www.geochron.org/redux_service.php"),// + "filetoupload", + uploadFile); + } catch (IOException iOException) { + } + + org.w3c.dom.Document doc = null; + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(false); + try { + doc = factory.newDocumentBuilder().parse(response); + } catch (ParserConfigurationException | SAXException | IOException parserConfigurationException) { + } + + String error = "no"; + String message = ""; + if (doc != null) { + if (doc.getElementsByTagName("error").getLength() > 0) { + error = doc.getElementsByTagName("error").item(0).getTextContent(); + message = doc.getElementsByTagName("message").item(0).getTextContent(); + } + } + + sample.setArchivedInRegistry(error.equalsIgnoreCase("no")); + + JOptionPane.showMessageDialog(null, + new String[]{ + !error.equalsIgnoreCase("no") ? "Failure!\n" : "Success!\n", + message + " " + aliquot.getSampleIGSN() + "::" + aliquot.getAliquotName() + }); + } + +} diff --git a/src/main/java/org/earthtime/archivingTools/IEDACredentialsValidator.java b/src/main/java/org/earthtime/archivingTools/IEDACredentialsValidator.java new file mode 100644 index 00000000..11cc8e82 --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/IEDACredentialsValidator.java @@ -0,0 +1,171 @@ +/* + * Copyright 2015 CIRDLES. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.archivingTools; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.JOptionPane; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import org.earthtime.UPb_Redux.user.ReduxPersistentState; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * + * @author James F. Bowring + */ +public class IEDACredentialsValidator { + + public static String validateSesarCredentials(String username, String password, boolean isVerbose) { + + String sesarCredentialsService = "http://app.geosamples.org/webservices/credentials_service.php";//note test http://sesar3.geoinfogeochem.org/webservices/credentials_service.php + boolean valid = false; + // Feb 2015 userCode is prefix for IGSN + String userCode = ""; + + // using geochron as identifier since both are same and need backward compartibility for serialization + ReduxPersistentState myState = ReduxPersistentState.getExistingPersistentState(); + myState.getReduxPreferences().setGeochronUserName(username); + myState.getReduxPreferences().setGeochronPassWord(password); + myState.serializeSelf(); + + Document doc = HTTP_PostAndResponse(username, password, sesarCredentialsService); + + if (doc != null) { + if (doc.getElementsByTagName("valid").getLength() > 0) { + valid = doc.getElementsByTagName("valid").item(0).getTextContent().trim().equalsIgnoreCase("yes"); + if (valid) { + userCode = doc.getElementsByTagName("user_code").item(0).getTextContent().trim(); + } + } + + if (isVerbose) { + JOptionPane.showMessageDialog(null, + new String[]{ + valid ? "SESAR credentials are VALID!\n" : "SESAR credentials NOT valid!\n" + }); + } + } else { + if (isVerbose) { + JOptionPane.showMessageDialog(null, + new String[]{"SESAR Credentials Server " + sesarCredentialsService + " cannot be located.\n" + }); + } + } + return userCode; + } + + /** + * + * http://www.geochronportal.org/post_to_credentials_service.html + * + * @param username + * @param password + * @param isVerbose + * @return + */ + public static String validateGeochronCredentials(String username, String password, boolean isVerbose) { + + String geochronCredentialsService = "http://www.geochron.org/credentials_service.php"; + boolean valid = false; + // Feb 2015 userCode is prefix for IGSN + String userCode = ""; + + // using geochron as identifier since both are same and need backward compartibility for serialization + ReduxPersistentState.getExistingPersistentState().getReduxPreferences().setGeochronUserName(username); + ReduxPersistentState.getExistingPersistentState().getReduxPreferences().setGeochronPassWord(password); + + Document doc = HTTP_PostAndResponse(username, password, geochronCredentialsService); + + if (doc != null) { + if (doc.getElementsByTagName("valid").getLength() > 0) { + valid = doc.getElementsByTagName("valid").item(0).getTextContent().trim().equalsIgnoreCase("yes"); + if (valid) { + userCode = doc.getElementsByTagName("user_code").item(0).getTextContent().trim(); + } + } + + if (isVerbose) { + JOptionPane.showMessageDialog(null, + new String[]{ + valid ? "GeoChron credentials are VALID!\n" : "GeoChron credentials NOT valid!\n" + }); + } + } else { + if (isVerbose) { + JOptionPane.showMessageDialog(null, + new String[]{"Credentials Server " + geochronCredentialsService + " cannot be located.\n" + }); + } + } + + return userCode; + } + + private static Document HTTP_PostAndResponse(String userName, String password, String credentialsService) { + Document doc = null; + Map dataToPost = new HashMap<>(); + dataToPost.put("username", userName); + dataToPost.put("password", password); + + CloseableHttpClient httpclient = HttpClients.createDefault(); + org.apache.http.client.methods.HttpPost httpPost = new HttpPost(credentialsService); + List nameValuePairs = new ArrayList(); + nameValuePairs.add(new BasicNameValuePair("username", userName)); + nameValuePairs.add(new BasicNameValuePair("password", password)); + CloseableHttpResponse httpResponse = null; + try { + httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); + httpResponse = httpclient.execute(httpPost); + HttpEntity myEntity = httpResponse.getEntity(); + InputStream response = myEntity.getContent(); + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(false); + try { + doc = factory.newDocumentBuilder().parse(response); + //System.out.println("CCCC" + doc.getElementsByTagName("valid").item(0).getTextContent().trim()); + } catch (ParserConfigurationException | SAXException | IOException parserConfigurationException) { + System.out.println("PARSE error " + parserConfigurationException.getMessage()); + } + + EntityUtils.consume(myEntity); + } catch (IOException iOException) { + + } finally { + try { + httpResponse.close(); + } catch (IOException iOException) { + } + } + + return doc; + } +} diff --git a/src/main/java/org/earthtime/utilities/URIHelper.java b/src/main/java/org/earthtime/archivingTools/URIHelper.java similarity index 89% rename from src/main/java/org/earthtime/utilities/URIHelper.java rename to src/main/java/org/earthtime/archivingTools/URIHelper.java index e74a9ea7..7845f605 100644 --- a/src/main/java/org/earthtime/utilities/URIHelper.java +++ b/src/main/java/org/earthtime/archivingTools/URIHelper.java @@ -18,10 +18,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.earthtime.utilities; +package org.earthtime.archivingTools; import java.io.BufferedReader; -import java.io.DataOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -82,7 +81,7 @@ public static InputStream getInputStreamFromURI(String fileURI) { urlConn.setUseCaches(false); retval = urlConn.getInputStream(); - + } catch (IOException iOException) { JOptionPane.showMessageDialog(null, new String[]{"Error reaching server: "// @@ -215,7 +214,6 @@ public static BufferedReader getBufferedReader(String filename) // // return retval; // } - /** * * @param reader @@ -326,56 +324,58 @@ public static org.w3c.dom.Document RetrieveXMLfromServerAsDOMdocument(String con }); ex.printStackTrace(); } - return ConvertXMLTextToDOMdocument(new File(tempSESARFileName)); + return convertXMLTextToDOMdocument(new File(tempSESARFileName)); } - /** - * - * @param serviceURI - * @param data - * @return - */ - public static File HTTP_PostAndResponse(String serviceURI, String data) { - File fileOut = new File("HTTP_PostAndResponse_tempXML.xml"); - fileOut.delete(); - - try { - // Send data - URL url = new URL(serviceURI); - URLConnection conn = url.openConnection(); - conn.setDoOutput(true); - conn.setDoInput(true); - - // The POST line - try (DataOutputStream dstream = new DataOutputStream(conn.getOutputStream())) { - // The POST line - dstream.writeBytes(data); - } - - FileOutputStream streamOut; - try ( // Read Response - InputStream in = conn.getInputStream()) { - streamOut = new FileOutputStream(fileOut); - int x; - while ((x = in.read()) != -1) { - streamOut.write(x); - //System.out.write(x); - } - } - streamOut.close(); - } catch (Exception e) { - return null; - } - - return fileOut; - } +// /** +// * +// * @param serviceURI +// * @param data +// * @return +// */ +// public static File HTTP_PostAndResponse(String serviceURI, String data, String fileTag) { +// File fileOut = null; +// try { +// // Send data +// URL url = new URL(serviceURI); +// URLConnection conn = url.openConnection(); +// conn.setDoOutput(true); +// conn.setDoInput(true); +// +// // The POST line +// try (DataOutputStream dstream = new DataOutputStream(conn.getOutputStream())) { +// // The POST line +// dstream.writeBytes(data); +// } +// +// fileOut = new File(fileTag + "HTTP_PostAndResponse_tempXML.xml"); +// fileOut.delete(); +// +// FileOutputStream streamOut; +// +// try ( // Read Response +// InputStream in = conn.getInputStream()) {// +// streamOut = new FileOutputStream(fileOut); +// int x; +// while ((x = in.read()) != -1) { +// streamOut.write(x); +// //System.out.write(x); +// } +// } +// streamOut.close(); +// } catch (Exception e) { +// return null; +// } +// +// return fileOut; +// } /** * * @param XMLfile * @return */ - public static org.w3c.dom.Document ConvertXMLTextToDOMdocument(File XMLfile) { + public static org.w3c.dom.Document convertXMLTextToDOMdocument(File XMLfile) { org.w3c.dom.Document doc = null; // Parses an XML file and returns a DOM document. diff --git a/src/main/java/org/earthtime/archivingTools/forSESAR/CoordinateSystemConversions.java b/src/main/java/org/earthtime/archivingTools/forSESAR/CoordinateSystemConversions.java new file mode 100644 index 00000000..f23187f6 --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/forSESAR/CoordinateSystemConversions.java @@ -0,0 +1,71 @@ +/* + * Copyright 2015 CIRDLES. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.archivingTools.forSESAR; + +import java.math.BigDecimal; +import java.math.MathContext; +import java.math.RoundingMode; +import org.earthtime.UPb_Redux.utilities.BrowserControl; + +/** + * + * @author James F. Bowring + */ +public class CoordinateSystemConversions { + + private final static BigDecimal sixty = new BigDecimal(60); + + public static BigDecimal[] convertDecimalCoordinateToDMS(BigDecimal coordDecimal) { + BigDecimal[] coordDMS = new BigDecimal[3]; + + BigDecimal[] degreeMinute = coordDecimal.abs().multiply(sixty, new MathContext(6)).setScale(0, RoundingMode.FLOOR).divideAndRemainder(sixty, new MathContext(6)); + // only degrees canhave negative value + coordDMS[0] = (coordDecimal.signum() < 0) ? degreeMinute[0].negate() : degreeMinute[0]; + coordDMS[1] = degreeMinute[1]; + + BigDecimal[] degreex60Minute = coordDecimal.abs().multiply(sixty).multiply(sixty).divideAndRemainder(sixty); + coordDMS[2] = degreex60Minute[1].setScale(4, RoundingMode.HALF_UP); + + return coordDMS; + } + + public static BigDecimal convertDMSCoordinateToDecimal(BigDecimal[] coordDMS) { + BigDecimal coordDecimal = null; + + coordDecimal = coordDMS[0].abs()// + .add(coordDMS[1].divide(sixty, 6, RoundingMode.HALF_UP))// + .add(coordDMS[2].divide(sixty, 6, RoundingMode.HALF_UP).divide(sixty, 6, RoundingMode.HALF_UP)).setScale(6, RoundingMode.HALF_UP); + + if (coordDMS[0].signum() < 0) { + coordDecimal = coordDecimal.negate(); + } + + return coordDecimal; + } + + public static void launchGoogleMapsForLatLong(BigDecimal latDecimal, BigDecimal longDecimal) { + String displayString = latDecimal.setScale(6, RoundingMode.HALF_UP).toPlainString() + "," + longDecimal.setScale(6, RoundingMode.HALF_UP).toPlainString(); + BrowserControl.displayURL(// + "https://maps.googleapis.com/maps/api/staticmap?center" // + + displayString + "&markers=color:red%7Clabel:S%7C" // + + displayString + "&zoom=11&size=400x400"); + } + + public static String getDecimalCoordinateAsString(BigDecimal coordinate){ + return coordinate.setScale(6).toPlainString(); + } + +} diff --git a/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSample.java b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSample.java new file mode 100644 index 00000000..a3802869 --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSample.java @@ -0,0 +1,631 @@ +/* + * SesarSample.java + * + * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.archivingTools.forSESAR; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.ConversionException; +import com.thoughtworks.xstream.io.xml.DomDriver; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.math.BigDecimal; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; +import javax.swing.JOptionPane; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.earthtime.UPb_Redux.utilities.ClientHttpRequest; +import org.earthtime.archivingTools.URIHelper; +import static org.earthtime.archivingTools.URIHelper.convertXMLTextToDOMdocument; +import org.earthtime.dataDictionaries.SESAR_MaterialTypesEnum; +import org.earthtime.dataDictionaries.SESAR_ObjectTypesEnum; +import org.earthtime.exceptions.ETException; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * Based on http://www.iedadata.org/services/sesar_api + * + * @author James F. Bowring + */ +public class SesarSample { + + private String userCode; + private String userName; + private String password; + private String sampleType; + private String material; + private String IGSN; + private String parentIGSN; + private String name; + private String nameOfLocalSample; + private String description; + private BigDecimal latitude; + private BigDecimal longitude; + private String primaryLocationName; + private String country; + private String collection_start_date; + private String originalArchive; + private String[] children; + private boolean isChild; + + public SesarSample() { + this("", "", "", false); + } + + /** + * + * @param userCode the value of userCode + * @param userName the value of userName + * @param password the value of password + * @param isParent the value of isParent + */ + public SesarSample(String userCode, String userName, String password, boolean isChild) { + this.userCode = userCode; + this.userName = userName; + this.password = password; + this.sampleType = SESAR_ObjectTypesEnum.IndividualSample.getName(); + this.material = SESAR_MaterialTypesEnum.Mineral.getName(); + this.IGSN = ""; + this.parentIGSN = ""; + this.name = ""; + this.nameOfLocalSample = ""; + this.description = ""; + this.latitude = BigDecimal.ZERO; + this.longitude = BigDecimal.ZERO; + this.primaryLocationName = ""; + this.country = ""; + this.collection_start_date = ""; + this.originalArchive = ""; + this.children = new String[0]; + this.isChild = isChild; + } + + public boolean confirmUserCodeCompliance(String proposedIGSN) { + return proposedIGSN.toUpperCase().startsWith(userCode.toUpperCase()); + } + + public SESAR_ObjectTypesEnum getSesarObjectType() { + SESAR_ObjectTypesEnum retval; + if (sampleType.length() == 0) { + retval = SESAR_ObjectTypesEnum.Other; + } else { + try { + retval = SESAR_ObjectTypesEnum.valueOf(sampleType.replace(" ", "")); + } catch (Exception e) { + retval = SESAR_ObjectTypesEnum.Other; + } + } + + return retval; + } + + public SESAR_MaterialTypesEnum getSesarMaterialType() { + SESAR_MaterialTypesEnum retval; + if (material.length() == 0) { + retval = SESAR_MaterialTypesEnum.Other; + } else { + try { + retval = SESAR_MaterialTypesEnum.valueOf(material.replace(" ", "")); + } catch (Exception e) { + retval = SESAR_MaterialTypesEnum.Other; + } + } + + return retval; + } + + public boolean hasNameClashBetweenLocalAndSesar() { + return (name.compareToIgnoreCase(nameOfLocalSample) != 0); + } + + public static SesarSample createSesarSampleFromSesarRecord(String igsn) { + SesarSample sesarSample = null; + try { + File sample = retrieveXMLFileFromSesarForIGSN(igsn); + + // replace the results tag with sample tag + // todo make more robust + Path file = sample.toPath(); + byte[] fileArray; + fileArray = Files.readAllBytes(file); + String str = new String(fileArray, "UTF-8"); + str = str.replace("results", "sample"); + fileArray = str.getBytes(); + Files.write(file, fileArray); + + sesarSample = (SesarSample) readXMLObject(file.toString()); + } catch (IOException | ETException iOException) { + } + + return sesarSample; + } + + private static File retrieveXMLFileFromSesarForIGSN(String igsn) { + + String tempSESARcontents = // + URIHelper.getTextFromURI("http://app.geosamples.org/webservices/display.php?igsn=" + igsn); + + // write this to a file + String fileNameForIGSN = "IGSN_" + igsn + "_fromSESAR.xml"; + FileOutputStream fos = null; + try { + fos = new FileOutputStream(fileNameForIGSN); + } catch (FileNotFoundException ex) { + } + + OutputStreamWriter out = new OutputStreamWriter(fos); + try { + out.write(tempSESARcontents); + out.flush(); + out.close(); + } catch (IOException ex) { + JOptionPane.showMessageDialog(null, + new String[]{ + "Error reaching server: "// + + ex.getMessage() + }); +// ex.printStackTrace(); + } + return new File(fileNameForIGSN); + } + + public static Object readXMLObject(String filename) + throws FileNotFoundException, ETException { + SesarSample sesarSample = null; + + BufferedReader reader = URIHelper.getBufferedReader(filename); + + if (reader != null) { + + XStream xstream = getXStreamReader(); + + try { + sesarSample = (SesarSample) xstream.fromXML(reader); + } catch (ConversionException e) { + throw new ETException(null, e.getMessage()); + } + + System.out.println("\nThis is your SesarSample that was just read successfully:\n"); + + String xml2 = getXStreamWriter().toXML(sesarSample); + + System.out.println(xml2); + System.out.flush(); + + } else { + throw new FileNotFoundException("Missing XML data file."); + } + + return sesarSample; + } + + public String uploadAndRegisterSesarSample() { + + String content = serializeForUploadToSesar(); + + Map dataToPost = new HashMap<>(); + dataToPost.put("username", userName); + dataToPost.put("password", password); + dataToPost.put("content", content); + + InputStream response = null; + try { + response = ClientHttpRequest.post(// + new URL("http://app.geosamples.org/webservices/uploadservice.php"),// + dataToPost); + } catch (IOException iOException) { + } + + org.w3c.dom.Document doc = null; + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(false); + try { + doc = factory.newDocumentBuilder().parse(response); + } catch (ParserConfigurationException | SAXException | IOException parserConfigurationException) { + System.out.println("PARSE error " + parserConfigurationException.getMessage()); + } + + String statusMessage = "SESAR registration status: "; + String igsnMessage = "IGSN = "; + String igsnValue = ""; + String errorMessage = ""; + if (doc != null) { + if (doc.getElementsByTagName("status").getLength() > 0) { + statusMessage += doc.getElementsByTagName("status").item(0).getTextContent(); + if (doc.getElementsByTagName("igsn").getLength() > 0) { + // success + igsnValue = doc.getElementsByTagName("igsn").item(0).getTextContent(); + igsnMessage += igsnValue; + } else if (doc.getElementsByTagName("error").getLength() > 0) { + // take first error + errorMessage = doc.getElementsByTagName("error").item(0).getTextContent(); + } + } + } + + JOptionPane.showMessageDialog(null, + new String[]{ + statusMessage, + (igsnValue.length() == 0) ? errorMessage : igsnMessage + }, // + (igsnValue.length() == 0) ? "ET Redux Warning" : "ET Redux Information",// + (igsnValue.length() == 0) ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE); + + return igsnValue; + } + + // XML Serialization + /** + * gets an XStream writer. Creates, customizes, and returns + * XStream for XML serialization + * + * @pre XStream package is available @post XStream + * for XML encoding is returned + * + * @return XStream - for XML serialization encoding + */ + public static XStream getXStreamWriter() { + XStream xstream = new XStream(); + + customizeXstream(xstream); + + return xstream; + } + + /** + * gets an XStream reader. Creates, customizes, and returns + * XStream for XML serialization + * + * @pre XStream package is available @post XStream + * for XML decoding is returned + * + * @return XStream - for XML serialization decoding + */ + public static XStream getXStreamReader() { + + XStream xstream = new XStream(new DomDriver()); + + customizeXstream(xstream); + + return xstream; + } + + /** + * registers converter for argument xstream and sets aliases to + * make the XML file more human-readable + * + * @pre argument xstream is a valid XStream @post + * argument xstream is customized to produce a cleaner output + * file + * + * @param xstream XStream to be customized + */ + public static void customizeXstream(XStream xstream) { + + xstream.registerConverter(new SesarSampleXMLConverter()); + + xstream.alias("sample", SesarSample.class); + } + + public String serializeForUploadToSesar() { + XStream xstream = getXStreamWriter(); + + String xml = xstream.toXML(this); + // fix double underscores + xml = xml.replace("__", "_"); + + xml = "" + xml + ""; + + System.out.println(xml); + + return xml; + } + + public void serializeXMLObject(String filename) { + XStream xstream = getXStreamWriter(); + + String xml = xstream.toXML(this); + // fix double underscores + xml = xml.replace("__", "_"); + + try { + FileWriter outFile = new FileWriter(filename); + PrintWriter out = new PrintWriter(outFile); + + // Write xml to file + out.println(xml); + out.flush(); + out.close(); + outFile.close(); + + } catch (IOException e) { + } + } + + public static boolean validateSampleIGSNatSESAR(String igsn) { + File file = retrieveXMLFileFromSesarForIGSN(igsn); + Document doc = convertXMLTextToDOMdocument(file); + boolean retVal = false; + + if (doc != null) { + if (doc.hasChildNodes()) { + boolean resultsElementPresent = doc.getFirstChild().getNodeName().equalsIgnoreCase("results"); + if (resultsElementPresent) { + retVal = doc.getElementsByTagName("error").getLength() == 0; + } + } + } + return retVal; + } + + public static boolean validateAliquotIGSNatSESAR(String aliquotIgsn, String parentIgsn) { + File file = retrieveXMLFileFromSesarForIGSN(aliquotIgsn); + Document doc = convertXMLTextToDOMdocument(file); + boolean retVal = false; + + if (doc != null) { + if (doc.hasChildNodes()) { + boolean resultsElementPresent = doc.getFirstChild().getNodeName().equalsIgnoreCase("results"); + if (resultsElementPresent) { + retVal = doc.getElementsByTagName("error").getLength() == 0; + if (retVal){ + // test if parent present + String parentIgsnFromSesar = doc.getElementsByTagName("parent_igsn").item(0).getTextContent(); + retVal = parentIgsnFromSesar.compareToIgnoreCase(parentIgsn) == 0; + } + } + } + } + return retVal; + } + + public static boolean isWellFormedIGSN(String igsn, String userCode) { + boolean retval = (igsn.length() == 9); + + if (userCode.length() == 3) { + retval = retval && igsn.substring(0, 3).toUpperCase().matches("^[A-Z]{3}"); + } else { // assume length 5 + retval = retval && igsn.substring(0, 5).toUpperCase().matches("^[A-Z]{5}"); + } + + retval = retval && igsn.substring(userCode.length(), 9).matches("^[A-Z0-9]{" + (igsn.length() - userCode.length()) + "}"); + + return retval; + + } + + /** + * @return the userCode + */ + public String getUserCode() { + return userCode; + } + + /** + * @param userCode the userCode to set + */ + public void setUserCode(String userCode) { + this.userCode = userCode; + } + + /** + * @return the sampleType + */ + public String getSampleType() { + return sampleType; + } + + /** + * @param sampleType the sampleType to set + */ + public void setSampleType(String sampleType) { + this.sampleType = sampleType; + } + + /** + * @return the material + */ + public String getMaterial() { + return material; + } + + /** + * @param material the material to set + */ + public void setMaterial(String material) { + this.material = material; + } + + /** + * @return the IGSN + */ + public String getIGSN() { + return IGSN; + } + + /** + * @param IGSN the IGSN to set + */ + public void setIGSN(String IGSN) { + this.IGSN = IGSN; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the latitude + */ + public BigDecimal getLatitude() { + return latitude; + } + + /** + * @param latitude the latitude to set + */ + public void setLatitude(BigDecimal latitude) { + this.latitude = latitude; + } + + /** + * @return the longitude + */ + public BigDecimal getLongitude() { + return longitude; + } + + /** + * @param longitude the longitude to set + */ + public void setLongitude(BigDecimal longitude) { + this.longitude = longitude; + } + + /** + * @return the primaryLocationName + */ + public String getPrimaryLocationName() { + return primaryLocationName; + } + + /** + * @param primaryLocationName the primaryLocationName to set + */ + public void setPrimaryLocationName(String primaryLocationName) { + this.primaryLocationName = primaryLocationName; + } + + /** + * @return the country + */ + public String getCountry() { + return country; + } + + /** + * @param country the country to set + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * @return the collection_start_date + */ + public String getCollection_start_date() { + return collection_start_date; + } + + /** + * @param collection_start_date the collection_start_date to set + */ + public void setCollection_start_date(String collection_start_date) { + this.collection_start_date = collection_start_date; + } + + /** + * @return the originalArchive + */ + public String getOriginalArchive() { + return originalArchive; + } + + /** + * @param originalArchive the originalArchive to set + */ + public void setOriginalArchive(String originalArchive) { + this.originalArchive = originalArchive; + } + + /** + * @return the parentIGSN + */ + public String getParentIGSN() { + return parentIGSN; + } + + /** + * @param parentIGSN the parentIGSN to set + */ + public void setParentIGSN(String parentIGSN) { + this.parentIGSN = parentIGSN; + } + + /** + * @return the children + */ + public String[] getChildren() { + return children; + } + + /** + * @param children the children to set + */ + public void setChildren(String[] children) { + this.children = children; + } + + /** + * @return the nameOfLocalSample + */ + public String getNameOfLocalSample() { + return nameOfLocalSample; + } + + /** + * @param nameOfLocalSample the nameOfLocalSample to set + */ + public void setNameOfLocalSample(String nameOfLocalSample) { + this.nameOfLocalSample = nameOfLocalSample; + } +} diff --git a/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleManager.form b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleManager.form new file mode 100644 index 00000000..f850237d --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleManager.form @@ -0,0 +1,46 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleManager.java b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleManager.java new file mode 100644 index 00000000..2f61b4a6 --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleManager.java @@ -0,0 +1,309 @@ +/* + * Copyright 2015 CIRDLES. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.archivingTools.forSESAR; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.math.BigDecimal; +import javax.swing.DefaultComboBoxModel; +import javax.swing.InputVerifier; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import static javax.swing.SwingConstants.RIGHT; +import org.earthtime.UPb_Redux.ReduxConstants; +import org.earthtime.UPb_Redux.dialogs.DialogEditor; +import org.earthtime.UPb_Redux.utilities.BrowserControl; +import org.earthtime.beans.ET_JButton; +import org.earthtime.dataDictionaries.SESAR_MaterialTypesEnum; +import org.earthtime.dataDictionaries.SESAR_ObjectTypesEnum; + +/** + * + * @author James F. Bowring + */ +public class SesarSampleManager extends DialogEditor { + + private SesarSample sesarSample; + private final static int ROW_HEIGHT = 25; + private JTextField sampleIGSNText; + private JCheckBox autoGenerateCheckBox; + + /** + * Creates new form SesarSampleManager + */ + public SesarSampleManager(Frame parent, boolean modal, SesarSample sesarSample, boolean editable) { + super(parent, modal); + + this.sesarSample = sesarSample; + + initComponents(); + + setSize(450, 300); + + initSesarSample(editable); + } + + private void initSesarSample(boolean editable) { + + sesarSampleDetailsLayeredPane.add(labelFactory("IGSN:", 10, 10, 100)); + + sampleIGSNText = new JTextField(sesarSample.getIGSN()); + sampleIGSNText.setEditable(editable); + sampleIGSNText.setBounds(120, 10, 100, ROW_HEIGHT); + sampleIGSNText.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(sampleIGSNText); + + if (editable) { + autoGenerateCheckBox = new JCheckBox("Let SESAR generate IGSN"); + autoGenerateCheckBox.setBounds(225, 10, 250, ROW_HEIGHT); + autoGenerateCheckBox.setFont(ReduxConstants.sansSerif_12_Bold); + autoGenerateCheckBox.setSelected(false); + sesarSampleDetailsLayeredPane.add(autoGenerateCheckBox); + autoGenerateCheckBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent event) { + JCheckBox cb = (JCheckBox) event.getSource(); + if (cb.isSelected()) { + sampleIGSNText.setText(sesarSample.getUserCode() + "------".substring(0, (9 - sesarSample.getUserCode().length()))); + sampleIGSNText.setEditable(false); + } else { + sampleIGSNText.setText(sesarSample.getIGSN()); + sampleIGSNText.setEditable(true); + } + } + }); + } else { + // provide button to see full record + JButton viewSesarRecordButton = new ET_JButton("View full record at SESAR"); + viewSesarRecordButton.setBounds(225, 10, 200, ROW_HEIGHT); + viewSesarRecordButton.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(viewSesarRecordButton); + viewSesarRecordButton.addActionListener((ActionEvent e) -> { + BrowserControl.displayURL("http://app.geosamples.org/sample/igsn/" + sesarSample.getIGSN()); + }); + } + + sesarSampleDetailsLayeredPane.add(labelFactory("Sample Name:", 10, 40, 100)); + + JTextField sampleNameText = new JTextField(sesarSample.getName()); + sampleNameText.setEditable(false); + sampleNameText.setBounds(120, 40, 150, ROW_HEIGHT); + sampleNameText.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(sampleNameText); + + if (!editable) { + // check for name inconsistency + if (sesarSample.hasNameClashBetweenLocalAndSesar()) { + JLabel nameClashWarning = labelFactory("The local sample name <" + sesarSample.getNameOfLocalSample() + "> differs!", 275, 28, 150); + nameClashWarning.setForeground(Color.red); + nameClashWarning.setSize(150, 50); + sesarSampleDetailsLayeredPane.add(nameClashWarning); + } + } + + sesarSampleDetailsLayeredPane.add(labelFactory("Sample Type:", 10, 70, 100)); + + JComboBox sesarObjectTypesCombo = new JComboBox<>(); + sesarObjectTypesCombo.setEnabled(editable); + sesarObjectTypesCombo.setModel(new DefaultComboBoxModel<>(SESAR_ObjectTypesEnum.values())); + sesarObjectTypesCombo.setBounds(120, 70, 200, ROW_HEIGHT); + sesarObjectTypesCombo.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(sesarObjectTypesCombo); + sesarObjectTypesCombo.setSelectedItem(sesarSample.getSesarObjectType()); + + sesarSampleDetailsLayeredPane.add(labelFactory("Material Type:", 10, 100, 100)); + + JComboBox sesarMaterialTypesCombo = new JComboBox<>(); + sesarMaterialTypesCombo.setEnabled(editable); + sesarMaterialTypesCombo.setModel(new DefaultComboBoxModel<>(SESAR_MaterialTypesEnum.values())); + sesarMaterialTypesCombo.setBounds(120, 100, 200, ROW_HEIGHT); + sesarMaterialTypesCombo.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(sesarMaterialTypesCombo); + sesarMaterialTypesCombo.setSelectedItem(sesarSample.getSesarMaterialType()); + + sesarSampleDetailsLayeredPane.add(labelFactory("decimal Lat:", 10, 130, 100)); + JTextField decimalLatitude = new JTextField(); + decimalLatitude.setDocument(new BigDecimalDocument(decimalLatitude, editable)); + decimalLatitude.setText(sesarSample.getLatitude().setScale(6).toPlainString()); + decimalLatitude.setBounds(120, 130, 100, ROW_HEIGHT); + decimalLatitude.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(decimalLatitude); + decimalLatitude.setInputVerifier(new InputVerifier() { + + @Override + public boolean verify(JComponent input) { + JTextField textField = (JTextField) input; + if (textField.getText().trim().length() == 0) { + textField.setText("0.0"); + } + double latitude = Double.parseDouble(textField.getText().trim()); + if (Math.abs(latitude) > 90.0) { + textField.setText(latitude < 0 ? "-90.0" : "90.0"); + } + return true; + } + }); + decimalLatitude.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + if ((key == KeyEvent.VK_ENTER) || (key == KeyEvent.VK_TAB)) { + decimalLatitude.getInputVerifier().verify(decimalLatitude); + } + } + } + ); + + sesarSampleDetailsLayeredPane.add(labelFactory("decimal Long:", 10, 160, 100)); + JTextField decimalLongitude = new JTextField(); + decimalLongitude.setDocument(new BigDecimalDocument(decimalLongitude, editable)); + decimalLongitude.setText(sesarSample.getLongitude().setScale(6).toPlainString()); + decimalLongitude.setBounds(120, 160, 100, ROW_HEIGHT); + decimalLongitude.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(decimalLongitude); + decimalLongitude.setInputVerifier(new InputVerifier() { + + @Override + public boolean verify(JComponent input) { + JTextField textField = (JTextField) input; + if (textField.getText().trim().length() == 0) { + textField.setText("0.0"); + } + double longitude = Double.parseDouble(textField.getText().trim()); + if (Math.abs(longitude) > 180.0) { + textField.setText(longitude < 0 ? "-180.0" : "180.0"); + } + return true; + } + }); + decimalLongitude.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + if ((key == KeyEvent.VK_ENTER) || (key == KeyEvent.VK_TAB)) { + decimalLongitude.getInputVerifier().verify(decimalLongitude); + } + } + } + ); + + JButton showMapButton = new ET_JButton("Show map"); + showMapButton.setBounds(320, 145, 100, 25); + showMapButton.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(showMapButton); + showMapButton.addActionListener((ActionEvent e) -> { + CoordinateSystemConversions.launchGoogleMapsForLatLong(// + new BigDecimal(decimalLatitude.getText()), new BigDecimal(decimalLongitude.getText())); + }); + + if (editable) { + JButton registerSampleButton = new ET_JButton("Register this Sample"); + registerSampleButton.setBounds(120, 200, 200, 25); + registerSampleButton.setFont(ReduxConstants.sansSerif_12_Bold); + sesarSampleDetailsLayeredPane.add(registerSampleButton); + registerSampleButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean doRegister = false; + String messageText = ""; + if (!autoGenerateCheckBox.isSelected()) { + String proposedIGSN = sampleIGSNText.getText(); + if (!sesarSample.confirmUserCodeCompliance(proposedIGSN)) { + messageText = "User code prefix of IGSN should be: " + sesarSample.getUserCode(); + } else if (SesarSample.validateSampleIGSNatSESAR(proposedIGSN)) { + messageText = "The IGSN: " + proposedIGSN + " is already in use."; + } else if (!SesarSample.isWellFormedIGSN(proposedIGSN, sesarSample.getUserCode())) { + messageText = "The IGSN: " + proposedIGSN + " is not of the form " + sesarSample.getUserCode() + "NNNNNNN\".substring(0, (9 - userCode.length())) + \", where N is any digit or any capital letter."; + } else { + sesarSample.setIGSN(proposedIGSN); + doRegister = true; + } + } else { + sesarSample.setIGSN(""); + doRegister = true; + } + if (doRegister) { + sesarSample.setSampleType(((SESAR_ObjectTypesEnum) sesarObjectTypesCombo.getSelectedItem()).getName()); + sesarSample.setMaterial(((SESAR_MaterialTypesEnum) sesarMaterialTypesCombo.getSelectedItem()).getName()); + sesarSample.setLatitude(new BigDecimal(decimalLatitude.getText())); + sesarSample.setLongitude(new BigDecimal(decimalLongitude.getText())); + // register at SESAR + String igsnValue = sesarSample.uploadAndRegisterSesarSample(); + if (igsnValue.length() > 0) { + sesarSample.setIGSN(igsnValue); + close(); + } else { + sesarSample.setIGSN("NONE"); + } + + } else { + JOptionPane.showMessageDialog( + null, + new String[]{messageText}, + "ET Redux Warning", + JOptionPane.WARNING_MESSAGE); + } + } + }); + } + + } + + private JLabel labelFactory(String text, int x, int y, int width) { + JLabel label = new JLabel(text); + label.setBounds(x, y, width, ROW_HEIGHT); + label.setFont(ReduxConstants.sansSerif_12_Bold); + label.setHorizontalAlignment(RIGHT); + + return label; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + sesarSampleDetailsLayeredPane = new javax.swing.JLayeredPane(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + getContentPane().setLayout(null); + + sesarSampleDetailsLayeredPane.setBackground(new java.awt.Color(255, 255, 255)); + sesarSampleDetailsLayeredPane.setOpaque(true); + getContentPane().add(sesarSampleDetailsLayeredPane); + sesarSampleDetailsLayeredPane.setBounds(0, 0, 630, 470); + + pack(); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLayeredPane sesarSampleDetailsLayeredPane; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleXMLConverter.java b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleXMLConverter.java new file mode 100644 index 00000000..7c9b8f10 --- /dev/null +++ b/src/main/java/org/earthtime/archivingTools/forSESAR/SesarSampleXMLConverter.java @@ -0,0 +1,226 @@ +/* + * SesarSampleXMLConverter.java + * + * + * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.archivingTools.forSESAR; + +import com.thoughtworks.xstream.converters.Converter; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import java.math.BigDecimal; +import org.earthtime.dataDictionaries.SESAR_MaterialTypesEnum; +import org.earthtime.dataDictionaries.SESAR_ObjectTypesEnum; + +/** + * A SesarSampleXMLConverter is used to marshal and unmarshal data + * between SesarSample and XML files. + * + * @imports + * + * com.thoughtworks.xstream.converters.Converter + * @imports + * + * com.thoughtworks.xstream.converters.MarhsallingContext + * @imports + * + * com.thoughtworks.xstream.converters.UnmarshallingContext + * @imports + * + * com.thoughtworks.xstream.io.HierachicalSreamReader + * @imports + * + * com.thoughtworks.xstream.io.HierarchicalStreamWriter + * @author James F. Bowring, javaDocs by Stan Gasque + */ +public class SesarSampleXMLConverter implements Converter { + + /** + * checks the argument clazz against SesarSample's + * Class. Used to ensure that the object about to be + * marshalled/unmarshalled is of the correct type. + * + * @pre argument clazz is a valid Class + * @post boolean is returned comparing clazz + * against ValueModel.class + * @param clazz Class of the Object you wish to + * convert to/from XML + * @return boolean - true if clazz + * matches SesarSample's Class; else + * false. + */ + @Override + public boolean canConvert(Class clazz) { + return clazz.equals(SesarSample.class); + } + + /** + * writes the argument value to the XML file specified through + * writer + * + * @pre value is a valid SesarSample, + * writer is a valid HierarchicalStreamWriter, and + * context is a valid MarshallingContext + * @post value is written to the XML file specified via + * writer + * @param value SesarSample that you wish to write to a file + * @param writer stream to write through + * @param context MarshallingContext used to store generic data + */ + @Override + public void marshal(Object value, HierarchicalStreamWriter writer, + MarshallingContext context) { + + SesarSample sesarSample = (SesarSample) value; + + // this order is for registering at SESAR + writer.startNode("userCode"); + writer.setValue(sesarSample.getUserCode()); + writer.endNode(); + + writer.startNode("sample_type"); + writer.setValue(sesarSample.getSampleType()); + writer.endNode(); + + writer.startNode("material"); + writer.setValue(sesarSample.getMaterial()); + writer.endNode(); + + writer.startNode("igsn"); + writer.setValue(sesarSample.getIGSN()); + writer.endNode(); + + writer.startNode("name"); + writer.setValue(sesarSample.getName()); + writer.endNode(); + + writer.startNode("parent_igsn"); + writer.setValue(sesarSample.getParentIGSN()); + writer.endNode(); + + writer.startNode("latitude"); + writer.setValue(CoordinateSystemConversions.getDecimalCoordinateAsString(sesarSample.getLatitude())); + writer.endNode(); + + writer.startNode("longitude"); + writer.setValue(CoordinateSystemConversions.getDecimalCoordinateAsString(sesarSample.getLongitude())); + writer.endNode(); + + + } + + /** + * reads a SesarSample from the XML file specified through + * reader + * + * @pre reader leads to a valid SesarSample + * @post the SesarSample is read from the XML file and returned + * @param reader stream to read through + * @param context UnmarshallingContext used to store generic + * data + * @return SesarSample - ValueModel read from file + * specified by reader + */ + public Object unmarshal(HierarchicalStreamReader reader, + UnmarshallingContext context) { + + SesarSample sesarSample = new SesarSample(); + + reader.moveDown(); + // bar code + reader.moveUp(); + + reader.moveDown(); + sesarSample.setIGSN(reader.getValue()); + reader.moveUp(); + + reader.moveDown(); + sesarSample.setName(reader.getValue()); + reader.moveUp(); + + reader.moveDown(); + // sample_other_names + reader.moveUp(); + + reader.moveDown(); + String sampleType = reader.getValue(); + try { + sampleType = SESAR_ObjectTypesEnum.valueOf(sampleType.replace(" ", "")).getName(); + } catch (Exception e) { + sampleType = "Other"; + } + sesarSample.setSampleType(sampleType); + reader.moveUp(); + + reader.moveDown(); + sesarSample.setParentIGSN(cleanStringElement(reader.getValue())); + reader.moveUp(); + + reader.moveDown(); + String material = reader.getValue(); + try { + material = SESAR_MaterialTypesEnum.valueOf(material.replace(" ", "")).getName(); + } catch (Exception e) { + material = "Other"; + } + sesarSample.setMaterial(material); + reader.moveUp(); + + skipElements(reader, 11); + + reader.moveDown(); + sesarSample.setLatitude(new BigDecimal(cleanNumberElement(reader.getValue()))); + reader.moveUp(); + + reader.moveDown(); + sesarSample.setLongitude(new BigDecimal(cleanNumberElement(reader.getValue()))); + reader.moveUp(); + + return sesarSample; + } + + private void skipElements(HierarchicalStreamReader reader, int count) { + for (int i = 0; i < count; i++) { + reader.moveDown(); + reader.moveUp(); + } + } + + private String cleanStringElement(String element){ + String retval; + if (element.trim().startsWith("Not Provided")){ + retval = ""; + } else { + retval = element.trim(); + } + + return retval; + } + + private String cleanNumberElement(String element){ + String retval; + if (element.trim().startsWith("Not Provided")){ + retval = "0"; + } else { + retval = element.trim(); + } + + return retval; + } + +} diff --git a/src/main/java/org/earthtime/dataDictionaries/GeochronValidationResults.java b/src/main/java/org/earthtime/dataDictionaries/GeochronValidationResults.java index 64fe2581..1ef64560 100644 --- a/src/main/java/org/earthtime/dataDictionaries/GeochronValidationResults.java +++ b/src/main/java/org/earthtime/dataDictionaries/GeochronValidationResults.java @@ -18,7 +18,7 @@ */ package org.earthtime.dataDictionaries; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.w3c.dom.Node; /** diff --git a/src/main/java/org/earthtime/dataDictionaries/SESAR_MaterialTypesEnum.java b/src/main/java/org/earthtime/dataDictionaries/SESAR_MaterialTypesEnum.java new file mode 100644 index 00000000..42dc7e0a --- /dev/null +++ b/src/main/java/org/earthtime/dataDictionaries/SESAR_MaterialTypesEnum.java @@ -0,0 +1,58 @@ +/* + * SESAR_MaterialTypesEnum.java + * + * + * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.dataDictionaries; + +/** + * + * @author James F. Bowring + */ +public enum SESAR_MaterialTypesEnum { + + /** + * + */ + Mineral("Mineral"), + /** + * + */ + Other("Other"), + Rock("Rock"), + Sediment("Sediment"), + Soil("Soil"); + + private String name; + + private SESAR_MaterialTypesEnum(String name){ + this.name = name; + } + + /** + * @return the name + */ + public String getName () { + return name; + } + + @Override + public String toString() { + return name; + } + + +} diff --git a/src/main/java/org/earthtime/dataDictionaries/SESAR_ObjectTypesEnum.java b/src/main/java/org/earthtime/dataDictionaries/SESAR_ObjectTypesEnum.java new file mode 100644 index 00000000..9ad8b5bc --- /dev/null +++ b/src/main/java/org/earthtime/dataDictionaries/SESAR_ObjectTypesEnum.java @@ -0,0 +1,55 @@ +/* + * SESAR_ObjectTypesEnum.java + * + * + * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.earthtime.dataDictionaries; + +/** + * + * @author James F. Bowring + */ +public enum SESAR_ObjectTypesEnum { + + /** + * + */ + IndividualSample("Individual Sample"), + /** + * + */ + Other("Other"); + + private String name; + + private SESAR_ObjectTypesEnum(String name){ + this.name = name; + } + + /** + * @return the name + */ + public String getName () { + return name; + } + + @Override + public String toString() { + return name; + } + + +} diff --git a/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java b/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java index 51fa40b9..04576eaf 100644 --- a/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java +++ b/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java @@ -18,7 +18,7 @@ */ package org.earthtime.dataDictionaries; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; /** * diff --git a/src/main/java/org/earthtime/dataDictionaries/TemplatesForCsvImport.java b/src/main/java/org/earthtime/dataDictionaries/TemplatesForCsvImport.java index 4ba6e18d..d7bee087 100644 --- a/src/main/java/org/earthtime/dataDictionaries/TemplatesForCsvImport.java +++ b/src/main/java/org/earthtime/dataDictionaries/TemplatesForCsvImport.java @@ -3,15 +3,15 @@ * * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License,Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software + * Unless required by applicable law or agreed to in writing,software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @@ -25,52 +25,60 @@ public class TemplatesForCsvImport { // september 2009 to support batch upload of csv sample files /** - * + * */ public static final String IDTIMSLegacyDataSampleFieldNames_MIT = // - "Fraction, 206/238, 2-sig%, 207/235, 2-sig%, 207/206, 2-sig%, " - + "rho 6/8-7/5, 206/204, 208/206, Pb*/Pbc, Pb* pg, Pbc pg, conc U, conc Pb, Th/U samp, " - + "frac mass, age206/238, 2-sig, age207/235, 2-sig, age207/206, 2-sig, age206/238xTh, 2-sig, " - + "age207/235xPa, 2-sig, age207/206xTh, 2-sig, 207/206xPa, 2-sig"; + "Fraction,206/238,2-sig%,207/235,2-sig%,207/206,2-sig%," + + "rho 6/8-7/5,206/204,208/206,Pb*/Pbc,Pb* pg,Pbc pg,conc U,conc Pb,Th/U samp," + + "frac mass,age206/238,2-sig,age207/235,2-sig,age207/206,2-sig,age206/238xTh,2-sig," + + "age207/235xPa,2-sig,age207/206xTh,2-sig,207/206xPa,2-sig"; // April 2010 to support batch upload of csv sample files George Gehrels /** - * + * */ public static final String LAICPMSLegacyDataSampleFieldNames_MC_UA = // - "Analysis, U(ppm), 206/204, U/Th, 206/207, 1-sig%, 207/235, 1-sig%, 206/238, 1-sig%, " - + "rho 6/8-7/5, " - + "age206/238, 1-sig, age207/235, 1-sig, age207/206, 1-sig, Best age, 1-sig"; + "Analysis,U(ppm),206/204,U/Th,206/207,1-sig%,207/235,1-sig%,206/238,1-sig%," + + "rho 6/8-7/5," + + "age206/238,1-sig,age207/235,1-sig,age207/206,1-sig,Best age,1-sig"; // May 2010 to support Jeff VerVoort at Washington State with single-collector LA-ICP MS /** - * + * */ public static final String LAICPMSLegacyDataSampleFieldNames_SC_WSU_vA = // - "Analysis, 207Pb/235U, 1-sig abs, 206Pb/238U, 1-sig abs, 207Pb/206Pb,1-sig abs, " - + "Th/U,207Pb/235U,1-sig abs,206Pb/238U,1-sig abs,ignored,ignored,207Pb/206Pb,1-sig abs, "// + "Analysis,207Pb/235U,1-sig abs,206Pb/238U,1-sig abs,207Pb/206Pb,1-sig abs," + + "Th/U,207Pb/235U,1-sig abs,206Pb/238U,1-sig abs,ignored,ignored,207Pb/206Pb,1-sig abs,"// + "ignored,ignored,ignored,ignored,ignored,rho 6/8-7/5"; // Sept 2010 to support Jeff VerVoort at Washington State with single-collector LA-ICP MS /** - * + * */ public static final String LAICPMSLegacyDataSampleFieldNames_SC_WSU_vB = // - "Analysis, 207Pb/235U, 1-sig abs, 206Pb/238U, 1-sig abs, 207Pb/206Pb,1-sig abs, " - + "Th/U,207Pb/235U,1-sig abs,206Pb/238U,1-sig abs, 207Pb/206Pb,1-sig abs, "// + "Analysis,207Pb/235U,1-sig abs,206Pb/238U,1-sig abs,207Pb/206Pb,1-sig abs," + + "Th/U,207Pb/235U,1-sig abs,206Pb/238U,1-sig abs,207Pb/206Pb,1-sig abs,"// + "ignored,ignored,ignored,ignored,ignored,ignored,ignored,ignored,ignored,rho 6/8-7/5"; // June 2010 to support batch upload of csv sample files Matt Horstwood NIGL /** - * + * */ public static final String LAICPMSLegacyDataSampleFieldNames_NIGL = // - "Analysis, Pb(ppm), U(ppm), 206/204, 1-sig%, 207/206, 1-sig%, 207/235, 1-sig%, 206/238, 1-sig%, " - + "rho 6/8-7/5, " - + "age207/206, 2-sig-abs, age206/238, 2-sig-abs, age207/235, 2-sig-abs"; - // July 2012 to support generic UPb isotopic data for Blair and Urs, etc. + "Analysis,Pb(ppm),U(ppm),206/204,1-sig%,207/206,1-sig%,207/235,1-sig%,206/238,1-sig%," + + "rho 6/8-7/5," + + "age207/206,2-sig-abs,age206/238,2-sig-abs,age207/235,2-sig-abs"; + // July 2012 to support generic UPb isotopic data for Blair and Urs,etc. /** * */ - public static final String GenericUPbIsotopicLegacyDataSampleFieldNames_A = // - "Sample and fractions, mass(g), # of grains, Pb conc (ppm), U conc (ppm), Th/U, Pb*/Pbc, Pbc (pg), " - + "206Pb/204Pb, 208Pb/206Pb, 207Pb/206Pb, 2-sig%, 207Pb/235Pb, 2-sig%, 206Pb/238U, 2-sig%, rho 6/8-7/5, " - + "age 207Pb/206Pb, 2-sig, age 207Pb/235U, 2-sig, age 206Pb/238U, 2-sig "; + public static final String GenericUPbIsotopicLegacyDataSampleFieldNames_A = // + "Sample and fractions,mass(g),# of grains,Pb conc (ppm),U conc (ppm),Th/U,Pb*/Pbc,Pbc (pg)," + + "206Pb/204Pb,208Pb/206Pb,207Pb/206Pb,2-sig%,207Pb/235Pb,2-sig%,206Pb/238U,2-sig%,rho 6/8-7/5," + + "age 207Pb/206Pb,2-sig,age 207Pb/235U,2-sig,age 206Pb/238U,2-sig "; + + public static final String ProjectOfLegacySamplesFieldNames_UCSB_LASS_A = // + "sample name,mineral type,grain number,spot number,position,Xpos.,Y pos.," + + "Pb ppm,U ppm,Th ppm,Th/U,206Pb/204Pb,2s. Abs.,207Pb/206Pb,2s. Abs.,238U/206Pb,2s. Abs.," + + "207Pb/235U,2s. Abs.,206Pb/238U,2s. Abs.,7/35 vs. 6/38 Rho,208Pb/232Th,2s. Abs.," + + "207Pb/206Pb (Ma),2s abs.,207Pb/235U (Ma),2s abs.,206Pb/238U (Ma),2s abs.,206Pb/238U (Ma)," + + "2s abs.,208Pb/232Th (Ma),2s abs.,Si ppm,P ppm,Ca ppm,Ti ppm,Rb ppm,Sr ppm,Y ppm,Zr ppm," + + "La ppm,Ce ppm,Pr ppm,Nd ppm,Sm ppm,Eu ppm,Gd ppm,Tb ppm,Dy ppm,Ho ppm,Er ppm,Tm ppm,Yb ppm,Lu ppm,Hf ppm"; } diff --git a/src/main/java/org/earthtime/physicalConstants/PhysicalConstants.java b/src/main/java/org/earthtime/physicalConstants/PhysicalConstants.java index f8d4a9fc..d51af58e 100644 --- a/src/main/java/org/earthtime/physicalConstants/PhysicalConstants.java +++ b/src/main/java/org/earthtime/physicalConstants/PhysicalConstants.java @@ -46,7 +46,7 @@ import org.earthtime.ratioDataModels.pbBlankICModels.PbBlankICModel; import org.earthtime.ratioDataModels.physicalConstantsModels.PhysicalConstantsModel; import org.earthtime.utilities.DateHelpers; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/projects/Project.java b/src/main/java/org/earthtime/projects/Project.java index f9e158e0..f5a58b83 100644 --- a/src/main/java/org/earthtime/projects/Project.java +++ b/src/main/java/org/earthtime/projects/Project.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.io.Serializable; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Iterator; import java.util.SortedSet; @@ -40,7 +41,6 @@ import org.earthtime.UPb_Redux.exceptions.BadLabDataException; import org.earthtime.UPb_Redux.filters.ReduxFileFilter; import org.earthtime.UPb_Redux.fractions.Fraction; -import org.earthtime.UPb_Redux.fractions.UPbReduxFractions.UPbFractionI; import org.earthtime.UPb_Redux.fractions.UPbReduxFractions.UPbLAICPMSFraction; import org.earthtime.UPb_Redux.reduxLabData.ReduxLabData; import org.earthtime.UPb_Redux.samples.Sample; @@ -194,9 +194,6 @@ public void prepareSamplesForRedux() { // make a super-sample or projectsample to leverage existing Redux try { compiledSuperSample = new Sample( // - // - // - // projectName, // SampleTypesEnum.PROJECT.getName(), // SampleAnalysisTypesEnum.TRIPOLIZED.getName(), // @@ -234,6 +231,8 @@ public void prepareSamplesForRedux() { // automatically added to aliquot #1 as we are assuming only one aliquot in this scenario sample.addUPbFraction(uPbLAICPMSFraction); + // feb 2015 in prep for export + ((UPbReduxAliquot)aliquot).getAliquotFractions().add(uPbLAICPMSFraction); } // this forces aliquot fraction population @@ -263,7 +262,7 @@ public void prepareSamplesForRedux() { * */ @Override - public void exportProjectSamples() throws ETException{ + public Path exportProjectSamples() throws ETException { File projectSamplesFolder = new File(locationOfProjectReduxFile.getParent() + File.separatorChar + projectName + "_Samples"); boolean jobCompleted = true; @@ -278,9 +277,10 @@ public void exportProjectSamples() throws ETException{ } if (jobCompleted) { + prepareSamplesForExport(); + for (int i = 0; i < projectSamples.size(); i++) { SampleI sample = projectSamples.get(i); - System.out.println("Sample: " + sample.getSampleName()); File sampleFile = new File(// projectSamplesFolder.getAbsolutePath() + File.separatorChar + sample.getSampleName()); @@ -288,29 +288,55 @@ public void exportProjectSamples() throws ETException{ // first write sample out sample.saveTheSampleAsSerializedReduxFile(sampleFile); - // then read back in and repair aliquot number in fractions as there is only 1 aliquot per sample - EarthTimeSerializedFileInterface deserializedFile = // - (EarthTimeSerializedFileInterface) ETSerializer.GetSerializedObjectFromFile(sample.getReduxSampleFilePath()); - - Sample deserializedSample = (Sample) deserializedFile; +// // then read back in and repair aliquot number in fractions as there is only 1 aliquot per sample +// EarthTimeSerializedFileInterface deserializedFile = // +// (EarthTimeSerializedFileInterface) ETSerializer.GetSerializedObjectFromFile(sample.getReduxSampleFilePath()); +// +// Sample deserializedSample = (Sample) deserializedFile; +// +// for (int j = 0; j < deserializedSample.getUPbFractions().size(); j++) { +// ((UPbFractionI) deserializedSample.getUPbFractions().get(j)).setAliquotNumber(1); +// } +// +// // oct 2014 specify sample types +// if (compiledSuperSample.isAnalysisTypeTripolized()) { +// deserializedSample.setSampleType(SampleTypesEnum.ANALYSIS.getName()); +// } else { +// deserializedSample.setSampleType(SampleTypesEnum.LEGACY.getName()); +// deserializedSample.setAnalyzed(true); +// } +// deserializedSample.setLegacyStatusForReportTable(); +// +// // rewrite sample +// deserializedSample.saveTheSampleAsSerializedReduxFile(sampleFile); - for (int j = 0; j < deserializedSample.getUPbFractions().size(); j++) { - ((UPbFractionI) deserializedSample.getUPbFractions().get(j)).setAliquotNumber(1); - } + } + } else { + throw new ETException(null, "Unable to process " + projectSamplesFolder.getAbsolutePath()); + } - // oct 2014 specify sample types - if (compiledSuperSample.isAnalysisTypeTripolized()) { - deserializedSample.setSampleType(SampleTypesEnum.ANALYSIS.getName()); - } else { - deserializedSample.setSampleType(SampleTypesEnum.LEGACY.getName()); - deserializedSample.setAnalyzed(true); - } - deserializedSample.setLegacyStatusForReportTable(); - // rewrite sample - deserializedSample.saveTheSampleAsSerializedReduxFile(sampleFile); + return projectSamplesFolder.toPath(); + } + public void prepareSamplesForExport() { + for (int i = 0; i < projectSamples.size(); i++) { + SampleI sample = projectSamples.get(i); + System.out.println("Preparing for export Sample: " + sample.getSampleName()); + + // only on export and then not necessary ? +// for (int j = 0; j < sample.getUPbFractions().size(); j++) { +// ((UPbFractionI) sample.getUPbFractions().get(j)).setAliquotNumber(1); +// } + + // oct 2014 specify sample types + if (compiledSuperSample.isAnalysisTypeTripolized()) { + sample.setSampleType(SampleTypesEnum.ANALYSIS.getName()); + } else { + sample.setSampleType(SampleTypesEnum.LEGACY.getName()); + sample.setAnalyzed(true); } - } else throw new ETException(null, "Unable to process " + projectSamplesFolder.getAbsolutePath()); + sample.setLegacyStatusForReportTable(); + } } /** @@ -455,4 +481,11 @@ public AbstractRawDataFileHandler getRawDataFileHandler() { public void setRawDataFileHandler(AbstractRawDataFileHandler rawDataFileHandler) { this.rawDataFileHandler = rawDataFileHandler; } + + /** + * @return the compiledSuperSample + */ + public SampleI getCompiledSuperSample() { + return compiledSuperSample; + } } diff --git a/src/main/java/org/earthtime/projects/ProjectI.java b/src/main/java/org/earthtime/projects/ProjectI.java index e93586cb..ddff015e 100644 --- a/src/main/java/org/earthtime/projects/ProjectI.java +++ b/src/main/java/org/earthtime/projects/ProjectI.java @@ -5,6 +5,7 @@ package org.earthtime.projects; import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import org.earthtime.Tripoli.dataModels.inputParametersModels.AbstractAcquisitionModel; import org.earthtime.Tripoli.rawDataFiles.handlers.AbstractRawDataFileHandler; @@ -129,5 +130,7 @@ public interface ProjectI { /** * */ - public void exportProjectSamples()throws ETException; + public Path exportProjectSamples()throws ETException; + + public SampleI getCompiledSuperSample(); } diff --git a/src/main/java/org/earthtime/projects/projectImporters/ProjectOfLegacySamplesImporterFromCSVFile_UCSB_LASS_A.java b/src/main/java/org/earthtime/projects/projectImporters/ProjectOfLegacySamplesImporterFromCSVFile_UCSB_LASS_A.java index 141f5c17..774b928f 100644 --- a/src/main/java/org/earthtime/projects/projectImporters/ProjectOfLegacySamplesImporterFromCSVFile_UCSB_LASS_A.java +++ b/src/main/java/org/earthtime/projects/projectImporters/ProjectOfLegacySamplesImporterFromCSVFile_UCSB_LASS_A.java @@ -1,5 +1,5 @@ /* - * ProjectOfLegacySamplesImporterFromCSVFile_UCSB_LASS_A.java + * ProjectOfLegacySamplesFieldNames_UCSB_LASS_A.java * * Copyright 2006-2015 James F. Bowring and www.Earth-Time.org * @@ -19,6 +19,9 @@ import java.io.File; import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Scanner; @@ -32,10 +35,12 @@ import org.earthtime.UPb_Redux.reduxLabData.ReduxLabData; import org.earthtime.UPb_Redux.samples.Sample; import org.earthtime.UPb_Redux.samples.SampleI; +import org.earthtime.UPb_Redux.utilities.BrowserControl; import org.earthtime.UPb_Redux.valueModels.ValueModel; import org.earthtime.UPb_Redux.valueModels.definedValueModels.PercentDiscordance; import org.earthtime.dataDictionaries.RadDates; import org.earthtime.dataDictionaries.SampleTypesEnum; +import org.earthtime.dataDictionaries.TemplatesForCsvImport; import org.earthtime.dataDictionaries.TraceElements; import org.earthtime.exceptions.ETException; import org.earthtime.projects.ProjectI; @@ -148,8 +153,11 @@ protected ProjectI extractProjectFromCSVFile(ProjectI project, File file) .setValue(readCSVCell(myFractionData.get(8)).// column I movePointLeft(6)); - // Th ppm missing = column J (9) - // + datumName = "concTh"; + myFraction.getCompositionalMeasureByName(datumName)// + .setValue(readCSVCell(myFractionData.get(9)).// column J + movePointLeft(6)); + datumName = "rTh_Usample"; myFraction.getCompositionalMeasureByName(datumName)// .setValue(readCSVCell(myFractionData.get(10)));// column K @@ -259,10 +267,10 @@ protected ProjectI extractProjectFromCSVFile(ProjectI project, File file) datumName = RadDates.age208_232r.getName(); myFraction.getRadiogenicIsotopeDateByName(datumName)// - .setValue(readCSVCell(myFractionData.get(32)).// column AE + .setValue(readCSVCell(myFractionData.get(32)).// column AG movePointRight(6)); myFraction.getRadiogenicIsotopeDateByName(datumName)// - .setOneSigma(readCSVCell(myFractionData.get(33)).// column AF + .setOneSigma(readCSVCell(myFractionData.get(33)).// column AH divide(new BigDecimal(2.0)).movePointRight(6)); // calculate percentDiscordance @@ -318,39 +326,39 @@ protected ProjectI extractProjectFromCSVFile(ProjectI project, File file) } private void traceElementProcessor(String datumName, Fraction myFraction, Vector myFractionData, int col) { - myFraction.getTraceElementByName(datumName)// - .setValue(readCSVCell(myFractionData.get(col)). - movePointLeft(6)); + // check for missing fields at end of row + if (col < myFractionData.size()) { + myFraction.getTraceElementByName(datumName)// + .setValue(readCSVCell(myFractionData.get(col)). + movePointLeft(6)); + } else { + myFraction.getTraceElementByName(datumName)// + .setValue(BigDecimal.ZERO); + } } -// /** -// * -// */ -// public static void writeAndOpenCSVFileOfLegacyDataSampleFieldNames() { -// String fieldNames = TemplatesForCsvImport.GenericUPbIsotopicLegacyDataSampleFieldNames_A; -// File CSVFile = new File("GenericUPbLegacySampleFieldNamesTemplate_A" + ".csv"); -// CSVFile.delete(); -// PrintWriter outputWriter = null; -// try { -// outputWriter = new PrintWriter(new FileWriter(CSVFile)); -// -// outputWriter.println("GENERIC UPb Isotopic LEGACY DATA SAMPLE FIELD NAMES FOR IMPORT INTO U-Pb_Redux\n"); -//// outputWriter.println( "FractionName, IsotopicRatios, , , , , , , , , Composition, , , , , , , IsotopicDates (Ma)" ); -// outputWriter.println(fieldNames); -// -// outputWriter.println("Leave this line blank"); -// outputWriter.println("First Sample Name here"); -// outputWriter.println("First fraction row here"); -// -// outputWriter.close(); -// -// } catch (IOException iOException) { -// } -// -// try { -// BrowserControl.displayURL(CSVFile.getCanonicalPath()); -// } catch (IOException ex) { -// } -// -// } + /** + * + */ + public static void writeAndOpenCSVFileOfLegacyDataSampleFieldNames() { + String fieldNames = TemplatesForCsvImport.ProjectOfLegacySamplesFieldNames_UCSB_LASS_A; + File CSVFile = new File("ProjectOfLegacySamples_UCSB_LASS_A_CSVFile_Template" + ".csv"); + CSVFile.delete(); + PrintWriter outputWriter = null; + try { + outputWriter = new PrintWriter(new FileWriter(CSVFile)); + + outputWriter.println(fieldNames); + + outputWriter.close(); + + } catch (IOException iOException) { + } + + try { + BrowserControl.displayURL(CSVFile.getCanonicalPath()); + } catch (IOException ex) { + } + + } } diff --git a/src/main/java/org/earthtime/ratioDataModels/AbstractRatiosDataModel.java b/src/main/java/org/earthtime/ratioDataModels/AbstractRatiosDataModel.java index 1e7f7e9f..e53fbaec 100644 --- a/src/main/java/org/earthtime/ratioDataModels/AbstractRatiosDataModel.java +++ b/src/main/java/org/earthtime/ratioDataModels/AbstractRatiosDataModel.java @@ -43,7 +43,7 @@ import org.earthtime.matrices.matrixModels.CorrelationMatrixModel; import org.earthtime.matrices.matrixModels.CovarianceMatrixModel; import org.earthtime.utilities.DateHelpers; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.earthtime.xmlUtilities.XMLSerializationI; /** diff --git a/src/main/java/org/earthtime/utilities/FileHelper.java b/src/main/java/org/earthtime/utilities/FileHelper.java index cfc17838..351b0b10 100644 --- a/src/main/java/org/earthtime/utilities/FileHelper.java +++ b/src/main/java/org/earthtime/utilities/FileHelper.java @@ -103,7 +103,7 @@ public boolean accept(File file, String string) { new String[]{"The file exists.", "Do you want to replace it?" }, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.NO_OPTION) { @@ -199,7 +199,7 @@ public static File AllPlatformGetFolder( if (!fractionFolder.exists()) { JOptionPane.showMessageDialog(null, new String[]{"The folder does NOT exist."}, - "U-Pb Redux Warning", + "ET Redux Warning", JOptionPane.WARNING_MESSAGE); } } diff --git a/src/test/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel_Test_04142014Test.java b/src/test/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel_Test_04142014Test.java index 6263ca71..c713ab6a 100644 --- a/src/test/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel_Test_04142014Test.java +++ b/src/test/java/org/earthtime/UPb_Redux/valueModels/MeasuredRatioModel_Test_04142014Test.java @@ -27,7 +27,7 @@ import java.io.FileNotFoundException; import java.math.BigDecimal; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.junit.Test; diff --git a/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced_Test_04092014Test.java b/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced_Test_04092014Test.java index 3906fead..9553afc7 100644 --- a/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced_Test_04092014Test.java +++ b/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModelReferenced_Test_04092014Test.java @@ -28,7 +28,7 @@ import java.io.FileNotFoundException; import java.math.BigDecimal; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.junit.Test; diff --git a/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModel_Test_01152014Test.java b/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModel_Test_01152014Test.java index 2a584b0b..fa68563c 100644 --- a/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModel_Test_01152014Test.java +++ b/src/test/java/org/earthtime/UPb_Redux/valueModels/ValueModel_Test_01152014Test.java @@ -45,7 +45,7 @@ import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; import org.earthtime.exceptions.ETException; -import org.earthtime.utilities.URIHelper; +import org.earthtime.archivingTools.URIHelper; import org.w3c.dom.Document; import org.xml.sax.SAXException; import java.io.File;