Update of 
/var/cvs/applications/editwizard/src/org/mmbase/applications/editwizard
In directory 
james.mmbase.org:/tmp/cvs-serv28871/applications/editwizard/src/org/mmbase/applications/editwizard

Modified Files:
      Tag: MMBase-1_8
        Wizard.java WizardDatabaseConnector.java 
Log Message:
MMB-1594 Data loaded by included lists (add list item) are not saved when 
changed


See also: 
http://cvs.mmbase.org/viewcvs/applications/editwizard/src/org/mmbase/applications/editwizard
See also: http://www.mmbase.org/jira/browse/MMB-1594


Index: Wizard.java
===================================================================
RCS file: 
/var/cvs/applications/editwizard/src/org/mmbase/applications/editwizard/Wizard.java,v
retrieving revision 1.149.2.9
retrieving revision 1.149.2.10
diff -u -b -r1.149.2.9 -r1.149.2.10
--- Wizard.java 13 Oct 2008 13:09:02 -0000      1.149.2.9
+++ Wizard.java 30 Dec 2008 12:07:01 -0000      1.149.2.10
@@ -45,7 +45,7 @@
  * @author Pierre van Rooden
  * @author Hillebrand Gelderblom
  * @since MMBase-1.6
- * @version $Id: Wizard.java,v 1.149.2.9 2008/10/13 13:09:02 sdeboer Exp $
+ * @version $Id: Wizard.java,v 1.149.2.10 2008/12/30 12:07:01 nklasens Exp $
  *
  */
 public class Wizard implements org.mmbase.util.SizeMeasurable {
@@ -446,7 +446,7 @@
                 }
 
                 parent.appendChild(newobject);
-                databaseConnector.tagDataNodes(data);
+                databaseConnector.tagDataNodesWithoutDataID(data);
                 dataId = Utils.getAttribute(newobject, "number");
 
                 if (log.isDebugEnabled()) {
@@ -2450,7 +2450,6 @@
                         for (int j = 0; j < newSubObjects.getLength(); j++) {
                             Node newSubObject = newSubObjects.item(j);
                             Utils.setAttribute(newSubObject, "already-exists", 
"true");
-                            
//loadedData.getDocumentElement().appendChild(loadedData.importNode(newSubObject.cloneNode(true),
 true));
                         }
 
                         
loadedData.getDocumentElement().appendChild(loadedData.importNode(newSubRelation.cloneNode(true),
 true));


Index: WizardDatabaseConnector.java
===================================================================
RCS file: 
/var/cvs/applications/editwizard/src/org/mmbase/applications/editwizard/WizardDatabaseConnector.java,v
retrieving revision 1.46.2.5
retrieving revision 1.46.2.6
diff -u -b -r1.46.2.5 -r1.46.2.6
--- WizardDatabaseConnector.java        29 Dec 2008 13:13:04 -0000      1.46.2.5
+++ WizardDatabaseConnector.java        30 Dec 2008 12:07:01 -0000      1.46.2.6
@@ -18,7 +18,7 @@
 
 
 /**
- * This class handles all communition with mmbase. It uses the MMBase-Dove 
code to do the transactions and get the information
+ * This class handles all communication with mmbase. It uses the MMBase-Dove 
code to do the transactions and get the information
  * needed for rendering the wizard screens.
  * The WizardDatabaseConnector can connect to MMBase and get data, relations, 
constraints, lists. It can also
  * store changes, create new objects and relations.
@@ -31,7 +31,7 @@
  * @author Michiel Meeuwissen
  * @author Pierre van Rooden
  * @since MMBase-1.6
- * @version $Id: WizardDatabaseConnector.java,v 1.46.2.5 2008/12/29 13:13:04 
michiel Exp $
+ * @version $Id: WizardDatabaseConnector.java,v 1.46.2.6 2008/12/30 12:07:01 
nklasens Exp $
  *
  */
 public class WizardDatabaseConnector {
@@ -45,6 +45,7 @@
      * Constructor: Creates the connector. Call #init also.
      */
     public WizardDatabaseConnector(){
+       // nothing to do
     }
 
     /**
@@ -61,9 +62,9 @@
      *
      * @param       data    The data document which should be tagged.
      */
-    public void tagDataNodes(Document data) {
-        didcounter = 1;
-        tagDataNode(data.getDocumentElement());
+    public void tagDataNodesWithoutDataID(Document data) {
+        NodeList nodes = Utils.selectNodeList(data.getDocumentElement(), 
".|.//*[not(@did)]");
+        didcounter = Utils.tagNodeList(nodes, "did", "d", didcounter);
     }
 
     /**
@@ -149,7 +150,7 @@
         if (loadAction != null) {
             loadRelations(object, objectNumber, loadAction);
         }
-        tagDataNodes(data);
+        tagDataNodesWithoutDataID(data);
         return data;
     }
 
@@ -515,27 +516,26 @@
             }
             String dtype = "";
 
-            String createDir = Utils.getAttribute(relation, 
Dove.ELM_CREATEDIR, "either");
             Node inside_object = null;
             Node inside_objectdef = Utils.selectSingleNode(relation, "object");
+
             if (dnumber != null) {
                 // dnumber is given (direct reference to an existing mmbase 
node)
                 // obtain the object.
                 // we can do this here as it is a single retrieval
                 try {
                     inside_object = 
getDataNode(targetParentNode.getOwnerDocument(), dnumber, null);
-                } catch (Exception e) {
-                    throw new WizardException("Could not load object (" + 
dnumber + "). Message: " + Logging.stackTrace(e));
-                }
-
                 // but annotate that this one is loaded from mmbase. Not a new 
one
 
                 Utils.setAttribute(inside_object, "already-exists", "true");
-                Utils.setAttribute(inside_object, "repository", "true");
                 
loadedData.getDocumentElement().appendChild(loadedData.importNode(inside_object.cloneNode(true),
 true));
 
                 // grab the type
                 dtype = Utils.getAttribute(inside_object, "type", "");
+                } catch (Exception e) {
+                    throw new WizardException("Could not load object (" + 
dnumber + "). Message: " + Logging.stackTrace(e));
+                }
+
             } else {
                 // type should be determined from the destinationtype
                 dtype = Utils.getAttribute(relation, "destinationtype", "");
@@ -547,7 +547,7 @@
                 }
             }
 
-
+            String createDir = Utils.getAttribute(relation, 
Dove.ELM_CREATEDIR, "either");
             Node relationNode = getNewRelation(objectNode, role, snumber, 
stype, dnumber, dtype, createDir);
             if (context != null && !context.equals("")) {
                 Utils.setAttribute(relationNode, "context", context);
@@ -837,15 +837,17 @@
                         Utils.setAttribute(node, "status", "changed");
                         // store original destination also. easier to process 
later on
                         Utils.setAttribute(node, "olddestination", 
olddestination);
+                        Utils.setAttribute(orignode, "repository", "update");
                     } else {
                         // it's the same (or at least: the destination is the 
same)
                         // now check if some inside-fields are changed.
                         boolean valueschanged = 
checkRelationFieldsChanged(orignode, node);
 
                         if (valueschanged) {
-                            // values in the fields are changed, 
destination/source are still te same.
+                            // values in the fields are changed, 
destination/source are still the same.
                             // let's store that knowledge.
                             Utils.setAttribute(node,"status", 
"fieldschangedonly");
+                            Utils.setAttribute(orignode, "repository", 
"update");
                         } else {
                             // really nothing changed.
                                 // remove relation from both orig as new
@@ -859,9 +861,9 @@
                     // check if it is changed
                     boolean different = isDifferent(node, orignode);
                     if (!different) {
-                        // remove both objects
+                        // remove object from both orig as new
                         node.getParentNode().removeChild(node);
-                        Utils.setAttribute(orignode, "repository", "true");
+                        orignode.getParentNode().removeChild(orignode);
                     } else {
                         // check if fields are different?
                         NodeList fields=Utils.selectNodeList(node,"field");
@@ -875,7 +877,7 @@
                                 }
                             }
                         }
-                        Utils.setAttribute(orignode, "repository", "false");
+                        Utils.setAttribute(orignode, "repository", "update");
                     }
                 }
             } else {
@@ -956,19 +958,13 @@
                 convertRelationIntoObject(rel);
             }
         }
+        
         return req.getDocumentElement();
     }
 
     private void markDeletedNodes(Document req, Node reqnew, Node reqorig) {
-        // remove all repository nodes
-        NodeList repnodes = Utils.selectNodeList(reqorig, 
".//relati...@repository='true']|.//obje...@repository='true']");
-        for (int i=0; i<repnodes.getLength(); i++) {
-            Node repnode = repnodes.item(i);
-            repnode.getParentNode().removeChild(repnode);
-        }
-
         // find all deleted relations and objects
-        NodeList orignodes = Utils.selectNodeList(reqorig, 
".//relation|.//object");
+        NodeList orignodes = Utils.selectNodeList(reqorig, 
".//relation[not(@repository)]|.//object[not(@repository)]");
         for (int i=0; i<orignodes.getLength(); i++) {
             Node orignode = orignodes.item(i);
             String nodenumber = Utils.getAttribute(orignode, "number", "");
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to