001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.kfs.sys.document.validation.event;
017    
018    import java.util.HashMap;
019    import java.util.Map;
020    
021    import org.kuali.kfs.sys.document.validation.AccountingRuleEngineRule;
022    import org.kuali.rice.kns.document.Document;
023    import org.kuali.rice.kns.rule.BusinessRule;
024    import org.kuali.rice.kns.rule.event.KualiDocumentEventBase;
025    
026    /**
027     * Base abstract implementation of an attributed document event.
028     */
029    public class AttributedDocumentEventBase extends KualiDocumentEventBase implements AttributedDocumentEvent {
030        private Map<String, Object> attributes;
031        private Object iterationSubject;
032    
033        /**
034         * Constructs a AttributedDocumentEventBase
035         * @param description
036         * @param errorPathPrefix
037         */
038        protected AttributedDocumentEventBase(String description, String errorPathPrefix) {
039            super(description, errorPathPrefix);
040            attributes = new HashMap<String, Object>();
041        }
042        
043        /**
044         * @see org.kuali.rice.kns.rule.event.KualiDocumentEventBase#KualiDocumentEventBase(java.lang.String, java.lang.String, org.kuali.rice.kns.document.Document)
045         */
046        public AttributedDocumentEventBase(String description, String errorPathPrefix, Document document) {
047            super(description, errorPathPrefix, document);
048            attributes = new HashMap<String, Object>();
049        }
050    
051        /**
052         * @see org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent#getAttribute(java.lang.String)
053         */
054        public Object getAttribute(String attributeName) {
055            return attributes.get(attributeName);
056        }
057    
058        /**
059         * @see org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent#setAttribute(java.lang.String, java.lang.Object)
060         */
061        public void setAttribute(String attributeName, Object attributeValue) {
062            attributes.put(attributeName, attributeValue);
063        }
064    
065        /**
066         * Gets the iterationSubject attribute. 
067         * @return Returns the iterationSubject.
068         */
069        public Object getIterationSubject() {
070            return iterationSubject;
071        }
072    
073        /**
074         * Sets the iterationSubject attribute value.
075         * @param iterationSubject The iterationSubject to set.
076         */
077        public void setIterationSubject(Object iterationSubject) {
078            this.iterationSubject = iterationSubject;
079        }
080    
081        /**
082         * @see org.kuali.rice.kns.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
083         */
084        public Class getRuleInterfaceClass() {
085            return AccountingRuleEngineRule.class;
086        }
087    
088        /**
089         * @see org.kuali.rice.kns.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.kns.rule.BusinessRule)
090         */
091        public boolean invokeRuleMethod(BusinessRule rule) {
092            return ((AccountingRuleEngineRule)rule).validateForEvent(this);
093        }
094    }