Author: tmortagne
Date: 2007-11-02 16:39:02 +0100 (Fri, 02 Nov 2007)
New Revision: 5610
Added:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocumentDoesNotExistException.java
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/ApplicationManager.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/AbstractSuperClass.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperClass.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocument.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocumentTest.java
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/TestAbstractSuperClassTest.java
Log:
XAAM-25: Support more than one object by document in SuperClass feature.
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/ApplicationManager.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/ApplicationManager.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/ApplicationManager.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -21,7 +21,6 @@
package com.xpn.xwiki.plugin.applicationmanager;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -124,7 +123,7 @@
if (!doc.isNew()) {
return (XWikiApplication)
XWikiApplicationClass.getInstance(context)
- .newSuperDocument(doc, context);
+ .newSuperDocument(doc, 0, context);
}
}
@@ -135,35 +134,12 @@
* Search for all document containing a object of class
XWikiApplicationClass.
*
* @param context the XWiki context.
- * @return a list of [EMAIL PROTECTED] XWikiDocument}.
- * @throws XWikiException error when calling for
- * [EMAIL PROTECTED]
XWikiApplicationClass#searchItemDocuments(XWikiContext)}
- */
- public List getApplicationDocumentList(XWikiContext context) throws
XWikiException
- {
- return
XWikiApplicationClass.getInstance(context).searchItemDocuments(context);
- }
-
- /**
- * Search for all document containing a object of class
XWikiApplicationClass.
- *
- * @param context the XWiki context.
* @return a list if [EMAIL PROTECTED] XWikiApplication}.
- * @throws XWikiException error when calling for
- * [EMAIL PROTECTED]
XWikiApplicationClass#searchItemDocuments(XWikiContext)}
+ * @throws XWikiException error when searching documents.
*/
public List getApplicationList(XWikiContext context) throws XWikiException
{
- List documentList = getApplicationDocumentList(context);
-
- List applicationList = new ArrayList(documentList.size());
-
- for (Iterator it = documentList.iterator(); it.hasNext();) {
-
applicationList.add(XWikiApplicationClass.getInstance(context).newSuperDocument(
- (XWikiDocument) it.next(), context));
- }
-
- return applicationList;
+ return
XWikiApplicationClass.getInstance(context).searchSuperDocuments(context);
}
/**
@@ -207,7 +183,7 @@
XWikiApplication appSuperDocToSave =
(XWikiApplication)
XWikiApplicationClass.getInstance(context).newSuperDocument(
- docToSave, context);
+ docToSave, 0, context);
appSuperDocToSave.mergeBaseObject(userAppSuperDoc);
@@ -244,8 +220,8 @@
public XWikiApplication getApplication(String appName, XWikiContext
context, boolean validate)
throws XWikiException
{
- return
XWikiApplicationClass.getInstance(context).getApplication(appName, context,
- validate);
+ return
XWikiApplicationClass.getInstance(context).getApplication(appName, validate,
+ context);
}
/**
@@ -485,7 +461,7 @@
if (XWikiApplicationClass.getInstance(context).isInstance(doc)) {
reloadApplication((XWikiApplication)
XWikiApplicationClass.getInstance(context)
- .newSuperDocument(doc, context), comment, context);
+ .newSuperDocument(doc, 0, context), comment, context);
}
}
}
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/AbstractSuperClass.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/AbstractSuperClass.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/AbstractSuperClass.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -26,12 +26,14 @@
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import com.xpn.xwiki.XWiki;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.api.Document;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.classes.BaseClass;
@@ -577,11 +579,11 @@
*
* @see SuperClass#getClassDocument(com.xpn.xwiki.XWikiContext)
*/
- public XWikiDocument getClassDocument(XWikiContext context) throws
XWikiException
+ public Document getClassDocument(XWikiContext context) throws
XWikiException
{
check(context);
- return context.getWiki().getDocument(getClassFullName(), context);
+ return context.getWiki().getDocument(getClassFullName(),
context).newDocument(context);
}
/**
@@ -589,11 +591,12 @@
*
* @see SuperClass#getClassSheetDocument(com.xpn.xwiki.XWikiContext)
*/
- public XWikiDocument getClassSheetDocument(XWikiContext context) throws
XWikiException
+ public Document getClassSheetDocument(XWikiContext context) throws
XWikiException
{
check(context);
- return context.getWiki().getDocument(getClassSheetFullName(), context);
+ return context.getWiki().getDocument(getClassSheetFullName(),
context).newDocument(
+ context);
}
/**
@@ -601,11 +604,12 @@
*
* @see SuperClass#getClassTemplateDocument(com.xpn.xwiki.XWikiContext)
*/
- public XWikiDocument getClassTemplateDocument(XWikiContext context) throws
XWikiException
+ public Document getClassTemplateDocument(XWikiContext context) throws
XWikiException
{
check(context);
- return context.getWiki().getDocument(getClassTemplateFullName(),
context);
+ return context.getWiki().getDocument(getClassTemplateFullName(),
context).newDocument(
+ context);
}
/**
@@ -621,6 +625,16 @@
/**
* [EMAIL PROTECTED]
*
+ * @see SuperClass#isInstance(com.xpn.xwiki.doc.XWikiDocument)
+ */
+ public boolean isInstance(Document doc)
+ {
+ return doc.getObject(getClassFullName()) != null;
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ *
* @see SuperClass#getItemDocumentDefaultName(java.lang.String,
XWikiContext)
*/
public String getItemDocumentDefaultName(String itemName, XWikiContext
context)
@@ -656,41 +670,21 @@
/**
* [EMAIL PROTECTED]
- *
- * @see SuperClass#getItemDocument(java.lang.String,
com.xpn.xwiki.XWikiContext)
+ *
+ * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass#getSuperDocument(java.lang.String,
int, boolean, com.xpn.xwiki.XWikiContext)
*/
- public XWikiDocument getItemDocument(String itemName, XWikiContext context)
- throws XWikiException
+ public SuperDocument getSuperDocument(String itemName, int objectId,
boolean validate,
+ XWikiContext context) throws XWikiException
{
- return
context.getWiki().getDocument(getItemDocumentDefaultFullName(itemName, context),
- context);
- }
+ XWikiDocument doc =
+
context.getWiki().getDocument(getItemDocumentDefaultFullName(itemName, context),
+ context);
- /**
- * Find all XWikiDocument containing object of this XWiki class.
- *
- * @param context the XWiki context.
- * @return a list of XWikiDocument containing object of this XWiki class.
- * @throws XWikiException error when searching for document in database.
- * @see #getClassFullName()
- */
- public List searchItemDocuments(XWikiContext context) throws XWikiException
- {
- return searchItemDocumentsByFields(null, context);
- }
+ if (doc.isNew() || !isInstance(doc)) {
+ throw new SuperDocumentDoesNotExistException(itemName + " object
does not exist");
+ }
- /**
- * [EMAIL PROTECTED]
- *
- * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass#searchItemDocumentsByField(java.lang.String,
- * java.lang.String, java.lang.String, com.xpn.xwiki.XWikiContext)
- */
- public List searchItemDocumentsByField(String fieldName, String
fieldValue, String fieldType,
- XWikiContext context) throws XWikiException
- {
- String[][] fieldDescriptors = new String[][] {{fieldName, fieldType,
fieldValue}};
-
- return searchItemDocumentsByFields(fieldDescriptors, context);
+ return newSuperDocument(doc, objectId, context);
}
/**
@@ -710,7 +704,7 @@
new StringBuffer(" where doc.fullName=obj.name and obj.className="
+ HQL_PARAMETER_STRING);
parameterValues.add(getClassFullName());
-
+
where.append(" and obj.name<>" + HQL_PARAMETER_STRING);
parameterValues.add(getClassTemplateFullName());
@@ -746,12 +740,46 @@
}
/**
- * [EMAIL PROTECTED]
+ * Find all XWikiDocument containing object of this XWiki class.
*
- * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass#searchItemDocumentsByFields(
- * java.lang.String[][], com.xpn.xwiki.XWikiContext)
+ * @param context the XWiki context.
+ * @return the list of found [EMAIL PROTECTED] SuperDocument}.
+ * @throws XWikiException error when searching for document in database.
+ * @see #getClassFullName()
*/
- public List searchItemDocumentsByFields(String[][] fieldDescriptors,
XWikiContext context)
+ public List searchSuperDocuments(XWikiContext context) throws
XWikiException
+ {
+ return searchSuperDocumentsByFields(null, context);
+ }
+
+ /**
+ * Search in instances of this document class.
+ *
+ * @param fieldName the name of field.
+ * @param fieldValue the value of field.
+ * @param fieldType the type of field.
+ * @param context the XWiki context.
+ * @return the list of found [EMAIL PROTECTED] SuperDocument}.
+ * @throws XWikiException error when searching for documents from in
database.
+ */
+ public List searchSuperDocumentsByField(String fieldName, String
fieldValue,
+ String fieldType, XWikiContext context) throws XWikiException
+ {
+ String[][] fieldDescriptors = new String[][] {{fieldName, fieldType,
fieldValue}};
+
+ return searchSuperDocumentsByFields(fieldDescriptors, context);
+ }
+
+ /**
+ * Search in instances of this document class.
+ *
+ * @param fieldDescriptors the list of fields name/value constraints.
Format : [[fieldName1,
+ * typeField1, valueField1][fieldName2, typeField2,
valueField2]].
+ * @param context the XWiki context.
+ * @return the list of found [EMAIL PROTECTED] SuperDocument}.
+ * @throws XWikiException error when searching for documents from in
database.
+ */
+ public List searchSuperDocumentsByFields(String[][] fieldDescriptors,
XWikiContext context)
throws XWikiException
{
check(context);
@@ -759,30 +787,33 @@
List parameterValues = new ArrayList();
String where = createWhereClause(fieldDescriptors, parameterValues);
- return context.getWiki().getStore().searchDocuments(where,
parameterValues, context);
+ return
newSuperDocumentList(context.getWiki().getStore().searchDocuments(where,
+ parameterValues, context), context);
}
/**
* [EMAIL PROTECTED]
*
* @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass#newSuperDocument(com.xpn.xwiki.doc.XWikiDocument,
- * com.xpn.xwiki.XWikiContext)
+ * int, com.xpn.xwiki.XWikiContext)
*/
- public SuperDocument newSuperDocument(XWikiDocument doc, XWikiContext
context)
+ public SuperDocument newSuperDocument(XWikiDocument doc, int objId,
XWikiContext context)
throws XWikiException
{
- return new DefaultSuperDocument(this, doc, context);
+ return new DefaultSuperDocument(this, doc, objId, context);
}
/**
* [EMAIL PROTECTED]
*
- * @see SuperClass#newSuperDocument(java.lang.String,
com.xpn.xwiki.XWikiContext)
+ * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass#newSuperDocument(java.lang.String,
+ * int, com.xpn.xwiki.XWikiContext)
*/
- public SuperDocument newSuperDocument(String docFullName, XWikiContext
context)
+ public SuperDocument newSuperDocument(String docFullName, int objId,
XWikiContext context)
throws XWikiException
{
- return newSuperDocument(context.getWiki().getDocument(docFullName,
context), context);
+ return newSuperDocument(context.getWiki().getDocument(docFullName,
context), objId,
+ context);
}
/**
@@ -792,6 +823,27 @@
*/
public SuperDocument newSuperDocument(XWikiContext context) throws
XWikiException
{
- return newSuperDocument(new XWikiDocument(), context);
+ return newSuperDocument(new XWikiDocument(), 0, context);
}
+
+ /**
+ * [EMAIL PROTECTED]
+ *
+ * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass#newSuperDocumentList(java.util.List,
+ * com.xpn.xwiki.XWikiContext)
+ */
+ public List newSuperDocumentList(List documents, XWikiContext context)
throws XWikiException
+ {
+ List list = new ArrayList(documents.size());
+ for (Iterator it = documents.iterator(); it.hasNext();) {
+ XWikiDocument doc = (XWikiDocument) it.next();
+ List objects = doc.getObjects(getClassFullName());
+
+ for (int i = 0; i < objects.size(); ++i) {
+ list.add(newSuperDocument(doc, i, context));
+ }
+ }
+
+ return list;
+ }
}
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocument.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -25,6 +25,7 @@
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.api.Document;
+import com.xpn.xwiki.api.Object;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.BaseObject;
@@ -49,7 +50,7 @@
* Value in int for [EMAIL PROTECTED] Boolean#FALSE}.
*/
private static final int BOOLEANFIELD_FALSE = 0;
-
+
/**
* Value in int for [EMAIL PROTECTED] Boolean} = null.
*/
@@ -61,52 +62,32 @@
protected SuperClass sclass;
/**
+ * The id of the XWiki object included in the document to manage.
+ */
+ protected int objectId;
+
+ /**
* true if this is a new document of this class (this document can exist
but does not contains
* object of this class).
*/
protected boolean isNew;
/**
- * Create new instance of DefaultSuperDocument.
- *
- * @param sclass the class manager for this document.
- * @param context the XWiki context.
- * @throws XWikiException error when calling [EMAIL PROTECTED]
#reload(XWikiContext)}.
- */
- public DefaultSuperDocument(SuperClass sclass, XWikiContext context)
throws XWikiException
- {
- this(sclass, new XWikiDocument(), context);
- }
-
- /**
- * Create instance of DefaultSuperDocument from XWikiDocument with
<code>docFullName</code>
- * full name.
- *
- * @param sclass the class manager for this document.
- * @param docFullName the full name of the XWikiDocument to manage.
- * @param context the Xwiki context.
- * @throws XWikiException error when calling [EMAIL PROTECTED]
#reload(XWikiContext)}.
- */
- public DefaultSuperDocument(SuperClass sclass, String docFullName,
XWikiContext context)
- throws XWikiException
- {
- this(sclass, context.getWiki().getDocument(docFullName, context),
context);
- }
-
- /**
* Create instance of DefaultSuperDocument from provided XWikiDocument.
*
* @param sclass the class manager for this document.
* @param xdoc the XWikiDocument to manage.
+ * @param objectId the id of the XWiki object included in the document to
manage.
* @param context the XWiki context.
* @throws XWikiException error when calling [EMAIL PROTECTED]
#reload(XWikiContext)}.
*/
- public DefaultSuperDocument(SuperClass sclass, XWikiDocument xdoc,
XWikiContext context)
- throws XWikiException
+ public DefaultSuperDocument(SuperClass sclass, XWikiDocument xdoc, int
objectId,
+ XWikiContext context) throws XWikiException
{
super(xdoc, context);
this.sclass = sclass;
+ this.objectId = objectId;
reload(context);
}
@@ -127,13 +108,19 @@
public void reload(XWikiContext context) throws XWikiException
{
if (this.getObjectNumbers(this.sclass.getClassFullName()) == 0) {
+ if (this.objectId > 0) {
+ throw new XWikiException(XWikiException.MODULE_XWIKI_DOC,
+ XWikiException.ERROR_XWIKI_DOES_NOT_EXIST,
+ "Object od id " + this.objectId + "does not exist");
+ }
+
BaseObject object =
getDoc().newObject(this.sclass.getClassFullName(), context);
- XWikiDocument docTemplate =
this.sclass.getClassTemplateDocument(context);
- BaseObject templateObject =
docTemplate.getObject(this.sclass.getClassFullName());
+ Document docTemplate =
this.sclass.getClassTemplateDocument(context);
+ Object templateObject =
docTemplate.getObject(this.sclass.getClassFullName());
if (templateObject != null) {
- object.merge(templateObject);
+ object.merge(templateObject.getXWikiObject());
}
if (super.isNew()) {
@@ -144,8 +131,58 @@
this.isNew = true;
}
}
+
+ /**
+ * [EMAIL PROTECTED]
+ *
+ * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperDocument#getDocumentApi()
+ */
+ public Document getDocumentApi()
+ {
+ return this;
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ *
+ * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperDocument#getObjectId()
+ */
+ public int getObjectId() {
+ return this.objectId;
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ *
+ * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperDocument#getObjectApi()
+ */
+ public Object getObjectApi()
+ {
+ BaseObject obj = getBaseObject(false);
+ return obj == null ? null : obj.newObjectApi(obj, context);
+ }
+
/**
+ * Get the managed [EMAIL PROTECTED] BaseObject}.
+ *
+ * @param toWrite indicate that the [EMAIL PROTECTED] BaseObject} will be
modified.
+ * @return the [EMAIL PROTECTED] BaseObject}.
+ */
+ protected BaseObject getBaseObject(boolean toWrite)
+ {
+ BaseObject obj;
+
+ if (toWrite) {
+ obj = getDoc().getObject(this.sclass.getClassFullName(),
this.objectId);
+ } else {
+ obj = this.doc.getObject(this.sclass.getClassFullName(),
this.objectId);
+ }
+
+ return obj;
+ }
+
+ /**
* [EMAIL PROTECTED]
*
* @see SuperDocument#mergeBaseObject(SuperDocument)
@@ -156,8 +193,7 @@
return;
}
- getDoc().getObject(this.sclass.getClassFullName()).merge(
- sdoc.getDocument().getObject(this.sclass.getClassFullName()));
+ getBaseObject(true).merge(sdoc.getObjectApi().getXWikiObject());
}
/**
@@ -198,129 +234,175 @@
*/
protected void deleteDocument() throws XWikiException
{
- super.deleteDocument();
+ if (getObjectNumbers(sclass.getClassFullName()) == 1) {
+ super.deleteDocument();
+ } else {
+ doc.removeObject(getBaseObject(false));
+ save();
+ }
+
+
this.isNew = true;
}
/**
- * Get the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Get the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @return the value in [EMAIL PROTECTED] String} of the field
<code>fieldName</code> of the class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @return the value in [EMAIL PROTECTED] String} of the field
<code>fieldName</code> of the managed
+ * object's class.
* @see com.xpn.xwiki.doc.XWikiDocument#getStringValue(java.lang.String)
*/
public String getStringValue(String fieldName)
{
- return this.doc.getStringValue(this.sclass.getClassFullName(),
fieldName);
+ BaseObject obj = getBaseObject(false);
+
+ if (obj == null) {
+ return null;
+ }
+
+ return obj.getStringValue(fieldName);
}
/**
- * Modify the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Modify the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @param value the new value of the field <code>fieldName</code> of the
class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @param value the new value of the field <code>fieldName</code> of the
managed object's
+ * class.
* @see
com.xpn.xwiki.doc.XWikiDocument#setStringValue(java.lang.String,java.lang.String,java.lang.String)
*/
public void setStringValue(String fieldName, String value)
{
- getDoc().setStringValue(this.sclass.getClassFullName(), fieldName,
value);
+ BaseObject obj = getBaseObject(true);
+
+ if (obj != null) {
+ obj.setStringValue(fieldName, value);
+ }
}
/**
- * Get the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Get the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @return the value in [EMAIL PROTECTED] String} of the field
<code>fieldName</code> of the class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @return the value in [EMAIL PROTECTED] String} of the field
<code>fieldName</code> of the managed
+ * object's class.
* @see com.xpn.xwiki.doc.XWikiDocument#getStringValue(java.lang.String)
*/
public String getLargeStringValue(String fieldName)
{
- return this.doc.getStringValue(this.sclass.getClassFullName(),
fieldName);
+ BaseObject obj = getBaseObject(false);
+
+ if (obj == null) {
+ return null;
+ }
+
+ return obj.getLargeStringValue(fieldName);
}
/**
- * Modify the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Modify the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @param value the new value of the field <code>fieldName</code> of the
class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @param value the new value of the field <code>fieldName</code> of the
managed object's
+ * class.
* @see
com.xpn.xwiki.doc.XWikiDocument#setLargeStringValue(java.lang.String,java.lang.String,java.lang.String)
*/
public void setLargeStringValue(String fieldName, String value)
{
- getDoc().setLargeStringValue(this.sclass.getClassFullName(),
fieldName, value);
+ BaseObject obj = getBaseObject(true);
+
+ if (obj != null) {
+ obj.setLargeStringValue(fieldName, value);
+ }
}
/**
- * Get the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Get the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @return the value in [EMAIL PROTECTED] List} of the field
<code>fieldName</code> of the class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @return the value in [EMAIL PROTECTED] List} of the field
<code>fieldName</code> of the managed
+ * object's class.
* @see com.xpn.xwiki.doc.XWikiDocument#getListValue(java.lang.String)
*/
public List getListValue(String fieldName)
{
- return this.doc.getListValue(this.sclass.getClassFullName(),
fieldName);
+ BaseObject obj = getBaseObject(false);
+
+ if (obj == null) {
+ return null;
+ }
+
+ return obj.getListValue(fieldName);
}
/**
- * Modify the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Modify the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @param value the new value of the field <code>fieldName</code> of the
class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @param value the new value of the field <code>fieldName</code> of the
managed object's
+ * class.
* @see
com.xpn.xwiki.doc.XWikiDocument#setStringListValue(java.lang.String,java.lang.String,java.util.List)
*/
public void setListValue(String fieldName, List value)
{
- getDoc().setStringListValue(this.sclass.getClassFullName(), fieldName,
value);
+ BaseObject obj = getBaseObject(true);
+
+ if (obj != null) {
+ obj.setStringListValue(fieldName, value);
+ }
}
/**
- * Get the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Get the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @return the value in int of the field <code>fieldName</code> of the
class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @return the value in int of the field <code>fieldName</code> of the
managed object's class.
* @see com.xpn.xwiki.doc.XWikiDocument#getListValue(java.lang.String)
*/
public int getIntValue(String fieldName)
{
- return this.doc.getIntValue(this.sclass.getClassFullName(), fieldName);
+ BaseObject obj = getBaseObject(false);
+
+ if (obj == null) {
+ return 0;
+ }
+
+ return obj.getIntValue(fieldName);
}
/**
- * Modify the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Modify the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @param value the new value of the field <code>fieldName</code> of the
class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @param value the new value of the field <code>fieldName</code> of the
managed object's
+ * class.
* @see com.xpn.xwiki.doc.XWikiDocument#setIntValue(String, String, int)
*/
public void setIntValue(String fieldName, int value)
{
- getDoc().setIntValue(this.sclass.getClassFullName(), fieldName, value);
+ BaseObject obj = getBaseObject(true);
+
+ if (obj != null) {
+ obj.setIntValue(fieldName, value);
+ }
}
/**
- * Get the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Get the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @return the value in [EMAIL PROTECTED] Boolean} of the field
<code>fieldName</code> of the class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @return the value in [EMAIL PROTECTED] Boolean} of the field
<code>fieldName</code> of the managed
+ * object's class.
* @see com.xpn.xwiki.doc.XWikiDocument#getListValue(java.lang.String)
*/
public Boolean getBooleanValue(String fieldName)
@@ -332,12 +414,12 @@
}
/**
- * Modify the value of the field <code>fieldName</code> of the class
"XWikiApplicationClass".
+ * Modify the value of the field <code>fieldName</code> of the managed
object's class.
*
- * @param fieldName the name of the field from the class
"XWikiApplicationClass" where to find
- * the value.
- * @param value the new value of the field <code>fieldName</code> of the
class
- * "XWikiApplicationClass".
+ * @param fieldName the name of the field from the managed object's class
where to find the
+ * value.
+ * @param value the new value of the field <code>fieldName</code> of the
managed object's
+ * class.
* @see com.xpn.xwiki.doc.XWikiDocument#setIntValue(String, String, int)
*/
public void setBooleanValue(String fieldName, Boolean value)
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperClass.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperClass.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperClass.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -24,6 +24,7 @@
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.api.Document;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.classes.BaseClass;
@@ -186,7 +187,7 @@
* @return the document containing the class for this context.
* @throws XWikiException error when getting class document from the
database.
*/
- XWikiDocument getClassDocument(XWikiContext context) throws XWikiException;
+ Document getClassDocument(XWikiContext context) throws XWikiException;
/**
* @return the default content to add in a new class sheet document.
@@ -200,7 +201,7 @@
* @return the document containing the class sheet for this context.
* @throws XWikiException error when getting class sheet document from the
database.
*/
- XWikiDocument getClassSheetDocument(XWikiContext context) throws
XWikiException;
+ Document getClassSheetDocument(XWikiContext context) throws XWikiException;
/**
* @return the default content to add in a new class template document.
@@ -214,7 +215,7 @@
* @return the class template document for this context.
* @throws XWikiException error when getting class template document from
the database.
*/
- XWikiDocument getClassTemplateDocument(XWikiContext context) throws
XWikiException;
+ Document getClassTemplateDocument(XWikiContext context) throws
XWikiException;
/**
* Determines if the specified <code>doc</code> is compatible with this
xwiki class (if he
@@ -226,6 +227,15 @@
boolean isInstance(XWikiDocument doc);
/**
+ * Determines if the specified <code>doc</code> is compatible with this
xwiki class (if he
+ * contains class object).
+ *
+ * @param doc the XWikidocument to test.
+ * @return true if <code>doc</code> support this class, false otherwise.
+ */
+ boolean isInstance(Document doc);
+
+ /**
* Get document name from item name <code>item</code>. Usually a Document
name is
* DocumentTypeItemName.
*
@@ -263,13 +273,17 @@
* Get document by full name from item name <code>itemName</code>.
*
* @param itemName the full name of the item.
+ * @param objectId the id of the XWiki object included in the document to
manage.
+ * @param validate indicate if it return new [EMAIL PROTECTED]
SuperDocument} or throw exception if wiki
+ * descriptor does not exist.
* @param context the XWiki context.
- * @return the full name of the document.
+ * @return the document.
* @throws XWikiException error when getting document from the database.
* @see #getItemDefaultName(String)
* @see #getItemDocumentDefaultFullName(String, XWikiContext)
*/
- XWikiDocument getItemDocument(String itemName, XWikiContext context)
throws XWikiException;
+ SuperDocument getSuperDocument(String itemName, int objectId, boolean
validate,
+ XWikiContext context) throws XWikiException;
/**
* Construct HQL where clause to use with [EMAIL PROTECTED]
com.xpn.xwiki.store.XWikiStoreInterface}
@@ -284,40 +298,17 @@
String createWhereClause(String[][] fieldDescriptors, List
parameterValues);
/**
- * Search in instances of this document class.
- *
- * @param fieldName the name of field.
- * @param fieldValue the value of field.
- * @param fieldType the type of field.
- * @param context the XWiki context.
- * @return the list of found XWikiDocuments.
- * @throws XWikiException error when searching for documents from in
database.
- */
- List searchItemDocumentsByField(String fieldName, String fieldValue,
String fieldType,
- XWikiContext context) throws XWikiException;
-
- /**
- * Search in instances of this document class.
- *
- * @param fieldDescriptors the list of fields name/value constraints.
Format : [[fieldName1,
- * typeField1, valueField1][fieldName2, typeField2,
valueField2]].
- * @param context the XWiki context.
- * @return the list of found XWikiDocuments.
- * @throws XWikiException error when searching for documents from in
database.
- */
- List searchItemDocumentsByFields(String[][] fieldDescriptors, XWikiContext
context)
- throws XWikiException;
-
- /**
* Create new super document containing object of class [EMAIL PROTECTED]
#getClassFullName()}. If
* document already exist it is returned with new object if it does not
contains any.
*
* @param doc the XWiki document to manage.
+ * @param objId the id of the XWiki object included in the document to
manage.
* @param context the XWiki context.
* @return a new SuperDocument instance.
* @throws XWikiException error when calling SuperDocument implementation
constructor.
*/
- SuperDocument newSuperDocument(XWikiDocument doc, XWikiContext context)
throws XWikiException;
+ SuperDocument newSuperDocument(XWikiDocument doc, int objId, XWikiContext
context)
+ throws XWikiException;
/**
* Create new super document containing object of class [EMAIL PROTECTED]
#getClassFullName()}. If
@@ -334,11 +325,23 @@
* document already exist it is returned with new object if it does not
contains any.
*
* @param docFullName the full name of document to manage.
+ * @param objId the id of the XWiki object included in the document to
manage.
* @param context the XWiki context.
* @return a new SuperDocument instance.
* @throws XWikiException error when calling SuperDocument implementation
constructor.
* @see #getClassFullName()
*/
- SuperDocument newSuperDocument(String docFullName, XWikiContext context)
+ SuperDocument newSuperDocument(String docFullName, int objId, XWikiContext
context)
throws XWikiException;
+
+ /**
+ * Create new super document containing object of class [EMAIL PROTECTED]
#getClassFullName()} for each
+ * [EMAIL PROTECTED] XWikiDocument} in the list and return it.
+ *
+ * @param documents the list of [EMAIL PROTECTED] XWikiDocument}.
+ * @param context the XWiki context.
+ * @return the list of [EMAIL PROTECTED] SuperDocument}.
+ * @throws XWikiException error when calling SuperDocument implementation
constructor.
+ */
+ List newSuperDocumentList(List documents, XWikiContext context) throws
XWikiException;
}
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocument.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocument.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocument.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -22,7 +22,8 @@
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.api.Document;
+import com.xpn.xwiki.api.Object;
/**
* SuperDocument interface.
@@ -69,7 +70,17 @@
boolean isNew();
/**
- * @return the XWiki document.
+ * @return the document.
*/
- XWikiDocument getDocument();
+ Document getDocumentApi();
+
+ /**
+ * @return the managed XWiki object.
+ */
+ Object getObjectApi();
+
+ /**
+ * @return the id of the managed XWiki object;
+ */
+ int getObjectId();
}
Added:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocumentDoesNotExistException.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocumentDoesNotExistException.java
(rev 0)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/SuperDocumentDoesNotExistException.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -0,0 +1,21 @@
+package com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes;
+
+import com.xpn.xwiki.XWikiException;
+
+/**
+ * Exception when try get [EMAIL PROTECTED] SuperDocument} that does not exist.
+ *
+ * @version $Id: $
+ */
+public class SuperDocumentDoesNotExistException extends XWikiException
+{
+ /**
+ * Create new instance of [EMAIL PROTECTED]
SuperDocumentDoesNotExistException}.
+ *
+ * @param message the error message.
+ */
+ public SuperDocumentDoesNotExistException(String message)
+ {
+ super(XWikiException.MODULE_XWIKI_DOC,
XWikiException.ERROR_XWIKI_DOES_NOT_EXIST, message);
+ }
+}
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -51,6 +51,7 @@
* Create new XWikiApplication managing provided XWikiDocument.
*
* @param xdoc the encapsulated XWikiDocument
+ * @param objectId the id of the XWiki object included in the document to
manage.
* @param context the XWiki context
* @throws XWikiException error when:
* <ul>
@@ -58,11 +59,12 @@
* <li>or when calling [EMAIL PROTECTED]
#reload(XWikiContext)}</li>
* </ul>
* @see
DefaultSuperDocument#DefaultSuperDocument(com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass,
- * XWikiDocument, XWikiContext)
+ * XWikiDocument, int, XWikiContext)
*/
- public XWikiApplication(XWikiDocument xdoc, XWikiContext context) throws
XWikiException
+ public XWikiApplication(XWikiDocument xdoc, int objectId, XWikiContext
context)
+ throws XWikiException
{
- super(XWikiApplicationClass.getInstance(context), xdoc, context);
+ super(XWikiApplicationClass.getInstance(context), xdoc, objectId,
context);
}
// ///
@@ -291,7 +293,7 @@
for (Iterator it = applications.iterator(); it.hasNext();) {
XWikiApplication app =
((XWikiApplicationClass) sclass)
- .getApplication((String) it.next(), context, true);
+ .getApplication((String) it.next(), true, context);
applicationSet.add(app);
if (recurse) {
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -24,12 +24,15 @@
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.objects.BaseObject;
import com.xpn.xwiki.objects.StringProperty;
import com.xpn.xwiki.objects.classes.BaseClass;
import com.xpn.xwiki.plugin.applicationmanager.ApplicationManagerException;
import
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.AbstractSuperClass;
import
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperDocument;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
/**
@@ -297,14 +300,18 @@
* @throws XWikiException error when searching for application descriptor
document.
* @see #getApplication(String, XWikiContext, boolean)
*/
- private XWikiDocument getApplicationDocument(String appName, XWikiContext
context,
+ protected XWikiDocument getApplicationDocument(String appName,
XWikiContext context,
boolean validate) throws XWikiException
{
XWiki xwiki = context.getWiki();
+ String[][] fieldDescriptors =
+ new String[][] {{FIELD_APPNAME,
StringProperty.class.getSimpleName(), appName}};
+ List parameterValues = new ArrayList();
+ String where = createWhereClause(fieldDescriptors, parameterValues);
+
List listApp =
- searchItemDocumentsByField(FIELD_APPNAME, appName,
StringProperty.class
- .getSimpleName(), context);
+ context.getWiki().getStore().searchDocuments(where,
parameterValues, context);
if (listApp.size() == 0) {
if (validate) {
@@ -332,23 +339,40 @@
* @throws XWikiException error when searching for application descriptor
document.
* @see #getApplicationDocument(String, XWikiContext, boolean)
*/
- public XWikiApplication getApplication(String appName, XWikiContext
context, boolean validate)
+ public XWikiApplication getApplication(String appName, boolean validate,
XWikiContext context)
throws XWikiException
{
- return (XWikiApplication)
newSuperDocument(getApplicationDocument(appName, context,
- validate), context);
+ XWikiDocument doc = getApplicationDocument(appName, context, validate);
+
+ int objectId = 0;
+ for (Iterator it = doc.getObjects(getClassFullName()).iterator();
it.hasNext();) {
+ BaseObject obj = (BaseObject) it.next();
+
+ if (obj.getStringValue(FIELD_APPNAME).equalsIgnoreCase(appName)) {
+ break;
+ }
+
+ ++objectId;
+ }
+
+ if (objectId == doc.getObjects(getClassFullName()).size()) {
+ objectId = 0;
+ }
+
+ return (XWikiApplication) newSuperDocument(doc, objectId, context);
}
/**
* [EMAIL PROTECTED]
* <p>
- * Override abstract method using [EMAIL PROTECTED] XWikiApplication} as
[EMAIL PROTECTED] XWikiApplication}.
+ * Override abstract method using [EMAIL PROTECTED] XWikiApplication} as
[EMAIL PROTECTED] SuperDocument}.
*
* @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.AbstractSuperClass#newSuperDocument(com.xpn.xwiki.doc.XWikiDocument,
- * com.xpn.xwiki.XWikiContext)
+ * int, com.xpn.xwiki.XWikiContext)
*/
- public SuperDocument newSuperDocument(XWikiDocument doc, XWikiContext
context)
+ public SuperDocument newSuperDocument(XWikiDocument doc, int objId,
XWikiContext context)
+ throws XWikiException
{
- return (SuperDocument)
doc.newDocument(XWikiApplication.class.getName(), context);
+ return new XWikiApplication(doc, objId, context);
}
}
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocumentTest.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocumentTest.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/DefaultSuperDocumentTest.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -186,7 +186,7 @@
SuperClass sclass =
TestAbstractSuperClassTest.DispatchSuperClass.getInstance(context);
DefaultSuperDocument sdoc =
- (DefaultSuperDocument)
sclass.newSuperDocument(DEFAULT_DOCFULLNAME, context);
+ (DefaultSuperDocument)
sclass.newSuperDocument(DEFAULT_DOCFULLNAME, 0, context);
assertNotNull(sdoc);
assertTrue(sdoc.isNew());
@@ -208,7 +208,7 @@
SuperClass sclass =
TestAbstractSuperClassTest.DispatchSuperClass.getInstance(context);
DefaultSuperDocument sdoc =
- (DefaultSuperDocument)
sclass.newSuperDocument(DEFAULT_DOCFULLNAME, context);
+ (DefaultSuperDocument)
sclass.newSuperDocument(DEFAULT_DOCFULLNAME, 0, context);
assertNotNull(sdoc);
assertTrue(sdoc.isNew());
Modified:
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/TestAbstractSuperClassTest.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/TestAbstractSuperClassTest.java
2007-11-02 14:23:36 UTC (rev 5609)
+++
xwiki-platform/xwiki-plugins/trunk/application-manager/src/test/java/com/xpn/xwiki/plugin/applicationmanager/core/doc/objects/classes/TestAbstractSuperClassTest.java
2007-11-02 15:39:02 UTC (rev 5610)
@@ -34,6 +34,7 @@
import com.xpn.xwiki.XWikiConfig;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.api.Document;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.BaseObject;
import com.xpn.xwiki.objects.PropertyInterface;
@@ -428,7 +429,7 @@
private void ptestGetClassDocument(SuperClass sclass) throws XWikiException
{
XWikiDocument doc = xwiki.getDocument(sclass.getClassFullName(),
context);
- XWikiDocument docFromClass = sclass.getClassDocument(context);
+ Document docFromClass = sclass.getClassDocument(context);
assertFalse(docFromClass.isNew());
assertEquals(doc.getFullName(), docFromClass.getFullName());
@@ -455,7 +456,7 @@
private void ptestGetClassSheetDocument(SuperClass sclass) throws
XWikiException
{
XWikiDocument doc = xwiki.getDocument(sclass.getClassSheetFullName(),
context);
- XWikiDocument docFromClass = sclass.getClassSheetDocument(context);
+ Document docFromClass = sclass.getClassSheetDocument(context);
assertFalse(docFromClass.isNew());
assertEquals(doc.getFullName(), docFromClass.getFullName());
@@ -482,7 +483,7 @@
private void ptestGetClassTemplateDocument(SuperClass sclass) throws
XWikiException
{
XWikiDocument doc =
xwiki.getDocument(sclass.getClassTemplateFullName(), context);
- XWikiDocument docFromClass = sclass.getClassTemplateDocument(context);
+ Document docFromClass = sclass.getClassTemplateDocument(context);
assertFalse(docFromClass.isNew());
assertEquals(doc.getFullName(), docFromClass.getFullName());
@@ -551,14 +552,14 @@
public void testIsInstanceNoDispatch() throws XWikiException
{
assertTrue(NoDispatchSuperClass.getInstance(context).isInstance(
-
NoDispatchSuperClass.getInstance(context).newSuperDocument(context).getDocument()));
+
NoDispatchSuperClass.getInstance(context).newSuperDocument(context).getDocumentApi()));
assertFalse(NoDispatchSuperClass.getInstance(context).isInstance(new
XWikiDocument()));
}
public void testIsInstanceDispatch() throws XWikiException
{
assertTrue(DispatchSuperClass.getInstance(context).isInstance(
-
DispatchSuperClass.getInstance(context).newSuperDocument(context).getDocument()));
+
DispatchSuperClass.getInstance(context).newSuperDocument(context).getDocumentApi()));
assertFalse(DispatchSuperClass.getInstance(context).isInstance(new
XWikiDocument()));
}
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications