Topic: 请问数据组装与模板替换有没有相关的pattern?

  Print this page

1.请问数据组装与模板替换有没有相关的pattern? Copy to clipboard
Posted by: tier3
Posted on: 2004-08-20 21:14

我们现在有一个问题,是关于数据组装和模板替换方面的,
请教各位高人有没有相关的通用解决方案?

具体的需求是这样的:

一边是数据集:
DNAME,LOC,JOB,ENAME,SAL
ACCOUNTING,NEW YORK,CLERK,MILLER,1300
ACCOUNTING,NEW YORK,MANAGER,CLARK,2450
ACCOUNTING,NEW YORK,PRESIDENT,KING,5000
RESEARCH,DALLAS,ANALYST,FORD,3000
RESEARCH,DALLAS,ANALYST,SCOTT,3000
RESEARCH,DALLAS,CLERK,ADAMS,1100
RESEARCH,DALLAS,CLERK,SMITH,800
RESEARCH,DALLAS,MANAGER,JONES,2975
SALES,CHICAGO,CLERK,JAMES,950
SALES,CHICAGO,MANAGER,BLAKE,2850
SALES,CHICAGO,SALESMAN,ALLEN,1600
SALES,CHICAGO,SALESMAN,MARTIN,1250
SALES,CHICAGO,SALESMAN,TURNER,1500
SALES,CHICAGO,SALESMAN,WARD,1250

另一边是模板:

##DNAME## ##LOC##
##JOB##
##ENAME## ##SAL##
Sum for ##JOB## ##SAL.sum##
Sum for ##DNAME## ##SAL.sum##
GRAND TOTAL ##SAL.sum##

要求循环所有的数据集,把他们按照模板排列好,替换其中所有动态值,
所有summary值,最后输出结果。

请问大家遇到过类似的问题吗?
有没有相关的通用的解决方案?多谢了!

2.Re:请问数据组装与模板替换有没有相关的pattern? [Re: tier3] Copy to clipboard
Posted by: floater
Posted on: 2004-08-20 21:46

This is more like sending data to the view in spring web.

I know folks using velocity to do this(just stripping html part).

3.Re:请问数据组装与模板替换有没有相关的pattern? [Re: tier3] Copy to clipboard
Posted by: tier3
Posted on: 2004-08-23 12:11

I know of Velcity, but it is related to from Business layer to Presentation layer, my requirement is within business layer.
most of the tools currently in the market all are related to presentation layer, that is not what I want. Smile

4.Re:请问数据组装与模板替换有没有相关的pattern? [Re: tier3] Copy to clipboard
Posted by: zyzhang
Posted on: 2004-08-23 17:51

I think the concept or spirit using by Velcity, JSP page or what ever template-like product are essentially the same. Generally speaking, you donot need to do this kind of programming by yourself.

If you do need to create your own solution, i think you have to find a way to interpret your template defined and integrate with the result set(metat data mapping) from jdbc.

The Interpreter design pattern of GoF is a good reference to deal with the language template related implementation(If complicated enough, the parser generator with Interpreter pattern can work together).

Regarding the integration of data base, the book "Patterns of Enterprise Architecture" by Martin Fowler is a good referenced.

5.Re:请问数据组装与模板替换有没有相关的pattern? [Re: tier3] Copy to clipboard
Posted by: floater
Posted on: 2004-08-23 23:08

I mean we use a view tool to do business logic, Tounge. After all, a tool is just a tool, as long as it serves the purpose. Sometimes, we use 钳子 as 锤子.

6.Re:请问数据组装与模板替换有没有相关的pattern? [Re: tier3] Copy to clipboard
Posted by: 主管
Posted on: 2004-11-05 17:20

小心过度设计哦

最简单的方案,1搞到数据库里,用数据库搞定
2用execel搞定

你要的是解决问题,不是时髦的pattern
如果有其他要求那是另回事,你没讲,没有问题约束怎么出方案


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923