1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.impex;
17
18 import java.io.File;
19 import java.lang.reflect.InvocationTargetException;
20
21 import org.apache.commons.beanutils.BeanUtils;
22 import org.kuali.common.impex.service.ImpexContext;
23 import org.kuali.common.impex.service.ImpexUtils;
24 import org.springframework.beans.factory.FactoryBean;
25
26 public class ImpexContextCloningFactoryBean implements FactoryBean<ImpexContext> {
27
28 ImpexContext sourceContext;
29 String include;
30 String artifactId;
31 File finalDirectory;
32 boolean copyDataFiles;
33 String schemaFileInclude;
34
35 @Override
36 public ImpexContext getObject() throws Exception {
37 ImpexContext context = ImpexUtils.clone(sourceContext, include, artifactId);
38 copyProperties(context, this);
39 return context;
40 }
41
42 protected void copyProperties(ImpexContext dest, ImpexContextCloningFactoryBean orig) {
43 try {
44 BeanUtils.copyProperties(dest, orig);
45 } catch (IllegalAccessException e) {
46 throw new IllegalArgumentException(e);
47 } catch (InvocationTargetException e) {
48 throw new IllegalArgumentException(e);
49 }
50 }
51
52 @Override
53 public Class<ImpexContext> getObjectType() {
54 return ImpexContext.class;
55 }
56
57 @Override
58 public boolean isSingleton() {
59 return false;
60 }
61
62 public ImpexContext getSourceContext() {
63 return sourceContext;
64 }
65
66 public void setSourceContext(ImpexContext sourceContext) {
67 this.sourceContext = sourceContext;
68 }
69
70 public String getInclude() {
71 return include;
72 }
73
74 public void setInclude(String include) {
75 this.include = include;
76 }
77
78 public String getArtifactId() {
79 return artifactId;
80 }
81
82 public void setArtifactId(String artifactId) {
83 this.artifactId = artifactId;
84 }
85
86 public File getFinalDirectory() {
87 return finalDirectory;
88 }
89
90 public void setFinalDirectory(File scmBaseDirectory) {
91 this.finalDirectory = scmBaseDirectory;
92 }
93
94 public boolean isCopyDataFiles() {
95 return copyDataFiles;
96 }
97
98 public void setCopyDataFiles(boolean copyDataFiles) {
99 this.copyDataFiles = copyDataFiles;
100 }
101
102 public String getSchemaFileInclude() {
103 return schemaFileInclude;
104 }
105
106 public void setSchemaFileInclude(String schemaFileInclude) {
107 this.schemaFileInclude = schemaFileInclude;
108 }
109 }