* Run the tool and write to the optionally provided map
*/
public static void run(JDBCConfiguration conf, String[] args, Flags flags, ClassLoader loader,
Map<Class<?>, String> output) throws IOException, SQLException {
// parse the schema to reverse-map
Log log = conf.getLog(OpenJPAConfiguration.LOG_TOOL);
SchemaGroup schema;
if (args.length == 0) {
log.info(_loc.get("revtool-running"));
SchemaGenerator gen = new SchemaGenerator(conf);
gen.generateSchemas();
schema = gen.getSchemaGroup();
} else {
SchemaParser parser = new XMLSchemaParser(conf);
File file;
for (int i = 0; i < args.length; i++) {
file = Files.getFile(args[i], loader);
log.info(_loc.get("revtool-running-file", file));
parser.parse(file);
}
schema = parser.getSchemaGroup();
}
// flags
ReverseMappingTool tool = newInstance(conf);
tool.setSchemaGroup(schema);
tool.setPackageName(flags.packageName);
tool.setDirectory(flags.directory);
tool.setUseSchemaName(flags.useSchemaName);
tool.setUseForeignKeyName(flags.useForeignKeyName);
tool.setNullableAsObject(flags.nullableAsObject);
tool.setBlobAsObject(flags.blobAsObject);
tool.setUseGenericCollections(flags.useGenericCollections);
tool.setTypeMap(flags.typeMap);
tool.setPrimaryKeyOnJoin(flags.primaryKeyOnJoin);
tool.setUseDataStoreIdentity(flags.useDataStoreIdentity);
tool.setUseBuiltinIdentityClass(flags.useBuiltinIdentityClass);
tool.setInnerIdentityClasses(flags.innerIdentityClasses);
tool.setIdentityClassSuffix(flags.identityClassSuffix);
tool.setInverseRelations(flags.inverseRelations);
tool.setDetachable(flags.detachable);
tool.setGenerateAnnotations(flags.generateAnnotations);
tool.setAccessType(flags.accessType);
tool.setCustomizer(flags.customizer);
tool.setCodeFormat(flags.format);
tool.setUseSchemaElement(flags.useSchemaElement);
// run
log.info(_loc.get("revtool-map"));
tool.run();
if (flags.generateAnnotations) {
log.info(_loc.get("revtool-gen-annos"));
tool.buildAnnotations();
}
log.info(_loc.get("revtool-write-code"));
tool.recordCode(output);
if (!LEVEL_NONE.equals(flags.metaDataLevel)) {
log.info(_loc.get("revtool-write-metadata"));
tool.recordMetaData(LEVEL_CLASS.equals(flags.metaDataLevel));
}
}