Changeset 3095
- Timestamp:
- 01/27/12 12:20:06 (4 months ago)
- Location:
- AnalyzerBeans/trunk
- Files:
-
- 5 edited
-
core/src/main/java/org/eobjects/analyzer/descriptors/AbstractMethodDescriptor.java (modified) (2 diffs)
-
core/src/main/java/org/eobjects/analyzer/job/builder/AbstractBeanJobBuilder.java (modified) (13 diffs)
-
core/src/main/java/org/eobjects/analyzer/job/builder/AnalyzerJobBuilder.java (modified) (1 diff)
-
core/src/test/java/org/eobjects/analyzer/job/builder/AnalysisJobBuilderTest.java (modified) (3 diffs)
-
env/xml-config/src/main/java/org/eobjects/analyzer/job/JaxbJobReader.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
AnalyzerBeans/trunk/core/src/main/java/org/eobjects/analyzer/descriptors/AbstractMethodDescriptor.java
r3031 r3095 22 22 import java.io.Serializable; 23 23 import java.lang.annotation.Annotation; 24 import java.lang.reflect.InvocationTargetException; 24 25 import java.lang.reflect.Method; 25 26 import java.util.Arrays; … … 71 72 } catch (RuntimeException e) { 72 73 throw e; 74 } catch (InvocationTargetException e) { 75 Throwable targetException = e.getTargetException(); 76 if (targetException instanceof RuntimeException) { 77 throw (RuntimeException) targetException; 78 } 79 throw new IllegalStateException("Invoked method threw exception", targetException); 73 80 } catch (Exception e) { 74 81 throw new IllegalStateException("Could not invoke method " + getMethod(), e); -
AnalyzerBeans/trunk/core/src/main/java/org/eobjects/analyzer/job/builder/AbstractBeanJobBuilder.java
r2631 r3095 28 28 import org.eobjects.analyzer.descriptors.BeanDescriptor; 29 29 import org.eobjects.analyzer.descriptors.ConfiguredPropertyDescriptor; 30 import org.eobjects.analyzer.lifecycle.LifeCycleHelper; 30 31 import org.eobjects.analyzer.result.renderer.Renderable; 31 32 import org.eobjects.analyzer.util.ReflectionUtils; … … 44 45 */ 45 46 @SuppressWarnings("unchecked") 46 public class AbstractBeanJobBuilder<D extends BeanDescriptor<E>, E, B> 47 implements Renderable { 47 public class AbstractBeanJobBuilder<D extends BeanDescriptor<E>, E, B> implements Renderable { 48 48 49 49 private final Logger logger = LoggerFactory.getLogger(getClass()); … … 54 54 private final AnalysisJobBuilder _analysisJobBuilder; 55 55 56 public AbstractBeanJobBuilder(AnalysisJobBuilder analysisJobBuilder, 57 D descriptor, Class<?> builderClass) { 56 public AbstractBeanJobBuilder(AnalysisJobBuilder analysisJobBuilder, D descriptor, Class<?> builderClass) { 58 57 if (analysisJobBuilder == null) { 59 throw new IllegalArgumentException( 60 "analysisJobBuilder cannot be null"); 58 throw new IllegalArgumentException("analysisJobBuilder cannot be null"); 61 59 } 62 60 if (descriptor == null) { … … 69 67 _descriptor = descriptor; 70 68 if (!ReflectionUtils.is(getClass(), builderClass)) { 71 throw new IllegalArgumentException( 72 "Builder class does not correspond to actual class of builder"); 73 } 74 75 _configurableBean = ReflectionUtils.newInstance(_descriptor 76 .getComponentClass()); 69 throw new IllegalArgumentException("Builder class does not correspond to actual class of builder"); 70 } 71 72 _configurableBean = ReflectionUtils.newInstance(_descriptor.getComponentClass()); 77 73 } 78 74 … … 89 85 } 90 86 91 public final boolean isConfigured(boolean throwException) 92 throws IllegalStateException, 87 public final boolean isConfigured(boolean throwException) throws IllegalStateException, 93 88 UnconfiguredConfiguredPropertyException { 94 for (ConfiguredPropertyDescriptor configuredProperty : _descriptor 95 .getConfiguredProperties()) { 89 for (ConfiguredPropertyDescriptor configuredProperty : _descriptor.getConfiguredProperties()) { 96 90 if (!isConfigured(configuredProperty, throwException)) { 97 91 if (throwException) { 98 throw new UnconfiguredConfiguredPropertyException(this, 99 configuredProperty); 92 throw new UnconfiguredConfiguredPropertyException(this, configuredProperty); 100 93 } else { 101 94 return false; … … 103 96 } 104 97 } 98 99 try { 100 LifeCycleHelper lifeCycleHelper = new LifeCycleHelper(null, null); 101 lifeCycleHelper.validate(getDescriptor(), getConfigurableBean()); 102 } catch (RuntimeException e) { 103 if (throwException) { 104 throw e; 105 } else { 106 return false; 107 } 108 } 109 105 110 return true; 106 111 } … … 119 124 } 120 125 121 public boolean isConfigured( 122 ConfiguredPropertyDescriptor configuredProperty, 123 boolean throwException) { 126 public boolean isConfigured(ConfiguredPropertyDescriptor configuredProperty, boolean throwException) { 124 127 if (configuredProperty.isRequired()) { 125 128 Map<ConfiguredPropertyDescriptor, Object> configuredProperties = getConfiguredProperties(); … … 132 135 if (value == null) { 133 136 if (throwException) { 134 throw new UnconfiguredConfiguredPropertyException(this, 135 configuredProperty); 137 throw new UnconfiguredConfiguredPropertyException(this, configuredProperty); 136 138 } else { 137 logger.debug("Configured property is not set: " 138 + configuredProperty); 139 logger.debug("Configured property is not set: " + configuredProperty); 139 140 return false; 140 141 } … … 145 146 146 147 public B setConfiguredProperty(String configuredName, Object value) { 147 ConfiguredPropertyDescriptor configuredProperty = _descriptor 148 .getConfiguredProperty(configuredName); 148 ConfiguredPropertyDescriptor configuredProperty = _descriptor.getConfiguredProperty(configuredName); 149 149 if (configuredProperty == null) { 150 throw new IllegalArgumentException("No such configured property: " 151 + configuredName); 150 throw new IllegalArgumentException("No such configured property: " + configuredName); 152 151 } 153 152 return setConfiguredProperty(configuredProperty, value); 154 153 } 155 154 156 public B setConfiguredProperty( 157 ConfiguredPropertyDescriptor configuredProperty, Object value) { 155 public B setConfiguredProperty(ConfiguredPropertyDescriptor configuredProperty, Object value) { 158 156 if (configuredProperty == null) { 159 throw new IllegalArgumentException( 160 "configuredProperty cannot be null"); 157 throw new IllegalArgumentException("configuredProperty cannot be null"); 161 158 } 162 159 if (value != null) { … … 168 165 Object valuePart = Array.get(value, i); 169 166 if (valuePart != null) { 170 if (!ReflectionUtils.is(valuePart.getClass(), 171 configuredProperty.getBaseType())) { 167 if (!ReflectionUtils.is(valuePart.getClass(), configuredProperty.getBaseType())) { 172 168 correctType = false; 173 169 } … … 175 171 } 176 172 } else { 177 if (!ReflectionUtils.is(value.getClass(), 178 configuredProperty.getBaseType())) { 173 if (!ReflectionUtils.is(value.getClass(), configuredProperty.getBaseType())) { 179 174 correctType = false; 180 175 } 181 176 } 182 177 } else { 183 if (!ReflectionUtils.is(value.getClass(), 184 configuredProperty.getBaseType())) { 178 if (!ReflectionUtils.is(value.getClass(), configuredProperty.getBaseType())) { 185 179 correctType = false; 186 180 } 187 181 } 188 182 if (!correctType) { 189 throw new IllegalArgumentException("Invalid value type: " 190 + value.getClass().getName() + ", expected: " 183 throw new IllegalArgumentException("Invalid value type: " + value.getClass().getName() + ", expected: " 191 184 + configuredProperty.getBaseType().getName()); 192 185 } … … 200 193 public Map<ConfiguredPropertyDescriptor, Object> getConfiguredProperties() { 201 194 Map<ConfiguredPropertyDescriptor, Object> map = new HashMap<ConfiguredPropertyDescriptor, Object>(); 202 Set<ConfiguredPropertyDescriptor> configuredProperties = getDescriptor() 203 .getConfiguredProperties(); 195 Set<ConfiguredPropertyDescriptor> configuredProperties = getDescriptor().getConfiguredProperties(); 204 196 for (ConfiguredPropertyDescriptor propertyDescriptor : configuredProperties) { 205 197 Object value = getConfiguredProperty(propertyDescriptor); … … 218 210 } 219 211 220 public Object getConfiguredProperty( 221 ConfiguredPropertyDescriptor propertyDescriptor) { 212 public Object getConfiguredProperty(ConfiguredPropertyDescriptor propertyDescriptor) { 222 213 return propertyDescriptor.getValue(getConfigurableBean()); 223 214 } -
AnalyzerBeans/trunk/core/src/main/java/org/eobjects/analyzer/job/builder/AnalyzerJobBuilder.java
r2786 r3095 179 179 if (_inputColumns.isEmpty()) { 180 180 if (throwException) { 181 throw new IllegalStateException("No input columns have been added !");181 throw new IllegalStateException("No input columns have been added to " + this); 182 182 } else { 183 183 return false; -
AnalyzerBeans/trunk/core/src/test/java/org/eobjects/analyzer/job/builder/AnalysisJobBuilderTest.java
r3053 r3095 31 31 import org.easymock.EasyMock; 32 32 import org.easymock.IArgumentMatcher; 33 import org.eobjects.analyzer.beans.NumberAnalyzer; 33 34 import org.eobjects.analyzer.beans.StringAnalyzer; 34 35 import org.eobjects.analyzer.beans.convert.ConvertToStringTransformer; … … 36 37 import org.eobjects.analyzer.beans.filter.NullCheckFilter; 37 38 import org.eobjects.analyzer.beans.filter.NullCheckFilter.NullCheckCategory; 39 import org.eobjects.analyzer.beans.filter.NumberRangeFilter; 40 import org.eobjects.analyzer.beans.filter.RangeFilterCategory; 38 41 import org.eobjects.analyzer.beans.filter.ValidationCategory; 39 42 import org.eobjects.analyzer.beans.standardize.EmailStandardizerTransformer; … … 79 82 } 80 83 84 public void testValidate() throws Exception { 85 analysisJobBuilder.addSourceColumns("PUBLIC.EMPLOYEES.REPORTSTO"); 86 MetaModelInputColumn reportsToColumn = analysisJobBuilder.getSourceColumns().get(0); 87 88 FilterJobBuilder<NumberRangeFilter, RangeFilterCategory> filter = analysisJobBuilder 89 .addFilter(NumberRangeFilter.class); 90 filter.addInputColumn(reportsToColumn); 91 filter.setConfiguredProperty("Lowest value", 2.0); 92 filter.setConfiguredProperty("Highest value", 1.0); 93 analysisJobBuilder.addAnalyzer(NumberAnalyzer.class).addInputColumn(reportsToColumn); 94 95 try { 96 analysisJobBuilder.isConfigured(true); 97 fail("Exception expected"); 98 } catch (Exception e) { 99 assertEquals("Lowest value is greater than the highest value", e.getMessage()); 100 } 101 } 102 81 103 public void testPreventCyclicFilterDependencies() throws Exception { 82 104 analysisJobBuilder.addSourceColumns("PUBLIC.EMPLOYEES.REPORTSTO"); -
AnalyzerBeans/trunk/env/xml-config/src/main/java/org/eobjects/analyzer/job/JaxbJobReader.java
r3046 r3095 481 481 .getOutput(); 482 482 483 assert outputColumns.size() == output.size(); 483 if (outputColumns.size() != output.size()) { 484 throw new IllegalStateException("Expected " 485 + outputColumns.size() 486 + " output column, but found " 487 + output.size() + " (" 488 + transformerJobBuilder + ")"); 489 } 484 490 485 491 for (int i = 0; i < output.size(); i++) {
Note: See TracChangeset
for help on using the changeset viewer.
