par.add(new RtfTableOfContents("如想查看目录,单击右键选择\"更新域\""));
par.setAlignment(1);
document.add(par);
CompositeDataProxy cdp = CompositeDataProxy.getInstance();
SingleDataProxy sdp = SingleDataProxy.getInstance();
Project p = new Project();
p.setProjectName(projectName);
p = (Project) sdp.get(p);
// 得到该项目的所有的场景
Scenario s = new Scenario();
s.setProjectId(p.getProjectId());
scenarios = cdp.query(s);
if (scenarios.size() > 0) {
for (int i = 0; i < scenarios.size(); i++) {
s = (Scenario) scenarios.get(i);
document.add(new Paragraph(""));
// 加场景名
document.add(new Paragraph("场景" + (i + 1) + ": "
+ s.getScenarioName().toString(),
RtfParagraphStyle.STYLE_HEADING_1));
// TODO 加用况
UseCase uc = new UseCase();
uc.setScenarioId(s.getScenarioId());
ArrayList ucs = cdp.query(uc);
if (ucs.size() > 0) {
for (int j = 0; j < ucs.size(); j++) {
uc = (UseCase) ucs.get(j);
document.add(new Paragraph(""));
document.add(new Paragraph("用况" + (i + 1) + "."
+ (j + 1) + ": "
+ uc.getUseCaseName().toString(),
RtfParagraphStyle.STYLE_HEADING_2));
RtfBorderGroup normal = new RtfBorderGroup(
Rectangle.BOX, RtfBorder.BORDER_SINGLE, 1,
new Color(0, 0, 0));
Paragraph title = new Paragraph();
title.add(new Chunk(uc.getUseCaseName().trim()));
title.setAlignment(1);
document.add(title);
RtfCell useCaseID = new RtfCell("用况编号:");
useCaseID.setBorders(normal);
RtfCell useCaseIDC = new RtfCell(uc.getUseCaseId()
.toString());
useCaseIDC.setBorders(normal);
RtfCell useCaseName = new RtfCell("用况名称:");
useCaseName.setBorders(normal);
RtfCell useCaseNameC = new RtfCell(uc.getUseCaseName());
useCaseNameC.setBorders(normal);
RtfCell useCaseDescription = new RtfCell("用况描述:");
useCaseDescription.setBorders(normal);
RtfCell useCaseDescriptionC = new RtfCell(uc
.getUseCaseDescription());
useCaseDescriptionC.setBorders(normal);
RtfCell useCasePriority = new RtfCell("用况优先级:");
useCasePriority.setBorders(normal);
RtfCell useCasePriorityC = null;
if (uc.getUseCasePriority() != null) {
useCasePriorityC = new RtfCell(uc
.getUseCasePriority().toString());
} else {
useCasePriorityC = new RtfCell("");
}
useCasePriorityC.setBorders(normal);
RtfCell specialRequirement = new RtfCell("特殊要求:");
specialRequirement.setBorders(normal);
RtfCell specialRequirementC = new RtfCell(uc
.getUseCaseSpecialRequirement());
specialRequirementC.setColspan(3);
specialRequirementC.setBorders(normal);
RtfCell preCondition = new RtfCell("前置条件:");
preCondition.setBorders(normal);
RtfCell preConditionC = new RtfCell(uc
.getUseCasePreconditions());
preConditionC.setColspan(3);
preConditionC.setBorders(normal);
RtfCell fireCondition = new RtfCell("触发条件:");
fireCondition.setBorders(normal);
RtfCell fireConditionC = new RtfCell(uc
.getUseCaseTrigger());
fireConditionC.setColspan(3);
fireConditionC.setBorders(normal);
RtfCell postCondition = new RtfCell("后置条件:");
postCondition.setBorders(normal);
RtfCell postConditionC = new RtfCell(uc
.getUseCasePostConditions());
postConditionC.setColspan(3);
postConditionC.setBorders(normal);
RtfCell failedEndCondition = new RtfCell("失败情况:");
failedEndCondition.setBorders(normal);
RtfCell failedEndConditionC = new RtfCell(uc
.getUseCaseFailedEndCondition());
failedEndConditionC.setColspan(3);
failedEndConditionC.setBorders(normal);
Table table = new Table(4);
table.addCell(useCaseID);
table.addCell(useCaseIDC);
table.addCell(useCaseName);
table.addCell(useCaseNameC);
table.addCell(useCaseDescription);
table.addCell(useCaseDescriptionC);
table.addCell(useCasePriority);
table.addCell(useCasePriorityC);
table.addCell(fireCondition);
table.addCell(fireConditionC);
table.addCell(preCondition);
table.addCell(preConditionC);
table.addCell(failedEndCondition);
table.addCell(failedEndConditionC);
table.addCell(postCondition);
table.addCell(postConditionC);
table.addCell(specialRequirement);
table.addCell(specialRequirementC);
// 生成Use Case具体描述的标题
RtfCell userOperation = new RtfCell("用户操作");
userOperation.setBorders(normal);
RtfCell systemOperation = new RtfCell("系统操作");
systemOperation.setBorders(normal);
RtfCell systemOutput = new RtfCell("系统输出");
systemOutput.setBorders(normal);
Table table2 = new Table(3);
table2.addCell(userOperation);
table2.addCell(systemOperation);
table2.addCell(systemOutput);
// 生成Use Case具体描述的内容
ArrayList ucis = new ArrayList();
UseCaseInteraction uci = new UseCaseInteraction();
uci.setUseCaseId(uc.getUseCaseId());
OrderRule orderule = new OrderRule();
orderule.setOrderColumn("sequence");
orderule.setOrderDirection(OrderDirection.ASC);
OrderRule[] orderRules = { orderule };
String temp;
ucis = cdp.query(uci, orderRules);
if (ucis.size() > 0) {
for (int k = 0; k < ucis.size(); k++) {
temp = ((UseCaseInteraction) ucis.get(k))
.getOperatorAction();
temp = removeHtml(temp);