Class GlueMongoSave
java.lang.Object
com.poscoict.glueframework.biz.activity.GlueActivity<GlueContext>
com.poscoict.glueframework.biz.activity.mongodb.GlueMongoSave
MongoRepository를 이용한 Document 저장.
Activity Property
- repository : (필수) applicationContext.xml의 repository id.
- entity-id / entity-name : (필수) 둘 중 하나만 항상 있어야 함.
entity-id : ctx에 담긴 entity를 나타내는 key
entity-name : 생성하고자 하는 entity class명
- entity-bindings : (선택) entity-name이 사용될 경우 필요함.
binding에 사용되는 값과 Mapping 되는 Key( fieldName=ctxKey[|fieldName=ctxKey] ).
- result-key : (선택) Context에 담기는 mongodb 저장결과
[ default ] : {repository}_result
예제
사용 예# 1
<activity name="Custom" class="...">
<transition name="success" value="Save" />
</activity>
<activity name="Save" class="com.poscoict.glueframework.biz.activity.mongodb.GlueMongoSave">
<transition name="success" value="NextActivity" />
<property name="repository" value="customerRepository" />
<property name="entity-id" value="data" />
</activity>
사용 예# 2
<activity name="Custom" class="...">
<transition name="success" value="Save" />
</activity>
<activity name="Save" class="com.poscoict.glueframework.biz.activity.mongodb.GlueMongoSave">
<transition name="success" value="NextActivity" />
<property name="repository" value="customerRepository" />
<property name="entity-id" value="dataList" />
</activity>
사용 예# 3
<activity name="Custom" class="...">
<transition name="success" value="SaveEntity" />
</activity>
<activity name="SaveEntity" class="com.poscoict.glueframework.biz.activity.mongodb.GlueMongoSave">
<transition name="success" value="NextActivity" />
<property name="repository" value="customerRepository" />
<property name="entity-name" value="sample.vo.Customer" />
<property name="entity-bindings" value="firstName=fName|lastName=lName" />
</activity>
참고 : applicationContext.xml
<mongo:repositories base-package="sample.repository" />
참고 : MongoRepository 확장
package sample.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import sample.vo.Customer;
public interface CustomerRepository extends MongoRepository<Customer, String> {
}
참고 : Document
package sample.vo;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document
public class Customer {
@Id
private String id;
private String firstName;
private String lastName;
public Customer( String firstName, String lastName ) {
this.firstName = firstName;
this.lastName = lastName;
}
}
참고 : Java Code (Custom)
ctx.put( "data", new Customer("glue", "f/w") );
List dataList = new ArrayList();
dataList.add(new Customer("glue", "f/w"));
dataList.add(new Customer("spring", "f/w"));
ctx.put( "dataList", dataList );
ctx.put( "fName", "glue" );
ctx.put( "lName", "f/w" );
- Author:
- 황유진
-
Field Summary
Fields inherited from class com.poscoict.glueframework.biz.activity.GlueActivity
dynamicProperties, logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrunActivity
(GlueContext ctx) Sub Class에서 반드시 구현하여야 하는 Abstract Method 이며 이 Method는 F/W에서 호출한다.Methods inherited from class com.poscoict.glueframework.biz.activity.GlueActivity
commitTransaction, commitTransaction, getDao, getEventList, getName, getProperty, getPropertyNames, getTransition, rollbackTransaction, rollbackTransaction, setEventList, setName, setProperty, setTransition
-
Constructor Details
-
GlueMongoSave
public GlueMongoSave()
-
-
Method Details
-
runActivity
Description copied from class:GlueActivity
Sub Class에서 반드시 구현하여야 하는 Abstract Method 이며 이 Method는 F/W에서 호출한다. 결과 값은 GlueContext에 담아서 다음 Activity 또는 F/W에 전달하게 된다. 필요한 모든 Data는 GlueContext에서 호출하여 사용하게 된다.예) <transition name="success" value="BizLogic"/> <transition name="failure" value="ErrorHandle"/> ==> return "success"이면 BizLogic Activity 를 실행함.
- Specified by:
runActivity
in classGlueActivity<GlueContext>
- Parameters:
ctx
- GlueContext- Returns:
- String 정상적이면 "success"를 Return 하고 비정상 처리를 원하면 "failure"를 Return 한다.
-