@Test public void jCasGenTest() throws Exception { String srcDirectory = "src/test/java"; String binDirectory = "target/resources/bin"; File binFile = new File(binDirectory); if(!binFile.exists()) { assertTrue(binFile.mkdirs()); } removeTestTypeFiles(srcDirectory, binDirectory); LeoTypeSystemDescription ftsd = null; ftsd = new LeoTypeSystemDescription("desc.gov.va.vinci.leo.types.TestTypeSystem", true); assertNotNull(ftsd); ftsd.jCasGen(srcDirectory, binDirectory); assertNotNull(ftsd); List<String> fileNames = new ArrayList<String>(); for (TypeDescription td :ftsd.getTypes()) { String name = td.getName().substring(td.getName().lastIndexOf('.') + 1, td.getName().length()); fileNames.add(name + ".java"); fileNames.add(name + "_Type.java"); } List<File> javaSrcFiles = LeoUtils.listFiles(new File(srcDirectory), new NameFileFilter(fileNames), true); assertNotNull(javaSrcFiles); File classFile = new File(binDirectory + "/gov/va/vinci/leo/types/TestType.class"); assertTrue(classFile.exists()); removeTestTypeFiles(srcDirectory, binDirectory); }
public void jCasGen(String srcDirectory, String binDirectory) throws Exception { if (this.myTypeSystemDescription == null) { throw new Exception("Cannot generate a null TypeSystem"); } if (StringUtils.isBlank(srcDirectory) || StringUtils.isBlank(binDirectory)) { throw new Exception("Both the source directory and bin directory are required arguments"); } this.toXML(this.mDescriptorLocator); String classpath = System.getProperty("java.class.path"); String[] args = {"-jcasgeninput", this.mDescriptorLocator.trim(), "-jcasgenoutput", srcDirectory, "=jcasgenclasspath", classpath}; Jg jcasGen = new Jg(); int ret = jcasGen.main1(args); if (ret == -1) { throw new Exception("Error occurred generating the Java source files"); } List<String> fileNames = new ArrayList<String>(); for (TypeDescription td : getTypes()) { String name = td.getName().substring(td.getName().lastIndexOf('.') + 1, td.getName().length()); fileNames.add(name + ".java"); fileNames.add(name + "_Type.java"); } NameFileFilter fnf = new NameFileFilter(fileNames); List<File> javaSrcFiles = LeoUtils.listFiles(new File(srcDirectory), fnf, true); if (javaSrcFiles == null) { log.warn("No Java Source files found to compile in jCasGen"); return; } try { AutoCompile.compileFiles(javaSrcFiles.toArray(new File[0]), binDirectory); } catch (Exception e) { log.warn("Exception Thrown compiling files in test", e); } }
LeoTypeSystemDescription { public void jCasGen(String srcDirectory, String binDirectory) throws Exception { if (this.myTypeSystemDescription == null) { throw new Exception("Cannot generate a null TypeSystem"); } if (StringUtils.isBlank(srcDirectory) || StringUtils.isBlank(binDirectory)) { throw new Exception("Both the source directory and bin directory are required arguments"); } this.toXML(this.mDescriptorLocator); String classpath = System.getProperty("java.class.path"); String[] args = {"-jcasgeninput", this.mDescriptorLocator.trim(), "-jcasgenoutput", srcDirectory, "=jcasgenclasspath", classpath}; Jg jcasGen = new Jg(); int ret = jcasGen.main1(args); if (ret == -1) { throw new Exception("Error occurred generating the Java source files"); } List<String> fileNames = new ArrayList<String>(); for (TypeDescription td : getTypes()) { String name = td.getName().substring(td.getName().lastIndexOf('.') + 1, td.getName().length()); fileNames.add(name + ".java"); fileNames.add(name + "_Type.java"); } NameFileFilter fnf = new NameFileFilter(fileNames); List<File> javaSrcFiles = LeoUtils.listFiles(new File(srcDirectory), fnf, true); if (javaSrcFiles == null) { log.warn("No Java Source files found to compile in jCasGen"); return; } try { AutoCompile.compileFiles(javaSrcFiles.toArray(new File[0]), binDirectory); } catch (Exception e) { log.warn("Exception Thrown compiling files in test", e); } } }
LeoTypeSystemDescription { public void jCasGen(String srcDirectory, String binDirectory) throws Exception { if (this.myTypeSystemDescription == null) { throw new Exception("Cannot generate a null TypeSystem"); } if (StringUtils.isBlank(srcDirectory) || StringUtils.isBlank(binDirectory)) { throw new Exception("Both the source directory and bin directory are required arguments"); } this.toXML(this.mDescriptorLocator); String classpath = System.getProperty("java.class.path"); String[] args = {"-jcasgeninput", this.mDescriptorLocator.trim(), "-jcasgenoutput", srcDirectory, "=jcasgenclasspath", classpath}; Jg jcasGen = new Jg(); int ret = jcasGen.main1(args); if (ret == -1) { throw new Exception("Error occurred generating the Java source files"); } List<String> fileNames = new ArrayList<String>(); for (TypeDescription td : getTypes()) { String name = td.getName().substring(td.getName().lastIndexOf('.') + 1, td.getName().length()); fileNames.add(name + ".java"); fileNames.add(name + "_Type.java"); } NameFileFilter fnf = new NameFileFilter(fileNames); List<File> javaSrcFiles = LeoUtils.listFiles(new File(srcDirectory), fnf, true); if (javaSrcFiles == null) { log.warn("No Java Source files found to compile in jCasGen"); return; } try { AutoCompile.compileFiles(javaSrcFiles.toArray(new File[0]), binDirectory); } catch (Exception e) { log.warn("Exception Thrown compiling files in test", e); } } LeoTypeSystemDescription(TypeDescription... types);  LeoTypeSystemDescription(TypeSystemDescription td);  LeoTypeSystemDescription(String descriptor, boolean byName);  LeoTypeSystemDescription(String aType, String aDescription, String aSupertypeName); }
LeoTypeSystemDescription { public void jCasGen(String srcDirectory, String binDirectory) throws Exception { if (this.myTypeSystemDescription == null) { throw new Exception("Cannot generate a null TypeSystem"); } if (StringUtils.isBlank(srcDirectory) || StringUtils.isBlank(binDirectory)) { throw new Exception("Both the source directory and bin directory are required arguments"); } this.toXML(this.mDescriptorLocator); String classpath = System.getProperty("java.class.path"); String[] args = {"-jcasgeninput", this.mDescriptorLocator.trim(), "-jcasgenoutput", srcDirectory, "=jcasgenclasspath", classpath}; Jg jcasGen = new Jg(); int ret = jcasGen.main1(args); if (ret == -1) { throw new Exception("Error occurred generating the Java source files"); } List<String> fileNames = new ArrayList<String>(); for (TypeDescription td : getTypes()) { String name = td.getName().substring(td.getName().lastIndexOf('.') + 1, td.getName().length()); fileNames.add(name + ".java"); fileNames.add(name + "_Type.java"); } NameFileFilter fnf = new NameFileFilter(fileNames); List<File> javaSrcFiles = LeoUtils.listFiles(new File(srcDirectory), fnf, true); if (javaSrcFiles == null) { log.warn("No Java Source files found to compile in jCasGen"); return; } try { AutoCompile.compileFiles(javaSrcFiles.toArray(new File[0]), binDirectory); } catch (Exception e) { log.warn("Exception Thrown compiling files in test", e); } } LeoTypeSystemDescription(TypeDescription... types);  LeoTypeSystemDescription(TypeSystemDescription td);  LeoTypeSystemDescription(String descriptor, boolean byName);  LeoTypeSystemDescription(String aType, String aDescription, String aSupertypeName); TypeSystemDescription getTypeSystemDescription(); LeoTypeSystemDescription addTypeSystemDescription(TypeSystemDescription aTypeSystemDescription); LeoTypeSystemDescription addTypeSystemDescription(LeoTypeSystemDescription aLeoTypeSystemDescription); LeoTypeSystemDescription addType(String aName, String aDescription, String aSuperType); LeoTypeSystemDescription addType(TypeDescription aTypeDescription); TypeDescription getType(String aTypeName); TypeDescription[] getTypes(); String getDescriptorLocator(); void toXML(String filename); void jCasGen(String srcDirectory, String binDirectory); }
LeoTypeSystemDescription { public void jCasGen(String srcDirectory, String binDirectory) throws Exception { if (this.myTypeSystemDescription == null) { throw new Exception("Cannot generate a null TypeSystem"); } if (StringUtils.isBlank(srcDirectory) || StringUtils.isBlank(binDirectory)) { throw new Exception("Both the source directory and bin directory are required arguments"); } this.toXML(this.mDescriptorLocator); String classpath = System.getProperty("java.class.path"); String[] args = {"-jcasgeninput", this.mDescriptorLocator.trim(), "-jcasgenoutput", srcDirectory, "=jcasgenclasspath", classpath}; Jg jcasGen = new Jg(); int ret = jcasGen.main1(args); if (ret == -1) { throw new Exception("Error occurred generating the Java source files"); } List<String> fileNames = new ArrayList<String>(); for (TypeDescription td : getTypes()) { String name = td.getName().substring(td.getName().lastIndexOf('.') + 1, td.getName().length()); fileNames.add(name + ".java"); fileNames.add(name + "_Type.java"); } NameFileFilter fnf = new NameFileFilter(fileNames); List<File> javaSrcFiles = LeoUtils.listFiles(new File(srcDirectory), fnf, true); if (javaSrcFiles == null) { log.warn("No Java Source files found to compile in jCasGen"); return; } try { AutoCompile.compileFiles(javaSrcFiles.toArray(new File[0]), binDirectory); } catch (Exception e) { log.warn("Exception Thrown compiling files in test", e); } } LeoTypeSystemDescription(TypeDescription... types);  LeoTypeSystemDescription(TypeSystemDescription td);  LeoTypeSystemDescription(String descriptor, boolean byName);  LeoTypeSystemDescription(String aType, String aDescription, String aSupertypeName); TypeSystemDescription getTypeSystemDescription(); LeoTypeSystemDescription addTypeSystemDescription(TypeSystemDescription aTypeSystemDescription); LeoTypeSystemDescription addTypeSystemDescription(LeoTypeSystemDescription aLeoTypeSystemDescription); LeoTypeSystemDescription addType(String aName, String aDescription, String aSuperType); LeoTypeSystemDescription addType(TypeDescription aTypeDescription); TypeDescription getType(String aTypeName); TypeDescription[] getTypes(); String getDescriptorLocator(); void toXML(String filename); void jCasGen(String srcDirectory, String binDirectory); static final Logger log; }