Insert Activity. GlueJdbcInsert Class는 "insert into emp(empno, ename, deptno) values(?, ?, ?)" 와 같은 SQL insert into 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 :
==>
binding(web) :
List args = new ArrayList();
args.add(((String[])ctx.get("EMPNO"))[0]);
args.add(((String[])ctx.get("ENAME"))[0]);
args.add(((String[])ctx.get("SAL"))[0]);
args.add(((String[])ctx.get("DEPTNO"))[0]);
GlueParameter param = new GlueParameter(args);
(NonUI) :
List args = new ArrayList();
args.add(ctx.get("EMPNO"));
args.add(ctx.get("ENAME"));
args.add(ctx.get("SAL"));
args.add(ctx.get("DEPTNO"));
GlueParameter param = new GlueParameter(args);
- case 2 : Looping 처리. (Web)
==>
binding : String[] checked = ctx.get("chk");
List args = new ArrayList();
for(int i=0, iz=checked.length; i param = new GlueParameter(args);
- case 3 : Looping 처리. (NonUI)
==>
binding : list = (ArrayList)ctx.get("dataList");
for(int i=0, iz=list.size(); i param = new GlueParameter(args);
..
}
- case 4 :
==>
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]);
args.put("deptno", ((String[])ctx.get("DEPTNO"))[0]);
GlueParameter
- case 5 : Looping 처리. (Web)
==>
binding : String[] checked = ctx.get("chk");
for(int i=0, iz=checked.length; i param = new GlueParameter(args);
..
}
- case 6 : Looping 처리. (NonUI)
==>
binding : List list = (ArrayList)ctx.get("dataList");
for(int i=0, iz=checked.length; i param = new GlueParameter(args);
..
}
Property 설정- dao : (필수) applicationContext.xml의 DAO id.
- sql-key : (필수) xxx-query.glue_sql의 query id
- param-count : (선택) Binding 할 개수 ( insert into emp(empno,ename,deptno) values (?,?,?) )의 "?" 수
- param#(param0,param1...) : (선택) Binding Value ("?"와 순서 일치 하여야 함)
- param-bindings : (선택) binding에 사용되는 값과 Mapping 되는 Key( bindName=ctxName[|bindName=ctxName] ).
ctx의 key가 binding variable name과 같은 경우 생략(대소문자 구분).
ctxName 은 Context의 Key이며, 가 있다면 "dataList" 의 map의 Key.
- chk-name : (선택) 화면의 CheckBox ID(HttpRequest의 parameter name).
와 같이 "chk" 가 선언 되어 있다면,
의 value 값에 따라 Looping 처리를 한다.
chk의 value는 0,1,2...,n 으로 부여되며 checked 된 값만 Context에 담긴다.
- list-key : (선택) SQL 문에 Binding 할 Data Context Key.
와 같이 "dataList" 가 선언 되어 있다면,
이전 Activity에서 List(Map) 구조의 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 ] : _insertCnt
- is-audit : insert시 Audit 항목 적용 Option
Audit 항목은 glue.properties에 audit.insert.key 와 audit.update.key 를 참고한다.
주의사항: Audit 항목은 SQL에 반영되어 있어야 한다.
GlueParameter를 사용해야하는 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.xmlQuery File : {name}-query.glue_sql
insert into emp(empno, ename, sal,deptno)
values(?, ?, ?, ?)
]]>
insert into emp(empno, ename, sal,deptno)
values(:empno, :ename, :sal, :deptno)
]]>
insert into emp_audit(
audit_create_id, audit_create_ip, audit_create_dt
, audit_update_id, audit_update_ip, audit_update_dt
, empno, ename, deptno)
values(?, ?, ?, ?, ?, ?, ?, ?, ?)
]]>
Field Summary
Fields inherited from class com.poscoict.glueframework.biz.activity.GlueActivity
Sub Class에서 반드시 구현하여야 하는 Abstract Method 이며 이 Method는 F/W에서 호출한다. 결과 값은 GlueContext에 담아서 다음 Activity 또는 F/W에 전달하게 된다. 필요한 모든 Data는
GlueContext에서 호출하여 사용하게 된다.