update project
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,11 +1,11 @@
|
||||
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
|
||||
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
|
||||
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=/usr/lib/jvm/java-25-openjdk
|
||||
java.home=C\:/Program Files/jdk-26
|
||||
jvm.arguments=
|
||||
offline.mode=false
|
||||
override.workspace.settings=true
|
||||
|
||||
Binary file not shown.
+21
-40
@@ -45,45 +45,26 @@ UPDATE CONTACT SET MAIL_ADDRESS=NULL WHERE ID=8;
|
||||
CREATE TABLE contact (
|
||||
contact_id NUMBER PRIMARY KEY,
|
||||
first_name TEXT,
|
||||
last_name TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE phone (
|
||||
contact_id NUMBER FOREIGN KEY,
|
||||
phone_no TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE emailaddress (
|
||||
contact_id NUMBER FOREIGN KEY,
|
||||
email TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE address (
|
||||
contact_id NUMBER FOREIGN KEY,
|
||||
last_name TEXT,
|
||||
email TEXT,
|
||||
phone_no TEXT,
|
||||
street TEXT,
|
||||
city TEXT,
|
||||
state TEXT,
|
||||
fk_CITY NUMBER,
|
||||
fk_STATE NUMBER,
|
||||
fk_ZIP NUMBER
|
||||
);
|
||||
|
||||
CREATE TABLE CITY (
|
||||
ID NUMBER,
|
||||
CITY TEXT
|
||||
)
|
||||
|
||||
CREATE TABLE STATE (
|
||||
ID NUMBER,
|
||||
state TEXT
|
||||
)
|
||||
|
||||
CREATE TABLE ZIP (
|
||||
ID NUMBER,
|
||||
zip TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE note (
|
||||
contact_id NUMBER FOREIGN KEY,
|
||||
note TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE activity (
|
||||
activity_id NUMBER FOREIGN KEY,
|
||||
activity_type TEXT,
|
||||
activity_note TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE contact_activity (
|
||||
activity_id NUMBER FOREIGN KEY,
|
||||
contact_id NUMBER FOREIGN KEY
|
||||
);
|
||||
|
||||
CREATE TABLE friends (
|
||||
contact_id NUMBER FOREIGN KEY,
|
||||
friend_contact_id NUMBER FORIEGN KEY
|
||||
);
|
||||
|
||||
)
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ControlDDXDialog extends Dialog<Contact> {
|
||||
tfPhoneNo.setText(ct.getPhoneNo().getphone_number());
|
||||
tfEmail.setText(ct.getEmail().getEmail_address());
|
||||
tfStreet.setText(ct.getMailing_address().getStreet());
|
||||
tfCity.setText(ct.getMailing_address().getStreet());
|
||||
tfCity.setText(ct.getMailing_address().getCity());
|
||||
tfState.setText(ct.getMailing_address().getState());
|
||||
tfZip.setText(ct.getMailing_address().getZip());
|
||||
}
|
||||
|
||||
@@ -143,13 +143,15 @@ public class ViewController implements Initializable {
|
||||
contactView.setOnMouseClicked(e -> {
|
||||
|
||||
PickResult p = e.getPickResult();
|
||||
ControlDDXDialog dialog = new ControlDDXDialog(contactView.getSelectionModel().getSelectedItem());
|
||||
Contact ct = contactView.getSelectionModel().getSelectedItem();
|
||||
ControlDDXDialog dialog = new ControlDDXDialog(ct);
|
||||
Optional<Contact> result = dialog.showAndWait();
|
||||
if (result.isPresent()) {
|
||||
log("result is present.");
|
||||
// add to storage
|
||||
Contact ct = (Contact) result.get();
|
||||
Contact updatedContact = (Contact) result.get();
|
||||
try {
|
||||
updatedContact.setId(ct.getId());
|
||||
ct.save();
|
||||
} catch (Exception ex) {
|
||||
log(ex.getMessage());
|
||||
|
||||
@@ -42,6 +42,7 @@ public class Contact {
|
||||
this.phone_number = phone_number;
|
||||
this.mailing_address = mailing_address;
|
||||
this.email_address = email_address;
|
||||
this.status = EnumStatus.NEW;
|
||||
}
|
||||
|
||||
public Contact(PhoneNumber phone_number, MailAddress mailing_address, EmailAddress email_address)
|
||||
|
||||
@@ -3,6 +3,7 @@ package edu.bookocontacts.model;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -13,14 +14,25 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.sqlite.SQLiteDataSource;
|
||||
|
||||
public interface DATASET {
|
||||
public static PreparedStatement getPreparedStatement(String sql) throws SQLException, IOException {
|
||||
public final class DATASET {
|
||||
private static Connection connection = null;
|
||||
|
||||
public 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()));
|
||||
return dataSource.getConnection().prepareStatement(sql);
|
||||
|
||||
connection = dataSource.getConnection();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static PreparedStatement getPreparedStatement(String sql) throws SQLException, IOException {
|
||||
|
||||
return getConnection().prepareStatement(sql);
|
||||
}
|
||||
|
||||
public static List<Contact> FINDDATA() {
|
||||
@@ -62,6 +74,7 @@ public interface DATASET {
|
||||
stmt.setInt(1, ct.getId());
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
rs.close();
|
||||
stmt.close();
|
||||
stmt = getPreparedStatement(String.format(
|
||||
"UPDATE CONTACT SET FIRST_NAME=?, LAST_NAME=?, EMAIL_ADDRESS=?, PHONE_NUMBER=?, MAIL_ADDRESS=? WHERE ID=?;"));
|
||||
@@ -74,6 +87,7 @@ public interface DATASET {
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} else {
|
||||
rs.close();
|
||||
stmt.close();
|
||||
stmt = getPreparedStatement(String.format(
|
||||
"INSERT INTO CONTACT(ID, FIRST_NAME, LAST_NAME, EMAIL_ADDRESS, PHONE_NUMBER, MAIL_ADDRESS) "
|
||||
@@ -92,7 +106,7 @@ public interface DATASET {
|
||||
}
|
||||
}
|
||||
|
||||
static void DELETE(Contact ct){
|
||||
static void DELETE(Contact ct) {
|
||||
try {
|
||||
PreparedStatement stmt = getPreparedStatement(String.format(
|
||||
"DELETE FROM CONTACT WHERE ID=?;"));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package edu.bookocontacts.model;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class MailAddress {
|
||||
|
||||
@@ -9,6 +10,8 @@ public final class MailAddress {
|
||||
String state;
|
||||
String zip;
|
||||
|
||||
Logger logger = Logger.getLogger(getClass().getName());
|
||||
|
||||
public MailAddress() {
|
||||
this("", "", "", "");
|
||||
}
|
||||
@@ -16,19 +19,25 @@ public final class MailAddress {
|
||||
public MailAddress(String addressline) {
|
||||
this("", "", "", "");
|
||||
if (addressline != null) {
|
||||
try (Scanner scanner = new Scanner(addressline)) {
|
||||
try {
|
||||
|
||||
scanner.useDelimiter(",\\s*");
|
||||
street = scanner.next();
|
||||
city = scanner.next();
|
||||
state = scanner.next();
|
||||
zip = scanner.next();
|
||||
String[] csz = addressline.split(",", 4);
|
||||
street = csz[0];
|
||||
city = csz[1];
|
||||
String[] csz2;
|
||||
if (csz.length < 3) {
|
||||
csz2 = csz[1].trim().split(" ");
|
||||
|
||||
} catch (java.util.NoSuchElementException e) {
|
||||
scanner.close();
|
||||
city = csz2[0];
|
||||
state = csz2[1];
|
||||
zip = csz2[2];
|
||||
}
|
||||
logger.log(Level.INFO, this.toString());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.INFO, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user