Example usage for java.util LinkedList get

List of usage examples for java.util LinkedList get

Introduction

In this page you can find the example usage for java.util LinkedList get.

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:controllers.controller.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//  w w w .j a  v a 2s.c om
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, Exception {

    request.setCharacterEncoding(PageParameters.getParameter("charset").toString());
    response.setCharacterEncoding(PageParameters.getParameter("charset").toString());
    response.setContentType(PageParameters.getParameter("servletSetContentType").toString());
    response.setHeader("Cache-Control", "no-cache");
    HttpSession session;
    PrintWriter out;
    QUID quid;
    LinkedList<String> userAccess;
    quid = new QUID();
    quid.setRequest(request);
    session = request.getSession(true);
    SessionUtil.addIfNotExistSession(session);
    out = response.getWriter();
    try {
        try {
            if (PageParameters.getParameter("SiteOnMaintenance").equals("true")) {
                response.sendRedirect(PageParameters.getParameter("SiteOnMaintenanceURL").toString());
            } else // <editor-fold defaultstate="collapsed" desc="Realizando LogIn de usuario">
            //si proviene de la pgina  de login aqui se detectara y se validara al usuario
            {
                if (request.getParameter("LogInPage") != null) {
                    //aqui consulta el usuario en Base de Datos.
                    //                        if (request.getParameter("captcha").equals(session.getAttribute("captcha")) && request.getParameter("captcha").equalsIgnoreCase("") == false) {
                    if (true) {
                        if (request.getParameter("user").equalsIgnoreCase("") == false
                                && request.getParameter("pass").equalsIgnoreCase("") == false) {

                            LinkedList infoUser = null;
                            LinkedList<String> accessos = null;

                            infoUser = quid.selectIdUsuario(request.getParameter("user"),
                                    request.getParameter("pass"), "ACTIVO");

                            if (infoUser != null) {
                                session.removeAttribute("captcha");
                                SessionUtil.clearNCloseSession(session);
                                session = request.getSession(true);
                                session.setAttribute("tipoRol", infoUser.get(3));
                                session.setAttribute("userID", infoUser.get(0));
                                session.setAttribute("userName", infoUser.get(1));
                                session.setAttribute("FK_ID_Plantel", infoUser.get(2));
                                //asignacion de permisos
                                //LinkedList<String> accessos = new LinkedList();
                                accessos = quid.selectPermisosUsuarios(infoUser.get(0).toString());
                                session.setMaxInactiveInterval(3 * 60 * 60); // 2hrs * 60 min * 60 seg

                                //accesos del usaurio y parametros del mismo
                                session.setAttribute("userAccess", accessos);
                                SessionUtil.addIfNotExistSession(session);
                                request.getRequestDispatcher(PageParameters.getParameter("mainMenuServLet"))
                                        .forward(request, response);
                            } else {
                                this.getServletConfig().getServletContext().getRequestDispatcher(""
                                        + PageParameters.getParameter("msgUtil")
                                        + "/msgNRedirectFull.jsp?title=Error&type=error&msg=Usuario o password incorrectos.&url=/"
                                        + PageParameters.getParameter("appName")
                                        + PageParameters.getParameter("LogInPage")).forward(request, response);
                            }
                        } else {
                            this.getServletConfig().getServletContext().getRequestDispatcher(""
                                    + PageParameters.getParameter("msgUtil")
                                    + "/msgNRedirectFull.jsp?title=Error&type=error&msg=El usuario y password no pueden estar vacos.&url=/"
                                    + PageParameters.getParameter("appName")
                                    + PageParameters.getParameter("LogInPage")).forward(request, response);
                        }
                    } else {
                        this.getServletConfig().getServletContext().getRequestDispatcher(""
                                + PageParameters.getParameter("msgUtil")
                                + "/msgNRedirectFull.jsp?title=Error&type=error&msg=Cdigo de verificacin incorrecto.&url=/"
                                + PageParameters.getParameter("appName")
                                + PageParameters.getParameter("LogInPage")).forward(request, response);
                    }
                    // </editor-fold> 
                    // <editor-fold defaultstate="expanded" desc="Validando que sea un usuario logeado">
                } else if (session.getAttribute("userAccess") == null) {
                    response.sendRedirect("/" + PageParameters.getParameter("appName")
                            + PageParameters.getParameter("LogInPage"));
                    // </editor-fold> 
                } else // <editor-fold defaultstate="collapsed" desc="Cerrando sesion">
                {
                    if (request.getParameter("exit") != null) {
                        //session.invalidate();
                        this.clearNCloseSession(session, request, response, quid, out);
                        //quid.insertLog("SysLogOut", "exit", "", "", "", "");
                        response.sendRedirect(PageParameters.getParameter("mainContext")
                                + PageParameters.getParameter("LogInPage").toString());
                        // </editor-fold>
                        // <editor-fold defaultstate="collapsed" desc="Revisando de que form viene">
                    } else if (request.getParameter("FormForm") != null) {
                        switch (request.getParameter("FormForm")) {
                        case "agregaFichaTecnica":
                            this.agregaFichaTecnica(session, request, response, quid, out);
                            break;
                        case "modificaFichaTecnica":
                            this.modificaFichaTecnica(session, request, response, quid, out);
                            break;
                        case "agregaEtapaDesarrollo":
                            this.agregaEtapaDesarrollo(session, request, response, quid, out);
                            break;
                        case "modificaEtapaDesarrollo":
                            this.modificaEtapaDesarrollo(session, request, response, quid, out);
                            break;
                        case "eliminaStage":
                            this.eliminaEtapa(session, request, response, quid, out);
                            break;
                        case "agregaActivity":
                            this.agregaActividad(session, request, response, quid, out);
                            break;
                        case "modificaActivity":
                            this.modificaActividad(session, request, response, quid, out);
                            break;
                        case "eliminaActivity":
                            this.eliminaActividad(session, request, response, quid, out);
                            break;
                        case "deleteObjetoArchivo":
                            this.deleteObjetoArchivo(session, request, response, quid, out);
                            break;
                        }
                        // </editor-fold>
                    } else if (ServletFileUpload.isMultipartContent(new ServletRequestContext(request))) {
                        this.subirArchivo(session, request, response, quid, out);

                    } else {
                        out.println("UPS.... Algo malo ha pasado");
                    }
                }
            }

        } catch (Exception ex) {
            Logger.getLogger(controller.class.getName()).log(Level.SEVERE, null, ex);
        }
    } finally {
        quid = null;
        out.close();
    }
}

From source file:lob.VisualisationGUI.java

public void updateLabels(GUIUpdatePackage GUP) {
    jLabel15.setText(Integer.toString(this.time));

    LinkedList<Trade> newTrades = this.broker.getNewTrades();

    float mid = GUP.getMidpriceHistory().getLast();
    this.midPrice = mid;
    long above = 0;
    long below = 0;
    long exact = 0;

    //Add up trade metrics
    for (int i = 0; i < newTrades.size(); i++) {
        Trade trade = newTrades.get(i);
        if (trade.getTradePrice() > mid)
            above = above + trade.getTradeVolume();
        else if (trade.getTradePrice() < mid)
            below = below + trade.getTradeVolume();
        else/*from w w  w  .  j a v a  2  s.co  m*/
            exact = exact + trade.getTradeVolume();
    }

    long tot = above + below + exact;

    this.totalTraded = this.totalTraded + tot;
    this.averageTradeVolume = this.totalTraded / this.time;

    jLabel21.setText(Long.toString(tot));
    jLabel22.setText(Long.toString(this.averageTradeVolume));
    jLabel23.setText(Long.toString(above));
    jLabel24.setText(Long.toString(below));

}

From source file:Interfaces.EstadisticaConocioGui.java

/**
 * Creates new form EstadisticaConocioGui
 *//*from w w w .j  a v  a 2 s  . co m*/
public EstadisticaConocioGui(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    abrirBase();
    LazyList<Socio> socios = Socio.findAll();
    Iterator<Socio> it = socios.iterator();
    Socio s;
    String nosConocio;
    Boolean activo;
    Integer[] nosConocioSuma = { 0, 0, 0, 0, 0, 0 };
    LinkedList<Pair<Integer, Integer>> actividadesRealizan = new LinkedList<>();
    LazyList<Arancel> aranceles = Arancel.findAll();
    Iterator<Arancel> itArancel = aranceles.iterator();
    while (itArancel.hasNext()) {
        Pair<Integer, Integer> par = new Pair<>(itArancel.next().getInteger("id"), 0);
        actividadesRealizan.add(par);
    }
    while (it.hasNext()) {
        s = it.next();
        nosConocio = s.getString("NOSCONOCIOPOR");
        activo = s.getBoolean("ACTIVO");
        switch (nosConocio) {
        case "NO ESPECIFICA":
            nosConocioSuma[0]++;
            break;
        case "VIO EL GIMNASIO":
            nosConocioSuma[1]++;
            break;
        case "POR RADIO":
            nosConocioSuma[2]++;
            break;
        case "POR TV":
            nosConocioSuma[3]++;
            break;
        case "REDES SOCIALES":
            nosConocioSuma[4]++;
            break;
        case "UN AMIGO/A":
            nosConocioSuma[5]++;
            break;
        }
        if (activo) {
            LazyList<Socioarancel> arancelesSocio = Socioarancel.where("id_socio = ?", s.getId());
            Iterator<Socioarancel> itAr = arancelesSocio.iterator();
            while (itAr.hasNext()) {
                Socioarancel ar = itAr.next();
                boolean sume = false;
                int i = 0;
                while (i < actividadesRealizan.size() && !sume) {
                    if (actividadesRealizan.get(i).first() == ar.getInteger("id_arancel")) {
                        Pair<Integer, Integer> aux = new Pair<>(actividadesRealizan.get(i).first(),
                                actividadesRealizan.get(i).second() + 1);
                        actividadesRealizan.remove(i);
                        actividadesRealizan.add(i, aux);
                        sume = true;
                    }
                    i++;
                }
            }
        }
    }
    DefaultCategoryDataset datasetConocio = new DefaultCategoryDataset();
    datasetConocio.setValue(nosConocioSuma[0], "nos conocieron", "NO ESPECIFICA");
    datasetConocio.setValue(nosConocioSuma[1], "nos conocieron", "VIO EL GIMNASIO");
    datasetConocio.setValue(nosConocioSuma[2], "nos conocieron", "POR RADIO");
    datasetConocio.setValue(nosConocioSuma[3], "nos conocieron", "POR TV");
    datasetConocio.setValue(nosConocioSuma[4], "nos conocieron", "REDES SOCIALES");
    datasetConocio.setValue(nosConocioSuma[5], "nos conocieron", "UN AMIGO/A");
    JFreeChart chart = ChartFactory.createBarChart3D("Estadisticas por donde nos conocieron", "donde",
            "cantidad de personas", datasetConocio, PlotOrientation.VERTICAL, true, true, false);
    // Creacin del panel con el grfico
    ChartPanel panelGrafico = new ChartPanel(chart);
    pnlConocio.add(panelGrafico);

    DefaultCategoryDataset datasetAct = new DefaultCategoryDataset();
    for (int i = 0; i < actividadesRealizan.size(); i++) {
        String nombreAct = Arancel.findById(actividadesRealizan.get(i).first()).getString("nombre");
        datasetAct.setValue(actividadesRealizan.get(i).second(), "actividad", nombreAct);

    }
    JFreeChart chartAct = ChartFactory.createBarChart3D("Estadisticas que actividad realizan", "actividad",
            "cantidad de personas", datasetAct, PlotOrientation.VERTICAL, true, true, false);
    // Creacin del panel con el grfico
    ChartPanel panelGraficoAc = new ChartPanel(chartAct);
    pnlAct.add(panelGraficoAc);

}

From source file:com.commander4j.db.JDBDespatch.java

public boolean delete() {
    PreparedStatement stmtupdate;
    boolean result = false;
    setErrorMessage("");
    logger.debug("delete [" + getDespatchNo() + "]");

    LinkedList<String> assignedList = new LinkedList<String>();

    JDBPallet pal = new JDBPallet(getHostID(), getSessionID());

    if (isValid(false) == true) {
        String journeyRef = getJourneyRef();

        assignedList.clear();/*from w w  w .  j  av  a2s.com*/
        assignedList.addAll(getAssignedSSCCs());

        if (assignedList.size() > 0) {
            for (int j = 0; j < assignedList.size(); j++) {
                if (pal.getPalletProperties(assignedList.get(j))) {
                    pal.setDespatchNo("");
                    pal.update();
                }
            }
        }

        try {
            stmtupdate = Common.hostList.getHost(getHostID()).getConnection(getSessionID()).prepareStatement(
                    Common.hostList.getHost(getHostID()).getSqlstatements().getSQL("JDBDespatch.delete"));
            stmtupdate.setString(1, getDespatchNo());
            stmtupdate.execute();
            stmtupdate.clearParameters();
            Common.hostList.getHost(getHostID()).getConnection(getSessionID()).commit();

            stmtupdate.close();

            if (journeyRef.equals("") == false) {
                JDBJourney jrny = new JDBJourney(getHostID(), getSessionID());
                if (jrny.getJourneyRefProperties(journeyRef)) {
                    jrny.setStatus("Unassigned");
                    jrny.setDespatchNo("");
                    jrny.update();
                }
            }

            result = true;
        } catch (SQLException e) {
            setErrorMessage(e.getMessage());
        }
    }

    return result;
}

From source file:pt.lsts.neptus.util.logdownload.LogsDownloaderWorkerActions.java

private void testingForLogFilesFromEachLogFolderAndFillInfo(LinkedList<LogFolderInfo> tmpLogFolderList) {

    long timeF1 = System.currentTimeMillis();

    Object[] objArray = new Object[gui.logFolderList.myModel.size()];
    gui.logFolderList.myModel.copyInto(objArray);
    for (Object comp : objArray) {
        if (stopLogListProcessing)
            break;

        try {/*from   w w w .j av a2  s .  c  o  m*/
            LogFolderInfo logFolder = (LogFolderInfo) comp;

            int indexLFolder = tmpLogFolderList.indexOf(logFolder);
            LinkedHashSet<LogFileInfo> logFilesTmp = (indexLFolder != -1)
                    ? tmpLogFolderList.get(indexLFolder).getLogFiles()
                    : new LinkedHashSet<LogFileInfo>();
            for (LogFileInfo logFx : logFilesTmp) {
                if (stopLogListProcessing)
                    break;

                if (!logFolder.getLogFiles().contains(logFx)) {
                    // The file or directory is new
                    logFolder.addFile(logFx);
                } else {
                    // The file or directory is already known so let us update
                    LogFileInfo lfx = logFolder.getLogFile(logFx.getName()/* fxStr */);
                    if (lfx.getSize() == -1) {
                        lfx.setSize(logFx.getSize());
                    } else if (lfx.getSize() != logFx.getSize()) {
                        // System.out.println("//////////// " + lfx.getSize() + "  " + logFx.getSize());
                        if (lfx.getState() == LogFolderInfo.State.SYNC)
                            lfx.setState(LogFolderInfo.State.INCOMPLETE);
                        else if (lfx.getState() == LogFolderInfo.State.LOCAL)
                            lfx.setState(LogFolderInfo.State.INCOMPLETE);
                        lfx.setSize(logFx.getSize());
                        lfx.setFile(logFx.getFile());
                    } else if (lfx.getSize() == logFx.getSize()) {
                        if (lfx.getState() == LogFolderInfo.State.LOCAL)
                            lfx.setState(LogFolderInfo.State.SYNC);
                    }
                    lfx.setHost(logFx.getHost());

                    if (logFx.isDirectory()) {
                        ArrayList<LogFileInfo> notMatchElements = new ArrayList<>();
                        notMatchElements.addAll(lfx.getDirectoryContents());
                        for (LogFileInfo lfi : logFx.getDirectoryContents()) {
                            boolean alreadyExists = false;
                            for (LogFileInfo lfiLocal : lfx.getDirectoryContents()) {
                                if (lfi.equals(lfiLocal)) {
                                    alreadyExists = true;
                                    notMatchElements.remove(lfiLocal);
                                    lfi.setSize(lfiLocal.getSize());
                                    lfi.setFile(lfiLocal.getFile());
                                    lfi.setHost(lfiLocal.getHost());
                                }
                            }
                            if (!alreadyExists) {
                                lfx.getDirectoryContents().add(lfi);
                                lfx.setState(LogFolderInfo.State.INCOMPLETE);
                            }
                        }
                        for (LogFileInfo lfi : notMatchElements) {
                            lfx.getDirectoryContents().remove(lfi);
                        }
                    }

                    if (lfx.isDirectory()) {
                        if (!LogsDownloaderWorkerUtil.getFileTarget(lfx.getName(),
                                worker.getDirBaseToStoreFiles(), worker.getLogLabel()).exists()) {
                            for (LogFileInfo lfi : lfx.getDirectoryContents()) {
                                if (!LogsDownloaderWorkerUtil.getFileTarget(lfi.getName(),
                                        worker.getDirBaseToStoreFiles(), worker.getLogLabel()).exists()) {
                                    if (lfx.getState() != LogFolderInfo.State.NEW
                                            && lfx.getState() != LogFolderInfo.State.DOWNLOADING)
                                        lfx.setState(LogFolderInfo.State.INCOMPLETE);
                                    break;
                                }
                            }
                        } else {
                            long sizeD = LogsDownloaderWorkerUtil.getDiskSizeFromLocal(lfx, worker);
                            if (lfx.getSize() != sizeD && lfx.getState() == LogFolderInfo.State.SYNC)
                                lfx.setState(LogFolderInfo.State.INCOMPLETE);
                        }
                    } else {
                        if (!LogsDownloaderWorkerUtil.getFileTarget(lfx.getName(),
                                worker.getDirBaseToStoreFiles(), worker.getLogLabel()).exists()) {
                            if (lfx.getState() != LogFolderInfo.State.NEW
                                    && lfx.getState() != LogFolderInfo.State.DOWNLOADING) {
                                lfx.setState(LogFolderInfo.State.INCOMPLETE);
                                // System.out.println("//////////// " + lfx.getName() + "  " + LogsDownloaderUtil.getFileTarget(lfx.getName()).exists());
                            }
                        } else {
                            long sizeD = LogsDownloaderWorkerUtil.getDiskSizeFromLocal(lfx, worker);
                            if (lfx.getSize() != sizeD && lfx.getState() == LogFolderInfo.State.SYNC)
                                lfx.setState(LogFolderInfo.State.INCOMPLETE);
                        }
                    }
                }
            }

            // Put LOCAL state on files not in server
            LinkedHashSet<LogFileInfo> toDelFL = new LinkedHashSet<LogFileInfo>();
            for (LogFileInfo lfx : logFolder.getLogFiles()) {
                if (!logFilesTmp.contains(lfx)
                /* !res.keySet().contains(lfx.getName()) */) {
                    lfx.setState(LogFolderInfo.State.LOCAL);
                    if (!LogsDownloaderWorkerUtil
                            .getFileTarget(lfx.getName(), worker.getDirBaseToStoreFiles(), worker.getLogLabel())
                            .exists()) {
                        toDelFL.add(lfx);
                        // logFolder.getLogFiles().remove(lfx); //This cannot be done here
                    }
                }
            }
            for (LogFileInfo lfx : toDelFL)
                logFolder.getLogFiles().remove(lfx);
        } catch (Exception e) {
            NeptusLog.pub().debug(e.getMessage());
        }
    }

    NeptusLog.pub().warn(".......Testing for log files from each log folder "
            + (System.currentTimeMillis() - timeF1) + "ms");
}

From source file:UI.MainStageController.java

/**
 * creates the data for the analysis pane and displays it
 * data created includes://from   ww  w . ja va 2s  .  c  o  m
 * highest positive/negative correlations
 * average counts
 */
private void displayAnalysisTextsAndGraphs() {
    //Display node with highest frequency
    double highestFrequency = AnalysisData.getHighestFrequency();
    TaxonNode nodeWithHighestFrequency = AnalysisData.getNodeWithHighestFrequency();
    dataStatText.setText("Highest Frequency:\n" + nodeWithHighestFrequency.getName() + " ("
            + String.format("%.3f", highestFrequency) + ")\n");

    //Display nodes with highest positive/negative correlation
    RealMatrix correlationMatrix = AnalysisData.getCorrelationMatrix();
    int[] highestPositiveCorrelationCoordinates = AnalysisData.getHighestPositiveCorrelationCoordinates();
    int[] highestNegativeCorrelationCoordinates = AnalysisData.getHighestNegativeCorrelationCoordinates();
    LinkedList<TaxonNode> taxonList = SampleComparison.getUnifiedTaxonList(LoadedData.getSamplesToAnalyze(),
            AnalysisData.getLevelOfAnalysis());
    TaxonNode hPCNode1 = taxonList.get(highestPositiveCorrelationCoordinates[0]);
    TaxonNode hPCNode2 = taxonList.get(highestPositiveCorrelationCoordinates[1]);
    TaxonNode hNCNode1 = taxonList.get(highestNegativeCorrelationCoordinates[0]);
    TaxonNode hNCNode2 = taxonList.get(highestNegativeCorrelationCoordinates[1]);

    dataStatText.setText(dataStatText.getText() + "\nHighest Positive Correlation:\n" + hPCNode1.getName()
            + " - " + hPCNode2.getName() + " ("
            + String.format("%.3f", correlationMatrix.getEntry(highestPositiveCorrelationCoordinates[0],
                    highestPositiveCorrelationCoordinates[1]))
            + ")\n");
    dataStatText.setText(dataStatText.getText() + "\nHighest Negative Correlation:\n" + hNCNode1.getName()
            + " - " + hNCNode2.getName() + " ("
            + String.format("%.3f", correlationMatrix.getEntry(highestNegativeCorrelationCoordinates[0],
                    highestNegativeCorrelationCoordinates[1]))
            + ")");

    //Generate Data for the pie chart
    frequencyChart.getData().clear();
    HashMap<TaxonNode, Double> averageCounts = SampleComparison
            .calcAverageCounts(LoadedData.getSamplesToAnalyze(), AnalysisData.getLevelOfAnalysis());
    for (TaxonNode taxonNode : averageCounts.keySet()) {
        PieChart.Data data = new PieChart.Data(taxonNode.getName(), averageCounts.get(taxonNode));
        frequencyChart.getData().add(data);
    }

    analysisPane.setVisible(true);
}

From source file:org.apache.pig.backend.hadoop.executionengine.tez.TezDagBuilder.java

private LinkedList<POStore> processStores(TezOperator tezOp, Configuration payloadConf, Job job)
        throws VisitorException, IOException {
    LinkedList<POStore> stores = PlanHelper.getPhysicalOperators(tezOp.plan, POStore.class);

    if (stores.size() > 0) {

        ArrayList<POStore> storeLocations = new ArrayList<POStore>();
        for (POStore st : stores) {
            storeLocations.add(st);//from   w ww  .  j av a 2 s  . c  o  m
            StoreFuncInterface sFunc = st.getStoreFunc();
            sFunc.setStoreLocation(st.getSFile().getFileName(), job);
        }

        Path tmpLocation = null;
        if (stores.size() == 1) {
            POStore st = stores.get(0);

            // set out filespecs
            String outputPathString = st.getSFile().getFileName();
            if (!outputPathString.contains("://") || outputPathString.startsWith("hdfs://")) {
                payloadConf.set("pig.streaming.log.dir",
                        new Path(outputPathString, JobControlCompiler.LOG_DIR).toString());
            } else {
                String tmpLocationStr = FileLocalizer.getTemporaryPath(pc).toString();
                tmpLocation = new Path(tmpLocationStr);
                payloadConf.set("pig.streaming.log.dir",
                        new Path(tmpLocation, JobControlCompiler.LOG_DIR).toString());
            }
            payloadConf.set("pig.streaming.task.output.dir", outputPathString);

            if (tezOp.plan.getLeaves().get(0) instanceof POSplit) {
                // Set this so that we get correct counters
                st.setMultiStore(true);
            }

        } else { // multi store case
            log.info("Setting up multi store job");
            String tmpLocationStr = FileLocalizer.getTemporaryPath(pc).toString();
            tmpLocation = new Path(tmpLocationStr);

            boolean disableCounter = payloadConf.getBoolean("pig.disable.counter", false);
            if (disableCounter) {
                log.info("Disable Pig custom output counters");
            }
            int idx = 0;
            for (POStore sto : storeLocations) {
                sto.setDisableCounter(disableCounter);
                sto.setMultiStore(true);
                sto.setIndex(idx++);
            }

            payloadConf.set("pig.streaming.log.dir",
                    new Path(tmpLocation, JobControlCompiler.LOG_DIR).toString());
            payloadConf.set("pig.streaming.task.output.dir", tmpLocation.toString());
        }

    }
    return stores;
}

From source file:org.asqatasun.referential.creator.FileGenerator.java

public void createSqlTest(LinkedList<String> levelColum, LinkedList<String> scopeColum) throws IOException {
    List<String> tests = FileUtils.readLines(getI18nDefaultFile("rule"));
    List<String> criteres = FileUtils.readLines(getI18nDefaultFile("criterion"));
    StringBuilder strb = new StringBuilder();
    strb.append(//from   w w  w. ja  v  a 2  s. c om
            "INSERT IGNORE INTO `TEST` (`Cd_Test`, `Description`, `Label`, `Rank`, `Weight`, `Rule_Archive_Name`, `Rule_Class_Name`, `Id_Decision_Level`, `Id_Level`, `Id_Scope`, `Rule_Design_Url`, `No_Process`) VALUES\n");
    for (int i = 0; i < tests.size(); i += 2) {
        strb.append("(\'").append(tests.get(i).split("=")[0]).append("\', \'\', \'");
        String tmpLabel = tests.get(i).substring(vpc.getReferential().replace(".", "").length() + 1)
                .split("=")[0].replace("-", ".");
        if (!isCriterionPresent) {
            strb.append(tmpLabel.substring(0, tmpLabel.length() - 2));
        } else {
            strb.append(tmpLabel);
        }
        strb.append("\', ").append(String.valueOf(i - (i / 2) + 1)).append(", ").append("\'1.0\', \'");
        strb.append(vpc.getReferential().replace(".", "").replace(" ", "").toLowerCase()).append("\', \'");
        strb.append(vpc.getPackageString()).append('.');
        strb.append(vpc.getReferential().replace(".", "").toLowerCase()).append(".");
        strb.append(String.valueOf(vpc.getClassRule().get(i - (i / 2)))).append("\', ");
        strb.append("NULL, ").append(getLevelColum(levelColum.get(i - (i / 2))));
        strb.append(", ").append(scopeColum.get(i - (i / 2)));
        strb.append(", \'\', b\'0\')");
        if (i < tests.size() - 2) {
            strb.append(",\n");
        } else if (i == tests.size() - 2) {
            strb.append(";\n\n");
        }
    }
    for (int i = 0; i < criteres.size(); i += 1) {
        strb.append(
                "UPDATE `TEST` SET `Id_Criterion` = (SELECT `Id_Criterion` FROM `CRITERION` WHERE `Cd_Criterion` LIKE \'");
        strb.append(criteres.get(i).split("=")[0]);
        strb.append("\') WHERE `Cd_Test` LIKE \'");
        strb.append(criteres.get(i).split("=")[0]).append("-%\';\n");
        if (i == criteres.size() - 1) {
            strb.append("\n");
        }
    }
    FileUtils.writeStringToFile(FileUtils.getFile(getSqlFile()), strb.toString(), true);
}

From source file:org.asqatasun.referentiel.creator.FileGenerator.java

public void createSqlTest(LinkedList<String> levelColum, LinkedList<String> scopeColum) throws IOException {
    List<String> tests = FileUtils.readLines(getI18nDefaultFile("rule"));
    List<String> criteres = FileUtils.readLines(getI18nDefaultFile("criterion"));
    StringBuilder strb = new StringBuilder();
    strb.append(/*from  ww w . java 2 s. com*/
            "INSERT IGNORE INTO `TEST` (`Cd_Test`, `Description`, `Label`, `Rank`, `Weight`, `Rule_Archive_Name`, `Rule_Class_Name`, `Id_Decision_Level`, `Id_Level`, `Id_Scope`, `Rule_Design_Url`, `No_Process`) VALUES\n");
    for (int i = 0; i < tests.size(); i += 2) {
        strb.append("(\'").append(tests.get(i).split("=")[0]).append("\', \'\', \'");
        String tmpLabel = tests.get(i).substring(vpc.getReferentiel().replace(".", "").length() + 1)
                .split("=")[0].replace("-", ".");
        if (!isCriterionPresent) {
            strb.append(tmpLabel.substring(0, tmpLabel.length() - 2));
        } else {
            strb.append(tmpLabel);
        }
        strb.append("\', ").append(String.valueOf(i - (i / 2) + 1)).append(", ").append("\'1.0\', \'");
        strb.append(vpc.getReferentiel().replace(".", "").replace(" ", "").toLowerCase()).append("\', \'");
        strb.append(vpc.getPackageString()).append('.');
        strb.append(vpc.getReferentiel().replace(".", "").toLowerCase()).append(".");
        strb.append(String.valueOf(vpc.getClassRule().get(i - (i / 2)))).append("\', ");
        strb.append("NULL, ").append(getLevelColum(levelColum.get(i - (i / 2))));
        strb.append(", ").append(scopeColum.get(i - (i / 2)));
        strb.append(", \'\', b\'0\')");
        if (i < tests.size() - 2) {
            strb.append(",\n");
        } else if (i == tests.size() - 2) {
            strb.append(";\n\n");
        }
    }
    for (int i = 0; i < criteres.size(); i += 1) {
        strb.append(
                "UPDATE `TEST` SET `Id_Criterion` = (SELECT `Id_Criterion` FROM `CRITERION` WHERE `Cd_Criterion` LIKE \'");
        strb.append(criteres.get(i).split("=")[0]);
        strb.append("\') WHERE `Cd_Test` LIKE \'");
        strb.append(criteres.get(i).split("=")[0]).append("-%\';\n");
        if (i == criteres.size() - 1) {
            strb.append("\n");
        }
    }
    FileUtils.writeStringToFile(FileUtils.getFile(getSqlFile()), strb.toString(), true);
}

From source file:controllers.controller.java

private void deleteObjetoArchivo(HttpSession session, HttpServletRequest request, HttpServletResponse response,
        QUID quid, PrintWriter out) throws Exception {
    LinkedList<String> access4ThisPage = new LinkedList();
    access4ThisPage.add("deletefiless");
    LinkedList documento = quid.select_Archivo(WebUtil.decode(session, request.getParameter("idArchivo")));
    LinkedList<String> userAccess = (LinkedList<String>) session.getAttribute("userAccess");
    if (UserUtil.isAValidUser(access4ThisPage, userAccess)) {

        boolean deleteArchivo = quid.select_CountArchivo4Objeto(
                WebUtil.decode(session, request.getParameter("idArchivo")),
                WebUtil.decode(session, request.getParameter("idObjeto"))) == 0;

        Transporter tport = quid.deleteObjetoArchivo_Archivo(
                WebUtil.decode(session, request.getParameter("idObjetoArchivo")),
                WebUtil.decode(session, request.getParameter("idArchivo")), deleteArchivo);
        if (tport.getCode() == 0) {
            if (PageParameters.getParameter("deleteFileOnModifyBD").equals("1")) {
                borrarDocumentoDeDisco(documento.get(2).toString(), documento.get(8).toString());
            }//from  www . j a va2  s . c om
            System.out.println(
                    "Nombre de Objeto: " + WebUtil.decode(session, request.getParameter("nombreObjeto")));
            System.out.println("id de Objeto: " + WebUtil.decode(session, request.getParameter("idObjeto")));
            System.out.println("Ruta: " + PageParameters.getParameter("mainContext")
                    + PageParameters.getParameter("gui") + "/Insert_ObjetoArchivo.jsp?"
                    + WebUtil.encode(session, "imix") + "=" + WebUtil.encode(session, UTime.getTimeMilis())
                    + "&nombreObjeto=" + request.getParameter("nombreObjeto") + "&idObjeto="
                    + request.getParameter("idObjeto"));
            this.getServletConfig().getServletContext().getRequestDispatcher(""
                    + PageParameters.getParameter("msgUtil")
                    + "/msgNRedirectFull.jsp?title=Operacin Exitosa&type=info&msg=El registro se elimino correctamente.&url="
                    + PageParameters.getParameter("gui") + "/Insert_ObjetoArchivo.jsp?"
                    + WebUtil.encode(session, "imix") + "=" + WebUtil.encode(session, UTime.getTimeMilis())
                    + "_param_nombreObjeto=" + request.getParameter("nombreObjeto") + "_param_idObjeto="
                    + request.getParameter("idObjeto")).forward(request, response);
        } else {
            this.getServletConfig().getServletContext().getRequestDispatcher(""
                    + PageParameters.getParameter("msgUtil")
                    + "/msgNRedirectFull.jsp?title=Error&type=error&msg=El registro no se pudo borrar.&url="
                    + PageParameters.getParameter("mainContext") + PageParameters.getParameter("gui")
                    + "/Insert_ObjetoArchivo.jsp?" + WebUtil.encode(session, "imix") + "="
                    + WebUtil.encode(session, UTime.getTimeMilis()) + "_param_nombreObjeto="
                    + request.getParameter("nombreObjeto") + "_param_idObjeto="
                    + request.getParameter("idObjeto")).forward(request, response);
        }
    } else {
        this.getServletConfig().getServletContext().getRequestDispatcher(""
                + PageParameters.getParameter("msgUtil")
                + "/msgNRedirectFull.jsp?title=Error&type=error&msg=Usted NO cuenta con el permiso para realizar esta accin.&url="
                + PageParameters.getParameter("mainContext") + PageParameters.getParameter("gui")
                + "/Insert_ObjetoArchivo.jsp?" + WebUtil.encode(session, "imix") + "="
                + WebUtil.encode(session, UTime.getTimeMilis()) + "_param_nombreObjeto="
                + request.getParameter("nombreObjeto") + "_param_idObjeto=" + request.getParameter("idObjeto"))
                .forward(request, response);
    }
}