From c3ebf8eb491d7146f96fb88af3ab02590b4a567e Mon Sep 17 00:00:00 2001 From: tworrall Date: Mon, 10 Sep 2012 17:38:46 +0000 Subject: [PATCH] merging r10046 to the trunk --- .../cornell/mannlib/vedit/util/FormUtils.java | 206 +++++++++--------- .../edit/IndividualTypeRetryController.java | 5 +- 2 files changed, 106 insertions(+), 105 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java b/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java index 17cea5ffc..15f7cb932 100644 --- a/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java +++ b/webapp/src/edu/cornell/mannlib/vedit/util/FormUtils.java @@ -1,11 +1,11 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + package edu.cornell.mannlib.vedit.util; import java.lang.reflect.Method; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Arrays; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Iterator; @@ -27,29 +27,29 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; public class FormUtils { - protected static final Log log = LogFactory.getLog(FormUtils.class.getName()); - protected static final int BASE_10 = 10; - protected static final Class[] SUPPORTED_TYPES = { String.class, - int.class, - Integer.class, - boolean.class, - Date.class - }; - - protected static final List SUPPORTED_TYPE_LIST = Arrays + protected static final Log log = LogFactory.getLog(FormUtils.class.getName()); + protected static final int BASE_10 = 10; + protected static final Class[] SUPPORTED_TYPES = { String.class, + int.class, + Integer.class, + boolean.class, + Date.class + }; + + protected static final List SUPPORTED_TYPE_LIST = Arrays .asList(SUPPORTED_TYPES); /* this class needs to be reworked */ - public static void populateFormFromBean (Object bean, - String action, + public static void populateFormFromBean (Object bean, + String action, FormObject foo) { populateFormFromBean(bean,action,null,foo,new HashMap()); } - public static void populateFormFromBean (Object bean, - String action, - FormObject foo, + public static void populateFormFromBean (Object bean, + String action, + FormObject foo, Map badValuesHash) { populateFormFromBean(bean,action,null,foo,badValuesHash); } @@ -57,14 +57,14 @@ public class FormUtils { /** * Populates form objects with bean values */ - public static void populateFormFromBean (Object bean, - String action, - EditProcessObject epo, - FormObject foo, + public static void populateFormFromBean (Object bean, + String action, + EditProcessObject epo, + FormObject foo, Map BadValuesHash) { - Class beanClass = - (epo != null && epo.getBeanClass() != null) - ? epo.getBeanClass() + Class beanClass = + (epo != null && epo.getBeanClass() != null) + ? epo.getBeanClass() : bean.getClass(); Method[] meths = beanClass.getMethods(); @@ -82,7 +82,7 @@ public class FormUtils { //we only want people directly to type in ints, strings, and dates //of course, most of the ints are probably foreign keys anyway... - String elementName = currMeth.getName().substring( + String elementName = currMeth.getName().substring( 3,currMeth.getName().length()); //see if there's something in the bean using @@ -91,7 +91,7 @@ public class FormUtils { Class[] paramClass = new Class[1]; paramClass[0] = currMethType; try { - Method getter = beanClass.getMethod( + Method getter = beanClass.getMethod( "get" + elementName, (Class[]) null); Object existingData = null; try { @@ -104,14 +104,14 @@ public class FormUtils { if (existingData instanceof String){ value += existingData; } - else if (!(existingData instanceof Integer + else if (!(existingData instanceof Integer && (Integer)existingData < 0)) { value += existingData.toString(); } } String badValue = (String) BadValuesHash.get(elementName); if (badValue != null) { - value = badValue; + value = badValue; } foo.getValues().put(elementName, value); } catch (NoSuchMethodException e) { @@ -122,20 +122,20 @@ public class FormUtils { } } - public static List