}
public void execute() throws Exception {
XWConnection xwconn = null;
ConnectionManager connectionManager = new ConnectionManager();
ConfBean confBean = null;
String physDoc = MyRequest.getParameter("physDoc", parameterMap);
String titleRule = "";
List<String> confControl = new ArrayList<String>();
confControl.add("docEdit");
confControl.add("valoriControllati");
try {
UserBean userBean = (UserBean) modelMap.get("userBean");
confBean = (ConfBean) modelMap.get("confBean");
WorkFlowBean workFlowBean = (WorkFlowBean) modelMap.get("workFlowBean");
xwconn = connectionManager.getConnection(workFlowBean.getArchive());
XMLBuilder builderDoc = null;
if (physDoc == null || physDoc.equals("") || physDoc.equals("-1")) {
builderDoc = new XMLBuilder("root");
} else {
builderDoc = new XMLBuilder(xwconn.getSingleXMLFromNumDoc(Integer.parseInt(physDoc)), "ISO-8859-1");
}
MultiEditingManager editingManager = new MultiEditingManager(parameterMap, confBean, userBean, workFlowBean);
editingManager.setTheXML(builderDoc);
confBean = editingManager.rewriteMultipleConf(confControl);
int newNrecord = 0;
int relation = 0;
int firstRecord = -1;
if (!(MyRequest.getParameter("relation", parameterMap)).equals("")) {
relation = Integer.parseInt(MyRequest.getParameter("relation", parameterMap));
}
// String theArch = myRequest.getParameter("db");
String pne = workFlowBean.getArchive().getPne();
String dataCompilatoreCMPN = DateUtil.getDataSystem("dd/MM/yyyy");
String nomeCompilatoreCMPN = userBean.getName() + " " + userBean.getLastName();
int relatedPhysDoc = 0;
int elementiMultipli = 0;
if (MyRequest.getParameter("elementiMultipli", parameterMap).equals("")) {
elementiMultipli = 1;
} else {
elementiMultipli = Integer.parseInt(MyRequest.getParameter("elementiMultipli", parameterMap));
}
if (!MyRequest.getParameter("relatedPhysDoc", parameterMap).equals("")) {
relatedPhysDoc = Integer.parseInt(MyRequest.getParameter("relatedPhysDoc", parameterMap));
}
String[] nomiRequest = MyRequest.ordinaRequest(workFlowBean.getRequest(), "." + pne + ".");
// HashMap laMappa = new HashMap();
SharpIncrementTool sharpIncrementTool = new SharpIncrementTool();
for (int cicli = 0; cicli < elementiMultipli; cicli++) {
/* ordino la request e creo l'XML */
XMLBuilder builder = new XMLBuilder(pne);
for (int i = 0; i < nomiRequest.length; i++) {
String ilNome = nomiRequest[i].replace('.', '/');
String ilValore = (workFlowBean.getRequest().getParameter(nomiRequest[i])).trim();
// System.out.println("ilNome=" + ilNome + " -- ilValore=" + ilValore + " ---");
// System.out.println("elementiMultipli=" + elementiMultipli + " ---");
// System.out.println("ilValore.indexOf(\"[#\") > 0 " + (ilValore.indexOf("[#") > 0));
// System.out.println("ilValore.indexOf(\"#]\") > 0 " + (ilValore.indexOf("#]") > 0));
// System.out.println("elementiMultipli > 1 " + (elementiMultipli > 1));
if (!ilValore.equals("")) {
try {
if ((ilValore.indexOf("[#") != -1) && (ilValore.indexOf("#]") > 0) && (elementiMultipli > 0)) {
ilValore = sharpIncrementTool.incrementValue(ilNome, ilValore);// ilValoreIni + contatoreMultiplo + ilValoreFin;
}
} catch (Exception eee) {
} finally {
if (ilNome.endsWith("/@cdata")) {
ilNome = StringUtils.chomp(ilNome, "/@cdata");
builder.insertNode(ilNome, ilValore, true);
} else {
builder.insertNode(ilNome, ilValore); // QUI INSERISCO IL VERO VALORE
}
}
}
}
/* fine ordino la request e creo l'XML */
XMLBuilder theXMLconf = confBean.getTheXMLConfEditing();
for (int a = 0; a < theXMLconf.contaNodi("/root/fixedValues/cdata/elemento"); a++) {
String ilNodoCorrente = theXMLconf.valoreNodo("/root/fixedValues/cdata/elemento[" + (a + 1) + "]/@path");
String ilValoreCorrente = theXMLconf.valoreNodo("/root/fixedValues/cdata/elemento[" + (a + 1) + "]/text()");
ilValoreCorrente = ilValoreCorrente.replaceAll(" ", "_");