Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist Data #14

Open
muuki88 opened this issue Feb 22, 2013 · 0 comments
Open

Persist Data #14

muuki88 opened this issue Feb 22, 2013 · 0 comments

Comments

@muuki88
Copy link
Member

muuki88 commented Feb 22, 2013

Storing the data is a two step process.

Create a Data instance

You must find the correct sensor in the database first.

Sensor sensor = em.find(Sensor.class, "the-sensor-id");
Data data = new Data(from, to, sensor);
em.persist(data);

Helpfull classes:

Copy files

After the sensor is persisted, you have to copy the files to the harddrive.

ISensor sensorInstance = ... // from sensorManager, not db instance!
Data data = new Data(from, to, sensor);
try (InputStream in = sensorInstance.getDataInputStream()) {
   // data.toPath() gets the harddrive path
   Files.copy(in, data.toPath());
}
@ghost ghost self-assigned this Feb 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant