- Timestamp:
- 08/28/10 21:55:08 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AnalyzerBeans/trunk/src/main/java/org/eobjects/analyzer/job/JaxbJobFactory.java
r980 r982 14 14 import javax.xml.bind.JAXBException; 15 15 import javax.xml.bind.Unmarshaller; 16 import javax.xml.bind.ValidationEvent;17 import javax.xml.bind.ValidationEventHandler;18 16 19 17 import org.eobjects.analyzer.beans.ExploringAnalyzer; 20 18 import org.eobjects.analyzer.beans.RowProcessingAnalyzer; 19 import org.eobjects.analyzer.configuration.AnalyzerBeansConfiguration; 21 20 import org.eobjects.analyzer.connection.DataContextProvider; 22 21 import org.eobjects.analyzer.connection.Datastore; … … 37 36 import org.eobjects.analyzer.job.jaxb.InputType; 38 37 import org.eobjects.analyzer.job.jaxb.Job; 38 import org.eobjects.analyzer.job.jaxb.JobMetadataType; 39 39 import org.eobjects.analyzer.job.jaxb.ObjectFactory; 40 40 import org.eobjects.analyzer.job.jaxb.OutputType; … … 43 43 import org.eobjects.analyzer.job.jaxb.TransformerDescriptorType; 44 44 import org.eobjects.analyzer.job.jaxb.TransformerType; 45 import org.eobjects.analyzer.util.JaxbValidationEventHandler; 45 46 import org.eobjects.analyzer.util.SchemaNavigator; 47 import org.eobjects.analyzer.util.StringUtils; 46 48 import org.slf4j.Logger; 47 49 import org.slf4j.LoggerFactory; … … 79 81 Unmarshaller unmarshaller = _jaxbContext.createUnmarshaller(); 80 82 81 unmarshaller.setEventHandler(new ValidationEventHandler() { 82 @Override 83 public boolean handleEvent(ValidationEvent event) { 84 int severity = event.getSeverity(); 85 if (severity == ValidationEvent.WARNING) { 86 logger.warn("encountered JAXB parsing warning: " 87 + event.getMessage()); 88 return true; 89 } 90 91 logger.warn("encountered JAXB parsing error: " 92 + event.getMessage()); 93 return false; 94 } 95 }); 83 unmarshaller.setEventHandler(new JaxbValidationEventHandler()); 96 84 Job job = (Job) unmarshaller.unmarshal(inputStream); 97 85 return create(job); … … 102 90 103 91 public AnalysisJobBuilder create(Job job) { 92 JobMetadataType metadata = job.getJobMetadata(); 93 if (metadata != null) { 94 logger.info("Job name: {}", metadata.getJobName()); 95 logger.info("Job version: {}", metadata.getJobVersion()); 96 logger.info("Job description: {}", metadata.getJobDescription()); 97 logger.info("Author: {}", metadata.getAuthor()); 98 logger.info("Created date: {}", metadata.getCreatedDate()); 99 logger.info("Updated date: {}", metadata.getUpdatedDate()); 100 } 101 104 102 SourceType source = job.getSource(); 105 103 … … 109 107 DataContextType dataContext = source.getDataContext(); 110 108 String ref = dataContext.getRef(); 111 if ( isNullOrEmpty(ref)) {109 if (StringUtils.isNullOrEmpty(ref)) { 112 110 throw new IllegalStateException("Datastore ref cannot be null"); 113 111 } … … 131 129 for (ColumnType column : columns) { 132 130 String path = column.getPath(); 133 if ( isNullOrEmpty(path)) {131 if (StringUtils.isNullOrEmpty(path)) { 134 132 throw new IllegalStateException("Column path cannot be null"); 135 133 } … … 141 139 physicalColumn); 142 140 String id = column.getId(); 143 if ( isNullOrEmpty(id)) {141 if (StringUtils.isNullOrEmpty(id)) { 144 142 throw new IllegalStateException( 145 143 "Source column id cannot be null"); … … 158 156 TransformerDescriptorType descriptor = transformer.getDescriptor(); 159 157 ref = descriptor.getRef(); 160 if ( isNullOrEmpty(ref)) {158 if (StringUtils.isNullOrEmpty(ref)) { 161 159 throw new IllegalStateException( 162 160 "Transformer descriptor ref cannot be null"); … … 189 187 for (InputType inputType : input) { 190 188 ref = inputType.getRef(); 191 if ( isNullOrEmpty(ref)) {189 if (StringUtils.isNullOrEmpty(ref)) { 192 190 throw new IllegalStateException( 193 191 "Transformer input column ref cannot be null"); … … 220 218 MutableInputColumn<?> o2 = outputColumns.get(i); 221 219 String name = o1.getName(); 222 if (! isNullOrEmpty(name)) {220 if (!StringUtils.isNullOrEmpty(name)) { 223 221 o2.setName(name); 224 222 } 225 223 String id = o1.getId(); 226 if ( isNullOrEmpty(id)) {224 if (StringUtils.isNullOrEmpty(id)) { 227 225 throw new IllegalStateException( 228 226 "Transformer output column id cannot be null"); … … 240 238 for (AnalyzerType analyzerType : analyzers) { 241 239 ref = analyzerType.getDescriptor().getRef(); 242 if ( isNullOrEmpty(ref)) {240 if (StringUtils.isNullOrEmpty(ref)) { 243 241 throw new IllegalStateException( 244 242 "Analyzer descriptor ref cannot be null"); … … 264 262 for (InputType inputType : input) { 265 263 ref = inputType.getRef(); 266 if ( isNullOrEmpty(ref)) {264 if (StringUtils.isNullOrEmpty(ref)) { 267 265 throw new IllegalStateException( 268 266 "Analyzer input column ref cannot be null"); … … 300 298 } 301 299 302 private boolean isNullOrEmpty(String str) {303 return str == null || str.trim().length() == 0;304 }305 306 300 private void applyProperties( 307 301 AbstractBeanJobBuilder<? extends BeanDescriptor<?>, ?, ?> builder, … … 313 307 String name = property.getName(); 314 308 String value = property.getValue(); 315 309 316 310 ConfiguredPropertyDescriptor configuredProperty = descriptor 317 .getConfiguredProperty(name);318 311 .getConfiguredProperty(name); 312 319 313 // TODO: Convert value according to configuredProperty's type 320 314 builder.setConfiguredProperty(configuredProperty, value);
Note: See TracChangeset
for help on using the changeset viewer.
