SchemaExpService.java| Commit | Date | Message |
|---|---|---|
a5bbdca6a | 2017-12-04 | Change logger to slf4j |
9ebb88522 | 2016-07-18 | Initial commit |
clearDb() (lines 49-52): Calls emfac.getJpaSchemaService().clearDatabase() — drops all tables in reverse dependency order. This is a destructive operation with no undo. Used both standalone (-cleardb flag) and as a prerequisite for imports (-cleardb -imp).
doImport(boolean clearDb, String clientFileName, RestoreMode modus) (lines 54-87): The main import pipeline: (1) optionally clear the database, (2) validate file existence, (3) detect file format (.xml vs .xml.gz) and decompress if needed, (4) delegate to the selected engine, (5) handle cleanup in finally block. The RestoreMode enum controls conflict resolution: InsertNew skips existing records, OverWrite updates them, InsertAll inserts everything (fails on duplicates).
doExport(String fileName) (lines 89-94): Delegates to jpaXmlDumpService.dumpToXml(emfac, file). Unlike import, export always uses the Genome library — there's no legacy XStream export path. Queries all entity types from JPA metadata, loads all records (full table scans), and serializes to XML with JPA-aware marshalling.
TransactionTemplate txTemplate (line 32) is injected but never used — dead code.IOUtils.closeQuietly() (line 84) is deprecated in Apache Commons IO 2.7+. Should use try-with-resources.SchemaExpMain.initApplicatinContext() (missing 'o' in "Application") is called by all tests.useJpaXmlDumpService = true should ideally be a Spring @Value property for runtime configuration.
The class's most notable architectural feature is its dual-engine import system, controlled by
useJpaXmlDumpService = true(line 47):true(default)de.micromata.genome.db.jpa.xmldumpfalseXmlDumpverifyDump(), post-import integrity checks viaConfigurationDaoThe Genome engine is preferred because it understands JPA entity metadata — it correctly handles
@OneToManycascades,@Inheritancestrategies, and foreign key relationships during import. The legacy engine is retained for backward compatibility.