Example usage for java.util ArrayList set

List of usage examples for java.util ArrayList set

Introduction

In this page you can find the example usage for java.util ArrayList set.

Prototype

public E set(int index, E element) 

Source Link

Document

Replaces the element at the specified position in this list with the specified element.

Usage

From source file:com.hygenics.parser.ForceConformityWithReference.java

private void iter() {
    log.info("Starting Enforcement @ " + Calendar.getInstance().getTime().toString() + " | UTC "
            + Calendar.getInstance().getTimeInMillis());

    String sql;//w  w  w.  ja  v  a  2s.  co  m
    boolean add = true;
    ArrayList<String> columns = null;
    ArrayList<String> tablecolumns = null;
    Quicksort<String> qs = new Quicksort<String>();
    Levenshtein lev = new Levenshtein();

    // iterate through each table
    for (String table : schema_columns.keySet()) {

        log.info("Checking for Table Existance " + table);
        String schema = this.baseschema;

        log.info("Checking  table: " + table + "&& schema: " + schema);

        if (template.checkTable(this.baseschema + "." + table, schema)) {

            log.info("Conforming: " + table);
            // get the arraylist
            tablecolumns = template.getColumns(this.baseschema + "." + table);

            if (insensitive == true) {
                for (int i = 0; i < tablecolumns.size(); i++) {
                    tablecolumns.set(i, tablecolumns.get(i).toLowerCase());
                }
            }

            columns = (ArrayList<String>) schema_columns.get(table);

            if (insensitive == true) {
                for (int i = 0; i < columns.size(); i++) {
                    columns.set(i, columns.get(i).toLowerCase());
                }
            }

            if (exclude != null) {
                // remove unmatchable columns
                if (exclude.size() > 0) {
                    for (String col : exclude) {
                        tablecolumns.remove(col);
                        columns.remove(col);
                    }
                }
            }

            // sort each arraylist
            qs.setTosortlist(columns);
            columns = qs.sort();

            qs.setTosortlist(tablecolumns);
            tablecolumns = qs.sort();

            // check each remaining column
            for (int i = 0; i < columns.size(); i++) {

                if (tablecolumns.contains(columns.get(i).trim()) == false || (insensitive == true
                        && tablecolumns.contains(columns.get(i).toLowerCase().trim()) == false)) {

                    if (correct) {
                        int dist = Levenshtein.getLevenshteinDistance(tablecolumns.get(i), columns.get(i));
                        add = false;
                        log.info("Distance was " + dist + " Cutoff is " + levcutoff);

                        // check lev. distances if requested and ensure some
                        // match with fuzzy (use at your own risk)
                        if (levcutoff > -1 & dist <= levcutoff) {

                            log.info("Approximate Match: Correcting Column");

                            // if distance is within 1 or specified
                            // distances, correct it
                            sql = "ALTER TABLE " + this.baseschema + "." + table + " RENAME COLUMN "
                                    + tablecolumns.get(i) + " TO " + columns.get(i);
                            template.execute(sql);

                            // get the table columns
                            tablecolumns = template.getColumns(this.baseschema + "." + table);
                            qs.setTosortlist(tablecolumns);
                            tablecolumns = qs.sort();

                        }
                    } else {
                        add = true;
                    }

                    if (add) {
                        // add column if necessary
                        sql = "Alter Table " + this.baseschema + "." + table + " ADD COLUMN " + columns.get(i)
                                + " text";
                        template.execute(sql);

                        // get the table columns again and resort them
                        tablecolumns = template.getColumns(this.baseschema + "." + table);

                        if (exclude != null) {
                            if (exclude.size() > 0) {
                                for (String ex : exclude) {
                                    tablecolumns.remove(ex);
                                    columns.remove(ex);
                                }
                            }
                        }

                        qs.setTosortlist(tablecolumns);
                        tablecolumns = qs.sort();
                    }
                    // iterate backward so that the integrety is assured
                    i--;
                }
            }
        } else {
            try {
                throw new SQLMalformedException("WARNING: Table " + table + " is missing");
            } catch (SQLMalformedException e) {
                e.printStackTrace();
            }
        }

    }
    log.info("Finishing Enforcement @ " + Calendar.getInstance().getTime().toString() + " | UTC "
            + Calendar.getInstance().getTimeInMillis());

}

From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorOrderController.java

@RequestMapping(value = "/module/accessmonitor/order", method = RequestMethod.POST)
public void postSave(ModelMap model, HttpServletRequest request) throws IOException {

    if (request.getParameter("offset") != null) {
        offset = Integer.parseInt(request.getParameter("offset"));
    }/*from w w  w.  j  a  v a 2  s  .  c o  m*/
    int count = -1;
    // parse them to Date, null is acceptable
    DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
    // Get the from date and to date
    Date to = null;
    Date from = null;
    try {
        from = format.parse(request.getParameter("datepickerFrom"));
    } catch (Exception e) {
        //System.out.println("======From Date Empty=======");
    }
    try {
        to = format.parse(request.getParameter("datepickerTo"));
    } catch (Exception e) {
        //System.out.println("======To Date Empty=======");
    }

    if (orderAccessData == null || orderAccessData.size() == 0) {
        // get all the records in the date range
        orderAccessData = ((OrderAccessService) Context.getService(OrderAccessService.class))
                .getOrderAccessesByAccessDateOrderByPatientId(from, to);
        if (orderAccessData == null) {
            orderAccessData = new ArrayList<OrderServiceAccess>();
        }
    }

    // get date for small graph
    Date toSmall = to;
    Date fromSmall = null;
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, 1);
    if (toSmall == null) {
        toSmall = calendar.getTime();
    } else {
        calendar.setTime(toSmall);
    }
    calendar.add(Calendar.DATE, -DAYNUM);
    fromSmall = calendar.getTime();

    List<String> dateStrings = new ArrayList<String>();
    for (int i = 0; i < DAYNUM; i++) {
        if (i == DAYNUM - 1) {
            dateStrings.add(format.format(toSmall));
        } else if (i == 0) {
            dateStrings.add(format.format(fromSmall));
        } else {
            dateStrings.add("");
        }
    }

    ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>();
    tooltip.add(new ArrayList<Integer>());
    for (int j = 0; j < SHOWNUM + 1; j++) {
        tooltip.get(0).add(1000 + j);
    }
    for (int i = 1; i < DAYNUM + 1; i++) {
        tooltip.add(new ArrayList<Integer>());
        tooltip.get(i).add(i);
        for (int j = 0; j < SHOWNUM; j++) {
            tooltip.get(i).add(0);
        }
    }

    ArrayList<String> patientIds = new ArrayList<String>();
    ArrayList<Integer> patientCounts = new ArrayList<Integer>();
    String last = "";
    for (OrderServiceAccess oa : orderAccessData) {
        // data for big graph
        String idString = (oa.getPatientId() == null) ? "No ID" : oa.getPatientId().toString();
        if (!idString.equals(last)) {
            count++;
            last = idString;
        }
        int index = patientIds.indexOf(idString);
        if (index < 0) {
            if (count < offset)
                continue;
            if (patientIds.size() >= SHOWNUM)
                break;
            patientIds.add(idString);
            patientCounts.add(1);
            index = patientIds.size() - 1;//index = personIds.indexOf(idString);
        } else {
            patientCounts.set(index, patientCounts.get(index) + 1);
        }
        // data for small graph
        if (oa.getAccessDate().after(fromSmall) && oa.getAccessDate().before(toSmall)) {
            int index2 = (int) ((oa.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24));
            if (index2 < DAYNUM && index2 >= 0)
                tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1);
        }
    }
    String patientIdString = JSONValue.toJSONString(patientIds);
    String patientCountString = JSONValue.toJSONString(patientCounts);
    String dateSmallString = JSONValue.toJSONString(dateStrings);
    String tooltipdata = JSONValue.toJSONString(tooltip);
    model.addAttribute("patientIds", patientIdString);
    model.addAttribute("patientCounts", patientCountString);
    model.addAttribute("dateSmallString", dateSmallString);
    model.addAttribute("tooltipdata", tooltipdata);

    model.addAttribute("user", Context.getAuthenticatedUser());
    //model.addAttribute("tables1", orderAccessData);
    //model.addAttribute("dateSmall", dateStrings);
    model.addAttribute("currentoffset", String.valueOf(offset));
}

From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorVisitController.java

@RequestMapping(value = "/module/accessmonitor/visit", method = RequestMethod.POST)
public void postSave(ModelMap model, HttpServletRequest request) throws IOException {

    if (request.getParameter("offset") != null) {
        offset = Integer.parseInt(request.getParameter("offset"));
    }/*ww w.  j  a v a 2  s  .  co  m*/
    int count = -1;
    // parse them to Date, null is acceptabl
    DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
    // Get the from date and to date
    Date to = null;
    Date from = null;
    try {
        from = format.parse(request.getParameter("datepickerFrom"));
    } catch (Exception e) {
        //System.out.println("======From Date Empty=======");
    }
    try {
        to = format.parse(request.getParameter("datepickerTo"));
    } catch (Exception e) {
        //System.out.println("======To Date Empty=======");
    }

    if (visitAccessData == null || visitAccessData.size() == 0) {
        // get all the records in the date range
        visitAccessData = ((VisitAccessService) Context.getService(VisitAccessService.class))
                .getVisitAccessesByAccessDateOrderByPatientId(from, to);
        if (visitAccessData == null) {
            visitAccessData = new ArrayList<VisitServiceAccess>();
        }
    }

    // get date for small graph
    Date toSmall = to;
    Date fromSmall = null;
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, 1);
    if (toSmall == null) {
        toSmall = calendar.getTime();
    } else {
        calendar.setTime(toSmall);
    }
    calendar.add(Calendar.DATE, -DAYNUM);
    fromSmall = calendar.getTime();

    List<String> dateStrings = new ArrayList<String>();
    for (int i = 0; i < DAYNUM; i++) {
        if (i == DAYNUM - 1) {
            dateStrings.add(format.format(toSmall));
        } else if (i == 0) {
            dateStrings.add(format.format(fromSmall));
        } else {
            dateStrings.add("");
        }
    }

    ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>();
    tooltip.add(new ArrayList<Integer>());
    for (int j = 0; j < SHOWNUM + 1; j++) {
        tooltip.get(0).add(1000 + j);
    }
    for (int i = 1; i < DAYNUM + 1; i++) {
        tooltip.add(new ArrayList<Integer>());
        tooltip.get(i).add(i);
        for (int j = 0; j < SHOWNUM; j++) {
            tooltip.get(i).add(0);
        }
    }

    ArrayList<String> patientIds = new ArrayList<String>();
    ArrayList<Integer> patientCounts = new ArrayList<Integer>();
    String last = "";
    for (VisitServiceAccess va : visitAccessData) {
        // data for big graph
        String idString = (va.getPatientId() == null) ? "No ID" : va.getPatientId().toString();
        if (!idString.equals(last)) {
            count++;
            last = idString;
        }
        int index = patientIds.indexOf(idString);
        if (index < 0) {
            if (count < offset)
                continue;
            if (patientIds.size() >= SHOWNUM)
                break;
            patientIds.add(idString);
            patientCounts.add(1);
            index = patientIds.size() - 1;//index = patientIds.indexOf(idString);
        } else {
            patientCounts.set(index, patientCounts.get(index) + 1);
        }
        // data for small graph
        if (va.getAccessDate().after(fromSmall) && va.getAccessDate().before(toSmall)) {
            int index2 = (int) ((va.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24));
            if (index2 < DAYNUM && index2 >= 0)
                tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1);
        }
    }
    String patientIdString = JSONValue.toJSONString(patientIds);
    String patientCountString = JSONValue.toJSONString(patientCounts);
    String dateSmallString = JSONValue.toJSONString(dateStrings);
    String tooltipdata = JSONValue.toJSONString(tooltip);
    model.addAttribute("patientIds", patientIdString);
    model.addAttribute("patientCounts", patientCountString);
    model.addAttribute("dateSmallString", dateSmallString);
    model.addAttribute("tooltipdata", tooltipdata);

    model.addAttribute("user", Context.getAuthenticatedUser());
    //        model.addAttribute("tables1", visitAccessData);
    //        model.addAttribute("dateSmall", dateStrings);
    model.addAttribute("currentoffset", String.valueOf(offset));

}

From source file:at.illecker.hama.hybrid.examples.hellohybrid.HelloHybridBSP.java

@Override
public void bsp(BSPPeer<IntWritable, NullWritable, IntWritable, NullWritable, NullWritable> peer)
        throws IOException, SyncException, InterruptedException {

    BSPJob job = new BSPJob((HamaConfiguration) peer.getConfiguration());
    FileSystem fs = FileSystem.get(peer.getConfiguration());
    FSDataOutputStream outStream = fs//from   www. j  av a  2  s  .  c om
            .create(new Path(FileOutputFormat.getOutputPath(job), peer.getTaskId() + ".log"));

    outStream.writeChars("HelloHybrid.bsp executed on CPU!\n");

    ArrayList<Integer> summation = new ArrayList<Integer>();

    // test input
    IntWritable key = new IntWritable();
    NullWritable nullValue = NullWritable.get();

    while (peer.readNext(key, nullValue)) {
        outStream.writeChars("input: key: '" + key.get() + "'\n");
        summation.add(key.get());
    }

    // test sequenceFileReader
    Path example = new Path(peer.getConfiguration().get(CONF_EXAMPLE_PATH));
    SequenceFile.Reader reader = null;
    try {
        reader = new SequenceFile.Reader(fs, example, peer.getConfiguration());

        int i = 0;
        while (reader.next(key, nullValue)) {
            outStream.writeChars("sequenceFileReader: key: '" + key.get() + "'\n");
            if (i < summation.size()) {
                summation.set(i, summation.get(i) + key.get());
            }
            i++;
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        if (reader != null) {
            reader.close();
        }
    }

    // test output
    for (Integer i : summation) {
        key.set(i);
        outStream.writeChars("output: key: '" + key.get() + "'\n");
        peer.write(key, nullValue);
    }

    // test getAllPeerNames
    outStream.writeChars("getAllPeerNames: '" + Arrays.toString(peer.getAllPeerNames()) + "'\n");

    // test String.split
    String splitString = "boo:and:foo";
    String[] splits;

    outStream.writeChars("splitString: '" + splitString + "'\n");

    splits = splitString.split(":");
    outStream.writeChars("split(\":\") len: " + splits.length + " values: '" + Arrays.toString(splits) + "'\n");

    splits = splitString.split(":", 2);
    outStream.writeChars(
            "split(\":\",2) len: " + splits.length + " values: '" + Arrays.toString(splits) + "'\n");

    splits = splitString.split(":", 5);
    outStream.writeChars(
            "split(\":\",5) len: " + splits.length + " values: '" + Arrays.toString(splits) + "'\n");

    splits = splitString.split(":", -2);
    outStream.writeChars(
            "split(\":\",-2) len: " + splits.length + " values: '" + Arrays.toString(splits) + "'\n");

    splits = splitString.split(";");
    outStream.writeChars("split(\";\") len: " + splits.length + " values: '" + Arrays.toString(splits) + "'\n");

    outStream.close();
}

From source file:classes.MyVisitor.java

@Override
public T visitDef_arreglo(MyLanguageParser.Def_arregloContext ctx) {

    T visit = visitExpr(ctx.expr());//from  w  ww .  j a va 2 s. c  om
    ArrayList<String> lista = (ArrayList<String>) visit;
    ArrayList<Integer> cuantos = new ArrayList<>();
    int size = 1;
    for (int i = 1; i < lista.size(); i++) {
        size *= Integer.valueOf(lista.get(i));
    }
    for (int i = 1; i < lista.size(); i++) {
        cuantos.add(size / Integer.valueOf(lista.get(i)));
    }

    ArrayList<String> add = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        add.add(lista.get(0) + "[");
    }

    for (int i = 1; i < lista.size(); i++) {
        add = dimensiones(size, Integer.valueOf(lista.get(i)), add);
    }

    for (int i = 0; i < size; i++) {
        add.set(i, add.get(i).substring(0, add.get(i).length() - 1));
        add.set(i, add.get(i).concat("]"));
    }

    for (String string : add) {
        guardar(string, lista.get(0));
    }
    return visitChildren(ctx);
}

From source file:com.pidoco.juri.JURI.java

/**
 * Decodes the path segments on request.
 * @return a new list that the caller may manipulate. Empty string if no path or the root path is set. Returns
 * empty path segments (//as//df// has three empty
 * segments)./*  ww w  .  j av  a  2s. co m*/
 */
public List<String> getPathSegments() {
    ArrayList<String> result = getRawPathSegments();
    for (int i = 0; i < result.size(); i++) {
        String segment = result.get(i);
        result.set(i, urlDecode(segment));
    }
    return result;
}

From source file:cn.edu.hfut.dmic.contentextractor.ContentExtractor.java

protected String getTitleByEditDistance(Element contentElement) throws Exception {
    final String metaTitle = doc.title();

    final ArrayList<Double> max = new ArrayList<Double>();
    max.add(0.0);/*  w w  w  . j a va2s . co  m*/
    final StringBuilder sb = new StringBuilder();
    doc.body().traverse(new NodeVisitor() {

        public void head(Node node, int i) {

            if (node instanceof TextNode) {
                TextNode tn = (TextNode) node;
                String text = tn.text().trim();
                double sim = strSim(text, metaTitle);
                if (sim > 0) {
                    if (sim > max.get(0)) {
                        max.set(0, sim);
                        sb.setLength(0);
                        sb.append(text);
                    }
                }

            }
        }

        public void tail(Node node, int i) {
        }
    });
    if (sb.length() > 0) {
        return sb.toString();
    }
    throw new Exception();

}

From source file:org.akaza.openclinica.control.managestudy.ViewStudySubjectServlet.java

public static void populateUncompletedCRFsWithCRFAndVersions(DataSource ds,
        ArrayList uncompletedEventDefinitionCRFs) {
    CRFDAO cdao = new CRFDAO(ds);
    CRFVersionDAO cvdao = new CRFVersionDAO(ds);

    int size = uncompletedEventDefinitionCRFs.size();
    for (int i = 0; i < size; i++) {
        DisplayEventDefinitionCRFBean dedcrf = (DisplayEventDefinitionCRFBean) uncompletedEventDefinitionCRFs
                .get(i);/*from   w ww. j a v  a 2  s  .  c  o m*/
        CRFBean cb = (CRFBean) cdao.findByPK(dedcrf.getEdc().getCrfId());
        dedcrf.getEdc().setCrf(cb);

        ArrayList theVersions = (ArrayList) cvdao.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
        ArrayList versions = new ArrayList();
        HashMap<String, CRFVersionBean> crfVersionIds = new HashMap<String, CRFVersionBean>();

        for (int j = 0; j < theVersions.size(); j++) {
            CRFVersionBean crfVersion = (CRFVersionBean) theVersions.get(j);
            crfVersionIds.put(String.valueOf(crfVersion.getId()), crfVersion);
        }

        if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
            String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
            for (String string : kk) {
                if (crfVersionIds.get(string) != null) {
                    versions.add(crfVersionIds.get(string));
                }
            }
        } else {
            versions = theVersions;
        }
        dedcrf.getEdc().setVersions(versions);
        uncompletedEventDefinitionCRFs.set(i, dedcrf);
    }
}

From source file:com.twosigma.beaker.core.rest.PluginServiceLocatorRest.java

/**
 * locatePluginService/*from   ww w. ja v a2s  .  c  o m*/
 * locate the service that matches the passed-in information about a service and return the
 * base URL the client can use to connect to the target plugin service. If such service
 * doesn't exist, this implementation will also start the service.
 *
 * @param pluginId
 * @param command name of the starting script
 * @param nginxRules rules to help setup nginx proxying
 * @param startedIndicator string indicating that the plugin has started
 * @param startedIndicatorStream stream to search for indicator, null defaults to stdout
 * @param recordOutput boolean, record out/err streams to output log service or not, null defaults
 * to false
 * @param waitfor if record output log service is used, string to wait for before logging starts
 * @return the base url of the service
 * @throws InterruptedException
 * @throws IOException
 */
@GET
@Path("/{plugin-id}")
@Produces(MediaType.TEXT_PLAIN)
public Response locatePluginService(@PathParam("plugin-id") String pluginId,
        @QueryParam("command") String command,
        @QueryParam("nginxRules") @DefaultValue("rest") String nginxRules,
        @QueryParam("startedIndicator") String startedIndicator,
        @QueryParam("startedIndicatorStream") @DefaultValue("stdout") String startedIndicatorStream,
        @QueryParam("recordOutput") @DefaultValue("false") boolean recordOutput,
        @QueryParam("waitfor") String waitfor) throws InterruptedException, IOException, ExecutionException {

    PluginConfig pConfig = this.plugins.get(pluginId);
    if (pConfig != null && pConfig.isStarted()) {
        logger.info("plugin service " + pluginId + " already started at" + pConfig.getBaseUrl());
        return buildResponse(pConfig.getBaseUrl(), false);
    }

    String password = RandomStringUtils.random(40, true, true);
    Process proc = null;
    String restartId = "";

    /*
     * Only one plugin can be started at a given time since we need to find a free port.
     * We serialize starting of plugins and we parallelize nginx configuration reload with the actual plugin
     * evaluator start.
     */
    synchronized (this) {
        // find a port to use for proxypass between nginx and the plugin
        final int port = getNextAvailablePort(this.portSearchStart);
        final String baseUrl = generatePrefixedRandomString(pluginId, 12).replaceAll("[\\s]", "");
        pConfig = new PluginConfig(port, nginxRules, baseUrl, password);
        this.portSearchStart = pConfig.port + 1;
        this.plugins.put(pluginId, pConfig);

        if (nginxRules.startsWith("ipython")) {
            generateIPythonConfig(pluginId, port, password, command);

            if (isIPython4OrNewer(getIPythonVersion(pluginId, command))) {
                new JupyterWidgetsExtensionProcessor(pluginId, this.pluginDir).copyJupyterExtensionIfExists();
            }
        }

        // reload nginx config
        restartId = generateNginxConfig();
        Process restartproc = Runtime.getRuntime().exec(this.nginxRestartCommand, this.nginxEnv);
        startGobblers(restartproc, "restart-nginx-" + pluginId, null, null);
        restartproc.waitFor();

        ArrayList<String> fullCommand = new ArrayList<String>(Arrays.asList(command.split("\\s+")));
        String args;

        fullCommand.set(0, (this.pluginLocations.containsKey(pluginId) ? this.pluginLocations.get(pluginId)
                : this.pluginDir) + "/" + fullCommand.get(0));
        if (Files.notExists(Paths.get(fullCommand.get(0)))) {
            throw new PluginServiceNotFoundException("plugin service " + pluginId + " not found at " + command);
        }

        List<String> extraArgs = this.pluginArgs.get(pluginId);
        if (extraArgs != null) {
            fullCommand.addAll(extraArgs);
        }

        fullCommand.add(Integer.toString(pConfig.port));

        String[] env = buildEnv(pluginId, password);

        if (windows()) {
            String python = this.config.getInstallDirectory() + "\\python\\python";
            fullCommand.add(0, python);
        }
        logger.info("Running");
        for (int i = 0; i < fullCommand.size(); i++) {
            logger.info(i + ": " + fullCommand.get(i));
        }
        proc = Runtime.getRuntime().exec(listToArray(fullCommand), env);
    }

    if (startedIndicator != null && !startedIndicator.isEmpty()) {
        InputStream is = startedIndicatorStream.equals("stderr") ? proc.getErrorStream()
                : proc.getInputStream();
        InputStreamReader ir = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(ir);
        String line = "";
        while ((line = br.readLine()) != null) {
            logger.info("looking on " + startedIndicatorStream + " found:" + line);
            if (line.indexOf(startedIndicator) >= 0) {
                logger.info("Acknowledge " + pluginId + " plugin started due to " + startedIndicator);
                break;
            }
        }
        if (null == line) {
            throw new PluginServiceNotFoundException("plugin service: " + pluginId + " failed to start");
        }
    }

    startGobblers(proc, pluginId, recordOutput ? this.outputLogService : null, waitfor);

    // check that nginx did actually restart
    String url = "http://127.0.0.1:" + this.restartPort + "/restart." + restartId + "/present.html";
    try {
        spinCheck(url);
    } catch (Throwable t) {
        logger.warn("time out plugin = {}", pluginId);
        this.plugins.remove(pluginId);
        if (windows()) {
            new WinProcess(proc).killRecursively();
        } else {
            proc.destroy(); // send SIGTERM
        }
        throw new NginxRestartFailedException(
                "nginx restart failed.\n" + "url=" + url + "\n" + "message=" + t.getMessage());
    }

    pConfig.setProcess(proc);
    logger.info("Done starting " + pluginId);

    return buildResponse(pConfig.getBaseUrl(), true);
}

From source file:ispd.gui.auxiliar.Graficos.java

public void criarGraficoPreempcao(RedeDeFilas rdf, List<Tarefa> tarefas) {

    DefaultCategoryDataset preempPorUsuario = new DefaultCategoryDataset();
    double mflopTotal = 0.0, tamanhoTotal;
    ArrayList<Integer> tarefasPreemp;
    tarefasPreemp = new ArrayList();
    int i, j, indexUsuario;

    for (i = 0; i < rdf.getUsuarios().size(); i++) {

        tarefasPreemp.add(0);//from  w w  w  .ja  v  a 2 s  .c  o  m

    }

    for (i = 0; i < tarefas.size(); i++) {

        indexUsuario = rdf.getUsuarios().indexOf(tarefas.get(i).getProprietario());

        if (tarefas.get(i).getMflopsDesperdicados() > 0.0 && tarefas.get(i).getEstado() != Tarefa.CANCELADO) {
            tarefasPreemp.set(indexUsuario, 1 + tarefasPreemp.get(indexUsuario));
        }

        mflopTotal = 0.0;

    }

    for (i = 0; i < rdf.getUsuarios().size(); i++) {

        preempPorUsuario.addValue(tarefasPreemp.get(i), "Number of tasks", rdf.getUsuarios().get(i));

    }

    JFreeChart jfc = ChartFactory.createStackedBarChart("Tasks preempted per user", //Titulo
            "", // Eixo X
            "Number of tasks", //Eixo Y
            preempPorUsuario, // Dados para o grafico
            PlotOrientation.VERTICAL, //Orientacao do grafico
            true, true, false); // exibir: legendas, tooltips, url
    PreemptionPerUser = new ChartPanel(jfc);
    PreemptionPerUser.setPreferredSize(new Dimension(600, 300));
}