Re: [xwiki-users] using XWQL with additional search criterias by dates

2010-10-23 Thread [Ricardo Rodriguez] eBioTIC.
Hi Eugen,

Eugen Colesnicov wrote:
> Hi Sergiu!
>
> I played before with jodatime. It have some problems ...
> For example, I tried to use example script from plugin home page (it can be
> usefull in my situation) and this script doesn't working: 
> #set($formatter =
> $xwiki.jodatime.getDateTimeFormatterForPattern('.MM.dd'))
> #set($myBirthday = $formatter.parseDateTime('2007.11.25'))
> #set($daysLeft = $myBirthday.minus($now.millis))
> $daysLeft.getDayOfYear() days left till my birthday!
>
> Also joda time is badly described - for all these reasons I used datetool.
>   

Have you tried to use Velocity ComparisonDateTool? I'm able to use 
DateTool like you, but I don't know how to call methods from 
ComparisonDateTool. Are they available within Xwiki? Thanks!

http://ebiotic.net/bin/ICT/Date
> About query ... Better for me - XWQL, but all my tryings to use any dates in
> XWQL gives some errors (most of all - java errors in a translation from XWQL
> to hql ...). I am not a professional in a XWQL and HQL (I am not sure - this
> is my error or bug), and Ricardo gave working example of using HQL - for
> this reason I used ready query example.
>
>  If you can give working example of using dates in a XWQL - will be great!
> Also I tried examples from here:
> http://dev.xwiki.org/xwiki/bin/view/DesignArchive/XWikiQueryLanguageSpecification
> (second script) - but give me error.
>
>
>
>
>
>   

-- 
Ricardo Rodríguez
CTO
eBioTIC.
Life Sciences, Data Modeling and Information Management Systems

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


Re: [xwiki-users] conditional redirect after login

2010-10-23 Thread [Ricardo Rodriguez] eBioTIC.
Hi,

Gerritjan Koekkoek wrote:
> Hi,
>
> We would like to, conditionally,  redirect users who log in to their profile 
> page. (in our case; XWiki.)
> The condition is: User is not in ANY OTHER GROUP then XWikiAllGroup.
>
> How can I do this most elegantly, modifying as little as possible of the 
> standard pages that come with a distribution of XWIKI
>
>
>   
This is not elegant, but I think it works:

#set($counter = 0)
#set($user = $xwiki.getUser())
#set($userContext = $context.user)

#set($query = ", BaseObject as obj, StringProperty as prop where 
doc.fullName = obj.name and obj.className='XWiki.XWikiGroups' and 
doc.fullName <> 'XWiki.XWikiGroupTemplate' and doc.fullName <> 
'XWiki.XWikiAllGroup' order by doc.fullName asc")

#set($results=$xwiki.searchDocuments($query))

#foreach($item in $results)
  #if($user.isUserInGroup($item))
#set($counter = $counter+1)
  #end
#end

#if($counter > 0)
$response.sendRedirect($xwiki.getURL($userContext))
#end

You could copy and paste in your WebHome or create an ad hoc document 
and use #includeInContext('YourSpace.YourDocument') to include it in 
your WebHome.

HTH,

Ricardo

-- 
Ricardo Rodríguez
CTO
eBioTIC.
Life Sciences, Data Modeling and Information Management Systems

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


Re: [xwiki-users] Using Scheduler issues (groovy questions)

2010-10-23 Thread Eugen Colesnicov

I tried redirecting in a scheduler script. I wrote:
{{groovy}}
response.sendRedirect(xwiki.getURL("ETVCCorrespondenceCode.CronJobProgrammingCode"));
{{/groovy}}

After this I started to using scheduler. First, I tried to trigger my job
(as I understand - this button starts execution of script immediately). This
give me error:
Error number 90012 in 5: com.xpn.xwiki.plugin.scheduler.SchedulerPlugin:
Error occured while trying to trigger job ETVCCorrespondenceJob
Wrapped Exception: The job (DEFAULT.xwiki:Scheduler.ETVCCorrespondenceJob_0)
referenced by the trigger does not exist.
Looks like program cannot find job ETVCCorrespondenceJob_0 - but my job
named ETVCCorrespondenceJob without "_0". what is "_0" - I don't know. I
tried to rename my job to ETVCCorrespondenceJob_0 - but also give me error
but with ETVCCorrespondenceJob_0_0 ... 
I cannot understand this error. This error exists also, if I write ANY
script (also empty script field).

Ok ... I tried to schedule my job. I putted small interval (30 seconds) - I
don't see any results (no emails in my mailbox) - but computer processor
gets high CPU (100%). I saw - java process giving this. I restarted my
ApplicationServer (Glassfish) - all is ok for the next time, when I tried to
schedule my job for 30 seconds interval. No any errors or special message in
a logs ...

I am not a professional in these and I cannot understand - this is my
problem (maybe I doing something wrong) or is it bugs?
-- 
View this message in context: 
http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp5666438p5666573.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] getRenderedContent issues

2010-10-23 Thread Eugen Colesnicov

Hi colleagues!

I testing some application with standart organization (many of XWiki
applications organized in a same way):
Exists TestAppCode space with all classes, templates, sheets, codes and
exists TestApp space with visualization pages using {{include
document="TestAppCode.SomeTemplate"/}}

When I trying to use getRenderedContent for this document from TestApp (for
example, when I want to send this page by email form another page with my
own code) I get rendered content of TestAppCode.SomeTemplate - not the
content of my data.

I want to clarify - this is because of
http://jira.xwiki.org/jira/browse/XWIKI-4274? Looks like my situation ... I
staying in one page and trying to getRenderedContent for the another page.

Maybe exists some ways to overcome this issue?

Thanks beforehand
Eugen Colesnicov
-- 
View this message in context: 
http://xwiki.475771.n2.nabble.com/getRenderedContent-issues-tp5666553p5666553.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Using Scheduler issues (groovy questions)

2010-10-23 Thread Paul Libbrecht
My first hint would be to consider groovy as java.
It's not exactly the same but it shares most.

The other idea is to simply call the web page from groovy?

new java.net.URL("blablalba").getContent()

paul




On 23 oct. 2010, at 23:26, Eugen Colesnicov wrote:

> 
> Hi colleagues!
> 
> I need some help for the Scheduler.
> I already have some not small script in a velocity. This script select some
> pages with complex conditions (hql),  make some calculations and sending
> emails. Now this script is working when I simply open it page (where script
> is placed).
> 
> I need to make automatic schedule for this script (for example - every day).
> Unfortunately, scheduler scripts permit only groovy scripts ... Also,
> problem for me - I dont't now groovy at all (velocity - so-so) and I am not
> a programmer. For me - groovy learning is difficult (in any case - not
> quickly).
> 
> My question - is any possibility to use my velocity script without total
> rewriting for groovy? Maybe I can write groovy script with redirection for
> my page with velocity script? Maybe is it possible to include code of one
> scripting language in another?
> 
> If is not (only need to totally rewrite script to grovvy) can somebody can
> help me in this operation? I attached my original velocity script (it's
> working fine).
> 
> http://xwiki.475771.n2.nabble.com/file/n5666438/velocity_script.txt
> velocity_script.txt 
> 
> --
> Thanks beforehand
> Eugen Colesnicov
> -- 
> View this message in context: 
> http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp5666438p5666438.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
> ___
> 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] using XWQL with additional search criterias by dates

2010-10-23 Thread Eugen Colesnicov

Hi Sergiu!

I played before with jodatime. It have some problems ...
For example, I tried to use example script from plugin home page (it can be
usefull in my situation) and this script doesn't working: 
#set($formatter =
$xwiki.jodatime.getDateTimeFormatterForPattern('.MM.dd'))
#set($myBirthday = $formatter.parseDateTime('2007.11.25'))
#set($daysLeft = $myBirthday.minus($now.millis))
$daysLeft.getDayOfYear() days left till my birthday!

Also joda time is badly described - for all these reasons I used datetool.

About query ... Better for me - XWQL, but all my tryings to use any dates in
XWQL gives some errors (most of all - java errors in a translation from XWQL
to hql ...). I am not a professional in a XWQL and HQL (I am not sure - this
is my error or bug), and Ricardo gave working example of using HQL - for
this reason I used ready query example.

 If you can give working example of using dates in a XWQL - will be great!
Also I tried examples from here:
http://dev.xwiki.org/xwiki/bin/view/DesignArchive/XWikiQueryLanguageSpecification
(second script) - but give me error.





-- 
View this message in context: 
http://xwiki.475771.n2.nabble.com/using-XWQL-with-additional-search-criterias-by-dates-tp5660503p5666525.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] using XWQL with additional search criterias by dates

2010-10-23 Thread Sergiu Dumitriu
On 10/23/2010 10:45 PM, Eugen Colesnicov wrote:
>
> I checked this example and your script - it is not correct, because you
> compare separately year, month and day of document with current date - year,
> month and day-100. But if, for example now is 02 january, your script give
> uncorrect result, becase I also should change year and month (and year),
> then I want to get date BEFORE 100 days of 02 january.
>
> Need to make arithmetical operations with dates and these operations should
> consider also possible transitions of month and year when day changed ...
> In any case - thanks!
>
> I found the answer - need to use special velocity object $datetool

You can use the jodatime plugin, which makes it easier to work with dates.

See 
https://svn.xwiki.org/svnroot/xwiki/platform/xwiki-plugins/trunk/jodatime/

Accessed with $xwiki.jodatime

Also, you shouldn't use computed date segments as constants inside a 
query, but do a parameterized query and compare dates.

Schematic example:

$xwiki.searchDocuments(", DateProperty someDateProp where 
someDateProp.value > ?", [$computedStartDate])

> Example:
> #set ($d = 5)- days interval which I need
> #set ($ms = $d * 24 * 60 * 60 * 1000)- Calculating internal in
> Milliseconds
>
> #set ($calendar = $datetool.getCalendar())
> #set ($currentTime = $calendar.getTimeInMillis())
> #set ($targetTime = $currentTime - $ms)
> #set ($void = $calendar.setTimeInMillis($targetTime))
> #set ($targetDate = $calendar.getTime())
> #set ($targetYear = $datetool.getYear($targetDate)) :get year of
> a date = currentdate - 5 days
> #set ($targetMonth = $datetool.getMonth($targetDate) + 1)   :get month of a
> date = currentdate - 5 days
> #set ($targetDay = $datetool.getDay($targetDate))   :get day of
> a date = currentdate - 5 days
>
> and after this, in a hql searching, I can compare this year, month, and day
> with documents year, month and day ...
>


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Using Scheduler issues (groovy questions)

2010-10-23 Thread Eugen Colesnicov

Hi colleagues!

I need some help for the Scheduler.
I already have some not small script in a velocity. This script select some
pages with complex conditions (hql),  make some calculations and sending
emails. Now this script is working when I simply open it page (where script
is placed).

I need to make automatic schedule for this script (for example - every day).
Unfortunately, scheduler scripts permit only groovy scripts ... Also,
problem for me - I dont't now groovy at all (velocity - so-so) and I am not
a programmer. For me - groovy learning is difficult (in any case - not
quickly).

My question - is any possibility to use my velocity script without total
rewriting for groovy? Maybe I can write groovy script with redirection for
my page with velocity script? Maybe is it possible to include code of one
scripting language in another?

If is not (only need to totally rewrite script to grovvy) can somebody can
help me in this operation? I attached my original velocity script (it's
working fine).

http://xwiki.475771.n2.nabble.com/file/n5666438/velocity_script.txt
velocity_script.txt 

--
Thanks beforehand
Eugen Colesnicov
-- 
View this message in context: 
http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp5666438p5666438.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] using XWQL with additional search criterias by dates

2010-10-23 Thread Eugen Colesnicov

I checked this example and your script - it is not correct, because you
compare separately year, month and day of document with current date - year,
month and day-100. But if, for example now is 02 january, your script give
uncorrect result, becase I also should change year and month (and year),
then I want to get date BEFORE 100 days of 02 january.

Need to make arithmetical operations with dates and these operations should
consider also possible transitions of month and year when day changed ...
In any case - thanks!

I found the answer - need to use special velocity object $datetool
Example:
#set ($d = 5)- days interval which I need
#set ($ms = $d * 24 * 60 * 60 * 1000)- Calculating internal in
Milliseconds 

#set ($calendar = $datetool.getCalendar())
#set ($currentTime = $calendar.getTimeInMillis())
#set ($targetTime = $currentTime - $ms)
#set ($void = $calendar.setTimeInMillis($targetTime))
#set ($targetDate = $calendar.getTime())
#set ($targetYear = $datetool.getYear($targetDate)) :get year of
a date = currentdate - 5 days
#set ($targetMonth = $datetool.getMonth($targetDate) + 1)   :get month of a
date = currentdate - 5 days
#set ($targetDay = $datetool.getDay($targetDate))   :get day of
a date = currentdate - 5 days

and after this, in a hql searching, I can compare this year, month, and day
with documents year, month and day ...

-- 
View this message in context: 
http://xwiki.475771.n2.nabble.com/using-XWQL-with-additional-search-criterias-by-dates-tp5660503p5666357.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] using XWQL with additional search criterias by dates

2010-10-23 Thread [Ricardo Rodriguez] eBioTIC.
Hi!

Eugen Colesnicov wrote:
> Thanks, Ricardo! But for me your example is not enough.
>
> I need to filter not by fixed date, but for dynamic criteria - current date
> - 5 days ...
> How is it possible?
>   
Well, this is not hard to do... after the examples shown  here...

http://platform.xwiki.org/xwiki/bin/view/DevGuide/velocityHqlExamples

> Maybe I should do it by 2 steps: 1) set target date (current date - 5 days)
> as value, 2) use this target date (fixed value) as a filter criteria. Ok,
> but for this - how is it possible to define my target date = current date -
> 5 days?

This simple script works for me here...

#set($query = ", BaseObject as obj, StringProperty as firstName, 
StringProperty as lastName where doc.fullName = obj.name and 
obj.className='XWiki.XWikiUsers' and obj.id=firstName.id.id and 
firstName.id.name='first_name' and obj.id=lastName.id.id and 
lastName.id.name='last_name' and (firstName.value like '%Ricardo%' or 
firstName.value like '%Mar%') and lastName.value like '%Rodr%' and 
year(doc.date) = year(current_date()) and month(doc.date) = 
month(current_date()) and day(doc.date) > (day(current_date()) - 100) 
order by doc.fullName asc")

#set($results=$xwiki.searchDocuments($query))
#foreach($item in $results)
#set($itemdoc = $xwiki.getDocument($item))
[$itemdoc.display('first_name')>$item]
#end

HTH!

-- 
Ricardo Rodríguez
CTO
eBioTIC.
Life Sciences, Data Modeling and Information Management Systems

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


Re: [xwiki-users] using XWQL with additional search criterias by dates

2010-10-23 Thread Eugen Colesnicov

Thanks, Ricardo! But for me your example is not enough.

I need to filter not by fixed date, but for dynamic criteria - current date
- 5 days ...
How is it possible?

Maybe I should do it by 2 steps: 1) set target date (current date - 5 days)
as value, 2) use this target date (fixed value) as a filter criteria. Ok,
but for this - how is it possible to define my target date = current date -
5 days?

Thanks beforehand
Eugen Colesnicov
-- 
View this message in context: 
http://xwiki.475771.n2.nabble.com/using-XWQL-with-additional-search-criterias-by-dates-tp5660503p5665222.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Livetable does not show results

2010-10-23 Thread Gerritjan Koekkoek
Hi Thibault,

I copied the script in a page in the sandbox environment...
It should show a LiveTable on Panels.PanelClass
NO, the script works fine, but there are NO records shown

I also copied the script into the sandbox environment of our production 
instance:  www.cdlswold.org
It gives the same result as my test environment 2.5
production is on 2.1.1.25889

I guess it must be some kind of security?
Or could it be that not all objects originated from the same class defenition? 
(i.o: The class was modified after initial objects are created?)

Hope this helps tracking my problem down

Gerritjan


Op 22 okt 2010, om 16:15 heeft Thibaut Camberlin het volgende geschreven:

Hi Gerritjan,

I tested on Panels.PanelClass on a 2.5 M2 and it works fine.

Can you test this code (generated by the script)

{{velocity}}
#set($columns = [ "doc.title"  ,"name"  ,"type"  ,"description"  ,"content"  
,"category" ]) 
#set($columnsProperties = { "name" : { "type" : "text", "link" : 
"view", "size" : 10, "filterable" : true, "sortable": true }, "type" : 
{ "type" : "list", "link" : "view", "size" : 10, "filterable" : true, 
"sortable": true }, "description" : { "type" : "text", "link" : "view", 
"size" : 10, "filterable" : true, "sortable": true }, "content" : { 
"type" : "text", "link" : "view", "size" : 10, "filterable" : true, "sortable": 
true }, "category" : { "type" : "list", "link" : "view", "size" : 10, 
"filterable" : true, "sortable": true },"_avatar" : { "type" : "none", 
"link" : "none", "html" : "true", "sortable":false },   "_images" : { 
"type" : "none", "link" : "none", "html" : "true", "sortable":false },   
"_attachments" : { "type" : "none", "link" : "none", "html" : "true", 
"sortable":false },   "_actions" : { "type" : "none", "link" : "none", 
"html" : "true", "sortable":false },"doc.name" : { "type" : "text", 
"link" : "view", "size" : "10", "filterable" : true, "sortable": true },   
"doc.space" : { "type" : "text", "link" : "view", "size" : "10", "filterable" : 
true, "sortable": true },   "doc.fullName" : { "type" : "text", "link" : 
"view", "size" : "10", "filterable" : true, "sortable": true },   
"doc.author" : { "type" : "text", "link" : "view", "size" : "10", "filterable" 
: true, "sortable": true },   "doc.date" : { "type" : "text", "link" : 
"view", "size" : "10", "filterable" : true, "sortable": true },   
"doc.creator" : { "type" : "text", "link" : "view", "size" : "10", "filterable" 
: true, "sortable": true },   "doc.creationDate" : { "type" : "text", 
"link" : "view", "size" : "10", "filterable" : true, "sortable": true },   
"doc.title" : { "type" : "text", "link" : "view", "size" : "20", "filterable" : 
true, "sortable": true } })

#set($options = { "className":"Panels.PanelClass", "translationPrefix" : 
"panel.livetable.", "tagCloud" : true, "rowCount": 15, "maxPages" : 10, 
"selectedColumn" : "doc.title", "defaultOrder" : "asc" })

#livetable("panel" $columns $columnsProperties $options)
{{/velocity}}


You may have to hit ctrl + F5 to refresh the livetable.

--
Thibaut

On Wed, Oct 20, 2010 at 8:47 PM, Gerritjan Koekkoek 
 wrote:
Hi

I only have 2.5, deinstalled the old version
In my situation It looks like it is only working on classes where the classes 
sit in the XWiki space and the documents holding the objects are in the same 
space?
So it works with users, but not with panels.panelclass (or my own custom 
developed class). It does work brilliantly with tag-class Even get unexected 
goodies

I do not think it's the generator script, but something with livetable?

Gerritjan

Op 20 okt 2010, om 01:05 heeft [Ricardo Rodriguez] eBioTIC. het volgende 
geschreven:

Hi,

Thibaut Camberlin wrote:
> Hi Gerritjan,
>
> Ludovic did that script not me I have to say!
>
> Did you test the same code on another version of XWiki ? If so what is the
> behaviour and the version ?
> Can you generate the livetable based on another class, say XWiki.XWikiUsers,
> what is the result ?
>
>

It is working fine in a XE/XEM 2.4.1 system. Thibaut, you can check it
here...

http://ebiotic.net/bin/ICT/LiveTableUsers

> On Tue, Oct 19, 2010 at 7:48 PM, Gerritjan Koekkoek <
> gerritjankoekk...@gmail.com> wrote:
>
>
>> Hi Thibaut,
>> The script works like magic, very nice.
>> Copy and Paste from the link created some formatting challenges, but after
>> fixing the script generated actually created a live table;
>> BUT...
>> Still there are no records displayed? Like with the script I put in this
>> question.
>> The pages where the objects are stored are in a space that has access
>> forbidden for unregistered users?
>> Off course I run the generated script as a registered user (actually as a
>> admin user
>> I'm running this on xwiki 2.5
>>
>> Gerritjan
>>
>> Op 18 okt 2010, om 23:11 heeft Thibaut Camberlin het volgende geschreven:
>>
>> Hi Gerritjan,
>>
>> You can use the livetable generator code snippet
>> http://co