Skip to content

Commit

Permalink
Merge pull request #26 from bowring/hotfix
Browse files Browse the repository at this point in the history
hotfix to handle resources cases local class file vs jar file
  • Loading branch information
bowring committed Jun 5, 2015
2 parents 54e7667 + f60d34b commit 716d53c
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 138 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<groupId>org.cirdles</groupId>
<artifactId>ET_Redux</artifactId>
<name>ET_Redux</name>
<version>3.2.0</version>
<version>3.2.1</version>
<description>Successor to U-Pb_Redux</description>
<url>https://cirdles.org</url>
<inceptionYear>2006</inceptionYear>
Expand Down
41 changes: 18 additions & 23 deletions src/main/java/org/earthtime/ETRedux.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@
package org.earthtime;

import java.awt.Font;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.help.SwingHelpUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import org.earthtime.UPb_Redux.exceptions.BadLabDataException;
import org.earthtime.UPb_Redux.user.ReduxPersistentState;
import org.earthtime.UPb_Redux.utilities.JHelpAction;
import org.earthtime.exceptions.ETWarningDialog;
import org.earthtime.ratioDataModels.mineralStandardModels.MineralStandardUPbModel;

/**
*
Expand All @@ -48,12 +46,12 @@ public class ETRedux {
/**
* Version 3.0.0 initiates switch to ET_Redux from U-Pb_Redux
*/
public static String VERSION;// = "3.x.0";
public static String VERSION = "version";

/**
*
*/
public static String RELEASE_DATE;// = "June 2015";
public static String RELEASE_DATE = "date";

/**
* Creates a new instance of UPbRedux
Expand All @@ -62,22 +60,19 @@ public class ETRedux {
*/
public ETRedux(File reduxFile) //throws3 IOException, InvalidPreferencesFormatException
{
// get version number written by pom.xml
URL versionFileURL = MineralStandardUPbModel.class.getClassLoader().getResource("version.txt");
File versionFile = new File(versionFileURL.getPath());

try ( //first use a Scanner to get headers of 4 lines
// http://en.wikipedia.org/wiki/Windows-1252
Scanner scanner = new Scanner(versionFile, "CP1252")) {
String[] versionText = scanner.nextLine().split("=");
try {
// get version number written by pom.xml
InputStream versionFileStreamL = ETRedux.class.getClassLoader().getResourceAsStream("version.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(versionFileStreamL));
StringBuilder out = new StringBuilder();
String line;

String[] versionText = reader.readLine().split("=");
VERSION = versionText[1];

String[] versionDate = scanner.nextLine().split("=");
String[] versionDate = reader.readLine().split("=");
RELEASE_DATE = versionDate[1];

scanner.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(ETRedux.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException iOException) {
}

// get redux persistent state file
Expand Down Expand Up @@ -116,7 +111,7 @@ public ETRedux(File reduxFile) //throws3 IOException, InvalidPreferencesFormatEx
// installer etc ref
// http://www.centerkey.com/mac/java/
}
// installer etc ref
// installer etc ref
// http://www.centerkey.com/mac/java/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.io.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import org.earthtime.UPb_Redux.ReduxConstants;
import org.earthtime.UPb_Redux.fractions.UPbReduxFractions.UPbFraction;
import org.earthtime.UPb_Redux.fractions.UPbReduxFractions.fractionReduction.UPbFractionReducer;
Expand All @@ -34,10 +38,10 @@
import org.earthtime.UPb_Redux.valueModels.ValueModel;
import org.earthtime.UPb_Redux.valueModels.ValueModelXMLConverter;
import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.exceptions.ETException;
import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelET;
import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelETXMLConverter;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.xmlUtilities.XMLSerializationI;

/**
Expand Down Expand Up @@ -180,12 +184,12 @@ public Object readXMLObject ( String filename, boolean doValidate )
throw new ETException( null, e.getMessage() );
}

System.out.println( "This is your AnalysisFraction that was just read successfully:\n" );

String xml2 = getXStreamWriter().toXML( myFraction );

System.out.println( xml2 );
System.out.flush();
// System.out.println( "This is your AnalysisFraction that was just read successfully:\n" );
//
// String xml2 = getXStreamWriter().toXML( myFraction );
//
// System.out.println( xml2 );
// System.out.flush();
} else {
throw new ETException( null, "XML data file does not conform to schema." );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.io.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -34,12 +39,12 @@
import org.earthtime.UPb_Redux.valueModels.ValueModel;
import org.earthtime.UPb_Redux.valueModels.ValueModelXMLConverter;
import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException;
import org.earthtime.exceptions.ETException;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.dataDictionaries.DataDictionary;
import org.earthtime.exceptions.ETException;
import org.earthtime.ratioDataModels.AbstractRatiosDataModel;
import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelET;
import org.earthtime.utilities.DateHelpers;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.xmlUtilities.XMLSerializationI;

/**
Expand Down Expand Up @@ -520,12 +525,12 @@ public Object readXMLObject ( String filename, boolean doValidate )
throw new ETException( null, e.getMessage() );
}

System.out.println( "This is your InitialPbModel that was just read successfully:\n" );

String xml2 = getXStreamWriter().toXML( myInitialPbModel );

System.out.println( xml2 );
System.out.flush();
// System.out.println( "This is your InitialPbModel that was just read successfully:\n" );
//
// String xml2 = getXStreamWriter().toXML( myInitialPbModel );
//
// System.out.println( xml2 );
// System.out.flush();
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
import org.earthtime.UPb_Redux.valueModels.ValueModelReferencedXMLConverter;
import org.earthtime.UPb_Redux.valueModels.ValueModelXMLConverter;
import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.dataDictionaries.DataDictionary;
import org.earthtime.exceptions.ETException;
import org.earthtime.ratioDataModels.AbstractRatiosDataModel;
import org.earthtime.ratioDataModels.initialPbModelsET.InitialPbModelET;
import org.earthtime.ratioDataModels.mineralStandardModels.MineralStandardUPbModel;
import org.earthtime.utilities.DateHelpers;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.xmlUtilities.XMLSerializationI;

/**
Expand Down Expand Up @@ -379,6 +379,7 @@ public void serializeXMLObject ( String filename ) {
* @throws ETException
* @throws BadOrMissingXMLSchemaException
*/
@Override
public Object readXMLObject ( String filename, boolean doValidate )
throws FileNotFoundException,
ETException,
Expand All @@ -404,12 +405,6 @@ public Object readXMLObject ( String filename, boolean doValidate )
throw new ETException( null, e.getMessage() );
}

System.out.println( "This is your MineralStandardModel that was just read successfully:\n" );

String xml2 = getXStreamWriter().toXML( myMineralStandardModel );

System.out.println( xml2 );
System.out.flush();
} else {
throw new FileNotFoundException( "Badly formed or unvalidated XML data file." );
}
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/org/earthtime/UPb_Redux/pbBlanks/PbBlank.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.io.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -34,12 +39,12 @@
import org.earthtime.UPb_Redux.valueModels.ValueModel;
import org.earthtime.UPb_Redux.valueModels.ValueModelXMLConverter;
import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException;
import org.earthtime.exceptions.ETException;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.dataDictionaries.DataDictionary;
import org.earthtime.exceptions.ETException;
import org.earthtime.ratioDataModels.AbstractRatiosDataModel;
import org.earthtime.ratioDataModels.pbBlankICModels.PbBlankICModel;
import org.earthtime.utilities.DateHelpers;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.xmlUtilities.XMLSerializationI;

/**
Expand Down Expand Up @@ -671,12 +676,12 @@ public Object readXMLObject ( String filename, boolean doValidate )
throw new ETException( null, e.getMessage() );
}

System.out.println( "This is your PbBlank that was just read successfully:\n" );

String xml2 = getXStreamWriter().toXML( retPbBlank );
// System.out.println( "This is your PbBlank that was just read successfully:\n" );

System.out.println( xml2 );
System.out.flush();
// String xml2 = getXStreamWriter().toXML( retPbBlank );
//
// System.out.println( xml2 );
// System.out.flush();
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import org.earthtime.UPb_Redux.ReduxConstants;
import org.earthtime.UPb_Redux.user.UPbReduxConfigurator;
import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException;
import org.earthtime.exceptions.ETException;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.exceptions.ETException;
import org.earthtime.xmlUtilities.XMLSerializationI;

/**
Expand Down Expand Up @@ -286,12 +286,12 @@ public Object readXMLObject(String filename, boolean doValidate)
throw new ETException(null, e.getMessage());
}

System.out.println("This is your SESARSampleMetadata that was just read successfully:\n");

String xml2 = getXStreamWriter().toXML(SESARSampleMetadata);
// System.out.println("This is your SESARSampleMetadata that was just read successfully:\n");

System.out.println(xml2);
System.out.flush();
// String xml2 = getXStreamWriter().toXML(SESARSampleMetadata);
//
// System.out.println(xml2);
// System.out.flush();
} else {
throw new ETException( null, "XML data file does not conform to schema." );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.earthtime.UPb_Redux.fractions.FractionMetaData;
import org.earthtime.UPb_Redux.user.UPbReduxConfigurator;
import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException;
import org.earthtime.exceptions.ETException;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.exceptions.ETException;
import org.earthtime.xmlUtilities.XMLSerializationI;

/**
Expand Down Expand Up @@ -250,12 +250,12 @@ public Object readXMLObject(String filename, boolean doValidate)
throw new ETException(null, e.getMessage());
}

System.out.println("\nThis is your SampleMetaData that was just read successfully:\n");

String xml2 = getXStreamWriter().toXML(mySampleMetaData);
// System.out.println("\nThis is your SampleMetaData that was just read successfully:\n");

System.out.println(xml2);
System.out.flush();
// String xml2 = getXStreamWriter().toXML(mySampleMetaData);
//
// System.out.println(xml2);
// System.out.flush();
}

} else {
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/org/earthtime/UPb_Redux/tracers/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.io.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand All @@ -36,14 +41,14 @@
import org.earthtime.UPb_Redux.valueModels.ValueModel;
import org.earthtime.UPb_Redux.valueModels.ValueModelXMLConverter;
import org.earthtime.XMLExceptions.BadOrMissingXMLSchemaException;
import org.earthtime.exceptions.ETException;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.dataDictionaries.DataDictionary;
import org.earthtime.dataDictionaries.TracerIsotopes;
import org.earthtime.dataDictionaries.TracerRatiosEnum;
import org.earthtime.exceptions.ETException;
import org.earthtime.ratioDataModels.AbstractRatiosDataModel;
import org.earthtime.ratioDataModels.tracers.TracerUPbModel;
import org.earthtime.utilities.DateHelpers;
import org.earthtime.archivingTools.URIHelper;
import org.earthtime.xmlUtilities.XMLSerializationI;

/**
Expand Down Expand Up @@ -939,12 +944,12 @@ public Object readXMLObject ( String filename, boolean doValidate )
throw new ETException( null, e.getMessage() );
}

System.out.println( "This is your Tracer that was just read successfully:\n" );

String xml2 = getXStreamWriter().toXML( myTracer );
// System.out.println( "This is your Tracer that was just read successfully:\n" );

System.out.println( xml2 );
System.out.flush();
// String xml2 = getXStreamWriter().toXML( myTracer );
//
// System.out.println( xml2 );
// System.out.flush();

} else {
throw new ETException( null, "Badly formed XML data file." );
Expand Down
Loading

0 comments on commit 716d53c

Please sign in to comment.