[Ils-source] r1417 - in trunk/webapp/api/ccure: ccureuser/get updatescore.vws user/put

scribe at crosswire.org scribe at crosswire.org
Thu Mar 31 17:16:11 MST 2016


Author: scribe
Date: 2016-03-31 17:16:11 -0700 (Thu, 31 Mar 2016)
New Revision: 1417

Modified:
   trunk/webapp/api/ccure/ccureuser/get/index.jsp
   trunk/webapp/api/ccure/updatescore.vws/index.jsp
   trunk/webapp/api/ccure/user/put/index.jsp
Log:
update for CCURE integration for JAX.  All working now until they change something else.


Modified: trunk/webapp/api/ccure/ccureuser/get/index.jsp
===================================================================
--- trunk/webapp/api/ccure/ccureuser/get/index.jsp	2016-03-24 09:50:15 UTC (rev 1416)
+++ trunk/webapp/api/ccure/ccureuser/get/index.jsp	2016-04-01 00:16:11 UTC (rev 1417)
@@ -9,6 +9,7 @@
 <%@ page import="com.resolutions.ils.Utils" %>
 <%@ page import="com.resolutions.ils.ILSSession" %>
 <%@ page import="com.resolutions.ils.data.Company" %>
+<%@ page import="com.resolutions.ils.data.UserProfile" %>
 <%@ page import="org.apache.log4j.Logger" %>
 <%@ page import="java.net.URLEncoder"%>
 <%@ page import="java.net.InetAddress"%>
@@ -32,12 +33,15 @@
 			? ILSSession.login(company.getCompanyName(), userID, userPw)
 			: (ILSSession)session.getAttribute("ilsSession");
 	++errCode;
-/*
+
+	// since we need to lookup an employee record to map GUID to ObjectID (addr2), even if an ilsSession isn't established, let's use anon
+	if (ilsSession == null) ilsSession = ILSSession.getAnonymous(company.getCompanyID());
+
 	if (ilsSession == null) {
 		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
 		return;
 	}
-*/
+
 	String detail = request.getParameter("detail");
 	int detailLevel = org.crosswire.data.DataObject.DETAIL_COMPLETE;
 	if ("headeronly".equals(detail)) detailLevel = org.crosswire.data.DataObject.DETAIL_HEADERONLY;
@@ -49,17 +53,43 @@
 
 	boolean debug = "debug".equals(detail);
 
-	String userData = request.getParameter("objectID");
+	String objectID = request.getParameter("objectID");
+	String guid = request.getParameter("guid");
+	String userProfileID = request.getParameter("userProfileID");
 
-	if (userData != null) {
+	++errCode;
+	if (objectID == null && userProfileID != null) {
+		UserProfile up = UserProfile.getUserProfile(ilsSession, Integer.parseInt(userProfileID));
+		if (up != null) {
+			objectID = up.getUserProfileAddr2();
+		}
+		else {
+			out.print("<error code=\""+errCode+"\" message=\"Couldn't find user in ILS with userProfileID: "+HTTPUtils.canonize(userProfileID)+"\"/>");
+			return;
+		}
+	}
+	++errCode;
+	if (guid != null) {
+		UserProfile up = UserProfile.getUserProfileByUserData(ilsSession, guid);
+		if (up != null) {
+			objectID = up.getUserProfileAddr2();
+		}
+		else {
+			out.print("<error code=\""+errCode+"\" message=\"Couldn't find user in ILS with GUID: "+HTTPUtils.canonize(guid)+"\"/>");
+			return;
+		}
+	}
 
-		eventsLogger.debug("CCURE ccureuser/get: objectID="+userData);
+	if (objectID != null) {
 
-		int personID = -1; try { personID = Integer.parseInt(userData); } catch (Exception e) {}
 
+		int personID = -1; try { personID = Integer.parseInt(objectID); } catch (Exception e) {}
+
+		eventsLogger.debug("CCURE ccureuser/get: "+(personID == -1?"objectID=":"guid=")+(personID == -1?guid:objectID));
+
 		++errCode;
-		if (personID < 0) {
-			out.print("<error code=\""+errCode+"\" message=\"You must pass a valid personID as userProfileUserData.\"/>");
+		if (personID < 0 && guid == null) {
+			out.print("<error code=\""+errCode+"\" message=\"You must pass a valid objectID or guid as userProfileUserData.\"/>");
 			return;
 		}
 
@@ -113,7 +143,12 @@
 }
 		params = "";
 		params += "type="+URLEncoder.encode("Personnel", "UTF-8");
-		params += "&id="+URLEncoder.encode(Integer.toString(personID), "UTF-8");
+		if (personID != -1) {
+			params += "&id="+URLEncoder.encode(Integer.toString(personID), "UTF-8");
+		}
+		else {
+			params += "&GUID="+URLEncoder.encode(guid, "UTF-8");
+		}
 		params += "&token="+URLEncoder.encode(token, "UTF-8");
 		headers = new String[] {
 			"Access-Control-Expose-Headers", "session-id",
@@ -162,6 +197,7 @@
 <table border="1">
 <tbody>
 <tr><th>objectID</th><td>the CCURE ObjectID for the Personnel Record to retrieve</td></tr>
+<tr><th>guid</th><td>the CCURE GUID for the Personnel Record to retrieve</td></tr>
 <tr><th>ILSUSER</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
 <tr><th>ILSPASSWD</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
 <tr><th>detail</th><td>debug - turn on debug info</td></tr>

Modified: trunk/webapp/api/ccure/updatescore.vws/index.jsp
===================================================================
--- trunk/webapp/api/ccure/updatescore.vws/index.jsp	2016-03-24 09:50:15 UTC (rev 1416)
+++ trunk/webapp/api/ccure/updatescore.vws/index.jsp	2016-04-01 00:16:11 UTC (rev 1417)
@@ -7,6 +7,7 @@
 <%@ page import="com.resolutions.ils.Utils" %>
 <%@ page import="com.resolutions.ils.ILSSession" %>
 <%@ page import="com.resolutions.ils.data.Company" %>
+<%@ page import="com.resolutions.ils.data.UserProfile" %>
 <%@ page import="java.util.Date" %>
 <%@ page import="java.text.SimpleDateFormat" %>
 <%@ page import="org.apache.log4j.Logger" %>
@@ -27,18 +28,22 @@
 		return;
 	}
 
-/*
 	String userID = request.getParameter("ILSUSER");
 	String userPw = request.getParameter("ILSPASSWD");
 	ILSSession ilsSession = (userID != null && userPw != null)
 			? ILSSession.login(company.getCompanyName(), userID, userPw)
 			: (ILSSession)session.getAttribute("ilsSession");
+
+	// since we need to lookup an employee record to map GUID to ObjectID (addr2), even if an ilsSession isn't established, let's use anon
+	if (ilsSession == null) ilsSession = ILSSession.getAnonymous(company.getCompanyID());
+
 	++errCode;
 	if (ilsSession == null) {
 		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
 		return;
 	}
-*/
+
+
 	String detail = request.getParameter("detail");
 	int detailLevel = org.crosswire.data.DataObject.DETAIL_COMPLETE;
 	if ("headeronly".equals(detail)) detailLevel = org.crosswire.data.DataObject.DETAIL_HEADERONLY;
@@ -51,12 +56,14 @@
 
 
 	Map<String, String> courses = new HashMap<String, String>();
+	Map<String, String> courseEnums = new HashMap<String, String>();
 	int i = 1;
 	while (true) {
 		String courseName = Utils.getSysConfig(session).getProperty("CCURECourse."+i);
-//		String courseField = Utils.getSysConfig(session).getProperty("CCUREFieldCourseResult."+i);
-		if (courseName != null) {
+		String courseEnum = Utils.getSysConfig(session).getProperty("CCURECourseEnum."+i);
+		if (courseName != null && courseEnum != null) {
 			courses.put(courseName, Integer.toString(i));
+			courseEnums.put(courseName, courseEnum);
 		}
 		else break;
 		i++;
@@ -64,30 +71,68 @@
 	// if our configuration isn't specifying course names and fields, then populate with defaults
 	if (courses.size() == 0) {
 		courses.put("Ramp Driving", "1");
+		courseEnums.put("Ramp Driving", "RAMPDRIVING");
+
 		courses.put("Airfield Driving", "2");
-		courses.put("SIDA", "4");
-		courses.put("Sterile", "5");
+		courseEnums.put("Airfield Driving", "AIRFIELDDRIVING");
+
+		courses.put("SIDA", "3");
+		courseEnums.put("SIDA", "SIDA");
+
+		courses.put("Sterile", "4");
+		courseEnums.put("Sterile", "STERILE");
 	}
 	
-	String userData = request.getParameter("userProfileUserData");
+	String guid = request.getParameter("userProfileUserData");
+	String userProfileID = request.getParameter("userProfileID");
+	String companyID = request.getParameter("companyID");
+	if (companyID != null) ilsSession.setValue("COMPANYID", Integer.parseInt(companyID));
+
 	String caCompleteDateString = request.getParameter("completeDate");
 	String caStatusDescription = request.getParameter("statusDescription");
 	String courseName = request.getParameter("courseName");
 	String caScore = request.getParameter("score");
 
-	if (userData != null) {
+	String objectID = request.getParameter("objectID");
 
-		eventsLogger.debug("CCURE: userData="+userData+"; caCompleteDate="+caCompleteDateString+"; caStatusDesc="+caStatusDescription+"; courseName="+courseName+"; caScore="+caScore);
+	++errCode;
+	if (objectID == null && userProfileID != null) {
+		UserProfile up = UserProfile.getUserProfile(ilsSession, Integer.parseInt(userProfileID));
+		if (up != null) {
+			objectID = up.getUserProfileAddr2();
+		}
+		else {
+			out.print("<error code=\""+errCode+"\" message=\"Couldn't find user in ILS with userProfileID: "+HTTPUtils.canonize(userProfileID)+"\"/>");
+			return;
+		}
+	}
 
+	++errCode;
+	if (objectID == null && guid != null) {
+		UserProfile up = UserProfile.getUserProfileByUserData(ilsSession, guid);
+		if (up != null) {
+			objectID = up.getUserProfileAddr2();
+		}
+		else {
+			out.print("<error code=\""+errCode+"\" message=\"Couldn't find user in ILS with GUID: "+HTTPUtils.canonize(guid)+"\"/>");
+			return;
+		}
+	}
+
+	if (objectID != null) {
+
+		eventsLogger.debug("CCURE: objectID="+objectID+"; caCompleteDate="+caCompleteDateString+"; caStatusDesc="+caStatusDescription+"; courseName="+courseName+"; caScore="+caScore);
+
 		String statusMsg = "";
 		SimpleDateFormat df  = new SimpleDateFormat("yyyy-MM-dd");
 
-		int personID = -1; try { personID = Integer.parseInt(userData); } catch (Exception e) {}
+		int personID = -1; try { personID = Integer.parseInt(objectID); } catch (Exception e) {}
 		Date caCompleteDate = new Date(); try { caCompleteDate = new SimpleDateFormat().parse(caCompleteDateString); } catch (Exception e) {}
-		String fieldName = null;
-		String fieldData = null;
+		String fieldName = request.getParameter("fieldSet");
+		String courseEnum  = null;
 
-		fieldName = courses.get(courseName);
+		if (fieldName == null) fieldName = courses.get(courseName);
+		courseEnum = courseEnums.get(courseName);
 
 		++errCode;
 		if (personID < 0) {
@@ -164,11 +209,11 @@
 		params += "&PropertyValues="+URLEncoder.encode(df.format(caCompleteDate), "UTF-8");
 		params += "&PropertyNames="+URLEncoder.encode("UDF__TRAINING_SCORE_"+fieldName+"_", "UTF-8");
 		params += "&PropertyValues="+URLEncoder.encode(caScore, "UTF-8");
-		params += "&PropertyNames="+URLEncoder.encode("UDF__TRAINING_ACTIVE_"+fieldName+"_", "UTF-8");
-		params += "&PropertyValues="+URLEncoder.encode("PASSED".equals(caStatusDescription)?"true":"false", "UTF-8");
+		params += "&PropertyNames="+URLEncoder.encode("UDF__TRAINING_RESULT_"+fieldName+"_", "UTF-8");
+		params += "&PropertyValues="+URLEncoder.encode("PASSED".equals(caStatusDescription)?"PASSED":"FAILED", "UTF-8");
 //		params += "&PropertyNames="+URLEncoder.encode("UDF__TRAINING_EXPIRES_"+fieldName+"_", "UTF-8");
 //		params += "&PropertyValues="+URLEncoder.encode(df.format(caCompleteDate), "UTF-8");
-//
+
 		headers = new String[] {
 			"Access-Control-Expose-Headers", "session-id",
 			"session-id", sessionID
@@ -208,7 +253,9 @@
 <h3>Parameters</h3>
 <table border="1">
 <tbody>
-<tr><th>userProfileUserData</th><td>the CCURE ObjectID for the Personnel Record to update</td></tr>
+<tr><th>(objectID</th><td>the CCURE ObjectID for the Personnel Record to update. one of the first 3 parameters needs to be provided.</td></tr>
+<tr><th>|userProfileUserData</th><td>the CCURE GUID for the Personnel Record to update</td></tr>
+<tr><th>|userProfileID)</th><td>the ILS user associated with the CCURE Personnel Record to update</td></tr>
 <tr><th>completeDate</th><td>course completion date</td></tr>
 <tr><th>statusDescription</th><td>result status of the course attempt: PASSED or FAILED</td></tr>
 <tr><th>courseName</th><td>course name</td></tr>

Modified: trunk/webapp/api/ccure/user/put/index.jsp
===================================================================
--- trunk/webapp/api/ccure/user/put/index.jsp	2016-03-24 09:50:15 UTC (rev 1416)
+++ trunk/webapp/api/ccure/user/put/index.jsp	2016-04-01 00:16:11 UTC (rev 1417)
@@ -98,23 +98,32 @@
 	for (XMLBlock record : records) {
 		++total;
 		errCode = loopStartErrCode;
+
+		int partition = "$$Default$$".equals(record.getValue("PartitionKey")) || "1".equals(record.getValue("PartitionID")) ? 1 : 2;
+		ilsSession.setValue("COMPANYID", partition);
 		
 		int userProfileID = -1;
-		String userData    = record.getValue("ObjectID");
+		String userData = record.getValue("GUID");
 
+		String lname = record.getValue("LastName");
+		String fname = record.getValue("FirstName");
+		String mname = record.getValue("MiddleName");
 		String val = record.getValue("Name");
-		String lname = val.substring(0,val.indexOf(","));
-		String fname = val.substring(val.indexOf(",")+1);
-		fname = fname.trim();
-		String mname = null;
-		if (fname.lastIndexOf(" ") != -1) {
-			mname = fname.substring(fname.lastIndexOf(" ")+1);
-			fname = fname.substring(0, fname.lastIndexOf(" "));
+		String objectID = record.getValue("ObjectID");
+		if (lname == null || lname.length() == 0) {
+			lname = val.substring(0,val.indexOf(","));
+			fname = val.substring(val.indexOf(",")+1);
+			fname = fname.trim();
+			if (fname.lastIndexOf(" ") != -1) {
+				mname = fname.substring(fname.lastIndexOf(" ")+1);
+				fname = fname.substring(0, fname.lastIndexOf(" "));
+			}
 		}
 
-		String loginID     = lname + "-" + userData;
+		String loginID = record.getValue("EmailAddress");
+		if (partition == 1 || loginID == null || loginID.length() == 0) loginID = lname + "-" + objectID;
 
-		result.write("<result objectID=\"" + userData + "\" loginID=\"" + loginID + "\">");
+		result.write("<result guid=\"" + userData + "\" objectID=\"" + objectID + "\" loginID=\"" + loginID + "\">");
 
 	// one of these must be supplied; otherwise, show usage info
 		++errCode;
@@ -306,8 +315,13 @@
 		if (val != null && val.trim().length() > 0) current.setUserProfileEmployeeTitleID(Integer.parseInt(val));
 		val = request.getParameter("addr1");
 		if (val != null && val.trim().length() > 0) current.setUserProfileAddr1(val);
-		val = request.getParameter("addr2");
+
+
+		// store ObjectID in ADDR2 for now until we can resolve how to use GUID to update records via VWS
+		val = objectID;
 		if (val != null && val.trim().length() > 0) current.setUserProfileAddr2(val);
+
+
 		val = request.getParameter("city");
 		if (val != null && val.trim().length() > 0) current.setUserProfileCity(val);
 		val = request.getParameter("state");




More information about the Ils-source mailing list