View Javadoc

1   /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.common.impex.schema.service;
17  
18  import org.kuali.common.impex.model.Schema;
19  import org.kuali.common.impex.schema.service.impl.DefaultExtractSchemaService;
20  import org.kuali.common.util.execute.Executable;
21  import org.springframework.util.Assert;
22  
23  public class ExtractSchemaExecutable implements Executable {
24  
25  	public static final boolean DEFAULT_SKIP = false;
26  	public static final ExtractSchemaService DEFAULT_SERVICE = new DefaultExtractSchemaService();
27  
28  	boolean skip = DEFAULT_SKIP;
29  	ExtractSchemaService service = DEFAULT_SERVICE;
30  
31  	// Required
32  	ExtractSchemaContext context;
33  
34  	// Filled in during execution
35  	ExtractSchemaResult result;
36  
37  	@Override
38  	public void execute() {
39  
40  		if (skip) {
41  			return;
42  		}
43  
44  		Assert.notNull(service, "service is null");
45  		Assert.notNull(context, "context is null");
46  
47  		Schema schema = service.getSchema(context);
48  		this.result = new ExtractSchemaResult(schema);
49  	}
50  
51  	/**
52  	 * Expose <code>SchemaExtractionResult</code> via a getter
53  	 */
54  	public ExtractSchemaResult getResult() {
55  		return result;
56  	}
57  
58  	public ExtractSchemaContext getContext() {
59  		return context;
60  	}
61  
62  	public void setContext(ExtractSchemaContext context) {
63  		this.context = context;
64  	}
65  
66  	public ExtractSchemaService getService() {
67  		return service;
68  	}
69  
70  	public void setService(ExtractSchemaService service) {
71  		this.service = service;
72  	}
73  
74  	public boolean isSkip() {
75  		return skip;
76  	}
77  
78  	public void setSkip(boolean skip) {
79  		this.skip = skip;
80  	}
81  }