List of usage examples for java.util LinkedHashMap entrySet
public Set<Map.Entry<K, V>> entrySet()
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnProductCreated(Boolean status, LinkedHashMap<Ingredient, Double> ingredents, Product product) { if (status) { Iterator<Entry<Ingredient, Double>> it = ingredents.entrySet().iterator(); StringBuilder ingredientes = new StringBuilder(); ingredientes.append("["); int i = 0; while (it.hasNext()) { Map.Entry<Ingredient, Double> ingredientPair = (Map.Entry<Ingredient, Double>) it.next(); product.addIngredient(dbHelper, ingredientPair.getKey(), ingredientPair.getValue()); Toast.makeText(mContext,/*from w w w . jav a 2 s. c o m*/ "Ingrediente: " + ingredientPair.getKey() + " Cantidad: " + ingredientPair.getValue(), Toast.LENGTH_LONG).show(); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); if (i != 0) { ingredientes.append(","); } ingredientes.append("{\"sync_id\": " + ingredientPair.getKey().getSyncId() + ",\"qty\": " + ingredientPair.getValue() + "}"); i++; } product.refreshIngredients(dbHelper); productos.add(product); //crear syncrow productList.add(new Registrable(product)); ingredientes.append("]"); createSyncRow("\"" + Setup.TABLE_PRODUCTS + "\"", product.getId(), product.getSyncId(), "{\"" + Setup.COLUMN_NAME + "\": \"" + product.getName() + "\",\"" + Setup.COLUMN_PRODUCT_AUTOMATIC + "\":" + product.isAutomaticCost() + ",\"_id\":" + product.getId() + ",\"" + Setup.COLUMN_PRODUCT_CATEGORY_ID + "\": " + product.getCategory().getSyncId() + ",\"" + Setup.COLUMN_PRODUCT_TAX_ID + "\": " + product.getTax().getSyncId() + ",\"" + Setup.COLUMN_PRODUCT_COST + "\": " + product.getCost() + ",\"" + Setup.COLUMN_PRODUCT_PRICE + "\": " + product.getPrice() + ",\"ingredients\": " + ingredientes.toString() + "}"); //hacer la forma que cuando se reciba esto, se creen los ingredientes (la base de datos debe exportar la forma) } else { productDatasource.deleteProduct(product); } }
From source file:com.nest5.businessClient.Initialactivity.java
private void sendCommandMessage(int msgCode) { switch (msgCode) { case DELETE_ALL_COMMAND: StringBuilder str = new StringBuilder(); str.append("N5AT-2\n"); new WiFiSend().execute(str.toString()); // sigue a SEND_ALL para agregar los nuevos compras case SEND_ALL_COMMAND: for (LinkedHashMap<Registrable, Integer> currentSale : cookingOrders) { str = new StringBuilder(); Iterator<Entry<Registrable, Integer>> it = currentSale.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Registrable, Integer> pair = (Map.Entry<Registrable, Integer>) it.next(); str.append(pair.getValue()); str.append(" -----> "); str.append(pair.getKey().name); str.append("\n"); }/*w w w.ja v a 2 s . co m*/ new WiFiSend().execute(str.toString()); } break; } }
From source file:com.nest5.businessClient.Initialactivity.java
private void updateSaleValue() { Double total = 0.0;/* www . j a v a 2 s . com*/ for (Sale currentSale : salesFromToday) { LinkedHashMap<Combo, Double> combos = currentSale.getCombos(); LinkedHashMap<Product, Double> products = currentSale.getProducts(); LinkedHashMap<Ingredient, Double> ingredients = currentSale.getIngredients(); Iterator<Entry<Combo, Double>> it = combos.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Combo, Double> pair = (Map.Entry<Combo, Double>) it.next(); total += (pair.getValue() * pair.getKey().getPrice()); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Product, Double>> it2 = products.entrySet().iterator(); while (it2.hasNext()) { Map.Entry<Product, Double> pair = (Map.Entry<Product, Double>) it2.next(); total += (pair.getValue() * pair.getKey().getPrice()); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Ingredient, Double>> it3 = ingredients.entrySet().iterator(); while (it3.hasNext()) { Map.Entry<Ingredient, Double> pair = (Map.Entry<Ingredient, Double>) it3.next(); if (pair.getKey() != null) total += (pair.getValue() * pair.getKey().getPrice()); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } DecimalFormat dec = new DecimalFormat("$###,###,###"); saleValue.setText("Ventas del Da: " + dec.format(total)); } }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnComboCreated(Boolean status, LinkedHashMap<Ingredient, Double> ingredents, LinkedHashMap<Product, Double> products, String name, Double cost, Double price, Tax tax) { if (status) { Combo combo = comboDatasource.createCombo(name, 0, cost, price, tax, 0); Iterator<Entry<Ingredient, Double>> it = ingredents.entrySet().iterator(); StringBuilder ingredientes = new StringBuilder(); ingredientes.append("["); StringBuilder productos = new StringBuilder(); productos.append("["); int i = 0; while (it.hasNext()) { Map.Entry<Ingredient, Double> ingredientPair = (Map.Entry<Ingredient, Double>) it.next(); combo.addIngredient(dbHelper, ingredientPair.getKey(), ingredientPair.getValue()); if (i != 0) { ingredientes.append(","); }//from w ww . ja va 2 s .c o m ingredientes.append("{\"sync_id\": " + ingredientPair.getKey().getSyncId() + ",\"qty\": " + ingredientPair.getValue() + "}"); i++; // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } ingredientes.append("]"); Iterator<Entry<Product, Double>> pt = products.entrySet().iterator(); int j = 0; while (pt.hasNext()) { Map.Entry<Product, Double> productPair = (Map.Entry<Product, Double>) pt.next(); combo.addProduct(dbHelper, productPair.getKey(), productPair.getValue()); if (j != 0) { productos.append(","); } productos.append("{\"sync_id\": " + productPair.getKey().getSyncId() + ",\"qty\": " + productPair.getValue() + "}"); j++; } productos.append("]"); createSyncRow("\"" + Setup.TABLE_COMBOS + "\"", combo.getId(), combo.getSyncId(), "{\"name\": \"" + combo.getName() + "\",\"" + Setup.COLUMN_COMBO_AUTOMATIC + "\":" + combo.isAutomaticCost() + ",\"_id\":" + combo.getId() + ",\"" + Setup.COLUMN_COMBO_TAX_ID + "\": " + combo.getTax().getSyncId() + ",\"" + Setup.COLUMN_COMBO_COST + "\": " + combo.getCost() + ",\"" + Setup.COLUMN_COMBO_PRICE + "\": " + combo.getPrice() + ",\"ingredients\": " + ingredientes.toString() + ",\"products\": " + productos.toString() + "}"); combo.refreshIngredients(dbHelper); combo.refreshProducts(dbHelper); combos.add(combo); comboList.add(new Registrable(combo)); } else { } }
From source file:org.jboss.pressgang.ccms.contentspec.builder.DocBookBuilder.java
/** * Builds the Author_Group.xml using the assigned writers for topics inside of the content specification. * * @param buildData Information and data structures for the build. * @param specTopic The topic to build the Author Group in place of. * @throws BuildProcessingException// w w w. jav a 2 s. c o m */ private void buildAuthorGroup(final BuildData buildData, final SpecTopic specTopic) throws BuildProcessingException { log.info("\tBuilding " + AUTHOR_GROUP_FILE_NAME); // Setup Author_Group.xml Document authorDoc = null; try { authorDoc = XMLUtilities.convertStringToDocument("<authorgroup></authorgroup>"); } catch (Exception ex) { // Exit since we shouldn't fail at converting the basic author group log.debug("", ex); throw new BuildProcessingException( String.format(getMessages().getString("FAILED_CONVERTING_TEMPLATE"), AUTHOR_GROUP_FILE_NAME)); } final LinkedHashMap<Integer, AuthorInformation> authorIDtoAuthor = new LinkedHashMap<Integer, AuthorInformation>(); // Check if the app should be shutdown if (isShuttingDown.get()) { return; } // Set the id if (specTopic != null) { DocBookBuildUtilities.processTopicID(buildData, specTopic, authorDoc); } else { DocBookBuildUtilities.setDOMElementId(buildData.getDocBookVersion(), authorDoc.getDocumentElement(), "Author_Group"); } // Get the mapping of authors using the topics inside the content spec for (final Integer topicId : buildData.getBuildDatabase().getTopicIds()) { final BaseTopicWrapper<?> topic = buildData.getBuildDatabase().getTopicNodesForTopicID(topicId).get(0) .getTopic(); final List<TagWrapper> authorTags = topic.getTagsInCategories( CollectionUtilities.toArrayList(buildData.getServerEntities().getWriterCategoryId())); if (authorTags.size() > 0) { for (final TagWrapper author : authorTags) { if (!authorIDtoAuthor.containsKey(author.getId())) { final AuthorInformation authorInfo = EntityUtilities.getAuthorInformation(providerFactory, buildData.getServerEntities(), author.getId(), author.getRevision()); if (authorInfo != null) { authorIDtoAuthor.put(author.getId(), authorInfo); } } } } } // Sort and make sure duplicate authors don't exist final Set<AuthorInformation> authors = new TreeSet<AuthorInformation>(new AuthorInformationComparator()); for (final Entry<Integer, AuthorInformation> authorEntry : authorIDtoAuthor.entrySet()) { final AuthorInformation authorInfo = authorEntry.getValue(); if (authorInfo != null) { authors.add(authorInfo); } } // Check if the app should be shutdown if (isShuttingDown.get()) { return; } boolean insertedAuthor = false; // If one or more authors were found then remove the default and attempt to add them if (!authors.isEmpty()) { // For each author attempt to find the author information records and populate Author_Group.xml. for (final AuthorInformation authorInfo : authors) { // Check if the app should be shutdown if (isShuttingDown.get()) { shutdown.set(true); return; } final Element authorEle = authorDoc.createElement("author"); final Element firstNameEle = authorDoc.createElement("firstname"); firstNameEle.setTextContent(authorInfo.getFirstName()); final Element lastNameEle = authorDoc.createElement("surname"); lastNameEle.setTextContent(authorInfo.getLastName()); // Docbook 5 needs <firstname>/<surname> wrapped in <personname> if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { final Element personnameEle = authorDoc.createElement("personname"); authorEle.appendChild(personnameEle); personnameEle.appendChild(firstNameEle); personnameEle.appendChild(lastNameEle); } else { authorEle.appendChild(firstNameEle); authorEle.appendChild(lastNameEle); } // Add the affiliation information if (authorInfo.getOrganization() != null) { final Element affiliationEle = authorDoc.createElement("affiliation"); final Element orgEle = authorDoc.createElement("orgname"); orgEle.setTextContent(authorInfo.getOrganization()); affiliationEle.appendChild(orgEle); if (authorInfo.getOrgDivision() != null) { final Element orgDivisionEle = authorDoc.createElement("orgdiv"); orgDivisionEle.setTextContent(authorInfo.getOrgDivision()); affiliationEle.appendChild(orgDivisionEle); } authorEle.appendChild(affiliationEle); } // Add an email if one exists if (authorInfo.getEmail() != null) { Element emailEle = authorDoc.createElement("email"); emailEle.setTextContent(authorInfo.getEmail()); authorEle.appendChild(emailEle); } authorDoc.getDocumentElement().appendChild(authorEle); insertedAuthor = true; } } // If no authors were inserted then use a default value if (!insertedAuthor) { // Use the author "PressGang CCMS Build System" final Element authorEle = authorDoc.createElement("author"); authorDoc.getDocumentElement().appendChild(authorEle); // Use the author "PressGang Alpha Build System" final Element firstNameEle = authorDoc.createElement("firstname"); firstNameEle.setTextContent(""); final Element lastNameEle = authorDoc.createElement("surname"); lastNameEle.setTextContent("PressGang CCMS Build System"); // Docbook 5 needs <firstname>/<surname> wrapped in <personname> if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) { final Element personnameEle = authorDoc.createElement("personname"); authorEle.appendChild(personnameEle); personnameEle.appendChild(firstNameEle); personnameEle.appendChild(lastNameEle); } else { authorEle.appendChild(firstNameEle); authorEle.appendChild(lastNameEle); } // Add the affiliation final Element affiliationEle = authorDoc.createElement("affiliation"); final Element orgEle = authorDoc.createElement("orgname"); orgEle.setTextContent("Red Hat"); affiliationEle.appendChild(orgEle); final Element orgDivisionEle = authorDoc.createElement("orgdiv"); orgDivisionEle.setTextContent("Engineering Content Services"); affiliationEle.appendChild(orgDivisionEle); authorEle.appendChild(affiliationEle); } // Add the Author_Group.xml to the book final String authorGroupXml = DocBookBuildUtilities.convertDocumentToDocBookFormattedString( buildData.getDocBookVersion(), authorDoc, "authorgroup", buildData.getEntityFileName(), getXMLFormatProperties()); addToZip(buildData.getBookLocaleFolder() + AUTHOR_GROUP_FILE_NAME, authorGroupXml, buildData); }
From source file:com.nest5.businessClient.Initialactivity.java
private void makeDailyTable(int TABLE_TYPE) { dailyTable.removeAllViews();//from ww w .jav a 2 s . co m Double total = 0.0; DecimalFormat dec = new DecimalFormat("$###,###,###"); TextView tv = new TextView(mContext); tv.setBackgroundColor(Color.parseColor("#80808080")); tv.setHeight(2); TableRow tr1 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate1 = (TextView) tr1.findViewById(R.id.cell_date); TextView tItem1 = (TextView) tr1.findViewById(R.id.cell_item); TextView tAccount1 = (TextView) tr1.findViewById(R.id.cell_account); TextView tVal1 = (TextView) tr1.findViewById(R.id.cell_value); TextView tTot1 = (TextView) tr1.findViewById(R.id.cell_total); tDate1.setText("FECHA"); tAccount1.setText("CUENTA"); tItem1.setText("ITEM"); tVal1.setText("VALOR"); tTot1.setText("TOTAL"); tr1.setBackgroundColor(Color.CYAN); dailyTable.addView(tr1); dailyTable.addView(tv); //actualizar sales de hoy Calendar today = Calendar.getInstance(); Calendar tomorrow = Calendar.getInstance(); today.set(Calendar.HOUR, 0); today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); tomorrow.roll(Calendar.DATE, 1); tomorrow.set(Calendar.HOUR, 0); tomorrow.set(Calendar.HOUR_OF_DAY, 0); tomorrow.set(Calendar.MINUTE, 0); tomorrow.set(Calendar.SECOND, 0); tomorrow.set(Calendar.MILLISECOND, 0); init = today.getTimeInMillis(); end = tomorrow.getTimeInMillis(); Log.d("GUARDANDOVENTA", today.toString()); Log.d("GUARDANDOVENTA", tomorrow.toString()); Calendar now = Calendar.getInstance(); now.setTimeInMillis(System.currentTimeMillis()); Log.d(TAG, now.toString()); Log.d(TAG, "Diferencia entre tiempos: " + String.valueOf(end - init)); salesFromToday = saleDataSource.getAllSalesWithin(init, end); List<Sale> usingSales = salesFromToday; switch (TABLE_TYPE) { case TABLE_TYPE_TODAY: usingSales = salesFromToday; break; case TABLE_TYPE_ALL: usingSales = saleList; break; } for (Sale currentSale : usingSales) { double totalLocal = 0.0; LinkedHashMap<Combo, Double> combos = currentSale.getCombos(); LinkedHashMap<Product, Double> products = currentSale.getProducts(); LinkedHashMap<Ingredient, Double> ingredients = currentSale.getIngredients(); Log.w("DAYILETABLES", " " + combos.size() + " " + products.size() + " " + ingredients.size()); Iterator<Entry<Combo, Double>> it = combos.entrySet().iterator(); Calendar date = Calendar.getInstance(); date.setTimeInMillis(currentSale.getDate()); String fecha = date.get(Calendar.MONTH) + "/" + date.get(Calendar.DAY_OF_MONTH) + "/" + date.get(Calendar.YEAR) + "\n" + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND); String account = currentSale.getPaymentMethod(); while (it.hasNext()) { TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Map.Entry<Combo, Double> pair = (Map.Entry<Combo, Double>) it.next(); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName() + " en Combo"); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Product, Double>> it2 = products.entrySet().iterator(); while (it2.hasNext()) { Map.Entry<Product, Double> pair = (Map.Entry<Product, Double>) it2.next(); TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName()); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Ingredient, Double>> it3 = ingredients.entrySet().iterator(); while (it3.hasNext()) { Map.Entry<Ingredient, Double> pair = (Map.Entry<Ingredient, Double>) it3.next(); TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName()); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); tDate.setText(fecha); tAccount.setText("-------"); tItem.setText("Ingreso por Ventas"); tVal.setText("----"); tTot.setText(dec.format(totalLocal)); tr.setBackgroundColor(Color.LTGRAY); dailyTable.addView(tr); TableRow tr2 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate2 = (TextView) tr2.findViewById(R.id.cell_date); TextView tItem2 = (TextView) tr2.findViewById(R.id.cell_item); TextView tAccount2 = (TextView) tr2.findViewById(R.id.cell_account); TextView tVal2 = (TextView) tr2.findViewById(R.id.cell_value); TextView tTot2 = (TextView) tr2.findViewById(R.id.cell_total); tDate2.setText(fecha); tAccount2.setText("-------"); tItem2.setText("Acumulado por Ventas"); tVal2.setText("----"); tTot2.setText(dec.format(total)); tr2.setBackgroundColor(Color.GRAY); dailyTable.addView(tr2); } }
From source file:com.nest5.businessClient.Initialactivity.java
private void saveSale(String method, Double value, Double discount, int delivery, int togo, int tip) { int number = checkSaleNumber(); int nextsale = addSale(); //se aumenta el valor de facturacin, //si falla se resta un numero de las ventas actuales mas adelante,. Sale createdSale = null;//from www . ja v a 2 s . c om long saveDate = System.currentTimeMillis(); LinkedHashMap<Registrable, Integer> currentSale = currentOrder; if (number > 0) { createdSale = saleDataSource.createSale(saveDate, method, value, 0, delivery, togo, tip, discount, nextsale); } else { alertbox("!ATENCIN!", "Esta venta no se puede facturar. Este dispositivo no tiene ms facturas autorizadas. Consulta el administrador, o si tu lo eres, ve a tu panel de control Nest5 y autoriza ms facturas. Para ms informacin: http://soporte.nest5.com"); } if (createdSale != null) { Iterator<Entry<Registrable, Integer>> it = currentSale.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Registrable, Integer> pair = (Map.Entry<Registrable, Integer>) it.next(); createdSale.saveItem(dbHelper, pair.getKey().type, pair.getKey().id, pair.getValue());//ser que ac guarda el id local y sincroiniza asi por eso llega luego tod en ceros al volver a sincronizar? // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } //cookingOrders.remove(currentSelectedPosition); try { cookingOrders.remove(currentSale); cookingOrdersDelivery.remove(currentSale); cookingOrdersTogo.remove(currentSale); cookingOrdersTimes.remove(currentSale); openTables.remove(cookingOrdersTable.get(currentSale)); cookingOrdersTable.remove(currentSale); //quitar mesas de las abiertas y quitar } catch (Exception e) { ////Log.i("ERRORES_REMOVE","HAY UN ERROR AL REMOVER CURRENTSALE DE COOKINGORDERS"); e.printStackTrace(); } currentTable = null; statusText.setText("Cuenta Cerrada Exitosamente."); currentSelectedPosition = -1; //sendCommandMessage(DELETE_ALL_COMMAND); 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); salesFromToday = saleDataSource.getAllSalesWithin(init, end); ordersList.setOnItemClickListener(orderListListener); //currentOrder.clear(); //NUEVO //makeTable("NA"); sale_name.setText("Venta Guardada con xito"); sale_details.setText("Selecciona otro elemento para ver detalles."); updateSaleValue(); //pdate sale object to get saved items, since the object doesn't have them createdSale = saleDataSource.getSale(createdSale.getId()); //Log.w("GUARDANDOVENTA","Cantidad de productos: "+String.valueOf(createdSale.getProducts().size())); createSyncRow("\"" + Setup.TABLE_SALE + "\"", createdSale.getId(), createdSale.getSyncId(), createdSale.serializedFields()); } else { subSale();//fall uardando venta por lo tanto resetea el valor de facturacin actual al anterior. Toast.makeText(mContext, "Error al Guardar la venta", Toast.LENGTH_LONG).show(); } }
From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.ElasticsearchIndexUtils.java
/** Creates a mapping for the bucket - columnar elements * ALSO INCLUDES THE PER-FIELD CONFIGURATION FROM THE SEARCH_INDEX_SCHEMA AND TEMPORAL_SCHMEA * @param bucket// w w w. j a v a 2 s . co m * @return * @throws IOException */ public static XContentBuilder getColumnarMapping(final DataBucketBean bucket, Optional<XContentBuilder> to_embed, final LinkedHashMap<Either<String, Tuple2<String, String>>, JsonNode> field_lookups, final JsonNode enabled_not_analyzed, final JsonNode enabled_analyzed, final JsonNode default_not_analyzed, final JsonNode default_analyzed, final Optional<JsonNode> doc_schema, final SearchIndexSchemaDefaultBean search_index_schema_override, final ObjectMapper mapper, final String index_type) { try { final XContentBuilder start = to_embed.orElse(XContentFactory.jsonBuilder().startObject()); final boolean columnar_enabled = Optional.ofNullable(bucket.data_schema()) .map(DataSchemaBean::columnar_schema).filter(s -> Optional.ofNullable(s.enabled()).orElse(true)) .isPresent(); final Map<Either<String, Tuple2<String, String>>, String> type_override = Optionals .of(() -> bucket.data_schema().search_index_schema().type_override()).map(m -> buildTypeMap(m)) .orElse(Collections.emptyMap()); // If no columnar settings are specified then go with a sensible default final Optional<DataSchemaBean.ColumnarSchemaBean> maybe_user_columnar_schema = Optionals .of(() -> bucket.data_schema().columnar_schema()); final DataSchemaBean.ColumnarSchemaBean columnar_schema = maybe_user_columnar_schema .filter(__ -> columnar_enabled).filter(schema -> (null == schema.field_include_list()) && // ie the entire thing is empty (null == schema.field_exclude_list()) && (null == schema.field_include_pattern_list()) && (null == schema.field_type_include_list()) && (null == schema.field_exclude_pattern_list()) && (null == schema.field_type_exclude_list())) .map(schema -> BeanTemplateUtils.clone(schema) .with(DataSchemaBean.ColumnarSchemaBean::field_type_include_list, Arrays.asList("string", "number", "date")) .done()) .orElseGet(() -> maybe_user_columnar_schema.orElse(null)) // (NOTE: can only be null if columnar_enabled is false) ; final LinkedHashMap<Either<String, Tuple2<String, String>>, JsonNode> column_lookups_pretypes = Stream .of(columnar_enabled ? createFieldIncludeLookups( Optionals.ofNullable(columnar_schema.field_include_list()).stream(), fn -> getKey(fn), field_lookups, enabled_not_analyzed, enabled_analyzed, true, search_index_schema_override, type_override, mapper, index_type) : Stream.<Tuple2<Either<String, Tuple2<String, String>>, JsonNode>>empty(), columnar_enabled ? createFieldExcludeLookups( Optionals.ofNullable(columnar_schema.field_exclude_list()).stream(), fn -> getKey(fn), field_lookups, search_index_schema_override, type_override, mapper, index_type) : Stream.<Tuple2<Either<String, Tuple2<String, String>>, JsonNode>>empty(), columnar_enabled ? createFieldIncludeLookups( Optionals.ofNullable(columnar_schema.field_include_pattern_list()) .stream(), fn -> Either.right(Tuples._2T(fn, "*")), field_lookups, enabled_not_analyzed, enabled_analyzed, true, search_index_schema_override, type_override, mapper, index_type) : Stream.<Tuple2<Either<String, Tuple2<String, String>>, JsonNode>>empty(), columnar_enabled ? createFieldIncludeLookups( Optionals.ofNullable(columnar_schema.field_type_include_list()) .stream(), fn -> Either.right(Tuples._2T("*", fn)), field_lookups, enabled_not_analyzed, enabled_analyzed, true, search_index_schema_override, type_override, mapper, index_type) : Stream.<Tuple2<Either<String, Tuple2<String, String>>, JsonNode>>empty(), columnar_enabled ? createFieldExcludeLookups( Optionals.ofNullable(columnar_schema.field_exclude_pattern_list()) .stream(), fn -> Either.right(Tuples._2T(fn, "*")), field_lookups, search_index_schema_override, type_override, mapper, index_type) : Stream.<Tuple2<Either<String, Tuple2<String, String>>, JsonNode>>empty(), columnar_enabled ? createFieldExcludeLookups( Optionals.ofNullable(columnar_schema.field_type_exclude_list()) .stream(), fn -> Either.right(Tuples._2T("*", fn)), field_lookups, search_index_schema_override, type_override, mapper, index_type) : Stream.<Tuple2<Either<String, Tuple2<String, String>>, JsonNode>>empty(), // Finally add the default columnar lookups to the unmentioned strings (ensures that *_* is at the end) field_lookups.entrySet().stream() .flatMap(kv -> createFieldIncludeLookups(Stream.of(kv.getKey().toString()), __ -> kv.getKey(), field_lookups, default_not_analyzed, default_analyzed, false, search_index_schema_override, type_override, mapper, index_type))) .flatMap(x -> x).collect(Collectors.toMap(t2 -> t2._1(), t2 -> t2._2(), (v1, v2) -> v1, // (ie ignore duplicates) () -> new LinkedHashMap<Either<String, Tuple2<String, String>>, JsonNode>())); ; // Also any types that didn't map onto one of the fields or tokens: final LinkedHashMap<Either<String, Tuple2<String, String>>, JsonNode> column_lookups_types = type_override .entrySet().stream() // (filter - convert name/* to name/type and check if I've already created such an entry using the type map) .filter(kv -> !column_lookups_pretypes .containsKey(kv.getKey().either(s -> s, t2 -> Tuples._2T(t2._1(), kv.getValue())))) .flatMap(kv -> createFieldIncludeLookups(Stream.of(kv.getKey().toString()), __ -> kv.getKey().<Either<String, Tuple2<String, String>>>either(s -> Either.left(s), t2 -> Either.right(Tuples._2T(t2._1(), kv.getValue()))), field_lookups, default_not_analyzed, default_analyzed, false, search_index_schema_override, type_override, mapper, index_type)) .collect(Collectors.toMap(t2 -> t2._1(), t2 -> t2._2(), (v1, v2) -> v1, () -> new LinkedHashMap<Either<String, Tuple2<String, String>>, JsonNode>())); final LinkedHashMap<Either<String, Tuple2<String, String>>, JsonNode> column_lookups = Stream .concat(column_lookups_pretypes.entrySet().stream(), column_lookups_types.entrySet().stream()) .sorted((a, b) -> Integer.compare(sortKey(a.getKey()), sortKey(b.getKey()))) .collect(Collectors.toMap(t2 -> t2.getKey(), t2 -> t2.getValue(), (v1, v2) -> v1, () -> new LinkedHashMap<Either<String, Tuple2<String, String>>, JsonNode>())); final XContentBuilder properties = column_lookups.entrySet().stream() // properties not dynamic_templates .filter(kv -> kv.getKey().isLeft()) // overwrite with version built using columns if it exists .map(kv -> Tuples._2T(kv.getKey(), column_lookups.getOrDefault(kv.getKey(), kv.getValue()))) .reduce(Optional.of(start.startObject("properties")) // add doc_schema if it exists .map(props -> doc_schema .map(ds -> Optionals.streamOf(ds.fields(), false) .reduce(props, Lambdas.wrap_u((acc, kv) -> acc.rawField(kv.getKey(), kv.getValue().toString().getBytes())), (acc1, acc2) -> acc1 // shouldn't be possible )).orElse(props)).get(), Lambdas.wrap_u((acc, t2) -> acc.rawField(t2._1().left().value(), t2._2().toString().getBytes())), // (left by construction) (acc1, acc2) -> acc1) // (not actually possible) .endObject(); final XContentBuilder templates = column_lookups.entrySet().stream() // properties not dynamic_templates .filter(kv -> kv.getKey().isRight()) // overwrite with version built using columns if it exists .map(kv -> Tuples._2T(kv.getKey(), column_lookups.getOrDefault(kv.getKey(), kv.getValue()))) .reduce(properties.startArray("dynamic_templates"), Lambdas.wrap_u((acc, t2) -> acc.startObject() .rawField(getFieldNameFromMatchPair(t2._1().right().value()), t2._2().toString().getBytes()) // (right by construction) .endObject()), (acc1, acc2) -> acc1) // (not actually possible) .endArray(); return templates; } catch (IOException e) { //Handle in-practice-impossible "IOException" return null; } }
From source file:org.tdwg.dwca.wikipedia.TaxonboxHandler.java
private void processTaxonPage(WikiArticle page, TaxonInfo taxon, LinkedHashMap<String, String> sections) throws IOException { taxon.postprocess(page, lang);/* w w w . j av a2s . c om*/ if (taxon.getScientificName() == null) { LOG.info("No scientific name found in infobox of page {}. Using article title {} as name", WikipediaUtils.getWikiLink(lang, page.getTitle()), page.getTitle()); taxon.setScientificName(page.getTitle()); taxon.addRemark( "No scientific name found in Wikipedia infobox template of page %s. Using article title %s as scientific name", WikipediaUtils.getWikiLink(lang, page.getTitle()), page.getTitle()); } taxonCount++; LOG.debug("Processing #" + taxonCount + " {}: {}", WikipediaUtils.getWikiLink(lang, page.getTitle()), taxon.getScientificName()); // write core record writer.newRecord(page.getId()); writer.addCoreColumn(DcTerm.references, WikipediaUtils.getWikiLink(lang, page.getTitle())); writer.addCoreColumn(DcTerm.modified, page.getTimeStamp()); writer.addCoreColumn(DwcTerm.scientificName, taxon.getScientificName()); writer.addCoreColumn(DwcTerm.scientificNameAuthorship, taxon.getScientificNameAuthorship()); if (taxon.getRank() != null) { writer.addCoreColumn(DwcTerm.taxonRank, taxon.getRank().name()); } writer.addCoreColumn(DwcTerm.verbatimTaxonRank, taxon.getRankVerbatim()); writer.addCoreColumn(DwcTerm.kingdom, taxon.getKingdom()); writer.addCoreColumn(DwcTerm.phylum, taxon.getPhylum()); writer.addCoreColumn(DwcTerm.class_, taxon.getClazz()); writer.addCoreColumn(DwcTerm.order, taxon.getOrder()); writer.addCoreColumn(DwcTerm.family, taxon.getFamily()); writer.addCoreColumn(DwcTerm.genus, taxon.getGenus()); writer.addCoreColumn(DwcTerm.subgenus, taxon.getSubgenus()); writer.addCoreColumn(DwcTerm.taxonRemarks, taxon.getRemarks()); // other non core writer.addCoreColumn(termTrend, taxon.getTrend()); writer.addCoreColumn(termFossil, taxon.getFossilRange()); writer.addCoreColumn(taxobox, taxon.getRawParams().toString()); Map<Term, String> row; // vernacular name extension for (String vname : taxon.getVernacularNamesInDefaultLang()) { if (Strings.isNullOrEmpty(vname) || vname.equalsIgnoreCase(taxon.getScientificName())) { continue; } row = Maps.newHashMap(); row.put(DwcTerm.vernacularName, vname); row.put(DcTerm.language, lang.getIso2LetterCode()); row.put(GbifTerm.isPreferredName, "true"); writer.addExtensionRecord(GbifTerm.VernacularName, row); } // other languages for (Map.Entry<String, String> vn : taxon.getVernacularNames().entrySet()) { if (Strings.isNullOrEmpty(vn.getValue()) || vn.getValue().equalsIgnoreCase(taxon.getScientificName())) { continue; } row = Maps.newHashMap(); row.put(DwcTerm.vernacularName, vn.getValue()); row.put(DcTerm.language, vn.getKey()); writer.addExtensionRecord(GbifTerm.VernacularName, row); } // species profile extension String fr = taxon.getFossilRange(); if (fr != null) { row = Maps.newHashMap(); row.put(GbifTerm.livingPeriod, fr); if (taxon.getExtinct() != null) { row.put(GbifTerm.isExtinct, taxon.getExtinct()); } else { row.put(GbifTerm.isExtinct, String.valueOf(taxon.getExtinctSymbol())); } writer.addExtensionRecord(GbifTerm.SpeciesProfile, row); } // distribution extension //TODO: publish distribution maps as images or html formatted textual descriptions??? /** for (Image image : taxon.getRangeMaps()) { if (!StringUtils.isBlank(image.getUrl())) { row = Maps.newHashMap(); row.put(DcTerm.identifier, WikipediaUtils.getImageLink(image.getUrl())); row.put(DwcTerm.locality, image.getTitle()); writer.addExtensionRecord(GbifTerm.Distribution, row); } } */ // image extension for (Image image : taxon.getImages()) { if (!StringUtils.isBlank(image.getUrl())) { imgScraper.scrape(image); row = Maps.newHashMap(); row.put(DcTerm.identifier, WikipediaUtils.getImageLink(image.getUrl())); row.put(DcTerm.references, WikipediaUtils.getImageWikiLink(image.getUrl())); row.put(DcTerm.title, image.getTitle()); row.put(DcTerm.creator, image.getAuthor()); row.put(DcTerm.created, image.getDate()); row.put(DcTerm.license, image.getLicense()); row.put(DcTerm.publisher, image.getPublisher()); row.put(DcTerm.source, image.getSource()); row.put(DcTerm.description, image.getDescription()); writer.addExtensionRecord(GbifTerm.Image, row); } } // sounds for (Sound sound : taxon.getSounds()) { if (!StringUtils.isBlank(sound.getUrl())) { imgScraper.scrape(sound); row = Maps.newHashMap(); row.put(DcTerm.identifier, WikipediaUtils.getImageLink(sound.getUrl())); row.put(DcTerm.references, WikipediaUtils.getImageWikiLink(sound.getUrl())); row.put(DcTerm.title, sound.getTitle()); row.put(DcTerm.creator, sound.getAuthor()); row.put(DcTerm.created, sound.getDate()); row.put(DcTerm.license, sound.getLicense()); row.put(DcTerm.publisher, sound.getPublisher()); row.put(DcTerm.source, sound.getSource()); row.put(DcTerm.description, sound.getDescription()); writer.addExtensionRecord(soundRowtype, row); } } // description extension for (Map.Entry<String, String> section : sections.entrySet()) { row = Maps.newHashMap(); row.put(DcTerm.type, section.getKey()); row.put(DcTerm.description, section.getValue()); row.put(DcTerm.language, lang.getIso2LetterCode()); row.put(DcTerm.license, TEXT_LICENSE); row.put(DcTerm.references, WikipediaUtils.getWikiLink(lang, page.getTitle(), section.getKey())); writer.addExtensionRecord(GbifTerm.Description, row); } // types extension if (!Strings.isNullOrEmpty(taxon.getTypeSpecies())) { row = Maps.newHashMap(); row.put(DwcTerm.typeStatus, "type species"); row.put(DwcTerm.scientificName, concatSciName(taxon.getTypeSpecies(), taxon.getTypeSpeciesAuthority())); writer.addExtensionRecord(GbifTerm.TypesAndSpecimen, row); } else if (!Strings.isNullOrEmpty(taxon.getTypeGenus())) { row = Maps.newHashMap(); row.put(DwcTerm.typeStatus, "type genus"); row.put(DwcTerm.scientificName, concatSciName(taxon.getTypeGenus(), taxon.getTypeGenusAuthority())); writer.addExtensionRecord(GbifTerm.TypesAndSpecimen, row); } // create individual records for each synonym int synIdx = 1; for (String synonym : taxon.getSynonyms()) { String synID = page.getId() + "-syn" + synIdx; writer.newRecord(synID); writer.addCoreColumn(DwcTerm.scientificName, synonym); writer.addCoreColumn(DwcTerm.acceptedNameUsage, taxon.getScientificName()); writer.addCoreColumn(DwcTerm.acceptedNameUsageID, page.getId()); writer.addCoreColumn(DwcTerm.taxonomicStatus, "synonym"); synIdx++; } }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public void OnOrderClicked(int isDelivery, int isTogo, String note) { // al guardar lo que hace es que guarda un objeto Sale con fecha, metodo // de pago y valor recibido. // despues toma currentOrder y dic saveItem(Context mContext,int type, // long item_id, double qty) para cada uno // al recuperar un sale se hace // price = 0.0; Date date = new Date(); String fecha = new SimpleDateFormat("dd/MM/yyyy - HH:mm:ss").format(date); //String fecha = DateFormat.getDateFormat(Initialactivity.this).format( //date);//from w ww . jav a 2s. c om // imprimir, conectar por wifi y enviar el texto arregladito a la app de // puente String mesa = "-DOMICILIO / PARA LLEVAR- O -MESA NO REGISTRADA-"; if (currentTable != null) { mesa = currentTable.getTable().getName().toUpperCase(Locale.getDefault()); } int lines = 0; StringBuilder factura = new StringBuilder(); String newline = "\r\n"; String title = "-----COMANDA----COMANDA-----" + "\r\n"; String tableheader = " Item Cantidad\r\n"; String notas = "NOTAS\r\n"; factura.append(title); factura.append(mesa + "\r\n"); lines++; factura.append(fecha); lines++; lines++; lines++; factura.append(newline); factura.append(tableheader); lines++; int j = 0; LinkedList<String> productos = new LinkedList<String>(); LinkedList<Integer> quantities = new LinkedList<Integer>(); LinkedList<Double> precios = new LinkedList<Double>(); Iterator<Entry<Registrable, Integer>> it = currentOrder.entrySet().iterator(); // Log.d(TAG,String.valueOf(currentOrder.size())); LinkedHashMap<Registrable, Integer> currentObjects = new LinkedHashMap<Registrable, Integer>(); 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; productos.add(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); int qtyL = String.valueOf(pairs.getValue()).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(pairs.getValue()); for (int k = 0; k < espacios2; k++) { factura.append(" "); } factura.append(newline); lines++; } factura.append(notas); factura.append(note); long startTime = System.currentTimeMillis(); if (currentSelectedAddTable > -1) {//esto significa que esta agregando la orden actual a otra existente, para la mesa que este seleccionada LinkedHashMap<Registrable, Integer> existingOrder = null; for (Map.Entry<LinkedHashMap<Registrable, Integer>, CurrentTable<Table, Integer>> tab : cookingOrdersTable .entrySet()) { if (tab.getValue().getTable().getName().equalsIgnoreCase(currentTable.getTable().getName())) { existingOrder = tab.getKey(); break; } } if (existingOrder != null) { int prevDelivery = cookingOrdersDelivery.get(existingOrder); int prevTogo = cookingOrdersTogo.get(existingOrder); Long prevTime = cookingOrdersTimes.get(existingOrder); cookingOrders.remove(existingOrder); cookingOrdersDelivery.remove(existingOrder); cookingOrdersTable.remove(existingOrder); cookingOrdersTimes.remove(existingOrder); cookingOrdersTogo.remove(existingOrder); Iterator<Entry<Registrable, Integer>> itnuevo = existingOrder.entrySet().iterator(); while (itnuevo.hasNext()) { LinkedHashMap.Entry<Registrable, Integer> pairs = (LinkedHashMap.Entry<Registrable, Integer>) itnuevo .next(); currentObjects.put(pairs.getKey(), pairs.getValue()); } cookingOrders.add(currentObjects); cookingOrdersDelivery.put(currentObjects, prevDelivery); cookingOrdersTogo.put(currentObjects, prevTogo); cookingOrdersTimes.put(currentObjects, prevTime); cookingOrdersTable.put(currentObjects, currentTable); } } else { cookingOrders.add(currentObjects); cookingOrdersDelivery.put(currentObjects, isDelivery); cookingOrdersTogo.put(currentObjects, isTogo); cookingOrdersTimes.put(currentObjects, startTime); if (currentTable != null) { cookingOrdersTable.put(currentObjects, currentTable); openTables.push(currentTable); } else { int[] coordinates = new int[2]; coordinates[0] = 0; coordinates[1] = 0; CurrentTable<Table, Integer> tabletemp = new CurrentTable<Table, Integer>( new Table("Domicilio / Para Llevar", 1, coordinates), 1); cookingOrdersTable.put(currentObjects, tabletemp); openTables.push(tabletemp); } } 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); /*if (!isTimerRunning) { startTimer(); }*/ currentOrder.clear(); currentTable = null; statusText.setText("En Espera de Abrir mesa."); makeTable("NA"); lines++; lines++; Boolean printed = true; try { if (mChatService.getState() == BluetoothChatService.STATE_CONNECTED) { try { mChatService.write(factura.toString().getBytes("x-UnicodeBig")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } else { printed = false; Toast.makeText(mContext, "No hay impresora 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("----COMANDA----"); formateado.append(PRINT_FEED_ONE_LINE); formateado.append(fecha); formateado.append(PRINT_FEED_ONE_LINE); formateado.append(mesa); formateado.append(PRINT_FEED_N_LINES); formateado.append((char) 0x03); formateado.append(JUSTIFICATION_LEFT); formateado.append("ITEM"); formateado.append(HORIZONTAL_TAB); formateado.append(HORIZONTAL_TAB); formateado.append(HORIZONTAL_TAB); formateado.append("CANTIDAD"); formateado.append(HORIZONTAL_TAB); formateado.append(SINGLE_WIDE_CHARACTERS); formateado.append(PRINT_FEED_ONE_LINE); for (String actual : productos) { int pos = productos.indexOf(actual); int cantidad = quantities.get(pos); formateado.append(actual); formateado.append(HORIZONTAL_TAB); formateado.append(HORIZONTAL_TAB); formateado.append(HORIZONTAL_TAB); formateado.append(cantidad); formateado.append(PRINT_FEED_ONE_LINE); } formateado.append(PRINT_FEED_N_LINES); formateado.append((char) 0x02); formateado.append(ITALIC_STYLE); formateado.append(notas); formateado.append(PRINT_FEED_ONE_LINE); formateado.append(note); formateado.append(ITALIC_CANCEL); formateado.append(FINALIZE_TICKET); formateado.append(PARTIAL_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()); } } }