List of usage examples for com.lowagie.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.lowagie.text Element ALIGN_RIGHT.
Click Source Link
From source file:com.qcadoo.mes.productionCountingWithCosts.pdf.ProductionBalanceWithCostsPdfService.java
License:Open Source License
private void addCostsBalance(final String type, final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { List<String> tableHeader = Lists.newArrayList(); tableHeader.add(translationService.translate( "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationLevel", locale));// w w w . j a v a 2 s . c o m tableHeader.add(translationService.translate( "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationName", locale)); tableHeader.add(translationService.translate( "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.planned" + upperCaseFirstLetter(type, locale) + L_COSTS, locale)); tableHeader.add(translationService .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column." + type + L_COSTS, locale)); tableHeader.add(translationService .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column." + type + "CostsBalance", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate( "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationLevel", locale), HeaderAlignment.LEFT); alignments.put(translationService.translate( "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationName", locale), HeaderAlignment.LEFT); alignments.put(translationService.translate( "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.planned" + upperCaseFirstLetter(type, locale) + L_COSTS, locale), HeaderAlignment.RIGHT); alignments.put(translationService .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column." + type + L_COSTS, locale), HeaderAlignment.RIGHT); alignments.put(translationService .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column." + type + "CostsBalance", locale), HeaderAlignment.RIGHT); boolean isPiecework = "cycles".equals(type); List<Entity> operationComponents = productionBalance .getHasManyField(isPiecework ? ProductionBalanceFieldsPCWC.OPERATION_PIECEWORK_COST_COMPONENTS : ProductionBalanceFieldsPCWC.OPERATION_COST_COMPONENTS); if (!operationComponents.isEmpty()) { document.add(Chunk.NEWLINE); document.add(new Paragraph(translationService.translate( "productionCounting.productionBalanceDetails.window.workCostsTab." + type + L_COSTS, locale), FontUtils.getDejavuBold11Dark())); operationComponents = Lists.newLinkedList(operationComponents); Collections.sort(operationComponents, new EntityProductionTrackingOperationComparator()); PdfPTable costsTable = pdfHelper.createTableWithHeader(5, tableHeader, false, alignments); String currency = " " + currencyService.getCurrencyAlphabeticCode(); for (Entity operationComponent : operationComponents) { costsTable.addCell(new Phrase( operationComponent.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT) .getStringField(TechnologyOperationComponentFields.NODE_NUMBER), FontUtils.getDejavuRegular7Dark())); costsTable.addCell(new Phrase(operationComponent.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT) .getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getStringField(OperationFields.NAME), FontUtils.getDejavuRegular7Dark())); costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); String plannedCost = numberService.format( operationComponent.getField("planned" + upperCaseFirstLetter(type, locale) + L_COSTS)); costsTable.addCell(new Phrase((plannedCost == null) ? L_NULL_OBJECT : (plannedCost + currency), FontUtils.getDejavuRegular7Dark())); String registeredCost = numberService.format(operationComponent.getField(type + L_COSTS)); costsTable .addCell(new Phrase((registeredCost == null) ? L_NULL_OBJECT : (registeredCost + currency), FontUtils.getDejavuRegular7Dark())); String balance = numberService.format(operationComponent.getField(type + L_COSTS_BALANCE)); costsTable.addCell(new Phrase((balance == null) ? L_NULL_OBJECT : (balance + currency), FontUtils.getDejavuRegular7Dark())); costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } costsTable.addCell(new Phrase( translationService.translate("productionCounting.productionBalance.report.total", locale), FontUtils.getDejavuRegular7Dark())); costsTable.addCell(new Phrase("", FontUtils.getDejavuRegular7Dark())); costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); String plannedCosts = numberService.format( productionBalance.getDecimalField(L_PLANNED + upperCaseFirstLetter(type, locale) + L_COSTS)); costsTable.addCell(new Phrase((plannedCosts == null) ? L_NULL_OBJECT : (plannedCosts + currency), FontUtils.getDejavuRegular7Dark())); String registeredCosts = numberService.format(productionBalance.getDecimalField(type + L_COSTS)); costsTable.addCell(new Phrase((registeredCosts == null) ? L_NULL_OBJECT : (registeredCosts + currency), FontUtils.getDejavuRegular7Dark())); String costsBalance = numberService.format(productionBalance.getDecimalField(type + L_COSTS_BALANCE)); costsTable.addCell(new Phrase((costsBalance == null) ? L_NULL_OBJECT : (costsBalance + currency), FontUtils.getDejavuRegular7Dark())); costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); document.add(costsTable); } }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForBatchPdfView.java
License:Open Source License
private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities, final Locale locale) throws DocumentException { List<String> qualityHeader = new ArrayList<String>(); qualityHeader// w w w. j a v a 2 s . co m .add(translationService.translate("qualityControls.qualityControl.report.product.number", locale)); qualityHeader.add(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.controlledQuantity.label", locale)); qualityHeader.add(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.rejectedQuantity.label", locale)); qualityHeader.add(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.acceptedDefectsQuantity.label", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate("qualityControls.qualityControl.report.product.number", locale), HeaderAlignment.LEFT); alignments.put(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.controlledQuantity.label", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.rejectedQuantity.label", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControlsForBatch.qualityControlForBatchDetails.window.mainTab.qualityControlForBatch.acceptedDefectsQuantity.label", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(4, qualityHeader, false, alignments); for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) { table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell( new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForBatchPdfView.java
License:Open Source License
private void addProductSeries(final Document document, final Entry<Entity, List<Entity>> entry, final Locale locale) throws DocumentException { document.add(qualityControlsReportService.prepareTitle(entry.getKey(), locale, "batch")); List<String> productHeader = new ArrayList<String>(); productHeader/*from ww w. j a v a2 s . c o m*/ .add(translationService.translate("qualityControls.qualityControl.report.batch.number", locale)); productHeader .add(translationService.translate("qualityControls.qualityControl.report.control.number", locale)); productHeader.add( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale)); productHeader.add( translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale)); productHeader.add(translationService .translate("qualityControls.qualityControl.report.accepted.defects.quantity", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate("qualityControls.qualityControl.report.batch.number", locale), HeaderAlignment.LEFT); alignments.put(translationService.translate("qualityControls.qualityControl.report.control.number", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControls.qualityControl.report.accepted.defects.quantity", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(5, productHeader, false, alignments); List<Entity> sortedOrders = entry.getValue(); Collections.sort(sortedOrders, new EntityBatchNumberComparator()); for (Entity entity : sortedOrders) { table.addCell( new Phrase(entity.getStringField("batchNr") == null ? "" : entity.getStringField("batchNr"), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(entity.getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(entity.getDecimalField("controlledQuantity")), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(numberService.format(entity.getDecimalField("rejectedQuantity")), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(numberService.format(entity.getDecimalField("acceptedDefectsQuantity")), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForOperationPdfView.java
License:Open Source License
private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities, final Locale locale) throws DocumentException { List<String> qualityHeader = new ArrayList<String>(); qualityHeader.add(// w w w . j av a 2s . com translationService.translate("qualityControls.qualityControl.report.operation.number", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put( translationService.translate("qualityControls.qualityControl.report.operation.number", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(5, qualityHeader, false, alignments); for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) { table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("nodeNumber"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell( new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(3)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForOrderPdfView.java
License:Open Source License
private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities, final Locale locale) throws DocumentException { List<String> qualityHeader = new ArrayList<String>(); qualityHeader/* ww w.java 2 s. co m*/ .add(translationService.translate("qualityControls.qualityControl.report.product.number", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale)); qualityHeader .add(translationService.translate("qualityControls.qualityControl.report.done.quantity", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale)); qualityHeader.add( translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate("qualityControls.qualityControl.report.product.number", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate("qualityControls.qualityControl.report.done.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.correct.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.incorrect.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.objective.quantity", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(6, qualityHeader, false, alignments); for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) { table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell( new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(4)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(3)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForUnitPdfView.java
License:Open Source License
private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities, final Locale locale) throws DocumentException { List<String> qualityHeader = new ArrayList<String>(); qualityHeader// w w w . j a v a2 s. c o m .add(translationService.translate("qualityControls.qualityControl.report.product.number", locale)); qualityHeader.add(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label", locale)); qualityHeader.add(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label", locale)); qualityHeader.add(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate("qualityControls.qualityControl.report.product.number", locale), HeaderAlignment.LEFT); alignments.put(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(4, qualityHeader, false, alignments); for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) { table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell( new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForUnitPdfView.java
License:Open Source License
private void addProductSeries(final Document document, final Entry<Entity, List<Entity>> entry, final Locale locale) throws DocumentException { document.add(qualityControlsReportService.prepareTitle(entry.getKey(), locale, "unit")); List<String> productHeader = new ArrayList<String>(); productHeader//from w w w .j av a2 s.co m .add(translationService.translate("qualityControls.qualityControl.report.control.number", locale)); productHeader.add( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale)); productHeader.add( translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale)); productHeader.add(translationService .translate("qualityControls.qualityControl.report.accepted.defects.quantity", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate("qualityControls.qualityControl.report.control.number", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControls.qualityControl.report.accepted.defects.quantity", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(4, productHeader, false, alignments); List<Entity> sortedOrders = entry.getValue(); Collections.sort(sortedOrders, new EntityNumberComparator()); for (Entity entity : sortedOrders) { table.addCell(new Phrase(entity.getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(entity.getField("controlledQuantity")), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(numberService.format(entity.getField("rejectedQuantity")), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(numberService.format(entity.getField("acceptedDefectsQuantity")), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java
License:Open Source License
private void addBalance(final Document document, final Entity simpleMaterialBalance, final Locale locale) throws DocumentException { document.add(new Paragraph( translationService.translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah", locale), FontUtils.getDejavuBold11Dark())); List<String> simpleMaterialBalanceTableHeader = new ArrayList<String>(); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale)); simpleMaterialBalanceTableHeader.add(translationService.translate("basic.product.unit.label", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(/* ww w . j a v a2s . c o m*/ translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale), HeaderAlignment.LEFT); alignments.put(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate("basic.product.unit.label", locale), HeaderAlignment.LEFT); PdfPTable table = pdfHelper.createTableWithHeader(6, simpleMaterialBalanceTableHeader, false, alignments); List<Entity> simpleMaterialBalanceOrdersComponents = simpleMaterialBalance .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_ORDERS_COMPONENTS); MrpAlgorithm mrpAlgorithm = MrpAlgorithm.parseString(simpleMaterialBalance.getStringField("mrpAlgorithm")); Map<Long, BigDecimal> neededProductQuantities = productQuantitiesService .getNeededProductQuantitiesForComponents(simpleMaterialBalanceOrdersComponents, mrpAlgorithm); List<Entity> simpleMaterialBalanceLocationComponents = simpleMaterialBalance .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_LOCATIONS_COMPONENTS); // TODO LUPO fix comparator // products = SortUtil.sortMapUsingComparator(products, new EntityNumberComparator()); for (Entry<Long, BigDecimal> neededProductQuantity : neededProductQuantities.entrySet()) { Entity product = productQuantitiesService.getProduct(neededProductQuantity.getKey()); table.addCell(new Phrase(product.getField(L_NUMBER).toString(), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(product.getField(L_NAME).toString(), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(neededProductQuantity.getValue()), FontUtils.getDejavuRegular7Dark())); BigDecimal available = BigDecimal.ZERO; for (Entity simpleMaterialBalanceLocationComponent : simpleMaterialBalanceLocationComponents) { available = available.add(materialFlowService.calculateShouldBeInLocation( simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getId(), product.getId(), (Date) simpleMaterialBalance.getField(L_DATE))); } table.addCell(new Phrase(numberService.format(available), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase( numberService.format( available.subtract(neededProductQuantity.getValue(), numberService.getMathContext())), FontUtils.getDejavuBold7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(new Phrase(product.getField(L_UNIT).toString(), FontUtils.getDejavuRegular7Dark())); } document.add(table); }
From source file:com.qcadoo.mes.technologies.print.TechnologiesTechnologyDetailsPdfView.java
License:Open Source License
@Override protected final String addContent(final Document document, final Map<String, Object> model, final Locale locale, final PdfWriter writer) throws DocumentException, IOException { checkState(model.get("id") != null, "Unable to generate report for unsaved technology! (missing id)"); String documentTitle = translationService .translate("technologies.technologiesTechnologyDetails.report.title", locale); String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, new Date()); DataDefinition technologyDD = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY); Entity technology = technologyDD.get(valueOf(model.get("id").toString())); Map<String, String> panelTableValues = newLinkedHashMap(); panelTableValues.put(TechnologyFields.NAME, technology.getStringField(TechnologyFields.NAME)); panelTableValues.put(TechnologyFields.NUMBER, technology.getStringField(TechnologyFields.NUMBER)); panelTableValues.put(TechnologyFields.PRODUCT, technology.getBelongsToField(TechnologyFields.PRODUCT).getStringField(ProductFields.NAME)); panelTableValues.put("default", technology.getBooleanField(TechnologyFields.MASTER) ? translationService.translate("qcadooView.true", locale) : translationService.translate("qcadooView.false", locale)); panelTableValues.put(TechnologyFields.DESCRIPTION, technology.getStringField(TechnologyFields.DESCRIPTION)); PdfPTable panelTable = pdfHelper.createPanelTable(2); for (Map.Entry<String, String> panelEntry : panelTableValues.entrySet()) { pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate( "technologies.technologiesTechnologyDetails.report.panel.technology." + panelEntry.getKey(), locale), panelEntry.getValue()); }// w w w. ja v a2 s .c o m panelTable.setSpacingAfter(20); panelTable.setSpacingBefore(20); document.add(panelTable); List<String> technologyDetailsTableHeader = new ArrayList<String>(); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale), HeaderAlignment.LEFT); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale), HeaderAlignment.LEFT); PdfPTable table = pdfHelper.createTableWithHeader(7, technologyDetailsTableHeader, false, alignments); EntityTree technologyTree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); treeNumberingService.generateTreeNumbers(technologyTree); List<Entity> technologyOperationComponents = entityTreeUtilsService.getSortedEntities(technologyTree); for (Entity technologyOperationComponent : technologyOperationComponents) { String nodeNumber = technologyOperationComponent .getStringField(TechnologyOperationComponentFields.NODE_NUMBER); String operationName = technologyOperationComponent .getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getStringField(OperationFields.NAME); List<Entity> operationProductComponents = newArrayList(); operationProductComponents.addAll(technologyOperationComponent .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS)); operationProductComponents.addAll(technologyOperationComponent .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS)); for (Entity operationProductComponent : operationProductComponents) { Entity product = operationProductComponent.getBelongsToField(L_PRODUCT); String productType = "technologies.technologiesTechnologyDetails.report.direction.out"; if (operationProductComponent.getDataDefinition().getName().equals("operationProductInComponent")) { productType = "technologies.technologiesTechnologyDetails.report.direction.in"; } table.addCell(new Phrase(nodeNumber, FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(operationName, FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(translationService.translate(productType, locale), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(product.getStringField(ProductFields.NUMBER), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(product.getStringField(ProductFields.NAME), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(operationProductComponent.getField(L_QUANTITY)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell( new Phrase(product.getStringField(ProductFields.UNIT), FontUtils.getDejavuRegular7Dark())); } } document.add(table); return translationService.translate("technologies.technologiesTechnologyDetails.report.fileName", locale); }
From source file:com.qcadoo.mes.warehouseMinimalState.print.DocumentPdf.java
License:Open Source License
public void addSmallCell(PdfPTable table, BigDecimal content) { PdfPCell cell = new PdfPCell(table.getDefaultCell()); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); String value = numberService.formatWithMinimumFractionDigits(content, 0); cell.setPhrase(new Phrase(value, FontUtils.getDejavuRegular7Dark())); table.addCell(cell);/*from w w w. j av a 2s . c o m*/ }