Mark:
That seemed, intuitively, to be the way that things were put together, and that's encouraging. However, I'm hoping that your claim that the xwiki objects give most of what I need is true, since that's as deep as I hope to have to get into it. Again, I'm acting as proxy to application developers here, so I need to be sure that this is all as easy as it seems.
In particular, the joins are hairy - a necessary consequence of the flexible object structure. And I'm still a bit confused about how to parse the results.
A use case is this: I have a document that I threw together quickly and easily that lists projects that I am responsible for. Being driven entirely from the objects on the page, it was easy to share, to the point that nearly everyone else who uses it simply uses #includeForm("Brian.WorkPages") - not a good idea from an organizational point of view, but wholly acceptable in a purely experimental environment. Each object on the page lists the name of the project, the name of the project's plan document, and its current status, due dates, etc. For terseness and convenience, I make the project name the text of a link to the project plan document. As success breeds success, I decided it was a really good way to report status to my boss, so I did two things: added a "journal entry" feature to each of the plan documents, which allowed me to add dated comments on document progress and status changes; and created another data-driven page which copied the data from the original page, followed the links to the plan pages, and displayed the project table again, then the journal entries for each one, with intra-page links from the status field text for convenience. In this way, I didn't need to make out a separate weekly status report for my boss; this page would show status at a glance, with links to more detailed information right at hand.
This was good, but two things were wrong: first, the projects were listed in the default order in which getObjects() listed them, which was the order of their creation; second, all the journal entries showed up. I wanted the projects to be listed in order by priority and/or due date, and to list journal entries from only the current week.
I had already seen that I could modify the WHERE clause in searchDocuments(), and used that to add options to Main.AllDocs to order by date or creator. but getObjects() gave me no such ability, so I had to use search(). And rather than futz around with trying to get the search results to fit the same wiki Object format, I followed another example and called getObject() with the objects' number fields, which was all I returned from the query. I could also have used getObjects with a list of objects, but I didn't think of it, and am still not sure I'd know the right way to turn the returned ArrayList into a Vector.
In short, the SQL wasn't hard; tying all the attributes to the BaseObject wasn't hard, when I wanted to do it, but for one thing, when I returned a BaseObject only, I wasn't able to find any of its properties attached to it at all, and none of the syntax that I expected to be able to use to request all fields worked - I suspect because the query schema is virtual and each field had to be specified. In other words, "select obj.* from BaseObject as obj, ..." was refused.
The other matter I asked about before was why I couldn't return an arbitrary expression as I could with SQL, even though the same expression had worked in a qualifier on the same query. I really wanted to ditch all the code I had written to figure out when one week ago was, and since it was already in my qualifier, I thought I'd return it also, but Hibernate didn't like that.
brain[sic]
-----Original Message-----
From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
Sent: Friday, March 24, 2006 11:14 PM
To: xwiki-users(a)objectweb.org
Subject: Re: HQL question (wasRE: [xwiki-users] SQL hair-pulling)
Hi Brian.
Sorry for the lack of clarity there, it was late in my part of the world.
This is my understanding of it in general, but I am sure someone can correct how it relates to xwiki along the way.
Hibernate hides the process of creating objects and populating them with data retrieved from the database.
The Java objects have an almost direct relationship to the database structure. The tables are represented by classes and the columns are represented by properties of the object.
So when an object is created, it already fully represents the table structure. This gives you the advantage of being able to describe the equivalent of SQL queries very simply by referring to their properties.
There are getters and setter for the properties so to select a particular item from the database all you have to do is "get" that property with the value you want.
Example: Instead of "SELECT * FROM foo WHERE id = '22'" you could just use something like ...
item = getSession().get(foo.id, '22');
This is the beautiful bit about it. "item" is now an object with all the data from that row of the table and you can adjust the properties with the setter methods.
Example: Instead of "UPDATE foo SET Name='New Name', Age='36' WHERE id='22'"
item.setName("New Name");
item.setAge("36");
getSession().update(item);
Note: When you want to update the database you just call method (eg update(item)) and your object returns all the current object properties to the appropriate row in the database.
So how does this relate to XWiki? The mapping of xwiki object to the MySQL database is in xwiki.hbm.xml. Using the hibernate query from the category field in the blog as an example.
Example: select prop.value from BaseObject as obj, StringProperty as prop where obj.className='Blog.Categories' and prop.id.id = obj.id and prop.id.name='name'
>From looking at the mapping I can see that "BaseObject" is of the class "com.xpn.xwiki.objects.BaseObject" and it is mapped to the table "xwikiobjects" in the database.
It is then aliased to "obj".
I can also see that the property "className" of "obj" is mapped to "XWO_CLASSNAME", "name" is mapped to "XWO_NAME" and "id" is mapped to "XWO_ID".
"StringProperty" is a joined subclass (hibernate returns all the subclasses automatically) and is mapped to "com.xpn.xwiki.objects.StringProperty" which relates to the table "xwikistrings". In that subclass "value" is mapped to "XWS_VALUE".
StringProperty is then aliased as prop.
So after all that, what we are trying to say is something to the effect of "give me a list object that is made up of the names of the categories".
Why do we have to do it like that? Because the data is described generically in the database schema and stored in 3 different places. To retrieve it you need to ask first to find the objects of the wiki defined class 'Blog.Categories' then you need to retrieve the properties related to those objects (in this case, only the strings) and then you want to list the values of those strings.
So the strength of XWiki is that you can create classes, instances of those classes and manipulate them through the wiki pages to represent almost anything. It also means that it is very independent of the backend (as shown by using HQSQL in the standalone version).
However, the drawback is that you need to understand clearly how your classes are put together because the data is spread across the database (Remember, your classes/objects that you have created are represented in the database by the generic BaseObject and its properties).
Getting back to using this info. I find mostly that the $xwiki, $request and $doc objects give you access via the api to most of what you need anyway without getting that deep into it.
Example: From the mapping file I can see that the string property "fullName" in class com.xpn.xwiki.doc.XWikiDocument (eg $doc or doc) relates to "XWD_FULLNAME" in the "xwikidoc" table.
So if I wanted to list all the different webspaces in my xwiki with the default page of "WebHome" I know that "doc" represents the "xwikidoc" table and "fullName" represents "XWD_FULLNAME" so I write the "where" part of the query as "doc.fullName like '%.WebHome'"
The searchDocuments method of $xwiki translates this as "select distinct doc.web, doc.name from com.xpn.xwiki.doc.XWikiDocument as doc where fullName like '%.WebHome'"
So you end up with a list as demonstrated below in a Velocity setting.
#set($whereclause = "doc.fullName like '%.WebHome'")
#set($mylist = $xwiki.searchDocuments($whereclause))
1.1 The list returned
\\$mylist
1.1 Individual items
#foreach ($item in $mylist)
#set($thisdoc = $xwiki.getDocument($item))
* $thisdoc.getFullName()
#end
Hope that wasn't too wandering and full of mistakes. It is just from poking around a bit inside so could be completely misguided. I look forward to comments.
Cheers,
Mark
On 25 Mar 2006, at 2:30 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
Okay; will do.
But I was just about to reply that if you omit the result-list ("select field, field, ...") then the returned value is the object type of the first object in the "from" list. Exactly what I wanted, and it sounds like what you were describing, but your examples didn't show it.
brain[sic]
-----Original Message-----
From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
Sent: Friday, March 24, 2006 11:35 AM
To: xwiki-users(a)objectweb.org
Subject: Re: HQL question (wasRE: [xwiki-users] SQL hair-pulling)
Hi Brian.
Check this thread out.
http://mail-archive.objectweb.org/xwiki-dev/2005-11/msg00031.html
Cheers,
Mark
On 25 Mar 2006, at 12:57 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
Huh...
Sounds intriguing, but I'm puzzled about a lot of details, like:
how do you do that?
Probably an example would be very useful. Do you have one handy?
brain[sic]
-----Original Message-----
From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
Sent: Friday, March 24, 2006 10:48 AM
To: xwiki-users(a)objectweb.org
Subject: Re: HQL question (wasRE: [xwiki-users] SQL hair-pulling)
It seems to be like ADODB, forget about query strings. Create an
object. Set variables, indicate the relationships (eg joins) and call
the method fpr retrieving the data.
Result data as an object. Updates are a breeze.
Cheers,
Mark
On 25 Mar 2006, at 12:32 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
Would this perhaps be why I can't use an arbitrary expression as a
result field?
Specifically, my query for objects less than a week old used the SQL
expression:
subdate(curdate(), 7)
which worked fine when used in a comparison to a date field in the
WHERE clause, but provoked an error when I tried to use it in the
column-list, which is (I believe) clearly legal SQL syntax. If this
were a feature that HQL simply didn't support, it would explain the
problem. Indeed, that is what the error message seems to say:
Error number 4001 in 4: Error while parsing velocity page
Brian.WorkPagesTest Wrapped Exception: Invocation of method 'search'
in class com.xpn.xwiki.api.XWiki threw exception class
com.xpn.xwiki.XWikiException : Error number 3223 in 3: Exception
while searching documents with sql select subdate(curdate(), 7),
prop.value, [...] where [...] or subdate(curdate(), 7) <=
prop.value ) [...]
Wrapped Exception: No data type for node:
org.hibernate.hql.ast.MethodNode
+-METHOD_CALL? MethodNode: '('
| +-METHOD_NAME? IdentNode: 'subdate' {originalText=subdate}
| -EXPR_LIST? SqlNode: 'exprList'
| +-METHOD_CALL? MethodNode: '('
| | +-METHOD_NAME? IdentNode: 'curdate' {originalText=curdate}
| | -EXPR_LIST? SqlNode: 'exprList'
| -NUM_INT? LiteralNode: '7'
brain[sic]
-----Original Message-----
From: jeremi joslin [mailto:jeremi23@gmail.com]
Sent: Thursday, March 23, 2006 10:47 PM
To: xwiki-users(a)objectweb.org
Subject: Re: [xwiki-users] SQL hair-pulling
Yes, XWiki is using hibernate for the database mapping. So it's not
a sql query, but a hql query. You use the objects and members name to
make the request. (if you don't know the hql, you can take a look to
the hibernate documentation :
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/
#queryhql)
Jérémi
--
You receive this message as a subscriber of the xwiki-
users(a)objectweb.org mailing list. To unsubscribe:
mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/
wws
--
You receive this message as a subscriber of the xwiki-
users(a)objectweb.org mailing list.
To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/
wws
--
You receive this message as a subscriber of the xwiki-users(a)objectweb.org mailing list.
To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
I'm having a problem registering new users.
I get the following error. What does the -1 code mean? Its not very helpful.
An error occured during the registration process (-1).
Robin
Hello All,
My xWiki is beginning to get a lot of comment spamming; is there a way to
force a user to enter some random value displayed in an image, or to send me
an e-mail, etc? I would prefer the site to send me an e-mail anytime a new
comment is added anywhere; at least this would be a good start.
Anyone have any ideas?
Bob Mixon
Microsoft SharePoint Portal Server MVP
<mailto:bob.mixon@gmail.com> bob.mixon(a)gmail.com
Skype ID: brm1999
http://bobmixon.xwiki.com
KM, BPM, Intranet and Portal Technologies
The Possibilities are Endless
Hi All.
Has anyone played with accessing the graphviz plugin from Velocity?
I have managed to get it creating graphs from my objects and
displaying with various options, but I seem to be stumbling on the
last step of adding client side image maps to allow the user to drill
down easily.
The problem is that if I call $xwiki.graphviz.outputDotImage($graph,
"cmapx", true) it will only render the mapping file (which I need)
instead of the whole page so I am assuming I have to call
$xwiki.graphviz.getDotImage($graph, "cmapx", true) and then display
it. I have also tried to write it, then access it via
$xwiki.getExternalURL() but no go.
It works as expected when you retrieve it from a separate file, but
not on the fly. Just a reference returned that doesn't seem to
respond to Name or Value methods.
Example below:
#set($graph = 'digraph abstract {"Node 1"[URL=WebHome];"Node
2"[URL=WebHome]; "Node 1" -> "Node 2";}')
#set($graphfilename = $xwiki.graphviz.writeDotImage($graph, "jpg",
true))
<img src="/xwiki/bin/dot/$doc.web/$doc.name/$graphfilename"
usemap="#abstract">
#set($graphmap = $xwiki.graphviz.getDotImage($graph, "cmapx", true))
$graphmap
Any suggestions are gratefully accepted.
Cheers,
Mark
Okay; will do.
But I was just about to reply that if you omit the result-list ("select field, field, ...") then the returned value is the object type of the first object in the "from" list. Exactly what I wanted, and it sounds like what you were describing, but your examples didn't show it.
brain[sic]
-----Original Message-----
From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
Sent: Friday, March 24, 2006 11:35 AM
To: xwiki-users(a)objectweb.org
Subject: Re: HQL question (wasRE: [xwiki-users] SQL hair-pulling)
Hi Brian.
Check this thread out.
http://mail-archive.objectweb.org/xwiki-dev/2005-11/msg00031.html
Cheers,
Mark
On 25 Mar 2006, at 12:57 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
> Huh...
>
> Sounds intriguing, but I'm puzzled about a lot of details, like:
> how do you do that?
>
> Probably an example would be very useful. Do you have one handy?
>
> brain[sic]
>
> -----Original Message-----
> From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
> Sent: Friday, March 24, 2006 10:48 AM
> To: xwiki-users(a)objectweb.org
> Subject: Re: HQL question (wasRE: [xwiki-users] SQL hair-pulling)
>
>
> It seems to be like ADODB, forget about query strings. Create an
> object. Set variables, indicate the relationships (eg joins) and call
> the method fpr retrieving the data.
>
> Result data as an object. Updates are a breeze.
>
> Cheers,
>
> Mark
>
> On 25 Mar 2006, at 12:32 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
>
>> Would this perhaps be why I can't use an arbitrary expression as a
>> result field?
>>
>> Specifically, my query for objects less than a week old used the SQL
>> expression:
>>
>> subdate(curdate(), 7)
>>
>> which worked fine when used in a comparison to a date field in the
>> WHERE clause, but provoked an error when I tried to use it in the
>> column-list, which is (I believe) clearly legal SQL syntax. If this
>> were a feature that HQL simply didn't support, it would explain the
>> problem. Indeed, that is what the error message seems to say:
>>
>> Error number 4001 in 4: Error while parsing velocity page
>> Brian.WorkPagesTest Wrapped Exception: Invocation of method 'search'
>> in class com.xpn.xwiki.api.XWiki threw exception class
>> com.xpn.xwiki.XWikiException : Error number 3223 in 3: Exception
>> while searching documents with sql select subdate(curdate(), 7),
>> prop.value, [...] where [...] or subdate(curdate(), 7) <=
>> prop.value ) [...]
>> Wrapped Exception: No data type for node:
>> org.hibernate.hql.ast.MethodNode
>> +-METHOD_CALL? MethodNode: '('
>> | +-METHOD_NAME? IdentNode: 'subdate' {originalText=subdate}
>> | -EXPR_LIST? SqlNode: 'exprList'
>> | +-METHOD_CALL? MethodNode: '('
>> | | +-METHOD_NAME? IdentNode: 'curdate' {originalText=curdate}
>> | | -EXPR_LIST? SqlNode: 'exprList'
>> | -NUM_INT? LiteralNode: '7'
>>
>> brain[sic]
>> -----Original Message-----
>> From: jeremi joslin [mailto:jeremi23@gmail.com]
>> Sent: Thursday, March 23, 2006 10:47 PM
>> To: xwiki-users(a)objectweb.org
>> Subject: Re: [xwiki-users] SQL hair-pulling
>> Yes, XWiki is using hibernate for the database mapping. So it's not
>> a sql query, but a hql query. You use the objects and members name to
>> make the request. (if you don't know the hql, you can take a look to
>> the hibernate documentation :
>> http://www.hibernate.org/hib_docs/v3/reference/en/html_single/
>> #queryhql)
>>
>> Jérémi
>>
>>
>> --
>> You receive this message as a subscriber of the xwiki-
>> users(a)objectweb.org mailing list. To unsubscribe:
>> mailto:xwiki-users-unsubscribe@objectweb.org
>> For general help: mailto:sympa@objectweb.org?subject=help
>> ObjectWeb mailing lists service home page: http://www.objectweb.org/
>> wws
>
>
>
>
> --
> You receive this message as a subscriber of the xwiki-
> users(a)objectweb.org mailing list.
> To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
> For general help: mailto:sympa@objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/
> wws
As demonstrated by this page
http://www.xwiki.org/xwiki/bin/view/Sandbox/includeOwnRSS
the XWiki feed parser plugin appears to fall over when parsing a feed
generated by XWiki. Other parsers have no problems.
The the stack trace isn't reported with the error so it's a bit hard
to see exactly what's going wrong... though I guess it's failing in
FeedPlugin.getFeedForce(..). I thought it might be a formatting
problem in the rdf template, exposing some fragility in the parser...
However, invoking rome as follows (using rome 0.7) works fine:
public class Feedread {
public static void main(String[] args) throws
IllegalArgumentException, IOException, FeedException, FetcherException
{
//
FeedFetcher feedFetcher = new HttpURLFeedFetcher();
URL feedURL = new
URL("http://www.xwiki.org/xwiki/bin/view/Main/WebRss?xpage=rdf");
SyndFeed feed = feedFetcher.retrieveFeed(feedURL);
feedFetcher.setUserAgent("XWikiBot");
System.out.println(feed);
}
}
So I'm not sure what's breaking when this happens inside XWiki.
The reason want to do this is that on my xwiki homepage I'd like to
include a bunch of feeds, some external, some from the wiki itself. It
would make my life easier if I could use my same macro to display them
all, rather than using the feed plug for the external ones, and direct
hql queries for the local ones.
Regards,
Robin
Can someone provide information on how RSS feeds and the Xwiki cache
system work together?
What's known so far.
1) The xwiki/WEB-INF/xwiki.cfg file contains the following lines
xwiki.store.cache=1
xwiki.store.cache.capacity=100
2) Based on the build.xml file included in the source, xwiki is
configured to use ehcache-1.1, oscache-2.0.2, and swarmcache.
3) grep results on source files indicate that OSCache is being used by
Xwiki.
Questions
4) Does item 1) mean caching is enabled for RSS feeds?
5) Does "xwiki.store.cache.capacity=100" relate to OSCache's
"cache.capacity" configuration property? Are they the same? See the
following URL
http://wiki.opensymphony.com/display/CACHE/Configuration
6) Please confirm that OSCache is being used by Xwiki 0.9.840 for RSS
feeds
That's enough, for now and thanks for any help you can provide.
Rex Kidwell
Hi,
Trying to view/preview any page on free xwiki.com hosted containing the text:
select x into y
causes nothing more than the following message to be displayed:
We are currently doing performance maintenance of our servers. The
service will be back in a few minutes. Sorry for the inconvenience.
'x' and 'y' can be any number of words. Note that this happens with
plain text - no velocity or anything, e.g. simply a document
containing the text:
Press the 'add' button to select which plugin is loaded into the
current effect slot.
I haven't raised this as bug on JIRA since I can't reproduce it
outside of xwiki.com hosted wikis. So I guess it's some configuration
issue or some extra protection gone wrong on xwiki.com.
Thanks,
Robin.
Hi all!
I'm a newbie in XWiki application development and I'm trying to make
sense of these plugins. I tried with the IPResolverPlugin which looks
quite simple but I don't know how to access it from the Velocity
context. Is this possible at least?
Thanks a lot!
--
_ _ Julien Bourdon
(o)(o)--. http://purl.org/net/JulienBourdon
\../ ( ) self isAddictedTo:(#Squeak&#linux)
m\/m--m'`--. ^true
Hi,
just testing the LDAP integration on a development build (head). I do
manage to authenticate against my LDAP server and I'm logged in
afterwards, but the username is not displayed (only:
$docuser.display("first_name", "view", $objuser)) and somehow I'm not
really "logged in". I don't have the permissions I normally have, when
I'm a logged in user.
Do I have to do anything extra for the LDAP integration? Do I have to
create each user which exists in ldap also in the xwiki db? (this
apparently works..) Below my xwiki.cfg
Christian
xwiki.cfg for ldap:
xwiki.authentication.ldap=1
xwiki.authentication.ldap.server=enron
xwiki.authentication.ldap.check_level=1
xwiki.authentication.ldap.base_DN=dc=LogicUnited,dc=Com
xwiki.authentication.ldap.bind_DN=cn=Manager,dc=logicunited,dc=com
xwiki.authentication.ldap.bind_pass=****
xwiki.authentication.ldap.UID_attr=uid
xwiki.authentication.ldap.fields_mapping=name=uid,last_name=sn,first_name=givenName,fullname=cn,mail=mail,ldap_dn=dn
--
------------------------------------------
Logic United GmbH
Email: leeden(a)logicunited.com
Tel: +49-89-189488-66
Huh...
Sounds intriguing, but I'm puzzled about a lot of details, like: how do you do that?
Probably an example would be very useful. Do you have one handy?
brain[sic]
-----Original Message-----
From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
Sent: Friday, March 24, 2006 10:48 AM
To: xwiki-users(a)objectweb.org
Subject: Re: HQL question (wasRE: [xwiki-users] SQL hair-pulling)
It seems to be like ADODB, forget about query strings. Create an
object. Set variables, indicate the relationships (eg joins) and
call the method fpr retrieving the data.
Result data as an object. Updates are a breeze.
Cheers,
Mark
On 25 Mar 2006, at 12:32 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
> Would this perhaps be why I can't use an arbitrary expression as a
> result field?
>
> Specifically, my query for objects less than a week old used the
> SQL expression:
>
> subdate(curdate(), 7)
>
> which worked fine when used in a comparison to a date field in the
> WHERE clause, but provoked an error when I tried to use it in the
> column-list, which is (I believe) clearly legal SQL syntax. If
> this were a feature that HQL simply didn't support, it would
> explain the problem. Indeed, that is what the error message seems
> to say:
>
> Error number 4001 in 4: Error while parsing velocity page
> Brian.WorkPagesTest
> Wrapped Exception: Invocation of method 'search' in class
> com.xpn.xwiki.api.XWiki threw exception class
> com.xpn.xwiki.XWikiException : Error number 3223 in 3: Exception
> while searching documents with sql select subdate(curdate(), 7),
> prop.value, [...] where [...] or subdate(curdate(), 7) <=
> prop.value ) [...]
> Wrapped Exception: No data type for node:
> org.hibernate.hql.ast.MethodNode
> +-METHOD_CALL? MethodNode: '('
> | +-METHOD_NAME? IdentNode: 'subdate' {originalText=subdate}
> | -EXPR_LIST? SqlNode: 'exprList'
> | +-METHOD_CALL? MethodNode: '('
> | | +-METHOD_NAME? IdentNode: 'curdate' {originalText=curdate}
> | | -EXPR_LIST? SqlNode: 'exprList'
> | -NUM_INT? LiteralNode: '7'
>
> brain[sic]
> -----Original Message-----
> From: jeremi joslin [mailto:jeremi23@gmail.com]
> Sent: Thursday, March 23, 2006 10:47 PM
> To: xwiki-users(a)objectweb.org
> Subject: Re: [xwiki-users] SQL hair-pulling
> Yes, XWiki is using hibernate for the database mapping. So it's
> not a sql query, but a hql query. You use the objects and members
> name to make the request. (if you don't know the hql, you can take
> a look to the hibernate documentation :
> http://www.hibernate.org/hib_docs/v3/reference/en/html_single/
> #queryhql)
>
> Jérémi
>
>
> --
> You receive this message as a subscriber of the xwiki-
> users(a)objectweb.org mailing list.
> To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
> For general help: mailto:sympa@objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/
> wws
Would this perhaps be why I can't use an arbitrary expression as a result field?
Specifically, my query for objects less than a week old used the SQL expression:
subdate(curdate(), 7)
which worked fine when used in a comparison to a date field in the WHERE clause, but provoked an error when I tried to use it in the column-list, which is (I believe) clearly legal SQL syntax. If this were a feature that HQL simply didn't support, it would explain the problem. Indeed, that is what the error message seems to say:
Error number 4001 in 4: Error while parsing velocity page Brian.WorkPagesTest
Wrapped Exception: Invocation of method 'search' in class com.xpn.xwiki.api.XWiki threw exception class com.xpn.xwiki.XWikiException : Error number 3223 in 3: Exception while searching documents with sql select subdate(curdate(), 7), prop.value, [...] where [...] or subdate(curdate(), 7) <= prop.value ) [...]
Wrapped Exception: No data type for node: org.hibernate.hql.ast.MethodNode
+-METHOD_CALL? MethodNode: '('
| +-METHOD_NAME? IdentNode: 'subdate' {originalText=subdate}
| -EXPR_LIST? SqlNode: 'exprList'
| +-METHOD_CALL? MethodNode: '('
| | +-METHOD_NAME? IdentNode: 'curdate' {originalText=curdate}
| | -EXPR_LIST? SqlNode: 'exprList'
| -NUM_INT? LiteralNode: '7'
brain[sic]
-----Original Message-----
From: jeremi joslin [mailto:jeremi23@gmail.com]
Sent: Thursday, March 23, 2006 10:47 PM
To: xwiki-users(a)objectweb.org
Subject: Re: [xwiki-users] SQL hair-pulling
Yes, XWiki is using hibernate for the database mapping. So it's not a sql query, but a hql query. You use the objects and members name to make the request. (if you don't know the hql, you can take a look to the hibernate documentation :
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql)
Jérémi
Jérémi:
Aha! I should have read my mail before sending my last note, which I began composing last night. That clears a lot of the mystery. I will save my other questions until after I've read your reference; thank you.
But it re-raises for me the issue I had thought resolved - that of where the boundary of queryability may be. I had assumed that it was the same as the boundary of the XWiki-defined object model, as it would seem logically if it had to be supported as a database map, but since it's a general-purpose persistence tool, might that assumption be wrong? Probably, any queryable object would have to be modeled in the database, but it's a grey area in my understanding. I do note that date fields are returned as java.sql.Timestamp rather than as java.util.Date, in case that has any bearing on the matter.
brain[sic]
-----Original Message-----
From: jeremi joslin [mailto:jeremi23@gmail.com]
Sent: Thursday, March 23, 2006 10:47 PM
To: xwiki-users(a)objectweb.org
Subject: Re: [xwiki-users] SQL hair-pulling
On 3/24/06, THOMAS, BRIAN M (SBCSI) <bt0008(a)att.com> wrote:
> As mentioned in an earlier message, I got into the $xwiki.search()
> world yesterday, and am thoroughly confused.
>
> The main problem seems to be that the XWiki database schema and the
> schema used in all of the $xwiki.search() queries I have found are
> completely disjoint.
>
> Instead of the documented tables and columns, what seems to be used is
> a schema which reflects the object model within XWiki. This would
> really be convenient if true; is it?
Hi,
Yes, XWiki is using hibernate for the database mapping. So it's not a sql query, but a hql query. You use the objects and members name to make the request. (if you don't know the hql, you can take a look to the hibernate documentation :
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql)
Jérémi
--
Blog: http://www.jeremi.info
LinkedIn: https://www.linkedin.com/profile?viewProfile=&key=1437724
Project Manager XWiki: http://www.xwiki.org
skype: jeremi23 -- msn et gtalk : jeremi23(a)gmail.com
As mentioned in an earlier message, I got into the $xwiki.search() world
yesterday, and am thoroughly confused.
The main problem seems to be that the XWiki database schema and the
schema used in all of the $xwiki.search() queries I have found are
completely disjoint.
Instead of the documented tables and columns, what seems to be used is a
schema which reflects the object model within XWiki. This would really
be convenient if true; is it?
brain[sic]
>As mentioned in an earlier message, I got into the $xwiki.search() world
>yesterday, and am thoroughly confused.
>
>The main problem seems to be that the XWiki database schema and the
>schema used in all of the $xwiki.search() queries I have found are
>completely disjoint.
>
>Instead of the documented tables and columns, what seems to be used is a
>schema which reflects the object model within XWiki. This would really
>be convenient if true; is it?
This is right.
Bye
Frank
Hi All.
This is probably most appropriate to Jeremi, but I would appreciate
anyones thoughts on the subject.
XWiki is a phenomenal piece of software that I am thinking of new
uses every day.
I am currently running 0.9.840 on one of my servers and am a little
bit paranoid about upgrading until later in the year, as our
application is growing at a furious rate and I would like it to
stabilise a little before we go through an upgrade. However, some
of the new features are very tempting (I am using the standalone for
testing).
Ideally I would like to use your XWiki/ImportExport script to create
user configurable exports on the existing data and was wondering how
involved the underlying adjustments would be to the code to make it
work with the stable version.
The script looks for $export. Is this a java class that is put into
a xwiki context in the later release?
If so, is it self sufficient enough to compile and add to an existing
installation, or is it too dependent on other code in the later version?
With custom java classes, is there a straight forward description
somewhere on putting them in an XWiki context so they can be used by
Velocity?
In a mildly related point: I have deployed DWR (https://
dwr.dev.java.net/) side by xwiki in another testing installation for
some AJAX experimentation and it seems to be co-habiting without too
much trouble.
Apologies for the basic questions, but I am currently on a steep
learning curve with this and appreciate any help offerred.
Have a great day.
Mark.
Hi all,
I try to print future events in the left menus, but it looks that the test
of the event start date is always evaluated to false.
#foreach($event in
$xwiki.getDocument("Main.EventCalendar").getObjects("XWiki.CalendarEvent"))
#if ($event.getStartDate().getTime().after($xwiki.getDate()))
$event.startDate $event.endDate $event.description
#end
#end
Any idea or suggestion?
Regards,
Gaël Blondelle
EBM WebSourcing
Jérémi:
You make it look easy, but it took me a good long bit of searching and trial-and-error investigation to figure out how to get a real Date object out of an XWiki object field.
And you perform a little leger-de-main which I have not found explained anywhere: the expression $obj.XWikiObject.date.value is equivalent to $obj.XWikiObject.getDateValue("date"). Unfortunately, this is not suitable for use as an lvalue, but it makes a nice shorthand. Is this documented anywhere (other than in the source)?
I noted the same thing when I found, in some sample code, a call to a (seemingly) nonexistent method $xwiki.getCalendar(). Happily, simply writing $xwiki.calendar in a document yielded an object identifier containing the classname com.xpn.xwiki.plugin.calendar.CalendarAPI, so it seems that XWiki was fiddling my call into $xwiki.get("calendar"), which is documented to return a plugin API, which before this had meant nothing to me (either that, or the plugin augmented com.xpn.xwiki.api.XWiki with a getCalendar() method, which is what I thought before I saw the above).
Velocity, of course, turns any rvalue reference to $obj.foo into a call to $obj.getFoo() or $obj.getfoo(), and likewise any lvalue reference in a #set into a call to $obj.set[Ff]oo() with the RHS as its argument. But this trick is different, because at least in the first case it has to know the navigation of a particular XWiki-specific class hierarchy.
Nice shorthand; would be nicer if it were explained somewhere... Okay, I'll do it...
By the way, that $xwiki.calendar property finally got me to an answer to my date arithmetic problem, thanks to Java reflection.
The task was in a project status reporting page, where I wanted to ignore records more than a week old. The problem was that I could find no way at all to do date arithmetic in a Velocity script, because the time value returned from java.util.Date.getTime() is a long integer, which (until the next release of Velocity, at least) can't be used in an arithmetic expression. I could have used the Date functions to format a date, manipulate the string version, and then parse it, but that would be far too difficult, inflexible, and error-prone even ignoring the fact that those methods were deprecated. It works like this, for those who are interested:
First, $xwiki.calendar has a method getCalendar() which, in the version without arguments, returns a java.util.Calendar initialized with the current date. Because it inherits from java.lang.Object, it is Cloneable, so I clone()d it to get a copy that I could set back seven days, without disturbing the original object (I learned this the hard way: the returned object was a reference, and changes via the copied reference changed the original).
Turning back the clock in a java.util.Calendar by seven days is quite simple in Java - formally speaking, it's java.util.Calendar.add(java.util.Calendar.DAY_OF_YEAR, -7). However, this isn't Java exactly; we can call the add() method easily enough, because we have a Calendar object, but that DAY_OF_YEAR symbolic constant isn't accessible that way, because apparently Velocity doesn't translate field references, only method calls. The final expression was $xwiki.calendar.calendar.class.getField("DAY_OF_YEAR").int
#set($wcal = $xwiki.calendar.calendar.clone()) ## copy of java.util.Calendar with current time
$wcal.add($wcal.class.getField("DAY_OF_YEAR").int, -7) ## set the calendar back one week.
#set($weekago = $wcal.time) ## get the resulting date as a java.util.Date object
After this, when I wanted to see whether date "donedate" from an object was more than a week old, I wrote something like this:
#set($weekold = $obj.xWikiObject.donedate.value.before($weekago))
which worked just fine.
Of course, since I also wanted to sort those records on other than the default field, I needed to do an $xwiki.search() call with a custom query, and SQL can easily do date arithmetic.
That brings up another topic, because I was foolish enough to try it...
brain[sic]
-----Original Message-----
From: jeremi joslin [mailto:jeremi23@gmail.com]
Sent: Wednesday, March 22, 2006 8:25 AM
To: xwiki-users(a)objectweb.org
Subject: Re: [xwiki-users] Date value compare
On 3/22/06, jjanssen(a)nl.swets.com <jjanssen(a)nl.swets.com> wrote:
> Hello,
>
> I've got several classes in which I use date attributes. Is there a
> way to list objects of such a class, but only those in which the value
> of the date attribute is before current date?
I do it a while ago using the before function:
#if ($obj.XWikiObject.date.value.before($xwiki.getCurrentDate()))
Jérémi
--
Blog: http://www.jeremi.info
LinkedIn: https://www.linkedin.com/profile?viewProfile=&key=1437724
Project Manager XWiki: http://www.xwiki.org
skype: jeremi23 -- msn et gtalk : jeremi23(a)gmail.com
hello everybody,
I spent the morning creating an xWiki page called MyTutorials. The link name was Main.MyTutorials
I finished up by adding a new News Item to my blog, the Page Name unfortunately was also MyTutorials.
Now when I try to link to the work I did this morning I just get the Blog news item.
Please can someone assist. I cant even find the pages I created that link from my MyTutorials page.
Thanks
Scott.
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
Hello,
I've got several classes in which I use date attributes. Is there a way to list objects of such a class, but only those in which the value of the date attribute is before current date?
Thanks again,
Joep Janssen
Dear xwiki developers,
first of all, thanks for XWiki, which is really an awesome
tool and one of the most advanced Wikis I know of.
I have a problem attaching a skin to a space via the
webpreferences of the space.
What I did:
1. I created an empty page XWiki.WebpageSkin and
attached a new objekt also called "XWiki.WebpageSkin"
of class XWiki.XWikiSkins.
I removed all contents from the "style" box and entered
"THIS IS THE HEADER" into the header box, just to see,
if the skin is used or not.
2. I testet the skin by appending ?skin=XWiki.WebpageSkin and
to a page and this worked fine.
3. I edited the Main webpreferences (via More Actions/Space
Preferences on Main.WebHome) and entered "XWiki.WebpageSkin"
in the "skin" box.
But this did not take effect.
When I did the same for the XWiki preferences (instead of the
space preferences), it did work properly, but for all spaces,
of course.
What did I do wrong? How can I configure different skins for
different spaces?
Any help would be highly appreciated
& thanks a lot in advance
& best
Lars
Hello,
In my wiki I've got several classes which objects I want to list, only when an Integer attribute is > or < then a certain value. However something like: #if($duration < 10), doesn't work. Anybody any ideas?
Thanks again,
Joep Janssen