Persisting with rails, preprocess with java?

I’m fairly new to jruby and rails and I have searched high and low for
an
answer to this problem, but
haven’t been able to solve it.

My dilema: I have a java library that takes a file, parses the contents
and
stores the contents in individual
vectors. The file may have a 100 names and 100 addresses and so I would
have
2 vectors…

What I want to do is have a very simple web interface that takes the
name of
the file, sends it to the java library which parses it, then use rails
to
access the vectors and persist the data to my database.

So far all I’ve seen on the CRUD tutorials is saving data via a
form…but
the data I want to save is not in the form and I am saving hundreds of
records at once, not just simple form data.

Does anyone know how I would go about doing this? A simple example of
using
the rails controller to do this would be most helpful.

By the way, I know that I could probably use gems to parse the data in
the
file, but my real question is how to call a library that returns results
and
then persist it in some way…especially when I have 100s or 1000s of
rows
that need to be inserted into the database.

Thanks very much for the time!


View this message in context:
http://www.nabble.com/persisting-with-rails%2C-preprocess-with-java--tp23912314p23912314.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

rmacedon wrote:

By the way, I know that I could probably use gems to parse the data in the
file, but my real question is how to call a library that returns results and
then persist it in some way…especially when I have 100s or 1000s of rows
that need to be inserted into the database.

You should be able to call the library without any trouble. My
recommendation once you have the vectors would be to simply iterate over
them and construct your ActiveRecord model objects to persist. If you
start to see that’s too much data to do an object at a time, you may
need to look into some bulk way of inserting the data (I’m not familiar
with how to do that with AR).

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email