Re: [xwiki-devs] [xwiki-notifications] r25768 - in contrib/sandbox/xwiki-model: . src src/main src/main/java/org/xwiki/model
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 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
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
On Dec 12, 2009, at 4:46 PM, Thomas Mortagne 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
[...]
[snip]
- 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) ?
Re storage it means storing the content in a syntax indep way indeed, in some serialization format for Blocks (Having a table for each block type sounds way too complex - in order to load a given document's content you'd need to do tons of SQL queries). Note that storing in some serialized block format means faster load time since there's no need to perform syntax parsing. One pb with using syntax-indep storage though is that we need to migrate existing content to the new format. It also means some questions to support the 1.0 syntax since 1.0 syntax is rendered using the old rendering which doesn't know about XDOM blocks.
+ //String setContent(String content); + + boolean hasObject(String objectName); + + // Q: Is this ok? + DocumentName getDocumentName();
[snip]
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.
I agree. [snip]
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 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...).
+1 for XWikiResourceName, similar to what we already have in xwiki-url module: XWikiURL, XWikiDocumentURL, XWikiAttachmentURL, etc. So we can keep DocumentName and AttachmentName but transform them so that they extend WikiResourceName and create other names for Objects, Properties, etc. <brainstorm mode - Note: below you can replace Document with WikiResource everywhere> Re the Query API, yes we could probably find a way to reuse the existing API, for example by having DocumentQuery (implements Query), AttachmentQuery (implement Query), etc. So you'd write something like: Document document = (Document) new DocumentQuery(DocumentName).execute().get(0); It may still be slightly too complex (not sure) so we might still need to have some higher-level API, such as DocumentQueryManager.createQuery(DocumentName). Or maybe simply add a new method in DocumentQuery such as: Document DocumentQuery.getDocument(); That would give: Document document = new DocumentQuery(DocumentName).getDocument(); This is probably still too complex and we should use some singleton object instead of doing a new query every time... The name Query isn't nice too. So instead something like: class: WikiResourceFinder<T> method: T findResource(T resource); internally WikiResourceFinder could use the Query Manager to find the resource. <brainstorm mode>
* 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
+1 too Thanks -Vincent
On Sat, Dec 12, 2009 at 18:46, Vincent Massol <[email protected]> wrote:
On Dec 12, 2009, at 4:46 PM, Thomas Mortagne 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
[...]
[snip]
- 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) ?
Re storage it means storing the content in a syntax indep way indeed, in some serialization format for Blocks (Having a table for each block type sounds way too complex - in order to load a given document's content you'd need to do tons of SQL queries).
Note that storing in some serialized block format means faster load time since there's no need to perform syntax parsing.
One pb with using syntax-indep storage though is that we need to migrate existing content to the new format. It also means some questions to support the 1.0 syntax since 1.0 syntax is rendered using the old rendering which doesn't know about XDOM blocks.
Well we do have xwiki/1.0 parser, we could say it's enough for the new model API and the old one is still here if you really want to work with real xwiki/1.0. And I don't think we will refactor too quickly view velocity templates to use new model instead of XWikiDocument#getRenderedContent
+ //String setContent(String content); + + boolean hasObject(String objectName); + + // Q: Is this ok? + DocumentName getDocumentName();
[snip]
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.
I agree.
[snip]
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 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...).
+1 for XWikiResourceName, similar to what we already have in xwiki-url module: XWikiURL, XWikiDocumentURL, XWikiAttachmentURL, etc.
So we can keep DocumentName and AttachmentName but transform them so that they extend WikiResourceName and create other names for Objects, Properties, etc.
Sure. Note that we also need the WikiResourceName getName() at Peristable level overriden in Document, Wiki, etc.... with specialized types.
<brainstorm mode - Note: below you can replace Document with WikiResource everywhere> Re the Query API, yes we could probably find a way to reuse the existing API, for example by having DocumentQuery (implements Query), AttachmentQuery (implement Query), etc. So you'd write something like:
Document document = (Document) new DocumentQuery(DocumentName).execute().get(0);
It may still be slightly too complex (not sure) so we might still need to have some higher-level API, such as DocumentQueryManager.createQuery(DocumentName). Or maybe simply add a new method in DocumentQuery such as: Document DocumentQuery.getDocument();
That would give: Document document = new DocumentQuery(DocumentName).getDocument();
This is probably still too complex and we should use some singleton object instead of doing a new query every time... The name Query isn't nice too.
So instead something like:
class: WikiResourceFinder<T> method: T findResource(T resource);
internally WikiResourceFinder could use the Query Manager to find the resource. <brainstorm mode>
* 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
+1 too
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
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) ?
Actually this would introduce an important limitation compared to now: impossible to use a syntax for which no renderer is provided, which mean most of the others wiki syntaxes.
+ //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 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
participants (2)
-
Thomas Mortagne -
Vincent Massol