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.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(/*from   w w  w.ja  v a2s . 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 addProductionCosts(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);/*from w w w .j  ava 2 s .c o  m*/
    document.add(
            new Paragraph(
                    translationService.translate(
                            "productionCounting.productionBalance.report.panel.productionCosts", locale),
                    FontUtils.getDejavuBold11Dark()));

    PdfPTable costsPanel = pdfHelper.createPanelTable(3);

    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machinePlanned",
            productionBalance.getField(ProductionBalanceFieldsPCWC.PLANNED_MACHINE_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machineRegistered",
            productionBalance.getField(ProductionBalanceFieldsPCWC.MACHINE_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machineBalance",
            productionBalance.getField(ProductionBalanceFieldsPCWC.MACHINE_COSTS_BALANCE), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborPlanned",
            productionBalance.getField(ProductionBalanceFieldsPCWC.PLANNED_LABOR_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborRegistered",
            productionBalance.getField(ProductionBalanceFieldsPCWC.LABOR_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborBalance",
            productionBalance.getField(ProductionBalanceFieldsPCWC.LABOR_COSTS_BALANCE), locale);

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

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));/*  ww w.  j  av  a2s  .  c  o m*/
    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  .ja  v  a2s .c om
    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.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(/*  w  w w.j  a  va 2 s .co 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.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java

License:Open Source License

private void addOrders(final Document document, final Entity simpleMaterialBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);//www . j a v a 2  s. c om
    document.add(new Paragraph(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah2", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> simpleMaterialBalanceOrdersTableHeader = new ArrayList<String>();
    simpleMaterialBalanceOrdersTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale));
    simpleMaterialBalanceOrdersTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale));

    PdfPTable table = pdfHelper.createTableWithHeader(2, simpleMaterialBalanceOrdersTableHeader, false);
    List<Entity> orders = new ArrayList<Entity>(
            simpleMaterialBalance.getHasManyField(L_SIMPLE_MATERIAL_BALANCE_ORDERS_COMPONENTS));
    Collections.sort(orders, new EntityOrderNumberComparator());
    for (Entity e : orders) {
        table.addCell(new Phrase(e.getBelongsToField(L_ORDER).getStringField(L_NUMBER),
                FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(e.getBelongsToField(L_ORDER).getStringField(L_NAME),
                FontUtils.getDejavuRegular7Dark()));
    }
    document.add(table);
}

From source file:com.qcadoo.mes.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java

License:Open Source License

private void addLocations(final Document document, final Entity simpleMaterialBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);//from   www  .  j a  va 2s.  c o  m
    document.add(new Paragraph(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah3", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> simpleMaterialBalanceLocationTableHeader = new ArrayList<String>();
    simpleMaterialBalanceLocationTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale));
    simpleMaterialBalanceLocationTableHeader.add(translationService
            .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale));

    PdfPTable table = pdfHelper.createTableWithHeader(2, simpleMaterialBalanceLocationTableHeader, false);
    List<Entity> simpleMaterialBalanceLocationComponents = new ArrayList<Entity>(
            simpleMaterialBalance.getHasManyField(L_SIMPLE_MATERIAL_BALANCE_LOCATIONS_COMPONENTS));
    Collections.sort(simpleMaterialBalanceLocationComponents, new EntityLocationNumberComparator());
    for (Entity simpleMaterialBalanceLocationComponent : simpleMaterialBalanceLocationComponents) {
        table.addCell(new Phrase(
                simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getStringField(L_NUMBER),
                FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(
                simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getStringField(L_NAME),
                FontUtils.getDejavuRegular7Dark()));
    }
    document.add(table);
}

From source file:com.qcadoo.mes.warehouseMinimalState.print.DocumentPdf.java

License:Open Source License

private void addWarehouseTable(Document document, Entity warehouse) throws DocumentException {
    String subtitle = translationService.translate("warehouseMinimalState.report.subtitle", locale,
            warehouse.getStringField(LocationFields.NUMBER), warehouse.getStringField(LocationFields.NAME));

    PdfPTable warehouseTable = createTable();

    List<Entity> stocks = warehouseMinimalStateHelper.getWarehouseStockWithTooSmallMinState(warehouse);
    Map<Long, Entity> stocksByProduct = stocks.stream()
            .collect(Collectors.toMap(res -> res.getBelongsToField("product").getId(), (res) -> res));
    Collection<Entity> minimumStates = warehouseToMinimumStateMap.get(warehouse.getId());
    minimumStates = minimumStates.stream()
            .sorted((ms1, ms2) -> ms1.getBelongsToField("product").getStringField(ProductFields.NUMBER)
                    .compareToIgnoreCase(ms2.getBelongsToField("product").getStringField(ProductFields.NUMBER)))
            .collect(Collectors.toList());
    boolean rowsWereAdded = false;
    for (Entity minimumState : minimumStates) {
        rowsWereAdded |= addRow(minimumState, stocksByProduct, warehouseTable);
    }// ww  w.  j  a v a  2  s.c o m
    if (rowsWereAdded) {
        document.add(new Paragraph(subtitle, FontUtils.getDejavuBold11Light()));
        document.add(warehouseTable);
    }
}

From source file:com.qcadoo.mes.workPlans.pdf.document.component.OperationSectionHeader.java

License:Open Source License

private Paragraph titleParagraph(String title) {
    return new Paragraph(title, FontUtils.getDejavuBold11Dark());
}

From source file:com.qcadoo.mes.workPlans.pdf.document.operation.component.OperationAdditionalFields.java

License:Open Source License

public void print(Entity operationComponent, Document document, Locale locale) throws DocumentException {
    Optional<String> imageUrlInWorkPlan = getImageUrlInWorkPlan(operationComponent);

    if (!imageUrlInWorkPlan.isPresent())
        return;/*from  w  w  w . j a v  a2  s .co m*/

    document.add(new Paragraph(title(locale), FontUtils.getDejavuBold10Dark()));
    pdfHelper.addImage(document, imageUrlInWorkPlan.get());
    document.add(Chunk.NEXTPAGE);

}