Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.impl.document.search;
 
 
 import  javax.annotation.Nullable;
 import java.util.List;
 import java.util.Map;

 
 class FormFields {
     private final Collection<Rowrows;
 
     FormFields(Collection<Rowrows) {
         this. = rows;
     }

    
Preserves Field values, saving single or array property value depending on field type; single property value is converted into String[1] This implementation makes the assumption that a Field can either represent a single property value, or an array of values but not both! (only one is preserved)

Returns:
a Map<String, String[]> containing field values depending on field type
 
     Map<StringString[]> getFieldValues() {
         Map<StringString[]> values = new HashMap<StringString[]>();
         for (Field field : getFields()) {
             String[] value;
             if(!..contains(field.getFieldType())) {
                 value = new String[] { field.getPropertyValue() };
             } else {
                 //multi value, set to values
                 value = field.getPropertyValues();
             }
             values.put(field.getPropertyName(), value);
         }
         return values;
     }
     
     Field getField(final String name) {
         return Iterables.tryFind(getFields(), new Predicate<Field>() {
             public boolean apply(@Nullable Field input) {
                 return StringUtils.equals(nameinput.getPropertyName());
             }
         }).orNull();
     }
 
     void setFieldValue(String nameString value) {
         setFieldValue(namenew String[]{value});
     }
 
     void setFieldValue(String nameString[] value) {
         setFieldValues(Collections.singletonMap(namevalue));
     }

    
Overrides Row Field values with Map values

Parameters:
values the fieldvalues
 
     void setFieldValues(Map<StringString[]> values) {
         for (Field fieldgetFields()) {
             if (StringUtils.isNotBlank(field.getPropertyName())) {
                 String[] value = values.get(field.getPropertyName());
                 if (ArrayUtils.isNotEmpty(value)) {
                     setFieldValue(fieldvalue);
                 }
             }
         }
     }
        for (Field fgetFields()) {
            lhs.applyFieldAuthorizationsFromNestedLookups(f);
        }
    }
    List<FieldgetFieldList() {
        return Lists.newArrayList(getFields());
    }

    
Sets a Field value appropriately, depending on whether it is a "multi-value" field type
    void setFieldValue(Field fieldString[] values) {
        if(!..contains(field.getFieldType())) {
            field.setPropertyValue(CollectionUtils.get(values, 0));
        } else {
            //multi value, set to values
            field.setPropertyValues(values);
        }
    }
    Iterable<FieldgetFields() {
        return Iterables.concat(Iterables.transform(this.new Function<RowIterable<Field>>() {
            @Override
            public Iterable<Fieldapply(@Nullable Row row) {
                return row.getFields();
            }
        }));
    }
New to GrepCode? Check out our FAQ X