<% /****************************************************************************** * 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.*,com.edeal.frontline.navigation.FlRequest,java.util.*"%> <%@ page import="com.edeal.frontline.Criteria2Bean" %> <%@ page import="com.edeal.frontline.FieldNotInitializedException" %> <%@page import="com.edeal.frontline.display.TargettingFieldInterfaceManager"%> <%@page import="com.edeal.frontline.display.TargettingFieldInterface"%> <%@page import="com.edeal.frontline.helper.*"%><%@page import="com.edeal.frontline.helper.custom.*"%> <%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %> <% //recuperation du contexte final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); String contextPath = (String)session.getAttribute("contextPath"); if(contextPath == null) { contextPath = request.getContextPath(); } FlContext context = Frontline.getContext(contextPath); DataDictionary dico = context.getDataDictionary(); FlRequest flRequest=new FlRequest(request); String paramID = Utils.getRequestParameter(context, request, "id"); String paramNode = Utils.getRequestParameter(context, request, "Node"); String paramEdit = Utils.getRequestParameter(context, request, "Edit"); String paramTemplate = (String) session.getAttribute("idPattern"); String paramSe2ID = Utils.getRequestParameter(context, request, "SelID"); Criteria2Bean obj = new Criteria2Bean(paramID, session); Criteria2Helper criteriaHelper=BasicHelper.factory(obj); String Cr2Se2 = null; try { Cr2Se2 = obj.getCr2Se2ID(); }catch(FieldNotInitializedException ex) {} Selection2Bean se2Bean = new Selection2Bean(); try { se2Bean = new Selection2Bean(Cr2Se2, session); } catch (FrontlineException fe) { logger.warn("FrontlineException occured while creating a new Selection2Bean."); logger.warn("Message: " + fe.getMessage()); logger.warn("Cause: " + fe.getCause()); } catch (AccessDeniedException ade) { logger.warn("AccessDeniedException occured while creating a new Selection2Bean."); logger.warn("Message: " + ade.getMessage()); logger.warn("Cause: " + ade.getCause()); } int Cond =0; try { Cond = se2Bean.getSe2Condition(); }catch(FieldNotInitializedException ex) {} boolean isSelection = false; boolean isHole =false; String Belong="Belong"; String ParamBelong = Utils.getRequestParameter(context, request, "Belong"); boolean isBelong = ParamBelong != null; boolean isEdit = false; if(paramEdit == null) { paramEdit = "0"; isEdit = false; } else { isEdit = "1".equals(paramEdit); } // Template Display Processing String Cr2Condition = null ; try { Cr2Condition = obj.getCr2Condition(); }catch(FieldNotInitializedException ex) {} // c'est liée à une condition type String se2OldID = null ; try { se2OldID = obj.getCr2Se2IDold(); }catch(FieldNotInitializedException ex) {} String condName = null; //faut aussi voir le cas si le parent est un lien vers condition type if (Cond == 0 && Cr2Condition != null) { isSelection = true; Selection2Bean seBean = new Selection2Bean(Cr2Condition, session); try { condName = seBean.getSe2Name(); } catch(FieldNotInitializedException ex) { } } boolean trou = false; try { trou = obj.isCr2IsTemplate(); }catch(FieldNotInitializedException ex) {} if(trou && Cond==0){ isHole = true; } String object = null; String objectDisplay = null; try { object = obj.getCr2FobID(); }catch(FieldNotInitializedException ex) {} if (object != null){ //[JSA].rather display the alias instead of the objectname. If not possible, use the former method try { // JSA: rather display the alias instead of the objectname objectDisplay = Utils.getMessage(session,obj.getCr2TempName(),obj.getCr2TempName()); } catch(FieldNotInitializedException ex) {} try { if (objectDisplay==null) { // if no display, then use the data dictionnary objectDisplay = (new ObjectsBean(object,context)).getObjDisplay(); } } catch(FieldNotInitializedException ex) { objectDisplay=Utils.getMessage(session, "L60E0", ""); } } // is Agraggate Node //******************************* boolean IsAgraggate= false; String CardOpe = null; try { CardOpe = obj.getCr2CardOpe(); } catch(FieldNotInitializedException ex) {} if (CardOpe != null) { IsAgraggate=true; } String AgraggateLabel = ""; try { AgraggateLabel = obj.getCr2CardLabel(); } catch (FieldNotInitializedException e) {} String _Label = Utils.getMessage(session, AgraggateLabel, Utils.getMessage(session, "L60E0", "")); //************************************ // a Child of a Agraggate Node // ******************************** boolean IsAgraggateChild = false; String Parent = null; String CardOp = null; try { Parent = obj.getCr2ParentID(); } catch (FieldNotInitializedException e) {} try { CardOp = obj.getCr2FldID(); } catch (FieldNotInitializedException e) {} if (Parent != null) { Criteria2Bean objParent = new Criteria2Bean(Parent, session); Criteria2Helper objParentHlpr=BasicHelper.factory(objParent); String CardParent = null ; Vector objChildren= objParentHlpr.getChildren(); try { CardParent = objParent.getCr2CardOpe(); } catch (FieldNotInitializedException e) {} if(CardParent != null ) { if( CardOp == null && (objChildren.size()>1)) { /* try { // obj.delete(); } catch (AccessDeniedException e) {}*/ } IsAgraggateChild = true; } } // is Template //************************************** boolean type =false; String label =""; String Field = null; try { Field = obj.getCr2FldID(); } catch (FieldNotInitializedException ex){} try { label = obj.getCr2TempName(); } catch (FieldNotInitializedException ex){} try { type = obj.isCr2IsTemplate(); } catch (FieldNotInitializedException ex){} //******************************************************** boolean isValueNeeded = true; try { String strOpeID = obj.getCr2Ope(); isValueNeeded = !"exist".equals(dico.getRefCode("Cr2Ope", strOpeID)); } catch (FieldNotInitializedException ex) { } %> <% Vector children = new Vector(); children = criteriaHelper.getChildren(); //c'est un noeud d'agregat dans une condition type if ((IsAgraggate && !type) || (IsAgraggate && Cond == 1)){ if (isBelong){ if(children != null && children.size() > 0) { for(int i = 0; i < children.size(); i++) { String childID = (String)children.elementAt(i); request.setAttribute("Criteria2", new Criteria2Bean(childID, session)); %> <% String valueV1 = paramNode + "." + i; %> <% } } }else { //else de isBelong %> <% }//fin du else de isBelong %> <% } else if(isSelection) { //else if du c'est un noeud d'agregat : cette fois ci c'est une condition type isBelong = true; %> <% if(children != null && children.size() > 0 ) { for(int i = 0; i < children.size(); i++) { String childID = (String)children.elementAt(i); request.setAttribute("Criteria2", new Criteria2Bean(childID, session)); if (!isBelong){ %> <%= i == 0 ? "" : (obj.isCr2And() ? Utils.getMessage(session, "L604B", "et") : Utils.getMessage(session, "L604C", "ou")) %>
<% } %> <% String valueV3 = paramNode + "." + i; %> <% } %> <%-- The following table is to correct a visual bug.... It's a hack and it's ugly but it works --%>
<% if(isEdit) { %><% } else { %> <% } %>
<% if(type && Cond != 0) { String label1 = Utils.getMessage(session, label, Utils.getMessage(session, "L60E0", "")); if(isEdit) { %> <%=_Label%>  <% } else { %><%=_Label%><% } %>     <%=label1%> <% } else { if(isEdit) { %> <%=_Label%>  <% } else { %><%=_Label%><% } %>    <% } %>
<% if(children != null && children.size() > 0) { for(int i = 0; i < children.size(); i++) { String childID = (String)children.elementAt(i); request.setAttribute("Criteria2", new Criteria2Bean(childID, session)); %> <%= i == 0 ? "" : (obj.isCr2And() ? Utils.getMessage(session, "L604B", "et") : Utils.getMessage(session, "L604C", "ou")) %>
<% String valueV2 = paramNode + "." + i; %> <% } } %> <% if(isEdit) { %><% } else { %> <% } %>
<% if(isEdit) { %><% } else { %> <% } %>
<% String[] fieldS = {"Cr2ID"}; String[][] querySEdit = {{"Cr2Se2ID = "+Utils.formatToSQL(context, Cr2Se2),"Cr2CardOpe = null", "Cr2TempName <> null"}}; String[] fieldA={"Cr2ID"}; String[][] queryAEdit={{"Cr2Se2ID = "+Utils.formatToSQL(context, Cr2Se2), "Cr2Ope = null", "Cr2TempName <> null"}}; Vector listA = Criteria2Bean.listSummary(session, fieldA, queryAEdit); Vector list = Criteria2Bean.listSummary(session, fieldS, querySEdit); Utils.showQuery(fieldS,querySEdit); Utils.showQuery(fieldA,queryAEdit); int h = list.size(); int m=listA.size(); boolean isVisible = true; if (h==0 && m==0){ isVisible = false; } if(isEdit && isVisible) { %><%=condName%><%} else {%><%=condName%><%}%>
<% } %> <% }else if(children != null && children.size() > 0 ) { //else de if condition type donc c'est un critére normal parent //c'est ici que j'ai le probléme car cet agregat a des noeuds donc on les vois pas %> <% request.setAttribute("Criteria2", obj); String Card = null; try{ Card = obj.getCr2CardOpe(); }catch (FieldNotInitializedException ex){} if(Card != null ) { %>
" class="dataValue"><%=_Label%>    
<% } %> <% if(isBelong){ for(int i = 0; i < children.size(); i++) { String childID = (String)children.elementAt(i); request.setAttribute("Criteria2", new Criteria2Bean(childID, session)); %> <% String valueV4 = paramNode + "." + i; %> <% } } else { %> <% if(isEdit) { %><% } else { %> <% } %> <% for(int i = 0; i < children.size(); i++) { String childID = (String)children.elementAt(i); request.setAttribute("Criteria2", new Criteria2Bean(childID, session)); %> <%= i == 0 ? "" : (obj.isCr2And() ? Utils.getMessage(session, "L604B", "et") : Utils.getMessage(session, "L604C", "ou")) %>
<% String valueV5 = paramNode + "." + i; %> <% } %> <% if(isEdit) { %> <% } %> <% } %> <% }else if(isHole){ //fin de voir tous les fils alors c'est un critére à afficher %> <% request.setAttribute("Criteria2", obj); String Card = null; try{ Card = obj.getCr2CardOpe(); }catch (FieldNotInitializedException ex){} if(Card != null ) { %> " class="dataValue"><%=_Label%>     <% } else { %> " class="dataValue"><%if (Field !=null){ %><%}%>   <%=objectDisplay%> <%= obj.isCr2Not() ? Utils.getMessage(session, "L2006", "Non") + " " : "" %> <% String Fld = null ; try { Fld = obj.getCr2FldID(); }catch (FieldNotInitializedException exChx) {} if (Fld != null){ %> <% FieldBean fld = dico.getFieldByID(Fld); Vector vectChx = null; try { vectChx = obj.getCr2Chx(); } catch (FieldNotInitializedException exChx) { vectChx = new Vector(); } Vector vectDisplay = new Vector(); try { //if field is fob String fobID = fld.getFldFobID(); ObjectsBean fob = dico.getTable("id", fobID); if (!vectChx.isEmpty()){ StringTokenizer st = new StringTokenizer((String)vectChx.elementAt(0),";"); while (st.hasMoreTokens()) { vectDisplay.addElement(fob.toString(session, st.nextToken())); } } } catch (FieldNotInitializedException exFob) { try { String refID = fld.getFldTabID(); String fldSql = fld.getFldSql(); for(int i = 0; i < vectChx.size(); i++) { vectDisplay.addElement(dico.getRefDisp(session, fldSql, (String)vectChx.elementAt(i))); } } catch (FieldNotInitializedException exRef) { String fldType = null; try { fldType = dico.getRefCode("FldFltID", fld.getFldFltID()); } catch (FieldNotInitializedException exTyp) {}; if("BIT".equals(fldType)) { for(int i = 0; i < vectChx.size(); i++) { vectDisplay.addElement("1".equals((String)vectChx.elementAt(i)) ? Utils.getMessage(session, "L2005", "Oui") : Utils.getMessage(session, "L2006", "Non")); } } else { vectDisplay = vectChx; } } } for(int i = 0; i < vectDisplay.size(); i++) { Object chxDisplay = vectDisplay.elementAt(i); %> <%=chxDisplay%> 
<% } %> <% } }// } else { //fin du else de is Hole ... if ((!isBelong)){ request.setAttribute("Criteria2", obj); %> <% if(isEdit) { %><% } else { %> <% } %> " style="border:thin solid #e1f0ff;" class="dataValue"><% if(isEdit) { %><% } %><%if (Field !=null){ %><%}%><% if(isEdit) { %><% } %>   <%=objectDisplay%> <%= obj.isCr2Not() ? Utils.getMessage(session, "L2006", "Non") + " " : "" %> <%} } %> <% if(!isBelong){ if(isValueNeeded) { if(type && Cond != 0 && !IsAgraggate) { label = Utils.getMessage(session, label, Utils.getMessage(session, "L60E0", "")); %> <%=label%>  
<%} else if (!IsAgraggate){ String Fld = null ; try { Fld = obj.getCr2FldID(); }catch (FieldNotInitializedException exChx) {} if (Fld != null){ %> <% StringBuffer valueDisplay=new StringBuffer(); FieldBean fld = dico.getFieldByID(Fld); TargettingFieldInterfaceManager tfim=TargettingFieldInterfaceManager.factory(context); String readhtml=null; if (tfim.hasCustomInterface(fld.getFldSql())) { Criteria2Bean criteria=(Criteria2Bean)obj; readhtml=tfim.getHtmlForFieldRead(session,flRequest,fld.getFldSql(),se2Bean,criteria); } if (readhtml!=null) { out.append(readhtml); } else { Vector vectChx = null; try { vectChx = obj.getCr2Chx(); } catch (FieldNotInitializedException exChx) { vectChx = new Vector(); } Vector vectDisplay = new Vector(); try { //if field is fob String fobID = fld.getFldFobID(); ObjectsBean fob = dico.getTable("id", fobID); for(int i = 0; i < vectChx.size(); i++) { String vectChxValue = (String)vectChx.elementAt(i); if("$$CurrentDate$$".equals(vectChxValue)||"$$ActID$$".equals(vectChxValue)){ vectDisplay.addElement(vectChxValue); } else { vectDisplay.addElement(fob.toString(session, vectChxValue)); } } } catch (FieldNotInitializedException exFob) { try { String refID = fld.getFldTabID(); String fldSql = fld.getFldSql(); for(int i = 0; i < vectChx.size(); i++) { vectDisplay.addElement(dico.getRefDisp(session, fldSql, (String)vectChx.elementAt(i))); } } catch (FieldNotInitializedException exRef) { String fldType = null; try { fldType = dico.getRefCode("FldFltID", fld.getFldFltID()); } catch (FieldNotInitializedException exTyp) {}; if("BIT".equals(fldType)) { for(int i = 0; i < vectChx.size(); i++) { vectDisplay.addElement("1".equals(vectChx.elementAt(i)) ? Utils.getMessage(session, "L2005", "Oui") : Utils.getMessage(session, "L2006", "Non")); } } else { vectDisplay = vectChx; } } } for(int i = 0; i < vectDisplay.size(); i++) { Object chxDisplay = vectDisplay.elementAt(i); valueDisplay.append(chxDisplay.toString()+"
"); } } %> <%=valueDisplay.toString()%>   <% } } }else { %>    
<% } } %> <% if ( !isBelong || se2OldID == null || Parent == null) { %> <% } %>