Example usage for com.lowagie.text Paragraph Paragraph

List of usage examples for com.lowagie.text Paragraph Paragraph

Introduction

In this page you can find the example usage for com.lowagie.text Paragraph Paragraph.

Prototype

public Paragraph(float leading, String string) 

Source Link

Document

Constructs a Paragraph with a certain String and a certain leading.

Usage

From source file:com.qcadoo.mes.materialRequirements.print.pdf.MaterialRequirementPdfService.java

License:Open Source License

@Override
protected void buildPdfContent(final Document document, final Entity materialRequirement, final Locale locale)
        throws DocumentException {
    String documenTitle = translationService.translate("materialRequirements.materialRequirement.report.title",
            locale);/*w  ww .j a  va 2  s  . com*/
    String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale);

    pdfHelper.addDocumentHeader(document, "", documenTitle, documentAuthor,
            materialRequirement.getDateField(MaterialRequirementFields.DATE));

    addPanel(document, materialRequirement, locale);

    document.add(new Paragraph(
            translationService.translate("materialRequirements.materialRequirement.report.paragrah", locale),
            FontUtils.getDejavuBold11Dark()));

    Map<String, HeaderAlignment> orderHeadersWithAlignments = Maps.newLinkedHashMap();
    orderHeadersWithAlignments.put(translationService.translate("orders.order.number.label", locale),
            HeaderAlignment.LEFT);
    orderHeadersWithAlignments.put(translationService.translate("orders.order.name.label", locale),
            HeaderAlignment.LEFT);
    orderHeadersWithAlignments.put(translationService.translate("orders.order.product.label", locale),
            HeaderAlignment.LEFT);
    orderHeadersWithAlignments.put(
            translationService
                    .translate("materialRequirements.materialRequirement.report.order.plannedQuantity", locale),
            HeaderAlignment.RIGHT);
    orderHeadersWithAlignments.put(translationService.translate(
            "materialRequirements.materialRequirement.report.product.unit", locale), HeaderAlignment.LEFT);

    addOrderSeries(document, materialRequirement, orderHeadersWithAlignments);

    document.add(new Paragraph(
            translationService.translate("materialRequirements.materialRequirement.report.paragrah2", locale),
            FontUtils.getDejavuBold11Dark()));

    Map<String, HeaderAlignment> productHeadersWithAlignments = Maps.newLinkedHashMap();
    productHeadersWithAlignments.put(translationService.translate("basic.product.number.label", locale),
            HeaderAlignment.LEFT);
    productHeadersWithAlignments.put(translationService.translate("basic.product.name.label", locale),
            HeaderAlignment.LEFT);
    productHeadersWithAlignments.put(
            translationService.translate("technologies.technologyOperationComponent.quantity.label", locale),
            HeaderAlignment.RIGHT);
    productHeadersWithAlignments.put(translationService.translate(
            "materialRequirements.materialRequirement.report.product.unit", locale), HeaderAlignment.LEFT);

    addTechnologySeries(document, materialRequirement, productHeadersWithAlignments);
}

From source file:com.qcadoo.mes.orders.print.OrderReportPdf.java

License:Open Source License

private void addTableToDocument(Document document, Entity orderEntity, Locale locale, String headerKey,
        Map<String, String> values) throws DocumentException {
    document.add(/*from   w w w. jav  a2 s .  com*/
            new Paragraph(translationService.translate(headerKey, locale), FontUtils.getDejavuBold10Dark()));

    Map<String, HeaderAlignment> headerValues = Maps.newLinkedHashMap();
    for (String key : values.keySet()) {
        headerValues.put(translationService.translate(String.format(L_TRANSLATION_PATH, key), locale),
                HeaderAlignment.LEFT);
    }

    PdfPTable table = pdfHelper.createTableWithHeader(values.size(), Lists.newArrayList(headerValues.keySet()),
            false, headerValues);
    table.getDefaultCell().disableBorderSide(PdfPCell.RIGHT);
    table.getDefaultCell().disableBorderSide(PdfPCell.LEFT);
    table.setHeaderRows(1);

    for (String value : values.values()) {
        table.addCell(createCell(value, Element.ALIGN_LEFT));
    }

    table.setSpacingAfter(20);

    document.add(table);
}

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

License:Open Source License

public void addInputProductsBalance(final Document document, final Entity productionBalance,
        final Locale locale) throws DocumentException {
    List<String> inputProductsTableHeader = Lists.newArrayList();

    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.number", locale));
    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.productionName", locale));
    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedQuantity", locale));
    inputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.usedQuantity", locale));
    inputProductsTableHeader//w  w w  .  ja  va 2  s .  c om
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));
    inputProductsTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate(
            "productionCounting.productionBalance.report.columnHeader.number", locale), HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.productionName", locale),
            HeaderAlignment.LEFT);
    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.plannedQuantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(
            translationService
                    .translate("productionCounting.productionBalance.report.columnHeader.usedQuantity", locale),
            HeaderAlignment.RIGHT);
    alignments.put(translationService.translate(PCPBRCHB_LITERAL, locale), HeaderAlignment.RIGHT);
    alignments.put(translationService.translate("basic.product.unit.label", locale), HeaderAlignment.LEFT);

    List<Entity> inputProductsList = productionBalance
            .getHasManyField(ProductionBalanceFields.BALANCE_OPERATION_PRODUCT_IN_COMPONENTS);

    if (!inputProductsList.isEmpty()) {
        document.add(new Paragraph(
                translationService.translate("productionCounting.productionBalance.report.paragraph", locale),
                FontUtils.getDejavuBold11Dark()));

        inputProductsList = Lists.newLinkedList(inputProductsList);

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

        for (Entity inputProduct : inputProductsList) {
            inputProductsTable.addCell(
                    new Phrase(inputProduct.getBelongsToField(BalanceOperationProductInComponentFields.PRODUCT)
                            .getStringField(ProductFields.NUMBER), FontUtils.getDejavuRegular9Dark()));
            inputProductsTable.addCell(
                    new Phrase(inputProduct.getBelongsToField(BalanceOperationProductInComponentFields.PRODUCT)
                            .getStringField(ProductFields.NAME), FontUtils.getDejavuRegular9Dark()));

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

        document.add(inputProductsTable);
    }
}

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

License:Open Source License

public void addOutputProductsBalance(final Document document, final Entity productionBalance,
        final Locale locale) throws DocumentException {

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

    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.number", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.productionName", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedQuantity", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.producedQuantity", locale));
    outputProductsTableHeader//from www.  ja  v  a2 s  .  co  m
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));
    outputProductsTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate(
            "productionCounting.productionBalance.report.columnHeader.number", locale), HeaderAlignment.LEFT);

    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.productionName", locale),
            HeaderAlignment.LEFT);

    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.plannedQuantity", locale),
            HeaderAlignment.RIGHT);

    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.producedQuantity", locale),
            HeaderAlignment.RIGHT);

    alignments.put(translationService.translate(PCPBRCHB_LITERAL, locale), HeaderAlignment.RIGHT);

    alignments.put(translationService.translate("basic.product.unit.label", locale), HeaderAlignment.LEFT);

    List<Entity> outputProductsList = productionBalance
            .getHasManyField(ProductionBalanceFields.BALANCE_OPERATION_PRODUCT_OUT_COMPONENTS);

    if (!outputProductsList.isEmpty()) {
        document.add(Chunk.NEWLINE);
        document.add(new Paragraph(
                translationService.translate("productionCounting.productionBalance.report.paragraph2", locale),
                FontUtils.getDejavuBold11Dark()));

        outputProductsList = Lists.newLinkedList(outputProductsList);

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

        for (Entity outputProduct : outputProductsList) {
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    outputProduct
                                            .getBelongsToField(
                                                    BalanceOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NUMBER),
                                    FontUtils.getDejavuRegular9Dark()));
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    outputProduct
                                            .getBelongsToField(
                                                    BalanceOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NAME),
                                    FontUtils.getDejavuRegular9Dark()));

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

        document.add(outputProductsTable);
    }
}

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

License:Open Source License

public void addMachineTimeBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);/*from  w w  w .  j a  v a2  s .com*/
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph3", locale),
            FontUtils.getDejavuBold11Dark()));

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

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedDuration", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredTime", locale));
    operationsTimeTableHeader
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable machineTimeTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationTimeComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_TIME_COMPONENTS);

    if (!operationTimeComponents.isEmpty()) {
        for (Entity operationTimeComponent : operationTimeComponents) {
            machineTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            machineTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.PLANNED_MACHINE_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(
                            operationTimeComponent.getIntegerField(OperationTimeComponentFields.MACHINE_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.MACHINE_TIME_BALANCE)),
                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    machineTimeTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_MACHINE_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME_BALANCE)),
            FontUtils.getDejavuRegular9Dark()));

    document.add(machineTimeTable);
}

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

License:Open Source License

public void addLaborTimeBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);//from   w  w  w  .jav  a2  s  . c om
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph4", locale),
            FontUtils.getDejavuBold11Dark()));

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

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedDuration", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredTime", locale));
    operationsTimeTableHeader
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable laborTimeTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationTimeComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_TIME_COMPONENTS);

    if (!operationTimeComponents.isEmpty()) {
        for (Entity operationTimeComponent : operationTimeComponents) {
            laborTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            laborTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.PLANNED_LABOR_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(
                            operationTimeComponent.getIntegerField(OperationTimeComponentFields.LABOR_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.LABOR_TIME_BALANCE)),
                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    laborTimeTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_LABOR_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService
                    .convertTimeToString(productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME_BALANCE)),
            FontUtils.getDejavuRegular9Dark()));

    document.add(laborTimeTable);
}

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

License:Open Source License

public void addPieceworkBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);/*from w  w  w. j  ava  2  s .com*/
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph5", locale),
            FontUtils.getDejavuBold11Dark()));

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

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedCycles", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredCycles", locale));
    operationsTimeTableHeader
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable pieceworkTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationPieceworkComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_PIECEWORK_COMPONENTS);

    BigDecimal totalPlannedCycles = BigDecimal.ZERO;
    BigDecimal totalCycles = BigDecimal.ZERO;
    BigDecimal totalCyclesBalance = BigDecimal.ZERO;

    if (!operationPieceworkComponents.isEmpty()) {
        for (Entity operationPieceworkComponent : operationPieceworkComponents) {
            BigDecimal plannedCycles = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.PLANNED_CYCLES);
            BigDecimal cycles = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.CYCLES);
            BigDecimal cyclesBalance = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.CYCLES_BALANCE);

            pieceworkTable
                    .addCell(new Phrase(
                            operationPieceworkComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            pieceworkTable
                    .addCell(new Phrase(
                            operationPieceworkComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(
                    new Phrase(numberService.format(plannedCycles), FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(new Phrase(numberService.format(cycles), FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(
                    new Phrase(numberService.format(cyclesBalance), FontUtils.getDejavuRegular9Dark()));

            totalPlannedCycles = totalPlannedCycles.add(plannedCycles, numberService.getMathContext());
            totalCycles = totalPlannedCycles.add(cycles, numberService.getMathContext());
            totalCyclesBalance = totalPlannedCycles.add(cyclesBalance, numberService.getMathContext());
        }
    }

    pieceworkTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    pieceworkTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    pieceworkTable
            .addCell(new Phrase(numberService.format(totalPlannedCycles), FontUtils.getDejavuRegular9Dark()));
    pieceworkTable.addCell(new Phrase(numberService.format(totalCycles), FontUtils.getDejavuRegular9Dark()));
    pieceworkTable
            .addCell(new Phrase(numberService.format(totalCyclesBalance), FontUtils.getDejavuRegular9Dark()));

    document.add(pieceworkTable);
}

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

License:Open Source License

public void addTimeBalanceAsPanel(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);//  w w  w.  j a  v a 2s  . c  om
    document.add(
            new Paragraph(
                    translationService.translate(
                            "productionCounting.productionBalanceDetails.window.productionTime", locale),
                    FontUtils.getDejavuBold11Dark()));

    PdfPTable timePanel = pdfHelper.createPanelTable(3);

    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.plannedMachineTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_MACHINE_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.machineTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.machineTimeBalance",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME_BALANCE)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.plannedLaborTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_LABOR_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.laborTime",
            locale) + ":",
            timeConverterService
                    .convertTimeToString(productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.laborTimeBalance",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME_BALANCE)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);

    timePanel.setSpacingBefore(10);
    document.add(timePanel);
}

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

License:Open Source License

private void addProductionTracking(final Document document, final Entity productionTracking,
        final Locale locale) throws DocumentException {
    Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);

    document.add(new Paragraph(
            translationService.translate("productionCounting.productionTrackingReport.report.paragraph", locale)
                    + " " + productionTracking.getStringField(ProductionTrackingFields.NUMBER),
            FontUtils.getDejavuBold19Dark()));

    PdfPTable panelTable = pdfHelper.createPanelTable(2);
    addTableCellAsTable(panelTable,// w ww  .  j  av  a 2  s .  c o m
            translationService
                    .translate("productionCounting.productionTrackingReport.report.panel.trackingType", locale),
            productionTracking.getBooleanField(ProductionTrackingFields.LAST_TRACKING)
                    ? translationService.translate(
                            "productionCounting.productionTrackingReport.report.panel.trackingType.final",
                            locale)
                    : translationService.translate(
                            "productionCounting.productionTrackingReport.report.panel.trackingType.partial",
                            locale),
            null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    if (productionCountingService.isTypeOfProductionRecordingCumulated(
            order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING))) {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.operationAndLevel", locale),
                L_N_A, null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    } else {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.operationAndLevel", locale),
                productionTracking.getBelongsToField(ProductionTrackingFields.TECHNOLOGY_OPERATION_COMPONENT)
                        .getStringField(TechnologyOperationComponentFields.NODE_NUMBER)
                        + " "
                        + productionTracking
                                .getBelongsToField(ProductionTrackingFields.TECHNOLOGY_OPERATION_COMPONENT)
                                .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                .getStringField(OperationFields.NAME),
                null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.dateAndTime", locale),
                new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, locale)
                        .format(productionTracking.getHasManyField(ProductionTrackingFields.STATE_CHANGES)
                                .get(0).getDateField(ProductionTrackingStateChangeFields.DATE_AND_TIME)),
                null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        if (order.getBooleanField(OrderFieldsPC.REGISTER_PRODUCTION_TIME)) {
            addTableCellAsTable(panelTable, translationService.translate(
                    "productionCounting.productionTrackingReport.report.panel.machineOperationTime", locale),
                    timeConverterService.convertTimeToString(
                            productionTracking.getIntegerField(ProductionTrackingFields.MACHINE_TIME)),
                    null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        } else {
            addTableCellAsTable(panelTable, translationService.translate(
                    "productionCounting.productionTrackingReport.report.panel.machineOperationTime", locale),
                    L_N_A, null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
        }
    }
    addTableCellAsTable(panelTable,
            translationService.translate("productionCounting.productionTrackingReport.report.panel.worker",
                    locale),
            productionTracking.getHasManyField(ProductionTrackingFields.STATE_CHANGES).get(0)
                    .getStringField(ProductionTrackingStateChangeFields.WORKER),
            null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    if (order.getBooleanField(OrderFieldsPC.REGISTER_PRODUCTION_TIME)) {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.laborOperationTime", locale),
                timeConverterService.convertTimeToString(
                        productionTracking.getIntegerField(ProductionTrackingFields.LABOR_TIME)),
                null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    } else {
        addTableCellAsTable(panelTable,
                translationService.translate(
                        "productionCounting.productionTrackingReport.report.panel.laborOperationTime", locale),
                L_N_A, null, FontUtils.getDejavuBold9Dark(), FontUtils.getDejavuBold9Dark(), null);
    }
    panelTable.setSpacingBefore(10);
    document.add(panelTable);

    Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);

    if (order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT)) {
        addInputProducts(document, productionTracking, technology, locale);
    }

    if (order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT)) {
        addOutputProducts(document, productionTracking, technology, locale);
    }
}

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   ww w. j  a  va 2  s  . c  o 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);
}