%/******************************************************************************
* 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 pageEncoding="UTF-8" session="true" import="com.edeal.frontline.*,java.util.*,java.io.*"%>
<%@ page import="com.edeal.frontline.HistoryBean" %>
<%@ page import="com.edeal.frontline.FieldNotInitializedException" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<%
final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass());
String contextPath = (String) session.getAttribute("contextPath");
FlContext context = null;
if (contextPath!=null) {
context = Frontline.getContext(contextPath);
} else {
context = Frontline.getContext(request.getContextPath());
}
DataDictionary dico = context.getDataDictionary();
String id = Utils.getRequestParameter(context, request, "id");
int nb = 0;
String strNb = Utils.getRequestParameter(context, request, "nb");
if (strNb != null && !"".equals(strNb)) {
try {
nb = Integer.parseInt(strNb);
} catch (NumberFormatException nfe) {
}
}
//boolean isPopup = Utils.getRequestParameter(context, request, "popup") != null;
String[] objFields = {"HisID", "HisDate", "HisActID", "HisPerID", "HisJouID", "HisSilID", "HisActID:ActFstName", "HisActID:ActName", "HisPerID:PerFstName", "HisPerID:PerName", "HisPerID:PerEntID", "HisPerID:PerEntID:EntCorpName", "HisJouID:JouFstName", "HisJouID:JouName", "HisSilID:SilFstName", "HisSilID:SilName", "HisCrDt"};
String[][] objQuery = {{"HisType = " + HistoryBean.OBJECT_UPDATE_LOG, "HisObjectID = " + Utils.formatToSQL(context, id)}};
String[] objOrderBy = {"HisDate DESC"};
Vector objList = HistoryBean.listSummary(context, objFields, objQuery, objOrderBy, 0, nb);
//if (isPopup) {
%>
<%
//}
//if (!isPopup) {
%>
<%
//}
//if (isPopup) {
%>
">
<%
//}
if (objList != null && !objList.isEmpty()) {
StringBuffer parents = new StringBuffer();
for (int i = 0; i < objList.size(); i++) {
Hashtable row = (Hashtable)objList.elementAt(i);
if (parents.length() > 0) {
parents.append(", ");
}
parents.append(Utils.formatToSQL(context, (String)row.get("HisID")));
}
String[] fldFields = {"HisName", "HisDataType", "HisParentID",
"HisOldTextValue", "HisNewTextValue",
"HisOldFobValue", "HisNewFobValue",
"HisOldRefValue", "HisNewRefValue",
"HisOldLongTextValue", "HisNewLongTextValue",
"HisOldDateTimeValue", "HisNewDateTimeValue",
"HisOldIntValue", "HisNewIntValue",
"HisOldFloatValue", "HisNewFloatValue",
"HisOldMvaTextValue", "HisNewMvaTextValue",
"HisOldMvaDateTimeValue", "HisNewMvaDateTimeValue",
"HisOldMvaIntValue", "HisNewMvaIntValue",
"HisOldMvaFloatValue", "HisNewMvaFloatValue", "HisCrDt"
};
String[][] fldQuery = {{"HisType = " + HistoryBean.FIELD_UPDATE_LOG, "HisParentID in (" + parents.toString() + ")", "HisObjectID = " + Utils.formatToSQL(context, id)}};
String[] fldOrderBy = {"HisName"};
Vector fldList = HistoryBean.listSummary(context, fldFields, fldQuery, fldOrderBy);
Hashtable fieldModifications = new Hashtable();
if (fldList != null) {
for (int i = 0; i < fldList.size(); i++) {
Hashtable row = (Hashtable)fldList.elementAt(i);
String parentID = (String)row.get("HisParentID");
if (parentID != null) {
Vector v = (Vector)fieldModifications.get(parentID);
if (v == null) {
v = new Vector();
fieldModifications.put(parentID, v);
}
v.addElement(row);
}
}
}
%>
<%
for (int i = 0; i < objList.size(); i++) {
Hashtable row = (Hashtable)objList.elementAt(i);
String hisID = (String)row.get("HisID");
Date date = (Date)row.get("HisDate");
String actID = (String)row.get("HisActID");
String actFstName = (String)row.get("HisActID:ActFstName");
String actName = (String)row.get("HisActID:ActName");
String perID = (String)row.get("HisPerID");
String perFstName = (String)row.get("HisPerID:PerFstName");
String perName = (String)row.get("HisPerID:PerName");
String entID = (String)row.get("HisPerID:PerEntID");
String entCorpName = (String)row.get("HisPerID:PerEntID:EntCorpName");
String jouID = (String)row.get("HisJouID");
String jouFstName = (String)row.get("HisJouID:JouFstName");
String jouName = (String)row.get("HisJouID:JouName");
String silID = (String)row.get("HisSilID");
String silFstName = (String)row.get("HisSilID:SilFstName");
String silName = (String)row.get("HisSilID:SilName");
String modifierID = null;
String modifierName = null;
String modifierType = null;
String modifierGroupID = null;
String modifierGroupName = null;
String modifierGroupType = null;
Date dateCrDt = (Date)row.get("HisCrDt");
if (perID != null) {
modifierID = perID;
modifierType = "person";
modifierGroupName = "enterprise";
modifierName = (perFstName != null ? perFstName + " " : "") + (perName != null ? perName : "");
modifierGroupID = entID;
modifierGroupName = entCorpName;
} else if (jouID != null) {
modifierID = jouID;
modifierType = "journalist";
modifierName = (jouFstName != null ? jouFstName + " " : "") + (jouName != null ? jouName : "");
} else if (silID != null) {
modifierID = silID;
modifierType = "silhouette";
modifierName = (silFstName != null ? silFstName + " " : "") + (silName != null ? silName : "");
} else {
modifierID = actID;
modifierType = "actor";
modifierName = (actFstName != null ? actFstName + " " : "") + (actName != null ? actName : "");
}
boolean isActorSpecial=false;
if ("actor".equals(modifierType)) {
isActorSpecial=context.getSystemID().equals(modifierID) || context.getAnonymousID().equals(modifierID);
}
HistoryBean his = new HistoryBean(hisID, context);
%>
<%= Utils.formatToWeb(date, false) %>
<% if (isActorSpecial) { %>
<%= Utils.formatToWeb(modifierName, false) %>
<% } else { %>
<%= Utils.formatToWeb(modifierName, false) %>
<% } %>
<% if (modifierGroupID != null) {
if (isActorSpecial) { %>
<%= Utils.formatToWeb(modifierGroupName, false) %>
<% } else { %>
<%= Utils.formatToWeb(modifierGroupName, false) %>
<% }
}
%>
|
<%
Vector fields = (Vector)fieldModifications.get(hisID);
if (fields != null) {
for (int j = 0; j < fields.size(); j++) {
Hashtable modif = (Hashtable)fields.elementAt(j);
String name = (String) modif.get("HisName");
String type = (String)modif.get("HisDataType");
FieldBean field = dico.getFieldByName(name);
String fieldName = null;
try {
//fieldName = Utils.getMessage(session, field.getFldDisplayLabel(), ""); // is doing silently a format to web, so when we format to web again in the lines below, there can be a problem.
fieldName = Utils.getMessage(session, field.getFldDisplayLabel(), false, true, "");
} catch (FieldNotInitializedException fnie) {
}
if (fieldName == null || "".equals(fieldName)) {
try {
fieldName = Utils.formatToWeb(field.getFldDisplay(), false);
} catch (FieldNotInitializedException fnie) {
}
}
if (fieldName == null || "".equals(fieldName)) {
fieldName = Utils.formatToWeb(name, false);
}
String oldValue = null;
String newValue = null;
if (field.isFldMultival()) {
if (field.isFob() || field.isRef() || field.isString()) {
Vector oldValues = (Vector)modif.get("HisOldMvaTextValue");
Vector newValues = (Vector)modif.get("HisNewMvaTextValue");
if (oldValues != null) {
Vector v = new Vector();
for (Iterator iter = oldValues.iterator(); iter.hasNext();) {
String element = (String)iter.next();
if (element != null) {
if (field.isRef()) {
v.addElement(dico.getRefDisp(session, name, element));
} else if (field.isFob()) {
ObjectsBean fobBean = dico.getTable("id", field.getFldFobID());
String fob = fobBean.toString(session, element);
if (fob == null || "".equals(fob)) {
fob = "--?--";
}
v.addElement(fob);
} else {
v.addElement(element);
}
}
}
StringBuffer buf = new StringBuffer();
for (Iterator iter = v.iterator(); iter.hasNext();) {
String element = (String)iter.next();
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(element);
}
oldValue = buf.toString();
}
if (newValues != null) {
Vector v = new Vector();
for (Iterator iter = newValues.iterator(); iter.hasNext();) {
String element = (String)iter.next();
if (element != null) {
if (field.isRef()) {
v.addElement(dico.getRefDisp(session, name, element));
} else if (field.isFob()) {
ObjectsBean fobBean = dico.getTable("id", field.getFldFobID());
String fob = fobBean.toString(session, element);
if (fob == null || "".equals(fob)) {
fob = "--?--";
}
v.addElement(fob);
} else {
v.addElement(element);
}
}
}
StringBuffer buf = new StringBuffer();
for (Iterator iter = v.iterator(); iter.hasNext();) {
String element = (String)iter.next();
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(element);
}
newValue = buf.toString();
}
} else if (field.isBoolean()) {
Vector oldValues = (Vector)modif.get("HisOldMvaIntValue");
if (oldValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = oldValues.iterator(); iter.hasNext();) {
Number element = (Number)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
if (element.intValue() == 1) {
buf.append(Utils.getMessage(session, "L2005", "Oui"));
} else {
buf.append(Utils.getMessage(session, "L2006", "Non"));
}
}
}
oldValue = buf.toString();
}
Vector newValues = (Vector)modif.get("HisNewMvaIntValue");
if (newValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = newValues.iterator(); iter.hasNext();) {
Number element = (Number)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
if (element.intValue() == 1) {
buf.append(Utils.getMessage(session, "L2005", "Oui"));
} else {
buf.append(Utils.getMessage(session, "L2006", "Non"));
}
}
}
newValue = buf.toString();
}
} else if (field.isInteger() || field.isByte() || field.isLong() || field.isShort()) {
Vector oldValues = (Vector)modif.get("HisOldMvaIntValue");
if (oldValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = oldValues.iterator(); iter.hasNext();) {
Number element = (Number)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(FlLocale.getInstance(session).getDecimalFormat("#,###").format(element.longValue()));
}
}
oldValue = buf.toString();
}
Vector newValues = (Vector)modif.get("HisNewMvaIntValue");
if (newValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = newValues.iterator(); iter.hasNext();) {
Number element = (Number)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(FlLocale.getInstance(session).getDecimalFormat("#,###").format(element.longValue()));
}
}
newValue = buf.toString();
}
} else if (field.isFloat() || field.isDouble()) {
Vector oldValues = (Vector)modif.get("HisOldMvaFloatValue");
if (oldValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = oldValues.iterator(); iter.hasNext();) {
Number element = (Number)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(FlLocale.getInstance(session).getDecimalFormat().format(element.doubleValue()));
}
}
oldValue = buf.toString();
}
Vector newValues = (Vector)modif.get("HisNewMvaFloatValue");
if (newValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = newValues.iterator(); iter.hasNext();) {
Number element = (Number)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(FlLocale.getInstance(session).getDecimalFormat().format(element.doubleValue()));
}
}
newValue = buf.toString();
}
} else if (field.isDate() || field.isDateTime() || field.isTime()) {
SimpleDateFormat sdf = FlLocale.getInstance(session).getDateTimeFormat();
if (field.isTime()) {
sdf = FlLocale.getInstance(session).getTimeFormat();
}else if(field.isDateTime()){
sdf = FlLocale.getInstance(session).getDateTimeFormat();
}else if (field.isDate()) {
sdf = FlLocale.getInstance(session).getDateFormat();
}
Vector oldValues = (Vector)modif.get("HisOldMvaDateTimeValue");
if (oldValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = oldValues.iterator(); iter.hasNext();) {
Date element = (Date)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
if (element != null) {
buf.append(sdf.format(element));
}
}
}
oldValue = buf.toString();
}
Vector newValues = (Vector)modif.get("HisNewMvaDateTimeValue");
if (newValues != null) {
Vector v = new Vector();
StringBuffer buf = new StringBuffer();
for (Iterator iter = newValues.iterator(); iter.hasNext();) {
Date element = (Date)iter.next();
if (element != null) {
if (buf.length() > 0) {
buf.append("\n");
}
buf.append(sdf.format(element));
}
}
newValue = buf.toString();
}
}
} else {
if (field.isRef()) {
Object objOldValue = modif.get("HisOldRefValue");
if (objOldValue != null) {
objOldValue = dico.getRefDisp(session, name, objOldValue.toString());
}
Object objNewValue = modif.get("HisNewRefValue");
if (objNewValue != null) {
objNewValue = dico.getRefDisp(session, name, objNewValue.toString());
}
oldValue=(objOldValue==null)?"":objOldValue.toString();
newValue=(objNewValue==null)?"":objNewValue.toString();
} else if (field.isFob()) {
try {
ObjectsBean fobBean = dico.getTable("id", field.getFldFobID());
oldValue = (String)modif.get("HisOldFobValue");
if (oldValue != null) {
oldValue = fobBean.toString(session, oldValue);
if (oldValue == null || "".equals(oldValue)) {
oldValue = "--?--";
}
}
newValue = (String)modif.get("HisNewFobValue");
if (newValue != null) {
newValue = fobBean.toString(session, newValue);
if (newValue == null || "".equals(newValue)) {
newValue = "--?--";
}
}
} catch (FieldNotInitializedException fnie) {
}
} else if (field.isString()) {
oldValue = (String)modif.get("HisOldTextValue");
newValue = (String)modif.get("HisNewTextValue");
if (oldValue == null && newValue == null) {
oldValue = (String)modif.get("HisOldLongTextValue");
newValue = (String)modif.get("HisNewLongTextValue");
}
} else if (field.isBoolean()) {
Number nOldValue = (Number)modif.get("HisOldIntValue");
if (nOldValue != null) {
if (nOldValue.intValue() == 1) {
oldValue = Utils.getMessage(session, "L2005", "Oui");
} else {
oldValue = Utils.getMessage(session, "L2006", "Non");
}
}
Number nNewValue = (Number)modif.get("HisNewIntValue");
if (nNewValue != null) {
if (nNewValue.intValue() == 1) {
newValue = Utils.getMessage(session, "L2005", "Oui");
} else {
newValue = Utils.getMessage(session, "L2006", "Non");
}
}
} else if (field.isInteger() || field.isByte() || field.isLong() || field.isShort()) {
Number nOldValue = (Number)modif.get("HisOldIntValue");
if (nOldValue != null) {
oldValue = FlLocale.getInstance(session).getDecimalFormat("#,###").format(nOldValue.longValue());
}
Number nNewValue = (Number)modif.get("HisNewIntValue");
if (nNewValue != null) {
newValue = FlLocale.getInstance(session).getDecimalFormat("#,###").format(nNewValue.longValue());
}
} else if (field.isFloat() || field.isDouble()) {
Number nOldValue = (Number)modif.get("HisOldFloatValue");
if (nOldValue != null) {
oldValue = FlLocale.getInstance(session).getDecimalFormat().format(nOldValue.doubleValue());
}
Number nNewValue = (Number)modif.get("HisNewFloatValue");
if (nNewValue != null) {
newValue = FlLocale.getInstance(session).getDecimalFormat().format(nNewValue.doubleValue());
}
} else if (field.isDate() || field.isDateTime() || field.isTime()) {
Date dOldValue = (Date)modif.get("HisOldDateTimeValue");
SimpleDateFormat sdf = FlLocale.getInstance(session).getDateTimeFormat();
if (field.isTime()) {
sdf = FlLocale.getInstance(session).getTimeFormat(false);
}else if(field.isDateTime()){
sdf = FlLocale.getInstance(session).getDateTimeFormat(false);
}else if (field.isDate()) {
sdf = FlLocale.getInstance(session).getDateFormat();
}
if (dOldValue != null) {
oldValue = sdf.format(dOldValue);
}
Date dNewValue = (Date)modif.get("HisNewDateTimeValue");
if (dNewValue != null) {
newValue = sdf.format(dNewValue);
}
}
}
fieldName = Utils.formatToWeb(session, fieldName, false);
oldValue = Utils.formatToWeb(session, oldValue, false);
newValue = Utils.formatToWeb(session, newValue, false);
%>
<%= fieldName %> |
<%= oldValue != null ? oldValue : " " %> |
|
<%= newValue != null ? newValue : " " %> |
<% }
}
}
%>
<%
}
%>
|
<%
/******************************************************************************
* CVS Log File - This is no longer maintained!
*
* Revision 1.1 2004/07/23 18:20:21 brian
* Initial Revision
*
*****************************************************************************/
%>