diff --git a/.classpath b/.classpath index ba36a3e..eaef1cb 100644 --- a/.classpath +++ b/.classpath @@ -1,18 +1,28 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/.gradle/9.3.1/executionHistory/executionHistory.bin b/.gradle/9.3.1/executionHistory/executionHistory.bin index 7dec671..f2d218a 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 867e3b9..364c675 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 ef1ca86..2044f6e 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 dd9c645..d02a896 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 1cb254a..48ec992 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 d5f1085..0ba5d52 100755 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/.project b/.project index a3569b4..08682a3 100644 --- a/.project +++ b/.project @@ -5,11 +5,6 @@ - - org.eclipse.jdt.core.javabuilder - - - org.eclipse.buildship.core.gradleprojectbuilder diff --git a/.settings/org.eclipse.ajdt.core.prefs b/.settings/org.eclipse.ajdt.core.prefs new file mode 100644 index 0000000..779f1c1 --- /dev/null +++ b/.settings/org.eclipse.ajdt.core.prefs @@ -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 diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs index 8e50e0f..e479558 100644 --- a/.settings/org.eclipse.buildship.core.prefs +++ b/.settings/org.eclipse.buildship.core.prefs @@ -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 diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 99f26c0..a296f7d 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,2 +1,3 @@ eclipse.preferences.version=1 encoding/=UTF-8 +encoding/build.gradle=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index f3fe8c3..be90df2 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index f6ccdb8..5667d92 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -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 diff --git a/db/deleted.log b/db/deleted.log new file mode 100644 index 0000000..19fee81 --- /dev/null +++ b/db/deleted.log @@ -0,0 +1 @@ +6,"Jay","Sanders","410-784-8763","","DELETED","Pleasant Place","Largo","MD","20783" diff --git a/db/sample.db b/db/sample.db index f2945d2..c0a9660 100644 Binary files a/db/sample.db and b/db/sample.db differ diff --git a/db/updated.log b/db/updated.log new file mode 100644 index 0000000..88e742d --- /dev/null +++ b/db/updated.log @@ -0,0 +1 @@ +0,"Adam","Whare","310-789-5443","","INSTORE","","","","" diff --git a/src/main/java/edu/bookocontacts/StorageMonitor.aj b/src/main/java/edu/bookocontacts/StorageMonitor.aj index ffa1f0a..e3b6159 100644 --- a/src/main/java/edu/bookocontacts/StorageMonitor.aj +++ b/src/main/java/edu/bookocontacts/StorageMonitor.aj @@ -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(StorageMonitor.class); - Logger logger = LoggerFactory.getLogger(Contact.class); + logger.info(String.format("AspectJ-Check: %s. ", ct)); - logger.info(String.format("AspectJ-Check: %s. ", ob)); - - return ob; + File file = new File(String.format("%sdeleted.log", DataRepositoryConfig.getPath())); + Factory.write2CSV(file, ct); + } + + 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); + + } + } diff --git a/src/main/java/edu/bookocontacts/ViewController.java b/src/main/java/edu/bookocontacts/ViewController.java index 7c82360..036059c 100755 --- a/src/main/java/edu/bookocontacts/ViewController.java +++ b/src/main/java/edu/bookocontacts/ViewController.java @@ -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 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()); } diff --git a/src/main/java/edu/bookocontacts/model/Contact.java b/src/main/java/edu/bookocontacts/model/Contact.java index eacd8a3..b2c572d 100644 --- a/src/main/java/edu/bookocontacts/model/Contact.java +++ b/src/main/java/edu/bookocontacts/model/Contact.java @@ -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; } diff --git a/src/main/java/edu/bookocontacts/model/DATASET.java b/src/main/java/edu/bookocontacts/model/DATASET.java index 51fbccb..5afcd89 100644 --- a/src/main/java/edu/bookocontacts/model/DATASET.java +++ b/src/main/java/edu/bookocontacts/model/DATASET.java @@ -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=?;")); diff --git a/src/main/java/edu/bookocontacts/model/DataRepositoryConfig.java b/src/main/java/edu/bookocontacts/model/DataRepositoryConfig.java new file mode 100644 index 0000000..5061ecb --- /dev/null +++ b/src/main/java/edu/bookocontacts/model/DataRepositoryConfig.java @@ -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/"; + } +} diff --git a/src/main/java/edu/bookocontacts/model/Factory.java b/src/main/java/edu/bookocontacts/model/Factory.java index 89e359b..e20ab64 100755 --- a/src/main/java/edu/bookocontacts/model/Factory.java +++ b/src/main/java/edu/bookocontacts/model/Factory.java @@ -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()); + } + + } + }