Re: [xwiki-users] Implement Jsontool.serialize in groovy

2014-07-01 Thread Eduardo Abritta
Hi Thomas, I instantiate the jsonbuilder as follows in the example yet returned 
to previous error that was not allow adding elements in my "json" method. "Add 
()". 
I have also realized by placing the method within an array as criuado test 
("data.projetos [i]. Id.add ()").

{{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name and 
obj.className = 'E-nova.E-novaClass'";def listProjetos = 
services.query.hql(hql0).execute();def i = 0;def data = new 
groovy.json.JsonBuilder();data = ["totalprojetos": 
listProjetos.size(),"projetos": [ id: "", tag: "", label: "", size: "", color: 
"", x: "", y : "" ],"edges":[ id: "", source: "", target: "" ]];
for(item in listProjetos){ def hql = "select distinct list from BaseObject as 
obj, DBStringListProperty as prop join prop.list list where 
obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
and obj.name ='$item' ";def tag = services.query.hql(hql).execute(); i = i + 1; 
data.projetos.id.add()=1; data.projetos.tag.add()="tags"; 
data.projetos.label.add()="Label do projeto"; data.projetos.size.add()=5; 
data.projetos.color.add()="#696969"; data.projetos.x.add()=1; 
data.projetos.y.add()= 1;}
def json = new groovy.json.JsonBuilder(data)println 
json.toPrettyString(){{/groovy}}
Atenciosamente,
Eduardo Abritta
e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631

> From: eduardo.abri...@outlook.com
> To: users@xwiki.org
> Date: Mon, 30 Jun 2014 15:23:37 -0300
> Subject: Re: [xwiki-users] Implement Jsontool.serialize in groovy
> 
> I'm trying to implement a function that told me but I can not add the data 
> online, I can only add one. How do I do that?
{{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name and 
obj.className = 'E-nova.E-novaClass'";def listProjetos = 
services.query.hql(hql0).execute();def i = 0;def data = new 
groovy.json.JsonBuilder();data = ["totalprojetos": 
listProjetos.size(),"projetos": [  id: "",  tag: "",
  label: "",  size: "",  color: "", 
 x: "",  y : ""],"edges":[id: "",   
 source: "",target: ""]];
for(item in listProjetos){ def hql = "select distinct list from BaseObject as 
obj, DBStringListProperty as prop join prop.list list where 
obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
and obj.name ='$item' ";def tag = services.query.hql(hql).execute(); i = i + 1; 
data.projetos.id=1; data.projetos.tag="tags"; data.projetos.label="Label do 
projeto"; data.projetos.size=5; data.projetos.color="#696969"; 
data.projetos.x=1; data.projetos.y= 1;}
def json = new groovy.json.JsonBuilder(data)println 
json.toPrettyString(){{/groovy}}
> Atenciosamente,
> Eduardo Abritta
> e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631
> 
> 
> 
> > Date: Fri, 27 Jun 2014 11:51:47 +0200
> > From: thomas.morta...@xwiki.com
> > To: users@xwiki.org
> > Subject: Re: [xwiki-users] Implement Jsontool.serialize in groovy
> > 
> > You should probably use JsonBuilder which is the standard tool to
> > manipulate JSON in Groovy.
> > 
> > On Fri, Jun 27, 2014 at 10:33 AM, Clemens Klein-Robbenhaar
> >  wrote:
> > >
> > > The velocity tools are not automatically created for groovy scripts
> > > The closest you can get is to create them manually in your script, like:
> > >
> > >  def jsontool = new org.xwiki.velocity.tools.JSONTool()
> > >
> > > I feel there should be a better way to do that, but it works this way.
> > > (it is likely that using groovy.json.JsonBuilder() works, too, but I have 
> > > not tried)
> > >
> > > Clemens
> > >
> > > On 06/24/2014 09:21 PM, Eduardo Abritta wrote:
> > >> Hello Sirs,
> > >> I need to implement the function "jsontool.serialize" in the code below, 
> > >> groovy, and I do not understand the error that is accusing, can help me 
> > >> solve this?
> > >> {{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name 
> > >> and obj.className = 'E-nova.E-novaClass'";def listProjetos = 
> > >> services.query.hql(hql0).execute();def json = ['totalprojetos': 
> > >> listProjetos.size(),

Re: [xwiki-users] Implement Jsontool.serialize in groovy

2014-06-30 Thread Eduardo Abritta
I'm trying to implement a function that told me but I can not add the data 
online, I can only add one. How do I do that?
{{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name and 
obj.className = 'E-nova.E-novaClass'";def listProjetos = 
services.query.hql(hql0).execute();def i = 0;def data = new 
groovy.json.JsonBuilder();data = ["totalprojetos": 
listProjetos.size(),"projetos": [  id: "",  tag: "",
  label: "",  size: "",  color: "", 
 x: "",  y : ""],"edges":[id: "",   
 source: "",target: ""]];
for(item in listProjetos){  def hql = "select distinct list from BaseObject as 
obj, DBStringListProperty as prop join prop.list list where 
obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
and obj.name ='$item' ";def tag = services.query.hql(hql).execute();i = 
i + 1;data.projetos.id=1;data.projetos.tag="tags";
data.projetos.label="Label do projeto";data.projetos.size=5;
data.projetos.color="#696969";data.projetos.x=1;data.projetos.y= 1;}
def json = new groovy.json.JsonBuilder(data)println 
json.toPrettyString(){{/groovy}}
Atenciosamente,
Eduardo Abritta
e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631



> Date: Fri, 27 Jun 2014 11:51:47 +0200
> From: thomas.morta...@xwiki.com
> To: users@xwiki.org
> Subject: Re: [xwiki-users] Implement Jsontool.serialize in groovy
> 
> You should probably use JsonBuilder which is the standard tool to
> manipulate JSON in Groovy.
> 
> On Fri, Jun 27, 2014 at 10:33 AM, Clemens Klein-Robbenhaar
>  wrote:
> >
> > The velocity tools are not automatically created for groovy scripts
> > The closest you can get is to create them manually in your script, like:
> >
> >  def jsontool = new org.xwiki.velocity.tools.JSONTool()
> >
> > I feel there should be a better way to do that, but it works this way.
> > (it is likely that using groovy.json.JsonBuilder() works, too, but I have 
> > not tried)
> >
> > Clemens
> >
> > On 06/24/2014 09:21 PM, Eduardo Abritta wrote:
> >> Hello Sirs,
> >> I need to implement the function "jsontool.serialize" in the code below, 
> >> groovy, and I do not understand the error that is accusing, can help me 
> >> solve this?
> >> {{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name 
> >> and obj.className = 'E-nova.E-novaClass'";def listProjetos = 
> >> services.query.hql(hql0).execute();def json = ['totalprojetos': 
> >> listProjetos.size(), 'projetos':[1000] , 'edges':[1000] ];def i = 0;
> >> for(item in listProjetos){def hql = "select distinct list from 
> >> BaseObject as obj, DBStringListProperty as prop join prop.list list where 
> >> obj.className='XWiki.TagClass' and obj.id=prop.id.id and 
> >> prop.id.name='tags' and obj.name ='$item' ";def tag = 
> >> services.query.hql(hql).execute();i = i + 1;
> >> json.projetos.add({id: xwiki.getDocument(item).getName()})}
> >> jsontool.serialize(json);
> >> {{/groovy}}
> >> Ty.
> >> Atenciosamente,
> >> Eduardo Abritta
> >> e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631
> >>
> >>
> >> ___
> >> 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
> 
> 
> 
> -- 
> Thomas Mortagne
> ___
> 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] Implement Jsontool.serialize in groovy

2014-06-27 Thread Thomas Mortagne
You should probably use JsonBuilder which is the standard tool to
manipulate JSON in Groovy.

On Fri, Jun 27, 2014 at 10:33 AM, Clemens Klein-Robbenhaar
 wrote:
>
> The velocity tools are not automatically created for groovy scripts
> The closest you can get is to create them manually in your script, like:
>
>  def jsontool = new org.xwiki.velocity.tools.JSONTool()
>
> I feel there should be a better way to do that, but it works this way.
> (it is likely that using groovy.json.JsonBuilder() works, too, but I have not 
> tried)
>
> Clemens
>
> On 06/24/2014 09:21 PM, Eduardo Abritta wrote:
>> Hello Sirs,
>> I need to implement the function "jsontool.serialize" in the code below, 
>> groovy, and I do not understand the error that is accusing, can help me 
>> solve this?
>> {{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name and 
>> obj.className = 'E-nova.E-novaClass'";def listProjetos = 
>> services.query.hql(hql0).execute();def json = ['totalprojetos': 
>> listProjetos.size(), 'projetos':[1000] , 'edges':[1000] ];def i = 0;
>> for(item in listProjetos){def hql = "select distinct list from 
>> BaseObject as obj, DBStringListProperty as prop join prop.list list where 
>> obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
>> and obj.name ='$item' ";def tag = services.query.hql(hql).execute();
>> i = i + 1;
>> json.projetos.add({id: xwiki.getDocument(item).getName()})}
>> jsontool.serialize(json);
>> {{/groovy}}
>> Ty.
>> Atenciosamente,
>> Eduardo Abritta
>> e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631
>>
>>
>> ___
>> 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



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


Re: [xwiki-users] Implement Jsontool.serialize in groovy

2014-06-27 Thread Clemens Klein-Robbenhaar

The velocity tools are not automatically created for groovy scripts
The closest you can get is to create them manually in your script, like:

 def jsontool = new org.xwiki.velocity.tools.JSONTool()

I feel there should be a better way to do that, but it works this way.
(it is likely that using groovy.json.JsonBuilder() works, too, but I have not 
tried)

Clemens

On 06/24/2014 09:21 PM, Eduardo Abritta wrote:
> Hello Sirs,
> I need to implement the function "jsontool.serialize" in the code below, 
> groovy, and I do not understand the error that is accusing, can help me solve 
> this?
> {{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name and 
> obj.className = 'E-nova.E-novaClass'";def listProjetos = 
> services.query.hql(hql0).execute();def json = ['totalprojetos': 
> listProjetos.size(), 'projetos':[1000] , 'edges':[1000] ];def i = 0;
> for(item in listProjetos){def hql = "select distinct list from BaseObject 
> as obj, DBStringListProperty as prop join prop.list list where 
> obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
> and obj.name ='$item' ";def tag = services.query.hql(hql).execute();i 
> = i + 1;
> json.projetos.add({id: xwiki.getDocument(item).getName()})}
> jsontool.serialize(json);
> {{/groovy}}
> Ty.
> Atenciosamente,
> Eduardo Abritta
> e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631
> 
> 
> ___
> 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


[xwiki-users] Implement Jsontool.serialize in groovy

2014-06-24 Thread Eduardo Abritta
Hello Sirs,
I need to implement the function "jsontool.serialize" in the code below, 
groovy, and I do not understand the error that is accusing, can help me solve 
this?
{{groovy}}def hql0 = ", BaseObject as obj where doc.fullName = obj.name and 
obj.className = 'E-nova.E-novaClass'";def listProjetos = 
services.query.hql(hql0).execute();def json = ['totalprojetos': 
listProjetos.size(), 'projetos':[1000] , 'edges':[1000] ];def i = 0;
for(item in listProjetos){  def hql = "select distinct list from BaseObject 
as obj, DBStringListProperty as prop join prop.list list where 
obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' 
and obj.name ='$item' ";def tag = services.query.hql(hql).execute();i = 
i + 1;
json.projetos.add({id: xwiki.getDocument(item).getName()})}
jsontool.serialize(json);
{{/groovy}}
Ty.
Atenciosamente,
Eduardo Abritta
e-mail: eduardo.abri...@outlook.com | cel: (32)8472-9631

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