update project. deepcopy on contact.

This commit is contained in:
2026-02-22 01:23:41 -05:00
parent f2e335af2e
commit b200f1ca7d
22 changed files with 165 additions and 55 deletions
+18 -8
View File
@@ -1,18 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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="src" output="bin/main" path="src/main/java">
<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.buildship.core.gradleclasspathcontainer"/>
<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/">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>
<attribute name="org.eclipse.ajdt.inpath.restriction" value="aspectjrt-1.9.25.jar"/>
<attribute name="org.eclipse.ajdt.inpath" value="org.eclipse.ajdt.inpath"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/home/sherwinp/.gradle/caches/modules-2/files-2.1/org.aspectj/aspectjrt/1.9.25/7f46c0f089601cde5cfbfabf4feee16aeeaf2428/aspectjrt-1.9.25.jar"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-5
View File
@@ -5,11 +5,6 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
+41
View File
@@ -0,0 +1,41 @@
eclipse.preferences.version=1
org.aspectj.ajdt.core.compiler.BuildOptions.showweavemessages=false
org.aspectj.ajdt.core.compiler.lint.BrokeSerialVersionCompatibility=ignore
org.aspectj.ajdt.core.compiler.lint.CannotImplementLazyTJP=ignore
org.aspectj.ajdt.core.compiler.lint.InvalidAbsoluteTypeName=warning
org.aspectj.ajdt.core.compiler.lint.NeedSerialVersionUIDField=ignore
org.aspectj.ajdt.core.compiler.lint.NoInterfaceCtorJoinpoint=warning
org.aspectj.ajdt.core.compiler.lint.ShadowNotInStructure=ignore
org.aspectj.ajdt.core.compiler.lint.TypeNotExposedToWeaver=warning
org.aspectj.ajdt.core.compiler.lint.UnresolvableMember=warning
org.aspectj.ajdt.core.compiler.lint.WildcardTypeName=ignore
org.aspectj.ajdt.core.compiler.lint.adviceDidNotMatch=warning
org.aspectj.ajdt.core.compiler.lint.annotationAsTargetForDecpIgnored=warning
org.aspectj.ajdt.core.compiler.lint.calculatingSerialVersionUID=ignore
org.aspectj.ajdt.core.compiler.lint.cantFindType=error
org.aspectj.ajdt.core.compiler.lint.cantFindTypeAffectingJPMatch=warning
org.aspectj.ajdt.core.compiler.lint.cantMatchArrayTypeOnVarargs=ignore
org.aspectj.ajdt.core.compiler.lint.elementAlreadyAnnotated=warning
org.aspectj.ajdt.core.compiler.lint.enumAsTargetForDecpIgnored=warning
org.aspectj.ajdt.core.compiler.lint.invalidTargetForAnnotation=warning
org.aspectj.ajdt.core.compiler.lint.multipleAdviceStoppingLazyTjp=ignore
org.aspectj.ajdt.core.compiler.lint.noExplicitConstructorCall=warning
org.aspectj.ajdt.core.compiler.lint.noGuardForLazyTjp=ignore
org.aspectj.ajdt.core.compiler.lint.noJoinpointsForBridgeMethods=warning
org.aspectj.ajdt.core.compiler.lint.runtimeExceptionNotSoftened=warning
org.aspectj.ajdt.core.compiler.lint.swallowedExceptionInCatchBlock=ignore
org.aspectj.ajdt.core.compiler.lint.uncheckedAdviceConversion=warning
org.aspectj.ajdt.core.compiler.lint.uncheckedArgument=warning
org.aspectj.ajdt.core.compiler.lint.unmatchedTargetKind=warning
org.aspectj.ajdt.core.compiler.lint.unorderedAdviceAtShadow=ignore
org.aspectj.ajdt.core.compiler.list.UnmatchedSuperTypeInCall=warning
org.aspectj.ajdt.core.compiler.weaver.XHasMember=false
org.aspectj.ajdt.core.compiler.weaver.XNoInline=false
org.aspectj.ajdt.core.compiler.weaver.XNotReweavable=false
org.aspectj.ajdt.core.compiler.weaver.XSerializableAspects=false
org.aspectj.ajdt.core.compiler.weaver.timers=false
org.aspectj.ajdt.core.compiler.weaver.verbose=false
org.aspectj.ajdt.core.complier.lint.aspectExcludedByConfiguration=ignore
org.eclipse.ajdt.core.builder.incrementalCompilationOptimizations=true
org.eclipse.ajdt.core.compiler.nonStandardOptions=
org.eclipse.ajdt.core.compiler.useProjectSettings=true
+6 -6
View File
@@ -1,13 +1,13 @@
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
arguments=
auto.sync=false
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=
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
override.workspace.settings=false
show.console.view=false
show.executions.view=false
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
encoding/build.gradle=UTF-8
+7 -1
View File
@@ -1,6 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=25
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=25
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=25
+5 -5
View File
@@ -1,10 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: bookocontacts
Bundle-SymbolicName: bookocontacts
Bundle-Name: edu.bookocontacts
Bundle-SymbolicName: edu.bookocontacts
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-26
Automatic-Module-Name: bookocontacts
Export-Package: edu.bookocontacts,
Bundle-RequiredExecutionEnvironment: JavaSE-25
Automatic-Module-Name: edu.bookocontacts
Export-Package: edu.bookocontacts
edu.bookocontacts.model,
media
+1
View File
@@ -0,0 +1 @@
6,"Jay","Sanders","410-784-8763","","DELETED","Pleasant Place","Largo","MD","20783"
BIN
View File
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
0,"Adam","Whare","310-789-5443","","INSTORE","","","",""
@@ -1,20 +1,40 @@
package edu.bookocontacts;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import edu.bookocontacts.model.DataRepositoryConfig;
import edu.bookocontacts.model.DATASET;
import edu.bookocontacts.model.Factory;
import edu.bookocontacts.model.Contact;
public aspect StorageMonitor {
pointcut save(): execution(public * edu.bookocontacts.model.Factory.*(..));
Contact around(Contact ct): execution(public * edu.bookocontacts.model.Factory.save(Contact)) && args(ct) && if(ct!=null) {
Contact ob = proceed(ct);
pointcut DELETE(): execution(public * edu.bookocontacts.model.DATASET.*(..));
before(Contact ct): execution(public * edu.bookocontacts.model.DATASET.DELETE(Contact)) && args(ct) && if(ct!=null) {
Logger logger = LoggerFactory.getLogger(Contact.class);
Logger logger = LoggerFactory.getLogger(StorageMonitor.class);
logger.info(String.format("AspectJ-Check: %s. ", ob));
logger.info(String.format("AspectJ-Check: %s. ", ct));
File file = new File(String.format("%sdeleted.log", DataRepositoryConfig.getPath()));
Factory.write2CSV(file, ct);
return ob;
}
pointcut copy(): execution(public * edu.bookocontacts.model.Contact.*(..));
before(Contact me, Contact other): execution(public * edu.bookocontacts.model.Contact.copy(Contact, Contact)) && args(me, other) && if(me!=null) {
Logger logger = LoggerFactory.getLogger(StorageMonitor.class);
logger.info(String.format("AspectJ-Check: %s. ", me));
File file = new File(String.format("%supdated.log", DataRepositoryConfig.getPath()));
Factory.write2CSV(file, me);
}
}
@@ -101,7 +101,7 @@ public class ViewController implements Initializable {
@Override
public void handle(javafx.event.ActionEvent t) {
ControlDDXDialog dialog = new ControlDDXDialog(contactView.getSelectionModel().getSelectedItem());
ControlDDXDialog dialog = new ControlDDXDialog(null);
Optional<Contact> result = dialog.showAndWait();
@@ -154,8 +154,8 @@ public class ViewController implements Initializable {
updatedContact.setId(ct.getId());
updatedContact.setStatus(EnumStatus.UPDATED);
updatedContact.save();
ct.copy(updatedContact);
//ct would be the contact in the observed list in our view.
Contact.copy(ct, updatedContact);
} catch (Exception ex) {
logger.log(Level.WARNING, ex.getMessage());
}
@@ -75,14 +75,15 @@ public class Contact {
}
}
public void copy(Contact ct){
this.id = ct.id;
this.first_name = ct.first_name;
this.last_name = ct.last_name;
this.phone_number = ct.phone_number;
this.email_address = ct.email_address;
this.mailing_address = ct.mailing_address;
this.status = ct.status;
public final static void copy(Contact me, Contact other) {
// copy other to me.
me.id = other.id;
me.first_name = other.first_name;
me.last_name = other.last_name;
me.phone_number = other.phone_number;
me.email_address = other.email_address;
me.mailing_address = other.mailing_address;
me.status = other.status;
}
@Override
@@ -97,6 +98,21 @@ public class Contact {
return sb.toString();
}
public String toCSVString() {
StringBuilder sb = new StringBuilder();
sb.append(id).append(",");
sb.append("\"").append(first_name).append("\",");
sb.append("\"").append(last_name).append("\",");
sb.append("\"").append(phone_number).append("\",");
sb.append("\"").append(email_address.getEmail_address()).append("\",");
sb.append("\"").append(status).append("\",");
sb.append("\"").append(mailing_address.street).append("\",");
sb.append("\"").append(mailing_address.city).append("\",");
sb.append("\"").append(mailing_address.state).append("\",");
sb.append("\"").append(mailing_address.zip).append("\"");
return sb.toString();
}
public void save() throws IOException {
Factory.save(this);
this.status = EnumStatus.INSTORE;
@@ -114,7 +130,7 @@ public class Contact {
this.id = id;
}
public void setStatus(EnumStatus es){
public void setStatus(EnumStatus es) {
this.status = es;
}
@@ -57,14 +57,6 @@ public final class DATASET {
return list;
}
public interface DataRepositoryConfig {
public static String getPath() {
String home = System.getenv("HOME") != null ? System.getenv("HOME")
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
return home.replace('\\', '/') + "/workspace/bookocontacts/db/";
}
}
public static void UPDATESERT(Contact ct) {
try {
PreparedStatement stmt = getPreparedStatement(String.format(
@@ -104,7 +96,7 @@ public final class DATASET {
}
}
static void DELETE(Contact ct) {
public static void DELETE(Contact ct) {
try {
PreparedStatement stmt = getPreparedStatement(String.format(
"DELETE FROM CONTACT WHERE ID=?;"));
@@ -0,0 +1,9 @@
package edu.bookocontacts.model;
public final 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/bookocontacts/db/";
}
}
@@ -4,8 +4,12 @@
*/
package edu.bookocontacts.model;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
@@ -24,12 +28,26 @@ public final class Factory {
}
public static Contact save(final Contact ct) throws IOException {
if(ct.status==EnumStatus.DELETED){
if (ct.status == EnumStatus.DELETED) {
DATASET.DELETE(ct);
}else{
} else {
DATASET.UPDATESERT(ct);
}
return ct;
}
public final static void write2CSV(File outfile, final Contact ct) {
String NEW_LINE = "\n";
try (FileWriter fileWriter = new FileWriter(outfile)) {
fileWriter.append(ct.toCSVString());
fileWriter.append(NEW_LINE);
} catch (IOException e) {
Logger.getLogger(Factory.class.getName()).log(Level.INFO, e.getMessage());
}
}
}