On Sat, Dec 12, 2009 at 16:46, Thomas Mortagne <[email protected]> wrote:
On Sat, Dec 12, 2009 at 16:02, vmassol <[email protected]> wrote:
Author: vmassol Date: 2009-12-12 16:02:21 +0100 (Sat, 12 Dec 2009) New Revision: 25768
Added: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Persistable.java Removed: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/internal/ contrib/sandbox/xwiki-model/src/main/resources/ contrib/sandbox/xwiki-model/src/test/ Modified: contrib/sandbox/xwiki-model/ contrib/sandbox/xwiki-model/pom.xml contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Attachment.java contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Document.java contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Object.java contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinition.java contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinitionProperty.java contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Server.java contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Space.java contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Wiki.java Log: Continuing work on the new Model. The idea is to do step1, which is about designing the interfaces and implementing them with the old model FTM.
* Remove dependencies on JCR since we now want to create interfaces for the new model that are independent of JCR (for a start). I'm still unsure whether we should base these interfaces on JCR or not but it seems easier not to for the moment. * Several questions asked in comments
[...]
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Attachment.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Attachment.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Attachment.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -1,8 +1,6 @@ package org.xwiki.model;
-import javax.jcr.Node; - -public interface Attachment extends Node +public interface Attachment extends Persistable {
}
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Document.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Document.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Document.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -1,10 +1,12 @@ package org.xwiki.model;
+import org.xwiki.bridge.DocumentName; +import org.xwiki.rendering.block.XDOM; + import java.util.List; +import java.util.Locale;
-import javax.jcr.Node; - -public interface Document extends Node +public interface Document extends Persistable { /** * @return the list of object definitions defined inside this document @@ -14,6 +16,24 @@ List<Object> getObjects();
List<Attachment> getAttachments(); - - String setContent(String content); + + void setParent(Document document); + + Document getParent(); + + // Note: In order to make modifications to the document's content, modify the returned XDOM + // Default language + XDOM getContent(); + XDOM getContent(Locale locale); + + // get/setSyntax(Syntax syntax) + + // Q: Should we have this or should we force users to use a Parser for a given syntax, ie make Document + // independent of the Syntax?
Sounds nicer to only work with XDOM but what does it mean for the storage ? Is the way to store the document content (a string in some syntax, directly in the database with each block type having its own table, etc...) become an implementation details (good idea IMO) ?
+ //String setContent(String content); + + boolean hasObject(String objectName); + + // Q: Is this ok? + DocumentName getDocumentName(); }
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Object.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Object.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Object.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -1,8 +1,6 @@ package org.xwiki.model;
-import javax.jcr.Node; - -public interface Object extends Node +public interface Object extends Persistable {
}
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinition.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinition.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinition.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -1,8 +1,6 @@ package org.xwiki.model;
-import javax.jcr.Node; - -public interface ObjectDefinition extends Node +public interface ObjectDefinition extends Persistable {
}
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinitionProperty.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinitionProperty.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/ObjectDefinitionProperty.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -1,12 +1,6 @@ package org.xwiki.model;
-import javax.jcr.Node; - -/** - * Note: we cannot map an Object Definition Property to a JCR property since it has several properties such as - * validation script, edit sheet, etc. - */ -public interface ObjectDefinitionProperty extends Node +public interface ObjectDefinitionProperty extends Persistable {
}
Added: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Persistable.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Persistable.java (rev 0) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Persistable.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -0,0 +1,9 @@ +package org.xwiki.model; + +public interface Persistable +{ + // Note: All the other methods don't save. Need to call save() to save. For ex this allows to add several docs + // at once before saving them all at once. This allows for optimizations. + // Q: Should we use a more generic API? Like pass a Map<String, String>?
I don't think is really needed, we can always add support for a Map<String, String> latter.
+ void save(String comment, boolean isMinorEdit); +}
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Server.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Server.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Server.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -1,16 +1,14 @@ package org.xwiki.model;
+import org.xwiki.bridge.DocumentName; + import java.util.List;
-import javax.jcr.Repository; - -import org.xwiki.model.Wiki; - /** * An XWiki Server is made of one or several {@link org.xwiki.model.Wiki}s. This is the top most * object of the XWiki Model. */ -public interface Server extends Repository +public interface Server extends Persistable { /** * @return the list of all wiki names inside this Server @@ -24,4 +22,17 @@ void addWiki(Wiki wiki);
void removeWiki(String wikiName); + + boolean hasWiki(String wikiName); + + // Q: Should the methods below be moved into some other class, such as a DocumentQuery component which would + // be less generic than using the Query Manager?
Yes it's looks too much like a helper for something that should be in some generic query api to me. Or having something more generic, see at the end of the mail.
+ + // Q: Is this ok? + Document getDocument(DocumentName documentName); + + // Should we also have getSpace(SpaceName spaceName)? + + // Q: Is this ok? + boolean hasDocument(DocumentName documentName); }
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Space.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Space.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Space.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -2,12 +2,11 @@
import java.util.List;
-import javax.jcr.Node; - -public interface Space extends Node +public interface Space extends Persistable { /** * @return the space's description + * @todo Should not be implemented with the old model */ String getDescription();
@@ -16,13 +15,38 @@ */ List<Space> getSpaces();
+ /** + * @param spaceName the name of the nested space to look for + * @return the nested space whose name is passed as parameter + */ + Space getSpace(String spaceName); + + /** + * @todo Should not be implemented with the old model + */ void addSpace(String spaceName); - + + /** + * @todo Should not be implemented with the old model + */ + Space createSpace(String spaceName); + + /** + * @todo Should not be implemented with the old model + */ void removeSpace(String spaceName);
+ List<Document> getDocuments(); + + boolean hasSpace(String spaceName); + + boolean hasDocument(String shortDocumentName); + + Document getDocument(String shortDocumentName); + void addDocument(Document document);
- void removeDocument(String documentName); - - Document createDocument(String documentName); + void removeDocument(String shortDocumentName); + + Document createDocument(String shortDocumentName); }
Modified: contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Wiki.java =================================================================== --- contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Wiki.java 2009-12-11 17:03:01 UTC (rev 25767) +++ contrib/sandbox/xwiki-model/src/main/java/org/xwiki/model/Wiki.java 2009-12-12 15:02:21 UTC (rev 25768) @@ -2,17 +2,17 @@
import java.util.List;
-import javax.jcr.Workspace; - -import org.xwiki.model.Space; - -public interface Wiki extends Workspace +public interface Wiki extends Persistable { /** - * @return the list of all space names of this wiki including nested spaces + * @return the list of all space names in this wiki including nested spaces */ List<String> getSpaceNames();
+ /** + * @param spaceName the name of the space + * @return the object representing the space whose name is passed in parameter + */ Space getSpace(String spaceName);
Space createSpace(String spaceName); @@ -20,4 +20,6 @@ void addSpace(Space space);
void removeSpace(String spaceName); + + boolean hasSpace(String spaceName); }
_______________________________________________ notifications mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/notifications
Some quick comments about the model: * I think we should have something more generic that DocumentName that support anything from Wiki to objet or class property. Some WikiResourceName that target anything in XWiki and that you can use
or PersistableName actually, sounds better integrated in the api
with the query api. Then we can provide different parser/serializer for WikiResourceName (URIParser/serializer used in REST, WikiSyntaxParser/Serialize commonly used in the document content as link/attachment/image reference, etc...). * Persistable should maybe also contains something like copy() or clone(), we generally know what we are copying but having in at Persistable make sure this is posible for anything in the model tree
-- Thomas Mortagne
-- Thomas Mortagne