unique persistence ids

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

unique persistence ids

bwallis42
Orbeon generates unique ids for form templates and instances that are used at the persistence API when forms are stored. Can I substitute in my own ID generation instead of using the ones generated within Orbeon?

I can use the current generated ones but that means I need to have a mapping from that to the IDs inside our system when forms are stored via the persistence API. It would simplify things a bit if I could just use my own unique IDs in the first place.

thanks
Reply | Threaded
Open this post in threaded view
|

Re: unique persistence ids

bwallis42
Is there no way to do this?
Reply | Threaded
Open this post in threaded view
|

Re: unique persistence ids

bwallis42
Can I take a different tack on this? Hopefully someone will answer this?

Can I just ignore the unique ID used when saving or publishing a form definition and substitute my own that I then return in query results.

Are queries over the persistence API the only way orbeon builder and and form runner get the IDs that are used to save and publish forms and templates? Can I just use my unique ID in the name attribute of the document element in the query response?

thanks
Reply | Threaded
Open this post in threaded view
|

Re: unique persistence ids

Aaron Spike
In the absence of a definitive answer, you could do some experimentation. I have Orbeon Forms running against PostgreSQL. I saved a form and then changed the document_id using the database console. I'm able to edit the form and come back to the page and view it again. Haven't noticed any problems yet.

And here are links to a few interesting lines in the source code if you are inclined to take the investigation further:
https://github.com/orbeon/orbeon-forms/blob/master/src/resources/apps/fr/includes/persistence/persistence-model.xml#L78
https://github.com/orbeon/orbeon-forms/blob/master/src/main/scala/org/orbeon/oxf/util/SecureUtils.scala#L199

Aaron Spike

This electronic communication, including any attached documents, may contain confidential and/or legally privileged information that is intended only for use by the recipient(s) named above. If you have received this communication in error, please notify the sender immediately and delete the communication and any attachments. Views expressed by the author do not necessarily represent those of Martin Luther College.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: unique persistence ids

Alessandro  Vernet
Administrator
In reply to this post by bwallis42
Hi Brian,

What you have there is a common use case. Essentially you want to be able to correlate information users enter in a form with something else that makes sense in your context. Let's say you have a token for that something else, i.e. some kind of id. You could imagine to make the document id equal to that token, but Form Runner doesn't allow you to do that, but however can do the following.

You can pass that token as a request parameter to the new page (/new?token=123). Then, in the form, you have a field that you use to store that token. To do that, you put that field in an "Internal" section, with the visibility set to false(), so users never see it, and have the field initial value set to xxf:get-request-parameter('token').

With this, the token will be stored as part of the data, e.g. under /form/internal/token. If you want to store multiple pieces of information, just use multiple fields. And here the value comes from a request parameter, but it could also come from an HTTP header, using xxf:get-request-header('your-header'), say if you have a reverse proxy or servlet filter that can set the value of that header.

You'll let us know if this works for you!

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: unique persistence ids

bwallis42
To get back to an old question.

I don't think a field in every form template is a good way to do this. We allow customers to design their own forms and we have consultants who do the same for our customers. Requiring an extra field to be present in every form design to allow the form to work with our system is not a great way to do this.

I tried the approach I suggested above of just essentially ignoring the generated ID and returning my own ID in search results and that was working OK until I added attachments to the forms. What I see in the xform data for an attached image is the following

<control-6 filename="27-10-09_1558.jpg" mediatype="image/jpeg" size="241927">
  /fr/service/persistence/crud/cpf/FormWithThreeImages/data/1202fee07e87e39058e22f21ada3bfbf25235e04/893c9f48ebac26c9535ac7709a8224a141afad82.bin
</control-6>

So the original ID is still used in the attachment (this is for when you create a new form, I haven't tried an edit of an existing form yet).

I can add a mapping component within our persistence implementation but that is sort of difficult to do and would require a schema change in our product which we try to avoid.

Any other suggestions? I really would like to be able to use our own ID.

thanks
brian...
Reply | Threaded
Open this post in threaded view
|

Re: unique persistence ids

Alessandro  Vernet
Administrator
Hi Brian,

Yes, I understand how impractical having to add a field in every form is in your case. If you really need to provide your own id, then maybe the easiest way to do it is to change the Form Runner code to, instead of calling secure:randomHexId(), call your code that generates an id. The main occurrence is:


This same secure:randomHexId() is also called if you're using the dialog that can show on submit with the "clear" and "keep" buttons, and if you have a duplicate button. If you don't, the place pointed above is the only one you need to change, and since this is an XML file, it should be pretty easy to do (no need to recompile Orbeon Forms).

Alex

On Tue, Apr 14, 2015 at 3:01 PM, bwallis42 <[hidden email]> wrote:
To get back to an old question.

I don't think a field in every form template is a good way to do this. We
allow customers to design their own forms and we have consultants who do the
same for our customers. Requiring an extra field to be present in every form
design to allow the form to work with our system is not a great way to do
this.

I tried the approach I suggested above of just essentially ignoring the
generated ID and returning my own ID in search results and that was working
OK until I added attachments to the forms. What I see in the xform data for
an attached image is the following



So the original ID is still used in the attachment (this is for when you
create a new form, I haven't tried an edit of an existing form yet).

I can add a mapping component within our persistence implementation but that
is sort of difficult to do and would require a schema change in our product
which we try to avoid.

Any other suggestions? I really would like to be able to use our own ID.

thanks
brian...


--
View this message in context: http://discuss.orbeon.com/unique-persistence-ids-tp4659101p4659806.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet