java.lang.Object
com.poscoict.glueframework.biz.activity.GlueActivity<GlueContext>
com.poscoict.glueframework.biz.activity.mongodb.GlueMongoFind

public class GlueMongoFind extends GlueActivity<GlueContext>
MongoRepository를 이용한 Document 조회.
 Activity Property
 
 - repository : (필수) applicationContext.xml의 repository id.

 - result-key : (선택) Context에 담기는 mongodb 조회결과
          [ default ] : {repository}_resultList

 - method-name : Repository에서 제공하는 다음 method를 제외한 조회용 method 명.
          [ default ] : 생략시 mongo-ids와 sort-names의 유무에 따라 다음이 사용됨
          List <T> findAll()
          List <T> findAll(Sort sort)
          Iterable <T> findAll(Iterable < ID > ids)
          T findOne(ID id)

 - method-bindings : (선택) method-name 사용시 해당 method의 매개변수 값 정보.
         ctxName=dataType|ctxName=dataType 형태임.
         ctx.get(ctxName)의 dataType 정보로 없을 경우 String으로.
         dataType은 String, int, boolean, ctx.get(ctxName).getClass() 으로 처리함.

 - mongo-ids : (선택) ctx의 key로 그 값은 @Id에 해당한다.

 - sort-names : (선택) entity의 field name과 정렬 정보.
         fieldName=asc|fieldName=desc 형태임
 


 예제
 
 사용 예# 1

     <activity name="FindAll" class="com.poscoict.glueframework.biz.activity.mongodb.GlueMongoFind">
         <transition name="success" value="NextActivity" />
         <property name="repository" value="customerRepository" />
         <property name="result-key" value="customerList" />
     </activity>


 사용 예# 2

     <activity name="Custom" class="...">
         <transition name="success" value="FindById" />
     </activity>
     <activity name="FindById" class="com.poscoict.glueframework.biz.activity.mongodb.GlueMongoFind">
         <transition name="success" value="NextActivity" />
         <property name="repository" value="customerRepository" />
         <property name="mongo-ids" value="ids" />
         <property name="result-key" value="customerList" />
     </activity>


 사용 예# 3

     <activity name="FindOnSort" class="com.poscoict.glueframework.biz.activity.mongodb.GlueMongoFind">
         <transition name="success" value="NextActivity" />
         <property name="repository" value="customerRepository" />
         <property name="sort-names" value="firstName=asc|lastName=desc" />
         <property name="result-key" value="customerList" />
     </activity>


 사용 예# 4

     <activity name="FindByMethod" class="com.poscoict.glueframework.biz.activity.mongodb.GlueMongoFind">
         <transition name="success" value="NextActivity" />
         <property name="repository" value="customerRepository" />
         <property name="method-name" value="findByFirstName" />
         <property name="method-bindings" value="firstName" />
         <property name="result-key" value="customerList" />
     </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> {
         public Customer findByFirstName(String firstName);
         public List<Customer> findByLastName(String lastName);
     }


 참고 : 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( "ids", ID );
 
Author:
황유진
  • Constructor Details

    • GlueMongoFind

      public GlueMongoFind()
  • Method Details

    • runActivity

      public String runActivity(GlueContext ctx)
      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 class GlueActivity<GlueContext>
      Parameters:
      ctx - GlueContext
      Returns:
      String 정상적이면 "success"를 Return 하고 비정상 처리를 원하면 "failure"를 Return 한다.