List of usage examples for org.apache.poi.ss.usermodel Cell setCellStyle
void setCellStyle(CellStyle style);
Set the style for the cell.
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobStatusXlsReportProcessor.java
License:Apache License
/** * Adds the table header to the sheet/*from w w w . j a va 2s . 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. * // w w w.j a v a 2 s . 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;//from ww w .ja va 2 s. com 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 w w. ja v a2 s . c o 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); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerLisaQAXlsReportHelper.java
License:Apache License
/** * Add title to the sheet/*from ww w.j ava 2 s .c om*/ * * @param p_sheet * the sheet * @throws Exception */ private void addTitle(Workbook p_workbook, Sheet p_sheet) throws Exception { ResourceBundle bundle = PageHandler.getBundle(request.getSession()); // Title font is black bold on white Font titleFont = p_workbook.createFont(); titleFont.setUnderline(Font.U_NONE); titleFont.setFontName("Times"); titleFont.setFontHeightInPoints((short) 14); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); titleFont.setColor(IndexedColors.BLACK.getIndex()); CellStyle titleStyle = p_workbook.createCellStyle(); titleStyle.setFont(titleFont); titleStyle.setWrapText(false); Row titleRow = getRow(p_sheet, 0); Cell titleCell = getCell(titleRow, 0); titleCell.setCellValue(bundle.getString("implemented_comments_check_report")); titleCell.setCellStyle(titleStyle); p_sheet.setColumnWidth(0, 40 * 256); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerLisaQAXlsReportHelper.java
License:Apache License
/** * Write the Job information into the header * //from w ww .j ava 2s. co m * @param p_sheet * the sheet * @throws Exception */ private void writeLanguageInfo(Workbook p_workbook, Sheet p_sheet) throws Exception { int col = 0; int row = LANGUAGE_INFO_ROW; long jobId = 0; if (request.getParameter(WebAppConstants.JOB_ID) != null && !"*".equals(request.getParameter(WebAppConstants.JOB_ID))) { // Request from main reports entrance. jobId = Long.valueOf(request.getParameter(WebAppConstants.JOB_ID)); LocaleManagerLocal manager = new LocaleManagerLocal(); writeLanguageInfo(p_workbook, p_sheet, jobId, manager.getLocaleById(Long.valueOf(request.getParameter(WebAppConstants.TARGET_LANGUAGE))) .getDisplayName(), request.getParameter(WebAppConstants.DATE_FORMAT)); } else if (sessionMgr.getAttribute(WebAppConstants.JOB_ID) != null) { // Request from pop up editor or work offline page. Object jobIdObject = sessionMgr.getAttribute(WebAppConstants.JOB_ID); if (jobIdObject instanceof String) { jobId = Long.parseLong((String) jobIdObject); } else if (jobIdObject instanceof Long) { jobId = (Long) jobIdObject; } writeLanguageInfo(p_workbook, p_sheet, jobId, (String) sessionMgr.getAttribute(WebAppConstants.TARGETVIEW_LOCALE), DEFAULT_DATE_FORMAT); } else { // If no job exists, just set the cell blank. Row infoRow = getRow(p_sheet, row); Cell cell_A = getCell(infoRow, col++); cell_A.setCellValue(""); cell_A.setCellStyle(getContentStyle(p_workbook)); Cell cell_B = getCell(infoRow, col++); cell_B.setCellValue(""); cell_B.setCellStyle(getContentStyle(p_workbook)); } }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerLisaQAXlsReportHelper.java
License:Apache License
/** * Write the Job information into the header * /*from ww w. j av a 2 s . c o m*/ * @param p_sheet * the sheet * @param p_jobId * the job id * @param p_targetLang * the displayed target language * @param p_dateFormat * the date format * @throws Exception */ private void writeLanguageInfo(Workbook p_workbook, Sheet p_sheet, long p_jobId, String p_targetLang, String p_dateFormat) throws Exception { Job job = ServerProxy.getJobHandler().getJobById(p_jobId); int col = 0; int row = LANGUAGE_INFO_ROW; // Source Language Row langInfoRow = getRow(p_sheet, row); Cell cell_A = getCell(langInfoRow, col++); cell_A.setCellValue(job.getSourceLocale().getDisplayName(uiLocale)); cell_A.setCellStyle(getContentStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 30 * 256); // Target Language Cell cell_B = getCell(langInfoRow, col++); cell_B.setCellValue(p_targetLang); cell_B.setCellStyle(getContentStyle(p_workbook)); p_sheet.setColumnWidth(col - 1, 30 * 256); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerLisaQAXlsReportHelper.java
License:Apache License
/** * For Implemented Comments Check Report, Write segment information into * each row of the sheet./*from w w w .java 2 s .c om*/ * * @see writeSegmentInfoRCR(WritableSheet, long, long, String, int) */ private int writeSegmentInfoICC(Workbook p_workbook, Sheet p_sheet, long p_jobId, String p_targetLang, String p_srcPageId, int p_row) throws Exception { Job job = ServerProxy.getJobHandler().getJobById(p_jobId); long companyId = job.getCompanyId(); Vector<TargetPage> targetPages = new Vector<TargetPage>(); TranslationMemoryProfile tmp = null; List<String> excludItems = null; GlobalSightLocale targetLocale = null; for (Workflow workflow : job.getWorkflows()) { 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_targetLang.equals(String.valueOf(workflow.getTargetLocale().getId()))) { targetLocale = workflow.getTargetLocale(); targetPages = workflow.getTargetPages(); tmp = workflow.getJob().getL10nProfile().getTranslationMemoryProfile(); if (tmp != null) { excludItems = new ArrayList<String>(tmp.getJobExcludeTuTypes()); } } } if (targetPages.isEmpty()) { // If no corresponding target page exists // and the row is the initial row, then set the cell blank if (SEGMENT_START_ROW == p_row) { writeBlank(p_workbook, p_sheet, SEGMENT_START_ROW, 10); } } else { LeverageMatchLingManager leverageMatchLingManager = LingServerProxy.getLeverageMatchLingManager(); TermLeverageManager termLeverageManager = ServerProxy.getTermLeverageManager(); Locale sourcePageLocale = job.getSourceLocale().getLocale(); Locale targetPageLocale = targetLocale.getLocale(); Map<Long, Set<TermLeverageMatch>> termLeverageMatchResultMap = null; TermLeverageOptions termLeverageOptions = getTermLeverageOptions(sourcePageLocale, targetPageLocale, job.getL10nProfile().getProject().getTermbaseName(), String.valueOf(job.getCompanyId())); if (termLeverageOptions != null) { termLeverageMatchResultMap = termLeverageManager.getTermMatchesForPages(job.getSourcePages(), targetLocale); } String category = null; PseudoData pData = new PseudoData(); pData.setMode(PseudoConstants.PSEUDO_COMPACT); String sourceSegmentString = null; String targetSegmentString = null; String sid = null; for (int i = 0; i < targetPages.size(); i++) { 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; } List sourceTuvs = SegmentTuvUtil.getSourceTuvs(sourcePage); List targetTuvs = SegmentTuvUtil.getTargetTuvs(targetPage); Map<Long, LeverageSegment> exactMatches = leverageMatchLingManager .getExactMatches(sourcePage.getIdAsLong(), new Long(targetPage.getLocaleId())); Map<Long, Set<LeverageMatch>> leverageMatcheMap = leverageMatchLingManager .getFuzzyMatches(sourcePage.getIdAsLong(), new Long(targetPage.getLocaleId())); 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++) { int col = 0; Tuv targetTuv = (Tuv) targetTuvs.get(j); Tuv sourceTuv = (Tuv) sourceTuvs.get(j); category = sourceTuv.getTu(companyId).getTuType(); if (excludItems != null && excludItems.contains(category)) { continue; } // Comment List issueHistories = null; String lastComment = ""; String failure = ""; Date issueCreatedDate = null; Issue issue = issuesMap.get(targetTuv.getId()); if (issue != null) { issueHistories = issue.getHistory(); failure = issue.getCategory(); } if (issueHistories != null && issueHistories.size() > 0) { IssueHistory issueHistory = (IssueHistory) issueHistories.get(0); lastComment = issueHistory.getComment(); issueCreatedDate = issueHistory.dateReportedAsDate(); } sourceSegmentString = sourceTuv.getGxmlElement().getTextValue(); sid = sourceTuv.getSid(); targetSegmentString = targetTuv.getGxmlElement().getTextValue(); Date targetSegmentModifiedDate = targetTuv.getLastModified(); StringBuilder matches = getMatches(exactMatches, leverageMatcheMap, targetTuv, sourceTuv); // Get Terminology/Glossary Source and Target. String sourceTerms = ""; String targetTerms = ""; if (termLeverageMatchResultMap != null) { Set<TermLeverageMatch> termLeverageMatchSet = termLeverageMatchResultMap .get(sourceTuv.getId()); if (termLeverageMatchSet != null && termLeverageMatchSet.size() > 0) { TermLeverageMatch tlm = termLeverageMatchSet.iterator().next(); sourceTerms = tlm.getMatchedSourceTerm(); targetTerms = tlm.getMatchedTargetTerm(); } } // For Implemented Comments Check Report (LSO Extension) if (lastComment.length() == 0) { continue; } CellStyle style = getContentStyle(p_workbook); // Set color format for target segment changed if (targetSegmentModifiedDate.before(issueCreatedDate)) { style = getRedStyle(p_workbook); } // Job id Row row = getRow(p_sheet, p_row); Cell cell_A = getCell(row, col++); cell_A.setCellValue(p_jobId); cell_A.setCellStyle(style); p_sheet.setColumnWidth(col - 1, 20 * 256); // Segment id Cell cell_B = getCell(row, col++); cell_B.setCellValue(sourceTuv.getTu(companyId).getId()); cell_B.setCellStyle(style); p_sheet.setColumnWidth(col - 1, 20 * 256); // 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 + ")"; } // TargetPage id Cell cell_C = getCell(row, col++); cell_C.setCellValue(Name); cell_C.setCellStyle(style); p_sheet.setColumnWidth(col - 1, 20 * 256); // Source segment CellStyle sourceStyle = m_rtlSourceLocale ? getRtlContentStyle(p_workbook) : style; String srcContent = m_rtlSourceLocale ? EditUtil.toRtlString(sourceSegmentString) : sourceSegmentString; Cell cell_D = getCell(row, col++); cell_D.setCellValue(srcContent); cell_D.setCellStyle(sourceStyle); p_sheet.setColumnWidth(col - 1, 40 * 256); // Target segment CellStyle targetStyle = m_rtlTargetLocale ? getRtlContentStyle(p_workbook) : style; String content = m_rtlTargetLocale ? EditUtil.toRtlString(targetSegmentString) : targetSegmentString; Cell cell_E = getCell(row, col++); cell_E.setCellValue(content); cell_E.setCellStyle(targetStyle); p_sheet.setColumnWidth(col - 1, 40 * 256); Cell cell_F = getCell(row, col++); cell_F.setCellValue(sid); cell_F.setCellStyle(style); p_sheet.setColumnWidth(col - 1, 40 * 256); CellStyle commentStyle = m_rtlTargetLocale ? getUnlockedRightStyle(p_workbook) : getUnlockedStyle(p_workbook); // Set color format for target segment changed if (targetSegmentModifiedDate.before(issueCreatedDate)) { commentStyle = m_rtlTargetLocale ? getRedRightStyle(p_workbook) : getRedStyle(p_workbook); } if (m_rtlTargetLocale) { lastComment = EditUtil.toRtlString(lastComment); } Cell cell_G = getCell(row, col++); cell_G.setCellValue(lastComment); cell_G.setCellStyle(commentStyle); p_sheet.setColumnWidth(col - 1, 40 * 256); // Category failure CellStyle cfStyle = getUnlockedStyle(p_workbook); // Set color format for target segment changed if (targetSegmentModifiedDate.before(issueCreatedDate)) { cfStyle = getRedStyle(p_workbook); } Cell cell_H = getCell(row, col++); cell_H.setCellValue(failure); cell_H.setCellStyle(cfStyle); p_sheet.setColumnWidth(col - 1, 30 * 256); // TM match Cell cell_I = getCell(row, col++); cell_I.setCellValue(matches.toString()); cell_I.setCellStyle(style); p_sheet.setColumnWidth(col - 1, 30 * 256); // Glossary source Cell cell_J = getCell(row, col++); cell_J.setCellValue(sourceTerms); cell_J.setCellStyle(style); p_sheet.setColumnWidth(col - 1, 30 * 256); // Glossary target Cell cell_K = getCell(row, col++); cell_K.setCellValue(targetTerms); cell_K.setCellStyle(style); p_sheet.setColumnWidth(col - 1, 30 * 256); p_row++; } } // Add category failure drop down list here. addCategoryFailureValidation(p_sheet, SEGMENT_START_ROW, p_row, CATEGORY_FAILURE_COLUMN, CATEGORY_FAILURE_COLUMN); } return p_row; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerVendorPoXlsReportHelper.java
License:Apache License
private void addTitle(Workbook p_workbook, Sheet p_sheet) throws Exception { Font titleFont = p_workbook.createFont(); titleFont.setUnderline(Font.U_NONE); titleFont.setFontName("Arial"); titleFont.setFontHeightInPoints((short) 14); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); titleFont.setColor(IndexedColors.BLACK.getIndex()); CellStyle titleStyle = p_workbook.createCellStyle(); titleStyle.setWrapText(false);/* w ww . j a v a 2s . c o m*/ titleStyle.setFont(titleFont); Row titleRow = getRow(p_sheet, 0); Cell titleCell = getCell(titleRow, 0); titleCell.setCellValue(EMEA + " " + bundle.getString("lb_reviewer_po")); titleCell.setCellStyle(titleStyle); p_sheet.setColumnWidth(0, 20 * 256); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerVendorPoXlsReportHelper.java
License:Apache License
/** * Adds the table header for the Dell Matches sheet * /* w w w . j av a 2 s .c om*/ */ private void addHeaderForDellMatches(Workbook p_workbook) throws Exception { Sheet theSheet = data.dellSheet; int c = 0; Row headerRow = getRow(theSheet, 2); Cell cell_A = getCell(headerRow, c); cell_A.setCellValue(bundle.getString("lb_job_id")); cell_A.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); c++; Cell cell_B = getCell(headerRow, c); cell_B.setCellValue(bundle.getString("lb_job_name")); cell_B.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); c++; Cell cell_C = getCell(headerRow, c); cell_C.setCellValue(bundle.getString("lb_po_number_report")); cell_C.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); theSheet.setColumnWidth(c, 15 * 256); c++; Cell cell_D = getCell(headerRow, c); cell_D.setCellValue(bundle.getString("lb_description")); cell_D.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); theSheet.setColumnWidth(c, 15 * 256); c++; Cell cell_E = getCell(headerRow, c); cell_E.setCellValue(bundle.getString("lb_creation_date")); cell_E.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); c++; Cell cell_F = getCell(headerRow, c); cell_F.setCellValue(bundle.getString("lb_activity_name")); cell_F.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); theSheet.setColumnWidth(c, 20 * 256); c++; Cell cell_G = getCell(headerRow, c); cell_G.setCellValue(bundle.getString("lb_accepted_reviewer_date")); cell_G.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); theSheet.setColumnWidth(c, 15 * 256); c++; Cell cell_H = getCell(headerRow, c); cell_H.setCellValue(bundle.getString("lb_lang")); cell_H.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); c++; Cell cell_I = getCell(headerRow, c); cell_I.setCellValue(bundle.getString("lb_word_count")); cell_I.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); theSheet.setColumnWidth(c, 15 * 256); c++; Cell cell_J = getCell(headerRow, c); cell_J.setCellValue(bundle.getString("jobinfo.tmmatches.invoice")); cell_J.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); c++; Cell cell_K = getCell(headerRow, c); cell_K.setCellValue(bundle.getString("lb_tracking")); cell_K.setCellStyle(getHeaderStyle(p_workbook)); theSheet.addMergedRegion(new CellRangeAddress(2, 3, c, c)); setRegionStyle(theSheet, new CellRangeAddress(2, 3, c, c), getHeaderStyle(p_workbook)); }