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
|
auto.sync=true
|
||||||
build.scans.enabled=false
|
build.scans.enabled=false
|
||||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||||
connection.project.dir=
|
connection.project.dir=
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
gradle.user.home=
|
gradle.user.home=
|
||||||
java.home=/usr/lib/jvm/java-25-openjdk
|
java.home=C\:/Program Files/jdk-26
|
||||||
jvm.arguments=
|
jvm.arguments=
|
||||||
offline.mode=false
|
offline.mode=false
|
||||||
override.workspace.settings=true
|
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 (
|
CREATE TABLE contact (
|
||||||
contact_id NUMBER PRIMARY KEY,
|
contact_id NUMBER PRIMARY KEY,
|
||||||
first_name TEXT,
|
first_name TEXT,
|
||||||
last_name TEXT
|
last_name TEXT,
|
||||||
);
|
email TEXT,
|
||||||
|
phone_no 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,
|
|
||||||
street TEXT,
|
street TEXT,
|
||||||
city TEXT,
|
fk_CITY NUMBER,
|
||||||
state TEXT,
|
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
|
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());
|
tfPhoneNo.setText(ct.getPhoneNo().getphone_number());
|
||||||
tfEmail.setText(ct.getEmail().getEmail_address());
|
tfEmail.setText(ct.getEmail().getEmail_address());
|
||||||
tfStreet.setText(ct.getMailing_address().getStreet());
|
tfStreet.setText(ct.getMailing_address().getStreet());
|
||||||
tfCity.setText(ct.getMailing_address().getStreet());
|
tfCity.setText(ct.getMailing_address().getCity());
|
||||||
tfState.setText(ct.getMailing_address().getState());
|
tfState.setText(ct.getMailing_address().getState());
|
||||||
tfZip.setText(ct.getMailing_address().getZip());
|
tfZip.setText(ct.getMailing_address().getZip());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,13 +143,15 @@ public class ViewController implements Initializable {
|
|||||||
contactView.setOnMouseClicked(e -> {
|
contactView.setOnMouseClicked(e -> {
|
||||||
|
|
||||||
PickResult p = e.getPickResult();
|
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();
|
Optional<Contact> result = dialog.showAndWait();
|
||||||
if (result.isPresent()) {
|
if (result.isPresent()) {
|
||||||
log("result is present.");
|
log("result is present.");
|
||||||
// add to storage
|
// add to storage
|
||||||
Contact ct = (Contact) result.get();
|
Contact updatedContact = (Contact) result.get();
|
||||||
try {
|
try {
|
||||||
|
updatedContact.setId(ct.getId());
|
||||||
ct.save();
|
ct.save();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log(ex.getMessage());
|
log(ex.getMessage());
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class Contact {
|
|||||||
this.phone_number = phone_number;
|
this.phone_number = phone_number;
|
||||||
this.mailing_address = mailing_address;
|
this.mailing_address = mailing_address;
|
||||||
this.email_address = email_address;
|
this.email_address = email_address;
|
||||||
|
this.status = EnumStatus.NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contact(PhoneNumber phone_number, MailAddress mailing_address, EmailAddress email_address)
|
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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -13,14 +14,25 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import org.sqlite.SQLiteDataSource;
|
import org.sqlite.SQLiteDataSource;
|
||||||
|
|
||||||
public interface DATASET {
|
public final class DATASET {
|
||||||
public static PreparedStatement getPreparedStatement(String sql) throws SQLException, IOException {
|
private static Connection connection = null;
|
||||||
File rootDir = new File(String.format("%s", DataRepositoryConfig.getPath()));
|
|
||||||
Files.createDirectories(rootDir.toPath());
|
|
||||||
|
|
||||||
SQLiteDataSource dataSource = new SQLiteDataSource();
|
public static synchronized Connection getConnection() throws IOException, SQLException {
|
||||||
dataSource.setUrl(String.format("jdbc:sqlite:%ssample.db", DataRepositoryConfig.getPath()));
|
if (connection == null) {
|
||||||
return dataSource.getConnection().prepareStatement(sql);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PreparedStatement getPreparedStatement(String sql) throws SQLException, IOException {
|
||||||
|
|
||||||
|
return getConnection().prepareStatement(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Contact> FINDDATA() {
|
public static List<Contact> FINDDATA() {
|
||||||
@@ -62,6 +74,7 @@ public interface DATASET {
|
|||||||
stmt.setInt(1, ct.getId());
|
stmt.setInt(1, ct.getId());
|
||||||
ResultSet rs = stmt.executeQuery();
|
ResultSet rs = stmt.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = getPreparedStatement(String.format(
|
stmt = getPreparedStatement(String.format(
|
||||||
"UPDATE CONTACT SET FIRST_NAME=?, LAST_NAME=?, EMAIL_ADDRESS=?, PHONE_NUMBER=?, MAIL_ADDRESS=? WHERE ID=?;"));
|
"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.execute();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} else {
|
} else {
|
||||||
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = getPreparedStatement(String.format(
|
stmt = getPreparedStatement(String.format(
|
||||||
"INSERT INTO CONTACT(ID, FIRST_NAME, LAST_NAME, EMAIL_ADDRESS, PHONE_NUMBER, MAIL_ADDRESS) "
|
"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 {
|
try {
|
||||||
PreparedStatement stmt = getPreparedStatement(String.format(
|
PreparedStatement stmt = getPreparedStatement(String.format(
|
||||||
"DELETE FROM CONTACT WHERE ID=?;"));
|
"DELETE FROM CONTACT WHERE ID=?;"));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package edu.bookocontacts.model;
|
package edu.bookocontacts.model;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public final class MailAddress {
|
public final class MailAddress {
|
||||||
|
|
||||||
@@ -9,6 +10,8 @@ public final class MailAddress {
|
|||||||
String state;
|
String state;
|
||||||
String zip;
|
String zip;
|
||||||
|
|
||||||
|
Logger logger = Logger.getLogger(getClass().getName());
|
||||||
|
|
||||||
public MailAddress() {
|
public MailAddress() {
|
||||||
this("", "", "", "");
|
this("", "", "", "");
|
||||||
}
|
}
|
||||||
@@ -16,19 +19,25 @@ public final class MailAddress {
|
|||||||
public MailAddress(String addressline) {
|
public MailAddress(String addressline) {
|
||||||
this("", "", "", "");
|
this("", "", "", "");
|
||||||
if (addressline != null) {
|
if (addressline != null) {
|
||||||
try (Scanner scanner = new Scanner(addressline)) {
|
try {
|
||||||
try {
|
|
||||||
|
|
||||||
scanner.useDelimiter(",\\s*");
|
|
||||||
street = scanner.next();
|
|
||||||
city = scanner.next();
|
|
||||||
state = scanner.next();
|
|
||||||
zip = scanner.next();
|
|
||||||
|
|
||||||
} catch (java.util.NoSuchElementException e) {
|
String[] csz = addressline.split(",", 4);
|
||||||
scanner.close();
|
street = csz[0];
|
||||||
|
city = csz[1];
|
||||||
|
String[] csz2;
|
||||||
|
if (csz.length < 3) {
|
||||||
|
csz2 = csz[1].trim().split(" ");
|
||||||
|
|
||||||
|
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