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.kew.rule;
017
018import org.kuali.rice.core.api.uif.RemotableAttributeError;
019import org.kuali.rice.core.api.uif.RemotableAttributeField;
020import org.kuali.rice.kew.framework.rule.attribute.WorkflowRuleAttributeFields;
021import org.kuali.rice.kns.util.FieldUtils;
022import org.kuali.rice.kns.web.ui.Row;
023
024import java.util.List;
025import java.util.Map;
026
027/**
028 * This class wraps a {@link WorkflowRuleAttributeFields} object and provides a KNS-compatible view to the data
029 * contained therein. Primarily, this means that RemotableAttributeField objects are transformed to KNS Row objects.
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033public class WorkflowRuleAttributeRows {
034
035    private final WorkflowRuleAttributeFields fields;
036    private final List<Row> rows;
037
038    public WorkflowRuleAttributeRows(WorkflowRuleAttributeFields fields) {
039        this.fields = fields;
040        this.rows = convertToRows(fields.getAttributeFields());
041    }
042
043    private static List<Row> convertToRows(List<RemotableAttributeField> attributeFields) {
044        return FieldUtils.convertRemotableAttributeFields(attributeFields);
045    }
046
047    public List<Row> getRows() {
048        return rows;
049    }
050
051    public List<RemotableAttributeError> getValidationErrors() {
052        return fields.getValidationErrors();
053    }
054
055    public Map<String, String> getRuleExtensionValues() {
056        return fields.getRuleExtensionValues();
057    }
058
059}