Example usage for java.util LinkedHashMap entrySet

List of usage examples for java.util LinkedHashMap entrySet

Introduction

In this page you can find the example usage for java.util LinkedHashMap entrySet.

Prototype

public Set<Map.Entry<K, V>> entrySet() 

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:com.ikanow.aleph2.analytics.services.DeduplicationService.java

@Override
public void onObjectBatch(final Stream<Tuple2<Long, IBatchRecord>> batch, final Optional<Integer> batch_size,
        final Optional<JsonNode> grouping_key) {
    if (_deduplication_is_disabled.get()) {
        // no deduplication, generally shouldn't be here...
        //.. but if we are, make do the best we can
        batch.forEach(t2 -> _context.get().emitImmutableObject(t2._1(), t2._2().getJson(), Optional.empty(),
                Optional.empty(), Optional.empty()));
        return;/* w w w  . ja  v a2 s.  co m*/
    }

    // Create big query

    final Tuple3<QueryComponent<JsonNode>, List<Tuple2<JsonNode, Tuple2<Long, IBatchRecord>>>, Either<String, List<String>>> fieldinfo_dedupquery_keyfields = getDedupQuery(
            batch, _dedup_fields.get(), _db_mapper.get());

    // Get duplicate results

    final Tuple2<List<String>, Boolean> fields_include = getIncludeFields(_policy.get(), _dedup_fields.get(),
            _timestamp_field.get());

    final CompletableFuture<Iterator<JsonNode>> dedup_res = fieldinfo_dedupquery_keyfields._2().isEmpty()
            ? CompletableFuture.completedFuture(Collections.<JsonNode>emptyList().iterator())
            : _dedup_context.get().getObjectsBySpec(fieldinfo_dedupquery_keyfields._1(), fields_include._1(),
                    fields_include._2()).thenApply(cursor -> cursor.iterator());

    // Wait for it to finsh

    //(create handy results structure if so)
    final LinkedHashMap<JsonNode, LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>>> mutable_obj_map = fieldinfo_dedupquery_keyfields
            ._2().stream()
            .collect(Collector.of(
                    () -> new LinkedHashMap<JsonNode, LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>>>(),
                    (acc, t2) -> {
                        // (ie only the first element is added, duplicate elements are removed)
                        final Tuple3<Long, IBatchRecord, ObjectNode> t3 = Tuples._3T(t2._2()._1(), t2._2()._2(),
                                _mapper.createObjectNode());
                        acc.compute(t2._1(), (k, v) -> {
                            final LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>> new_list = (null == v)
                                    ? new LinkedList<>()
                                    : v;
                            new_list.add(t3);
                            return new_list;
                        });
                    }, (map1, map2) -> {
                        map1.putAll(map2);
                        return map1;
                    }));

    //TODO (ALEPH-20): add timestamps to annotation
    //TODO (ALEPH-20): support different timestamp fields for the different buckets
    //TODO (ALEPH-20): really need to support >1 current enrichment job 
    //                 ^^(Really really longer term you should be able to decide what objects you want and what you don't  <- NOTE: don't remember what i meant here)

    final Iterator<JsonNode> cursor = dedup_res.join();

    // Handle the results

    final Stream<JsonNode> records_to_delete = Lambdas.get(() -> {
        if (isCustom(_doc_schema.get().deduplication_policy())
                || _doc_schema.get().delete_unhandled_duplicates()) {
            return Optionals.streamOf(cursor, true)
                    .collect(Collectors.groupingBy(
                            ret_obj -> getKeyFieldsAgain(ret_obj, fieldinfo_dedupquery_keyfields._3())))
                    .entrySet().stream().<JsonNode>flatMap(kv -> {

                        final Optional<JsonNode> maybe_key = kv.getKey();
                        final Optional<LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>>> matching_records = maybe_key
                                .map(key -> mutable_obj_map.get(key));

                        // Stats:
                        _mutable_stats.duplicate_keys++;
                        _mutable_stats.duplicates_existing += kv.getValue().size();
                        _mutable_stats.duplicates_incoming += matching_records.map(l -> l.size()).orElse(0);

                        //DEBUG
                        //System.out.println("?? " + kv.getValue().size() + " vs " + maybe_key + " vs " + matching_records.map(x -> Integer.toString(x.size())).orElse("(no match)"));

                        return matching_records
                                .<Stream<JsonNode>>map(records -> handleDuplicateRecord(_doc_schema.get(),
                                        _custom_handler.optional().map(
                                                handler -> Tuples._2T(handler, this._custom_context.get())),
                                        _timestamp_field.get(), records, kv.getValue(), maybe_key.get(),
                                        mutable_obj_map))
                                .orElse(Stream.empty());
                    });
        } else {
            Optionals.streamOf(cursor, true).forEach(ret_obj -> {
                final Optional<JsonNode> maybe_key = getKeyFieldsAgain(ret_obj,
                        fieldinfo_dedupquery_keyfields._3());
                final Optional<LinkedList<Tuple3<Long, IBatchRecord, ObjectNode>>> matching_records = maybe_key
                        .map(key -> mutable_obj_map.get(key));

                //DEBUG
                //System.out.println("?? " + ret_obj + " vs " + maybe_key + " vs " + matching_record.map(x -> x._2().getJson().toString()).orElse("(no match)"));

                // Stats:
                _mutable_stats.duplicate_keys++;
                _mutable_stats.duplicates_existing++;
                _mutable_stats.duplicates_incoming += matching_records.map(l -> l.size()).orElse(0);

                matching_records.ifPresent(records -> handleDuplicateRecord(_doc_schema.get(),
                        _custom_handler.optional()
                                .map(handler -> Tuples._2T(handler, this._custom_context.get())),
                        _timestamp_field.get(), records, Arrays.asList(ret_obj), maybe_key.get(),
                        mutable_obj_map));
            });
            return Stream.<JsonNode>empty();
        }
    });

    final List<Object> ids = records_to_delete.map(j -> jsonToObject(j)).filter(j -> null != j)
            .collect(Collectors.toList());

    if (!ids.isEmpty()) { // fire a bulk deletion request
        mutable_uncompleted_deletes.add(
                _dedup_context.get().deleteObjectsBySpec(CrudUtils.allOf().withAny(AnnotationBean._ID, ids)));

        _mutable_stats.deleted += ids.size();

        //(quickly see if we can reduce the number of outstanding requests)
        final Iterator<CompletableFuture<Long>> it = mutable_uncompleted_deletes.iterator();
        while (it.hasNext()) {
            final CompletableFuture<Long> cf = it.next();
            if (cf.isDone()) {
                it.remove();
            } else
                break; // ie stop as soon as we hit one that isn't complete)
        }
    }

    _mutable_stats.nonduplicate_keys += mutable_obj_map.size();

    if (Optional.ofNullable(_doc_schema.get().custom_finalize_all_objects()).orElse(false)) {
        mutable_obj_map.entrySet().stream()
                .forEach(kv -> handleCustomDeduplication(
                        _custom_handler.optional()
                                .map(handler -> Tuples._2T(handler, this._custom_context.get())),
                        kv.getValue(), Collections.emptyList(), kv.getKey()));
    } else { // Just emit the last element of each grouped object set
        mutable_obj_map.values().stream().map(t -> t.peekLast())
                .forEach(t -> _context.get().emitImmutableObject(t._1(), t._2().getJson(), Optional.of(t._3()),
                        Optional.empty(), Optional.empty()));
    }
}

From source file:ome.formats.OMEROMetadataStoreClient.java

public IObjectContainer getIObjectContainer(Class<? extends IObject> klass,
        LinkedHashMap<Index, Integer> indexes) {
    // Transform an integer collection into an integer array without using
    // wrapper objects.
    Collection<Integer> indexValues = indexes.values();
    int[] indexesArray = new int[indexValues.size()];
    int i = 0;/* w w  w .j a  v a 2s.co  m*/
    for (Integer index : indexValues) {
        indexesArray[i] = index;
        i++;
    }

    // Create a new LSID.
    LSID lsid = new LSID(klass, indexesArray);

    Map<String, Integer> asString = new HashMap<String, Integer>();
    for (Entry<Index, Integer> v : indexes.entrySet()) {
        asString.put(v.getKey().toString(), v.getValue());
    }

    if (!containerCache.containsKey(lsid)) {
        IObjectContainer c = new IObjectContainer();
        c.indexes = asString;
        c.LSID = lsid.toString();
        c.sourceObject = getSourceObjectInstance(klass);
        containerCache.put(lsid, c);
    }

    return containerCache.get(lsid);
}

From source file:com.nest5.businessClient.Initialactivity.java

@Override
public void OnPrintSelect(int Type) {
    LinkedHashMap<Registrable, Integer> imprimiendo = cookingOrders.get(currentSelectedPosition);
    Date date = new Date();
    String fecha = new SimpleDateFormat("dd/MM/yyyy - HH:mm:ss").format(date);
    String mesa = "DOMICILIO / PARA LLEVAR";
    CurrentTable<Table, Integer> mesaActual = cookingOrdersTable.get(imprimiendo);
    if (mesaActual != null) {
        mesa = mesaActual.getTable().getName().toUpperCase(Locale.getDefault());
    }//from w w w . j  a  v a 2  s  .c om

    StringBuilder factura = new StringBuilder();
    SharedPreferences prefs = Util.getSharedPreferences(mContext);
    String empresa = prefs.getString(Setup.COMPANY_NAME, "Nombre de Empresa");
    String nit = prefs.getString(Setup.COMPANY_NIT, "000000000-0");
    String email = prefs.getString(Setup.COMPANY_EMAIL, "email@empresa.com");
    String pagina = prefs.getString(Setup.COMPANY_URL, "http://www.empresa.com");
    String direccion = prefs.getString(Setup.COMPANY_ADDRESS, "Direccin Fsica Empresa");
    String telefono = prefs.getString(Setup.COMPANY_TEL, "555-55-55");
    String mensaje = prefs.getString(Setup.COMPANY_MESSAGE,
            "No hay ningn mensaje configurado an. En el mensaje es recomendable mencionar tus redes sociales, benficios y promociones que tengas, adems de informacin de inters paratus clientes. ");
    String propina = prefs.getString(Setup.TIP_MESSAGE,
            "No hay ningn mensaje de propina configurado an. ");
    String resolution = prefs.getString(Setup.RESOLUTION_MESSAGE,
            "Resolucin de facturacin No. 00000-0000 de 1970 DIAN");
    //int currentSale = prefs.getInt(Setup.CURRENT_SALE, 0);
    factura.append("COPIA DE ORDEN\r\n");
    factura.append("NO VLIDO COMO FACTURA\r\n");
    factura.append("--------------------\r\n");
    factura.append(empresa + "\r\n");
    factura.append(empresa + "\r\n");
    factura.append(nit + "\r\n");
    factura.append(direccion + "\r\n");
    factura.append(telefono + "\r\n");
    factura.append(email + "\r\n");
    factura.append(pagina + "\r\n");
    factura.append(resolution + "\r\n");
    factura.append("\r\n");
    factura.append(fecha);
    factura.append("\r\n");
    factura.append(mesa);
    factura.append("\r\n");
    factura.append("    Item       Cantidad   Precio\r\n");
    Iterator<Entry<Registrable, Integer>> it = imprimiendo.entrySet().iterator();
    //////Log.i("MISPRUEBAS","Valor de currentOrder"+String.valueOf(currentOrder.size()));
    // Log.d(TAG,String.valueOf(currentOrder.size()));
    LinkedHashMap<Registrable, Integer> currentObjects = new LinkedHashMap<Registrable, Integer>();
    float base = 0;
    float iva = 0;
    float total = 0;
    ArrayList<String> productos = new ArrayList<String>();
    ArrayList<String> quantities = new ArrayList<String>();
    ArrayList<String> precios = new ArrayList<String>();
    while (it.hasNext()) {

        LinkedHashMap.Entry<Registrable, Integer> pairs = (LinkedHashMap.Entry<Registrable, Integer>) it.next();

        currentObjects.put(pairs.getKey(), pairs.getValue());

        String name = pairs.getKey().name;

        int longName = name.length();
        int subLength = 14 - longName;
        if (subLength < 0)
            name = name.substring(0, 14);
        int espacios1 = 4;
        int espacios2 = 12;
        if (name.length() < 14) {
            espacios1 += 14 - name.length();
        }
        factura.append(name);
        productos.add(name);
        int qtyL = String.valueOf(pairs.getValue()).length();
        float precioiva = (float) Math.round(pairs.getKey().price + pairs.getKey().price * pairs.getKey().tax);
        base += (float) Math.round(pairs.getKey().price * pairs.getValue());
        iva += (float) Math.round((pairs.getKey().price * pairs.getKey().tax) * pairs.getValue());
        total += precioiva * pairs.getValue();

        int priceL = String.valueOf(precioiva).length();
        espacios1 = espacios1 - qtyL < 1 ? espacios1 = 1 : espacios1 - qtyL;
        espacios2 = espacios2 - priceL < 1 ? espacios2 = 1 : espacios2 - priceL;
        espacios2 = espacios2 - qtyL < 1 ? espacios2 = 1 : espacios2 - qtyL;
        for (int k = 0; k < espacios1; k++) {
            factura.append(" ");
        }
        factura.append(pairs.getValue());
        quantities.add(String.valueOf(pairs.getValue()));
        for (int k = 0; k < espacios2; k++) {
            factura.append(" ");
        }
        factura.append("$");
        factura.append(precioiva);
        factura.append("\r\n");
        precios.add("$" + precioiva);
    }
    factura.append("\r\n");
    factura.append("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>\r\n");
    factura.append("BASE:      $" + base + "\r\n");
    factura.append("Imp.:      $" + iva + "\r\n");
    factura.append("SUBTOTAL:     $" + total + "\r\n");
    factura.append("\r\n");
    factura.append("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>\r\n");
    factura.append("\r\n");
    factura.append(propina + "\r\n");
    factura.append(mensaje);

    Boolean printed = true;
    try {
        if (mChatService.getState() == mChatService.STATE_CONNECTED) {
            try {
                mChatService.write(factura.toString().getBytes("x-UnicodeBig"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        } else {
            printed = false;
            Toast.makeText(mContext, "No hay impresora bluetooth conectada.", Toast.LENGTH_LONG).show();
        }
    } catch (NullPointerException e) {
        printed = false;
        e.printStackTrace();
    }
    if (!printed) {//buscar impresora TCP/IP
        StringBuilder formateado = new StringBuilder();
        formateado.append(CLEAR_PRINTER);
        formateado.append(INITIALIZE_PRINTER);
        formateado.append(JUSTIFICATION_CENTER);
        formateado.append(DOUBLE_WIDE_CHARACTERS);
        formateado.append("CUENTA PEDIDO No." + String.valueOf(currentSelectedPosition + 1));
        formateado.append(PRINT_FEED_ONE_LINE);
        formateado.append(fecha);
        formateado.append(PRINT_FEED_N_LINES);
        formateado.append((char) 0x02);
        formateado.append(mesa);
        formateado.append(PRINT_FEED_N_LINES);
        formateado.append((char) 0x02);
        formateado.append(SINGLE_WIDE_CHARACTERS);
        formateado.append("NO VLIDO COMO FACTURA DE VENTA");
        formateado.append(PRINT_FEED_ONE_LINE);
        formateado.append(PRINT_FEED_N_LINES);
        formateado.append((char) 0x03);
        formateado.append(DOUBLE_WIDE_CHARACTERS);
        formateado.append(JUSTIFICATION_LEFT);
        formateado.append("ITEM");
        formateado.append(HORIZONTAL_TAB);
        formateado.append("CANT.");
        formateado.append(HORIZONTAL_TAB);
        formateado.append("PRECIO");
        formateado.append(SINGLE_WIDE_CHARACTERS);
        formateado.append(PRINT_FEED_ONE_LINE);
        for (String actual : productos) {
            int pos = productos.indexOf(actual);
            String cantidad = quantities.get(pos);
            String precio = precios.get(pos);
            formateado.append(actual);
            formateado.append(HORIZONTAL_TAB);
            formateado.append(HORIZONTAL_TAB);
            formateado.append("x" + cantidad);
            formateado.append(HORIZONTAL_TAB);
            formateado.append(HORIZONTAL_TAB);
            formateado.append(precio);
            formateado.append(PRINT_FEED_ONE_LINE);
        }
        formateado.append(DOUBLE_WIDE_CHARACTERS);
        formateado.append("______________________");
        formateado.append(SINGLE_WIDE_CHARACTERS);
        formateado.append(PRINT_FEED_N_LINES);
        formateado.append((char) 0x02);
        formateado.append("BASE:");
        formateado.append(HORIZONTAL_TAB);
        formateado.append(HORIZONTAL_TAB);
        formateado.append(HORIZONTAL_TAB);
        formateado.append(HORIZONTAL_TAB);
        formateado.append("$" + base);
        formateado.append(PRINT_FEED_ONE_LINE);
        formateado.append("Impuesto:");
        formateado.append(HORIZONTAL_TAB);
        formateado.append(HORIZONTAL_TAB);
        formateado.append(HORIZONTAL_TAB);
        formateado.append("$" + iva);
        formateado.append(PRINT_FEED_ONE_LINE);
        formateado.append("TOTAL:");
        formateado.append(HORIZONTAL_TAB);
        formateado.append(HORIZONTAL_TAB);
        formateado.append(HORIZONTAL_TAB);
        formateado.append("$" + total);
        formateado.append(PRINT_FEED_ONE_LINE);
        formateado.append(DOUBLE_WIDE_CHARACTERS);
        formateado.append("______________________");
        formateado.append(SINGLE_WIDE_CHARACTERS);
        formateado.append(PRINT_FEED_N_LINES);
        formateado.append((char) 0x02);
        formateado.append(ITALIC_STYLE);
        formateado.append(propina);
        formateado.append(PRINT_FEED_ONE_LINE);
        formateado.append("DESEA INCLUIRLA?");
        formateado.append(PRINT_FEED_ONE_LINE);
        formateado.append("SI: |____|");
        formateado.append(HORIZONTAL_TAB);
        formateado.append("NO:|____|");
        formateado.append(PRINT_FEED_N_LINES);
        formateado.append((char) 0x02);
        formateado.append(mensaje);
        formateado.append(ITALIC_CANCEL);
        formateado.append(FINALIZE_TICKET);
        formateado.append(FULL_CUT);
        if (mTCPPrint != null) {
            if (mTCPPrint.getStatus() == TCPPrint.CONNECTED) {
                mTCPPrint.sendMessage(formateado.toString());
                mTCPPrint.sendMessage(formateado.toString());
            } else {
                mTCPPrint.stopClient();
                new connectTask().execute(formateado.toString());
                alertbox("Oops!",
                        "Al Parecer no hay impresora disponible. Estamos tratando de reconectarnos e imprimir. Si no funciona, reinicia la Red o la impresora y ve a rdenes para imprimir el pedido.");
            }
        } else {
            alertbox("Oops!",
                    "Al Parecer no hay impresora disponible. Trataremos en este momento de nuevo de imprimir el pedido. Si no funciona, reinicia la red o la impreso y ve a rdenes para imprimir de nuevo la orden.");
            new connectTask().execute(formateado.toString());
        }
    }
    //currentOrder.clear(); //NUEVOO
    //makeTable("NA");
    List<Long> items = new ArrayList<Long>();
    List<String> nameTables = new ArrayList<String>();
    for (LinkedHashMap<Registrable, Integer> current : cookingOrders) {
        items.add(cookingOrdersTimes.get(current));
        nameTables.add(cookingOrdersTable.get(current).getTable().getName());
    }
    cookingAdapter = new SaleAdapter(mContext, items, nameTables, inflater);
    ordersList.setAdapter(cookingAdapter);
    ordersList.setOnItemClickListener(orderListListener);
    currentSelectedPosition = -1;

}

From source file:com.primovision.lutransport.service.ImportMainSheetServiceImpl.java

@Override
public List<LinkedList<Object>> importVendorSpecificFuelLog(InputStream is,
        LinkedHashMap<String, String> vendorSpecificColumns, Long vendor,
        HashMap<String, Object> additionalVendorData) throws Exception {
    List<LinkedList<Object>> data = new ArrayList<LinkedList<Object>>();
    try {/*from ww w.j a  v a2s. co  m*/
        POIFSFileSystem fs = new POIFSFileSystem(is);

        HSSFWorkbook wb = new HSSFWorkbook(fs);
        Sheet sheet = wb.getSheetAt(0);
        Row titleRow = sheet.getRow(sheet.getFirstRowNum());

        LinkedHashMap<String, Integer> orderedColIndexes = getOrderedColumnIndexes(titleRow,
                vendorSpecificColumns);
        Set<Entry<String, Integer>> keySet = orderedColIndexes.entrySet();

        System.out.println("Physical number of rows in Excel = " + sheet.getPhysicalNumberOfRows());
        System.out.println("While reading values from vendor specific Excel Sheet: ");

        Map criterias = new HashMap();
        criterias.put("id", vendor);
        FuelVendor fuelVendor = genericDAO.findByCriteria(FuelVendor.class, criterias, "name", false).get(0);

        boolean stopParsing = false;
        for (int i = titleRow.getRowNum() + 1; !stopParsing && i <= sheet.getPhysicalNumberOfRows() - 1; i++) {
            LinkedList<Object> rowObjects = new LinkedList<Object>();

            rowObjects.add(fuelVendor.getName());
            rowObjects.add(fuelVendor.getCompany().getName());

            Row row = sheet.getRow(i);

            Iterator<Entry<String, Integer>> iterator = keySet.iterator();
            while (iterator.hasNext()) {
                Entry<String, Integer> entry = iterator.next();

                // corresponding column not found in actual column list, find in additionalVendorData
                if (entry.getValue() == -1) {
                    System.out.println("Additional vendor data = " + additionalVendorData);
                    System.out.println("Column " + entry.getKey()
                            + " not found in Vendor Excel, checking in additionalVendorData");
                    Object cellValueObj = additionalVendorData.get(entry.getKey());
                    if (cellValueObj != null) {
                        rowObjects.add(cellValueObj);
                    } else {
                        rowObjects.add(StringUtils.EMPTY);
                    }
                    continue;
                }

                Object cellValueObj = getCellValue((HSSFCell) row.getCell(entry.getValue()), true);
                if (cellValueObj != null && cellValueObj.toString().equalsIgnoreCase("END_OF_DATA")) {
                    System.out.println("Received END_OF_DATA");
                    stopParsing = true;
                    rowObjects.clear();
                    break;
                }
                rowObjects.add(cellValueObj);
            }

            if (!stopParsing) {
                data.add(rowObjects);
            }
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }
    return data;
}

From source file:com.primovision.lutransport.service.ImportMainSheetServiceImpl.java

@Override
public List<LinkedList<Object>> importTollCompanySpecificTollTag(InputStream is,
        LinkedHashMap<String, String> tollCompanySpecificColumns, Long tollCompanyId) throws Exception {
    List<LinkedList<Object>> data = new ArrayList<LinkedList<Object>>();
    try {/*from   ww  w .  ja v  a 2 s. c  o  m*/
        POIFSFileSystem fs = new POIFSFileSystem(is);

        HSSFWorkbook wb = new HSSFWorkbook(fs);
        Sheet sheet = wb.getSheetAt(0);
        Row titleRow = sheet.getRow(sheet.getFirstRowNum());

        LinkedHashMap<String, Integer> orderedColIndexes = getOrderedColumnIndexes(titleRow,
                tollCompanySpecificColumns);
        Set<Entry<String, Integer>> keySet = orderedColIndexes.entrySet();

        System.out.println("Physical number of rows in Excel = " + sheet.getPhysicalNumberOfRows());
        System.out.println("While reading values from vendor specific Excel Sheet: ");

        Map criterias = new HashMap();
        criterias.put("id", tollCompanyId);
        TollCompany tollCompany = genericDAO.findByCriteria(TollCompany.class, criterias, "name", false).get(0);

        //boolean stopParsing = false;
        for (int i = titleRow.getRowNum() + 1; i <= sheet.getPhysicalNumberOfRows() - 1; i++) {
            Row row = sheet.getRow(i);

            Object firstCellValueObj = getCellValue((HSSFCell) row.getCell(0), true);
            if (firstCellValueObj != null && firstCellValueObj.toString().equalsIgnoreCase("END_OF_DATA")) {
                System.out.println("Received END_OF_DATA");
                break;
            }

            LinkedList<Object> rowObjects = new LinkedList<Object>();

            rowObjects.add(tollCompany.getName());

            /*// TODO: For now, need to get logic 
            String company = StringUtils.substringAfterLast(tollCompany.getName(), " ");
            company = StringUtils.defaultIfEmpty(company, "LU");
            rowObjects.add(company);*/

            rowObjects.add(tollCompany.getCompany().getName());

            Iterator<Entry<String, Integer>> iterator = keySet.iterator();
            while (iterator.hasNext()) {
                Entry<String, Integer> entry = iterator.next();

                if (entry.getValue() == -1) {
                    // corresponding column not found
                    rowObjects.add(StringUtils.EMPTY);
                    continue;
                }

                Object cellValueObj = getCellValue((HSSFCell) row.getCell(entry.getValue()), true);
                if (cellValueObj != null) {
                    System.out.println("Adding " + cellValueObj.toString());
                } else {
                    System.out.println("Adding NULL");
                }
                rowObjects.add(cellValueObj);
            }

            data.add(rowObjects);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return data;
}

From source file:com.primovision.lutransport.service.ImportMainSheetServiceImpl.java

private LinkedHashMap<String, Integer> getOrderedColumnIndexes(Row titleRow,
        LinkedHashMap<String, String> vendorSpecificColumns) {
    LinkedHashMap<String, Integer> orderedColumnIndexesMap = new LinkedHashMap<String, Integer>();

    int startCellNumber = titleRow.getFirstCellNum();

    Set<Entry<String, String>> keySet = vendorSpecificColumns.entrySet();
    Iterator<Entry<String, String>> iterator = keySet.iterator();
    while (iterator.hasNext()) {
        Entry<String, String> entry = iterator.next();

        if (StringUtils.isEmpty(entry.getValue())) {
            orderedColumnIndexesMap.put(entry.getKey(), -1);
        }//w  w w .  ja  v a  2s  .co  m

        boolean foundExpectedColumn = false;
        for (int i = startCellNumber; i < titleRow.getLastCellNum(); i++) {
            String columnHeader = (String) getCellValue(((HSSFCell) titleRow.getCell(i)));
            if (StringUtils.isEmpty(columnHeader.trim()) && StringUtils.isEmpty(entry.getValue().trim())) {
                continue;
            }

            if (columnHeader.trim().equalsIgnoreCase(entry.getValue().trim())) {
                // match found
                foundExpectedColumn = true;
                // orderedColumnIndexes.add(i);
                orderedColumnIndexesMap.put(entry.getKey(), i);

                System.out.println("Column Index Mapping for " + entry.getKey() + " = " + columnHeader
                        + " @ index = " + i);
                break;
            }
        }
        if (!foundExpectedColumn) {
            // throw error??
            System.out.println("Could not find expected column " + entry.getValue());
            orderedColumnIndexesMap.put(entry.getKey(), -1);
        }
    }

    System.out.println("Ordered Column Indexes Map = " + orderedColumnIndexesMap);
    return orderedColumnIndexesMap;
}

From source file:de.ingrid.importer.udk.strategy.v32.IDCStrategy3_2_0.java

protected void updateSysListBeforeFile() throws Exception {
    log.info("\nUpdating sys_list before file is read...");

    // ---------------------------
    int lstId = 6005;
    log.info("Inserting new syslist " + lstId + " = \"Spezifikation der Konformitt\"...");

    // NOTICE: SYSLIST contains date at end of syslist value (yyyy-MM-dd), has to be cut off in IGE ! But used for mapping in DSC-Scripted !
    // german syslist
    LinkedHashMap<Integer, String> newSyslistMap_de = new LinkedHashMap<Integer, String>();
    newSyslistMap_de.put(1, "INSPIRE Data Specification on Addresses  Guidelines, 2010-05-03");
    newSyslistMap_de.put(2, "INSPIRE Data Specification on Administrative units --Guidelines, 2010-05-03");
    newSyslistMap_de.put(3, "INSPIRE Data Specification on Cadastral parcels --Guidelines, 2010-05-03");
    newSyslistMap_de.put(4, "INSPIRE Data Specification on Geographical names  Guidelines, 2010-05-03");
    newSyslistMap_de.put(5, "INSPIRE Data Specification on Hydrography  Guidelines, 2010-05-03");
    newSyslistMap_de.put(6, "INSPIRE Data Specification on Protected Sites  Guidelines, 2010-05-03");
    newSyslistMap_de.put(7, "INSPIRE Data Specification on Transport Networks  Guidelines, 2010-05-03");
    newSyslistMap_de.put(8, "INSPIRE Specification on Coordinate Reference Systems  Guidelines, 2010-05-03");
    newSyslistMap_de.put(9, "INSPIRE Specification on Geographical Grid Systems  Guidelines, 2010-05-03");
    newSyslistMap_de.put(10, "INSPIRE Durchfhrungsbestimmung Netzdienste, 2009-10-19");
    newSyslistMap_de.put(11, "INSPIRE Durchfhrungsbestimmung Metadaten, 2008-12-03");
    newSyslistMap_de.put(12,/*w w w  .  j  ava 2  s .  c o  m*/
            "INSPIRE Durchfhrungsbestimmung Interoperabilitt von Geodatenstzen und --diensten, 2010-11-21");
    newSyslistMap_de.put(13, "INSPIRE Richtlinie, 2007-03-14");
    // english syslist
    LinkedHashMap<Integer, String> newSyslistMap_en = new LinkedHashMap<Integer, String>();
    newSyslistMap_en.put(1, "INSPIRE Data Specification on Addresses  Guidelines, 2010-05-03");
    newSyslistMap_en.put(2, "INSPIRE Data Specification on Administrative units --Guidelines, 2010-05-03");
    newSyslistMap_en.put(3, "INSPIRE Data Specification on Cadastral parcels --Guidelines, 2010-05-03");
    newSyslistMap_en.put(4, "INSPIRE Data Specification on Geographical names  Guidelines, 2010-05-03");
    newSyslistMap_en.put(5, "INSPIRE Data Specification on Hydrography  Guidelines, 2010-05-03");
    newSyslistMap_en.put(6, "INSPIRE Data Specification on Protected Sites  Guidelines, 2010-05-03");
    newSyslistMap_en.put(7, "INSPIRE Data Specification on Transport Networks  Guidelines, 2010-05-03");
    newSyslistMap_en.put(8, "INSPIRE Specification on Coordinate Reference Systems  Guidelines, 2010-05-03");
    newSyslistMap_en.put(9, "INSPIRE Specification on Geographical Grid Systems  Guidelines, 2010-05-03");
    newSyslistMap_en.put(10, "INSPIRE Durchfhrungsbestimmung Netzdienste, 2009-10-19");
    newSyslistMap_en.put(11, "INSPIRE Durchfhrungsbestimmung Metadaten, 2008-12-03");
    newSyslistMap_en.put(12,
            "INSPIRE Durchfhrungsbestimmung Interoperabilitt von Geodatenstzen und --diensten, 2010-11-21");
    newSyslistMap_en.put(13, "INSPIRE Richtlinie, 2007-03-14");

    writeNewSyslist(lstId, true, newSyslistMap_de, newSyslistMap_en, 13, 13, null, null);
    // ---------------------------
    lstId = 6020;
    log.info("Inserting new syslist " + lstId + " = \"Nutzungsbedingungen\"...");

    // german syslist
    newSyslistMap_de = new LinkedHashMap<Integer, String>();
    newSyslistMap_de.put(1, "Keine");
    // english syslist
    newSyslistMap_en = new LinkedHashMap<Integer, String>();
    newSyslistMap_en.put(1, "No conditions apply");

    writeNewSyslist(lstId, true, newSyslistMap_de, newSyslistMap_en, -1, -1, null, null);
    // ---------------------------
    lstId = 505;
    log.info("Update syslist " + lstId + " = \"Address Rollenbezeichner\"...");

    // german syslist
    syslist505EntryKeyDatenverantwortung = 2;
    syslist505EntryKeyAuskunft = 7;
    newSyslistMap_de = new LinkedHashMap<Integer, String>();
    newSyslistMap_de.put(1, "Ressourcenanbieter");
    newSyslistMap_de.put(syslist505EntryKeyDatenverantwortung, "Verwalter");
    newSyslistMap_de.put(3, "Eigentmer");
    newSyslistMap_de.put(4, "Nutzer");
    newSyslistMap_de.put(5, "Vertrieb");
    newSyslistMap_de.put(6, "Urheber");
    newSyslistMap_de.put(syslist505EntryKeyAuskunft, "Ansprechpartner");
    newSyslistMap_de.put(8, "Projektleitung");
    newSyslistMap_de.put(9, "Bearbeiter");
    newSyslistMap_de.put(10, "Herausgeber");
    newSyslistMap_de.put(11, "Autor");

    // english syslist
    newSyslistMap_en = new LinkedHashMap<Integer, String>();
    newSyslistMap_en.put(1, "Resource Provider");
    newSyslistMap_en.put(syslist505EntryKeyDatenverantwortung, "Custodian");
    newSyslistMap_en.put(3, "Owner");
    newSyslistMap_en.put(4, "User");
    newSyslistMap_en.put(5, "Distributor");
    newSyslistMap_en.put(6, "Originator");
    newSyslistMap_en.put(syslist505EntryKeyAuskunft, "Point of Contact");
    newSyslistMap_en.put(8, "Principal Investigator");
    newSyslistMap_en.put(9, "Processor");
    newSyslistMap_en.put(10, "Publisher");
    newSyslistMap_en.put(11, "Author");

    // DESCRIPTION DE syslist (just for completeness)
    LinkedHashMap<Integer, String> newSyslistMap_description_de = new LinkedHashMap<Integer, String>();
    newSyslistMap_description_de.put(1, "Anbieter der Ressource");
    newSyslistMap_description_de.put(syslist505EntryKeyDatenverantwortung,
            "Person/Stelle, welche die Zustndigkeit und Verantwortlichkeit fr einen Datensatz "
                    + "bernommen hat und seine sachgerechte Pflege und Wartung sichert");
    newSyslistMap_description_de.put(3, "Eigentmer der Ressource");
    newSyslistMap_description_de.put(4, "Nutzer der Ressource");
    newSyslistMap_description_de.put(5, "Person oder Stelle fr den Vertrieb");
    newSyslistMap_description_de.put(6, "Erzeuger der Ressource");
    newSyslistMap_description_de.put(syslist505EntryKeyAuskunft,
            "Kontakt fr Informationen zur Ressource oder deren Bezugsmglichkeiten");
    newSyslistMap_description_de.put(8,
            "Person oder Stelle, die verantwortlich fr die Erhebung der Daten und die Untersuchung ist");
    newSyslistMap_description_de.put(9, "Person oder Stelle, welche die Ressource modifiziert");
    newSyslistMap_description_de.put(10, "Person oder Stelle, welche die Ressource verffentlicht");
    newSyslistMap_description_de.put(11, "Verfasser der Ressource");

    // DESCRIPTION EN syslist (just for completeness)
    LinkedHashMap<Integer, String> newSyslistMap_description_en = new LinkedHashMap<Integer, String>();
    newSyslistMap_description_en.put(1, "Party that supplies the resource");
    newSyslistMap_description_en.put(syslist505EntryKeyDatenverantwortung,
            "Party that accepts accountability and responsibility for the data and ensures "
                    + "appropriate care and maintenance of the resource");
    newSyslistMap_description_en.put(3, "Party that owns the resource");
    newSyslistMap_description_en.put(4, "Party who uses the resource");
    newSyslistMap_description_en.put(5, "Party who distributes the resource");
    newSyslistMap_description_en.put(6, "Party who created the resource");
    newSyslistMap_description_en.put(syslist505EntryKeyAuskunft,
            "Party who can be contacted for acquiring knowledge about or acquisition of the resource");
    newSyslistMap_description_en.put(8,
            "Key party responsible for gathering information and conducting research");
    newSyslistMap_description_en.put(9,
            "Party who has processed the data in a manner such that the resource has been modified");
    newSyslistMap_description_en.put(10, "Party who published the resource");
    newSyslistMap_description_en.put(11, "Party who authored the resource");

    writeNewSyslist(lstId, true, newSyslistMap_de, newSyslistMap_en, -1, -1, newSyslistMap_description_de,
            newSyslistMap_description_en);

    // also fix data in objects (values dependent from catalog language) !

    Iterator<Entry<Integer, String>> entryIt;
    if ("de".equals(UtilsLanguageCodelist.getShortcutFromCode(readCatalogLanguageKey()))) {
        entryIt = newSyslistMap_de.entrySet().iterator();
    } else {
        entryIt = newSyslistMap_en.entrySet().iterator();
    }

    String psSql = "UPDATE t012_obj_adr SET special_name = ? " + "WHERE special_ref = 505 AND type = ?";
    PreparedStatement psUpdate = jdbc.prepareStatement(psSql);

    while (entryIt.hasNext()) {
        Entry<Integer, String> entry = entryIt.next();

        if (entry.getKey().equals(syslist505EntryKeyDatenverantwortung)) {
            syslist505EntryValueVerwalter = entry.getValue();
        }

        psUpdate.setString(1, entry.getValue());
        psUpdate.setInt(2, entry.getKey());
        int numUpdated = psUpdate.executeUpdate();

        log.debug("t012_obj_adr: updated " + numUpdated + " rows -> type(" + entry.getKey() + "), "
                + "new value(" + entry.getValue() + ")");
    }
    psUpdate.close();

    // ---------------------------
    lstId = 2000;
    log.info("Insert new entries \"3109/Objektartenkatalog\", \"9990/Datendownload\", "
            + "\"9999/unspezifischer Verweis\" to syslist" + lstId + " (link type) ...");

    // german syslist
    newSyslistMap_de = new LinkedHashMap<Integer, String>();
    newSyslistMap_de.put(3109, "Objektartenkatalog");
    newSyslistMap_de.put(9990, "Datendownload");
    newSyslistMap_de.put(9999, "unspezifischer Verweis");
    // english syslist
    newSyslistMap_en = new LinkedHashMap<Integer, String>();
    newSyslistMap_en.put(3109, "Key Catalog");
    newSyslistMap_en.put(9990, "Download of data");
    newSyslistMap_en.put(9999, "unspecific Link");

    writeNewSyslist(lstId, false, newSyslistMap_de, newSyslistMap_en, -1, -1, null, null);

    log.info("Updating sys_list... done\n");

    // ---------------------------
    lstId = SYSLIST_ID_OPERATION_PLATFORM;
    log.info("Inserting new syslist " + lstId + " = \"Operation - Untersttzte Platformen\"...");

    // german syslist
    newSyslistMap_de = new LinkedHashMap<Integer, String>();
    newSyslistMap_de.put(1, "XML");
    newSyslistMap_de.put(2, "CORBA");
    newSyslistMap_de.put(3, "JAVA");
    newSyslistMap_de.put(4, "COM");
    newSyslistMap_de.put(5, "SQL");
    newSyslistMap_de.put(6, "WebServices");
    newSyslistMap_de.put(7, "HTTPGet");
    newSyslistMap_de.put(8, "HTTPPost");
    newSyslistMap_de.put(9, "SOAP");
    // english syslist
    newSyslistMap_en = new LinkedHashMap<Integer, String>();
    newSyslistMap_en.put(1, "XML");
    newSyslistMap_en.put(2, "CORBA");
    newSyslistMap_en.put(3, "JAVA");
    newSyslistMap_en.put(4, "COM");
    newSyslistMap_en.put(5, "SQL");
    newSyslistMap_en.put(6, "WebServices");
    newSyslistMap_en.put(7, "HTTPGet");
    newSyslistMap_en.put(8, "HTTPPost");
    newSyslistMap_en.put(9, "SOAP");

    writeNewSyslist(lstId, true, newSyslistMap_de, newSyslistMap_en, -1, -1, null, null);

    // ---------------------------
    log.info("Updating sys_list before file is read... done\n");
}

From source file:sos.settings.SOSSettingsDialog.java

/**
 * Dokumentation anzeigen// ww  w  .j  a va  2 s. co m
 * 
 * @throws Exception
 */

private void showDocumentation() throws Exception {
    this.debug(3, "showDocumentation");

    StringBuffer sqlStmt = new StringBuffer(
            "select \"TITLE\",\"APPLICATION\",\"SECTION\",\"NAME\",\"VALUE\",\"DISPLAY_TYPE\",\"INPUT_TYPE\" from "
                    + this.settings.source);

    String sqlAnd = " where ";

    String[] display_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_display_type_entries")
            .split(";");
    String[] input_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_input_type_entries")
            .split(";");

    if (this.settings.section.equals(this.settings.entrySchemaSection)) {
        this.settings.section = this.settings.entrySchemaSection;
    }

    if (!this.settings.application.equals("")) {
        sqlStmt.append(sqlAnd + " \"" + this.settings.entryApplication + "\" = "
                + this.dbQuoted(this.settings.application));
        sqlAnd = " and ";
    }
    if (!this.settings.section.equals("")) {
        sqlStmt.append(
                sqlAnd + " \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section));
        sqlAnd = " and ";
    }

    sqlStmt.append(" order by \"" + this.settings.entryApplication + "\",\"" + this.settings.entrySection
            + "\",\"" + this.settings.entryName + "\"");

    try {
        Vector results = this.connection.getArrayAsVector(sqlStmt.toString());

        LinkedHashMap applications = new LinkedHashMap();
        LinkedHashMap sections = new LinkedHashMap();
        LinkedHashMap entries = new LinkedHashMap();

        for (Enumeration el = results.elements(); el.hasMoreElements();) {
            HashMap result = (HashMap) el.nextElement();
            if (result.get("application").toString().equals(result.get("section").toString())
                    && result.get("application").toString().equals(result.get("name").toString())) {

                applications.put(result.get("application").toString(), result);

            } else if (result.get("section").toString().equals(result.get("name").toString())
                    && !result.get("section").toString().equals(result.get("application").toString())) {

                String key = result.get("application").toString();
                LinkedHashMap section = new LinkedHashMap();

                if (sections.containsKey(key)) {
                    section = (LinkedHashMap) sections.get(key);
                }
                section.put(result.get("section").toString(), result);
                sections.put(key, section);

            } else {
                String appKey = result.get("application").toString();
                String secKey = result.get("section").toString();

                LinkedHashMap section = new LinkedHashMap();
                LinkedHashMap entry = new LinkedHashMap();

                if (entries.containsKey(appKey)) {
                    section = (LinkedHashMap) entries.get(appKey);
                    if (section.containsKey(secKey)) {
                        entry = (LinkedHashMap) section.get(secKey);
                    }
                }
                entry.put(result.get("name").toString(), result);
                section.put(secKey, entry);
                entries.put(appKey, section);

            }

        }
        //out.print(entries);

        results = null;
        this.styleBorder = "1\" bgcolor=\"#ffffff\" bordercolorlight=\"#D2D2D2\" bordercolordark=\"#ffffff";

        this.showTableBegin();
        if (applications.size() != 0) {
            Iterator appIt = applications.entrySet().iterator();
            while (appIt.hasNext()) {
                Map.Entry application = (Map.Entry) appIt.next();
                String app_key = application.getKey().toString();
                HashMap app_value = (HashMap) application.getValue();
                this.out.println("<tr>");
                this.out.println("   <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">"
                        + app_value.get("title") + "</td>");
                this.out.println("   <td nowrap>" + app_value.get("name") + "</td>");
                this.out.println("   <td nowrap>&nbsp;</td>");
                this.out.println("</tr>");
                if (sections.containsKey(app_key)) {
                    HashMap appSections = (HashMap) sections.get(app_key);
                    Iterator secIt = appSections.entrySet().iterator();
                    while (secIt.hasNext()) {
                        Map.Entry section = (Map.Entry) secIt.next();
                        String sec_key = section.getKey().toString();
                        HashMap sec_value = (HashMap) section.getValue();
                        if (!sec_value.get("name").toString().equals(this.settings.entrySchemaSection)) {
                            this.out.println("<tr>");
                            this.out.println("   <td nowrap>&nbsp;</td>");
                            this.out.println(
                                    "   <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                            + sec_value.get("title") + "</td>");
                            this.out.println("   <td nowrap>" + sec_value.get("name") + "</td>");
                            this.out.println("   <td nowrap>&nbsp;</td>");
                            this.out.println("</tr>");
                            if (entries.containsKey(app_key)) {
                                HashMap secEntrie = (HashMap) entries.get(app_key);
                                if (secEntrie.containsKey(sec_key)) {
                                    HashMap secEntries = (HashMap) secEntrie.get(sec_key);

                                    Iterator entIt = secEntries.entrySet().iterator();
                                    while (entIt.hasNext()) {
                                        Map.Entry entry = (Map.Entry) entIt.next();
                                        String ent_key = entry.getKey().toString();
                                        HashMap ent_value = (HashMap) entry.getValue();

                                        this.out.println("<tr>");
                                        this.out.println("   <td width=\"20\" nowrap>&nbsp;</td>");
                                        this.out.println("   <td width=\"20\" nowrap>&nbsp;</td>");
                                        this.out.println("   <td width=\"35%\" nowrap valign=\"top\">"
                                                + ent_value.get("title") + "</td>");
                                        this.out.println("   <td width=\"10%\" nowrap valign=\"top\">"
                                                + ent_value.get("name") + "</td>");
                                        this.out.println("   <td nowrap valign=\"top\">");
                                        if (ent_value.get("input_type").toString().equals("5")) { // long_value
                                            this.out.println("[ "
                                                    + this.rb.getMessage(
                                                            "sos.settings.dialog.dialog_long_value_title")
                                                    + " ]");
                                            if (ent_value.get("display_type").toString().equals("4")) {
                                                this.out.println("&nbsp;" + display_type_entries[4]);
                                            }
                                        } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt
                                            this.out.println("[ " + input_type_entries[6] + " ]");
                                        } else {
                                            if (ent_value.get("display_type").toString().endsWith("3")) {
                                                this.out.println("<pre>" + this.htmlSpecialChars(
                                                        ent_value.get("value").toString()) + "</pre>");
                                            } else {
                                                this.out.println(
                                                        this.htmlSpecialChars(ent_value.get("value").toString())
                                                                + "&nbsp;");
                                            }
                                        }
                                        this.out.println("   </td>");
                                        this.out.println("</tr>");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } // if applications
        else if (sections.size() != 0) {
            try {
                HashMap application = this.connection.getSingle("select \"TITLE\",\"NAME\" from "
                        + this.settings.source + " where \"" + this.settings.entryApplication + "\" = "
                        + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection
                        + "\" = " + this.dbQuoted(this.settings.application) + " and \""
                        + this.settings.entryName + "\" = " + this.dbQuoted(this.settings.application));

                Iterator secIt = sections.entrySet().iterator();
                if (sections.containsKey(this.settings.application)) {
                    HashMap appSections = (HashMap) sections.get(this.settings.application);
                    Iterator secI = appSections.entrySet().iterator();
                    while (secI.hasNext()) {
                        Map.Entry section = (Map.Entry) secI.next();
                        String sec_key = section.getKey().toString();
                        HashMap sec_value = (HashMap) section.getValue();
                        this.out.println("<tr>");
                        this.out.println(
                                "   <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                        + application.get("title") + "</td>");
                        this.out.println("   <td nowrap>" + application.get("name") + "</td>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println("</tr>");
                        this.out.println("<tr>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println(
                                "   <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                        + sec_value.get("title") + "</td>");
                        this.out.println("   <td nowrap>" + sec_value.get("name") + "</td>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println("</tr>");
                        if (entries.containsKey(this.settings.application)) {
                            HashMap secEntrie = (HashMap) entries.get(this.settings.application);
                            if (secEntrie.containsKey(sec_key)) {
                                HashMap secEntries = (HashMap) secEntrie.get(sec_key);
                                Iterator entI = secEntries.entrySet().iterator();
                                while (entI.hasNext()) {
                                    Map.Entry entry = (Map.Entry) entI.next();
                                    String ent_key = entry.getKey().toString();
                                    HashMap ent_value = (HashMap) entry.getValue();

                                    this.out.println("<tr>");
                                    this.out.println("   <td width=\"3%\" nowrap>&nbsp;</td>");
                                    this.out.println("   <td width=\"3%\" nowrap>&nbsp;</td>");
                                    this.out.println("   <td width=\"35%\" nowrap valign=\"top\">"
                                            + ent_value.get("title") + "</td>");
                                    this.out.println("   <td width=\"10%\" nowrap valign=\"top\">"
                                            + ent_value.get("name") + "</td>");
                                    this.out.println("   <td nowrap valign=\"top\">");
                                    if (ent_value.get("input_type").toString().equals("5")) { // long_value
                                        this.out.println("[ " + this.rb.getMessage(
                                                "sos.settings.dialog.dialog_long_value_title") + " ]");
                                        if (ent_value.get("display_type").toString().equals("4")) {
                                            this.out.println("&nbsp;" + display_type_entries[4]);
                                        }
                                    } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt
                                        this.out.println("[ " + input_type_entries[6] + " ]");
                                    } else {
                                        if (ent_value.get("display_type").toString().endsWith("3")) {
                                            this.out.println("<pre>"
                                                    + this.htmlSpecialChars(ent_value.get("value").toString())
                                                    + "</pre>");
                                        } else {
                                            this.out.println(
                                                    this.htmlSpecialChars(ent_value.get("value").toString()));
                                        }
                                    }
                                    this.out.println("   </td>");
                                    this.out.println("</tr>");
                                }
                            }
                        }
                    }
                    //out.print(section);

                }

            } catch (Exception e) {
                this.setError(e.getMessage(), SOSClassUtil.getMethodName());
                return;
            }
        }

        this.showTableEnd();

    } catch (Exception e) {
        this.setError(e.getMessage(), SOSClassUtil.getMethodName());
        return;
    }

}

From source file:sos.settings.SOSSettingsDialog.java

/**
 * !!! unter Produktion mu nich verwendet werden <br/>Anzeige von aktuellen
 * Request,Session usw Variablen//  ww  w  .j a v a2s. c  om
 * 
 * @param request
 * @param out
 * @throws IOException
 */
public void showDevelopmentData(LinkedHashMap requestMultipart) throws Exception {

    this.out.println(
            "<div id='div_temp_request' style=\"background-color:#ffffff;width:400px; overflow: auto; POSITION: absolute; Z-INDEX: 20; VISIBILITY: visible; TOP: "
                    + this.divDevelopmentDataTop + "; LEFT: " + this.divDevelopmentDataLeft
                    + "; border:solid 2px #dddddd;\">");

    this.out.println("<table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>action</b> = " + this.action + " <b>range</b> = " + this.range
            + " <b>item</b> = " + this.item + "</td>");
    this.out.println("</tr>");

    this.out.println("<tr>");
    this.out.println(
            "   <td colspan=\"2\"><b>application</b> = " + this.settings.application + " <b>section</b> = "
                    + this.settings.section + " <b>entry</b> = " + this.settings.entry + "</td>");
    this.out.println("</tr>");

    this.out.println("<tr><td colspan=\"2\">&nbsp;</td></tr>");

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>REQUEST PARAMETER: </b></td>");
    this.out.println("</tr>");
    this.out.println("<tr>");
    this.out.println("   <td>");
    this.out.println("   <table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");
    Enumeration en = this.request.getParameterNames();
    while (en.hasMoreElements()) {
        String a = (String) en.nextElement();
        this.out.println("<tr>");
        this.out.println("   <td><b>" + a + "</b></td>");
        this.out.println("    <td>" + this.request.getParameter(a) + "</td>");
        this.out.println("</tr>");
    }
    this.out.println("   </table>");
    this.out.println("   </td>");
    this.out.println("   <td>&nbsp;</td>");
    this.out.println("</tr>");
    this.out.println("<tr><td colspan=\"2\">&nbsp;</td></tr>");

    this.out.println("<tr>");
    this.out.println("   <td width=\"50%\"><b>REQUEST ATTRIBUTE</b></td>");
    this.out.println("   <td><b>MULTIPART-REQUEST</b></td>");
    this.out.println("</tr>");
    this.out.println("<tr>");
    this.out.println("   <td>");
    this.out.println("   <table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");
    Enumeration ena = this.request.getAttributeNames();
    int r = 0;
    while (ena.hasMoreElements()) {
        String a = (String) ena.nextElement();
        this.out.println("<tr>");
        this.out.println("   <td><b>" + a + "</b></td>");
        this.out.println("    <td>" + (String) this.request.getAttribute(a) + "</td>");
        this.out.println("</tr>");
        r++;
    }
    this.out.println("   </table>");
    this.out.println("   </td>");
    this.out.println("   <td>");
    int m = 0;
    if (requestMultipart != null && requestMultipart.size() > 0) {
        this.out.println("   <table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");
        Iterator it = requestMultipart.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            this.out.println("<tr>");
            this.out.println("   <td><b>" + (String) entry.getKey() + "</b></td>");
            this.out.println("    <td>" + (String) entry.getValue() + "</td>");
            this.out.println("</tr>");
            m++;
        }
        this.out.println("   </table>");
    }
    this.out.println("   </td>");
    this.out.println("</tr>");
    this.out.println("<tr><td>" + r + "</td><td>" + m + "</td></tr>");
    this.out.println("<tr><td colspan=\"2\">&nbsp;</td></tr>");

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>Session: </b></td>");
    this.out.println("</tr>");
    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>ID = </b>" + this.session.getId() + "</td>");
    this.out.println("</tr>");
    if (this.request.isRequestedSessionIdFromCookie()) {
        this.out.println("<tr>");
        this.out.println("   <td colspan=\"2\">Session aus Cookie</td>");
        this.out.println("</tr>");
    }
    if (this.request.isRequestedSessionIdFromURL()) {
        this.out.println("<tr>");
        this.out.println("   <td colspan=\"2\">Session aus URL</td>");
        this.out.println("</tr>");
    }

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\">");
    if (this.session.isNew()) {
        this.out.print("neue Session");
    } else {
        this.out.print("alte Session");
    }
    this.out.println("   </td>");
    this.out.println("</tr>");

    Enumeration sessionAttributeNames = this.session.getAttributeNames();

    //this.session.setAttribute("SOS 1","SOS value");
    //String[] a = {"aa","bb","cc"};
    //this.session.setAttribute("SOS 2",a);

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\">");
    while (sessionAttributeNames.hasMoreElements()) {
        String sessionAttribute = (String) sessionAttributeNames.nextElement();
        Object obj = this.session.getAttribute(sessionAttribute);
        this.out.print("<b>" + sessionAttribute + "</b>  = " + obj + "<br />");
    }
    this.out.println("   </td>");
    this.out.println("</tr>");
    this.out.println("</table>");

    this.out.println("</div>");

}

From source file:org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.java

@SuppressWarnings("nls")
private Operator genUnionPlan(String unionalias, String leftalias, Operator leftOp, String rightalias,
        Operator rightOp) throws SemanticException {

    // Currently, the unions are not merged - each union has only 2 parents. So,
    // a n-way union will lead to (n-1) union operators.
    // This can be easily merged into 1 union
    RowResolver leftRR = opParseCtx.get(leftOp).getRowResolver();
    RowResolver rightRR = opParseCtx.get(rightOp).getRowResolver();
    LinkedHashMap<String, ColumnInfo> leftmap = leftRR.getFieldMap(leftalias);
    LinkedHashMap<String, ColumnInfo> rightmap = rightRR.getFieldMap(rightalias);
    // make sure the schemas of both sides are the same
    ASTNode tabref = qb.getAliases().isEmpty() ? null
            : qb.getParseInfo().getSrcForAlias(qb.getAliases().get(0));
    if (leftmap.size() != rightmap.size()) {
        throw new SemanticException("Schema of both sides of union should match.");
    }// w w w.  j a  va  2 s. c o m

    RowResolver unionoutRR = new RowResolver();

    Iterator<Map.Entry<String, ColumnInfo>> lIter = leftmap.entrySet().iterator();
    Iterator<Map.Entry<String, ColumnInfo>> rIter = rightmap.entrySet().iterator();
    while (lIter.hasNext()) {
        Map.Entry<String, ColumnInfo> lEntry = lIter.next();
        Map.Entry<String, ColumnInfo> rEntry = rIter.next();
        ColumnInfo lInfo = lEntry.getValue();
        ColumnInfo rInfo = rEntry.getValue();

        String field = lEntry.getKey(); // use left alias (~mysql, postgresql)
        // try widening conversion, otherwise fail union
        TypeInfo commonTypeInfo = FunctionRegistry.getCommonClassForUnionAll(lInfo.getType(), rInfo.getType());
        if (commonTypeInfo == null) {
            throw new SemanticException(generateErrorMessage(tabref,
                    "Schema of both sides of union should match: Column " + field + " is of type "
                            + lInfo.getType().getTypeName() + " on first table and type "
                            + rInfo.getType().getTypeName() + " on second table"));
        }
        ColumnInfo unionColInfo = new ColumnInfo(lInfo);
        unionColInfo.setType(commonTypeInfo);
        unionoutRR.put(unionalias, field, unionColInfo);
    }

    // For Spark,TEZ we rely on the generated SelectOperator to do the type casting.
    // Consider:
    //    SEL_1 (int)   SEL_2 (int)    SEL_3 (double)
    // If we first merge SEL_1 and SEL_2 into a UNION_1, and then merge UNION_1
    // with SEL_3 to get UNION_2, then no SelectOperator will be inserted. Hence error
    // will happen afterwards. The solution here is to insert one after UNION_1, which
    // cast int to double.
    boolean isMR = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_EXECUTION_ENGINE).equals("mr");

    if (!isMR || !(leftOp instanceof UnionOperator)) {
        leftOp = genInputSelectForUnion(leftOp, leftmap, leftalias, unionoutRR, unionalias);
    }

    if (!isMR || !(rightOp instanceof UnionOperator)) {
        rightOp = genInputSelectForUnion(rightOp, rightmap, rightalias, unionoutRR, unionalias);
    }

    // If one of the children (left or right) is:
    // (i) a union, or
    // (ii) an identity projection followed by a union,
    // merge with it
    // else create a new one
    if (leftOp instanceof UnionOperator || (leftOp instanceof SelectOperator
            && leftOp.getParentOperators() != null && !leftOp.getParentOperators().isEmpty()
            && leftOp.getParentOperators().get(0) instanceof UnionOperator
            && ((SelectOperator) leftOp).isIdentitySelect())) {

        if (!(leftOp instanceof UnionOperator)) {
            Operator oldChild = leftOp;
            leftOp = (Operator) leftOp.getParentOperators().get(0);
            leftOp.removeChildAndAdoptItsChildren(oldChild);
        }

        // make left a child of right
        List<Operator<? extends OperatorDesc>> child = new ArrayList<Operator<? extends OperatorDesc>>();
        child.add(leftOp);
        rightOp.setChildOperators(child);

        List<Operator<? extends OperatorDesc>> parent = leftOp.getParentOperators();
        parent.add(rightOp);

        UnionDesc uDesc = ((UnionOperator) leftOp).getConf();
        uDesc.setNumInputs(uDesc.getNumInputs() + 1);
        return putOpInsertMap(leftOp, unionoutRR);
    }

    if (rightOp instanceof UnionOperator || (rightOp instanceof SelectOperator
            && rightOp.getParentOperators() != null && !rightOp.getParentOperators().isEmpty()
            && rightOp.getParentOperators().get(0) instanceof UnionOperator
            && ((SelectOperator) rightOp).isIdentitySelect())) {

        if (!(rightOp instanceof UnionOperator)) {
            Operator oldChild = rightOp;
            rightOp = (Operator) rightOp.getParentOperators().get(0);
            rightOp.removeChildAndAdoptItsChildren(oldChild);
        }

        // make right a child of left
        List<Operator<? extends OperatorDesc>> child = new ArrayList<Operator<? extends OperatorDesc>>();
        child.add(rightOp);
        leftOp.setChildOperators(child);

        List<Operator<? extends OperatorDesc>> parent = rightOp.getParentOperators();
        parent.add(leftOp);
        UnionDesc uDesc = ((UnionOperator) rightOp).getConf();
        uDesc.setNumInputs(uDesc.getNumInputs() + 1);

        return putOpInsertMap(rightOp, unionoutRR);
    }

    // Create a new union operator
    Operator<? extends OperatorDesc> unionforward = OperatorFactory.getAndMakeChild(getOpContext(),
            new UnionDesc(), new RowSchema(unionoutRR.getColumnInfos()));

    // set union operator as child of each of leftOp and rightOp
    List<Operator<? extends OperatorDesc>> child = new ArrayList<Operator<? extends OperatorDesc>>();
    child.add(unionforward);
    rightOp.setChildOperators(child);

    child = new ArrayList<Operator<? extends OperatorDesc>>();
    child.add(unionforward);
    leftOp.setChildOperators(child);

    List<Operator<? extends OperatorDesc>> parent = new ArrayList<Operator<? extends OperatorDesc>>();
    parent.add(leftOp);
    parent.add(rightOp);
    unionforward.setParentOperators(parent);

    // create operator info list to return
    return putOpInsertMap(unionforward, unionoutRR);
}