update projects.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package edu.addressbook.view;
|
package edu.addressbook.view;
|
||||||
|
|
||||||
|
import edu.addressbook.api.HttpMessageService;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
@@ -25,7 +26,6 @@ public class ApplicationView extends Application {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
webEngine.setJavaScriptEnabled(true);
|
webEngine.setJavaScriptEnabled(true);
|
||||||
|
|
||||||
primaryStage.setTitle("AddressBook View");
|
primaryStage.setTitle("AddressBook View");
|
||||||
try {
|
try {
|
||||||
String htmlUrl = getClass().getResource(page).toExternalForm();
|
String htmlUrl = getClass().getResource(page).toExternalForm();
|
||||||
@@ -46,6 +46,7 @@ public class ApplicationView extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final static void main(String[] args) {
|
public final static void main(String[] args) {
|
||||||
|
new HttpMessageService().runServer();
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
module edu.addressbook.view {
|
|
||||||
requires java.desktop;
|
|
||||||
requires transitive javafx.graphics;
|
|
||||||
requires transitive javafx.web;
|
|
||||||
requires transitive javafx.controls;
|
|
||||||
|
|
||||||
opens edu.addressbook;
|
|
||||||
|
|
||||||
opens javafx.web;
|
|
||||||
opens javafx.controls;
|
|
||||||
opens javafx.graphics;
|
|
||||||
|
|
||||||
exports edu.addressbook.view;
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -6,6 +6,12 @@
|
|||||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="main"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25/"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25/"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
<classpathentry kind="output" path="bin/default"/>
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ group = 'edu.addressbook'
|
|||||||
version = '1.0'
|
version = '1.0'
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClass = 'edu.addressbook.App'
|
mainClass = 'edu.addressbook.api.App'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -34,23 +34,20 @@ javafx {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.slf4j:slf4j-api:2.0.17")
|
implementation("org.slf4j:slf4j-api:2.0.17")
|
||||||
implementation("ch.qos.logback:logback-classic:1.5.26")
|
implementation("ch.qos.logback:logback-classic:1.5.26")
|
||||||
implementation("org.aspectj:aspectjrt:1.9.25")
|
implementation("org.aspectj:aspectjrt:1.9.25")
|
||||||
|
|
||||||
implementation 'org.openjfx:javafx-base:25.0.1'
|
implementation 'org.xerial:sqlite-jdbc:3.51.2.0'
|
||||||
implementation 'org.openjfx:javafx-fxml:25.0.1'
|
|
||||||
implementation 'org.openjfx:javafx-controls:25.0.1'
|
|
||||||
implementation 'org.openjfx:javafx-graphics:25.0.1'
|
|
||||||
implementation 'org.openjfx:javafx-web:25.0.1'
|
|
||||||
|
|
||||||
|
implementation 'jakarta.activation:jakarta.activation-api:2.1.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Automatic-Module-Name': group,
|
attributes 'Automatic-Module-Name': group,
|
||||||
'Main-Class': application.mainClass,
|
'Main-Class': application.mainClass,
|
||||||
'Class-Path': 'edu.addressbook org.aspectj.runtime'
|
'Class-Path': 'edu.addressbook org.aspectj.runtime .'
|
||||||
}
|
}
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
|
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||||
@@ -59,10 +56,10 @@ jar {
|
|||||||
tasks.named('jar') {
|
tasks.named('jar') {
|
||||||
manifest {
|
manifest {
|
||||||
attributes(
|
attributes(
|
||||||
'Automatic-Module-Name':'edu.addressbook',
|
'Automatic-Module-Name':group,
|
||||||
'Implementation-Title': 'edu.addressbook',
|
'Implementation-Title': group,
|
||||||
'Implementation-Version': 1.0,
|
'Implementation-Version': 1.0,
|
||||||
'Main-Class': 'edu.addressbook.App',
|
'Main-Class': application.mainClass,
|
||||||
'Class-Path': 'edu.addressbook org.aspectj.runtime' )
|
'Class-Path': 'edu.addressbook org.aspectj.runtime .' )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package edu.addressbook;
|
|
||||||
|
|
||||||
public final class App {
|
|
||||||
public final static void main(final String[] args) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package edu.addressbook.api;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
import org.sqlite.SQLiteDataSource;
|
||||||
|
|
||||||
|
import edu.addressbook.model.Contact;
|
||||||
|
|
||||||
|
public final class App {
|
||||||
|
|
||||||
|
public final static ListIterator<Contact> FindAll() {
|
||||||
|
try {
|
||||||
|
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()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static void main(final String[] args) {
|
||||||
|
FindAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package edu.addressbook.api;
|
||||||
|
|
||||||
|
public class DataRepositoryConfig {
|
||||||
|
public final static String getPath() {
|
||||||
|
String home = System.getenv("HOME") != null ? System.getenv("HOME")
|
||||||
|
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
||||||
|
return home.replace('\\', '/') + "/workspace/addressbook/db/";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package edu.addressbook.api;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import com.sun.net.httpserver.HttpContext;
|
||||||
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
import com.sun.net.httpserver.HttpServer;
|
||||||
|
|
||||||
|
public final class HttpMessageService {
|
||||||
|
|
||||||
|
private class RequestHandler implements HttpHandler {
|
||||||
|
@Override
|
||||||
|
public void handle(HttpExchange httpExchange) {
|
||||||
|
InputStream inStream = httpExchange.getRequestBody();
|
||||||
|
Scanner scanner = new Scanner(inStream);
|
||||||
|
String data = scanner.nextLine();
|
||||||
|
System.out.println(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runServer() {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
HttpServer server = null;
|
||||||
|
try {
|
||||||
|
server = HttpServer.create(new InetSocketAddress(10080), 0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
HttpContext context = server.createContext("/addressbook");
|
||||||
|
context.setHandler(new RequestHandler());
|
||||||
|
server.setExecutor(null);
|
||||||
|
server.start();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
/**
|
|
||||||
* license: GPLv3
|
|
||||||
reservationsystem
|
|
||||||
*/
|
|
||||||
package edu.addressbook.model;
|
package edu.addressbook.model;
|
||||||
|
|
||||||
public final class Address{
|
public final class Address{
|
||||||
@@ -11,10 +7,6 @@ public final class Address{
|
|||||||
String state;
|
String state;
|
||||||
String zip;
|
String zip;
|
||||||
|
|
||||||
/** not used
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Address() {
|
public Address() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package edu.addressbook.model;
|
||||||
|
|
||||||
|
public class Company {
|
||||||
|
String legal_name;
|
||||||
|
String getLegalName(){
|
||||||
|
return legal_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,6 @@
|
|||||||
/**
|
|
||||||
* license: GPLv3
|
|
||||||
reservationsystem
|
|
||||||
*/
|
|
||||||
package edu.addressbook.model;
|
package edu.addressbook.model;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concrete account data class for account json storage record.
|
* Concrete account data class for account json storage record.
|
||||||
@@ -29,14 +19,11 @@ public class Contact {
|
|||||||
public Contact(
|
public Contact(
|
||||||
String phone_number,
|
String phone_number,
|
||||||
Address mailing_address,
|
Address mailing_address,
|
||||||
EmailAddress email_address) {
|
EmailAddress email_address) throws IllegalArgumentException {
|
||||||
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;
|
||||||
}
|
|
||||||
|
|
||||||
public Contact(Address mailing_address, EmailAddress email_address)
|
|
||||||
throws IllegalArgumentException {
|
|
||||||
if (phone_number == null) {
|
if (phone_number == null) {
|
||||||
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number",
|
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number",
|
||||||
mailing_address.toString()));
|
mailing_address.toString()));
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
/**
|
|
||||||
* license: GPLv3
|
|
||||||
reservationsystem
|
|
||||||
*/
|
|
||||||
package edu.addressbook.model;
|
package edu.addressbook.model;
|
||||||
|
|
||||||
public class EmailAddress{
|
public class EmailAddress{
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package edu.addressbook.model;
|
||||||
|
|
||||||
|
public class Person {
|
||||||
|
String first_name;
|
||||||
|
String last_name;
|
||||||
|
String getFirstName(){
|
||||||
|
return first_name;
|
||||||
|
}
|
||||||
|
String getLastName(){
|
||||||
|
return first_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package edu.addressbook.model;
|
||||||
|
|
||||||
|
public class PhoneNumber {
|
||||||
|
String phone_number;
|
||||||
|
|
||||||
|
public PhoneNumber(String phone_number) {
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getphone_number() {
|
||||||
|
return phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setphone_number(String phone_number) {
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((phone_number == null) ? 0 : phone_number.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
PhoneNumber other = (PhoneNumber) obj;
|
||||||
|
if (phone_number == null) {
|
||||||
|
if (other.phone_number != null)
|
||||||
|
return false;
|
||||||
|
} else if (!phone_number.equals(other.getphone_number()))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("{ \"PhoneNumber\":{");
|
||||||
|
sb.append("\"phone\": \"" + phone_number + "\"");
|
||||||
|
sb.append("}}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module edu.addressbook {
|
|
||||||
exports edu.addressbook;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user