changes
This commit is contained in:
@@ -33,7 +33,7 @@ public final class TestAccountLoad {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Configure data repository
|
||||
AccomodationManager mgr = new AccomodationManager(getRepositoryConfig.getPath());
|
||||
AccomodationManager mgr = new AccomodationManager(AccomodationManager.getRepositoryConfig.getPath());
|
||||
|
||||
// 3. Add new account object to the list managed by Manager (if account object
|
||||
// already exists on add action with the same account number, it is considered
|
||||
@@ -49,12 +49,4 @@ public final class TestAccountLoad {
|
||||
mgr.showAccountList();
|
||||
System.out.println("Program Completed.");
|
||||
}
|
||||
|
||||
public final static class getRepositoryConfig {
|
||||
public final static String getPath() {
|
||||
String home = System.getenv("HOME") != null ? System.getenv("HOME")
|
||||
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
||||
return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class TestReservations {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Configure data repository
|
||||
AccomodationManager mgr = new AccomodationManager(getRepositoryConfig.getPath());
|
||||
AccomodationManager mgr = new AccomodationManager(AccomodationManager.getRepositoryConfig.getPath());
|
||||
|
||||
// 1. Get the list of loaded accounts from Manager
|
||||
mgr.loadAll();
|
||||
@@ -149,12 +149,4 @@ public final class TestReservations {
|
||||
|
||||
System.out.println("Program Completed.");
|
||||
}
|
||||
|
||||
public final static class getRepositoryConfig {
|
||||
public final static String getPath() {
|
||||
String home = System.getenv("HOME") != null ? System.getenv("HOME")
|
||||
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
||||
return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public final class AccomodationManager {
|
||||
};
|
||||
|
||||
public AccomodationManager(String home) {
|
||||
|
||||
setDataStoreRoot(home);
|
||||
};
|
||||
|
||||
@@ -36,11 +35,15 @@ public final class AccomodationManager {
|
||||
DataRepository.setDataStoreRoot(home);
|
||||
}
|
||||
|
||||
String getDataStoreRoot(){
|
||||
return DataRepository.getPath();
|
||||
}
|
||||
|
||||
public final void loadAll()
|
||||
throws IOException, IllegalArgumentException, IllegalOperationException, DuplicateObjectException {
|
||||
accounts.clear();
|
||||
// walk directories
|
||||
Path rootDir = Paths.get(DataRepository.getPath());
|
||||
Path rootDir = Paths.get(getDataStoreRoot());
|
||||
DataRepository.WalkFileSystemTree(this, rootDir);
|
||||
System.out.println(String.format("%s LoadAll Accounts %d", "Deserializing", accounts.size()));
|
||||
}
|
||||
@@ -125,4 +128,12 @@ public final class AccomodationManager {
|
||||
System.out.println(String.format("Account %s", acct.getAccount_number()));
|
||||
}
|
||||
}
|
||||
|
||||
public final static class getRepositoryConfig {
|
||||
public final static String getPath() {
|
||||
String home = System.getenv("HOME") != null ? System.getenv("HOME")
|
||||
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
||||
return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user