001/**
002 * Copyright 2005-2016 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.rice.krad.datadictionary.validation.processor;
017
018import org.kuali.rice.core.api.CoreApiServiceLocator;
019import org.kuali.rice.core.api.datetime.DateTimeService;
020import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint;
021import org.kuali.rice.krad.service.DataDictionaryService;
022import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
023
024/**
025 * This abstract class can be extended by constraint processor classes that
026 * must be processed on every validation.  
027 * 
028 * @author Kuali Rice Team (rice.collab@kuali.org) 
029 */
030public abstract class MandatoryElementConstraintProcessor<C extends Constraint> implements ConstraintProcessor<Object, C> {
031
032        protected DataDictionaryService dataDictionaryService;
033        protected DateTimeService dateTimeService;
034        
035        
036        /**
037         * @see org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor#isOptional()
038         */
039        @Override
040        public boolean isOptional() {
041                return false;
042        }
043
044        /**
045         * @return the dataDictionaryService
046         */
047        public DataDictionaryService getDataDictionaryService() {
048                if (dataDictionaryService == null)
049                        dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
050                return this.dataDictionaryService;
051        }
052
053        /**
054         * @param dataDictionaryService the dataDictionaryService to set
055         */
056        public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
057                this.dataDictionaryService = dataDictionaryService;
058        }
059        
060        /**
061         * @return the dateTimeService
062         */
063        public DateTimeService getDateTimeService() {
064                if (dateTimeService == null)
065                        dateTimeService = CoreApiServiceLocator.getDateTimeService();
066                
067                return this.dateTimeService;
068        }
069
070        /**
071         * @param dateTimeService the dateTimeService to set
072         */
073        public void setDateTimeService(DateTimeService dateTimeService) {
074                this.dateTimeService = dateTimeService;
075        }
076        
077}