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.


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


          網站導航:
           
          主站蜘蛛池模板: 罗平县| 虞城县| 正宁县| 正安县| 竹北市| 仪陇县| 甘孜县| 东光县| 苗栗市| 汉阴县| 黄石市| 平乐县| 宁城县| 临西县| 屏山县| 长垣县| 延吉市| 稷山县| 罗山县| 博野县| 东乡县| 新沂市| 精河县| 大英县| 新疆| 密山市| 南昌市| 钦州市| 东兴市| 克什克腾旗| 乌海市| 辽宁省| 翁牛特旗| 洱源县| 内江市| 观塘区| 抚顺县| 辽宁省| 宾阳县| 富裕县| 临沧市|