Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-21 Thread Tjaart van Wijck
Thanks, these are extremely helpful comments.

On 21/04/2008, Sergiu Dumitriu <[EMAIL PROTECTED]> wrote:
> Tjaart van Wijck wrote:
>  > a) A class definition is essentially a special type of wiki page that
>  > defines the class structure (i.e. properties).
>
>
> Yes, but here "special" means just that it contains a class definition,
>  as otherwise nothing makes it "special". Any document can host a class,
>  just add property definitions to it.
>
>
>  > b) No more than 1 class definition can be contained in this special type of
>  > page.
>
>
> Yes. In the future this _might_ not be true, but there are no plans in
>  that direction.
>
>
>  > c) Objects are instances of these classes and must be associate with a 
> page.
>  > (Can a single object be associated with more than 1 page?)
>
>
> Yes. One object resides in only one page, so you cannot associate it
>  with more than one page directly. You can, however, define another class
>  with a DBList property listing the existing objects, and you can then
>  attach that type of "linking" object to other pages.
>
>
>  > d) Multiple objects can be associated with a wiki page.
>
>
> Yes, from the same or different classes.
>
>
>  > e) An HQL query iterates through the wiki pages, through each object in 
> each
>  > page and each property in each object
>
>
> Only if you write the query in this manner. Basically HQL is not
>  something XWiki invented, it is the standard Hibernate Query Language,
>  which is an object retrieval QL. So it behaves like any query language,
>  with the SELECT, FROM and WHERE sub-clauses. But you are right, meaning
>  that you can use in the FROM part documents, objects and properties, and
>  you can link them using "obj.name = doc.fullName" and "prop.id.id =
>  obj.id". You can use more than one property/object/document in the query
>  (I once got to write queries with something around 30 properties in the
>  same query, which I later had to split into 2 queries as mysql has a
>  limit on the number of JOINs you can have).
>
>
>  > d) An HQL query specifying page/document constraints returns a Java List of
>  > documents
>
>
> No, unless you use $xwiki.search("select doc from..."). The standard
>  $xwiki.searchDocuments returns a java list of document names. You then
>  have to use $xwiki.getDocument($item) or $xwiki.wrapDocs($results) to
>  get Document API objects (which are different from the internal
>  XWikiDocument objects)
>
>
>  > e) An HQL query specifying object constraints returns a Java List of 
> objects
>  > (does not seem to be the case from the above code?!)
>
>
> Yes, if you're using $xwiki.search("select obj from BaseObject obj...").
>  Still, this is the internal com.xpn.xwiki.objects.BaseObject class, and
>  not the API usually accessed from scripts, which is
>  com.xpn.xwiki.api.Object. This is why your script does not _seem_ to
>  work, as you're using API methods on the privileged object.
>
>
>  > f) An HQL query specifying property constraints returns a Java List of
>  > properties
>
>
> Yes, if you're using $xwiki.search("select prop from StringProperty
>  prop...") (replace with other property type).
>
> --
>  Sergiu Dumitriu
>  http://purl.org/net/sergiu/
>
>  ___
>
> users mailing list
>  users@xwiki.org
>  http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-21 Thread Sergiu Dumitriu
Tjaart van Wijck wrote:
> a) A class definition is essentially a special type of wiki page that
> defines the class structure (i.e. properties).

Yes, but here "special" means just that it contains a class definition, 
as otherwise nothing makes it "special". Any document can host a class, 
just add property definitions to it.

> b) No more than 1 class definition can be contained in this special type of
> page.

Yes. In the future this _might_ not be true, but there are no plans in 
that direction.

> c) Objects are instances of these classes and must be associate with a page.
> (Can a single object be associated with more than 1 page?)

Yes. One object resides in only one page, so you cannot associate it 
with more than one page directly. You can, however, define another class 
with a DBList property listing the existing objects, and you can then 
attach that type of "linking" object to other pages.

> d) Multiple objects can be associated with a wiki page.

Yes, from the same or different classes.

> e) An HQL query iterates through the wiki pages, through each object in each
> page and each property in each object

Only if you write the query in this manner. Basically HQL is not 
something XWiki invented, it is the standard Hibernate Query Language, 
which is an object retrieval QL. So it behaves like any query language, 
with the SELECT, FROM and WHERE sub-clauses. But you are right, meaning 
that you can use in the FROM part documents, objects and properties, and 
you can link them using "obj.name = doc.fullName" and "prop.id.id = 
obj.id". You can use more than one property/object/document in the query 
(I once got to write queries with something around 30 properties in the 
same query, which I later had to split into 2 queries as mysql has a 
limit on the number of JOINs you can have).

> d) An HQL query specifying page/document constraints returns a Java List of
> documents

No, unless you use $xwiki.search("select doc from..."). The standard 
$xwiki.searchDocuments returns a java list of document names. You then 
have to use $xwiki.getDocument($item) or $xwiki.wrapDocs($results) to 
get Document API objects (which are different from the internal 
XWikiDocument objects)

> e) An HQL query specifying object constraints returns a Java List of objects
> (does not seem to be the case from the above code?!)

Yes, if you're using $xwiki.search("select obj from BaseObject obj..."). 
Still, this is the internal com.xpn.xwiki.objects.BaseObject class, and 
not the API usually accessed from scripts, which is 
com.xpn.xwiki.api.Object. This is why your script does not _seem_ to 
work, as you're using API methods on the privileged object.

> f) An HQL query specifying property constraints returns a Java List of
> properties

Yes, if you're using $xwiki.search("select prop from StringProperty 
prop...") (replace with other property type).
-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-21 Thread Sergiu Dumitriu
Tjaart van Wijck wrote:
> Guillaume,
> 
> That worked! Thanks a lot for the help.
> 
> Yet, I still don't understand why the HQL string below does not yield
> the correct results:
> $query = "select obj from BaseObject obj where
> obj.className='Contacts.ContactClass'"
> 
> Can someone explain how XWiki traverses documents and objects to
> generate the resultset when executing HQL statements?

$xwiki.selectDocuments is a "safe" method, because it allows to select 
only document names. $xwiki.search is a "privileged" method, because it 
allows a user to retrieve ANYTHING from the database, even data he might 
not have access to, like private documents or user emails or passwords 
(fortunately the passwords are not stored in plaintext in the database, 
so that is not an issue, but simple passwords could be cracked using 
brute force dictionary attacks). For this reason $xwiki.search requires 
programming rights, and is not the recommended method for retrieving 
information.

This is why your query does not work:

$xwiki.search("select obj from BaseObject obj...") will return what you 
told it to select: instances of BaseObject, which is the privileged 
com.xpn.xwiki.objects.BaseObject class, privileged as in "it should not 
be exposed to the scripting world". However, since you're already using 
a privileged method to retrieve them, that is not a problem by itself 
anymore. But these objects have different methods than the object API 
which is regularly used in velocity scripts, located in 
com.xpn.xwiki.api.Object, so $item.get does not work because it is not a 
method of that object. When you see that a method that is supposed to 
work doesn't, like was the case with your $item.get, then either the 
object is null, or has a different type than you expect it to be. What 
you should do in this case is try to see what's wrong, and you do this 
by writing:

$item $item.class

This will print either $item, if it is null, or something for $item 
followed by the real class name. You then go to that class documentation 
and see what you should use. So a working script would be:

#set($query="select obj from BaseObject obj where 
obj.className='Contacts.ContactClass'")
#set($results=$xwiki.search($query, 10, 1))
#foreach ($item in $results)
#set($item = $item.newObjectApi($item, $context.context))
$item.get("firstname") | $item.get("surname") | $item.get("phone1") 
#end


or:

#set($query="select obj from BaseObject obj where
obj.className='Contacts.ContactClass'")
#set($results=$xwiki.search($query, 10, 1))
#foreach ($item in $results)
$item.displayView("firstname", $context.context) | 
$item.displayView("surname", $context.context) | 
$item.displayView("phone1", $context.context) 
#end

Either one of these is NOT recommended, as they require programming 
rights. The proper way is:

#set($query=", BaseObject obj where obj.name = doc.fullName and 
obj.className='Contacts.ContactClass' and obj.name <> 
'Contacts.ContactClassTemplate'")
## Replace with the real name of your template document, if there is one
#set($results=$xwiki.searchDocuments($query, 10, 1))
#foreach ($docName in $results)
   #set($docItem = $xwiki.getDocument($docName))
   #foreach($item in $docItem.getObjects("Contacts.ContactClass))
 $docItem.display("firstname", $item) | $docItem.display("surname", 
$item) | $docItem.display("phone1", $item) 
   #end
#end

This is different from the other suggested scripts because it does not 
assume that there is only one object in each document, but it iterates 
over each object of that type.
-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-21 Thread Sergiu Dumitriu
[Ricardo Rodriguez] Your EPEC Network ICT Team wrote:
> But, please, why obj.name=doc.fullName is required? If I remove this 
> conditions, the query retrieve only a couple of documents with the 
> defined properties populated and a bunch of empty ones.
> 

As with any query language, "select from A, B" will not imply any 
relationship between A and B. In the query above, "select from 
XWikiDocument, BaseObject" means "select from any document, and any 
object", without the restrictions that the selected objects belong to 
the selected document. You do this by adding "where obj.name = 
doc.fullName", which changes the query into: "select from any document, 
and any object attached to the current document", where "current" means 
each document currently considered for inclusion in the result.

I guess some SQL training would be better to comprehend how queries 
work, but I hope that this little explanation is good for the moment.
-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-16 Thread [Ricardo Rodriguez] Your EPEC Network ICT Team
[Ricardo Rodriguez] Your EPEC Network ICT Team wrote:
> A brief update:
>
> http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specification?language=en
>
> Greetings,
>
> Ricardo
>
>   
Still another entry. Sorry, I forgot it in my previous message:

http://www.xwiki.org/xwiki/bin/view/FAQ/HowdoIretrievepropertiesfroma

Cheers,

Ricardo

-- 
Ricardo Rodríguez
Your EPEC Network ICT Team

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-16 Thread [Ricardo Rodriguez] Your EPEC Network ICT Team
A brief update:

http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specification?language=en

Greetings,

Ricardo

-- 
Ricardo Rodríguez
Your EPEC Network ICT Team

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread [Ricardo Rodriguez] Your EPEC Network ICT Team
Hi all!

Tjaart van Wijck wrote:
> Guillaume,
>
> That worked! Thanks a lot for the help.
>
> Yet, I still don't understand why the HQL string below does not yield
> the correct results:
> $query = "select obj from BaseObject obj where
> obj.className='Contacts.ContactClass'"
>
> Can someone explain how XWiki traverses documents and objects to
> generate the resultset when executing HQL statements?
>
> Thanks.

It logically worked for me as well :-) Thanks!

I could understand that the first part of the sentence is hardcoded for 
this unprivileged method as Marco said, and

obj.name<>'Contacts.ContactClassTemplate'

avoids that a object with all properties empty, the template, is retrieved.

But, please, why obj.name=doc.fullName is required? If I remove this 
conditions, the query retrieve only a couple of documents with the 
defined properties populated and a bunch of empty ones.

Sorry, I am new to HSQL!!! Thanks for any insight!

Cheers,

Ricardo

-- 
Ricardo Rodríguez
Your EPEC Network ICT Team

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users



Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Tjaart van Wijck
Guillaume,

That worked! Thanks a lot for the help.

Yet, I still don't understand why the HQL string below does not yield
the correct results:
$query = "select obj from BaseObject obj where
obj.className='Contacts.ContactClass'"

Can someone explain how XWiki traverses documents and objects to
generate the resultset when executing HQL statements?

Thanks.

On 15/04/2008, Guillaume Lerouge <[EMAIL PROTECTED]> wrote:
> Hi Tjaart,
>
>
>  Unfortunately removing the select part does not help and I get the same
>  > error.
>  >
>  > It is hard to believe that few people have managed to construct a
>  > query for all object of the same class. I though this would be
>  > straight forward.
>  >
>  > I want to retrieve a list of object from a specified class and then
>  > print all their attributes.
>
>
>
> Most people simply copy/paste the standard query and it works fine for them
>  ;-)
>
>  #set ($query = ", BaseObject as obj where obj.name=doc.fullName and
>  obj.className='Contacts.ContactClass' and
>  obj.name<>'Contacts.ContactClassTemplate'
>  order by doc.date desc")
>
> #set($results=$xwiki.searchDocuments($query, 10, 1))
>  #foreach($item in $results)
>
>  #set ($itemdoc = $xwiki.getDocument($item))
>
>  #set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))
>
>
> $itemdoc.display('firstname')
>  | $itemdoc.display('lastname') | $itemdoc.display('phone1')  
>
>  #end
>
>
>
> Guillaume
>
> ___
>  users mailing list
>  users@xwiki.org
>  http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Guillaume Lerouge
Hi Tjaart,

Unfortunately removing the select part does not help and I get the same
> error.
>
> It is hard to believe that few people have managed to construct a
> query for all object of the same class. I though this would be
> straight forward.
>
> I want to retrieve a list of object from a specified class and then
> print all their attributes.


Most people simply copy/paste the standard query and it works fine for them
;-)

#set ($query = ", BaseObject as obj where obj.name=doc.fullName and
obj.className='Contacts.ContactClass' and
obj.name<>'Contacts.ContactClassTemplate'
order by doc.date desc")
#set($results=$xwiki.searchDocuments($query, 10, 1))
#foreach($item in $results)

#set ($itemdoc = $xwiki.getDocument($item))

#set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))

$itemdoc.display('firstname')
| $itemdoc.display('lastname') | $itemdoc.display('phone1')  

#end


Guillaume
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Tjaart van Wijck
Marco,

Unfortunately removing the select part does not help and I get the same error.

It is hard to believe that few people have managed to construct a
query for all object of the same class. I though this would be
straight forward.

I want to retrieve a list of object from a specified class and then
print all their attributes.

Kind regards,
-Tjaart

On 15/04/2008, Marco Fabbri <[EMAIL PROTECTED]> wrote:
>
>  On Tue, 2008-04-15 at 14:43 +0100, Tjaart van Wijck wrote:
>  >
>  > #set($query="select obj from BaseObject obj where
>  > obj.className='Contacts.ContactClass'")
>  > #set($results=$xwiki.searchDocuments($query, 10, 1))
>  > #foreach($item in $results)
>  > #set ($itemdoc = $xwiki.getDocument($item))
>  > #set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))
>  > $itemobject.display('firstname') | $itemobject.display('lastname') |
>  > $itemobject.display('phone1')  
>  > #end
>  >
>  > But get the error:
>  >
>  > Error number 4001 in 4: Error while parsing velocity page
>  > Contacts.Contacts Directory Wrapped Exception: Invocation of method
>  > 'searchDocuments' in class com.xpn.xwiki.api.XWiki threw exception
>  > com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception while
>  > searching documents with SQL web, doc.name from XWiki Document as doc
>  > where select obj from Base Object obj where obj.class
>  > Name='Contacts.Contact Class'? Wrapped Exception: unexpected token:
>  > select near line 1, column 85 web, doc.name from
>  > com.xpn.xwiki.doc.XWiki Document as doc where select obj from
>  > com.xpn.xwiki.objects.Base Object obj where obj.class
>  > Name='Contacts.Contact Class'? @ Contacts.Contacts Directory2,22
>
>
> >From the reported exception message the error seems to lay in the HQL
>  query. When using the "unprivileged" searchDocument API method you have
>  the beginning of the query already set up so the "select obj from
>  BaseObject obj" happens to be inserted in the query after another select
>  (you should start $query with the where clause), causing the reported
>  error.
>
>  Have a look at
>  
> 
>  for further info.
>
>  --
>  Marco
>
>  =
>  "We know nothing
>   — that is the first point.
>  Therefore we should be very modest
>   — that is the second.
>  That we should not claim to know when we do not know
>   — that is the third."
>
>   Karl R. Popper
>
>
>  ___
>  users mailing list
>  users@xwiki.org
>  http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Marco Fabbri

On Tue, 2008-04-15 at 14:43 +0100, Tjaart van Wijck wrote:
> 
> #set($query="select obj from BaseObject obj where
> obj.className='Contacts.ContactClass'")
> #set($results=$xwiki.searchDocuments($query, 10, 1))
> #foreach($item in $results)
> #set ($itemdoc = $xwiki.getDocument($item))
> #set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))
> $itemobject.display('firstname') | $itemobject.display('lastname') |
> $itemobject.display('phone1')  
> #end
> 
> But get the error:
> 
> Error number 4001 in 4: Error while parsing velocity page
> Contacts.Contacts Directory Wrapped Exception: Invocation of method
> 'searchDocuments' in class com.xpn.xwiki.api.XWiki threw exception
> com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception while
> searching documents with SQL web, doc.name from XWiki Document as doc
> where select obj from Base Object obj where obj.class
> Name='Contacts.Contact Class'? Wrapped Exception: unexpected token:
> select near line 1, column 85 web, doc.name from
> com.xpn.xwiki.doc.XWiki Document as doc where select obj from
> com.xpn.xwiki.objects.Base Object obj where obj.class
> Name='Contacts.Contact Class'? @ Contacts.Contacts Directory2,22

>From the reported exception message the error seems to lay in the HQL
query. When using the "unprivileged" searchDocument API method you have
the beginning of the query already set up so the "select obj from
BaseObject obj" happens to be inserted in the query after another select
(you should start $query with the where clause), causing the reported
error.

Have a look at

for further info.

-- 
Marco

=
"We know nothing
 — that is the first point.
Therefore we should be very modest
 — that is the second.
That we should not claim to know when we do not know
 — that is the third."

 Karl R. Popper

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Tjaart van Wijck
Hi Guillaume,

Thanks for the advise but it still doesn't work. I've implemented:

#set($query="select obj from BaseObject obj where
obj.className='Contacts.ContactClass'")
#set($results=$xwiki.searchDocuments($query, 10, 1))
#foreach($item in $results)
#set ($itemdoc = $xwiki.getDocument($item))
#set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))
$itemobject.display('firstname') | $itemobject.display('lastname') |
$itemobject.display('phone1')  
#end

But get the error:

Error number 4001 in 4: Error while parsing velocity page
Contacts.Contacts Directory Wrapped Exception: Invocation of method
'searchDocuments' in class com.xpn.xwiki.api.XWiki threw exception
com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception while
searching documents with SQL web, doc.name from XWiki Document as doc
where select obj from Base Object obj where obj.class
Name='Contacts.Contact Class'? Wrapped Exception: unexpected token:
select near line 1, column 85 web, doc.name from
com.xpn.xwiki.doc.XWiki Document as doc where select obj from
com.xpn.xwiki.objects.Base Object obj where obj.class
Name='Contacts.Contact Class'? @ Contacts.Contacts Directory2,22

I also tried this with $itemdoc.display(...) as you suggested but that
is not the source of the problem.

Am I right in suspecting that HQL queries like "select doc from
XWikiDocument..." will return a resultset of "XWikiDocuments" but a
HQL query like "select obj from BaseObject..." will return a resultset
of BaseObjects. I think the cause of the exception might be that
seachDocuments should requires a doc resultset as parameter.

Any ideas?

Thanks.

On 15/04/2008, Guillaume Lerouge <[EMAIL PROTECTED]> wrote:
> Hi Tjaart,
>  Here we go at last :
>
>
>  #set($query="select obj from BaseObject obj where obj.className='Contacts
>  .ContactClass'")
>
> #set($results=$xwiki.searchDocuments($query, 10, 1))
>  #foreach($item in $results)
>
>  #set ($itemdoc = $xwiki.getDocument($item))
>
>  #set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))
>
>  $itemdoc.display('firstname')
>  | $itemdoc.display('lastname') | $itemdoc.display('phone1')  
>
>  #end
>
>
>  Hopefully this will work...
>
>
>
>  Guillaume
>
> ___
>  users mailing list
>  users@xwiki.org
>  http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Guillaume Lerouge
Hi Tjaart,
Here we go at last :

#set($query="select obj from BaseObject obj where obj.className='Contacts
.ContactClass'")
#set($results=$xwiki.searchDocuments($query, 10, 1))
#foreach($item in $results)

#set ($itemdoc = $xwiki.getDocument($item))

#set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))

$itemdoc.display('firstname')
| $itemdoc.display('lastname') | $itemdoc.display('phone1')  

#end


Hopefully this will work...


Guillaume
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Tjaart van Wijck
Hi,

My problem is still unresolved. I have followed the suggestions from the FAQ
post:
http://www.xwiki.org/xwiki/bin/view/FAQ/HowToListDocumentsWithACertainPropertyValue

And rewrote the code as follows:

#set($query="select obj from BaseObject obj where
obj.className='Contacts.ContactClass'")
#set($results=$xwiki.search($query, 10, 1))
#foreach($item in $results)
   #set($doc=$xwiki.getDocument($item))
   #set($obj=$doc.getObject('Cotacts.ContactClass'))
   #set($firstname=$obj.getProperty('firstname').value)
   #set($surname=$obj.getProperty('surname').value)
   #set($phone1=$obj.getProperty('phone1').value)
$firstname | $surname | $phone1 
#end

With the result:
$firstname | $surname | $phone1
$firstname | $surname | $phone1

I should add that I would have been confused if the above had worked. Please
let me know if my understanding of the object model is correct:
a) A class definition is essentially a special type of wiki page that
defines the class structure (i.e. properties).
b) No more than 1 class definition can be contained in this special type of
page.
c) Objects are instances of these classes and must be associate with a page.
(Can a single object be associated with more than 1 page?)
d) Multiple objects can be associated with a wiki page.
e) An HQL query iterates through the wiki pages, through each object in each
page and each property in each object
d) An HQL query specifying page/document constraints returns a Java List of
documents
e) An HQL query specifying object constraints returns a Java List of objects
(does not seem to be the case from the above code?!)
f) An HQL query specifying property constraints returns a Java List of
properties

Regards,
Tjaart

On 15/04/2008, [Ricardo Rodriguez] Your EPEC Network ICT Team <
[EMAIL PROTECTED]> wrote:
>
> Hi Tjaart, all,
>
>
> Tjaart van Wijck wrote:
> > I have created the class Contacts.ContactClass. This class has three
> string
> > properties "firstname", "surname" and "phone1". I have also created two
> > instances of this class and filled out the attributes.
> >
> > Now, it should be straight forward to write a Velocity script to seach
> for
> > all objects with the given class type of "Contacts.ContactClass" and
> write
> > out the attributes but I'm having some trouble. Below is my script:
> > #set($query="select obj from BaseObject obj where
> > obj.className='Contacts.ContactClass'")
> > #set($results=$xwiki.search($query, 10, 1))
> > #foreach ($item in $results)
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")  />
> > #end
> >
> > However this does not work. All I get is:
> >
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> >
> > When I run:
> >
> > #set($query="select obj from BaseObject obj where
> > obj.className='Contacts.ContactClass'")
> > #set($results=$xwiki.search($query, 10, 1))
> > #foreach ($item in $results)
> > $item
> > #end
> >
> > I get:
> >
>
> >  Contacts.Tjaart 0 Contacts.ContactClass
> >  Contacts.Jane 0 Contacts.ContactClass
>
>
> I think we are missing some important point about how objects are
> retrieved. See this FAQ...
>
> http://tinyurl.com/6rgm8h
>
> I am not able yet to relate this with Guillaume proposal. He doesn't use
> .getProperty and I don't know why.
>
> And this thread in xwiki-devs...
>
> http://tinyurl.com/6j5a2m
>
> I will keep this post when I get a simple example. Your feedback will be
> really welcome!
>
> Cheers,
>
> Ricardo
>
> --
> Ricardo Rodríguez
>
> Your EPEC Network ICT Team
>
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread [Ricardo Rodriguez] Your EPEC Network ICT Team
Guillaume Lerouge wrote:
>
>
> Obviously I've been writing too fast thus proposing a mistaken solution :-)
>
> I'll check on stuff I've used before and try to get back with a _working_
> suggestion ;-)
>
> Guillaume

Thanks!

-- 
Ricardo Rodríguez
Your EPEC Network ICT Team

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Guillaume Lerouge
Hi Ricardo,


> > I have created the class Contacts.ContactClass. This class has three
> string
> > properties "firstname", "surname" and "phone1". I have also created two
> > instances of this class and filled out the attributes.
> >
> > Now, it should be straight forward to write a Velocity script to seach
> for
> > all objects with the given class type of "Contacts.ContactClass" and
> write
> > out the attributes but I'm having some trouble. Below is my script:
> > #set($query="select obj from BaseObject obj where
> > obj.className='Contacts.ContactClass'")
> > #set($results=$xwiki.search($query, 10, 1))
> > #foreach ($item in $results)
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")  />
> > #end
> >
> > However this does not work. All I get is:
> >
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> >
> > When I run:
> >
> > #set($query="select obj from BaseObject obj where
> > obj.className='Contacts.ContactClass'")
> > #set($results=$xwiki.search($query, 10, 1))
> > #foreach ($item in $results)
> > $item
> > #end
> >
> > I get:
> >
> >  Contacts.Tjaart 0 Contacts.ContactClass
> >  Contacts.Jane 0 Contacts.ContactClass
>
> I think we are missing some important point about how objects are
> retrieved. See this FAQ...
>
> http://tinyurl.com/6rgm8h
>
> I am not able yet to relate this with Guillaume proposal. He doesn't use
> .getProperty and I don't know why.
>
> And this thread in xwiki-devs...
>
> http://tinyurl.com/6j5a2m


Obviously I've been writing too fast thus proposing a mistaken solution :-)

I'll check on stuff I've used before and try to get back with a _working_
suggestion ;-)

Guillaume
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread [Ricardo Rodriguez] Your EPEC Network ICT Team
Hi Tjaart, all,

Tjaart van Wijck wrote:
> I have created the class Contacts.ContactClass. This class has three string
> properties "firstname", "surname" and "phone1". I have also created two
> instances of this class and filled out the attributes.
>
> Now, it should be straight forward to write a Velocity script to seach for
> all objects with the given class type of "Contacts.ContactClass" and write
> out the attributes but I'm having some trouble. Below is my script:
> #set($query="select obj from BaseObject obj where
> obj.className='Contacts.ContactClass'")
> #set($results=$xwiki.search($query, 10, 1))
> #foreach ($item in $results)
> $item.get("firstname") | $item.get("surname") | $item.get("phone1") 
> #end
>
> However this does not work. All I get is:
>
> $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> $item.get("firstname") | $item.get("surname") | $item.get("phone1")
>
> When I run:
>
> #set($query="select obj from BaseObject obj where
> obj.className='Contacts.ContactClass'")
> #set($results=$xwiki.search($query, 10, 1))
> #foreach ($item in $results)
> $item
> #end
>
> I get:
>
>  Contacts.Tjaart 0 Contacts.ContactClass
>  Contacts.Jane 0 Contacts.ContactClass

I think we are missing some important point about how objects are 
retrieved. See this FAQ...

http://tinyurl.com/6rgm8h

I am not able yet to relate this with Guillaume proposal. He doesn't use 
.getProperty and I don't know why.

And this thread in xwiki-devs...

http://tinyurl.com/6j5a2m

I will keep this post when I get a simple example. Your feedback will be 
really welcome!

Cheers,

Ricardo

-- 
Ricardo Rodríguez
Your EPEC Network ICT Team

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-15 Thread Tjaart van Wijck
Thanks for the help but unfortunately this still does not solve my problem.

1) Your first suggestion:

#foreach($item in $results)
$item.getObject('Contacts.ContactClass')
$item.display('firstname') | $item.display('lastname') |
$item.display('phone1') 
#end

Produces:
$item.getObject('Contacts.ContactClass') $item.display('firstname') |
$item.display('lastname') | $item.display('phone1')
$item.getObject('Contacts.ContactClass') $item.display('firstname') |
$item.display('lastname') | $item.display('phone1')


2) The second suggestion:

#foreach($item in $results)
$item.getObject('Contacts.ContactClass')
$item.firstname | $item.lastname | $item.phone1 
#end

Produces:
$item.getObject('Contacts.ContactClass') $item.firstname | $item.lastname |
$item.phone1
$item.getObject('Contacts.ContactClass') $item.firstname | $item.lastname |
$item.phone1

I also tried:

#foreach($item in $results)
#set($obj=$item.getObject('Contacts.ContactClass')
 $obj.firstname | $obj.lastname | $obj.phone1 
#end

But produces :

$obj.firstname | $obj.lastname | $obj.phone1
$obj.firstname | $obj.lastname | $obj.phone1

Any insight would be appreciated.

-Tjaart


On 15/04/2008, Guillaume Lerouge <[EMAIL PROTECTED]> wrote:
>
> Hi Tjaart,
>
>
> > I have created the class Contacts.ContactClass. This class has three
> > string
> > properties "firstname", "surname" and "phone1". I have also created two
> > instances of this class and filled out the attributes.
> >
> > Now, it should be straight forward to write a Velocity script to seach
> for
> > all objects with the given class type of "Contacts.ContactClass" and
> write
> > out the attributes but I'm having some trouble. Below is my script:
> > #set($query="select obj from BaseObject obj where
> > obj.className='Contacts.ContactClass'")
> > #set($results=$xwiki.search($query, 10, 1))
> > #foreach ($item in $results)
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")  />
> > #end
> >
> > However this does not work. All I get is:
> >
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> > $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> >
> > When I run:
> >
> > #set($query="select obj from BaseObject obj where
> > obj.className='Contacts.ContactClass'")
> > #set($results=$xwiki.search($query, 10, 1))
> > #foreach ($item in $results)
> > $item
> > #end
> >
> > I get:
> >
>
> >  Contacts.Tjaart 0 Contacts.ContactClass
> >  Contacts.Jane 0 Contacts.ContactClass
>
>
> Have you tried with :
>
> #foreach($item in $results)
> $item.getObject('Contacts.ContactClass')
> $item.display('firstname') | $item.display('lastname') |
> $item.display('phone1') 
> #end
>
> or
>
> #foreach($item in $results)
> $item.getObject('Contacts.ContactClass')
> $item.firstname | $item.lastname | $item.phone1 
> #end
>
> ?
>
> Hope this helps,
>
> Guillaume
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Trouble with velocity script to list Object properties

2008-04-14 Thread Guillaume Lerouge
Hi Tjaart,

> I have created the class Contacts.ContactClass. This class has three
> string
> properties "firstname", "surname" and "phone1". I have also created two
> instances of this class and filled out the attributes.
>
> Now, it should be straight forward to write a Velocity script to seach for
> all objects with the given class type of "Contacts.ContactClass" and write
> out the attributes but I'm having some trouble. Below is my script:
> #set($query="select obj from BaseObject obj where
> obj.className='Contacts.ContactClass'")
> #set($results=$xwiki.search($query, 10, 1))
> #foreach ($item in $results)
> $item.get("firstname") | $item.get("surname") | $item.get("phone1") 
> #end
>
> However this does not work. All I get is:
>
> $item.get("firstname") | $item.get("surname") | $item.get("phone1")
> $item.get("firstname") | $item.get("surname") | $item.get("phone1")
>
> When I run:
>
> #set($query="select obj from BaseObject obj where
> obj.className='Contacts.ContactClass'")
> #set($results=$xwiki.search($query, 10, 1))
> #foreach ($item in $results)
> $item
> #end
>
> I get:
>
>  Contacts.Tjaart 0 Contacts.ContactClass
>  Contacts.Jane 0 Contacts.ContactClass


Have you tried with :

#foreach($item in $results)
$item.getObject('Contacts.ContactClass')
$item.display('firstname') | $item.display('lastname') |
$item.display('phone1') 
#end

or

#foreach($item in $results)
$item.getObject('Contacts.ContactClass')
$item.firstname | $item.lastname | $item.phone1 
#end

?

Hope this helps,

Guillaume
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users