840 likes | 954 Views
Heather Stapleton, Indiana University Warren Liang, University of California-Irvine. November 17 th , 2009. Customizing KFS Business Rules. Ways to Customize KFS. System Parameters Maintenance Tables Extending KFS Classes Presentation Controllers Authorizers Rules Granular Validations.
E N D
Heather Stapleton, Indiana University Warren Liang, University of California-Irvine November 17th, 2009 Customizing KFS Business Rules
Ways to Customize KFS • System Parameters • Maintenance Tables • Extending KFS Classes • Presentation Controllers • Authorizers • Rules • Granular Validations Identity Management (KIM) Tuesday @ 11am Salon B Workflow (KEW) Wednesday @ 2pm Conf 3+4
Parameters - Purpose • Customize based on YOUR policies • Controlled by users • Externalize constants • Maintained in tables • Easy to use
Parameters – Usage • May be used in: • Business rules checks • Runtime changes; no server restart • May not be used in: • Values not represented by constants • Core constants that will not change • Spring XML configuration files • OJB XML descriptor files
Parameter Examples On/Off Switches
Parameter Examples Defaults
Parameter Examples Requiredness
Customizing KFS Goals • To customize KFS documents’ rules and authorization with a minimal amount of KFS code changes • Achieve this by: • Extending classes • Overriding configuration
Customizing KFS Rules - note Code shown on the PPT is abbreviated Real code is shown in the notes of the PPT file Examples will be shown, link to patches at end of slides
Configuration overview KFS/Application Module Configs spring.source.files build property dataDictionaryPackages property DD Spring Beans (Document Entries) Doc rules, pres, cont., authorizers Properties in DD doc entry
Document Presentation Controllers • Determines whether a document is in a state that would allow certain actions to be performed • Decisions not based on user
Document Presentation Controllers interface DocumentPresentationController { Set<String> getDocumentActions(Document document); boolean canInitiate(String docTypeName); }
Document Authorizers • Determines whether a particular user is allowed to take a particular action against a document • Primarily a façade for KIM • Customization performed by changing KIM data
Presentation Controller/Authorizer Presentation Controllers Document Authorizers
Document Rules • Performs validation before actions are taken • Primarily used for maintenance documents, but also for some transactional documents
Document Rules interface RouteDocumentRule extends BusinessRule { boolean processRouteDocument(Document document); }
DocumentRuleBase • Base implementation for most of these interfaces is DocumentRuleBase • Contains a customization hook to add document-specific logic
DocumentRuleBase public boolean processRouteDocument(Document doc) { boolean isValid = isDocAttrsValid(document, true); isValid = isValid && processCustomRouteDocBusinessRules(doc); return isValid; } protected boolean processCustomRouteDocBusinessRules(Document doc) { // Document-specific logic would override this method return true; }
Configuration overview KFS/Application Module Configs spring.source.files build property dataDictionaryPackages property DD Spring Beans (Document Entries) Doc rules, pres, cont., authorizers Properties in DD doc entry
Data Dictionary • Repository of metadata for documents and business objects • Comprised of Spring beans • Configures how to validate a document
Data Dictionary Overriding Abstract parent bean definition and “concrete” inheriting bean Customize/override the concrete beans
Document DD bean example <bean id="CashMgmtDocument" parent="CashMgmtDocument-parentBean"/> <bean id="CashMgmtDocument-parentBean" abstract="true“ parent="AccountingDocumentEntry"> <property name="businessRulesClass“ value=“<package>.CashMgmtDocRule"/> <property name="documentAuthorizerClass“ value=“<package>.CashMgmtDocAuth"/> <property name="documentPresentationControllerClass“ value=“<package>.CashMgmtDocPresContBase"/>
Configuration overview KFS/Application Module Configs spring.source.files build property dataDictionaryPackages property DD Spring Beans (Document Entries) Doc rules, pres, cont., authorizers Properties in DD doc entry
Module Configuration • Maintains metadata related to an application module • List of DD directories • Override the Module Configuration Bean if adding new DD files
Module Configuration Example <bean id="arModuleConfiguration" parent="arModuleConfiguration-parentBean" /> <bean id="arModuleConfiguration-parentBean" class=“<package>.FinancialSystemModuleConfiguration" abstract="true"> <property name="dataDictionaryPackages"> <list> <value> org/kuali/kfs/module/ar/bo/datadictionary </value> <value> org/kuali/kfs/module/ar/doc/datadictionary </value> </list> </property> }
Configuration overview KFS/Application Module Configs spring.source.files build property dataDictionaryPackages property DD Spring Beans (Document Entries) Doc rules, pres, cont., authorizers Properties in DD doc entry
Build properties • Files in build/properties contain default values • Can redefine props in ~/kfs-build.properties • Various output files • work/src/configuration.properties • web.xml • security.properties • Etc.
Build property customization ~/kfs-build.properties Optionally defines ${shared.external. build.properties} OVERRIDES build/project/ *.properties
Build property customization • institution.* properties are customization hooks • Override properties in ~/kfs-build.properties or shared external build properties file
Customization example 1 • Modify rule to force org doc code to be a prefix of the description • Rule will only be triggered on routing (and, as a side effect, approvals, because of chaining)
Customization example 1 How? • Write a new rules class • Override the DD bean • Override the module bean • Define new build properties • Redeploy application
Customization example 1 – Step 1 KFS/Application Module Configs spring.source.files build property dataDictionaryPackages property DD Spring Beans (Document Entries) Doc rules, pres, cont., authorizers Properties in DD doc entry
Customization example 1 – Step 1 @Override protected boolean processCustRouteDocRules(Document doc) { if (!orgCodePrefixOfDocDesc(doc)) { registerErrorOnWebPage(); return false; } return super.processCustRouteDocRules(doc); }
Customization example 1 – Step 2 KFS/Application Module Configs spring.source.files build property dataDictionaryPackages property DD Spring Beans (Document Entries) Doc rules, pres, cont., authorizers Properties in DD doc entry
Customization example 1 – Step 2 <bean id="CashControlDoc“ parent="CashControlDoc-parentBean"> <property name="businessRulesClass" value="<cust_pkg>.CustCashContDocRule"/> </bean>
Customization example 1 – Step 3 KFS/Application Module Configs spring.source.files build property dataDictionaryPackages property DD Spring Beans (Document Entries) Doc rules, pres, cont., authorizers Properties in DD doc entry
Customization example 1 – Step 3 edu/school/kfs/module/ar/spring-ar-overrides.xml <bean id="arModuleConfiguration" parent="arModuleConfiguration-parentBean"> <property name="dataDictionaryPackages"> <list> <value>org/kuali/kfs/module/ar/bo/datadict</value> <value>org/kuali/kfs/module/ar/doc/datadict</value> <value>edu/school/kfs/module/ar/doc/datadict</value> </list> </property> </bean>