Skip to content

Commit

Permalink
Added log capability to server/datastruct
Browse files Browse the repository at this point in the history
  • Loading branch information
dep11007 committed Apr 17, 2015
1 parent 64a0764 commit 15ecf25
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/InputOutput/DataStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ public class DataStructure extends Hashtable<String, Hashtable<String, Hashtable
private static final long serialVersionUID = 1105146094425728795L;
//private Hashtable<String, Hashtable<String, String>> internalStructure;
private final String FILE_NAME = "datastruct.txt";

public DataStructure(){
private Thermostatable owner;

public DataStructure(Thermostatable owner){
this.owner = owner;
File f = new File(FILE_NAME);
if(f.exists() && !f.isDirectory()) {
System.out.println("Previous Settings/Data Found!");
this.restoreFromDisk();
}
}

public String updateTable(String tableName, String key, String subKey, String value){
public void updateTable(String tableName, String key, String subKey, String value){

String query = "Inserting Value: "+value + " FOR KEY: "+subKey+" FOR Object: "+key+" INTO: "+tableName;

Expand Down Expand Up @@ -61,7 +63,7 @@ public String updateTable(String tableName, String key, String subKey, String va
this.put(tableName, tempTable);
this.writeToDisk();

return query;
this.owner.datastructureLogEvent(query);
}

public String queryForValue(String tableName, String key, String subKey){
Expand Down
9 changes: 4 additions & 5 deletions src/InputOutput/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

public class Database extends DataStructure implements Thermostatable{

public Database(){
public Database(Thermostatable owner){
super(owner);
this.updateTable("UserTable", null, null, null);

this.updateTable("Thermostat", null, null, null);
Expand Down Expand Up @@ -59,11 +60,9 @@ public String getDevicesFromEmail(String email){
}



@Override
public String datastructureLogEvent() {
// TODO Auto-generated method stub
return null;
public void datastructureLogEvent(String query) {
// don't use this here
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/InputOutput/Thermostatable.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public interface Thermostatable {

public String getDevicesFromEmail(String email);

public String datastructureLogEvent();
public void datastructureLogEvent(String query);
}
12 changes: 7 additions & 5 deletions src/server/server.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public server() {
String adminpassword = "admin";
String ip = "127.0.0.1";
String email = "admin@uconn.edu";
Database dataStorage = new Database();
Database dataStorage = new Database(this);
dataStorage.createUser(admin, adminpassword, ip, email);
}

Expand Down Expand Up @@ -82,9 +82,11 @@ public String getDevicesFromEmail(String email) {
// TODO Auto-generated method stub
return null;
}





@Override
public void datastructureLogEvent(String query) {
// take this query string and pass it to the UI to display in the Log in the server text field
}


}

0 comments on commit 15ecf25

Please sign in to comment.