RE: Orbeon GUID

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: Orbeon GUID

gino-m
This post was updated on .
Brian,

I got this working for controlling this ID when saving new resource.  Also, if I change
the ID when editing an existing  resource, it is saved to the correct
collection, but the old collection in not removed.  Any ideas where to put
the hook to remove the old?  Perhaps an observer on fr-persistence-instance?

I was hoping there was some built-in functionality of fr that handled this,
but I guess it's easy enough to implement ourselves, provided we have a safe
way to know the resource was saved correctly..

Thanks again!

-Gino

 
Gino Miceli
Forest Information Systems Specialist
Food and Agriculture Organization of the United Nations
FAO-Finland Cooperation Programme
Sustainable Forest Management in a Changing Climate
Forest Management Division, Rm. D-406
Viale delle Terme di Caracalla, s.n.c.
00153 Rome, Italy
http://www.fao.org/forestry
Reply | Threaded
Open this post in threaded view
|

Re: RE: Orbeon GUID

Brian_Steuhl
Gino,
 
Not sure why you would change the ID on an existing resource but if you wanted to and needed to delete the old one you could call the eXist REST API using the method="Delete".  I would only run this after you were sure the other resource was renamed and saved (for example put it in the xforms submission with an action with two attributes ev:observer="submission id"  and ev:event="xforms-submit-done" and then call the submission id <xforms:send submission="deleteResource" /> to delete resource.
Brian Steuhl, Business Analyst
E-mail: [hidden email]
Home Office: 732-961-3187
Cell: 908-421-0742

-----"Miceli, Gino (FOMR)" [hidden email] wrote: -----

To: Brian Steuhl <[hidden email]>, [hidden email]
From: "Miceli, Gino (FOMR)" <[hidden email]>
Date: 03/23/2010 11:14AM
Subject: [ops-users] RE: Orbeon GUID

Brian,

 

I got this working for controlling this ID when saving new resource (note: I had to enable write permissions on the ‘data’ collection).  Also, if I change the ID when editing an existing  resource, it is saved to the correct collection, but the old collection in not removed.  Any ideas where to put the hook to remove the old?  Perhaps an observer on fr-persistence-instance?

 

I was hoping there was some built-in functionality of fr that handled this, but I guess it’s easy enough to implement ourselves, provided we have a safe way to know the resource was saved correctly..

 

Thanks again!

-Gino

 

From: Brian Steuhl [mailto:[hidden email]]
Sent: 22 March 2010 18:43
To: Miceli, Gino (FOMR)
Subject: Orbeon GUID

 

Gino,

 

All you have to do is replace (xforms:setvalue) the orbeon document ID with the ID you pass in on xforms:action ev:event="xforms-model-construct-done".

 

This than changes the orbeon instance that holds the document element they generate and store in exist for retrieval later on.

 


 


Brian Steuhl
website: http://BTMSoftwareSolutions.com
business email: [hidden email]
cell: 908-421-0742


home office: 732-961-3187
RSS Feed To My Blog:

Business Process Modeling - BTMSoftwareSolutions.com

 


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Re: RE: Orbeon GUID

gino-m

Hi Brian,

 

As mentioned, each form has an ID which we would like reflected in the database and form URLs.  If the user creates the form with the wrong ID, but fills it and saves anyway, we would still like the user to be able to move that data to the correct location/document.

 

Good idea to use the eXist REST API to delete the resource.  Peeking through the fr code, I see that there is also a way to delete a form using the existing fr persistence mode:

 

<xforms:dispatch name="fr-delete-data" target="fr-persistence-model">

<xxforms:context name="document-id" select="$state/original_id"/>

</xforms:dispatch>

 

This would be an elegant solution, but as far as I can tell, the trigger submit doesn’t delete the containing  collection, but only the data.xml resource.  So instead, I will use eXist REST directly as you suggested:

 

<xforms:action ev:observer="fr-create-update-submission" ev:event="xforms-submit-done" if="not($state/original_id=id)">

      <xforms:send submission="delete-old-submission"/>

      <xforms:load resource="{id}"/>

</xforms:action>

     

<xforms:submission id="delete-old-submission" method="delete" serialization="none"

       resource="/exist/rest/db/myapp/myform/data/{$state/original_id}" replace="none"/>

 

This does two things; after save, it deletes the old collection (and resource), and redirects to the new edit form via relative URL.  {id} is the id element in my fr-form-instance, and to keep a copy of the original document id around:

 

<xforms:action ev:event="xforms-model-construct-done">

      <xxforms:variable name="original-id" model="fr-parameters-model" select="data(document)" />

      <xforms:setvalue ref="$state/original_id" value="$original-id"/>

      <xforms:action if="id = ''">

            <xforms:setvalue ref="id" value="$original-id"/>

      </xforms:action>

</xforms:action>

 

Note that I also copy the id to my instance if it is not already there.  This lets the app create new instance just by pointing to the appropriate form edit URL.

 

Everything works now; the only piece left is the warn if the document already exists.   I hope this info may be helpful to you or someone else!

 

-Gino

 

P.S. Please ignore my previous comment about having to set collection permissions in eXist; the permissions were wrong because I was entering test data as admin, but fr works by default as ‘guest’.  If the data were created through fr as it would be in production, the owner of the collection would be ‘guest’ and there would be no problem.

 

From: [hidden email] [mailto:[hidden email]]
Sent: 23 March 2010 16:34
To: [hidden email]
Subject: [ops-users] Re: RE: Orbeon GUID

 

Gino,

 

Not sure why you would change the ID on an existing resource but if you wanted to and needed to delete the old one you could call the eXist REST API using the method="Delete".  I would only run this after you were sure the other resource was renamed and saved (for example put it in the xforms submission with an action with two attributes ev:observer="submission id"  and ev:event="xforms-submit-done" and then call the submission id <xforms:send submission="deleteResource" /> to delete resource.

Brian Steuhl, Business Analyst
E-mail: [hidden email]
Home Office: 732-961-3187
Cell: 908-421-0742

 

-----"Miceli, Gino (FOMR)" [hidden email] wrote: -----

To: Brian Steuhl <[hidden email]>, [hidden email]
From: "Miceli, Gino (FOMR)" <[hidden email]>
Date: 03/23/2010 11:14AM
Subject: [ops-users] RE: Orbeon GUID

Brian,

 

I got this working for controlling this ID when saving new resource (note: I had to enable write permissions on the ‘data’ collection).  Also, if I change the ID when editing an existing  resource, it is saved to the correct collection, but the old collection in not removed.  Any ideas where to put the hook to remove the old?  Perhaps an observer on fr-persistence-instance?

 

I was hoping there was some built-in functionality of fr that handled this, but I guess it’s easy enough to implement ourselves, provided we have a safe way to know the resource was saved correctly..

 

Thanks again!

-Gino

 

From: Brian Steuhl [mailto:[hidden email]]
Sent: 22 March 2010 18:43
To: Miceli, Gino (FOMR)
Subject: Orbeon GUID

 

Gino,

 

All you have to do is replace (xforms:setvalue) the orbeon document ID with the ID you pass in on xforms:action ev:event="xforms-model-construct-done".

 

This than changes the orbeon instance that holds the document element they generate and store in exist for retrieval later on.

 


 


Brian Steuhl
website: http://BTMSoftwareSolutions.com
business email: [hidden email]
cell: 908-421-0742


home office: 732-961-3187
RSS Feed To My Blog:

Business Process Modeling - BTMSoftwareSolutions.com

 


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
OW2 mailing lists service home page: http://www.ow2.org/wws

 



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Gino Miceli
Forest Information Systems Specialist
Food and Agriculture Organization of the United Nations
FAO-Finland Cooperation Programme
Sustainable Forest Management in a Changing Climate
Forest Management Division, Rm. D-406
Viale delle Terme di Caracalla, s.n.c.
00153 Rome, Italy
http://www.fao.org/forestry