#4316: SchemaExpMain.java

tools/org.projectforge.tools.schemaexp/src/main/java/org/projectforge/tools/schemaexp/SchemaExpMain.java

Path: tools/org.projectforge.tools.schemaexp/src/main/java/org/projectforge/tools/schemaexp/SchemaExpMain.java

Type: CLI entry point (standalone, NOT Spring Boot) · Lines: 130 · Author: Roger Rene Kommer

Purpose: Command-line entry point for the SchemaExp tool — manually boots a minimal Spring context, parses CLI arguments, and delegates to SchemaExpService for export/import/clear operations.

Source: GitHub

130 lines · 106 code · 8 comments · 16 blank
CommitMessage
9ebb885222016-07-18 Initial commit

How it differs from the main app

Unlike the main ProjectForge application which uses Spring Boot (SpringApplication.run(ProjectForgeApplication.class, args)), this tool manually bootstraps a plain Spring context:

ApplicationContext context = new AnnotationConfigApplicationContext(SchemaExpContext.class);
TenantRegistryMap.getInstance().setApplicationContext(context);
DatabaseSupport.setInstance(new DatabaseSupport(HibernateUtils.getDialect()));

Three manual bootstrapping steps replace what Spring Boot does automatically: context creation, tenant registry registration, and Hibernate dialect setup. This gives the tool a minimal footprint — no embedded Tomcat, no Spring Security, no Quartz scheduler.

CLI argument parsing

The tool accepts options followed by a single file argument. Supported flags:

FlagEffect
-expExport operation → SchemaExpService.doExport()
-impImport operation → SchemaExpService.doImport()
-cleardbDrop all tables before import (or standalone clear)
-insertnewRestoreMode.InsertNew — skip existing records
-overwriteRestoreMode.OverWrite — update existing records
-insertallRestoreMode.InsertAll — insert everything (default)

The option parser (parseOption(), lines 40-65) uses StringUtils.equalsIgnoreCase() for case-insensitive matching. Positional options — flags must come before the file argument. The while (parseOption(args, pos++)) loop (line 78) iterates until it hits a non-option, then --pos backs up to point at the first non-option argument (the filename).

Known issues