Example usage for org.apache.poi.ss.usermodel Cell setCellValue

List of usage examples for org.apache.poi.ss.usermodel Cell setCellValue

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell setCellValue.

Prototype

void setCellValue(boolean value);

Source Link

Document

Set a boolean value for the cell

Usage

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.TranslationVerificationReportGenerator.java

License:Apache License

/**
 * For Translations Edit Report, Write segment information into each row of
 * the sheet.//from   www.java 2s  . c o  m
 * 
 * @param p_sheet
 *            the sheet
 * @param p_jobId
 *            the job id
 * @param p_targetLang
 *            the target locale String
 * @param p_srcPageId
 *            the source page id
 * @param p_dateFormat
 *            the data format
 * @param p_row
 *            the segment row in sheet
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private int writeSegmentInfo(Workbook p_workBook, Sheet p_sheet, Job p_job, GlobalSightLocale p_targetLocale,
        String p_srcPageId, String p_dateFormat, int p_row) throws Exception {
    Vector<TargetPage> targetPages = new Vector<TargetPage>();

    TranslationMemoryProfile tmp = null;
    Vector<String> excludItems = null;

    for (Workflow workflow : p_job.getWorkflows()) {
        if (cancel)
            return 0;

        if (Workflow.PENDING.equals(workflow.getState()) || Workflow.CANCELLED.equals(workflow.getState())
        // || Workflow.EXPORT_FAILED.equals(workflow.getState())
                || Workflow.IMPORT_FAILED.equals(workflow.getState())) {
            continue;
        }
        if (p_targetLocale.getId() == workflow.getTargetLocale().getId()) {
            targetPages = workflow.getTargetPages();
            tmp = workflow.getJob().getL10nProfile().getTranslationMemoryProfile();
            if (tmp != null) {
                excludItems = tmp.getJobExcludeTuTypes();
            }
        }
    }

    if (targetPages.isEmpty()) {
        // If no corresponding target page exists, set the cell blank
        writeBlank(p_sheet, p_row, 11);
    } else {
        LeverageMatchLingManager lmLingManager = LingServerProxy.getLeverageMatchLingManager();
        TermLeverageManager termLeverageManager = ServerProxy.getTermLeverageManager();

        Locale sourcePageLocale = p_job.getSourceLocale().getLocale();
        Locale targetPageLocale = p_targetLocale.getLocale();
        TermLeverageOptions termLeverageOptions = getTermLeverageOptions(sourcePageLocale, targetPageLocale,
                p_job.getL10nProfile().getProject().getTermbaseName(), String.valueOf(p_job.getCompanyId()));
        Map<Long, Set<TermLeverageMatch>> termLeverageMatchResultMap = null;
        if (termLeverageOptions != null) {
            termLeverageMatchResultMap = termLeverageManager.getTermMatchesForPages(p_job.getSourcePages(),
                    p_targetLocale);
        }

        String category = null;
        PseudoData pData = new PseudoData();
        pData.setMode(PseudoConstants.PSEUDO_COMPACT);
        String sid = null;
        Set<Integer> rowsWithCommentSet = new HashSet<Integer>();
        for (int i = 0; i < targetPages.size(); i++) {
            if (cancel)
                return 0;

            TargetPage targetPage = (TargetPage) targetPages.get(i);
            SourcePage sourcePage = targetPage.getSourcePage();

            if (!"".equals(p_srcPageId) && !p_srcPageId.equals(String.valueOf(sourcePage.getId()))) {
                // ignore the source pages not equal to the one
                // if the request comes from pop up editor
                continue;
            }

            SegmentTuUtil.getTusBySourcePageId(sourcePage.getId());
            List sourceTuvs = SegmentTuvUtil.getSourceTuvs(sourcePage);
            List targetTuvs = SegmentTuvUtil.getTargetTuvs(targetPage);

            MatchTypeStatistics tuvMatchTypes = lmLingManager.getMatchTypesForStatistics(
                    sourcePage.getIdAsLong(), targetPage.getLocaleId(), p_job.getLeverageMatchThreshold());
            Map<Long, Set<LeverageMatch>> fuzzyLeverageMatchMap = lmLingManager
                    .getFuzzyMatches(sourcePage.getIdAsLong(), new Long(targetPage.getLocaleId()));
            Map<Long, Tuv> allTuvMap = this.getAllTuvsMap(targetPage);

            sourcePageLocale = sourcePage.getGlobalSightLocale().getLocale();
            targetPageLocale = targetPage.getGlobalSightLocale().getLocale();

            boolean m_rtlSourceLocale = EditUtil.isRTLLocale(sourcePageLocale.toString());
            boolean m_rtlTargetLocale = EditUtil.isRTLLocale(targetPageLocale.toString());

            // Find segment all comments belong to this target page
            Map<Long, IssueImpl> issuesMap = CommentHelper.getIssuesMap(targetPage.getId());

            for (int j = 0; j < targetTuvs.size(); j++) {
                if (cancel)
                    return 0;

                int col = 0;
                Tuv targetTuv = (Tuv) targetTuvs.get(j);
                Tuv sourceTuv = (Tuv) sourceTuvs.get(j);

                category = sourceTuv.getTu(p_job.getId()).getTuType();
                if (excludItems != null && excludItems.contains(category)) {
                    continue;
                }

                // Comment
                List issueHistories = null;
                String lastComment = "";
                String failure = "";
                String commentStatus = "";
                Issue issue = issuesMap.get(targetTuv.getId());
                if (issue != null) {
                    issueHistories = issue.getHistory();
                    failure = issue.getCategory();
                    commentStatus = issue.getStatus();
                }
                if (issueHistories != null && issueHistories.size() > 0) {
                    IssueHistory issueHistory = (IssueHistory) issueHistories.get(0);
                    lastComment = issueHistory.getComment();
                }

                sid = sourceTuv.getSid();

                StringBuilder matches = getMatches(fuzzyLeverageMatchMap, tuvMatchTypes, excludItems,
                        sourceTuvs, targetTuvs, sourceTuv, targetTuv, p_job.getId());

                // Get Terminology/Glossary Source and Target.
                String sourceTerms = "";
                String targetTerms = "";
                if (termLeverageMatchResultMap != null && termLeverageMatchResultMap.size() > 0) {
                    Set<TermLeverageMatch> termLeverageMatchSet = termLeverageMatchResultMap
                            .get(sourceTuv.getId());
                    if (termLeverageMatchSet != null && termLeverageMatchSet.size() > 0) {
                        TermLeverageMatch tlm = termLeverageMatchSet.iterator().next();
                        sourceTerms = tlm.getMatchedSourceTerm();
                        targetTerms = tlm.getMatchedTargetTerm();
                    }
                }

                Row currentRow = getRow(p_sheet, p_row);

                // Source segment with compact tags
                CellStyle srcStyle = m_rtlSourceLocale ? getRtlContentStyle(p_workBook)
                        : getContentStyle(p_workBook);
                Cell cell_A = getCell(currentRow, col);
                cell_A.setCellValue(getSegment(pData, sourceTuv, m_rtlSourceLocale, p_job.getId()));
                cell_A.setCellStyle(srcStyle);
                col++;

                // the translation after the translation activity
                CellStyle trgStyle = null;
                String previousSegments = getPreviousSegments(allTuvMap, targetTuv.getId(), targetTuv,
                        p_job.getId(), pData);
                String currentSegments = getSegment(pData, targetTuv, m_rtlTargetLocale, p_job.getId());
                Cell cell_B = getCell(currentRow, col);
                cell_B.setCellValue(previousSegments);
                if (StringUtil.isNotEmpty(previousSegments) && !previousSegments.endsWith(currentSegments)) {
                    trgStyle = m_rtlTargetLocale ? getRtlContentStyle1(p_workBook)
                            : getContentStyle1(p_workBook);
                } else {
                    trgStyle = m_rtlTargetLocale ? getRtlContentStyle(p_workBook) : getContentStyle(p_workBook);
                }
                cell_B.setCellStyle(trgStyle);
                col++;

                // the translation after the review activity
                // CellStyle trgStyle = m_rtlTargetLocale ?
                // getRtlContentStyle(p_workBook)
                // : getContentStyle(p_workBook);
                Cell cell_C = getCell(currentRow, col);
                cell_C.setCellValue(currentSegments);
                cell_C.setCellStyle(trgStyle);
                col++;

                // Modify the translation
                CellStyle modifyTranslationStyle = m_rtlTargetLocale ? getUnlockedRightStyle(p_workBook)
                        : getUnlockedStyle(p_workBook);
                Cell cell_D = getCell(currentRow, col);
                cell_D.setCellValue("");
                cell_D.setCellStyle(modifyTranslationStyle);
                col++;

                // Reviewers Comments
                Cell cell_E = getCell(currentRow, col);
                cell_E.setCellValue(lastComment);
                cell_E.setCellStyle(getContentStyle(p_workBook));
                col++;

                // Translators Comments
                Cell cell_F = getCell(currentRow, col);
                cell_F.setCellValue("");
                cell_F.setCellStyle(getUnlockedStyle(p_workBook));
                col++;

                // Category failure
                Cell cell_G = getCell(currentRow, col);
                cell_G.setCellValue(failure);
                cell_G.setCellStyle(getContentStyle(p_workBook));
                col++;

                // Comment Status
                Cell cell_H = getCell(currentRow, col);
                cell_H.setCellValue(commentStatus);
                CellStyle commentCS = p_workBook.createCellStyle();
                commentCS.cloneStyleFrom(getContentStyle(p_workBook));
                commentCS.setLocked(false);
                cell_H.setCellStyle(commentCS);
                // add comment status drop down list for current row.
                String[] statusArray = getCommentStatusList(lastComment);
                if (statusArray.length > 1) {
                    rowsWithCommentSet.add(p_row);
                }
                col++;

                // TM match
                Cell cell_I = getCell(currentRow, col);
                cell_I.setCellValue(matches.toString());
                cell_I.setCellStyle(getContentStyle(p_workBook));
                col++;

                // Glossary source
                Cell cell_J = getCell(currentRow, col);
                cell_J.setCellValue(sourceTerms);
                cell_J.setCellStyle(getContentStyle(p_workBook));
                col++;

                // Glossary target
                Cell cell_K = getCell(currentRow, col);
                cell_K.setCellValue(targetTerms);
                cell_K.setCellStyle(getContentStyle(p_workBook));
                col++;

                // Job Id
                Cell cell_L = getCell(currentRow, col);
                cell_L.setCellValue(p_job.getId());
                cell_L.setCellStyle(getContentStyle(p_workBook));
                col++;

                // Segment id
                Cell cell_M = getCell(currentRow, col);
                cell_M.setCellValue(sourceTuv.getTu(p_job.getId()).getId());
                cell_M.setCellStyle(getContentStyle(p_workBook));
                col++;

                // Fix for GBS-1484
                String externalPageId = sourcePage.getExternalPageId();
                String[] pathNames = externalPageId.split("\\\\");
                String name = pathNames[pathNames.length - 1];
                boolean temp = pathNames[0].contains(")");
                if (temp) {
                    String[] firstNames = pathNames[0].split("\\)");
                    String detailName = firstNames[0];
                    name = name + detailName + ")";
                }
                // Page Name
                Cell cell_N = getCell(currentRow, col);
                cell_N.setCellValue(name);
                cell_N.setCellStyle(getContentStyle(p_workBook));
                col++;

                // SID
                Cell cell_O = getCell(currentRow, col);
                cell_O.setCellValue(sid);
                cell_O.setCellStyle(getContentStyle(p_workBook));
                col++;

                p_row++;
            }
        }
        // Add comment status
        addCommentStatus(p_sheet, rowsWithCommentSet, p_row);
        // Add category failure drop down list here.
        addCategoryFailureValidation(p_sheet, SEGMENT_START_ROW, p_row - 1, CATEGORY_FAILURE_COLUMN,
                CATEGORY_FAILURE_COLUMN);
    }

    return p_row;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobAttributeReportHelper.java

License:Apache License

private void addTitle() throws Exception {
    // title font is black bold on white
    Font titleFont = workbook.createFont();
    titleFont.setUnderline(Font.U_NONE);
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    CellStyle titleStyle = workbook.createCellStyle();
    titleStyle.setFont(titleFont);/*w ww.  j a  v a2 s .co  m*/

    Row titleRow = getRow(0);
    Cell cell_A = getCell(titleRow, 0);
    cell_A.setCellValue(bundle.getString("lb_job_attributes"));
    cell_A.setCellStyle(titleStyle);
    sheet.setColumnWidth(0, 20 * 256);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobAttributeReportHelper.java

License:Apache License

/**
 * Adds the table header for the Dell Matches sheet
 * //  w  w w  . j av  a2s.  c  om
 */
private void addHeader() throws Exception {
    int c = 0;
    Row headerRow = getRow(2);
    for (String header : getHeaders()) {
        Cell cell_Header = getCell(headerRow, c);
        cell_Header.setCellValue(header);
        cell_Header.setCellStyle(getHeaderStyle(false));
        sheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
        setRegionStyle(new CellRangeAddress(2, 3, c, c), headerStyle);
        sheet.setColumnWidth(c, 17 * 256);
        c++;
    }

    for (AttributeItem item : attriutes) {
        CellStyle style = item.isFromSuper() ? getHeaderStyle(true) : getHeaderStyle(false);
        Cell cell_Attriutes = getCell(headerRow, c);
        cell_Attriutes.setCellValue(item.getName());
        cell_Attriutes.setCellStyle(style);
        sheet.addMergedRegion(new CellRangeAddress(2, 3, c, c));
        setRegionStyle(new CellRangeAddress(2, 3, c, c), style);
        sheet.setColumnWidth(c, 25 * 256);
        c++;
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobAttributeReportHelper.java

License:Apache License

private void writeData() throws Exception {
    for (JobImpl job : jobAttributes) {
        int col = 0;
        Row theRow = getRow(row);/*w  w w.j  a  va  2  s.co  m*/

        // Job Id
        Cell cell_A = getCell(theRow, col++);
        cell_A.setCellValue(job.getId());
        cell_A.setCellStyle(getContentStyle());

        // Job Name
        Cell cell_B = getCell(theRow, col++);
        cell_B.setCellValue(job.getName());
        cell_B.setCellStyle(getContentStyle());

        // Number of Languages
        Cell cell_C = getCell(theRow, col++);
        cell_C.setCellValue(job.getWorkflows().size());
        cell_C.setCellStyle(getContentStyle());

        // Submitter
        Cell cell_D = getCell(theRow, col++);
        cell_D.setCellValue(UserHandlerHelper.getUser(job.getCreateUserId()).getUserName());
        cell_D.setCellStyle(getContentStyle());

        // Project
        Cell cell_E = getCell(theRow, col++);
        cell_E.setCellValue(job.getL10nProfile().getProject().getName());
        cell_E.setCellStyle(getContentStyle());

        for (AttributeItem item : attriutes) {
            JobAttribute jobAtt = getJobAttributeValue(item.getName(), job, item.isFromSuper());

            Cell cell = getCell(theRow, col++);
            if (jobAtt == null) {
                cell.setCellValue(bundle.getString("lb_na"));
                cell.setCellStyle(getContentStyle());
            } else {
                Object ob = jobAtt.getValue();
                if (ob == null) {
                    cell.setCellValue("");
                    cell.setCellStyle(getContentStyle());
                } else {
                    String type = jobAtt.getType();
                    if (Attribute.TYPE_FLOAT.equals(type)) {
                        double value = Double.parseDouble(jobAtt.getFloatValue().toString());
                        cell.setCellValue(value);
                        cell.setCellStyle(getContentStyle());
                        if (item.isTotal()) {
                            addTotalCell(col, row);
                        }
                    } else if (Attribute.TYPE_INTEGER.equals(type)) {
                        cell.setCellValue(jobAtt.getIntegerValue());
                        cell.setCellStyle(getContentStyle());
                        if (item.isTotal()) {
                            addTotalCell(col, row);
                        }
                    } else {
                        cell.setCellValue(getAttributeValueString(jobAtt));
                        cell.setCellStyle(getContentStyle());
                    }
                }
            }
        }

        row++;
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobAttributeReportHelper.java

License:Apache License

private void writeTotal() throws Exception {
    Font totalFont = workbook.createFont();
    totalFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    totalFont.setColor(IndexedColors.BLACK.getIndex());
    totalFont.setUnderline(Font.U_NONE);
    totalFont.setFontName("Arial");
    totalFont.setFontHeightInPoints((short) 9);

    CellStyle totalStyle = workbook.createCellStyle();
    totalStyle.setFont(totalFont);// w w  w  .  j  ava2  s  .c  o m

    Set<Integer> keys = totalCells.keySet();

    if (keys.size() > 0) {
        row++;
        Cell cell_B = getCell(getRow(row), 1);
        cell_B.setCellValue(bundle.getString("lb_total"));
        cell_B.setCellStyle(totalStyle);

        for (Integer key : keys) {
            Cell cell = getCell(getRow(row), key - 1);
            cell.setCellFormula(getTotalFormula(key, totalCells.get(key)));
            cell.setCellStyle(totalStyle);
        }
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobStatusXlsReportProcessor.java

License:Apache License

private void addTitle(Workbook p_workbook, Sheet p_sheet) {
    String EMEA = CompanyWrapper.getCurrentCompanyName();
    Row titleRow = getRow(p_sheet, 0);/*from   w w w . jav  a 2 s  .  c o  m*/
    Cell titleCell = getCell(titleRow, 0);
    titleCell.setCellValue(EMEA + " " + bundle.getString("lb_job_status"));
    titleCell.setCellStyle(getTitleStyle(p_workbook));
    p_sheet.setColumnWidth(0, 22 * 256);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobStatusXlsReportProcessor.java

License:Apache License

/**
 * Adds the table header to the sheet//w  w  w  .ja  v a2 s.c o m
 * 
 * @param p_sheet
 *            the sheet to be created in the report
 * 
 * @throws Exception
 */
private void addHeader(Workbook p_workbook, Sheet p_sheet) throws Exception {
    CellStyle headerCs = getHeaderStyle(p_workbook);

    int col = 0;
    Row headerRow = getRow(p_sheet, 3);

    Cell cell_A = getCell(headerRow, col++);
    cell_A.setCellValue(bundle.getString("jobinfo.jobid"));
    cell_A.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 10 * 256);

    Cell cell_B = getCell(headerRow, col++);
    cell_B.setCellValue(bundle.getString("lb_job"));
    cell_B.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 50 * 256);

    Cell cell_C = getCell(headerRow, col++);
    cell_C.setCellValue(bundle.getString("lb_lang"));
    cell_C.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_D = getCell(headerRow, col++);
    cell_D.setCellValue(bundle.getString("lb_word_count"));
    cell_D.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_E = getCell(headerRow, col++);
    cell_E.setCellValue(bundle.getString("lb_job_kickoff_date"));
    cell_E.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_F = getCell(headerRow, col++);
    cell_F.setCellValue(bundle.getString("lb_date_due_to_review"));
    cell_F.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_G = getCell(headerRow, col++);
    cell_G.setCellValue(bundle.getString("lb_actual_date_to_review"));
    cell_G.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_H = getCell(headerRow, col++);
    cell_H.setCellValue(bundle.getString("lb_current_activity"));
    cell_H.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_I = getCell(headerRow, col++);
    cell_I.setCellValue(bundle.getString("lb_reviewer_accepted"));
    cell_I.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_J = getCell(headerRow, col++);
    cell_J.setCellValue(bundle.getString("lb_reviewer_name"));
    cell_J.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_K = getCell(headerRow, col++);
    cell_K.setCellValue(bundle.getString("lb_Due_reviewer_complete"));
    cell_K.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_L = getCell(headerRow, col++);
    cell_L.setCellValue(bundle.getString("lb_actual_reviewer_complete"));
    cell_L.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_M = getCell(headerRow, col++);
    cell_M.setCellValue(bundle.getString("jobinfo.status.estimatedjobcompletion"));
    cell_M.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_N = getCell(headerRow, col++);
    cell_N.setCellValue(bundle.getString("jobinfo.status.actualjobcompletion"));
    cell_N.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);

    Cell cell_O = getCell(headerRow, col++);
    cell_O.setCellValue(bundle.getString("lb_pm"));
    cell_O.setCellStyle(headerCs);
    p_sheet.setColumnWidth(col - 1, 25 * 256);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobStatusXlsReportProcessor.java

License:Apache License

/**
 * Gets the task for the workflow and outputs page information.
 * /*from   www .  j  ava 2s.  c o  m*/
 * @param p_request
 * @param p_sheet
 * @param p_job
 * @param p_workflow
 * @param p_row
 * 
 * @throws Exception
 */
private void addWorkflow(HttpServletRequest p_request, Workbook p_workbook, Sheet p_sheet, Job p_job,
        Workflow p_workflow, IntHolder p_row, ResourceBundle bundle) throws Exception {
    int c = 0;
    Row row = getRow(p_sheet, p_row.getValue());

    // Job ID column
    Cell cell_A = getCell(row, c++);
    cell_A.setCellValue(p_job.getJobId());
    cell_A.setCellStyle(getContentStyle(p_workbook));

    // Job Name column
    Cell cell_B = getCell(row, c++);
    cell_B.setCellValue(p_job.getJobName());
    cell_B.setCellStyle(getContentStyle(p_workbook));

    // Target Language column
    Cell cell_C = getCell(row, c++);
    cell_C.setCellValue(p_workflow.getTargetLocale().getDisplayName(uiLocale));
    cell_C.setCellStyle(getContentStyle(p_workbook));

    // Word Count column
    Cell cell_D = getCell(row, c++);
    cell_D.setCellValue(p_workflow.getTotalWordCount());
    cell_D.setCellStyle(getContentStyle(p_workbook));

    // Job Kick off date column
    Cell cell_E = getCell(row, c++);
    cell_E.setCellValue(dateFormat.format(p_job.getCreateDate()));
    cell_E.setCellStyle(getContentStyle(p_workbook));

    // Date due to review column -- For the current workflow, find the
    // activity called "Dell_Review", then insert the Estimated Completion
    // Date (and time) for the activity prior to the "Dell_Review" activity.
    Task priorTask = null;
    Task revTask = null;
    TaskInfo priorTaskInfo = null;
    TaskInfo revTaskInfo = null;
    List<TaskInfo> taskInfos = ServerProxy.getWorkflowManager().getTaskInfosInDefaultPath(p_workflow);
    if (taskInfos == null)
        taskInfos = new ArrayList<TaskInfo>();
    for (TaskInfo ti : taskInfos) {
        if (ti.getType() == Task.TYPE_REVIEW) {
            revTaskInfo = ti;
            revTask = (Task) p_workflow.getTasks().get(revTaskInfo.getId());
            if (priorTaskInfo != null) {
                priorTask = (Task) p_workflow.getTasks().get(priorTaskInfo.getId());
            }
            break;
        } else {
            priorTaskInfo = ti;
        }
    }

    Cell cell_F = getCell(row, c++);
    ;
    Cell cell_G = getCell(row, c++);
    ;
    if (revTask == null) {
        cell_F.setCellValue(bundle.getString("lb_no_review"));
        cell_F.setCellStyle(getContentStyle(p_workbook));

        cell_G.setCellValue(bundle.getString("lb_no_review"));
        cell_G.setCellStyle(getContentStyle(p_workbook));
    } else if (priorTaskInfo != null && priorTask != null) {
        if (priorTaskInfo.getCompleteByDate() != null) {
            cell_F.setCellValue(dateFormat.format(priorTaskInfo.getCompleteByDate()));
            cell_F.setCellStyle(getContentStyle(p_workbook));
        } else {
            cell_F.setCellValue(bundle.getString("lb_na"));
            cell_F.setCellStyle(getContentStyle(p_workbook));
        }

        // Actual date to Review column: Insert the date (and time) the
        // "Dell_Review"
        // activity became available for acceptance in the current workflow.
        if (priorTask.getCompletedDate() != null) {
            cell_G.setCellValue(dateFormat.format(priorTask.getCompletedDate()));
            cell_G.setCellStyle(getContentStyle(p_workbook));
        } else {
            cell_G.setCellValue(bundle.getString("lb_na"));
            cell_G.setCellStyle(getContentStyle(p_workbook));
        }
    } else {
        cell_F.setCellValue(bundle.getString("lb_na"));
        cell_F.setCellStyle(getContentStyle(p_workbook));

        cell_G.setCellValue(bundle.getString("lb_na"));
        cell_G.setCellStyle(getContentStyle(p_workbook));
    }

    // Current Activity column: Currently active activity in the current
    // workflow.
    Map<Long, WorkflowTaskInstance> activeTasks = null;
    try {
        activeTasks = ServerProxy.getWorkflowServer().getActiveTasksForWorkflow(p_workflow.getId());
    } catch (Exception e) {
        activeTasks = null;
        // just log the message since we don't want a full stack trace to
        // clog the log
        s_logger.error("Failed to get active tasks for workflow " + p_workflow.getId() + " " + e.getMessage());
    }
    boolean wasExportFailed = false;

    // for now we'll only have one active task
    Object[] tasks = (activeTasks == null) ? null : activeTasks.values().toArray();
    WorkflowTaskInstance activeTask = null;

    Cell cell_H = getCell(row, c++);
    if (tasks != null && tasks.length > 0) {
        // assume just one active task for now
        activeTask = (WorkflowTaskInstance) tasks[0];
        // only write out if the Activity type is review only
        Activity a = activeTask.getActivity();
        cell_H.setCellValue(a.getDisplayName());
        cell_H.setCellStyle(getContentStyle(p_workbook));
    } else {
        String state = p_workflow.getState();
        if (Workflow.LOCALIZED.equals(state)) {
            cell_H.setCellValue(bundle.getString("lb_localized"));
            cell_H.setCellStyle(getContentStyle(p_workbook));
        } else if (Workflow.EXPORTED.equals(state)) {
            cell_H.setCellValue(bundle.getString("lb_exported"));
            cell_H.setCellStyle(getContentStyle(p_workbook));
        } else if (Workflow.EXPORT_FAILED.equals(state)) {
            cell_H.setCellValue(bundle.getString("lb_exported_failed"));
            cell_H.setCellStyle(getContentStyle(p_workbook));
            // if the workflow is EXPORT_FAILED, color the line in red
            wasExportFailed = true;
        } else if (Workflow.READY_TO_BE_DISPATCHED.equals(state)) {
            cell_H.setCellValue(bundle.getString("lb_not_yet_dispatched"));
            cell_H.setCellStyle(getContentStyle(p_workbook));
        } else if (Workflow.ARCHIVED.equals(state)) {
            cell_H.setCellValue(bundle.getString("lb_archived"));
            cell_H.setCellStyle(getContentStyle(p_workbook));
        } else {
            cell_H.setCellValue(bundle.getString("lb_unknown"));
            cell_H.setCellStyle(getContentStyle(p_workbook));
        }
    }

    boolean wasRejected = false;
    String rejectorName = null;
    boolean revAccepted = false;
    // Reviewer accepted column: If the "Dell_Review" activity has been
    // accepted, insert the date (and time) it was accepted. If not accepted
    // yet, put "not accepted yet".
    Cell cell_I = getCell(row, c++);
    if (revTask != null) {
        if (revTask.getAcceptor() != null) {
            revAccepted = true;
            if (revTask.getAcceptedDate() != null) {
                cell_I.setCellValue(dateFormat.format(revTask.getAcceptedDate()));
                cell_I.setCellStyle(getContentStyle(p_workbook));
            } else {
                cell_I.setCellValue(bundle.getString("lb_na"));
                cell_I.setCellStyle(getContentStyle(p_workbook));
            }
        } else {
            // see if this task has been rejected and if so color the line
            // in red
            if (activeTask != null) {
                Vector workItems = activeTask.getWorkItems();
                for (int i = 0; i < workItems.size(); i++) {
                    EnvoyWorkItem ewi = (EnvoyWorkItem) workItems.get(i);
                    if (WorkflowConstants.TASK_DECLINED == ewi.getWorkItemState()) {
                        wasRejected = true;
                        rejectorName = UserUtil.getUserNameById(ewi.getAssignee());
                        break;
                    }
                }
            }
            if (wasRejected) {
                cell_I.setCellValue(bundle.getString("lb_rejected_by") + " " + rejectorName);
                cell_I.setCellStyle(getRejectedStyle(p_workbook));
            } else {
                cell_I.setCellValue(bundle.getString("lb_not_accepted_yet"));
                cell_I.setCellStyle(getContentStyle(p_workbook));
            }
        }
    } else {
        cell_I.setCellValue(bundle.getString("lb_no_review"));
        cell_I.setCellStyle(getContentStyle(p_workbook));
    }

    // Reviewer name column: If not accepted, Insert all assignee(s)
    // assigned to the Dell_Review activity in the current workflow,
    // delimited by commas; add multiple names if there are multiple
    // assignees, until reaching 10 (cut it off at 10 names).
    // If activity is accepted, put in name of accepter.
    Cell cell_J = getCell(row, c++);
    if (revTask == null) {
        cell_J.setCellValue(bundle.getString("lb_no_review"));
        cell_J.setCellStyle(getContentStyle(p_workbook));
    } else if (revAccepted) {
        // get accepter somehow
        cell_J.setCellValue(UserUtil.getUserNameById(revTask.getAcceptor()));
        cell_J.setCellStyle(getContentStyle(p_workbook));
    } else {
        String reviewerName = getReviewerName(revTaskInfo);
        cell_J.setCellValue(reviewerName);
        cell_J.setCellStyle(getContentStyle(p_workbook));
    }

    // Due reviewer complete column: Insert the Estimated Completion Date
    // (and time) for the "Dell_Review" activity.
    Cell cell_K = getCell(row, c++);
    if (revTask != null && revTask.getEstimatedCompletionDate() != null) {
        cell_K.setCellValue(dateFormat.format(revTask.getEstimatedCompletionDate()));
        cell_K.setCellStyle(getContentStyle(p_workbook));
    } else if (revTask != null) {
        cell_K.setCellValue(bundle.getString("lb_na"));
        cell_K.setCellStyle(getContentStyle(p_workbook));
    } else {
        cell_K.setCellValue(bundle.getString("lb_no_review"));
        cell_K.setCellStyle(getContentStyle(p_workbook));
    }

    // Actual reviewer complete column: Insert the Actual Completion Date
    // (and time)
    // for the "Dell_Review" activity.
    Cell cell_L = getCell(row, c++);
    if (revTask != null && revTask.getCompletedDate() != null) {
        cell_L.setCellValue(dateFormat.format(revTask.getCompletedDate()));
        cell_L.setCellStyle(getContentStyle(p_workbook));
    } else if (revTask != null) {
        if (wasRejected) {
            cell_L.setCellValue(bundle.getString("lb_rejected_by") + " " + rejectorName);
            cell_L.setCellStyle(getRejectedStyle(p_workbook));
        } else {
            cell_L.setCellValue(bundle.getString("lb_not_yet_completed"));
            cell_L.setCellStyle(getContentStyle(p_workbook));
        }
    } else {
        cell_L.setCellValue(bundle.getString("lb_no_review"));
        cell_L.setCellStyle(getContentStyle(p_workbook));
    }

    // Estimated job completion column: Insert the estimated completion date
    // (and time) for each workflow.
    Cell cell_M = getCell(row, c++);
    if (p_workflow.getEstimatedCompletionDate() != null) {
        cell_M.setCellValue(dateFormat.format(p_workflow.getEstimatedCompletionDate()));
        cell_M.setCellStyle(getContentStyle(p_workbook));
    } else {
        cell_M.setCellValue(bundle.getString("lb_na"));
        cell_M.setCellStyle(getContentStyle(p_workbook));
    }

    // Actual job completion column: Insert the date (and time) the workflow
    // was exported.
    Cell cell_N = getCell(row, c++);
    if (p_workflow.getCompletedDate() != null) {
        cell_N.setCellValue(dateFormat.format(p_workflow.getCompletedDate()));
        cell_N.setCellStyle(getContentStyle(p_workbook));
    } else {
        if (wasRejected) {
            cell_N.setCellValue(bundle.getString("lb_rejected_by") + " " + rejectorName);
            cell_N.setCellStyle(getRejectedStyle(p_workbook));
        } else {
            cell_N.setCellValue(bundle.getString("lb_not_yet_completed"));
            cell_N.setCellStyle(getContentStyle(p_workbook));
        }
    }

    // Dell PM column
    Cell cell_O = getCell(row, c++);
    String pmString = getPMColumnString(p_workflow);
    if (!StringUtil.isEmpty(pmString)) {
        cell_O.setCellValue(pmString);
        cell_O.setCellStyle(getWrapStyle(p_workbook));
    } else {
        cell_O.setCellValue(bundle.getString("lb_na"));
        cell_O.setCellStyle(getContentStyle(p_workbook));
    }

    p_row.inc();

    // Rewrite current row in "RED" style.
    if (wasExportFailed) {
        Cell cell = null;
        for (int i = 0; i < c; i++) {
            cell = getCell(row, i);
            cell.setCellStyle(getRedStyle(p_workbook));
        }
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerLisaQAXlsReportHelper.java

License:Apache License

private void addSegmentHeaderICC(Workbook p_workbook, Sheet p_sheet) throws Exception {
    ResourceBundle bundle = PageHandler.getBundle(request.getSession());
    int col = 0;/* www.  ja  v a  2 s. co m*/
    int row = SEGMENT_HEADER_ROW;
    Row segHeaderRow = getRow(p_sheet, row);
    Cell cell_A = getCell(segHeaderRow, col++);
    cell_A.setCellValue(bundle.getString("lb_job_id_report"));
    cell_A.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_B = getCell(segHeaderRow, col++);
    cell_B.setCellValue(bundle.getString("lb_segment_id"));
    cell_B.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_C = getCell(segHeaderRow, col++);
    cell_C.setCellValue(bundle.getString("lb_page_name"));
    cell_C.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_D = getCell(segHeaderRow, col++);
    cell_D.setCellValue(bundle.getString("lb_source_segment"));
    cell_D.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 40 * 256);

    Cell cell_E = getCell(segHeaderRow, col++);
    cell_E.setCellValue(bundle.getString("lb_target_segment"));
    cell_E.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 20 * 256);

    Cell cell_F = getCell(segHeaderRow, col++);
    cell_F.setCellValue(bundle.getString("lb_sid"));
    cell_F.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 40 * 256);

    Cell cell_G = getCell(segHeaderRow, col++);
    cell_G.setCellValue(bundle.getString("lb_comment_free"));
    cell_G.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 40 * 256);

    Cell cell_H = getCell(segHeaderRow, col++);
    cell_H.setCellValue(bundle.getString("lb_category_failure"));
    cell_H.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_I = getCell(segHeaderRow, col++);
    cell_I.setCellValue(bundle.getString("lb_tm_match_original"));
    cell_I.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_J = getCell(segHeaderRow, col++);
    cell_J.setCellValue(bundle.getString("lb_glossary_source"));
    cell_J.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_K = getCell(segHeaderRow, col++);
    cell_K.setCellValue(bundle.getString("lb_glossary_target"));
    cell_K.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.setColumnWidth(col - 1, 30 * 256);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerLisaQAXlsReportHelper.java

License:Apache License

/**
 * Add job header to the sheet/*from   w ww  .  ja  va2s .co m*/
 * 
 * @param p_sheet
 *            the sheet
 * @throws Exception
 */
private void addLanguageHeader(Workbook p_workbok, Sheet p_sheet) throws Exception {
    ResourceBundle bundle = PageHandler.getBundle(request.getSession());

    int col = 0;
    int row = LANGUAGE_HEADER_ROW;
    Row langHeaderRow = getRow(p_sheet, row);
    Cell cell_A = getCell(langHeaderRow, col++);
    cell_A.setCellValue(bundle.getString("lb_source_language"));
    cell_A.setCellStyle(getHeaderStyle(p_workbok));
    p_sheet.setColumnWidth(col - 1, 30 * 256);

    Cell cell_B = getCell(langHeaderRow, col++);
    cell_B.setCellValue(bundle.getString("lb_target_language"));
    cell_B.setCellStyle(getHeaderStyle(p_workbok));
    p_sheet.setColumnWidth(col - 1, 30 * 256);
}