Search in sources :

Example 1 with Database

use of nl.knaw.dans.common.dataperfect.Database in project timbuctoo by HuygensING.

the class DataPerfectLoader method loadData.

@Override
public void loadData(List<Tuple<String, File>> files, Importer importer) throws InvalidFileException, IOException {
    Database dbPerfectdb = null;
    try {
        File output = writeZipToTempDir(files.get(0).getRight());
        File dirWithDb = unwrapToplevelDirIfNeeded(output);
        File structureFile = getStructureFile(dirWithDb);
        dbPerfectdb = new Database(structureFile);
        importDbPerfect(importer, dbPerfectdb);
        delete(output);
    } catch (DataPerfectLibException e) {
        throw new InvalidFileException("Not a valid dataperfect file", e);
    } finally {
        try {
            if (dbPerfectdb != null) {
                dbPerfectdb.close();
            }
        } catch (IOException e) {
            LOG.error("Something went wrong while closing the resources in the data import", e);
        }
    }
}
Also used : DataPerfectLibException(nl.knaw.dans.common.dataperfect.DataPerfectLibException) InvalidFileException(nl.knaw.huygens.timbuctoo.bulkupload.InvalidFileException) Database(nl.knaw.dans.common.dataperfect.Database) IOException(java.io.IOException) File(java.io.File)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 DataPerfectLibException (nl.knaw.dans.common.dataperfect.DataPerfectLibException)1 Database (nl.knaw.dans.common.dataperfect.Database)1 InvalidFileException (nl.knaw.huygens.timbuctoo.bulkupload.InvalidFileException)1