diff --git a/.gradle/9.3.1/executionHistory/executionHistory.bin b/.gradle/9.3.1/executionHistory/executionHistory.bin index 7128eac..871c4c5 100755 Binary files a/.gradle/9.3.1/executionHistory/executionHistory.bin and b/.gradle/9.3.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/9.3.1/executionHistory/executionHistory.lock b/.gradle/9.3.1/executionHistory/executionHistory.lock index 0c5718c..3211043 100755 Binary files a/.gradle/9.3.1/executionHistory/executionHistory.lock and b/.gradle/9.3.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/9.3.1/fileHashes/fileHashes.bin b/.gradle/9.3.1/fileHashes/fileHashes.bin index b99c6a5..7046df8 100755 Binary files a/.gradle/9.3.1/fileHashes/fileHashes.bin and b/.gradle/9.3.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/9.3.1/fileHashes/fileHashes.lock b/.gradle/9.3.1/fileHashes/fileHashes.lock index 32d7309..c1d8839 100755 Binary files a/.gradle/9.3.1/fileHashes/fileHashes.lock and b/.gradle/9.3.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 38dd9d2..eac0964 100755 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index ad8478b..8792fd7 100755 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs index 978c16a..8e50e0f 100644 --- a/.settings/org.eclipse.buildship.core.prefs +++ b/.settings/org.eclipse.buildship.core.prefs @@ -1,11 +1,11 @@ -arguments=--init-script C\:\\Users\\sherw\\AppData\\Roaming\\VSCodium\\User\\globalStorage\\redhat.java\\1.52.0\\config_win\\org.eclipse.osgi\\58\\0\\.cp\\gradle\\init\\init.gradle --init-script C\:\\Users\\sherw\\AppData\\Roaming\\VSCodium\\User\\globalStorage\\redhat.java\\1.52.0\\config_win\\org.eclipse.osgi\\58\\0\\.cp\\gradle\\protobuf\\init.gradle +arguments=--init-script /home/sherwinp/.config/VSCodium/User/globalStorage/redhat.java/1.50.0/config_linux/org.eclipse.osgi/58/0/.cp/gradle/init/init.gradle --init-script /home/sherwinp/.config/VSCodium/User/globalStorage/redhat.java/1.50.0/config_linux/org.eclipse.osgi/58/0/.cp/gradle/protobuf/init.gradle auto.sync=true build.scans.enabled=false connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.project.dir= eclipse.preferences.version=1 gradle.user.home= -java.home=C\:/Program Files/jdk-26 +java.home=/usr/lib/jvm/java-25-openjdk jvm.arguments= offline.mode=false override.workspace.settings=true diff --git a/db/sample.db b/db/sample.db index c5b9ffa..1b91102 100644 Binary files a/db/sample.db and b/db/sample.db differ diff --git a/readme.txt b/readme.txt index dc5e6ac..e0b75f6 100644 --- a/readme.txt +++ b/readme.txt @@ -49,22 +49,8 @@ last_name TEXT, email TEXT, phone_no TEXT, street TEXT, -fk_CITY NUMBER, -fk_STATE NUMBER, -fk_ZIP NUMBER +city TEXT, +state TEXT, +zip TEXT ); -CREATE TABLE CITY ( -ID NUMBER, -CITY TEXT -) - -CREATE TABLE STATE ( -ID NUMBER, -state TEXT -) - -CREATE TABLE ZIP ( -ID NUMBER, -zip TEXT -) diff --git a/src/main/java/edu/bookocontacts/AppSceneView.java b/src/main/java/edu/bookocontacts/AppSceneView.java index 3baeb05..cdfcc56 100755 --- a/src/main/java/edu/bookocontacts/AppSceneView.java +++ b/src/main/java/edu/bookocontacts/AppSceneView.java @@ -24,7 +24,7 @@ public class AppSceneView extends Application { stage = primaryStage; stage.setTitle("Contacts View"); Parent root = createView(); - Scene scene = new Scene(root, 600, 400); + Scene scene = new Scene(root, 500, 360); stage.setScene(scene); stage.sizeToScene(); diff --git a/src/main/java/edu/bookocontacts/ControlDDXDialog.java b/src/main/java/edu/bookocontacts/ControlDDXDialog.java index 70855f8..9218a44 100644 --- a/src/main/java/edu/bookocontacts/ControlDDXDialog.java +++ b/src/main/java/edu/bookocontacts/ControlDDXDialog.java @@ -46,7 +46,7 @@ public class ControlDDXDialog extends Dialog { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(fxml)); fxmlLoader.setController(this); fxmlLoader.setLocation(getClass().getResource(fxml)); - + try { fxmlLoader.load(); } catch (IOException exception) { @@ -65,7 +65,7 @@ public class ControlDDXDialog extends Dialog { private void setPropertyBindings(Contact ct) { Logger.getLogger(getClass().getName()).log(Level.INFO, "setPropertyBindings called."); if (ct == null) { - return; + return; } tfFirstName.setText(ct.getFirst_name()); tfLastName.setText(ct.getLast_name()); @@ -95,7 +95,7 @@ public class ControlDDXDialog extends Dialog { } private String getFirstName() { - return String.format( "%s", tfFirstName.getText()); + return String.format("%s", tfFirstName.getText()); } private String getLastName() { diff --git a/src/main/java/edu/bookocontacts/ViewController.java b/src/main/java/edu/bookocontacts/ViewController.java index a704977..24832ff 100755 --- a/src/main/java/edu/bookocontacts/ViewController.java +++ b/src/main/java/edu/bookocontacts/ViewController.java @@ -27,8 +27,6 @@ import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.input.MouseEvent; -import javafx.scene.input.PickResult; /** * FXML Controller class @@ -64,7 +62,7 @@ public class ViewController implements Initializable { private int currentPageIndex = 0; private void log(String message) { - logger.log(Level.INFO, message); + logger.log(Level.FINE, message); } /** @@ -142,23 +140,23 @@ public class ViewController implements Initializable { contactView.setOnMouseClicked(e -> { - PickResult p = e.getPickResult(); Contact ct = contactView.getSelectionModel().getSelectedItem(); - ControlDDXDialog dialog = new ControlDDXDialog(ct); - Optional result = dialog.showAndWait(); - if (result.isPresent()) { - log("result is present."); - // add to storage - Contact updatedContact = (Contact) result.get(); - try { - updatedContact.setId(ct.getId()); - ct.save(); - } catch (Exception ex) { - log(ex.getMessage()); + if (ct != null) { + ControlDDXDialog dialog = new ControlDDXDialog(ct); + Optional result = dialog.showAndWait(); + if (result.isPresent()) { + log("result is present."); + // add to storage + Contact updatedContact = (Contact) result.get(); + try { + updatedContact.setId(ct.getId()); + ct.save(); + } catch (Exception ex) { + log(ex.getMessage()); + } + updatecontactView(); } - updatecontactView(); } - }); } diff --git a/src/main/java/edu/bookocontacts/model/DATASET.java b/src/main/java/edu/bookocontacts/model/DATASET.java index 0770778..89cc35c 100644 --- a/src/main/java/edu/bookocontacts/model/DATASET.java +++ b/src/main/java/edu/bookocontacts/model/DATASET.java @@ -17,14 +17,12 @@ import org.sqlite.SQLiteDataSource; public final class DATASET { private static Connection connection = null; - public static synchronized Connection getConnection() throws IOException, SQLException { + private final static synchronized Connection getConnection() throws IOException, SQLException { if (connection == null) { File rootDir = new File(String.format("%s", DataRepositoryConfig.getPath())); Files.createDirectories(rootDir.toPath()); - SQLiteDataSource dataSource = new SQLiteDataSource(); dataSource.setUrl(String.format("jdbc:sqlite:%ssample.db", DataRepositoryConfig.getPath())); - connection = dataSource.getConnection(); } return connection; diff --git a/src/main/java/edu/bookocontacts/model/MailAddress.java b/src/main/java/edu/bookocontacts/model/MailAddress.java index d9a84d0..4b747f2 100644 --- a/src/main/java/edu/bookocontacts/model/MailAddress.java +++ b/src/main/java/edu/bookocontacts/model/MailAddress.java @@ -2,6 +2,8 @@ package edu.bookocontacts.model; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public final class MailAddress { @@ -19,25 +21,36 @@ public final class MailAddress { public MailAddress(String addressline) { this("", "", "", ""); if (addressline != null) { - try { + addressline = addressline.trim(); + if (!addressline.isBlank()) { + try { - String[] csz = addressline.split(",", 4); - street = csz[0]; - city = csz[1]; - String[] csz2; - if (csz.length < 3) { - csz2 = csz[1].trim().split(" "); + Pattern pattern = Pattern.compile("([0-9A-Za-z][^,]+)"); + Matcher matcher = pattern.matcher(addressline); + if (matcher.find()) { + street = matcher.group(); + matcher.find(); + city = matcher.group(); + matcher.find(); + state = matcher.group(); + if (matcher.find()) { + zip = matcher.group(); + return; + } + } - city = csz2[0]; - state = csz2[1]; - zip = csz2[2]; + pattern = Pattern.compile("(\\w+)\\b"); + matcher = pattern.matcher(state); + if (matcher.find()) { + state = matcher.group(); + if (matcher.find()) { + zip = matcher.group(); + } + } + } catch (Exception e) { + logger.log(Level.INFO, e.getMessage()); } - logger.log(Level.INFO, this.toString()); - - } catch (Exception e) { - logger.log(Level.INFO, e.getMessage()); } - } } diff --git a/src/main/resources/media/TableView.fxml b/src/main/resources/media/TableView.fxml index 7bce109..fb651f0 100755 --- a/src/main/resources/media/TableView.fxml +++ b/src/main/resources/media/TableView.fxml @@ -12,25 +12,26 @@ - - - - - - - - - - - -