[xwiki-users] Problem to give a name to a page with Class
Hello, Infos: I've a class to create some services (Prestations) with (at this time) 3 fields: name, town and country. They are created with a name for the doc, like MyService01, MyService02, etc (for the tests) Second part, there is another class used to evaluate each service. The system needed is to have a form of evaluation created each time that any person want make an evaluation for a service. So, I would like to create a system of pages called like MyService01_Eval_001, MyService01_Eval_002, MyService01_Eval_003, etc. for an evaluation of MyService01, and MyService02_Eval_001, MyService02_Eval_002, etc. for an evaluation of MyService02 for example. My problem, when I want create an evalutation, I get back the name of the service (spent in hidden parameter in the form) then I would like to use it in the code to create page and call the class template of the second class with the code: code #if($!request.xaction == 'createevaluationtype01') #if($docname != '' !$xwiki.exists($docname)) #if($!request.xaction == 'createevaluationtype01') $xwiki.copyDocument('EtudeCode.EtudeRatingType01Template', $docname) #set($etudeDoc= $xwiki.getDocument($docname)) $etudeDoc.setTitle(${title}) $etudeDoc.setParent($doc.getFullName()) $etudeDoc.save() $response.sendRedirect($etudeDoc.getURL('inline')) #end #end #end /code The $docname value has the good name when I display it, like for example MyService001_Eval_002, but when I click on button the page created is called WebHome_Eval_002, I can't keep the name of the service evaluated. Really, I don't understand why and I don't find any soluce to my problem since now almost 3 days and after tried several methods :( Someone could help me for this please ;) -- View this message in context: http://xwiki.475771.n2.nabble.com/Problem-to-give-a-name-to-a-page-with-Class-tp5667152p5667152.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)
On 10/24/2010 12:46 AM, Eugen Colesnicov wrote: I tried redirecting in a scheduler script. I wrote: {{groovy}} response.sendRedirect(xwiki.getURL(ETVCCorrespondenceCode.CronJobProgrammingCode)); {{/groovy}} You can't redirect a scheduled job. Redirects affect HTTP responses only, and a job executes without a valid request/response pair. 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? -- Sergiu Dumitriu http://purl.org/net/sergiu/ ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Problem to give a name to a page with Class
Marf ;) Forgot my last post, I just forgot to put a hidden field in my second form... -- View this message in context: http://xwiki.475771.n2.nabble.com/Problem-to-give-a-name-to-a-page-with-Class-tp5667152p5667191.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)
Thanks Sergiu! But can I use Paul Libbrecht advise? call the web page from groovy new java.net.URL(blablalba).getContent() Thanks beforehand! Eugen -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp5666438p5667271.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
Hi! 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. You are completely right: it is clearly stated in the example. They talked only about current day, week and month. Sorry about being too fast and don't think enough before posting! 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 ... -- 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
Hi [Ricardo Rodriguez] eBioTIC. wrote: 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 As you said: reading attentively the documentation is required to get this working! Following http://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting#HVelocitySpecificInformation I modified xwiki.properties to include... http://velocity.apache.org/tools/releases/1.4/javadoc/org/apache/velocity/tools/generic/ComparisonDateTool.html by adding... velocity.tools = comparisondatetool = org.apache.velocity.tools.generic.ComparisonDateTool It seems to me that the subclass is not available as the current date is printed if I use $comparisondatetool, but I'm not able yet to use its methods. (I've also checked that the required Velocity Tools library release is available ./WEB-INF/lib/velocity-tools-1.4.jar ) http://ebiotic.net/bin/ICT/Date Please, could you/anybody give an example? Thanks! 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. Cheers, -- 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)
Hi, Paul Libbrecht wrote: On 24 oct. 2010, at 13:54, Sergiu Dumitriu wrote: call the web page from groovy new java.net.URL(blablalba).getContent() Thanks beforehand! Eugen Yes, but note that the URL will be fetched without any session information, so if the requested page is private (not visible for guests), it won't work. or call http://user:passw...@host:port/xwiki/bin/view/Space/Name paul _ It doesn't work for me here. Please, any particular requirement/setting on the server side? Is it not related with this unresolved issue http://jira.xwiki.org/jira/browse/XWIKI-2018? Thanks! 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)
Paul Libbrecht wrote: On 24 oct. 2010, at 13:54, Sergiu Dumitriu wrote: call the web page from groovy new java.net.URL(blablalba).getContent() Thanks beforehand! Eugen Yes, but note that the URL will be fetched without any session information, so if the requested page is private (not visible for guests), it won't work. or call http://user:passw...@host:port/xwiki/bin/view/Space/Name Paul, can you give exactly example? What I should write in a scheduler field - Job script? Because of I tried different variants - but without results. Also, I rewrited my original code from velocity to groovy. I tested my groovy rewrited code in a another xwiki page - all is working fine. But when I putted this groovy code to the scheduler - no any actions. Looks like, that scheduler don't work at all, but standart xwiki watchlists - working ... I cannot understand nothing. Maybe somebody can help me. I attached my groovy code (as I said - from another xwiki page - this code working fine). http://xwiki.475771.n2.nabble.com/file/n5667864/groovy_code.txt groovy_code.txt Also, my original question (how need to call velocity code from groovy code in a scheduler) also is interesting for me. Thanks beforehand Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp5666438p5667864.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)
Could be not a script problem at all. If you test the scheduler via triggering, you need to unschedule, then reschedule, then trigger the job. Don't ask me why but it worked for me. -Ursprüngliche Nachricht- Von: users-boun...@xwiki.org [mailto:users-boun...@xwiki.org] Im Auftrag von Eugen Colesnicov Gesendet: Sonntag, 24. Oktober 2010 17:14 An: users@xwiki.org Betreff: Re: [xwiki-users] Using Scheduler issues (groovy questions) Paul Libbrecht wrote: On 24 oct. 2010, at 13:54, Sergiu Dumitriu wrote: call the web page from groovy new java.net.URL(blablalba).getContent() Thanks beforehand! Eugen Yes, but note that the URL will be fetched without any session information, so if the requested page is private (not visible for guests), it won't work. or call http://user:passw...@host:port/xwiki/bin/view/Space/Name Paul, can you give exactly example? What I should write in a scheduler field - Job script? Because of I tried different variants - but without results. Also, I rewrited my original code from velocity to groovy. I tested my groovy rewrited code in a another xwiki page - all is working fine. But when I putted this groovy code to the scheduler - no any actions. Looks like, that scheduler don't work at all, but standart xwiki watchlists - working ... I cannot understand nothing. Maybe somebody can help me. I attached my groovy code (as I said - from another xwiki page - this code working fine). http://xwiki.475771.n2.nabble.com/file/n5667864/groovy_code.txt groovy_code.txt Also, my original question (how need to call velocity code from groovy code in a scheduler) also is interesting for me. Thanks beforehand Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp 5666438p5667864.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] groups: mailing them
Hi! Joris Dirks wrote: I intend to make more use of groups and updating the members on changes relevant to them by sending them e-mail. There is a proposal that seek exactly that! http://dev.xwiki.org/xwiki/bin/view/GoogleSummerOfCode/SendMailtoWikiUsers I've not followed these projects during 2009 and 2010, so, I don't know what is its state. The Using Scheduler issues (groovy questions) actually active could also apply to what you are looking for. Watchlists look too technical/difficult and forcing group members to use them is too cumbersome, so I'd like to start simple: exporting the mail addresses and mailing them the old-fashioned way. Please, Joris, why to do you find technical/difficult the use of Watch? Perhaps I'm misunderstanding you, but all what a user has to do is to check the Watch star for a given document, space, or even the whole wiki. Of course this way users must do the action: they must check the stars! But also any administrator can modify Watch lists in the WatchListClass object of any users. And they also could be modified programmatically (well, don't ask me how, please! :-) Now for the coding: I started with http://code.xwiki.org/xwiki/bin/view/Snippets/CsvExportOfUsersSnippet yet group membership is only enclosed in the objects of the respective group pages. Any suggestions how to either export only members of a set group, or include subscribed groups as a column? As for how to export members of a given group. I've modified slightly the CsvExportOfUsersSnippet snippet. Just change XWiki.XWikiAdminGroup with the document name of the group you want to export: {{velocity}} #if($!{request.confirm} == '1') #set($ok = $response.setContentType(text/csv)) #set($ok = $response.setHeader(Content-disposition, attachment; filename=export-users.csv)) login;firstname;lasname;email;phone #set ($sql = , BaseObject as obj where obj.name = doc.fullName and obj.className = 'XWiki.XWikiUsers' and obj.name 'XWiki.XWikiUserTemplate' order by doc.name asc) #set($groupDoc = $xwiki.getDocument(XWiki.XWikiAdminGroup)) #foreach($user in $xwiki.searchDocuments($sql)) #if($groupDoc.getObject('XWiki.XWikiGroups', 'member', $user)) #set($userDoc = $xwiki.getDocument($user)) $userDoc.name;$userDoc.get('first_name');$userDoc.get('last_name');$userDoc.get('email');$userDoc.get('office_phone') #end #end #else * [[Download CSV list of users of group XWikiAdminGroup?confirm=1xpage=plainoutputSyntax=plain]] #end {{/velocity}} As for groups membership, check this: {{velocity filter=none}} {{html clean=false wiki=true}} #set($user = $xwiki.getUser()) #set($query = , BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className='XWiki.XWikiGroups' and doc.fullName 'XWiki.XWikiGroupTemplate' order by doc.fullName asc) #set($results=$xwiki.searchDocuments($query)) #foreach($item in $results) #if($user.isUserInGroup($item)) [[$item$item]]p/ #end #end {{/html}} {{/velocity}} Now, it will be needed to combine both scripts. I think it will be great to have a selection list to choose the group we/you want to export and, concerning groups membership, I don't know how to store the result in a Velocity variable, then include it as column in the output. This must not be difficult, but I've not tried yet! Any idea about a more elegant way of doing this will be welcome! 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)
Thomas Höschele wrote: Could be not a script problem at all. If you test the scheduler via triggering, you need to unschedule, then reschedule, then trigger the job. Don't ask me why but it worked for me. I made like you said - no result. Also I really waiting for scheduled time - also no result. But another bad thing - after this (manually triggered or automatically triggered the job) the CPU for the JAVA process goes to 100%. No any logs in a jvm or application logs ... - all look like as normal. My config - Windows, Oracle10G, Glassfish 3.01, XWiki Enterprise 2.4. What it can be? Best regards Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp5666438p5668148.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] conditional redirect after login
Hi, The script works fine; One modification required (#if($counter 0) == #if($counter == 0) But this only works when user login is on homepage, in our use cases there are also other pages where a guest can decide to login Is there a vm script that is always triggered when user does login? Gerritjan Op 24 okt 2010, om 01:52 heeft [Ricardo Rodriguez] eBioTIC. het volgende geschreven: Hi, Gerritjan Koekkoek wrote: Hi, We would like to, conditionally, redirect users who log in to their profile page. (in our case; XWiki.username) 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)) p/ #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 ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Using Scheduler issues (groovy questions)
Eugen Colesnicov wrote: ... another bad thing - after this (manually triggered or automatically triggered the job) the CPU for the JAVA process goes to 100%. No any logs in a jvm or application logs ... - all look like as normal. I found what is it!!! I am writing groovy code in a job page with {{groovy}} at the beginning and {{/groovy}} at the end of script. If I do like this - process JAVA.EXE goes to 100%. I simply deleted {{groovy}} and {{/groovy}} and my full groovy script, which I rewritted from my original velocity and pasted in a scheduler job page - started to work. Also I checked this 100% processor using variant at another machine, with another configuration - same situation. Very strange, but I think need to make some notes in a scheduler - that users shouldn't use {{groovy}} at the beginning and {{/groovy}} at the end of script. But, calling velocity or groovy script from scheduler script doesn't work ... I think, I wrote something wrong. Can somebody give me exactly example? Thanks beforehand Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-Scheduler-issues-groovy-questions-tp5666438p5668598.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] conditional redirect after login
Hi, Gerritjan Koekkoek wrote: Hi, The script works fine; One modification required (#if($counter 0) == #if($counter == 0) I'm afraid I don't understand the condition yet! :-( Do you want that any user belonging to any group but XWikiAllGroup is redirected to his/her profile? Or should be only XWikAllGroup members whom must be redirected to his/her profile page? Just trying to understand why do you need == instead o . Thanks! But this only works when user login is on homepage, in our use cases there are also other pages where a guest can decide to login Is there a vm script that is always triggered when user does login? OK! I've not taken this into account! login.vm in your /templates folder seems to be the right place to tweak. Gerritjan Op 24 okt 2010, om 01:52 heeft [Ricardo Rodriguez] eBioTIC. het volgende geschreven: Hi, Gerritjan Koekkoek wrote: Hi, We would like to, conditionally, redirect users who log in to their profile page. (in our case; XWiki.username) 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)) p/ #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 Greetings! -- 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)
On 24 oct. 2010, at 16:29, [Ricardo Rodriguez] eBioTIC. wrote: or call http://user:passw...@host:port/xwiki/bin/view/Space/Name paul _ It doesn't work for me here. Please, any particular requirement/setting on the server side? I don't think so. But I note that I'm using an older xwiki. Could be that they disabled that in more modern ones because it's not a good practice Is it not related with this unresolved issue http://jira.xwiki.org/jira/browse/XWIKI-2018? the scheme there isn't the same. paul ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Using Scheduler issues (groovy questions)
Eugen, you said you have a velocity page, say accessible at http://server/xwiki/bin/iview/MyScheduler/Velo what I was telling is that you should be able to get its execution from groovy with new URL(http://server/xwiki/bin/iview/MyScheduler/Velo;).getContent() and, if you needed secure access for that execution you could request new URL(http://admin:p...@server/xwiki/bin/iview/MyScheduler/Velo;).getContent() provided the user admin has password psps. paul On 24 oct. 2010, at 17:13, Eugen Colesnicov wrote: or call http://user:passw...@host:port/xwiki/bin/view/Space/Name Paul, can you give exactly example? What I should write in a scheduler field - Job script? ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users