Skip to content

Commit

Permalink
Fixed bug with single lookup function and added deployed zip archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Argo authored and Jonathan Argo committed Jan 14, 2017
1 parent 100b031 commit f8e6594
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 57 deletions.
27 changes: 20 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.jargo</groupId>
<artifactId>GeoLookup</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0.1</version>
<packaging>jar</packaging>

<name>GeoLookup</name>
Expand All @@ -13,12 +13,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.jargo.geolookup.GeoLookup</mainClass>
</properties>

<organization>
<!-- Used as the 'Vendor' for JNLP generation -->
<name>Your Organisation</name>
</organization>


<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -102,6 +97,24 @@
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptors>
<descriptor>src/assembly/bin.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions settings.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[settings]
key =

; Input fields
; [Input fields]
; If your address input field is all in one cell, use the fullAddressField. Otherwise set the individual parts.
fullAddressField =
streetField = street
cityField = city
stateField = state
zipField = zip

; Output fields
; [Output fields]
; All of these are optional.
fullLocationOutputField = full_location
latOutputField = latitude
Expand Down
31 changes: 31 additions & 0 deletions src/assembly/bin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
<include>settings.ini</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/site</directory>
<outputDirectory>docs</outputDirectory>
</fileSet>
</fileSets>
</assembly>
10 changes: 1 addition & 9 deletions src/main/java/com/jargo/geolookup/ApiResponse.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package com.jargo.geolookup;

import java.util.List;

/**
*
* @author jonat
*/
public class ApiResponse {
private String status;
private List<ApiResponseResult> results;
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/com/jargo/geolookup/ApiResponseBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javafx.scene.control.Alert.AlertType;

public class ApiResponseBuilder {
public static ApiResponse buildApiResponse(LookupConnector lookupConnector) {

InputStream in = lookupConnector.makeRequest();
String rawResponse = readRawResponse(in);
ApiResponse apiResponse = null;

Gson gson = new Gson();
ApiResponse apiResponse = gson.fromJson(rawResponse, ApiResponse.class);
apiResponse.setRawResponse(rawResponse);
try (InputStream in = lookupConnector.makeRequest()) {
String rawResponse = readRawResponse(in);
Gson gson = new Gson();
apiResponse = gson.fromJson(rawResponse, ApiResponse.class);
apiResponse.setRawResponse(rawResponse);
} catch (IOException ex) {
Output.handle("Failed to read response.", AlertType.ERROR);
}

return apiResponse;
}
Expand All @@ -32,7 +37,7 @@ protected static String readRawResponse(InputStream in) {
}

} catch (IOException ex) {
System.out.println("Failed to read raw response data: " + ex.getMessage());
Output.handle("Failed to read raw response data.", AlertType.ERROR);
rawResponse = null;
}

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/jargo/geolookup/GeoLookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
*
* @author jargo
*/
public class GeoLookup extends Application {

@Override
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/jargo/geolookup/GeoLookupController.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,28 +343,28 @@ protected File selectSpreadsheetFile(FileChooserType type, String title) {
}

return result;

}

protected String getKey() {
String returnVal = "";

String key = options.get("settings", "key");
if (key.isEmpty()) {
try {
FileReader fReader = new FileReader("key.txt");
BufferedReader bReader = new BufferedReader(fReader);
String line;
while ((line = bReader.readLine()) != null) {
returnVal += line;
File keyFile = new File("key.txt");
if (keyFile.canRead()) {
try {
FileReader fReader = new FileReader("key.txt");
BufferedReader bReader = new BufferedReader(fReader);
String line;
while ((line = bReader.readLine()) != null) {
returnVal += line;
}
} catch (FileNotFoundException ex) {
Output.handle("Could not find file 'key.txt'", AlertType.ERROR);
} catch (IOException ex) {
Output.handle("An error occurred while reading the key file: " + ex.getMessage(), AlertType.ERROR);
}

} catch (FileNotFoundException ex) {
Output.handle("Could not find file.", AlertType.ERROR);

} catch (IOException ex) {
Output.handle("An error occurred while reading the key file: "+ex.getMessage(), AlertType.ERROR);
}
}
} else {
returnVal = key;
}
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/com/jargo/geolookup/LookupConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import javafx.scene.control.Alert.AlertType;
import org.apache.http.client.utils.URIBuilder;

/**
*
* @author jargo
*/
public class LookupConnector {

private String _address;
Expand Down Expand Up @@ -47,13 +44,11 @@ public InputStream makeRequest() {
return connection.getInputStream();

} catch (MalformedURLException ex) {
System.out.println("Bad URL detected.");

Output.handle("Bad URL detected.", AlertType.ERROR);
} catch (IOException ex) {
System.out.println("Unable to establish connection to API.");

Output.handle("Unable to establish connection to API.", AlertType.ERROR);
} catch (URISyntaxException ex) {
System.out.println("Bad URI syntax.");
Output.handle("Bad URI syntax.", AlertType.ERROR);
}

return null;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fxml/GeoLookup.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<children>
<Label text="Single Address:" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<TextField fx:id="singleAddressField" disable="false" editable="true" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="0" />
<RadioButton fx:id="singleAddressRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="true" text="" GridPane.columnIndex="0" GridPane.rowIndex="0">
<RadioButton fx:id="singleAddressRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="false" text="" GridPane.columnIndex="0" GridPane.rowIndex="0">
<toggleGroup>
<ToggleGroup fx:id="lookupType" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="fileImportRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="false" text="" toggleGroup="$lookupType" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<RadioButton fx:id="fileImportRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="true" text="" toggleGroup="$lookupType" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<Label text="File Import:" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<children>
Expand Down
Binary file added target/GeoLookup-1.0.1-bin.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions target/classes/fxml/GeoLookup.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<children>
<Label text="Single Address:" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<TextField fx:id="singleAddressField" disable="false" editable="true" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="0" />
<RadioButton fx:id="singleAddressRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="true" text="" GridPane.columnIndex="0" GridPane.rowIndex="0">
<RadioButton fx:id="singleAddressRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="false" text="" GridPane.columnIndex="0" GridPane.rowIndex="0">
<toggleGroup>
<ToggleGroup fx:id="lookupType" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="fileImportRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="false" text="" toggleGroup="$lookupType" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<RadioButton fx:id="fileImportRadioButton" mnemonicParsing="false" onAction="#handleInputTypeChange" selected="true" text="" toggleGroup="$lookupType" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<Label text="File Import:" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<children>
Expand Down
4 changes: 2 additions & 2 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Sat Jan 14 01:03:35 EST 2017
version=1.0-SNAPSHOT
#Sat Jan 14 14:30:48 EST 2017
version=1.0.1
groupId=com.jargo
artifactId=GeoLookup

0 comments on commit f8e6594

Please sign in to comment.