Example usage for org.apache.commons.io FileUtils cleanDirectory

List of usage examples for org.apache.commons.io FileUtils cleanDirectory

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils cleanDirectory.

Prototype

public static void cleanDirectory(File directory) throws IOException 

Source Link

Document

Cleans a directory without deleting it.

Usage

From source file:com.redsqirl.auth.UserInfoBean.java

public void luceneIndex() throws Exception {
    logger.debug("luceneIndex ");

    String tomcatpath = WorkflowPrefManager.getSysProperty(WorkflowPrefManager.sys_tomcat_path,
            WorkflowPrefManager.defaultTomcat);
    String installPackage = WorkflowPrefManager.getSysProperty(WorkflowPrefManager.sys_install_package,
            tomcatpath);//  ww w .  ja  va  2s  .c  o m

    String indexResultPath = WorkflowPrefManager.getPathUserPref(getUserName()) + "/lucene/index";
    String indexPckUserPath = WorkflowPrefManager.getPathUserPref(getUserName()) + "/lucene/pck";
    String indexPckSysPath = WorkflowPrefManager.pathSysHome + "/lucene/pck";
    String indexMainHelpPath = WorkflowPrefManager.pathSysHome + "/lucene/mainHelp";
    String indexMergeSysPath = WorkflowPrefManager.pathSysHome + "/lucene/indexMerge";

    String userPath = installPackage + WorkflowPrefManager.getPathUserHelpPref(getUserName());
    String sysPath = installPackage + WorkflowPrefManager.getPathSysHelpPref();
    String mainlHelpPath = WorkflowPrefManager.getSysProperty(WorkflowPrefManager.sys_tomcat_path,
            WorkflowPrefManager.defaultTomcat);
    if (new File(mainlHelpPath, "redsqirl").exists()
            && new File(mainlHelpPath + "/redsqirl", "help").exists()) {
        mainlHelpPath += "/redsqirl/help";
    } else {
        mainlHelpPath += "/help";
    }

    logger.info("indexPath " + indexResultPath);
    logger.info("indexUserPath " + indexPckUserPath);
    logger.info("indexSystemPath " + indexPckSysPath);
    logger.info("indexDefaultPath " + indexMainHelpPath);

    logger.info("userPath " + userPath);
    logger.info("systemPath " + sysPath);
    logger.info("defaultPath " + mainlHelpPath);

    boolean userIndexUpdate = createIndex(indexPckUserPath, userPath);
    boolean sysPckUpdate = createIndex(indexPckSysPath, sysPath);
    boolean sysMainUpdate = createIndex(indexMainHelpPath, mainlHelpPath);
    SimpleFileIndexer sfi = new SimpleFileIndexer();

    File fileIndexMergeSysPath = new File(indexMergeSysPath);
    if (sysPckUpdate || sysMainUpdate || !fileIndexMergeSysPath.isDirectory()
            || fileIndexMergeSysPath.list().length == 0) {
        if (fileIndexMergeSysPath.isDirectory()) {
            FileUtils.cleanDirectory(fileIndexMergeSysPath);
        }
        logger.info("Merge: " + indexMergeSysPath);
        sfi.merge(indexMergeSysPath, indexPckSysPath, indexMainHelpPath);
    }

    File fileIndexResultPath = new File(indexResultPath);
    if (userIndexUpdate || sysPckUpdate || sysMainUpdate || !fileIndexResultPath.isDirectory()
            || fileIndexResultPath.list().length == 0
            || fileIndexResultPath.lastModified() < fileIndexMergeSysPath.lastModified()) {
        if (fileIndexResultPath.isDirectory()) {
            FileUtils.cleanDirectory(fileIndexResultPath);
        }
        logger.info("Merge: " + indexResultPath);
        sfi.merge(indexResultPath, indexMergeSysPath, indexPckUserPath);
        try {
            new File(WorkflowPrefManager.getPathOutputClasses(getUserName())).delete();
            new File(WorkflowPrefManager.getPathDataFlowActionClasses(getUserName())).delete();
        } catch (Exception e) {
            logger.error("Cannot delete output class", e);
        }
    }

}

From source file:de.ist.clonto.Ontogui.java

private void backupOntologyButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_backupOntologyButtonActionPerformed
    JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {/*from w  w  w.j av a 2 s  .  c o  m*/
            FileUtils.cleanDirectory(fc.getSelectedFile());
            FileUtils.copyDirectory(ontoPath.toFile(), fc.getSelectedFile());
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Loading ontology failed");
        }
        JOptionPane.showMessageDialog(this, "Created Backup files!");
    } else {
        JOptionPane.showMessageDialog(this, "Loading ontology failed");
    }

}

From source file:com.redsqirl.auth.UserInfoBean.java

public boolean createIndex(String indexFolder, String htmlFolder) throws Exception {
    String suffix = "html";
    File fileIndexFolder = new File(indexFolder);
    File fileHtmlFolder = new File(htmlFolder);
    boolean generate = !fileIndexFolder.isDirectory() || fileIndexFolder.list().length == 0
            || fileIndexFolder.lastModified() < fileHtmlFolder.lastModified();

    if (generate) {
        if (fileIndexFolder.isDirectory()) {
            FileUtils.cleanDirectory(fileIndexFolder);
        }/*from  w  w w.  ja  v  a2 s  .  c  o m*/
        fileIndexFolder.getParentFile().mkdirs();
        long start = System.currentTimeMillis();
        SimpleFileIndexer sfi = new SimpleFileIndexer();
        logger.info("Index: " + indexFolder);
        int numIndex = sfi.index(fileIndexFolder, fileHtmlFolder, suffix);
        logger.info("Total files indexed " + numIndex);
        logger.info((System.currentTimeMillis() - start));
    }
    return generate;
}

From source file:com.eastcom.hrmis.modules.emp.web.controller.api.EmployeeController.java

/**
 * ?/*from   ww  w.j ava 2  s .  c om*/
 * @param session
 * @param request
 * @param params
 * @return
 */
@OperationLog(content = "?", type = OperationType.VIEW)
@ResponseBody
@RequestMapping(value = "/headerUpload")
public AjaxJson headerUpload(HttpSession session, HttpServletRequest request,
        @RequestParam Map<String, Object> params) {
    logger.info("--?--");
    AjaxJson json = new AjaxJson();
    MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
    MultipartFile file = multiRequest.getFile("file");
    try {
        String id = StringUtils.defaultIfBlank((String) params.get("id"), "0");
        Employee employee = employeeService.get(id);
        if (employee != null) {
            employee.setHeaderImg(file.getBytes());
            employee.setHeaderImgName(employee.getId() + "-" + Math.random() + "." + StringUtils.lowerCase(
                    file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.') + 1)));
            employeeService.saveOrUpdate(employee);

            //,
            String directoryUrl = Global.getConfig("tmp.user_header.url") + employee.getId();
            File oldDirectory = new File(getRealPath(session) + directoryUrl);
            if (oldDirectory.exists()) {
                FileUtils.cleanDirectory(oldDirectory);
            }

            json.setMessage("?");
            json.setSuccess(true);
        }
    } catch (Exception e) {
        e.printStackTrace();
        json.setMessage("??!");
        json.setSuccess(false);
    }
    return json;
}

From source file:com.bibisco.manager.ProjectManager.java

public static ProjectDTO importProject(ImportProjectArchiveDTO pImportProjectArchiveDTO) {

    ProjectDTO lProjectDTO = null;//from w w  w.j av  a2s  .c o m

    mLog.debug("Start exportProject(String)");
    try {

        ContextManager lContextManager = ContextManager.getInstance();

        // get temp directory
        String lStrTempDirectory = lContextManager.getTempDirectoryPath();

        // if there is already a directory for the project, delete it   
        if (pImportProjectArchiveDTO.isAlreadyPresent()) {
            FileUtils.deleteDirectory(new File(getDBProjectDirectory(pImportProjectArchiveDTO.getIdProject())));
        }

        // copy files to db project directory
        FileUtils.copyDirectoryToDirectory(
                new File(lStrTempDirectory + pImportProjectArchiveDTO.getIdProject()),
                new File(lContextManager.getDbDirectoryPath()));

        // set project name to context
        ContextManager.getInstance().setIdProject(pImportProjectArchiveDTO.getIdProject());

        // check if project is created with previuos version of bibisco and update it
        checkProjectVersionAndUpdateIfNecessary(pImportProjectArchiveDTO.getIdProject());

        // load project
        lProjectDTO = load();

        // set language to context
        ContextManager.getInstance().setProjectLanguage(lProjectDTO.getLanguage());

        // if not exists, insert project into bibisco db
        if (!pImportProjectArchiveDTO.isAlreadyPresent()) {
            insertIntoBibiscoDB(lProjectDTO);
        }

        // delete temp directory content
        FileUtils.cleanDirectory(new File(lStrTempDirectory));

    } catch (Throwable t) {
        mLog.error(t);
        throw new BibiscoException(t, BibiscoException.IO_EXCEPTION);
    }

    mLog.debug("End exportProject(String)");

    return lProjectDTO;
}

From source file:com.codejumble.opentube.Main.java

/**
 * Deletes all the files contained in temporal files folder (Default: 'tmp')
 *
 * @param evt Swing event//  w w  w  . jav  a 2  s. c o  m
 */
private void clearItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearItemActionPerformed
    try {
        //Clear tmp folder
        FileUtils.cleanDirectory(new File(tmpFilesFolder));
    } catch (IOException ex) {
        createErrorDialog(this, ex.getMessage(), "Fatal error");
    }
}

From source file:com.bibisco.manager.ProjectManager.java

public static ImportProjectArchiveDTO importProjectArchiveFile(String pStrFileName, byte[] pBytes) {

    ImportProjectArchiveDTO lImportProjectArchiveDTO = null;

    mLog.debug("Start importProjectArchiveFile(String, byte[])");

    try {/*from w w w. j  av a2s  .  c  om*/

        ContextManager lContextManager = ContextManager.getInstance();

        // get temp directory
        String lStrTempDirectory = lContextManager.getTempDirectoryPath();

        // delete temp directory content
        FileUtils.cleanDirectory(new File(lStrTempDirectory));

        // get archive file path
        String lStrFilePath = lStrTempDirectory + pStrFileName;

        // copy archive file to temp directory
        File lFile = new File(lStrFilePath);
        lFile.createNewFile();
        FileOutputStream lFileOutputStream = new FileOutputStream(lFile);
        lFileOutputStream.write(pBytes);
        lFileOutputStream.close();

        // unzip archive file
        unZipIt(lStrFilePath);

        // check if file archive is valid and if project already exist in bibisco installation
        lImportProjectArchiveDTO = checkImportProjectArchive();

    } catch (Throwable t) {
        mLog.error(t);
        throw new BibiscoException(t, BibiscoException.IO_EXCEPTION);
    }

    mLog.debug("End importProjectArchiveFile(String, byte[])");

    return lImportProjectArchiveDTO;

}

From source file:com.migratebird.integrationtest.MigrateBirdIntegrationTest.java

private void clearScriptsDirectory() {
    try {/* w ww  . jav  a2 s  .c  om*/
        FileUtils.cleanDirectory(scriptsLocation);
    } catch (IOException e) {
        throw new MigrateBirdException(e);
    } catch (IllegalArgumentException e) {
        // Ignored
    }
}

From source file:abfab3d.grid.op.TestDownsampleAlpha.java

/**
 * Write out slices for debugging.  Ignore if debug if FALSE
 * @param dir/*  w w  w.  j  a v a 2 s.  c o  m*/
 * @param grid
 * @param maxAttributeValue
 */
private void writeSlices(String dir, Grid grid, int maxAttributeValue) {
    if (!DEBUG)
        return;

    try {
        File f = new File(dir);
        f.mkdirs();
        FileUtils.cleanDirectory(f);
        SlicesWriter slicer = new SlicesWriter();
        slicer.setFilePattern(dir + "/slice_%03d.png");
        slicer.setCellSize(12);
        slicer.setVoxelSize(9);
        slicer.setWriteLevels(false);
        slicer.setWriteVoxels(true);
        slicer.setLevels(new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 });
        slicer.setMaxAttributeValue(maxAttributeValue);

        slicer.writeSlices(grid);
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

}

From source file:edu.isi.karma.research.modeling.ModelLearner_KnownModels.java

public static void runResearchEvaluation() throws Exception {

    /***//from w  w  w  . j ava 2  s . c  o m
     * When running with k=1, change the flag "multiple.same.property.per.node" to true so all attributes have at least one semantic types
     */
    ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance()
            .registerByKarmaHome("/Users/mohsen/karma/");
    contextParameters.setParameterValue(ContextParameter.USER_DIRECTORY_PATH, "/Users/mohsen/karma/");
    contextParameters.setParameterValue(ContextParameter.USER_CONFIG_DIRECTORY, "/Users/mohsen/karma/config");
    contextParameters.setParameterValue(ContextParameter.TRAINING_EXAMPLE_MAX_COUNT, "1000000");
    contextParameters.setParameterValue(ContextParameter.SEMTYPE_MODEL_DIRECTORY,
            "/Users/mohsen/karma/semantic-type-files/");
    contextParameters.setParameterValue(ContextParameter.JSON_MODELS_DIR, "/Users/mohsen/karma/models-json/");
    contextParameters.setParameterValue(ContextParameter.GRAPHVIZ_MODELS_DIR,
            "/Users/mohsen/karma/models-graphviz/");
    contextParameters.setParameterValue(ContextParameter.USER_PYTHON_SCRIPTS_DIRECTORY,
            "/Users/mohsen/karma/python/");
    contextParameters.setParameterValue(ContextParameter.EVALUATE_MRR, "/Users/mohsen/karma/evaluate-mrr/");
    PythonRepository pythonRepository = new PythonRepository(true,
            contextParameters.getParameterValue(ContextParameter.USER_PYTHON_SCRIPTS_DIRECTORY));
    PythonRepositoryRegistry.getInstance().register(pythonRepository);

    //      String inputPath = Params.INPUT_DIR;
    String graphPath = Params.GRAPHS_DIR;
    File semFilesFolder = new File(
            contextParameters.getParameterValue(ContextParameter.SEMTYPE_MODEL_DIRECTORY));

    //      List<SemanticModel> semanticModels = ModelReader.importSemanticModels(inputPath);
    List<SemanticModel> semanticModels = ModelReader.importSemanticModelsFromJsonFiles(Params.MODEL_DIR,
            Params.MODEL_MAIN_FILE_EXT);

    File[] sources = new File(Params.SOURCE_DIR).listFiles();
    File[] r2rmlModels = new File(Params.R2RML_DIR).listFiles();
    if (sources.length > 0 && sources[0].getName().startsWith("."))
        sources = (File[]) ArrayUtils.removeElement(sources, sources[0]);
    if (r2rmlModels.length > 0 && r2rmlModels[0].getName().startsWith("."))
        r2rmlModels = (File[]) ArrayUtils.removeElement(r2rmlModels, r2rmlModels[0]);

    List<SemanticModel> trainingData = new ArrayList<SemanticModel>();
    File[] trainingSources;
    File[] trainingModels;
    File trainingSource = null;
    File trainingModel = null;
    File testSource;
    File testModel;

    OntologyManager ontologyManager = new OntologyManager(contextParameters.getId());
    File ff = new File(Params.ONTOLOGY_DIR);
    File[] files = ff.listFiles();
    for (File f : files) {
        if (f.getName().startsWith(".") || f.isDirectory()) {
            continue; //Ignore . files
        }
        ontologyManager.doImport(f, "UTF-8");
    }
    ontologyManager.updateCache();

    ModelLearningGraph modelLearningGraph = null;

    ModelLearner_KnownModels modelLearner;

    boolean onlyGenerateSemanticTypeStatistics = false;
    boolean iterativeEvaluation = true;
    boolean useCorrectType = false;
    boolean onlyEvaluateInternalLinks = false || useCorrectType;
    boolean zeroKnownModel = false;
    int numberOfCandidates = 1;

    if (onlyGenerateSemanticTypeStatistics) {
        getStatistics(semanticModels, null, 0);
        return;
    }
    int numberOfKnownModels;
    String filePath = Params.RESULTS_DIR + "temp/";
    String filename = "";
    filename += "results";
    filename += useCorrectType ? "-correct" : "-k=" + numberOfCandidates;
    filename += zeroKnownModel ? "-ontology" : "";
    filename += onlyEvaluateInternalLinks ? "-internal" : "-all";
    filename += iterativeEvaluation ? "-iterative" : "";
    filename += ".csv";

    PrintWriter resultFileIterative = null;
    PrintWriter resultFile = null;
    StringBuffer[] resultsArray = null;

    if (iterativeEvaluation) {
        resultFileIterative = new PrintWriter(new File(filePath + filename));
        resultsArray = new StringBuffer[semanticModels.size() + 2];
        for (int i = 0; i < resultsArray.length; i++) {
            resultsArray[i] = new StringBuffer();
        }
    } else {
        resultFile = new PrintWriter(new File(filePath + filename));
        resultFile.println("source \t p \t r \t t \t a \t m \n");
    }

    //      new OfflineTraining().getCorrectModel(contextParameters, 
    //            null, null, 
    //            sources[20], r2rmlModels[20], 0, numberOfCandidates);
    //      if (true) return;

    for (int i = 0; i < semanticModels.size(); i++) {
        //      for (int i = 0; i <= 1; i++) {
        //      int i = 1; {

        // clean semantic files folder in karma home
        FileUtils.cleanDirectory(semFilesFolder);
        trainingSource = null;
        trainingModel = null;

        int newSourceIndex = i;
        SemanticModel newSource = semanticModels.get(newSourceIndex);

        logger.info("======================================================");
        logger.info(newSource.getName() + "(#attributes:" + newSource.getColumnNodes().size() + ")");
        System.out.println(newSource.getName() + "(#attributes:" + newSource.getColumnNodes().size() + ")");
        logger.info("======================================================");

        if (zeroKnownModel)
            numberOfKnownModels = 0;
        else
            numberOfKnownModels = iterativeEvaluation ? 0 : semanticModels.size() - 1;

        if (iterativeEvaluation) {
            if (resultsArray[0].length() > 0)
                resultsArray[0].append(" \t ");
            resultsArray[0].append(newSource.getName() + "(" + newSource.getColumnNodes().size() + ")" + "\t"
                    + " " + "\t" + " " + "\t" + " " + "\t" + " ");
            if (resultsArray[1].length() > 0)
                resultsArray[1].append(" \t ");
            resultsArray[1].append("p \t r \t t \t a \t m");
        }

        //         numberOfKnownModels = 2;
        while (numberOfKnownModels <= semanticModels.size() - 1) {

            trainingData.clear();
            trainingSources = new File[numberOfKnownModels];
            trainingModels = new File[numberOfKnownModels];

            int j = 0, count = 0;
            while (count < numberOfKnownModels) {
                if (j != newSourceIndex) {
                    trainingData.add(semanticModels.get(j));
                    trainingSources[count] = sources[j];
                    trainingModels[count] = r2rmlModels[j];
                    count++;
                    if (count == numberOfKnownModels) {
                        trainingSource = sources[j];
                        trainingModel = r2rmlModels[j];
                    }
                }
                j++;
            }

            modelLearningGraph = (ModelLearningGraphCompact) ModelLearningGraph
                    .getEmptyInstance(ontologyManager, ModelLearningGraphType.Compact);

            SemanticModel correctModel;
            if (useCorrectType) {
                correctModel = newSource;
                correctModel.setAccuracy(1.0);
                correctModel.setMrr(1.0);
            } else {
                testSource = sources[newSourceIndex];
                testModel = r2rmlModels[newSourceIndex];
                if (iterativeEvaluation) {
                    correctModel = new OfflineTraining().getCorrectModel(contextParameters, trainingSource,
                            trainingModel, testSource, testModel, numberOfKnownModels, numberOfCandidates);
                } else {
                    correctModel = new OfflineTraining().getCorrectModel(contextParameters, trainingSources,
                            trainingModels, testSource, testModel, numberOfCandidates);
                }
            }

            List<ColumnNode> columnNodes = correctModel.getColumnNodes();
            //            if (useCorrectType && numberOfCRFCandidates > 1)
            //               updateCrfSemanticTypesForResearchEvaluation(columnNodes);

            List<Node> steinerNodes = new LinkedList<Node>(columnNodes);
            modelLearner = new ModelLearner_KnownModels(modelLearningGraph.getGraphBuilder(), steinerNodes);
            long start = System.currentTimeMillis();

            String graphName = !iterativeEvaluation
                    ? graphPath + semanticModels.get(newSourceIndex).getName() + Params.GRAPH_JSON_FILE_EXT
                    : graphPath + semanticModels.get(newSourceIndex).getName() + ".knownModels="
                            + numberOfKnownModels + Params.GRAPH_JSON_FILE_EXT;

            if (new File(graphName).exists()) {
                // read graph from file
                try {
                    logger.info("loading the graph ...");
                    DirectedWeightedMultigraph<Node, DefaultLink> graph = GraphUtil.importJson(graphName);
                    GraphBuilder gb = new GraphBuilderTopK(ontologyManager, graph);
                    modelLearner = new ModelLearner_KnownModels(gb, steinerNodes);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                logger.info("building the graph ...");
                for (SemanticModel sm : trainingData)
                    //                  modelLearningGraph.addModel(sm);
                    modelLearningGraph.addModelAndUpdate(sm, PatternWeightSystem.JWSPaperFormula);
                modelLearner = new ModelLearner_KnownModels(modelLearningGraph.getGraphBuilder(), steinerNodes);
                //               modelLearner.graphBuilder = modelLearningGraph.getGraphBuilder();
                //               modelLearner.nodeIdFactory = modelLearner.graphBuilder.getNodeIdFactory();
                // save graph to file
                try {
                    //                  GraphUtil.exportJson(modelLearningGraph.getGraphBuilder().getGraph(), graphName, true, true);
                    //                  GraphVizUtil.exportJGraphToGraphviz(modelLearner.graphBuilder.getGraph(), 
                    //                        "test", 
                    //                        true,                   
                    //                        GraphVizLabelType.LocalId,
                    //                        GraphVizLabelType.LocalUri,
                    //                        false, 
                    //                        true, 
                    //                        graphName + ".dot");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            List<SortableSemanticModel> hypothesisList = modelLearner.hypothesize(useCorrectType,
                    numberOfCandidates);

            long elapsedTimeMillis = System.currentTimeMillis() - start;
            float elapsedTimeSec = elapsedTimeMillis / 1000F;

            int cutoff = 20;//ModelingConfiguration.getMaxCandidateModels();
            List<SortableSemanticModel> topHypotheses = null;
            if (hypothesisList != null) {
                topHypotheses = hypothesisList.size() > cutoff ? hypothesisList.subList(0, cutoff)
                        : hypothesisList;
            }

            Map<String, SemanticModel> models = new TreeMap<String, SemanticModel>();

            ModelEvaluation me;
            models.put("1-correct model", correctModel);
            if (topHypotheses != null)
                for (int k = 0; k < topHypotheses.size(); k++) {

                    SortableSemanticModel m = topHypotheses.get(k);

                    me = m.evaluate(correctModel, onlyEvaluateInternalLinks, false);

                    String label = "candidate " + k + "\n" +
                    //                        (m.getSteinerNodes() == null ? "" : m.getSteinerNodes().getScoreDetailsString()) +
                            "link coherence:"
                            + (m.getLinkCoherence() == null ? "" : m.getLinkCoherence().getCoherenceValue())
                            + "\n";
                    label += (m.getSteinerNodes() == null || m.getSteinerNodes().getCoherence() == null) ? ""
                            : "node coherence:" + m.getSteinerNodes().getCoherence().getCoherenceValue() + "\n";
                    label += "confidence:" + m.getConfidenceScore() + "\n";
                    label += m.getSteinerNodes() == null ? ""
                            : "mapping score:" + m.getSteinerNodes().getScore() + "\n";
                    label += "cost:" + roundDecimals(m.getCost(), 6) + "\n" +
                    //                        "-distance:" + me.getDistance() + 
                            "-precision:" + me.getPrecision() + "-recall:" + me.getRecall();

                    models.put(label, m);

                    if (k == 0) { // first rank model
                        System.out.println("number of known models: " + numberOfKnownModels + ", precision: "
                                + me.getPrecision() + ", recall: " + me.getRecall() + ", time: "
                                + elapsedTimeSec + ", accuracy: " + correctModel.getAccuracy() + ", mrr: "
                                + correctModel.getMrr());
                        logger.info("number of known models: " + numberOfKnownModels + ", precision: "
                                + me.getPrecision() + ", recall: " + me.getRecall() + ", time: "
                                + elapsedTimeSec + ", accuracy: " + correctModel.getAccuracy() + ", mrr: "
                                + correctModel.getMrr());
                        //                     resultFile.println("number of known models \t precision \t recall");
                        //                     resultFile.println(numberOfKnownModels + "\t" + me.getPrecision() + "\t" + me.getRecall());
                        String s = me.getPrecision() + "\t" + me.getRecall() + "\t" + elapsedTimeSec + "\t"
                                + correctModel.getAccuracy() + "\t" + correctModel.getMrr();

                        if (iterativeEvaluation) {
                            if (resultsArray[numberOfKnownModels + 2].length() > 0)
                                resultsArray[numberOfKnownModels + 2].append(" \t ");
                            resultsArray[numberOfKnownModels + 2].append(s);
                        } else {
                            //                        s = newSource.getName() + "\t" + 
                            //                              me.getPrecision() + "\t" + 
                            //                              me.getRecall() + "\t" + 
                            //                              elapsedTimeSec + "\t" + 
                            //                              correctModel.getAccuracy() + "\t" + 
                            //                              correctModel.getMrr();
                            s = me.getPrecision() + "\t" + me.getRecall() + "\t" + elapsedTimeSec;
                            resultFile.println(s);
                        }

                        //                     resultFile.println(me.getPrecision() + "\t" + me.getRecall() + "\t" + elapsedTimeSec);
                    }
                }

            String outputPath = Params.OUTPUT_DIR;
            String outName = !iterativeEvaluation
                    ? outputPath + semanticModels.get(newSourceIndex).getName()
                            + Params.GRAPHVIS_OUT_DETAILS_FILE_EXT
                    : outputPath + semanticModels.get(newSourceIndex).getName() + ".knownModels="
                            + numberOfKnownModels + Params.GRAPHVIS_OUT_DETAILS_FILE_EXT;

            GraphVizUtil.exportSemanticModelsToGraphviz(models, newSource.getName(), outName,
                    GraphVizLabelType.LocalId, GraphVizLabelType.LocalUri, true, true);

            numberOfKnownModels++;
            if (zeroKnownModel)
                break;
        }

    }
    if (iterativeEvaluation) {
        for (StringBuffer s : resultsArray)
            resultFileIterative.println(s.toString());
        resultFileIterative.close();
    } else {
        resultFile.close();
    }

}