<% /****************************************************************************** * Copyright (c) 2000-2004 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. * * ******************************************************************************/ %><%@page session="true" import="com.edeal.frontline.*,java.util.*,java.text.*,java.lang.reflect.*, com.edeal.frontline.navigation.*"%> <%@ page import="java.util.LinkedHashMap" %> <%@ page import="com.edeal.frontline.helper.custom.EventHelper" %> <%@ page import="com.edeal.frontline.helper.EventBaseHelper.StatusType" %> <%@ page import="com.edeal.frontline.helper.EventBaseHelper.EventCategory" %> <%@ page import="java.util.Iterator" %> <%@ taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %> <% //GET CONTEXT INFO final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); DataDictionary dico = context.getDataDictionary(); // GET ACTOR NAME String actID = (String)session.getAttribute("actorID"); String actCompleteName = "........."; try { ObjectsBean objBean = dico.getTable("sql", "Actor"); actCompleteName = objBean.toString(session, actID); } catch (FrontlineException fe) { } //GET PARAMETERS String lsePositionStr = flRequest.getRequestParameterOrAttribute("lsePosition"); String perID = flRequest.getRequestParameterOrAttribute("perID"); String scriptID = flRequest.getRequestParameterOrAttribute("scriptID"); String preview = flRequest.getRequestParameterOrAttribute("preview"); if (preview == null) preview = "0"; int lsePosition = new Integer(lsePositionStr).intValue(); //GET OBJECTS FROM SESSION PersonBean person = null; ScriptBean script = null; Vector linkScriptElements = new Vector(); Vector scriptElements = new Vector(); person = (PersonBean)session.getAttribute("srpPerson"); script = (ScriptBean)session.getAttribute("srpScript"); scriptElements = (Vector)session.getAttribute("srpScriptElements"); linkScriptElements = (Vector)session.getAttribute("srpLinkScriptElements"); if (script == null || scriptElements == null || scriptElements.size() == 0 || !scriptID.equals(script.getScrID())) { throw new FrontlineException("scriptresponse edit_body info missing"); } // pour la replication de session en cluster if (person != null) { person.setSession(session); } if (script != null) { script.setSession(session); } for (int i = 0; i < scriptElements.size(); i++) { if (scriptElements.elementAt(i) != null) { ((ScriptElementBean)scriptElements.elementAt(i)).setSession(session); } } for (int i = 0; i < linkScriptElements.size(); i++) { if (linkScriptElements.elementAt(i) != null) { ((LinkScriptElementBean)linkScriptElements.elementAt(i)).setSession(session); } } ScriptElementBean scriptElement = null; LinkScriptElementBean linkScriptElement = null; if (scriptElements.size() > 0) { scriptElement = (ScriptElementBean)scriptElements.elementAt(lsePosition); linkScriptElement = (LinkScriptElementBean)linkScriptElements.elementAt(lsePosition); } //GET DISPLAY INFO String scriptLabel = "???"; String scriptNumber = "???"; String scriptEventID = null; scriptEventID = script.getScrEventID(); String scrParStatusRule = null; try { scrParStatusRule = script.getScrParStatusRule(); } catch (FieldNotInitializedException e) { } String scrParStatus = null; try { scrParStatus = script.getScrParStatus(); } catch (FieldNotInitializedException e) { } scriptLabel = script.getScrLabel(); DecimalFormat df = FlLocale.getInstance(session).getDecimalFormat("0000"); scriptNumber = df.format((long) (script.getScrSeqNum())); String perCompleteName = (person == null) ? Utils.getMessage(session, "L620E", "") : person.toString(); LinkedHashMap statusParIDAndDisplay = new LinkedHashMap(); //IF THIS IS THE LAST SCRIPT ELEMENT, WE'LL BE SHOWING THE EVENT STATUS CHOICES boolean askForParStatus = false; if (lsePosition == scriptElements.size() - 1) { String[][] queryPvt = {{"PvtEventID = " + Utils.formatToSQL(context, scriptEventID) , "PvtPersonID = " + Utils.formatToSQL(context, perID)}}; String[] fieldsPvt = {"PvtID"}; Vector listPvt = PersonEventBean.listSummary(session, fieldsPvt, queryPvt); //On regarde si on doit poser la question de l'état pour l'evenement if (scrParStatusRule == null || "NONE".equals(dico.getRefCode("ScrParStatusRule" , scrParStatusRule)) ) { if (listPvt == null || listPvt.size() == 0) { askForParStatus = true; } } else if ( "MANU".equals(dico.getRefCode("ScrParStatusRule" , scrParStatusRule)) ) { askForParStatus = true; } if (askForParStatus) { statusParIDAndDisplay = EventHelper.getListStatusByEvent(context, StatusType.PARTICIPATION, scriptEventID); } } //IF WE ALREADY KNOW THIS PERSON'S ANSWERS TO THIS QUESTION, WE WANT TO PRESELECT THEM Vector scriptElementResponses = new Vector(); String[][] querySer = {{"SerSrpID:SrpScriptID = " + Utils.formatToSQL(context, scriptID), "SerSrpID:SrpPersonID = " + Utils.formatToSQL(context, perID), "SerLseID = " + Utils.formatToSQL(context, linkScriptElement.getLseID())}}; scriptElementResponses = ScriptElementResponseBean.list(session, querySer); boolean hasNotes = "true".equals(flRequest.getRequestParameterOrAttribute("hasNotes")); %> <%= scriptLabel %>
"> <%-- DISPLAY NAVIGATION BAR --%>
    <% if (lsePosition != scriptElements.size() -1) { %> <% } else { %> <% } %>  
<%-- HEADER --%>
<% //IF THIS IS NOT A PREVIEW, SHOW A LINK TO THE PERSON if (perID != null) { %> <%= perCompleteName %> <% } else { %> <%= perCompleteName %> <% } %>
<%= scriptLabel %> (<%= scriptNumber %>)
<%-- END OF HEADER --%>
<%-- HIDDEN FORM FIELDS --%> <% if (scriptElement != null && linkScriptElement != null) { %> <% } %> <%-- Current element index --%> <% for (int i=0 ; i <%-- Here we write down all the JSP Pages for all the script elements so we can get them when we want to change elements --%> <% } %> <%----%> <%-- Next element requested index --%> "> <% if (scriptElement != null) { String qLabel = null; try { qLabel = scriptElement.getSceLabel(); } catch (FieldNotInitializedException fnie) { } String qDescription = null; try { qDescription = Utils.formatToWeb(scriptElement.getSceDescription(), false); } catch (FieldNotInitializedException fnie) { } // remplacement de $$actor$$ et $$person$$ if (qDescription != null) { qDescription = Utils.replace(qDescription, "$$person$$", perCompleteName); qDescription = Utils.replace(qDescription, "$$actor$$", actCompleteName); } /* String qComment = null; try { qComment = Utils.formatToWeb((String)scriptElement.getCustomProperty("SceComment_"), false); } catch (FieldNotInitializedException fnie) { } // remplacement de $$actor$$ et $$person$$ if (qComment != null) { qComment = Utils.replace(qComment, "$$person$$", perCompleteName); qComment = Utils.replace(qComment, "$$actor$$", actCompleteName); } */ //IMAGE String picID = null; try { picID = scriptElement.getSceImage(); } catch (FieldNotInitializedException ex) {} %> <%-- DISPLAY SCRIPT ELEMENT LABEL --%> <%-- DISPLAY SCRIPT ELEMENT IMAGE IF ANY --%> <% if (picID != null) { %> <% } %> <%-- DISPLAY SCRIPT ELEMENT DESCRIPTION --%> <%-- DISPLAY SCRIPT ELEMENT COMMENT IF ANY --%> <%-- <% if (qComment != null) { %> <% } %> --%> <%-- DISPLAY SCRIPT ELEMENT ANSWERS --%> <% if (scriptElement.getSceHasAnswers() == 1) { String qType = null; try { qType = scriptElement.getSceType(); } catch (FieldNotInitializedException fnie) { } //if text libre if ( qType == null || qType.equals(dico.getRefIdByCode("SceType" , "FRE")) ) { int inputSize = 0; try { inputSize = scriptElement.getSceInputSize(); } catch (FieldNotInitializedException fnie) { } String value = ""; if (scriptElementResponses.size() > 0) { try { value = ((ScriptElementResponseBean)scriptElementResponses.elementAt(0)).getSerText(); } catch (FieldNotInitializedException e) {} } if (inputSize == -1) { %> <%----%> <% } else { %> <%----%> <% } } else { //Pas Texte libre, c-a-d REF ou LST boolean isREF = false; boolean isLST = false; if ( qType.equals(dico.getRefIdByCode("SceType" , "REF")) ) { isREF = true; } if ( qType.equals(dico.getRefIdByCode("SceType" , "LST")) ) { isLST = true; } boolean isCombo = true; boolean isRadio = false; boolean isCheck = false; String dispType = null; try { dispType = scriptElement.getSceDispType(); } catch (FieldNotInitializedException fnie) { } if (dispType != null && dispType.equals(dico.getRefIdByCode("SceDispType", "RADIO"))) { isCombo = false; isRadio = true; } if (dispType != null && dispType.equals(dico.getRefIdByCode("SceDispType", "CHECK"))) { isCombo = false; isCheck = true; } int complementaryText = 0; try { complementaryText = scriptElement.getSceAssociatedText(); } catch (FieldNotInitializedException fnie) { } int nbColumn = 1; try { nbColumn = scriptElement.getSceColumnsNb(); } catch (FieldNotInitializedException fnie) { } int hasOther = 0; try { hasOther = scriptElement.getSceHasOther(); } catch (FieldNotInitializedException fnie) { } String refTableID = null; try { refTableID = scriptElement.getSceRefTable(); } catch (FieldNotInitializedException fnie) { } Vector possibleResponses = new Vector(); Vector recordedResponses = new Vector(); //in this vector we will store the responses from scriptElementResponses that we have Hashtable complementaryTexts = new Hashtable(); //in this hashtable we will store the complementary texts that we have if ( isLST ) { for (int j = 0 ; j < 15 ; j++) { String lstAnswer = null; try { Method getter = Class.forName("com.edeal.frontline.ScriptElementBean").getMethod("getSceLstAnswer" + j , null); lstAnswer = (String) getter.invoke(scriptElement , null); } catch (Exception e) { } if (lstAnswer != null) { Vector oneResponse = new Vector(); oneResponse.add(Integer.toString(j)); oneResponse.add(lstAnswer); possibleResponses.add(oneResponse); } } for (int k = 0 ; k < scriptElementResponses.size() ; k++) { try { String choice = new Integer(((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerPosition()).toString(); recordedResponses.addElement(choice); if(choice.equals("0")) { Integer choiceInt = new Integer(choice); int temp = choiceInt.intValue(); temp++; choice = choice.valueOf(temp); } complementaryTexts.put(choice, ((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerMoreText()); } catch (FieldNotInitializedException e) {} } } else { try { possibleResponses = dico.getRefList(session, refTableID , "Te1"); } catch (FrontlineException fe) { logger.error("DBG: dico.getRefList a lancé une exception : " + fe.getMessage()); } for (int k = 0 ; k < scriptElementResponses.size() ; k++) { try { String choice = ((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerRefValID(); recordedResponses.addElement(choice); if(choice.equals("0")) { Integer choiceInt = new Integer(choice); int temp = choiceInt.intValue(); temp++; choice = choice.valueOf(temp); } complementaryTexts.put(choice, ((ScriptElementResponseBean)scriptElementResponses.elementAt(k)).getSerMoreText()); } catch (FieldNotInitializedException e) {} } } if (isCombo) { %> <% } else { // pas combo , c-a-d checkbox ou radio String tagType = "checkbox"; if (isRadio) { tagType = "radio"; } %> <% } }//end of if (texte libre) }//end of if (scriptElement.getSceHasAnswers() == 1) %><%-- END OF DISPLAY SCRIPT ELEMENT ANSWERS --%><% }//end of if (scriptelement != null) %>
<%= qLabel == null ? " " : qLabel %>
<fl:getMessage code=">
 
<%= qDescription == null ? " " : qDescription %>
<%= qComment == null ? " " : qComment %>
">
<% if (complementaryText > 0) { String compText = (String)complementaryTexts.get(responseChoice); %> " size="<%= Integer.toString(complementaryText) %>"> <% } %>
<% int nbResByColumn = possibleResponses.size() / nbColumn; if ( nbColumn * nbResByColumn < possibleResponses.size() ) { nbResByColumn++; } int cptPossibleResponse = 0; for (int j = 0 ; j < possibleResponses.size() ; j++) { String responseChoice = (String) ((Vector) possibleResponses.elementAt(j)).elementAt(0); String responseLabel = (String) ((Vector) possibleResponses.elementAt(j)).elementAt(1); if (cptPossibleResponse % nbResByColumn == 0) { if (cptPossibleResponse > 0) { %> <% } %>
" value="<%= responseChoice %>"<%= recordedResponses.contains(responseChoice) ? " checked" : ""%>><%= responseLabel %> <% } else { %>
" value="<%= responseChoice %>"<%= recordedResponses.contains(responseChoice) ? " checked" : ""%>><%= responseLabel %> <% } if ( (complementaryText > 0) || (hasOther > 0 && j == possibleResponses.size() - 1) ) { String compText = (String)complementaryTexts.get(responseChoice); %> " size="<%= complementaryText > 0 ? Integer.toString(complementaryText) : Integer.toString(hasOther) %>"> <% } cptPossibleResponse++; } %>
<%-- IF THIS IS THE LAST ELEMENT, WE MAY WANT TO SHOW THE EVENT STATUS SECTION --%> <% if (lsePosition == scriptElements.size() - 1) { %> <%-- EVENT STATUS SECTION --%> <% if (askForParStatus) { %>
<% if (statusParIDAndDisplay != null && !statusParIDAndDisplay.isEmpty()) { Iterator iter = statusParIDAndDisplay.keySet().iterator(); while (iter.hasNext()) { String currStatusID = iter.next(); String currStatusDisplay = statusParIDAndDisplay.get(currStatusID); %> ><%= currStatusDisplay %> <% } } } else if ( scrParStatusRule != null && "AUTO".equals(dico.getRefCode("ScrParStatusRule" , scrParStatusRule)) ) { %>
"> <% } %>
<%-- END OF EVENT STATUS SECTION --%> <% } %> <%-- OBJECTIONS / ARGUMENTS --%> <% if (scriptElement != null && scriptElement.getID() != null) { String[][] query = {{"LsoScriptElementID = " + Utils.formatToSQL(context, scriptElement.getID())}}; String[] fields = {"LsoID" , "LsoObjectionID" , "LsoObjectionID:ObaObjection", "LsoPosition"}; String[] orderBy = {"LsoPosition"}; Vector linksList = LinkScriptElementObjectionBean.listSummary(session , fields, query, orderBy); //if there are links to objections if (linksList != null && linksList.size() > 0) { %>
 
 
<% //for each objection for (int i=0 ; i < linksList.size() ; i++) { Hashtable curLink = (Hashtable) linksList.elementAt(i); String curLsoObjectionID = (String) curLink.get("LsoObjectionID"); String obaObjection = (String) curLink.get("LsoObjectionID:ObaObjection"); %><%= obaObjection %>
<% } %>
 
<% }//end of if there are links to objections }//end of if there is a script element %><%-- END OF OBJECTIONS / ARGUMENTS --%><% if (scriptElement == null) { %><% } %> <%-- PROGRESS BAR --%>
<%-- END OF PROGRESS BAR --%>

<%if (hasNotes){ String noteJspPage= "notes.jsp"; String sceJSPID = ((ScriptElementBean)scriptElements.elementAt(0)).getSceJSPPage(); if (sceJSPID != null && !sceJSPID.equals(dico.getRefIdByCode("SceJSPPage", "DEFAULT"))) { noteJspPage= (String)dico.getRefDisp(session, "Pjs", "Te3", sceJSPID); //otherwise ask the script which JSP page to use } else { noteJspPage= (String)dico.getRefDisp(session, "Pjs", "Te3", script.getScrJSPPage()); } %>
<%}%>