Thanks.
-----Mensaje original-----
De: users-bounces(a)xwiki.org [mailto:users-bounces@xwiki.org] En nombre de Jeremie
BOUSQUET
Enviado el: miércoles, 24 de febrero de 2010 11:16
Para: XWiki Users
Asunto: Re: [xwiki-users] Autoincrement value in class
Well,
You can't execute code directly in a class property, you have to manage this
code at object creation time.
I see another possibility, if your matter is only that the Id should be
unique, you can directly use the Id of the object as Id of your bug. In a
HQL request it would be merely a "select obj.id from BaseObject obj where
..." to retrieve the ids of the bugs, and you would not have to manage this
id at all.
If you really need the bugs ids to be consecutive, and you have a property
"bugid" in your class, you can use something like the following to retrieve
last id before creating a new bug :
{{velocity}}
#set($sql="select max(ints.value) from IntegerProperty ints where ints.name
='bugid'")
#set($max=$xwiki.search($sql)[0])
{{/velocity}}
Then increment and use it to set value for 'bugid' in object to create.
You could also imagine adding all bug objects to the same xwiki documents,
and Ids will directly be the number of the object. But this might not be
very efficient if you have a large number of bugs in the system.
Of course I admit you programmatically create the new bugs in a page using
$doc.newObject(...). And it could be a good idea to check the range of
possible ids and check the max is not reached ;)
Jeremie
2010/2/24 Hernández Cuchí, Francisco Ricardo <francisco.hernandez(a)oepm.es>
I need it because I am using the xwiki for tracking
bugs and errors for a
external development. I goes quite good. And to get a unique identifier for
every "bug" created.
How can I get some code executed in one of the properties of the class, so
the property get's the value you mentioned?
Regards
Francisco
-----Mensaje original-----
De: users-bounces(a)xwiki.org [mailto:users-bounces@xwiki.org] En nombre de
Jeremie BOUSQUET
Enviado el: miércoles, 24 de febrero de 2010 9:54
Para: XWiki Users
Asunto: Re: [xwiki-users] Autoincrement value in class
Hi,
Do you mean, a property value that autoincrements each time you create an
object of this class ?
I don't think there is "built-in" ... But if you manage the process of
creation of objects, you can code the autoincrement yourself (for example
searching last value from most recent object then incrementing for new
object).
What do you need this for ?
Jeremie
2010/2/23 Hernández Cuchí, Francisco Ricardo <francisco.hernandez(a)oepm.es>
Hello,
I would like to create a class, with a number property that will be
autoincrement. Is it posible? How can I do it?
Thanks
Francisco
--
Francisco Hernández Cuchí
Jefe de Servicios Sistemas de Información
OFICINA ESPAÑOLA DE PATENTES Y MARCAS
**********************************************************************************************
IMPORTANTE: El contenido de este correo y
ficheros adjuntos es
confidencial
y está dirigido únicamente
para el destinatario/s.
Si Ud recibe este correo por error, por favor póngase en contacto con su
administrador de correo o con el
emisor immediatamente y no difunda su contenido a nadie ni haga copias.
*** Este correo ha sido escaneado de virus y contenido malicioso ***
**********************************************************************************************
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
**********************************************************************************************
IMPORTANTE: El contenido de este correo y ficheros adjuntos es confidencial
y está dirigido únicamente
para el destinatario/s.
Si Ud recibe este correo por error, por favor póngase en contacto con su
administrador de correo o con el
emisor immediatamente y no difunda su contenido a nadie ni haga copias.
*** Este correo ha sido escaneado de virus y contenido malicioso ***
**********************************************************************************************
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
**********************************************************************************************
IMPORTANTE: El contenido de este correo y ficheros adjuntos es confidencial y está
dirigido únicamente
para el destinatario/s.
Si Ud recibe este correo por error, por favor póngase en contacto con su administrador de
correo o con el
emisor immediatamente y no difunda su contenido a nadie ni haga copias.
*** Este correo ha sido escaneado de virus y contenido malicioso ***
**********************************************************************************************