aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons
diff options
context:
space:
mode:
authorGerwin Gsenger <g.gsenger@datentechnik-innovation.at>2015-01-15 10:20:46 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2015-06-19 11:07:52 +0200
commit1c8dc14de27abd95b79f4d515e80639ccb1cc366 (patch)
treefca63b3f900bc68cdd14ed795784818cfc3e51c0 /id/server/moa-id-commons
parent3e1ec05d5aeb0a02e6051c0f35607e6a91995092 (diff)
downloadmoa-id-spss-1c8dc14de27abd95b79f4d515e80639ccb1cc366.tar.gz
moa-id-spss-1c8dc14de27abd95b79f4d515e80639ccb1cc366.tar.bz2
moa-id-spss-1c8dc14de27abd95b79f4d515e80639ccb1cc366.zip
small codereview, added corresponding databasequeries as comments
Diffstat (limited to 'id/server/moa-id-commons')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java52
1 files changed, 35 insertions, 17 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java
index 8e2ae7e46..e39f598b1 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/NewConfigurationDBRead.java
@@ -33,25 +33,13 @@ public class NewConfigurationDBRead {
/**
*
- * @param key
- * @param clazz
- * @return
- */
- private static <T> List<T> getAllObjects(String key, Class<T> clazz) {
-
- List<T> result = null;
- result = conf.getList("getAllUsers", clazz);
- return result;
- }
-
- /**
- *
* @return
*/
public static List<UserDatabase> getAllUsers() {
Logger.trace("Get All Users from database.");
- List<UserDatabase> result = getAllObjects("getAllUsers", UserDatabase.class);
+ // select userdatabase from UserDatabase userdatabase
+ List<UserDatabase> result = conf.getList("getAllUsers", UserDatabase.class);
if (result.size() == 0) {
Logger.trace("No entries found.");
return null;
@@ -67,7 +55,8 @@ public class NewConfigurationDBRead {
public static List<OnlineApplication> getAllOnlineApplications() {
Logger.trace("Get All OnlineApplications from database.");
- return getAllObjects("getAllOnlineApplications", OnlineApplication.class);
+ // select onlineapplication from OnlineApplication onlineapplication
+ return conf.getList("getAllOnlineApplications", OnlineApplication.class);
}
/**
@@ -77,6 +66,8 @@ public class NewConfigurationDBRead {
public static List<OnlineApplication> getAllNewOnlineApplications() {
Logger.trace("Get All New OnlineApplications from database.");
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.isActive = '0' and onlineapplication.isAdminRequired = '1'
List<OnlineApplication> result = new ArrayList<OnlineApplication>();
List<OnlineApplication> allOAs = getAllOnlineApplications();
@@ -101,10 +92,14 @@ public class NewConfigurationDBRead {
public static MOAIDConfiguration getMOAIDConfiguration() {
Logger.trace("Load MOAID Configuration from database.");
+ // select moaidconfiguration from MOAIDConfiguration moaidconfiguration
MOAIDConfiguration result = null;
-
result = conf.get("getMOAIDConfiguration", MOAIDConfiguration.class);
+ if(result == null){
+ Logger.trace("No entries found. Create fresh instance.");
+ return new MOAIDConfiguration();
+ }
return result;
}
@@ -115,6 +110,8 @@ public class NewConfigurationDBRead {
public static List<OnlineApplication> getAllActiveOnlineApplications() {
Logger.trace("Get All New OnlineApplications from database.");
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.isActive = '1'
List<OnlineApplication> result = new ArrayList<OnlineApplication>();
List<OnlineApplication> allOAs = getAllOnlineApplications();
@@ -140,6 +137,9 @@ public class NewConfigurationDBRead {
public static OnlineApplication getActiveOnlineApplication(String id) {
Logger.trace("Getting Active OnlineApplication with ID " + id + " from database.");
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.publicURLPrefix =
+ // SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix)) and onlineapplication.isActive = '1'
OnlineApplication result = null;
List<OnlineApplication> allActiveOAs = getAllActiveOnlineApplications();
@@ -168,6 +168,7 @@ public class NewConfigurationDBRead {
public static OnlineApplication getOnlineApplication(long dbid) {
Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database.");
+ // select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id
OnlineApplication result = null;
List<OnlineApplication> allOAs = getAllOnlineApplications();
@@ -189,6 +190,8 @@ public class NewConfigurationDBRead {
public static OnlineApplication getOnlineApplication(String id) {
Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.publicURLPrefix = SUBSTRING(:id, 1, LENGTH(onlineapplication.publicURLPrefix))
OnlineApplication result = null;
List<OnlineApplication> allOAs = getAllOnlineApplications();
@@ -217,6 +220,8 @@ public class NewConfigurationDBRead {
public static List<OnlineApplication> searchOnlineApplications(String id) {
Logger.trace("Getting OnlineApplication with ID " + id + " from database.");
+ // select onlineapplication from OnlineApplication onlineapplication
+ // where onlineapplication.friendlyName like :id
List<OnlineApplication> result = new ArrayList<OnlineApplication>();
List<OnlineApplication> allOAs = getAllOnlineApplications();
@@ -241,12 +246,15 @@ public class NewConfigurationDBRead {
public static List<UserDatabase> getAllOpenUsersRequests() {
Logger.trace("Get all new Users from Database");
+ // select userdatabase from UserDatabase userdatabase
+ // where userdatabase.userRequestTokken is not null
+ // and userdatabase.isAdminRequest = '1' and userdatabase.isMailAddressVerified = '0'
List<UserDatabase> result = new ArrayList<UserDatabase>();
List<UserDatabase> allUsers = getAllUsers();
for (UserDatabase user : nullGuard(allUsers)) {
// TODO check result of query "... userdatabase.userRequestTokken is not null" if Tokken is null -> (null, "NULL", "", ... ?)
- if ((user.getUserRequestTokken() != null || !user.getUserRequestTokken().equals("") || !user.getUserRequestTokken().equals("NULL"))
+ if ((user.getUserRequestTokken() != null && !user.getUserRequestTokken().isEmpty() && !user.getUserRequestTokken().equals("NULL"))
&& (user.isIsAdminRequest()) && (!user.isIsMailAddressVerified())) {
result.add(user);
}
@@ -268,6 +276,7 @@ public class NewConfigurationDBRead {
public static UserDatabase getNewUserWithTokken(String tokken) {
Logger.trace("Getting Userinformation with Tokken " + tokken + " from database.");
+ // select userdatabase from UserDatabase userdatabase where userdatabase.userRequestTokken = :tokken
UserDatabase result = null;
List<UserDatabase> allUsers = getAllUsers();
@@ -289,6 +298,8 @@ public class NewConfigurationDBRead {
public static UserDatabase getUsersWithOADBID(long id) {
Logger.trace("Getting Userinformation with OADBID " + id + " from database.");
+ // select userdatabase from UserDatabase userdatabase
+ // inner join userdatabase.onlineApplication oa where oa.hjid = :id
UserDatabase result = null;
List<UserDatabase> allUsers = getAllUsers();
@@ -320,11 +331,14 @@ public class NewConfigurationDBRead {
public static UserDatabase getUserWithID(long id) {
Logger.trace("Getting Userinformation with ID " + id + " from database.");
+ // select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id
UserDatabase result = null;
List<UserDatabase> allUsers = getAllUsers();
+
for (UserDatabase user : nullGuard(allUsers)) {
if (user.getHjid() == id) {
result = user;
+ break;
}
}
@@ -339,12 +353,14 @@ public class NewConfigurationDBRead {
public static UserDatabase getUserWithUserName(String username) {
Logger.trace("Getting Userinformation with ID " + username + " from database.");
+ // select userdatabase from UserDatabase userdatabase where userdatabase.username = :username
UserDatabase result = null;
List<UserDatabase> allUsers = getAllUsers();
for (UserDatabase user : nullGuard(allUsers)) {
if (user.getUsername().equals(username)) {
result = user;
+ break;
}
}
@@ -359,12 +375,14 @@ public class NewConfigurationDBRead {
public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) {
Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database.");
+ // select userdatabase from UserDatabase userdatabase where userdatabase.bpk = :bpk
UserDatabase result = null;
List<UserDatabase> allUsers = getAllUsers();
for (UserDatabase user : nullGuard(allUsers)) {
if (user.getBpk().equals(bpkwbpk)) {
result = user;
+ break;
}
}