Example usage for com.lowagie.text.pdf PdfPTable getDefaultCell

List of usage examples for com.lowagie.text.pdf PdfPTable getDefaultCell

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPTable getDefaultCell.

Prototype

public PdfPCell getDefaultCell() 

Source Link

Document

Gets the default PdfPCell that will be used as reference for all the addCell methods except addCell(PdfPCell).

Usage

From source file:com.qcadoo.mes.productionCounting.print.ProductionTrackingReportPdfService.java

License:Open Source License

private void addInputProducts(final Document document, final Entity productionTracking, final Entity technology,
        final Locale locale) throws DocumentException {
    document.add(//from  w w  w . jav a 2 s  . co m
            new Paragraph(
                    translationService
                            .translate("productionCounting.productionTrackingReport.report.paragraph2", locale),
                    FontUtils.getDejavuBold11Dark()));

    List<String> inputProductsTableHeader = Lists.newArrayList();

    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.number", locale));
    inputProductsTableHeader.add(translationService.translate(
            "productionCounting.productionTrackingReport.report.columnHeader.productionName", locale));
    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.type", locale));
    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.quantity", locale));
    inputProductsTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    PdfPTable inputProductsTable = pdfHelper.createTableWithHeader(5, inputProductsTableHeader, false);

    if (productionTracking
            .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS) != null) {
        List<Entity> trackingOperationProductInComponents = Lists.newArrayList(productionTracking
                .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS));
        Collections.sort(trackingOperationProductInComponents, new EntityProductInOutComparator());
        for (Entity trackingOperationProductInComponent : trackingOperationProductInComponents) {
            inputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductInComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductInComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NUMBER),
                                    FontUtils.getDejavuRegular9Dark()));
            inputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductInComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductInComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NAME),
                                    FontUtils.getDejavuRegular9Dark()));

            String type = technologyService.getProductType(trackingOperationProductInComponent
                    .getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT), technology);
            inputProductsTable.addCell(new Phrase(
                    translationService.translate("basic.product.globalTypeOfMaterial.value." + type, locale),
                    FontUtils.getDejavuRegular9Dark()));

            inputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            if (trackingOperationProductInComponent
                    .getField(TrackingOperationProductInComponentFields.USED_QUANTITY) == null) {
                inputProductsTable.addCell(new Phrase(L_N_A, FontUtils.getDejavuRegular9Dark()));
            } else {
                inputProductsTable.addCell(new Phrase(
                        numberService.format(trackingOperationProductInComponent
                                .getField(TrackingOperationProductInComponentFields.USED_QUANTITY)),
                        FontUtils.getDejavuRegular9Dark()));
            }
            inputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            inputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductInComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductInComponentFields.PRODUCT)
                                            .getStringField(ProductFields.UNIT),
                                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    document.add(inputProductsTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionTrackingReportPdfService.java

License:Open Source License

private void addOutputProducts(final Document document, final Entity productionTracking,
        final Entity technology, final Locale locale) throws DocumentException {
    document.add(/*  ww w.  j a v a2  s.c  om*/
            new Paragraph(
                    translationService
                            .translate("productionCounting.productionTrackingReport.report.paragraph3", locale),
                    FontUtils.getDejavuBold11Dark()));

    List<String> outputProductsTableHeader = Lists.newArrayList();

    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.number", locale));
    outputProductsTableHeader.add(translationService.translate(
            "productionCounting.productionTrackingReport.report.columnHeader.productionName", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.type", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionTrackingReport.report.columnHeader.quantity", locale));
    outputProductsTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    PdfPTable outputProductsTable = pdfHelper.createTableWithHeader(5, outputProductsTableHeader, false);

    if (productionTracking
            .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS) != null) {
        List<Entity> trackingOperationProductOutComponents = Lists.newArrayList(productionTracking
                .getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS));
        Collections.sort(trackingOperationProductOutComponents, new EntityProductInOutComparator());
        for (Entity trackingOperationProductOutComponent : trackingOperationProductOutComponents) {
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductOutComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NUMBER),
                                    FontUtils.getDejavuRegular9Dark()));
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductOutComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NAME),
                                    FontUtils.getDejavuRegular9Dark()));

            String type = technologyService.getProductType(trackingOperationProductOutComponent
                    .getBelongsToField(TrackingOperationProductOutComponentFields.PRODUCT), technology);
            outputProductsTable.addCell(new Phrase(
                    translationService.translate("basic.product.globalTypeOfMaterial.value." + type, locale),
                    FontUtils.getDejavuRegular9Dark()));

            outputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            if (trackingOperationProductOutComponent
                    .getField(TrackingOperationProductOutComponentFields.USED_QUANTITY) == null) {
                outputProductsTable.addCell(new Phrase(L_N_A, FontUtils.getDejavuRegular9Dark()));
            } else {
                outputProductsTable.addCell(new Phrase(
                        numberService.format(trackingOperationProductOutComponent
                                .getField(TrackingOperationProductOutComponentFields.USED_QUANTITY)),
                        FontUtils.getDejavuRegular9Dark()));
            }
            outputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    trackingOperationProductOutComponent
                                            .getBelongsToField(
                                                    TrackingOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.UNIT),
                                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    document.add(outputProductsTable);
}

From source file:com.qcadoo.mes.productionCountingWithCosts.pdf.ProductionBalanceWithCostsPdfService.java

License:Open Source License

private void addMaterialCost(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    List<String> materialCostTableHeader = Lists.newArrayList();

    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.productNumber",
            locale));//from  www  . j  a  v  a  2 s .c  om
    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.plannedCost",
            locale));
    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.registeredCost",
            locale));
    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.balance",
            locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();

    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.productNumber",
            locale), HeaderAlignment.LEFT);
    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.plannedCost",
            locale), HeaderAlignment.RIGHT);

    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.registeredCost",
            locale), HeaderAlignment.RIGHT);

    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.balance",
            locale), HeaderAlignment.RIGHT);

    List<Entity> technologyOperationProductInComponents = productionBalance
            .getHasManyField(ProductionBalanceFieldsPCWC.TECHNOLOGY_OPERATION_PRODUCT_IN_COMPONENTS);

    if (!technologyOperationProductInComponents.isEmpty()) {
        document.add(Chunk.NEWLINE);

        document.add(
                new Paragraph(
                        translationService.translate(
                                "productionCounting.productionBalance.report.table.materialCost", locale),
                        FontUtils.getDejavuBold11Dark()));

        technologyOperationProductInComponents = Lists.newLinkedList(technologyOperationProductInComponents);
        Collections.sort(technologyOperationProductInComponents, new EntityProductInOutComparator());

        PdfPTable productsTable = pdfHelper.createTableWithHeader(4, materialCostTableHeader, false,
                alignments);

        String currency = " " + currencyService.getCurrencyAlphabeticCode();

        for (Entity technologyOperationProductInComponent : technologyOperationProductInComponents) {
            productsTable.addCell(new Phrase(technologyOperationProductInComponent
                    .getBelongsToField(TechnologyOperationProductInCompFields.PRODUCT)
                    .getStringField(ProductFields.NUMBER), FontUtils.getDejavuRegular7Dark()));
            productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);

            String plannedCost = numberService.format(technologyOperationProductInComponent
                    .getField(TechnologyOperationProductInCompFields.PLANNED_COST));
            productsTable.addCell(new Phrase((plannedCost == null) ? L_NULL_OBJECT : (plannedCost + currency),
                    FontUtils.getDejavuRegular7Dark()));
            String registeredCost = numberService.format(technologyOperationProductInComponent
                    .getField(TechnologyOperationProductInCompFields.REGISTERED_COST));
            productsTable
                    .addCell(new Phrase((registeredCost == null) ? L_NULL_OBJECT : (registeredCost + currency),
                            FontUtils.getDejavuRegular7Dark()));
            String balance = numberService.format(technologyOperationProductInComponent
                    .getField(TechnologyOperationProductInCompFields.BALANCE));
            productsTable.addCell(new Phrase((balance == null) ? L_NULL_OBJECT : (balance + currency),
                    FontUtils.getDejavuRegular7Dark()));
            productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

        }

        productsTable.addCell(new Phrase(
                translationService.translate("productionCounting.productionBalance.report.total", locale),
                FontUtils.getDejavuRegular7Dark()));
        String plannedComponentsCosts = numberService.format(
                productionBalance.getDecimalField(ProductionBalanceFieldsPCWC.PLANNED_COMPONENTS_COSTS));
        productsTable.addCell(new Phrase(
                (plannedComponentsCosts == null) ? L_NULL_OBJECT : (plannedComponentsCosts + currency),
                FontUtils.getDejavuRegular7Dark()));
        String componentsCosts = numberService
                .format(productionBalance.getDecimalField(ProductionBalanceFieldsPCWC.COMPONENTS_COSTS));
        productsTable
                .addCell(new Phrase((componentsCosts == null) ? L_NULL_OBJECT : (componentsCosts + currency),
                        FontUtils.getDejavuRegular7Dark()));
        String componentsCostsBalance = numberService.format(
                productionBalance.getDecimalField(ProductionBalanceFieldsPCWC.COMPONENTS_COSTS_BALANCE));
        productsTable.addCell(new Phrase(
                (componentsCostsBalance == null) ? L_NULL_OBJECT : (componentsCostsBalance + currency),
                FontUtils.getDejavuRegular7Dark()));
        productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

        document.add(productsTable);
    }
}

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 av 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 ww. j a v a2 s .c  om
            .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   w  w  w .  j a v a  2s.c  om
            .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(/*from  w  w  w .j  av  a  2 s .co m*/
            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//from w w  w  .j a  v a 2s .  c om
            .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//from   w  w w.j  a v a2s.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  www .  j  av  a 2  s  . c  om*/
            .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);

}