001/*
002 * Copyright 2008 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 */
016package org.kuali.ole.sys.document.validation.event;
017
018import java.util.HashMap;
019import java.util.Map;
020
021import org.kuali.ole.sys.document.validation.AccountingRuleEngineRule;
022import org.kuali.rice.krad.document.Document;
023import org.kuali.rice.krad.rules.rule.BusinessRule;
024import org.kuali.rice.krad.rules.rule.event.KualiDocumentEventBase;
025
026/**
027 * Base abstract implementation of an attributed document event.
028 */
029public 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.krad.rule.event.KualiDocumentEventBase#KualiDocumentEventBase(java.lang.String, java.lang.String, org.kuali.rice.krad.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.ole.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.ole.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.krad.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
083     */
084    public Class getRuleInterfaceClass() {
085        return AccountingRuleEngineRule.class;
086    }
087
088    /**
089     * @see org.kuali.rice.krad.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.krad.rule.BusinessRule)
090     */
091    public boolean invokeRuleMethod(BusinessRule rule) {
092        return ((AccountingRuleEngineRule)rule).validateForEvent(this);
093    }
094}