List of usage examples for org.apache.commons.io.filefilter TrueFileFilter INSTANCE
IOFileFilter INSTANCE
To view the source code for org.apache.commons.io.filefilter TrueFileFilter INSTANCE.
Click Source Link
From source file:org.wisdom.resources.FileWebJarLib.java
private void index() { File base = root;//w ww.jav a 2 s . c o m if (source != null) { // If source is defined as component-version.jar (eg: polymer-0.5.4.jar) // we are looking for an inner folder of the same name ( "polymer" in the example) String module = source.substring(0, source.lastIndexOf('-')); File file = new File(root, module); if (file.isDirectory()) { // If root/component is a directory, // then we will only index this directory. LOGGER.debug("Indexing files for WebJar library {}-{} / {}", name, version, source); base = file; } else { LOGGER.debug("Indexing files for WebJar library {}-{}", name, version); } } else { LOGGER.debug("Indexing files for WebJar library {}-{}", name, version); } for (File file : FileUtils.listFiles(base, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!file.isDirectory()) { // We compute the relative path of the file from the webjar root directory. String path = file.getAbsolutePath().substring(root.getAbsolutePath().length() + 1); // On windows we need to replace \ by / path = path.replace("\\", "/"); index.put(path, file); } } }
From source file:org.wisdom.resources.WebJarController.java
private void populateIndexForLibrary(WebJarLib lib) { LOGGER.debug("Indexing files for WebJar library {}-{}", lib.name, lib.version); for (File file : FileUtils.listFiles(lib.root, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!file.isDirectory()) { index.put(file.getAbsolutePath().substring(lib.root.getAbsolutePath().length() + 1), file); }//from w w w . j av a 2s .co m } }
From source file:org.wisdom.test.internals.RunnerUtils.java
/** * Checks if a file having somewhat the current tested application name is contained in the given directory. This * method follows the default maven semantic. The final file is expected to have a name compliant with the * following rules: <code>artifactId-version.jar</code>. If the version ends with <code>-SNAPSHOT</code>, * it just checks for <code>artifactId-stripped_version</code>, where stripped version is the version without the * <code>SNAPSHOT</code> part. * <p>//from ww w.j av a2 s. c o m * The artifactId and version are read from the <code>target/osgi/osgi.properties</code> file, * that should have been written by the Wisdom build process. * * @param directory the directory * @return the bundle file if found * @throws java.io.IOException if something bad happens. */ public static File detectApplicationBundleIfExist(File directory) throws IOException { Properties properties = getMavenProperties(); if (properties == null || directory == null || !directory.isDirectory()) { return null; } final String artifactId = properties.getProperty("project.artifactId"); final String groupId = properties.getProperty("project.groupId"); final String bsn = getBundleSymbolicName(groupId, artifactId); String version = properties.getProperty("project.version"); final String strippedVersion; if (version.endsWith("-SNAPSHOT")) { strippedVersion = version.substring(0, version.length() - "-SNAPSHOT".length()); } else { strippedVersion = version; } Iterator<File> files = FileUtils.iterateFiles(directory, new AbstractFileFilter() { @Override public boolean accept(File file) { return file.isFile() && file.getName().startsWith(bsn + "-" + strippedVersion) && file.getName().endsWith(".jar"); } }, TrueFileFilter.INSTANCE); if (files.hasNext()) { return files.next(); } return null; }
From source file:org.wso2.maven.AbstractMavenReleaseMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { File parentProjectBaseDir = mavenProject.getBasedir(); File releasePropertiesFile = new File(parentProjectBaseDir, RELEASE_PROPERTIES); releaseProperties = new Properties(); // execute only for the project in repository root. if (releasePropertiesFile.exists()) { try {/*from w ww. ja v a2s .com*/ InputStream inputStream = new FileInputStream(releasePropertiesFile); releaseProperties.load(inputStream); } catch (IOException e) { String errorMessage = "Error while reading " + RELEASE_PROPERTIES; throw new MojoExecutionException(errorMessage, e); } // iterate recursively and filter out files named artifact.xml Collection<File> artifactXMLFiles = FileUtils.listFiles(parentProjectBaseDir, new ArtifactXMLFilter(), TrueFileFilter.INSTANCE); for (File artifactXML : artifactXMLFiles) { File projectPath = new File(artifactXML.getPath().replaceAll(ARTIFACT_XML + "$", EMPTY_STRING)); File pomFile = new File(projectPath, POM_XML); // if not a maven project, continue. if (!pomFile.exists()) { log.warn("Skipping project since " + artifactXML.getPath() + " does not belong to a maven project."); continue; } try { // getNewVersion() depends on current goal. // Eg: for prepare-release, it should be the releasing version // for prepare-snapshot, it should be the next development version // for rollback, it should be the previous development version String newVersion = getNewVersion(artifactXML); if (StringUtils.isNotEmpty(newVersion)) { updateArtifactVersions(artifactXML, newVersion); } else { String errorMessage = "Cannot update artifact.xml as new version is empty/null. " + "Project: " + pomFile.getPath() + " Goal: " + getGoal(); throw new MojoFailureException(errorMessage); } } catch (IOException | XmlPullParserException e) { String errorMessage = "Error occurred while getting the new version for artifacts." + " Project: " + pomFile.getPath() + " Goal: " + getGoal(); throw new MojoFailureException(errorMessage, e); } catch (Exception e) { String errorMessage = "Error occurred while updating artifact versions. Project: " + pomFile.getPath() + " Goal: " + getGoal(); throw new MojoFailureException(errorMessage, e); } } // commit changes only if not running in dryRun mode if (isInDryRunMode()) { log.info("Skipped committing changes in dryRun mode."); } else { try { executeMojo( plugin(groupId(MAVEN_PLUGINS_GROUP), artifactId(MAVEN_SCM_PLUGIN), version(SCM_PLUGIN_VERSION)), goal(GOAL_CHECK_IN), configuration(getScmPluginProperties(parentProjectBaseDir)), executionEnvironment(mavenProject, mavenSession, pluginManager)); } catch (MojoExecutionException e) { throw new MojoExecutionException("Error occurred while invoking maven scm plug-in.", e); } } } else { log.debug("Skipping project since the " + RELEASE_PROPERTIES + " file was not found in project root."); } }
From source file:org.wso2.security.tools.reposcanner.scanner.GitHubRepoScanner.java
public void scan(Storage storage) throws Exception { String consoleTag = "[GIT] "; log.info(consoleTag + "GIT repository scanning started."); ArtifactInfoGenerator mavenArtifactInfoGenerator = new MavenArtifactInfoGenerator(); RepoDownloader gitRepoDownloader = new GitHubTagDownloader(); //Create temp folder for storing downloaded repository content File gitTempFolder = new File("temp-git"); if (gitTempFolder.exists()) { FileUtils.deleteDirectory(gitTempFolder); }/*from w ww . j a v a 2 s.c o m*/ if (gitTempFolder.mkdir()) { log.info(consoleTag + "Temporary folder created at: " + gitTempFolder.getAbsolutePath()); } else { log.error(consoleTag + "Unable to create temporary folder at: " + gitTempFolder.getAbsolutePath()); return; } //Get list of repositories from GitHub RepoInfoGenerator repoInfoGenerator = new GitHubRepoInfoGenerator(oAuth2Token); List<Repo> repoList = null; if (AppConfig.getGithubAccounts() == null || AppConfig.getGithubAccounts().isEmpty()) { log.error(consoleTag + "No GitHub user accounts provided for the scan. Terminating..."); return; } else { repoList = repoInfoGenerator.getRepoList(consoleTag, AppConfig.getGithubAccounts()); } if (!AppConfig.isSkipScan()) { repoList.parallelStream().forEach(repo -> { String newConsoleTag = consoleTag + "[User:" + repo.getUser() + ",Repo:" + repo.getRepositoryUrl() + ",Tag:" + repo.getTagName() + "] "; try { if (AppConfig.isRescanRepos() || !storage.isRepoPresent(repo)) { log.info(newConsoleTag + "[Adding] Adding repo to scanning pool"); //Create folder to store files from Github String identifier = repo.getRepositoryName() + "-Tag-" + repo.getTagName(); File artifactTempFolder = new File( gitTempFolder.getAbsoluteFile() + File.separator + identifier); artifactTempFolder.mkdir(); log.info(consoleTag + "Temporary folder created at: " + artifactTempFolder.getAbsolutePath()); try { //Download from GitHub and extract ZIP log.info(consoleTag + "Downloading started"); gitRepoDownloader.downloadRepo(repo, artifactTempFolder); log.info(consoleTag + "Downloading completed"); //Locate POM files within the extracted ZIP log.info(consoleTag + "POM searching started"); Collection<File> sourceFiles = FileUtils.listFiles(artifactTempFolder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); List<File> mavenBuildConfigFiles = sourceFiles.stream() .filter(file -> file.getName().equals("pom.xml")).collect(Collectors.toList()); log.info(consoleTag + "POM searching completed"); //Execute maven executor plugin on each POM to get Maven ID (groupId, artifactId, packaging, version) ExecutorService artifactWorkerExecutorService = Executors.newSingleThreadExecutor(); List<Callable<RepoArtifact>> callableArrayList = new ArrayList<>(); mavenBuildConfigFiles.stream().forEach(mavenBuildConfigFile -> { try { String path = mavenBuildConfigFile.getAbsolutePath().substring( artifactTempFolder.getAbsolutePath().length(), mavenBuildConfigFile.getAbsolutePath().length()); path = path.substring(path.indexOf(File.separator, 1), path.length()); String finalPath = path.replace("pom.xml", ""); String pathIncludedConsoleTag = consoleTag + "[" + path + "] "; //If this is a repo re-scan, only the artifacts that are not already indexed should be scanned. //If thus is not a repo re-scan, repo itself will be skipped if it is already indexed (in previous condition check) boolean scanArtifact = true; if (AppConfig.isRescanRepos() && (storage.isArtifactPresent(repo, path) || storage.isErrorPresent(repo, path))) { scanArtifact = false; } if (scanArtifact) { log.info(pathIncludedConsoleTag + "[Adding] Adding POM for artifact information gathering pool"); //Callable<RepoArtifact> callable = () -> { try { RepoArtifact repoArtifactInfo = mavenArtifactInfoGenerator.getArtifact( consoleTag, artifactTempFolder, mavenBuildConfigFile); repoArtifactInfo.setRepo(repo); log.info(consoleTag + "Maven ID extracted. Sending for storage."); //return repoArtifactInfo; storage.persist(repoArtifactInfo); } catch (Exception e) { RepoError repoError = new RepoError(finalPath, "MavenID not found", repo, new Date()); storage.persistError(repoError); if (AppConfig.isVerbose()) { log.warn(consoleTag + "[Skipping] Could not extract Maven ID from Maven executor", e); } else { log.warn(consoleTag + "[Skipping] Could not extract Maven ID from Maven executor"); } //return null; } //}; //callableArrayList.add(callable); } else { log.warn(pathIncludedConsoleTag + "[Skipping] Artifact is already present in storage."); } } catch (Exception e) { log.error(consoleTag + "[!!! CRITICAL ERROR !!!] Exception in extracting artifact information for repository: " + repo + " config file: " + mavenBuildConfigFile.getAbsolutePath(), e); } }); /** artifactWorkerExecutorService.invokeAll(callableArrayList).stream().forEach(artifactFuture -> { RepoArtifact repoArtifact = null; try { repoArtifact = artifactFuture.get(); if (repoArtifact != null) { storage.persist(repoArtifact); } } catch (Exception e) { log.error(consoleTag + "[!!! CRITICAL ERROR !!!] Exception in persisting Artifact: " + repoArtifact, e); } }); **/ } catch (Exception e) { try { FileUtils.deleteDirectory(artifactTempFolder); } catch (IOException e1) { log.warn("Exception in removing temp folder: " + artifactTempFolder.getAbsolutePath()); } log.error(consoleTag + "[!!! CRITICAL ERROR !!!] Git repository scanning failed: " + identifier, e); } finally { //Do cleanup and storage release log.info(consoleTag + "All threads complete. Clean up tasks started."); log.info(consoleTag + "Deleting: " + artifactTempFolder.getAbsolutePath()); FileUtils.deleteDirectory(artifactTempFolder); } } else { log.warn(newConsoleTag + "[Skipping] Repo is already present in storage."); } } catch (Exception e) { log.error(consoleTag + "[!!! CRITICAL ERROR !!!] Exception in scanning repository: " + repo, e); } }); } else { log.warn(consoleTag + "[Skipping] SkipScan parameter is set."); } //Do cleanup and storage release log.info(consoleTag + "All threads complete. Clean up tasks started."); FileUtils.deleteDirectory(gitTempFolder); }
From source file:pl.net.ptak.PrqPrePackageMojo.java
private void prepareBuildOutputForPackaging() throws MojoFailureException { File folderToCopy = null;/* w w w . j av a 2s . co m*/ boolean folderCopied = false; try { String folderName = "DiskImages"; Iterator<File> iterator = FileUtils.iterateFilesAndDirs(installshieldOutputDirectory, new NotFileFilter(TrueFileFilter.INSTANCE), DirectoryFileFilter.INSTANCE); while (iterator.hasNext()) { folderToCopy = iterator.next(); if (folderToCopy.getName().equalsIgnoreCase(folderName)) { getLog().info(String.format("Preparing %s for packaging", folderToCopy.getCanonicalPath())); File diskImagesTarget = new File(prePackageInstallerSubFolder, folderName); diskImagesTarget.mkdirs(); org.codehaus.plexus.util.FileUtils.copyDirectoryStructure(folderToCopy, diskImagesTarget); folderCopied = true; packagedDiskImagesFolder = folderToCopy; break; } } if (!folderCopied && failWhenNoInstallshieldFile) { String message = String.format("%s folder not found within the InstallShieldOutput", folderName); getLog().error(message); throw new MojoFailureException(message); } while (iterator.hasNext()) { folderToCopy = iterator.next(); if (folderToCopy.getName().equalsIgnoreCase(folderName)) { String message = String.format("More than one %s folder found within the InstallShieldOutput, " + "the first one will be used and the rest ignored", folderName); getLog().warn(message); break; } } } catch (IOException e) { String message = String.format("Failed to copy %s to %s", folderToCopy, prePackageInstallerSubFolder); String shortMessage = "Failed to copy resources"; getLog().debug(message, e); throw new MojoFailureException(e, shortMessage, message); } }
From source file:rita.compiler.CompileString.java
/** * El mtodo compile crea el archivo compilado a partir de un codigo fuente * y lo deja en un directorio determinado * /*ww w .j a v a 2s .c om*/ * @param sourceCode * el codigo fuente * @param className * el nombre que debera llevar la clase * @param packageName * nombre del paquete * @param outputDirectory * directorio donde dejar el archivo compilado * */ public static final Collection<File> compile(File sourceCode, File outputDirectory) throws Exception { diagnostics = new ArrayList<Diagnostic<? extends JavaFileObject>>(); JavaCompiler compiler = new EclipseCompiler(); System.out.println(sourceCode); DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() { @Override public void report(Diagnostic<? extends JavaFileObject> diagnostic) { if (diagnostic.getKind().equals(javax.tools.Diagnostic.Kind.ERROR)) { System.err.println("=======================ERROR=========================="); System.err.println("Tipo: " + diagnostic.getKind()); System.err.println("mensaje: " + diagnostic.getMessage(Locale.ENGLISH)); System.err.println("linea: " + diagnostic.getLineNumber()); System.err.println("columna: " + diagnostic.getColumnNumber()); System.err.println("CODE: " + diagnostic.getCode()); System.err.println( "posicion: de " + diagnostic.getStartPosition() + " a " + diagnostic.getEndPosition()); System.err.println(diagnostic.getSource()); diagnostics.add(diagnostic); } } }; StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); /* guardar los .class y directorios (packages) en un directorio separado; de esta manera * si se genera mas de 1 clase (porque p.ej. hay inner classes en el codigo) podemos identificar * a todas las clases resultantes de esta compilacion */ File tempOutput = createTempDirectory(); fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tempOutput)); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjects(sourceCode); try { if (compiler.getTask(null, fileManager, listener, null, null, compilationUnits).call()) { // copiar .class y directorios (packages) generados por el compilador en tempOutput al directorio final FileUtils.copyDirectory(tempOutput, outputDirectory); // a partir de los paths de los archivos .class generados en el dir temp, modificarlos para que sean relativos a outputDirectory Collection<File> compilationResults = new ArrayList<File>(); final int tempPrefix = tempOutput.getAbsolutePath().length(); for (File classFile : FileUtils.listFiles(tempOutput, new SuffixFileFilter(".class"), TrueFileFilter.INSTANCE)) { compilationResults .add(new File(outputDirectory, classFile.getAbsolutePath().substring(tempPrefix))); } // retornar los paths de todos los .class generados return compilationResults; } } catch (Exception e) { e.printStackTrace(); System.out.println("Error al realizar el compilado"); } finally { FileUtils.deleteDirectory(tempOutput); fileManager.close(); } return null; }
From source file:ro.nextreports.server.web.language.LanguageManager.java
@SuppressWarnings("unchecked") private LanguageManager() { languages.add(new Language(LANGUAGE_ENGLISH, COUNTRY_ENGLISH, PROPERTY_NAME_ENGLISH)); languages.add(new Language(LANGUAGE_FRENCH, COUNTRY_FRENCH, PROPERTY_NAME_FRENCH)); languages.add(new Language(LANGUAGE_ROMANIAN, COUNTRY_ROMANIAN, PROPERTY_NAME_ROMANIAN)); languages.add(new Language(LANGUAGE_POLISH, COUNTRY_POLISH, PROPERTY_NAME_POLISH)); languages.add(new Language(LANGUAGE_RUSSIAN, COUNTRY_RUSSIAN, PROPERTY_NAME_RUSSIAN)); LANGUAGES.add(PROPERTY_NAME_ENGLISH); LANGUAGES.add(PROPERTY_NAME_FRENCH); LANGUAGES.add(PROPERTY_NAME_ROMANIAN); LANGUAGES.add(PROPERTY_NAME_POLISH); LANGUAGES.add(PROPERTY_NAME_RUSSIAN); // try to see if other internatinalization filee where added by hand // must have name like NextServerApplication_<lang>_<country>.properties // you must add in all other i18n files the property: // Settings.personalize.language.<lang>_<country> to see it in seetings Collection<File> files = FileUtils.listFiles(new File("."), I18NFileFilter.INSTANCE, TrueFileFilter.INSTANCE); Set<String> fileNames = new HashSet<String>(); for (File file : files) { String name = file.getName(); String baseName = name.substring(0, name.indexOf(".properties")); String[] s = baseName.split("_"); if (s.length == 3) { fileNames.add(name);/*w ww . j a v a2s. co m*/ languages.add(new Language(s[1], s[2], s[1] + "_" + s[2])); LANGUAGES.add(s[1] + "_" + s[2]); } } }
From source file:ro.nextreports.server.web.themes.ThemesManager.java
@SuppressWarnings("unchecked") private ThemesManager() { THEMES.add(RED_THEME);/* w ww.java 2 s . com*/ THEMES.add(GREEN_THEME); THEMES.add(BLUE_THEME); // try to see if other theme files where added by hand // must have name like theme-<color>.properties // you must add in all other i18n files the property: // Settings.personalize.theme.theme-<color> to see it in seetings Collection<File> files = FileUtils.listFiles(new File("."), ThemeFileFilter.INSTANCE, TrueFileFilter.INSTANCE); Set<String> fileNames = new HashSet<String>(); for (File file : files) { String name = file.getName(); String baseName = name.substring(0, name.indexOf(".properties")); if (!RED_THEME_FILE_NAME.equals(baseName) && !BLUE_THEME_FILE_NAME.equals(baseName) && !GREEN_THEME_FILE_NAME.equals(baseName)) { THEMES.add(baseName); } LOG.info("Found " + THEMES.size() + " theme files."); } }
From source file:sbmltodb.Sbmltodb.java
/** * @param args the command line arguments *//* ww w . j a v a 2 s. com*/ public static void main(String[] args) throws UnsupportedEncodingException { // TODO code application logic here String modelid; String str; String expcond; String server, user, password, dbname, filepath; String cwd = System.getProperty("user.dir"); System.out.println(cwd); if (args.length == 0) { server = "localhost"; user = "root"; password = "root"; dbname = "sbmldb2"; /** * Path to get the SBML file list where cwd is "github\sbml2db\sbmltodb_standalone_Project\sbmltodb" so add a folder in this directory * and mention folder name instead of sbmlfiles */ filepath = cwd + "\\sbmlfiles"; } else { server = args[0]; user = args[1]; password = args[2]; dbname = args[3]; filepath = args[4]; } File folder = new File(filepath); List<File> files = (List<File>) FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); for (File file : files) { if (file.isFile() && (file.getName().endsWith(".xml") || file.getName().endsWith("_url.xml"))) { SBMLDocument doc = new FileCtrl().read(file); System.out.println(file.getName()); System.out.println(doc); Mysqlconn sql = new Mysqlconn(server, user, password, dbname); if (doc.getModel().getId().equals("")) { modelid = doc.getModel().getName(); } else { modelid = doc.getModel().getId(); } /* Inserting SBML table */ // sql.insertsbml(doc.getModel().getLevel(), doc.getModel().getVersion()); /* Inserting model table */ str = doc.getModel().getAnnotationString().replaceAll("<annotation>", ""); str = str.replaceAll("</annotation>", ""); if (!doc.getModel().getAnnotation().equals(null)) sql.insertmodel(modelid, doc.getModel().getName(), doc.getModel().getLevel(), doc.getModel().getVersion(), doc.getModel().getNotesString(), str.trim()); else sql.insertmodel(modelid, doc.getModel().getName(), doc.getModel().getLevel(), doc.getModel().getVersion(), doc.getModel().getNotesString(), ""); /* Inserting Experimental condition */ sql.insertexpcond("expcond_" + modelid, "Experimental Condition of " + modelid, "Experimental Condition of " + modelid, "", ""); /* Inserting Compartments */ for (Compartment sp : doc.getModel().getListOfCompartments()) { sql.insertcompartment(sp.getId(), sp.getName(), sp.getConstant(), modelid, sp.getSpatialDimensions(), sp.getSize(), sp.getUnits()); } /* Inserting Species */ for (Species sp : doc.getModel().getListOfSpecies()) { //annot = sp.getAnnotation(); str = sp.getAnnotationString().replaceAll("<annotation>", ""); str = str.replaceAll("</annotation>", ""); if (!sp.getAnnotation().equals(null)) sql.insertspecies(sp.getId(), sp.getName(), sp.getCompartment(), sp.getInitialAmount(), sp.getInitialConcentration(), sp.getSubstanceUnits(), sp.getHasOnlySubstanceUnits(), sp.getBoundaryCondition(), sp.getConstant(), sp.getConversionFactor(), modelid, str.trim()); else sql.insertspecies(sp.getId(), sp.getName(), sp.getCompartment(), sp.getInitialAmount(), sp.getInitialConcentration(), sp.getSubstanceUnits(), sp.getHasOnlySubstanceUnits(), sp.getBoundaryCondition(), sp.getConstant(), sp.getConversionFactor(), modelid, ""); sql.insertbioelement(sp.getId(), sp.getName(), sp.getName(), "", "", "species"); sql.insertbioelhasmodel(sp.getId(), modelid); sql.insertbioelhasexpcond(sp.getId(), "expcond_" + modelid, "", sp.getInitialConcentration(), -1); } /* Inserting Function Definitions */ for (FunctionDefinition sp : doc.getModel().getListOfFunctionDefinitions()) { sql.insertfunctionDefinition(sp.getId(), sp.getMath().toString(), modelid); } /* Inserting Unit Definitions */ for (UnitDefinition ud : doc.getModel().getListOfUnitDefinitions()) { sql.insertlistofunitdefinition(ud.getId(), ud.getName(), modelid); for (Unit u : ud.getListOfUnits()) { sql.insertunitdefinition(ud.getId(), u.getScale(), u.getExponent(), u.getMultiplier(), u.getKind().toString()); } } /* Inserting Reations and Species Reference */ for (Reaction react : doc.getModel().getListOfReactions()) { str = react.getAnnotationString().replaceAll("<annotation>", ""); str = str.replaceAll("</annotation>", ""); if (!react.getAnnotation().equals(null)) sql.insertlistofReactions(react.getId(), react.getName(), react.getReversible(), react.getFast(), modelid, react.getCompartment(), str.trim()); else sql.insertlistofReactions(react.getId(), react.getName(), react.getReversible(), react.getFast(), modelid, react.getCompartment(), ""); for (SpeciesReference sr : react.getListOfReactants()) { sql.insertSimplespeciesreference(react.getId(), sr.getSpecies(), sr.getSBOTermID(), sr.getStoichiometry(), "reactants", sr.getConstant()); } for (SpeciesReference sr : react.getListOfProducts()) { sql.insertSimplespeciesreference(react.getId(), sr.getSpecies(), sr.getSBOTermID(), sr.getStoichiometry(), "products", sr.getConstant()); } for (ModifierSpeciesReference sr : react.getListOfModifiers()) { sql.insertModifierspeciesreference(react.getId(), sr.getSpecies(), sr.getSBOTermID(), "modifiers"); } // if(react.getKineticLaw().getAnnotationString() != "") if (!(react.getKineticLaw() == null)) { str = react.getKineticLaw().getAnnotationString().replaceAll("<annotation>", ""); str = str.replaceAll("</annotation>", ""); if (!react.getKineticLaw().getAnnotation().equals(null)) sql.insertKineticLaw(react.getId(), react.getKineticLaw().getMetaId(), react.getKineticLaw().getMath().toString(), str.trim()); else sql.insertKineticLaw(react.getId(), react.getKineticLaw().getMetaId(), react.getKineticLaw().getMath().toString(), ""); } } /* Inserting Constraints */ for (Constraint sp : doc.getModel().getListOfConstraints()) { sql.insertConstraint(sp.getMath().toString(), sp.getMessageString(), modelid); } /* Inserting Constraint Definitions */ for (Constraint sp : doc.getModel().getListOfConstraints()) { sql.insertConstraint(sp.getMath().toString(), sp.getMessageString(), modelid); } /* Inserting Events */ for (Event e : doc.getModel().getListOfEvents()) { sql.insertevents(e.getId(), e.getName(), e.getUseValuesFromTriggerTime(), modelid); if (!(e.getTrigger() == null)) sql.inserteventtrigger(e.getId(), e.getTrigger().getInitialValue(), e.getTrigger().getPersistent(), e.getTrigger().getMath().toString()); if (!(e.getDelay() == null)) sql.inserteventdelay(e.getId(), e.getDelay().getMath().toString()); for (EventAssignment ea : e.getListOfEventAssignments()) { sql.inserteventassignment(e.getId(), ea.getVariable(), ea.getMath().toString()); } } /* Inserting Parameter List */ for (Parameter p : doc.getModel().getListOfParameters()) { sql.insertparameters(p.getId(), p.getName(), p.getValue(), p.getUnits(), p.getConstant(), modelid); } /* Inserting Rule */ for (Rule r : doc.getModel().getListOfRules()) { if (r.isAssignment()) sql.insertrules(r.getMetaId(), r.getMath().toString(), "assignmentrule", modelid); } sql.connclose(); } } }