public boolean streamIndividualFactory() { ModelCompiler compiler = ModelCompilerFactory.newModelCompiler(ModelFactory.CompileTarget.XSDX); SemanticXSDModel xsdModel; xsdModel = (SemanticXSDModel) compiler.compile(model); boolean success = false; try { String classPath = getXjcDir().getPath() + File.separator + xsdModel.getDefaultPackage().replace(".", File.separator); File f = new File(classPath); if (!f.exists()) { f.mkdirs(); } FileOutputStream fos = new FileOutputStream(classPath + File.separator + "IndividualFactory.java"); success = xsdModel.streamIndividualFactory(fos); fos.flush(); fos.close(); } catch (Exception e) { e.printStackTrace(); return false; } return success; }
protected boolean streamPersistenceConfigs( SemanticXSDModelCompiler xcompiler, SemanticXSDModel xmlModel) throws IOException { boolean success; xcompiler.mergeNamespacedPackageInfo(xmlModel); success = xmlModel.streamNamespacedPackageInfos(getXjcDir()); File f2 = new File(getMetaInfDir().getPath() + File.separator + "empire.configuration.file"); if (f2.exists()) { xcompiler.mergeEmpireConfig(f2, xmlModel); } FileOutputStream fos2 = new FileOutputStream(f2); success = success && xmlModel.streamEmpireConfig(fos2); fos2.flush(); fos2.close(); File f3 = new File(getMetaInfDir().getPath() + File.separator + "empire.annotation.index"); if (f3.exists()) { xcompiler.mergeIndex(f3, xmlModel); } FileOutputStream fos3 = new FileOutputStream(f3); success = success && xmlModel.streamIndex(fos3); fos3.flush(); fos3.close(); File f4 = new File(getMetaInfDir().getPath() + File.separator + "persistence-template-hibernate.xml"); // File f4 = new File( getXjcDir().getPath() + File.separator + "META-INF" + // File.separator + "persistence.xml" ); // if ( f4.exists() ) { // xcompiler.mergePersistenceXml( f4, xmlModel ); // } FileOutputStream fos4 = new FileOutputStream(f4); success = success && xmlModel.streamPersistenceXml(fos4); fos4.flush(); fos4.close(); return success; }
public boolean streamXSDsWithBindings(boolean includePersistenceConfiguration) { SemanticXSDModelCompiler xcompiler = (SemanticXSDModelCompiler) ModelCompilerFactory.newModelCompiler(ModelFactory.CompileTarget.XSDX); SemanticXSDModel xmlModel = (SemanticXSDModel) xcompiler.compile(model); xmlModel.streamAll(System.err); boolean success = false; try { success = xmlModel.stream(getMetaInfDir()); success = xmlModel.streamBindings(getMetaInfDir()); if (includePersistenceConfiguration) { success = success && streamPersistenceConfigs(xcompiler, xmlModel); } } catch (Exception e) { e.printStackTrace(); } return success; }