Skip to content

Persist Data #14

Description

@muuki88

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());
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions