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.service.impl; 017 018import org.kuali.rice.krad.datadictionary.validation.ViewAttributeValueReader; 019import org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult; 020import org.kuali.rice.krad.service.DictionaryValidationService; 021import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 022import org.kuali.rice.krad.service.ViewValidationService; 023import org.kuali.rice.krad.uif.view.View; 024import org.kuali.rice.krad.uif.view.ViewModel; 025 026/** 027 * Implementation of Validation service for views, uses the same validation mechanisms as DictionaryValidationService 028 * but uses a different AttributeValueReader to get the correct information from InputFields - which 029 * include any AttributeDefinition defined attributes, if defined and not overriden 030 * 031 * @see ViewValidationService 032 */ 033public class ViewValidationServiceImpl implements ViewValidationService { 034 035 protected DictionaryValidationService dictionaryValidationService; 036 037 @Override 038 public DictionaryValidationResult validateView(ViewModel model) { 039 return validateView(model.getPostedView(), model); 040 } 041 042 @Override 043 public DictionaryValidationResult validateView(View view, ViewModel model) { 044 return getDictionaryValidationService().validate(new ViewAttributeValueReader(view, model), true); 045 } 046 047 public DictionaryValidationService getDictionaryValidationService() { 048 if (dictionaryValidationService == null) { 049 this.dictionaryValidationService = KRADServiceLocatorWeb.getDictionaryValidationService(); 050 } 051 return dictionaryValidationService; 052 } 053 054 public void setDictionaryValidationService(DictionaryValidationService dictionaryValidationService) { 055 this.dictionaryValidationService = dictionaryValidationService; 056 } 057}