use of net.heartsome.cat.ts.ui.qa.model.WordsFAResult in project translationstudio8 by heartsome.
the class WordsFA method matching.
/**
* 开始处理匹配操作 如果返回null,则是用户点击退出按钮,执行退出操作
*/
public Map<String, WordsFAResult> matching(IProgressMonitor monitor) {
int matchTravelTuIndex = 0;
// 字数统计的结果集合
Map<String, WordsFAResult> wordsFAResultMap = new LinkedHashMap<String, WordsFAResult>();
Map<String, ArrayList<String>> languages = handler.getLanguages();
//先对每个文件存放一个结果集
for (IFile iFile : model.getAnalysisIFileList()) {
String filePath = iFile.getLocation().toOSString();
wordsFAResultMap.put(filePath, new WordsFAResult());
}
//针对每一个文件的结果集
WordsFAResult wordFaResult;
for (Entry<String, ArrayList<String>> langEntry : languages.entrySet()) {
String srcLanguage = langEntry.getKey();
for (String tgtLanguage : langEntry.getValue()) {
//针对每个文件,每种语言对获取其内容
allSrcTextsMap = getAllXlfSrcTexts(srcLanguage.toUpperCase(), tgtLanguage.toUpperCase());
// 如果返回的值为空,则标志用户点击了退出操作,那么退出程序
if (allSrcTextsMap == null) {
continue;
}
WordsFABean bean;
List<TranslationUnitAnalysisResult> exterMatchResult = null;
// 字数统计的结果集合
for (Entry<String, Map<String, WordsFABean>> textEntry : allSrcTextsMap.entrySet()) {
String filePath = textEntry.getKey();
IFile iFile = ResourceUtils.fileToIFile(filePath);
// 存储匹配结果的pojo类
wordFaResult = wordsFAResultMap.get(filePath);
Map<String, WordsFABean> fileSrcTextMap = textEntry.getValue();
monitor.setTaskName(MessageFormat.format(Messages.getString("qa.fileAnalysis.WordsFA.tip1"), iFile.getFullPath().toOSString()));
Iterator<Entry<String, WordsFABean>> it = fileSrcTextMap.entrySet().iterator();
while (it.hasNext()) {
Entry<String, WordsFABean> entry = (Entry<String, WordsFABean>) it.next();
matchTravelTuIndex++;
String rowId = entry.getKey();
bean = entry.getValue();
String srcPureText = bean.getSrcPureText();
int textLength = bean.getSrcLength();
String preTextHash = bean.getPreHash();
String nextTextHash = bean.getNextHash();
boolean isLocked = bean.isLocked();
String tagStr = bean.getTagStr();
int wordsCount = CountWord.wordCount(srcPureText, srcLanguage);
//若处于锁定状态,则添加到已锁定字数,然后跳出,执行下一文本段
if (isLocked) {
wordFaResult.setLockedPara(QAConstant.QA_FIRST);
wordFaResult.setLockedWords(wordsCount);
//删除该文本段,不再进行比较
fileSrcTextMap.remove(rowId);
it = fileSrcTextMap.entrySet().iterator();
continue;
}
// UNDO 应先判断数据库是否可用。
// 第一步,进行外部匹配,先封装参数。
tuInfoBean = new TransUnitInfo2TranslationBean();
tuInfoBean.setNextContext(bean.getNextHash());
tuInfoBean.setPreContext(bean.getPreHash());
tuInfoBean.setSrcFullText(bean.getSrcContent());
tuInfoBean.setSrcLanguage(srcLanguage);
tuInfoBean.setSrcPureText(bean.getSrcPureText());
tuInfoBean.setTgtLangugage(tgtLanguage);
exterMatchResult = tmMatcher.analysTranslationUnit(curProject, tuInfoBean);
int exterMatchRate = 0;
if (exterMatchResult != null && exterMatchResult.size() > 0) {
exterMatchRate = exterMatchResult.get(0).getSimilarity();
}
if (exterMatchRate == 100) {
// 如果锁定外部 100% 匹配,那么这些字数将被添加到锁定字数,而非外部 100% 匹配,外部101% 一样
if (model.isLockExter100()) {
wordFaResult.setLockedPara(QAConstant.QA_FIRST);
wordFaResult.setLockedWords(wordsCount);
needLockRowIdList.add(rowId);
} else {
wordFaResult.setExterRepeatPara(QAConstant.QA_FIRST);
wordFaResult.setExterMatchWords(wordsCount);
wordFaResult.setAllExterMatchWords(exterMatchRate, wordsCount);
}
//删除该文本段,不再进行比较
fileSrcTextMap.remove(rowId);
it = fileSrcTextMap.entrySet().iterator();
if (!handler.monitorWork(monitor, matchTravelTuIndex, workInterval, false)) {
return null;
}
continue;
}
if (exterMatchRate == 101) {
if (model.isLockExter101()) {
wordFaResult.setLockedPara(QAConstant.QA_FIRST);
wordFaResult.setLockedWords(wordsCount);
needLockRowIdList.add(rowId);
} else {
wordFaResult.setExterRepeatPara(QAConstant.QA_FIRST);
wordFaResult.setExterMatchWords(wordsCount);
wordFaResult.setAllExterMatchWords(exterMatchRate, wordsCount);
}
//删除该文本段,不再进行比较
fileSrcTextMap.remove(rowId);
it = fileSrcTextMap.entrySet().iterator();
if (!handler.monitorWork(monitor, matchTravelTuIndex, workInterval, false)) {
return null;
}
continue;
}
// 第二步,进行内部匹配
int inteMatchRate = 0;
// 如果要检查内部重复,那么就查找内部匹配
if (interRepeat) {
// 如果不进行内部模糊匹配,那么直接
int interNewWordsMaxMatchRate = interMatch ? newWordsMaxMatchRate : 100;
internalMatching(rowId, srcPureText, tagStr, textLength, preTextHash, nextTextHash, interNewWordsMaxMatchRate);
}
inteMatchRate = bean.getThisMatchRate() > inteMatchRate ? bean.getThisMatchRate() : inteMatchRate;
int maxMacthRate = exterMatchRate > inteMatchRate ? exterMatchRate : inteMatchRate;
if (inteMatchRate == 100 || inteMatchRate == 101) {
if (model.isLockInterRepeat()) {
wordFaResult.setLockedPara(QAConstant.QA_FIRST);
wordFaResult.setLockedWords(wordsCount);
needLockRowIdList.add(rowId);
} else {
wordFaResult.setInterRepeatPara(QAConstant.QA_FIRST);
wordFaResult.setInterMatchWords(wordsCount);
wordFaResult.setAllInterMatchWords(inteMatchRate, wordsCount);
}
} else if (maxMacthRate < newWordsMaxMatchRate) {
//最大匹配小于最小匹配时,就为新字数
wordFaResult.setNewPara(QAConstant.QA_FIRST);
wordFaResult.setNewWords(wordsCount);
} else {
if (inteMatchRate > exterMatchRate) {
// 内部匹配
wordFaResult.setInterMatchPara(QAConstant.QA_FIRST);
wordFaResult.setInterMatchWords(wordsCount);
wordFaResult.setAllInterMatchWords(inteMatchRate, wordsCount);
} else {
//外部匹配
wordFaResult.setExterMatchPara(QAConstant.QA_FIRST);
wordFaResult.setExterMatchWords(wordsCount);
wordFaResult.setAllExterMatchWords(exterMatchRate, wordsCount);
}
}
//删除该文本段,不再进行比较
fileSrcTextMap.remove(rowId);
it = fileSrcTextMap.entrySet().iterator();
if (!handler.monitorWork(monitor, matchTravelTuIndex, workInterval, false)) {
return null;
}
}
wordsFAResultMap.put(filePath, wordFaResult);
}
if (!handler.monitorWork(monitor, matchTravelTuIndex, workInterval, false)) {
return null;
}
}
}
lockRepeatTU(wordsFAResultMap);
return wordsFAResultMap;
}
use of net.heartsome.cat.ts.ui.qa.model.WordsFAResult in project translationstudio8 by heartsome.
the class WordsFA method paraSetInputData.
/**
* 创建第二张表的数据,关于文本段的统计
* @param curContainer
* @param paraFAdata
* @param paddLeft ;
*/
public void paraSetInputData(IContainer curContainer, StringBuffer paraFAdata, int paddLeft) {
paddLeft += 10;
// 先判断该容器中是否有直接子文件为本次分析文件
if (hasFAIFiles(curContainer)) {
// 每个文件的具体数据
for (int fIndex = 0; fIndex < model.getAnalysisIFileList().size(); fIndex++) {
IFile curIFile = model.getAnalysisIFileList().get(fIndex);
if (curIFile.getParent().equals(curContainer)) {
WordsFAResult faResult = WordsFAResultMap.get(curIFile.getLocation().toOSString());
paraFAdata.append("\t\t<tr id='" + curContainer.getFullPath().toOSString() + "' name='paras' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n");
// 文件名
paraFAdata.append("\t\t\t<td class='fileTd' style='padding-left: " + paddLeft + "'>" + curIFile.getName() + "</td>\n");
// 新文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNewPara() + "</td>\n");
if (interMatch) {
// 内部匹配文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getInterMatchPara() + "</td>\n");
}
// 外部匹配文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getExterMatchPara() + "</td>\n");
if (interRepeat) {
// 内部重复文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getInterRepeatPara() + "</td>\n");
}
// 外部重复文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getExterRepeatPara() + "</td>\n");
// 锁定文本段
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getLockedPara() + "</td>\n");
// 总段数
paraFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTotalPara() + "</td>\n");
paraFAdata.append("\t\t</tr>\n");
}
}
}
// 遍历所有含有分析文件的容器,找出当前容器的子容器,
for (int index = 0; index < allFolderList.size(); index++) {
IContainer childContainer = allFolderList.get(index);
if (childContainer.getParent().equals(curContainer)) {
WordsFAResult faResult = WordsFAResultMap.get(childContainer.getLocation().toOSString());
String folderId = childContainer.getFullPath().toOSString();
paraFAdata.append("<tr id='" + curContainer.getFullPath().toOSString() + "' name='paras' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' ><a href='javascript:void(0)' id='" + folderId + "' name='paras' class='link' style='padding-left: " + paddLeft + "'" + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)'>" + "<span id='" + folderId + "_span'>-</span> " + childContainer.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + faResult.getNewPara() + "</td>\n" + "<td class='folderTd' align='right'>" + (interMatch ? faResult.getInterMatchPara() + "</td>\n" + "<td class='folderTd' align='right'>" : "") + faResult.getExterMatchPara() + "</td>\n" + "<td class='folderTd' align='right'>" + (interRepeat ? faResult.getInterRepeatPara() + "</td>\n" + "<td class='folderTd' align='right'>" : "") + faResult.getExterRepeatPara() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getLockedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + faResult.getTotalPara() + "</td>\n" + "</tr>\n");
paraSetInputData(childContainer, paraFAdata, paddLeft);
}
}
}
use of net.heartsome.cat.ts.ui.qa.model.WordsFAResult in project translationstudio8 by heartsome.
the class WordsFA method allExterMatchSetInputData.
/**
* 创建第一张表的数据,新字数,内部匹配,外部匹配,锁定字数的统计
* @param exterFAdata
*/
public void allExterMatchSetInputData(IContainer curContainer, StringBuffer exterFAdata, int paddLeft, String[] equivArray) {
paddLeft += 10;
int length = equivArray.length;
// 先判断该容器中是否有直接子文件为本次分析文件
if (hasFAIFiles(curContainer)) {
// 每个文件的具体数据
for (int fIndex = 0; fIndex < model.getAnalysisIFileList().size(); fIndex++) {
IFile curIFile = model.getAnalysisIFileList().get(fIndex);
if (curIFile.getParent().equals(curContainer)) {
WordsFAResult faResult = WordsFAResultMap.get(curIFile.getLocation().toOSString());
exterFAdata.append("\t\t<tr id='" + curContainer.getFullPath().toOSString() + "' name='allExter' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n");
exterFAdata.append("\t\t\t<td class='fileTd' style='padding-left: " + paddLeft + "'>" + curIFile.getName() + // 文件名
"</td>\n");
//创建外部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "fileTd";
if (QAConstant._External101.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getExterMatch("101") + "</td>\n");
} else if (QAConstant._External100.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getExterMatch("100") + "</td>\n");
} else if (!QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getExterMatch(matchPair) + "</td>\n");
}
}
//创建内部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "fileTd";
if (interRepeat && QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getInterMatch("100-101") + "</td>\n");
} else if (interMatch && matchPair.indexOf("external") == -1) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getInterMatch(matchPair) + "</td>\n");
}
}
//创建新字数,锁定字数,总字数三列
exterFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getNewWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getEqalWords(equivStr) + "</td>\n");
exterFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getLockedWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='fileTd' align='right'>" + faResult.getTotalWords() + "</td>\n");
exterFAdata.append("\t\t</tr>\n");
}
}
}
// 遍历所有含有分析文件的容器,找出当前容器的子容器,
for (int index = 0; index < allFolderList.size(); index++) {
IContainer childContainer = allFolderList.get(index);
if (childContainer.getParent().equals(curContainer)) {
WordsFAResult faResult = WordsFAResultMap.get(childContainer.getLocation().toOSString());
String folderId = childContainer.getFullPath().toOSString();
exterFAdata.append("<tr id='" + curContainer.getFullPath().toOSString() + "' name='allExter' " + "onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' ><a href='javascript:void(0)' id='" + folderId + "' name='allExter' class='link' style='padding-left: " + paddLeft + "'" + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)'>" + "<span id='" + folderId + "_span'>-</span> " + childContainer.getName() + "</a></td>\n");
//创建外部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "folderTd";
if (QAConstant._External101.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getExterMatch("101") + "</td>\n");
} else if (QAConstant._External100.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getExterMatch("100") + "</td>\n");
// UNDO 这里的这个判断是否正确?
} else if (!QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getExterMatch(matchPair) + "</td>\n");
}
}
//创建内部匹配部
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "folderTd";
if (interRepeat && QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getInterMatch("100-101") + "</td>\n");
} else if (interMatch && matchPair.indexOf("external") == -1) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + faResult.getInterMatch(matchPair) + "</td>\n");
}
}
//创建新字数,锁定字数,新字数三列
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + faResult.getNewWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + faResult.getEqalWords(equivStr) + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + faResult.getLockedWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + faResult.getTotalWords() + "</td>\n");
exterFAdata.append("</tr>\n");
allExterMatchSetInputData(childContainer, exterFAdata, paddLeft, equivArray);
}
}
}
use of net.heartsome.cat.ts.ui.qa.model.WordsFAResult in project translationstudio8 by heartsome.
the class WordsFA method setDataToFolder.
/**
* 将文件下所有的子文件(直接或间接子文件)的值加到文件夹中
*/
public void setDataToFolder(IProject curProject) {
// 先存放项目相关的信息,所有的文件都存放在该项目中的,因此直接遍历所有的文件
WordsFAResult proFaResult = new WordsFAResult();
for (int i = 0; i < model.getAnalysisIFileList().size(); i++) {
IFile ifile = model.getAnalysisIFileList().get(i);
WordsFAResult faResult = WordsFAResultMap.get(ifile.getLocation().toOSString());
proFaResult.setNewPara(faResult.getNewPara());
proFaResult.setInterRepeatPara(faResult.getInterRepeatPara());
proFaResult.setInterMatchPara(faResult.getInterMatchPara());
proFaResult.setExterRepeatPara(faResult.getExterRepeatPara());
proFaResult.setExterMatchPara(faResult.getExterMatchPara());
proFaResult.setLockedPara(faResult.getLockedPara());
proFaResult.setNewWords(faResult.getNewWords());
proFaResult.setInterMatchWords(faResult.getInterMatchWords());
proFaResult.setExterMatchWords(faResult.getExterMatchWords());
proFaResult.setLockedWords(faResult.getLockedWords());
proFaResult.setAllExterMatchWords(faResult.getAllExterMatchWords());
proFaResult.setAllInterMatchWords(faResult.getAllInterMatchWords());
}
WordsFAResultMap.put(curProject.getLocation().toOSString(), proFaResult);
// 先遍历所有的文件夹
for (int index = 0; index < allFolderList.size(); index++) {
IContainer container = allFolderList.get(index);
WordsFAResult folderFaResult = new WordsFAResult();
// 循环所有的已经分析完的文件
for (int i = 0; i < model.getAnalysisIFileList().size(); i++) {
IFile ifile = model.getAnalysisIFileList().get(i);
IContainer iFileParent = ifile.getParent();
while (iFileParent != null) {
if (iFileParent.equals(container)) {
WordsFAResult faResult = WordsFAResultMap.get(ifile.getLocation().toOSString());
folderFaResult.setNewPara(faResult.getNewPara());
folderFaResult.setInterRepeatPara(faResult.getInterRepeatPara());
folderFaResult.setInterMatchPara(faResult.getInterMatchPara());
folderFaResult.setExterRepeatPara(faResult.getExterRepeatPara());
folderFaResult.setExterMatchPara(faResult.getExterMatchPara());
folderFaResult.setLockedPara(faResult.getLockedPara());
folderFaResult.setNewWords(faResult.getNewWords());
folderFaResult.setInterMatchWords(faResult.getInterMatchWords());
folderFaResult.setExterMatchWords(faResult.getExterMatchWords());
folderFaResult.setLockedWords(faResult.getLockedWords());
//所有外部匹配的值
folderFaResult.setAllExterMatchWords(faResult.getAllExterMatchWords());
//所有内部匹配的值
folderFaResult.setAllInterMatchWords(faResult.getAllInterMatchWords());
break;
} else {
iFileParent = iFileParent.getParent();
}
}
}
WordsFAResultMap.put(container.getLocation().toOSString(), folderFaResult);
}
}
use of net.heartsome.cat.ts.ui.qa.model.WordsFAResult in project translationstudio8 by heartsome.
the class WordsFA method createFAResultHtml.
/**
* 生成字数分析结果html文件
* @return html文件的路径
*/
public String createFAResultHtml() {
allFolderList = new LinkedList<IContainer>();
Date createDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String createTime = formatter.format(createDate);
formatter = new SimpleDateFormat("yyyyMMdd-HHmmss");
String htmlNameTime = formatter.format(createDate);
IProject curProject = model.getAnalysisIFileList().get(0).getProject();
String htmlName = "WordLog" + htmlNameTime + ".html";
String htmlPath = curProject.getLocation().append("Intermediate").append("Report").append(htmlName).toOSString();
File htmlFile = new File(htmlPath);
if (!htmlFile.getParentFile().exists()) {
htmlFile.getParentFile().mkdirs();
}
FileOutputStream output;
try {
output = new FileOutputStream(htmlPath);
output.write(QAConstant.FA_HtmlDoctype.getBytes("UTF-8"));
output.write("<html>\n".getBytes("UTF-8"));
String headerNode = QAConstant.FA_htmlHeader;
headerNode = headerNode.replace("###Title###", Messages.getString("qa.fileAnalysis.WordsFA.name1"));
output.write(headerNode.getBytes("UTF-8"));
output.write("\t<body>\n".getBytes("UTF-8"));
output.write(("<p class=\"title\">" + Messages.getString("qa.all.fa.WordsFA") + "</p>").getBytes("UTF-8"));
// ----------------<<<<<<start-- 下面是相关信息提示部份---------------------
output.write("\t<div>\n".getBytes("UTF-8"));
output.write("\t\t<table class=\"infoTableStyle\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n".getBytes("UTF-8"));
// 记忆库
String title = Messages.getString("qa.fa.info.tm");
ProjectConfiger projectConfiger = ProjectConfigerFactory.getProjectConfiger(curProject);
List<DatabaseModelBean> tmBeanList = projectConfiger.getAllTmDbs();
StringBuffer tmInfoSB = new StringBuffer();
if (tmBeanList.size() > 0) {
for (DatabaseModelBean bean : tmBeanList) {
tmInfoSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
String dbType = bean.getDbType();
if ("MySQL 5.x".equals(dbType)) {
dbType = "MySQL";
} else if ("MsSQL2005".equals(dbType)) {
dbType = "SQL Server";
}
tmInfoSB.append(dbType);
String location = "";
if ("Internal DB".equals(dbType) || "SQLite".equals(dbType)) {
location = bean.getItlDBLocation();
} else {
location = bean.getHost() + ":" + bean.getPort();
if (":".equals(location)) {
location = "";
}
}
if (location != null && !"".equals(location.trim()) && !" : ".equals(location)) {
tmInfoSB.append(" ( " + location + " ) ");
}
tmInfoSB.append(": ");
tmInfoSB.append(MessageFormat.format("{0}" + bean.getDbName() + "{1}", new Object[] { bean.isDefault() ? "<b>" : "", bean.isDefault() ? "</b>" : "" }));
tmInfoSB.append("</div>\n");
}
} else {
tmInfoSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
tmInfoSB.append("N/A");
tmInfoSB.append("</div>\n");
}
String infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", tmInfoSB.toString());
output.write(infoStr.getBytes("UTF-8"));
// 最底匹配率
title = Messages.getString("qa.fa.info.newWordMatch");
String content = newWordsMaxMatchRate + "%";
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", content);
output.write(infoStr.getBytes("UTF-8"));
// 分析文件总数
title = Messages.getString("qa.fa.info.fileSum");
content = "" + model.getSubFileNum();
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", content);
output.write(infoStr.getBytes("UTF-8"));
// 分析失败文件
title = Messages.getString("qa.fa.info.errorFiles");
StringBuffer errorFileSB = new StringBuffer();
errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
errorFileSB.append(model.getErrorIFileList().size());
errorFileSB.append("</div>");
for (IFile iFile : model.getErrorIFileList()) {
errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
errorFileSB.append(iFile.getFullPath().toOSString());
errorFileSB.append("</div>");
}
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", errorFileSB.toString());
output.write(infoStr.getBytes("UTF-8"));
// 报告生成时间
title = Messages.getString("qa.fa.info.createTime");
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", createTime);
output.write(infoStr.getBytes("UTF-8"));
output.write("</table></div><br>\n".getBytes("UTF-8"));
// ---------------->>>>>>end-- 报表信息提示部分结束---------------------
int paddLeft = 6;
String folderId = curProject.getFullPath().toOSString();
getAllFolder(curProject, allFolderList);
// 向所有的文件夹传值
setDataToFolder(curProject);
// 首先写下项目
WordsFAResult proFaResult = WordsFAResultMap.get(curProject.getLocation().toOSString());
// --------------数据库匹配率区间---------------------
output.write(("\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.WordsFA.wordsFA") + "</b></div>").getBytes("UTF-8"));
StringBuffer exterFAdata = new StringBuffer();
//"100-101:0.5;89-99:0.4"
String[] equivArray = equivStr.split(";");
int length = equivArray.length;
// 是否有 上下文匹配
boolean hasExter101 = equivStr.indexOf("external101") != -1;
int interMathNum = 0;
if (interRepeat && !interMatch) {
interMathNum = 1;
} else if (interRepeat && interMatch) {
interMathNum = length - (hasExter101 ? 2 : 1);
}
//要显示列的总数(文件列是普通列的三倍)
int columLength = length - 1 + interMathNum + 3 + 4;
float width = (float) 100 / columLength;
//开始创建表头
exterFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
// 表头
exterFAdata.append("\t\t<tr>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + 3 * width + "%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' colSpan='" + (length - 1) + "' width='" + (length - 1) * width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.exterMatch") + "</td>\n");
if (interRepeat) {
exterFAdata.append("\t\t\t<td class='headerTd' colSpan='" + interMathNum + "' width='" + interMathNum * width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.interMatch") + "</td>\n");
}
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.newWordsNum") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.equivWordsNum") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.lockWordsNum") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.wordsSum") + "</td>\n");
exterFAdata.append("\t\t</tr>\n");
exterFAdata.append("\t\t<tr>\n");
//这是创建显示结果的外部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "headerTd";
if (QAConstant._External101.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.contentMath") + "</td>\n");
} else if (QAConstant._External100.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + "100%" + "</td>\n");
} else if (!QAConstant._InternalRepeat.equals(matchPair)) {
matchPair = matchPair.substring(0, matchPair.indexOf("-")) + "%" + matchPair.substring(matchPair.indexOf("-"), matchPair.length()) + "%";
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + matchPair + "</td>\n");
}
}
//这是创建显示结果的内部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "headerTd";
if (interRepeat && QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.contentRepeat") + "</td>\n");
} else if (interMatch && matchPair.indexOf("external") == -1) {
matchPair = matchPair.substring(0, matchPair.indexOf("-")) + "%" + matchPair.substring(matchPair.indexOf("-"), matchPair.length()) + "%";
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + matchPair + "</td>\n");
}
}
exterFAdata.append("\t\t</tr>\n");
// 首先写下项目
exterFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'><a href='javascript:void(0)' id='" + folderId + "' name='allExter' class='link' " + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)' >" + "<span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n");
//项目的外部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "folderTd";
if (QAConstant._External101.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getExterMatch("101") + "</td>\n");
} else if (QAConstant._External100.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getExterMatch("100") + "</td>\n");
} else if (!QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getExterMatch(matchPair) + "</td>\n");
}
}
//项目的内部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "folderTd";
if (interRepeat && QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getInterMatch("100-101") + "</td>\n");
} else if (interMatch && matchPair.indexOf("external") == -1) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getInterMatch(matchPair) + "</td>\n");
}
}
//新字数,锁定字数,总字数
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getNewWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getEqalWords(equivStr) + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getLockedWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getTotalWords() + "</td>\n");
exterFAdata.append("</tr>");
allExterMatchSetInputData(curProject, exterFAdata, paddLeft, equivArray);
exterFAdata.append("\t</table>\n");
output.write(exterFAdata.toString().getBytes("UTF-8"));
// --------------文本段---------------------
output.write("<br/>\n".getBytes("UTF-8"));
output.write(("\t\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.WordsFA.paragraph") + "</b></div>").getBytes("UTF-8"));
StringBuffer paraFAdata = new StringBuffer();
int paraTableColumnNum = 4 + 3;
if (interRepeat && !interMatch) {
// 文件名列占两个单位的长度
paraTableColumnNum = 5 + 3;
} else if (interRepeat && interMatch) {
paraTableColumnNum = 6 + 3;
}
float paraCloumnWidth = (float) 100 / paraTableColumnNum;
// 创建一个表
paraFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
// 表头
paraFAdata.append("\t\t<tr>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + 2 * paraCloumnWidth + "%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.newPara") + "</td>\n");
if (interMatch) {
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.interMatchPara") + "</td>\n");
}
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.exterMatchPara") + "</td>\n");
if (interRepeat) {
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.interRepeatPara") + "</td>\n");
}
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.exterRepeatPara") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.lockedPara") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.paraSum") + "</td>\n");
paraFAdata.append("\t\t</tr>\n");
// 首先写下项目
paddLeft = 6;
paraFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'><a href='javascript:void(0)' id='" + folderId + "' name='paras' class='link' " + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)' ><span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNewPara() + "</td>\n" + (interMatch ? "<td class='folderTd' align='right'>" + proFaResult.getInterMatchPara() + "</td>\n" : "") + "<td class='folderTd' align='right'>" + proFaResult.getExterMatchPara() + "</td>\n" + (interRepeat ? "<td class='folderTd' align='right'>" + proFaResult.getInterRepeatPara() + "</td>\n" : "") + "<td class='folderTd' align='right'>" + proFaResult.getExterRepeatPara() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getLockedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTotalPara() + "</td>\n" + "</tr>");
paraSetInputData(curProject, paraFAdata, paddLeft);
paraFAdata.append("\t</table>\n");
output.write(paraFAdata.toString().getBytes("UTF-8"));
// output.write("\t\t</fieldset><br/>\n".getBytes("UTF-8"));
/* String htmlPathDiv = "<div style='width:100%;font-size:14;color:blue;'>"
+ Messages.getString("qa.all.fa.fileLocation")
+ curProject.getFullPath().append("Report").append(htmlName).toOSString() + "</div>";
output.write(htmlPathDiv.getBytes("UTF-8"));*/
output.write("\t</body>\n".getBytes("UTF-8"));
output.write("</html>".getBytes("UTF-8"));
output.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log6"), e);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log7"), e);
} catch (IOException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log8"), e);
}
return htmlPath;
}
Aggregations