com.webbfontaine.valuewebb.action.tt.TtPrinting.java Source code

Java tutorial

Introduction

Here is the source code for com.webbfontaine.valuewebb.action.tt.TtPrinting.java

Source

package com.webbfontaine.valuewebb.action.tt;

import com.webbfontaine.valuewebb.model.TtGen;
import com.webbfontaine.valuewebb.model.util.PrintUtils;
import com.webbfontaine.valuewebb.report.*;
import org.apache.commons.lang3.StringUtils;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.web.RequestParameter;

import java.math.BigDecimal;

/**
 * Copyrights 2002-2012 Webb Fontaine
 * This software is the proprietary information of Webb Fontaine.
 * Its use is subject to License terms.
 * Developer: nigiyan
 * Date: 13/01/2012
 */

@Name("ttPrinting")
public class TtPrinting {

    @RequestParameter
    String entityId;

    public Object print(boolean isDraft) {

        TtGenHome ttGenHome = (TtGenHome) Component.getInstance(TtGenHome.class, ScopeType.CONVERSATION, false);

        TtGen ttGen = ttGenHome.getInstance();
        prepareFCVRReport(ttGen, isDraft).doImmediateReport();

        return null;
    }

    public byte[] getFCVRReport(TtGen ttGen) {
        return prepareFCVRReport(ttGen, false).generateReport();
    }

    public SingleTTReport prepareFCVRReport(TtGen ttGen, boolean isDraft) {
        SingleTTReport str = new SingleTTReport();

        str.getTtId().setValue(new BigDecimal(ttGen.getId().toString()));

        ClassLoader classLoader = getClass().getClassLoader();

        if (isDraft) {
            str.getDraft().setValue(classLoader.getResourceAsStream(PrintUtils.getDraftImagePath()));
        } else {
            String signImage = PrintUtils.getSignatureImagePath();
            if (!StringUtils.isEmpty(signImage)) {
                str.getSignature().setValue(classLoader.getResourceAsStream(signImage));
            }

            if (ttGen.getFcvrNum() == null) {
                str.getDraft().setValue(classLoader.getResourceAsStream(PrintUtils.getDraftImagePath()));
            }
        }

        str.getTitle().setValue(classLoader.getResourceAsStream(PrintUtils.getTitleImagePath()));
        return str;
    }

    public Object printoutTTAss() {
        TtGenHome ttGenHome = (TtGenHome) Component.getInstance(TtGenHome.class, ScopeType.CONVERSATION, false);
        PrintoutTTAss printout = new PrintoutTTAss();
        printout.getTtId().setValue(new BigDecimal(ttGenHome.getId().toString()));

        printout.doImmediateReport();
        return null;
    }

    public Object printoutTTDec() {
        TtGenHome ttGenHome = (TtGenHome) Component.getInstance(TtGenHome.class, ScopeType.CONVERSATION, false);
        PrintoutTTDec printout = new PrintoutTTDec();
        printout.getTtId().setValue(new BigDecimal(ttGenHome.getId().toString()));

        printout.doImmediateReport();
        return null;
    }

    public Object printTTAudit() {
        TtAuditReport ttAuditReport = new TtAuditReport();
        ttAuditReport.getTtId().setValue(new BigDecimal(entityId));

        ProcessingTime processingTime = new ProcessingTime();
        processingTime.calculate(Long.parseLong(entityId));

        ttAuditReport.getAdjProcTime().setValue(processingTime.getProcessingTimeWithoutQueryStatusInStringFormat());

        ttAuditReport.doImmediateReport();
        return null;
    }
}