posts - 7, comments - 3, trackbacks - 0, articles - 26

          How to use ConditionBuilder.

          Posted on 2010-02-03 10:04 delvin 閱讀(305) 評論(0)  編輯  收藏

          It is very complex to use ConditionBuilder to control visiable or others.
          We will use a example to explain  how to use ConditionBuilder. We choose the file visiblity.
          We need to use ConditionGroups to determine whether or not a given file is
          visible to a given Candidate.  To see how ConditionGroups work, study the
          CandidateRestriction system (login to the app and go to
          /durango/do/candidaterestriction/list).

          There are several parts to implementing this:
          - database and entity bean changes
          - back-end code to use ConditionGroupEngine for file visibility
          - UI work to use the ConditionBuilder code to set up rules for a given file's visibility

          This bug will cover the database and entity bean changes. 

          Create a new FileEntityConditionGroup table, similar to
          CandidateRestrictionConditionGroup, to link the FileEntity and ConditionGroup tables.

          Also create a FileEntityConditionGroup entity bean which extends ConditionGroup
          (see CandidateRestrictionConditionGroup as an example).  Then make the existing
          FileEntity class implement the ConditionGroupAdapter interface, similarly to
          CandidateRestriction.


          To determine whether a given Candidate can see a given File, we'll use the
          ConditionGroupEngine.  This engine is based on the drools rules engine.  It
          works like this:

          Facts -> Engine+Rules -> Result

          That is, you give the engine some facts and some rules, and it applies the
          rules to the set of facts, and returns a result.

          In our case the engine and rules are pretty much taken care of by the existing
          condition group framework.  But we'll need to create the facts, and create a
          class to hold the results.

          First, look at ConditionGroupEngineFactory, which has methods to return various
          types of ConditionGroup engines.  We want to add a method,
          getFileVisibilityConditionGroupEngine(EntityManager, Map<Enum,Object>).  Like
          the other methods, it should check that the OWNER_ID and CANDIDATE_ID params
          are in the map, then call the ConditionGroupEngine constructor to return an
          engine. 

          To make this constructor call we need a lot of new stuff:

          First, a new FILEVISIBILITY_CONDITION_RULE_NAME, and a corresponding section in
          the conditionRules.xml file.  Create a FileVisibilityConditionGroupGenerator
          similar to other subclasses of RuleGenerator, and new .vsl files using existing
          ones as models.

          Create a FileVisibilityResult, similar to FormVisibilityResult:  this class
          should hold a collection of File ids which can be seen by the Candidate.

          Also, create a FileVisibilityConditionFactSource which adds a
          FileVisibilityResult to the globals collection.  And a
          FileVisibilityWorkingMemoryResultProcessor to return the result.  Lastly,
          you'll need a new ConditionContext for file visibility.

          Create a unit test class like those that exist for other ConditionGroup
          engines, and test it thoroughly.


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 武宣县| 文化| 金昌市| 义马市| 大洼县| 陇川县| 文水县| 逊克县| 富阳市| 奉贤区| 阿城市| 栾城县| 大宁县| 邯郸市| 瓦房店市| 樟树市| 吴桥县| 隆化县| 河东区| 疏勒县| 当阳市| 浑源县| 牟定县| 通许县| 景东| 新乡市| 新营市| 昌乐县| 清镇市| 利辛县| 常宁市| 大理市| 通道| 阿巴嘎旗| 湖南省| 吉隆县| 西安市| 嵊泗县| 曲阜市| 中牟县| 泗水县|