com.poscoict.glueframework.biz.activity
Class GlueJdbcModify

java.lang.Object
  extended by com.poscoict.glueframework.biz.activity.GlueActivity<GlueContext>
      extended by com.poscoict.glueframework.biz.activity.GlueJdbcModify

public class GlueJdbcModify
extends GlueActivity<GlueContext>

Modify Activity. GlueJdbcModify Class´Â "update emp set ename=?, job=? where empno=?" ¿Í °°Àº SQL update statement¸¦ ¼öÇà ÇÏ´Â Activity ÀÌ´Ù. WebÈ­¸é°ú NonUI °øÅëÀ¸·Î »ç¿ëµÇ°í Binding Parameter TypeÀº WebÀÎ °æ¿ì String []ÀÇ {0}¹ø°·Î Binding ÇÏ°í WebÀÌ ¾Æ´Ñ °æ¿ì´Â ÇØ´ç Object¸¦ Binding ÇÑ´Ù. ¿©±â¼­ chk-nameÀÌ ÀÖ´Â °æ¿ì WebÀÇ CheckBox¿¡ Check µÈ ¼ö¸¸Å­ ¹Ýº¹ ÇÏ°í ¾ø´Â °æ¿ì´Â Context¿¡¼­ ¹Ù·Î String[] ·Î getÇÏ¿© Binding ÇÑ´Ù. NonUIÀÇ °æ¿ì Data TypeÀÌ String[]°¡ ¾Æ´Ñ °æ¿ì ¹Ù·Î ÇØ´ç Object·Î Binding ÇÑ´Ù.

 »ç¿ë ¿¹
 - case 1 :
 <activity name="Modify" class="com.poscoict.glueframework.biz.activity.GlueJdbcModify">
     <property name="dao" value="testdao" />
     <property name="sql-key" value="emp.update" />
     <property name="param-count" value="3" />
     <property name="param0" value="SAL" />
     <property name="param1" value="ENAME" />
     <property name="param2" value="EMPNO" />
     <property name="result-key" value="updateCnt" />
     <transition name="success" value="Find" />
 </activity>
 ==>
      binding(web) :
              List args = new ArrayList();
              args.add(((String[])ctx.get("SAL"))[0]);
              args.add(((String[])ctx.get("ENAME"))[0]);
              args.add(((String[])ctx.get("EMPNO"))[0]);
              GlueParameter<List> param = new GlueParameter<List>(args);
           (NonUI) :
              List args = new ArrayList();
              args.add(ctx.get("SAL"));
              args.add(ctx.get("ENAME"));
              args.add(ctx.get("EMPNO"));
              GlueParameter<List> param = new GlueParameter<List>(args);
 
 
 - case 2 : Looping ó¸®. (Web)
 <activity name="Modify" class="com.poscoict.glueframework.biz.activity.GlueJdbcModify">
     <property name="dao" value="testdao" />
     <property name="sql-key" value="emp.update" />
     <property name="param-count" value="3" />
     <property name="param0" value="SAL" />
     <property name="param1" value="ENAME" />
     <property name="param2" value="EMPNO" />
     <property name="result-key" value="updateCnt" />
     <property name="chk-name" value="chk" />
     <transition name="success" value="Find" />
 </activity>
 ==>
      binding : String[] checked = ctx.get("chk");
              List args = new ArrayList();
              for(int i=0, iz=checked.length; i<iz; i++){
                  args.add(((String[])ctx.get("SAL"))[Integer.parseInt(checked[i])]);
                  args.add(((String[])ctx.get("ENAME"))[Integer.parseInt(checked[i])]);
                  args.add(((String[])ctx.get("EMPNO"))[Integer.parseInt(checked[i])]);
              }
              GlueParameter<List> param = new GlueParameter<List>(args);
 
 
 - case 3 : Looping ó¸®. (NonUI)
 <activity name="Modify" class="com.poscoict.glueframework.biz.activity.GlueJdbcModify">
     <property name="dao" value="testdao" />
     <property name="sql-key" value="emp.update" />
     <property name="param-count" value="3" />
     <property name="param0" value="SAL" />
     <property name="param1" value="ENAME" />
     <property name="param2" value="EMPNO" />
     <property name="result-key" value="updateCnt" />
     <property name="list-key" value="dataList" />
     <transition name="success" value="Find" />
 </activity>
 ==>
      binding : list = (ArrayList)ctx.get("dataList");
              for(int i=0, iz=list.size(); i<iz; i++){
                  List args = new ArrayList();
                  args.add(((Map)list.get(i)).get("SAL"));
                  args.add(((Map)list.get(i)).get("ENAME"));
                  args.add(((Map)list.get(i)).get("EMPNO"));
                  GlueParameter<List> param = new GlueParameter<List>(args);
                  ..
              }
 
 
 - case 4 :
 <activity name="Modify" class="com.poscoict.glueframework.biz.activity.GlueJdbcModify">
     <property name="dao" value="testdao" />
     <property name="sql-key" value="emp.update.named" />
     <property name="param-bindings" value="empno=EMPNO|ename=ENAME|sal=SAL" />
     <property name="result-key" value="updateCnt" />
     <transition name="success" value="Find" />
 </activity>
 ==>
      binding(web) :
              Map args = new HashMap();
              args.put("empno", ((String[])ctx.get("EMPNO"))[0]);
              args.put("ename", ((String[])ctx.get("ENAME"))[0]);
              args.put("sal", ((String[])ctx.get("SAL"))[0]);
              GlueParameter<Map> param = new GlueParameter<Map>(args);
           (NonUI) : 
              Map args = new HashMap();
              args.put("empno", ctx.get("EMPNO"));
              args.put("ename", ctx.get("ENAME"));
              args.put("sal", ctx.get("SAL"));
              GlueParameter<Map> param = new GlueParameter<Map>(args);
 
 
 - case 5 : Looping ó¸®. (Web)
 <activity name="Modify" class="com.poscoict.glueframework.biz.activity.GlueJdbcModify">
     <property name="dao" value="testdao" />
     <property name="sql-key" value="emp.update.named" />
     <property name="param-bindings" value="empno=EMPNO|ename=ENAME|sal=SAL" />
     <property name="result-key" value="updateCnt" />
     <property name="chk-name" value="chk" />
     <transition name="success" value="Find" />
 </activity>
 ==>
      binding : String[] checked = ctx.get("chk");
              for(int i=0, iz=checked.length; i<iz; i++){
                  Map args = new HashMap();
                  args.put("empno", ((String[])ctx.get("EMPNO"))[Integer.parseInt(checked[i])]);
                  args.put("ename", ((String[])ctx.get("ENAME"))[Integer.parseInt(checked[i])]);
                  args.put("sal", ((String[])ctx.get("SAL"))[Integer.parseInt(checked[i])]);
                  GlueParameter<Map> param = new GlueParameter<Map>(args);
                  ..
              }
 
 
 - case 6 : Looping ó¸®. (NonUI)
 <activity name="Modify" class="com.poscoict.glueframework.biz.activity.GlueJdbcModify">
     <property name="dao" value="testdao" />
     <property name="sql-key" value="emp.update.named" />
     <property name="param-bindings" value="empno=EMPNO|ename=ENAME|sal=SAL" />
     <property name="result-key" value="updateCnt" />
     <property name="list-key" value="dataList" />
     <transition name="success" value="Find" />
 </activity>
 ==>
      binding : List list = (ArrayList)ctx.get("dataList");
              for(int i=0, iz=checked.length; i<iz; i++){
                  Map args = new HashMap();
                  args.put("empno", ((Map)list.get(i)).get("EMPNO"));
                  args.put("ename", ((Map)list.get(i)).get("ENAME"));
                  args.put("sal", ((Map)list.get(i)).get("ENAME"));
                  GlueParameter<Map> param = new GlueParameter<Map>(args);
                  ..
              }
 
 
 
 Property ¼³Á¤
 - dao : (Çʼö) applicationContext.xmlÀÇ DAO id.
 
 - sql-key : (Çʼö) xxx-query.glue_sqlÀÇ query id
 
 - param-count : (¼±ÅÃ) Binding ÇÒ °³¼ö ( update emp set ename=? job=? where empno=? )ÀÇ "?" ¼ö
 
 - param#(param0,param1...) : (¼±ÅÃ) Binding Value ("?"¿Í ¼ø¼­ ÀÏÄ¡ ÇÏ¿©¾ß ÇÔ)
 
 - param-bindings : (¼±ÅÃ) binding¿¡ »ç¿ëµÇ´Â °ª°ú Mapping µÇ´Â Key( bindName=ctxName[|bindName=ctxName] ).
         ctxÀÇ key°¡ binding variable name°ú °°Àº °æ¿ì »ý·«(´ë¼Ò¹®ÀÚ ±¸ºÐ).
         ctxName Àº ContextÀÇ KeyÀ̸ç, <property name="list-key" value="dataList" />°¡ ÀÖ´Ù¸é "dataList" ÀÇ mapÀÇ Key.
 
 - chk-name : (¼±ÅÃ) È­¸éÀÇ CheckBox ID(HttpRequestÀÇ parameter name).
         <property name="chk-name" value="chk" /> ¿Í °°ÀÌ "chk" °¡ ¼±¾ð µÇ¾î ÀÖ´Ù¸é,
         <input type="checkbox" name="chk">ÀÇ value °ª¿¡ µû¶ó Looping 󸮸¦ ÇÑ´Ù.
         chkÀÇ value´Â 0,1,2...,n À¸·Î ºÎ¿©µÇ¸ç checked µÈ °ª¸¸ Context¿¡ ´ã±ä´Ù.
 
 - list-key : (¼±ÅÃ) SQL ¹®¿¡ Binding ÇÒ Data Context Key.
         <property name="list-key" value="dataList" /> ¿Í °°ÀÌ "dataList" °¡ ¼±¾ð µÇ¾î ÀÖ´Ù¸é,
         ÀÌÀü Activity¿¡¼­ List(Map<name, value>) ±¸Á¶ÀÇ Data¸¦ »ý¼ºÇؼ­ Context¿¡ ´ã´Â´Ù.
         [ sample java code ] 
             List dataList = new ArrayList();
             Map data1 = new HashMap();
             data1.put("EMPNO","1111");
             data1.put("ENAME","SCOTT");
             data1.put("DEPTNO","10");
             dataList.add(data1);
             Map data2 = new HashMap();
             data2.put("EMPNO","2222");
             data2.put("ENAME","JANE");
             data2.put("DEPTNO","10");
             dataList.add(data2);
             ctx.put("dataList",dataList);
 
 - result-key : (¼±ÅÃ) Context¿¡ ´ã±â´Â Query ¼öÇà °á°ú(¼öÁ¤ record ¼ö) Key.
         [ default ] : <sql-key>_updateCnt
 
 - is-audit : update½Ã Audit Ç׸ñ Àû¿ë Option
          Audit Ç׸ñÀº glue.properties¿¡ audit.insert.key ¿Í audit.update.key ¸¦ Âü°íÇÑ´Ù.
          ÁÖÀÇ»çÇ×: Audit Ç׸ñÀº SQL¿¡ ¹Ý¿µµÇ¾î ÀÖ¾î¾ß ÇÑ´Ù. 
                GlueParameter<List>¸¦ »ç¿ëÇؾßÇÏ´Â SQLÀÎ °æ¿ì, 
                ColumnÀÇ ¼ø¼­´Â glue.properties¿¡ Á¤ÀÇÇÑ ¼ø¼­¿Í °°¾Æ¾ß Çϸç, 
                Audit Ç׸ñÀ» À§ SQLó·³ ¸Ç ¾Õ¿¡ ±â¼úµÇ¾î¾ß ÇÑ´Ù.
 
 
 
 glue.properties
 audit.insert.key=id,ip,cur_time,id,ip,cur_time
 audit.update.key=id,ip,cur_time
  
 applicationContext.xml
 <bean id="testdao" class="com.poscoict.glueframework.dao.jdbc.GlueJdbcDao">
     <property name="dataSource"><ref local="dataSource"/></property>
     <property name="queryManager"><ref local="queryManager"/></property>
 </bean>
 
 Query File : {name}-query.glue_sql
 <query id="emp.update" desc="Type #1">
     <![CDATA[ 
           update emp
           set sal=?, ename=?
           where empno=?
     ]]> 
 </query>
 <query id="emp.update.named" desc="Type #1" isNamed="true">
     <![CDATA[ 
           update emp
           set sal=:sal, ename=:ename
           where empno=:empno
     ]]>
 </query>
 <query id="emp.update.audit">
     <![CDATA[ 
           update emp_audit
           set audit_update_id=?, audit_update_ip=?, audit_update_dt=?, 
             ename=?, job=?
           where empno=?
     ]]>
 </query>
 


Field Summary
 
Fields inherited from class com.poscoict.glueframework.biz.activity.GlueActivity
dynamicProperties, logger
 
Constructor Summary
GlueJdbcModify()
           
 
Method Summary
 String runActivity(GlueContext ctx)
          Sub Class¿¡¼­ ¹Ýµå½Ã ±¸ÇöÇÏ¿©¾ß ÇÏ´Â Abstract Method À̸ç ÀÌ Method´Â F/W¿¡¼­ È£ÃâÇÑ´Ù.
 
Methods inherited from class com.poscoict.glueframework.biz.activity.GlueActivity
commitTransaction, getDao, getEventList, getName, getProperty, getPropertyNames, getTransition, rollbackTransaction, setEventList, setName, setProperty, setTransition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlueJdbcModify

public GlueJdbcModify()
Method Detail

runActivity

public String runActivity(GlueContext ctx)
Description copied from class: GlueActivity
Sub Class¿¡¼­ ¹Ýµå½Ã ±¸ÇöÇÏ¿©¾ß ÇÏ´Â Abstract Method À̸ç ÀÌ Method´Â F/W¿¡¼­ È£ÃâÇÑ´Ù. °á°ú °ªÀº GlueContext¿¡ ´ã¾Æ¼­ ´ÙÀ½ Activity ¶Ç´Â F/W¿¡ Àü´ÞÇÏ°Ô µÈ´Ù. ÇÊ¿äÇÑ ¸ðµç Data´Â GlueContext¿¡¼­ È£ÃâÇÏ¿© »ç¿ëÇÏ°Ô µÈ´Ù.

Specified by:
runActivity in class GlueActivity<GlueContext>
Parameters:
ctx - GlueContext
Returns:
String Á¤»óÀûÀ̸é "success"¸¦ Return ÇÏ°í ºñÁ¤»ó 󸮸¦ ¿øÇϸé "failure"¸¦ Return ÇÑ´Ù.
 ¿¹) 
 <transition name="success" value="BizLogic"/>
 <transition name="failure" value="ErrorHandle"/>
 ==> return "success"À̸é BizLogic Activity ¸¦ ½ÇÇàÇÔ.
 


Copyright © 2013–2014 POSCO ICT SWÁ¦Ç°±â¼úÆÀ. All rights reserved.