User Account Display
public ArrayList ucUpsertUserRecord(
Connection dbconn,
SesameSession session,
SecurityUser su,
HashMap suHm,
ArrayList UFIColumnDope )
public ArrayList ucUpsertUserRecord(
Connection dbconn,
SesameSession session,
SecurityUser su,
HashMap suHm,
ArrayList UFIColumnDope )
throws Exception {
//Loop through the UFIDope array list, for each table, pick up the column name
//then grab the values, if any, from the suHm and do that insert
ArrayList uarSecGroupIdList = new ArrayList();
ArrayList uarAreaIdList = new ArrayList();
ArrayList ugUserGroupIdList = new ArrayList();
String tempVal = new String();
for (int x=0; x< UFIColumnDope.size(); x++) {
tempVal = "";
UFIColumnDope ufi = (UFIColumnDope)UFIColumnDope.get(x);
String columnName = ufi.getColumnName();
//UC_USER_AREA_ROLE.SECURITY_GROUP_ID is a column name
//ADMIN is the value OP_SPECIALE
//UC_USER_AREA_ROLE.AREA_ID is a column name
//Fault Tracking is the value
//Conformance is the value
if (suHm.containsKey(columnName)) {
if (suHm.get(columnName) instanceof ArrayList){
//grab each arrayList and keep it until the end of the columnDope loop
if ("UC_USER_AREA_ROLE.SECURITY_GROUP_ID".equalsIgnoreCase(columnName)) {
uarSecGroupIdList = (ArrayList)suHm.get(columnName);
} else if ("UC_USER_AREA_ROLE.AREA_ID".equalsIgnoreCase(columnName)) {
uarAreaIdList = (ArrayList) suHm.get(columnName);
} else if ("USER_GROUP_ID".equalsIgnoreCase(columnName)) {
ugUserGroupIdList = (ArrayList) suHm.get(columnName);
}
} else {
if ("UC_USER_AREA_ROLE.SECURITY_GROUP_ID".equalsIgnoreCase(columnName)){
tempVal = (String)suHm.get(columnName);
uarSecGroupIdList.add(tempVal);
} else if ("UC_USER_AREA_ROLE.AREA_ID".equalsIgnoreCase(columnName)) {
tempVal = (String)suHm.get(columnName);
uarAreaIdList.add(tempVal);
} else if ("USER_GROUP_ID".equalsIgnoreCase(columnName)){
tempVal = (String)suHm.get(columnName);
ugUserGroupIdList.add(tempVal);
}
}
}
}
//now that we've looped through all of the columns for this user, we should
//have a handful of ArrayLists that we can pull data out of and insert appropriate
//values into the system for the current user.
//first we'll work on the UC_USER_AREA_ROLE table
ArrayList areaRoleList = new ArrayList();
for (int y=0; y<uarAreaIdList.size(); y++) {
String areaVal = new String();
String roleVal = new String();
areaVal = (String)uarAreaIdList.get(y);
if (uarSecGroupIdList.size()>0 && uarSecGroupIdList.size()<=y) {
roleVal = (String)uarSecGroupIdList.get(y);
}
if (TextManager.isStringVisible(areaVal) && TextManager.isStringVisible(roleVal) ) {
areaRoleList.add(areaVal + "|" + roleVal);
}
}
//when inserting users into user area roles, we'll also use the standard
//methods so that we're consistent with the GUI methodology
if (areaRoleList.size()>0){
UserAreaRole.addMultiple(dbconn, su.getId(), areaRoleList, session.getUserId());
}
//now let's deal with the USER_GROUP stuff
//when inserting users into user groups, we want to use the custom methods
//so that the user is also added to each project, privacy group etc etc
for (int y=0; y<ugUserGroupIdList.size(); y++){
String userGroupId = (String)ugUserGroupIdList.get(y);
if (TextManager.isStringVisible(userGroupId)) {
Z.log.writeToLog(Z.log.DEBUG, "adding " + userGroupId + " for user " + su.getId());
UserGroup.addUserToUserGroup(dbconn, userGroupId, su.getId());
}
}
return null;
}