Author: ludovic
Date: 2007-09-06 15:13:31 +0200 (Thu, 06 Sep 2007)
New Revision: 4742
Modified:
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/BaseCollection.java
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources.properties
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_en.properties
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_fr.properties
Log:
XWIKI-1710 Fixed exception in old diff template. Added class changes diff.
Modified:
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/BaseCollection.java
===================================================================
---
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/BaseCollection.java
2007-09-06 12:23:54 UTC (rev 4741)
+++
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/BaseCollection.java
2007-09-06 13:13:31 UTC (rev 4742)
@@ -438,12 +438,14 @@
BaseProperty prop2 = (BaseProperty)
collection.getFields().get(name);
if (prop2==null) {
+ // this is the case property exist in object 1 and not in
object 2
if ((prop!=null)&&(!prop.toText().equals(""))) {
String dprop = (prop.getValue() instanceof String) ?
prop.toText() :
((PropertyClass)getxWikiClass(context).getField(name)).displayView(name,this,context);
difflist.add(new ObjectDiff(getClassName(), getNumber(),
"added",
name, dprop , ""));
}
} else if (!prop2.toText().equals(((prop==null) ? "" :
prop.toText()))) {
+ // this is the case property exists in both and is different
BaseClass bclass = getxWikiClass(context);
PropertyClass pclass = (PropertyClass) ((bclass==null) ? null
: bclass.getField(name));
if (pclass==null) {
@@ -465,6 +467,7 @@
BaseProperty prop2 =
(BaseProperty)collection.getFields().get(name);
if (prop==null) {
+ // this is the case property exists in object2 and not in
object1
if ((prop2!=null)&&(!prop2.toText().equals(""))) {
BaseClass bclass = getxWikiClass(context);
PropertyClass pclass = (PropertyClass) ((bclass==null) ?
null : bclass.getField(name));
Modified:
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java
===================================================================
---
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java
2007-09-06 12:23:54 UTC (rev 4741)
+++
xwiki-platform/core/branches/xwiki-core-1.1/src/main/java/com/xpn/xwiki/objects/classes/BaseClass.java
2007-09-06 13:13:31 UTC (rev 4742)
@@ -24,7 +24,7 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -42,12 +42,8 @@
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.BaseObject;
-import com.xpn.xwiki.objects.BaseProperty;
-import com.xpn.xwiki.objects.ElementComparator;
-import com.xpn.xwiki.objects.PropertyInterface;
-import com.xpn.xwiki.plugin.query.OrderClause;
+import com.xpn.xwiki.objects.*;
+import com.xpn.xwiki.plugin.query.OrderClause;
import com.xpn.xwiki.plugin.query.XWikiCriteria;
import com.xpn.xwiki.plugin.query.XWikiQuery;
import com.xpn.xwiki.validation.XWikiValidationInterface;
@@ -221,9 +217,9 @@
el.addText((getValidationScript()==null) ? "" : getValidationScript());
cel.add(el);
- // Iterate over values sorted by field name so that the values are
- // exported to XML in a consistent order.
- Iterator it = getSortedIterator();
+ // Iterate over values sorted by field name so that the values are
+ // exported to XML in a consistent order.
+ Iterator it = getSortedIterator();
while (it.hasNext()) {
PropertyClass bprop = (PropertyClass)it.next();
cel.add(bprop.toXML());
@@ -769,4 +765,36 @@
}
}
+ public List getDiff(Object coll, XWikiContext context) {
+ ArrayList difflist = new ArrayList();
+ BaseClass bclass = (BaseClass) coll;
+ Iterator itfields = getFieldList().iterator();
+ while (itfields.hasNext()) {
+ PropertyClass prop = (PropertyClass) itfields.next();
+ String name = prop.getName();
+ PropertyClass prop2 = (PropertyClass) bclass.get(name);
+
+ if (prop2==null) {
+ difflist.add(new ObjectDiff(getClassName(), getNumber(),
"added",
+ name, "" , ""));
+ } else if (!prop2.equals(prop)) {
+ difflist.add(new ObjectDiff(getClassName(), getNumber(),
"changed",
+ name, "", ""));
+ }
+ }
+
+ itfields = bclass.getFieldList().iterator();
+ while (itfields.hasNext()) {
+ PropertyClass prop2 = (PropertyClass) itfields.next();
+ String name = prop2.getName();
+ PropertyClass prop = (PropertyClass) get(name);
+
+ if (prop==null) {
+ difflist.add(new ObjectDiff(getClassName(), getNumber(),
"removed",
+ name, "" , ""));
+ }
+ }
+
+ return difflist;
+ }
}
Modified:
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources.properties
===================================================================
---
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources.properties
2007-09-06 12:23:54 UTC (rev 4741)
+++
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources.properties
2007-09-06 13:13:31 UTC (rev 4742)
@@ -817,4 +817,6 @@
changes.tag.tags=Tags
changes.objectchanges=Object Changes
changes.ofclass=of class
-changes.noobjectchanges=No Object Changes
\ No newline at end of file
+changes.noobjectchanges=No Object Changes
+changes.classeschanges=Class Changes
+changes.noclasseschanges=No Class Changes
Modified:
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_en.properties
===================================================================
---
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_en.properties
2007-09-06 12:23:54 UTC (rev 4741)
+++
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_en.properties
2007-09-06 13:13:31 UTC (rev 4742)
@@ -817,4 +817,6 @@
changes.tag.tags=Tags
changes.objectchanges=Object Changes
changes.ofclass=of class
-changes.noobjectchanges=No Object Changes
\ No newline at end of file
+changes.noobjectchanges=No Object Changes
+changes.classeschanges=Class Changes
+changes.noclasseschanges=No Class Changes
Modified:
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_fr.properties
===================================================================
---
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_fr.properties
2007-09-06 12:23:54 UTC (rev 4741)
+++
xwiki-platform/core/branches/xwiki-core-1.1/src/main/resources/ApplicationResources_fr.properties
2007-09-06 13:13:31 UTC (rev 4742)
@@ -806,4 +806,6 @@
changes.tag.tags=Tags
changes.objectchanges=Ajout/Modifications d'objets
changes.ofclass=de la classe
-changes.noobjectchanges=Il n'y a pas de changements
\ No newline at end of file
+changes.noobjectchanges=Il n'y a pas de changements
+changes.classeschanges=Changements de d�finition de classe
+changes.noclasseschanges=Il n'y a pas de changements
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications