Life/Asia table struct copybook convert to java pojo automaticlly

来源:互联网 发布:snare for windows 编辑:程序博客网 时间:2024/06/10 02:35

For My English Writing Practice(I know,Very poor)..

 

Technique Solution Overview

         First of all, We should retrive the table struct. But how can we achieve it? Since the Life/Asia table struct is build by display screen file by SMART commad: CB SXXX XDS. So we can retrive all screen(or table) fields by AS400 Command DSPFFD FILE(SXXX ) OUTPUT(*FILE) FILEOPT(*FIRST *ADD).

        After we get the table fields, you can make following consequence steps now.

(1)Resort them .(Fields in table struct copybook are sorted in ascending order)

(2)Create java pojo by table fields with FreeMarker .  We can read logical file fldd to determinate the field type and length.  Pojo name is TXXXXRecjava.

(3)Create a RFML file to map the table fields with FreeMarker. RFML file name = TXXXXREC.rfml

(4)Create a RFML Parase program, which can convert string(item.genarea) to java pojo with the help of RFML.  File name = TXXXXRecOParase.java. Bean name = tXXXXRecOParase.

(5)Create a helper class ItemRead with cacheable function.

    @Component("itemRead")
     public class ItemRead{

   @Cacheable..
   public <T> T read(String company,String table,String item,String seq,Class<T> classOfT){
  Item item = ItemReader.read(company,table,item,seq);
  String beanName = String.uncaplize(table) + "RecOParase";
  RfmlOParse<T> rfmlOParse = (RfmlOParse<T>) SptringUtil.getBean(beanName);
  return rfmlOparse.parse(item.getGenarea());
  }

(6) Snip Code

T5679Rec t5679Rec = itemRead.read("2","T5679","T512","",T5679Rec.class);