Revision 058a92f1
Added by Andreas Müller over 1 year ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java | ||
---|---|---|
17 | 17 |
import org.apache.commons.lang3.StringUtils; |
18 | 18 |
import org.apache.logging.log4j.LogManager; |
19 | 19 |
import org.apache.logging.log4j.Logger; |
20 |
import org.springframework.beans.BeansException; |
|
21 |
import org.springframework.context.ApplicationContext; |
|
22 |
import org.springframework.context.ApplicationContextAware; |
|
23 | 20 |
import org.springframework.remoting.httpinvoker.CachingHttpInvokerProxyFactoryBean; |
24 | 21 |
import org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor; |
25 | 22 |
import org.springframework.security.access.AccessDecisionVoter; |
... | ... | |
33 | 30 |
import org.springframework.security.core.context.SecurityContext; |
34 | 31 |
import org.springframework.security.core.context.SecurityContextHolder; |
35 | 32 |
import org.springframework.stereotype.Component; |
36 |
import org.springframework.transaction.PlatformTransactionManager; |
|
37 |
import org.springframework.transaction.TransactionStatus; |
|
38 | 33 |
|
39 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
40 | 34 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
41 | 35 |
import eu.etaxonomy.cdm.api.service.IAnnotationService; |
42 | 36 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
... | ... | |
105 | 99 |
*/ |
106 | 100 |
@Component |
107 | 101 |
// TODO split into CdmRepository and proper @Configuration class |
108 |
public class CdmApplicationRemoteConfiguration implements ICdmRepository, ApplicationContextAware {
|
|
102 |
public class CdmApplicationRemoteConfiguration implements ICdmRepository { |
|
109 | 103 |
|
110 | 104 |
@SuppressWarnings("unused") |
111 | 105 |
private static final Logger logger = LogManager.getLogger(); |
... | ... | |
135 | 129 |
*/ |
136 | 130 |
public static final int HTTP_READ_TIMEOUT = 10 * 60 * 1000; |
137 | 131 |
|
138 |
protected ApplicationContext applicationContext; |
|
139 |
|
|
140 | 132 |
private ICdmRemoteSource remoteSource; |
141 | 133 |
|
142 | 134 |
//TODO should be something like Map<Class<IService>, IService>, but we have no common service base interface yet |
... | ... | |
206 | 198 |
|
207 | 199 |
// ****************************** APPLICATION CONTEXT *************************************************/ |
208 | 200 |
|
209 |
@Override |
|
210 |
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException{ |
|
211 |
this.applicationContext = applicationContext; |
|
212 |
} |
|
213 |
|
|
214 |
@Override |
|
215 |
public PlatformTransactionManager getTransactionManager() throws UnsupportedOperationException { |
|
216 |
throw new UnsupportedOperationException("getTransactionManager is not implemented for CdmApplicationRemoteConfiguration"); |
|
217 |
} |
|
218 |
|
|
219 | 201 |
public IEditGeoService getEditGeoService() { |
220 | 202 |
return (IEditGeoService) getService(IEditGeoService.class, "/remoting/editgeo.service", new AuthenticatingHttpInvokerRequestExecutor()); |
221 | 203 |
} |
... | ... | |
236 | 218 |
|
237 | 219 |
// ****************************** GETTER *************************************************/ |
238 | 220 |
|
239 |
@Override |
|
240 |
public final Object getBean(String name){ |
|
241 |
throw new UnsupportedOperationException("getBean is not implemented for CdmApplicationRemoteConfiguration"); |
|
242 |
} |
|
243 |
|
|
244 | 221 |
@Override |
245 | 222 |
public IAccountRegistrationService getAccountRegistrationService() { |
246 | 223 |
return (IAccountRegistrationService) getService(IAccountRegistrationService.class, "/remoting/accountregistrationservice.service", new AuthenticatingHttpInvokerRequestExecutor()); |
... | ... | |
390 | 367 |
return new ProviderManager(Arrays.asList((AuthenticationProvider)daoAuthenticationProvider)); |
391 | 368 |
} |
392 | 369 |
|
393 |
|
|
394 |
@Override |
|
395 |
public ConversationHolder NewConversation() { |
|
396 |
throw new RuntimeException("ConversationHolder not supported by CdmApplicationRemoteConfiguration"); |
|
397 |
} |
|
398 |
|
|
399 | 370 |
@Override |
400 | 371 |
public ICollectionService getCollectionService(){ |
401 | 372 |
return (ICollectionService) getService(ICollectionService.class, "/remoting/collection.service", new AuthenticatingHttpInvokerRequestExecutor()); |
... | ... | |
501 | 472 |
return cdmPermissionEvaluator; |
502 | 473 |
} |
503 | 474 |
|
504 |
@Override |
|
505 |
public TransactionStatus startTransaction() throws UnsupportedOperationException { |
|
506 |
throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration"); |
|
507 |
} |
|
508 |
|
|
509 |
@Override |
|
510 |
public TransactionStatus startTransaction(Boolean readOnly) throws UnsupportedOperationException { |
|
511 |
throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration"); |
|
512 |
} |
|
513 |
|
|
514 |
@Override |
|
515 |
public void commitTransaction(TransactionStatus txStatus) throws UnsupportedOperationException { |
|
516 |
throw new UnsupportedOperationException("commitTransaction is not implemented for CdmApplicationRemoteConfiguration"); |
|
517 |
} |
|
518 |
|
|
519 |
@Override |
|
520 |
public void rollbackTransaction(TransactionStatus arg0) { |
|
521 |
throw new UnsupportedOperationException("rollbackTransaction is not implemented for CdmApplicationRemoteConfiguration"); |
|
522 |
} |
|
523 |
|
|
524 | 475 |
@Override |
525 | 476 |
public void authenticate(String username, String password){ |
526 | 477 |
UsernamePasswordAuthenticationToken tokenForUser = new UsernamePasswordAuthenticationToken(username, password); |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
/** |
32 | 32 |
* CDM Application Controller class for remoting clients |
33 |
* |
|
34 |
* FIXME:Remoting extending {@link CdmApplicationController} is a temporary workaround. |
|
35 |
* The {@link CdmApplicationController} should be split into a CdmApplicationControllerBase |
|
36 |
* class with {@link CdmApplicationController} and this class as subclasses |
|
37 | 33 |
*/ |
38 |
public class CdmApplicationRemoteController extends CdmApplicationControllerBase { |
|
34 |
public class CdmApplicationRemoteController |
|
35 |
extends CdmApplicationControllerBase<ICdmRepository> { |
|
39 | 36 |
|
40 | 37 |
private static final Logger logger = LogManager.getLogger(); |
41 | 38 |
|
... | ... | |
145 | 142 |
@Override |
146 | 143 |
protected void init(){ |
147 | 144 |
configuration = new CdmApplicationRemoteConfiguration(remoteSource); |
148 |
((CdmApplicationRemoteConfiguration)configuration).setApplicationContext(applicationContext); |
|
149 | 145 |
AbstractLazyInitializer.setConfiguration((CdmApplicationRemoteConfiguration)configuration); |
150 | 146 |
AbstractPersistentCollection.setConfiguration((CdmApplicationRemoteConfiguration)configuration); |
151 | 147 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractIOManager.java | ||
---|---|---|
58 | 58 |
ICdmRepository applicationConfiguration) { |
59 | 59 |
this.applicationConfiguration = applicationConfiguration; |
60 | 60 |
} |
61 |
|
|
62 |
/** |
|
63 |
* Starts the IO process |
|
64 |
* |
|
65 |
* @param configurator |
|
66 |
* a CONFIGURATOR object. |
|
67 |
*/ |
|
68 |
public void run(final CONFIGURATOR configurator) { |
|
69 |
// create job |
|
70 |
Job job = createIOJob(configurator); |
|
71 |
run(job); |
|
72 |
} |
|
61 |
// |
|
62 |
// /**
|
|
63 |
// * Starts the IO process
|
|
64 |
// *
|
|
65 |
// * @param configurator
|
|
66 |
// * a CONFIGURATOR object.
|
|
67 |
// */
|
|
68 |
// public void run(final CONFIGURATOR configurator) {
|
|
69 |
// // create job
|
|
70 |
// Job job = createIOJob(configurator);
|
|
71 |
// run(job);
|
|
72 |
// }
|
|
73 | 73 |
|
74 | 74 |
public void run(Job job) { |
75 | 75 |
// configure the job |
... | ... | |
79 | 79 |
job.schedule(); |
80 | 80 |
} |
81 | 81 |
|
82 |
/** |
|
83 |
* <p> |
|
84 |
* createIOJob |
|
85 |
* </p> |
|
86 |
* |
|
87 |
* @param configurator |
|
88 |
* a CONFIGURATOR object. |
|
89 |
* @return a {@link org.eclipse.core.runtime.jobs.Job} object. |
|
90 |
*/ |
|
91 |
protected abstract Job createIOJob(CONFIGURATOR configurator); |
|
82 |
// /**
|
|
83 |
// * <p>
|
|
84 |
// * createIOJob
|
|
85 |
// * </p>
|
|
86 |
// *
|
|
87 |
// * @param configurator
|
|
88 |
// * a CONFIGURATOR object.
|
|
89 |
// * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
|
|
90 |
// */
|
|
91 |
// protected abstract Job createIOJob(CONFIGURATOR configurator);
|
|
92 | 92 |
|
93 | 93 |
/** |
94 | 94 |
* @param configurator |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java | ||
---|---|---|
23 | 23 |
import java.util.zip.ZipEntry; |
24 | 24 |
import java.util.zip.ZipOutputStream; |
25 | 25 |
|
26 |
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger; |
|
26 |
import org.apache.logging.log4j.LogManager; |
|
27 |
import org.apache.logging.log4j.Logger; |
|
27 | 28 |
import org.eclipse.core.runtime.Assert; |
28 | 29 |
import org.eclipse.core.runtime.IProgressMonitor; |
29 | 30 |
import org.eclipse.core.runtime.IStatus; |
... | ... | |
36 | 37 |
import eu.etaxonomy.cdm.api.application.ICdmRepository; |
37 | 38 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
38 | 39 |
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator; |
39 |
import eu.etaxonomy.cdm.io.common.CdmDefaultExport; |
|
40 | 40 |
import eu.etaxonomy.cdm.io.common.ExportDataWrapper; |
41 | 41 |
import eu.etaxonomy.cdm.io.common.ExportResult; |
42 | 42 |
import eu.etaxonomy.cdm.io.common.ExportResultType; |
... | ... | |
46 | 46 |
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator; |
47 | 47 |
import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator; |
48 | 48 |
import eu.etaxonomy.cdm.io.service.IIOService; |
49 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
|
50 | 49 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
51 | 50 |
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter; |
52 | 51 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
... | ... | |
56 | 55 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
57 | 56 |
|
58 | 57 |
/** |
59 |
* |
|
60 | 58 |
* @author n.hoffmann |
61 | 59 |
* @created Sep 11, 2009 |
62 | 60 |
*/ |
... | ... | |
64 | 62 |
extends AbstractIOManager<IExportConfigurator> |
65 | 63 |
implements IPostMoniteredOperationEnabled { |
66 | 64 |
|
67 |
private static final Logger logger = LogManager.getLogger(ExportManager.class); |
|
65 |
private static final Logger logger = LogManager.getLogger(); |
|
66 |
|
|
68 | 67 |
/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */ |
69 | 68 |
public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm"; |
70 | 69 |
|
... | ... | |
79 | 78 |
return new ExportManager(applicationConfiguration); |
80 | 79 |
} |
81 | 80 |
|
82 |
@Override |
|
83 |
protected Job createIOJob(final IExportConfigurator configurator) { |
|
84 |
|
|
85 |
Assert.isNotNull(configurator, "Configuration may not be null"); |
|
86 |
|
|
87 |
final Display display = Display.getCurrent(); |
|
88 |
|
|
89 |
Job job = new Job("Export: " + configurator.getClass().getSimpleName()) { |
|
90 |
@Override |
|
91 |
protected IStatus run(IProgressMonitor monitor) { |
|
92 |
monitor.beginTask( |
|
93 |
"Exporting database. This will take some time.", 100); |
|
94 |
monitor.worked(10); |
|
95 |
|
|
96 |
/** see ticket # 4456 and */ |
|
97 |
// display.asyncExec(new Runnable() { |
|
81 |
// @Override |
|
82 |
// protected Job createIOJob(final IExportConfigurator configurator) { |
|
98 | 83 |
// |
99 |
// @Override |
|
100 |
// public void run() { |
|
84 |
// Assert.isNotNull(configurator, "Configuration may not be null"); |
|
101 | 85 |
// |
102 |
// // terminate any open transactions
|
|
103 |
// IConversationEnabled activePart = (IConversationEnabled) StoreUtil
|
|
104 |
// .getActivePage().getActivePart();
|
|
105 |
// activePart.getConversationHolder().commit(false);
|
|
106 |
// }
|
|
107 |
// });
|
|
108 |
|
|
86 |
// final Display display = Display.getCurrent();
|
|
87 |
// |
|
88 |
// Job job = new Job("Export: " + configurator.getClass().getSimpleName()) {
|
|
89 |
// @Override
|
|
90 |
// protected IStatus run(IProgressMonitor monitor) {
|
|
91 |
// monitor.beginTask(
|
|
92 |
// "Exporting database. This will take some time.", 100); |
|
109 | 93 |
// monitor.worked(10); |
110 |
|
|
111 |
CdmDefaultExport<IExportConfigurator> exporter = new CdmDefaultExport<>(); |
|
112 |
configurator.setProgressMonitor(CdmProgressMonitorAdapter |
|
113 |
.CreateSubMonitor(monitor, 80)); |
|
114 |
exporter.setCdmAppController(applicationConfiguration); |
|
115 |
monitor.worked(10); |
|
116 |
|
|
117 |
try { |
|
118 |
exporter.invoke(configurator); |
|
119 |
monitor.worked(60); |
|
120 |
} catch (RuntimeException e) { |
|
121 |
MessagingUtils.messageDialog("Error exporting data", this, |
|
122 |
"An error occurred while" |
|
123 |
+ "exporting to destination '" |
|
124 |
+ configurator.getDestinationNameString() |
|
125 |
+ "'.\n" |
|
126 |
+ "Please check error log for details.", e); |
|
127 |
} |
|
128 |
|
|
129 |
// display.asyncExec(()-> { |
|
130 |
// Object activePart = EventUtility.getActivePart(); |
|
131 |
// if (activePart instanceof IConversationEnabled) { |
|
132 |
// // terminate any open transactions |
|
133 |
// IConversationEnabled conversationEnabled = (IConversationEnabled) activePart; |
|
134 |
// // restarting transaction and committing it to |
|
135 |
// // trigger |
|
136 |
// // change listener |
|
137 |
// // TODO verify correct behaviour |
|
138 | 94 |
// |
139 |
// try{ |
|
140 |
// conversationEnabled.getConversationHolder() |
|
141 |
// .startTransaction(); |
|
95 |
// /** see ticket # 4456 and */ |
|
96 |
//// display.asyncExec(new Runnable() { |
|
97 |
//// |
|
98 |
//// @Override |
|
99 |
//// public void run() { |
|
100 |
//// |
|
101 |
//// // terminate any open transactions |
|
102 |
//// IConversationEnabled activePart = (IConversationEnabled) StoreUtil |
|
103 |
//// .getActivePage().getActivePart(); |
|
104 |
//// activePart.getConversationHolder().commit(false); |
|
105 |
//// } |
|
106 |
//// }); |
|
142 | 107 |
// |
143 |
// conversationEnabled.getConversationHolder() |
|
144 |
// .commit(); |
|
145 |
// }catch(RuntimeException e){ |
|
146 |
// MessagingUtils.messageDialog("Error starting conversation handling", this, "" + |
|
147 |
// "Conversation Error: "+ e); |
|
148 |
// } |
|
149 |
// } |
|
150 |
// }); |
|
151 |
monitor.worked(10); |
|
152 |
|
|
153 |
return Status.OK_STATUS; |
|
154 |
} |
|
155 |
}; |
|
156 |
|
|
157 |
return job; |
|
158 |
} |
|
108 |
//// monitor.worked(10); |
|
109 |
// |
|
110 |
// CdmDefaultExport<IExportConfigurator> exporter = new CdmDefaultExport<>(); |
|
111 |
// configurator.setProgressMonitor(CdmProgressMonitorAdapter |
|
112 |
// .CreateSubMonitor(monitor, 80)); |
|
113 |
// exporter.setCdmAppController(applicationConfiguration); |
|
114 |
// monitor.worked(10); |
|
115 |
// |
|
116 |
// try { |
|
117 |
// exporter.invoke(configurator); |
|
118 |
// monitor.worked(60); |
|
119 |
// } catch (RuntimeException e) { |
|
120 |
// MessagingUtils.messageDialog("Error exporting data", this, |
|
121 |
// "An error occurred while" |
|
122 |
// + "exporting to destination '" |
|
123 |
// + configurator.getDestinationNameString() |
|
124 |
// + "'.\n" |
|
125 |
// + "Please check error log for details.", e); |
|
126 |
// } |
|
127 |
// |
|
128 |
//// display.asyncExec(()-> { |
|
129 |
//// Object activePart = EventUtility.getActivePart(); |
|
130 |
//// if (activePart instanceof IConversationEnabled) { |
|
131 |
//// // terminate any open transactions |
|
132 |
//// IConversationEnabled conversationEnabled = (IConversationEnabled) activePart; |
|
133 |
//// // restarting transaction and committing it to |
|
134 |
//// // trigger |
|
135 |
//// // change listener |
|
136 |
//// // TODO verify correct behaviour |
|
137 |
//// |
|
138 |
//// try{ |
|
139 |
//// conversationEnabled.getConversationHolder() |
|
140 |
//// .startTransaction(); |
|
141 |
//// |
|
142 |
//// conversationEnabled.getConversationHolder() |
|
143 |
//// .commit(); |
|
144 |
//// }catch(RuntimeException e){ |
|
145 |
//// MessagingUtils.messageDialog("Error starting conversation handling", this, "" + |
|
146 |
//// "Conversation Error: "+ e); |
|
147 |
//// } |
|
148 |
//// } |
|
149 |
//// }); |
|
150 |
// monitor.worked(10); |
|
151 |
// |
|
152 |
// return Status.OK_STATUS; |
|
153 |
// } |
|
154 |
// }; |
|
155 |
// |
|
156 |
// return job; |
|
157 |
// } |
|
159 | 158 |
|
160 | 159 |
public Job createIOServiceJob(final IExportConfigurator configurator, final File exportFile) { |
161 | 160 |
Assert.isNotNull(configurator, "Configuration may not be null"); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ImportManager.java | ||
---|---|---|
23 | 23 |
import org.eclipse.core.runtime.Status; |
24 | 24 |
import org.eclipse.core.runtime.jobs.Job; |
25 | 25 |
import org.eclipse.swt.widgets.Display; |
26 |
import org.eclipse.ui.PlatformUI; |
|
27 | 26 |
|
28 | 27 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
29 | 28 |
import eu.etaxonomy.cdm.api.application.ICdmRepository; |
30 | 29 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
31 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
32 | 30 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
33 | 31 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE; |
34 | 32 |
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase; |
... | ... | |
49 | 47 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
50 | 48 |
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; |
51 | 49 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
52 |
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter; |
|
53 | 50 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
54 | 51 |
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled; |
55 | 52 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
56 | 53 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
57 |
import eu.etaxonomy.taxeditor.ui.dialog.ReportTextDialog; |
|
58 | 54 |
|
59 | 55 |
/** |
60 | 56 |
* @author n.hoffmann |
... | ... | |
74 | 70 |
return new ImportManager(applicationConfiguration); |
75 | 71 |
} |
76 | 72 |
|
77 |
/** |
|
78 |
* Use when importing data into the current application context |
|
79 |
* |
|
80 |
* @param configurator |
|
81 |
* a {@link eu.etaxonomy.cdm.io.common.IImportConfigurator} |
|
82 |
* object. |
|
83 |
* @return a {@link org.eclipse.core.runtime.jobs.Job} object. |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
protected Job createIOJob(final IImportConfigurator configurator) { |
|
87 |
Assert.isNotNull(configurator, "Configuration may not be null"); |
|
88 |
|
|
89 |
final Display display = Display.getDefault(); |
|
90 |
|
|
91 |
Job job = new Job("Import: " + configurator.getClass().getSimpleName()) { |
|
92 |
|
|
93 |
@Override |
|
94 |
protected IStatus run(IProgressMonitor monitor) { |
|
95 |
monitor.beginTask("Importing data", 100); |
|
96 |
configurator.setProgressMonitor(CdmProgressMonitorAdapter |
|
97 |
.CreateSubMonitor(monitor, 70)); |
|
98 |
|
|
99 |
monitor.worked(5); |
|
100 |
|
|
101 |
CdmDefaultImport<IImportConfigurator> importer = new CdmDefaultImport<>(); |
|
102 |
importer.setCdmAppController(applicationConfiguration); |
|
103 |
monitor.worked(5); |
|
104 |
ImportResult importResult = null; |
|
105 |
try { |
|
106 |
importResult = importer.invoke(configurator); |
|
107 |
|
|
108 |
monitor.worked(80); |
|
109 |
} catch (RuntimeException e) { |
|
110 |
MessagingUtils.messageDialog( |
|
111 |
"Error importing data", |
|
112 |
this, |
|
113 |
"An error occurred while" |
|
114 |
+ "importing from source '" |
|
115 |
+ configurator.getSourceNameString() |
|
116 |
+ "'.\n" |
|
117 |
+ "Please check error log for details.", e); |
|
118 |
} |
|
119 |
|
|
120 |
monitor.worked(5); |
|
121 |
monitor.done(); |
|
122 |
|
|
123 |
|
|
124 |
final StringBuilder reportText = new StringBuilder(); |
|
125 |
if(importResult!=null){ |
|
126 |
List<byte[]> reports = importResult.getReports(); |
|
127 |
for (byte[] bs : reports) { |
|
128 |
reportText.append(new String(bs)); |
|
129 |
} |
|
130 |
} |
|
131 |
display.asyncExec(new Runnable() { |
|
132 |
|
|
133 |
@Override |
|
134 |
public void run() { |
|
135 |
// display reports with possibility to save |
|
136 |
ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); |
|
137 |
dialog.setTitle(configurator.getClass().getSimpleName()+" Report"); |
|
138 |
dialog.setReportText(reportText.toString()); |
|
139 |
dialog.open(); |
|
140 |
|
|
141 |
CdmStore.getContextManager().notifyContextRefresh(); |
|
142 |
|
|
143 |
} |
|
144 |
}); |
|
145 |
|
|
146 |
return Status.OK_STATUS; |
|
147 |
} |
|
148 |
}; |
|
149 |
|
|
150 |
return job; |
|
151 |
|
|
152 |
} |
|
73 |
// /**
|
|
74 |
// * Use when importing data into the current application context
|
|
75 |
// *
|
|
76 |
// * @param configurator
|
|
77 |
// * a {@link eu.etaxonomy.cdm.io.common.IImportConfigurator}
|
|
78 |
// * object.
|
|
79 |
// * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
|
|
80 |
// */
|
|
81 |
// @Override
|
|
82 |
// protected Job createIOJob(final IImportConfigurator configurator) {
|
|
83 |
// Assert.isNotNull(configurator, "Configuration may not be null");
|
|
84 |
// |
|
85 |
// final Display display = Display.getDefault();
|
|
86 |
// |
|
87 |
// Job job = new Job("Import: " + configurator.getClass().getSimpleName()) {
|
|
88 |
// |
|
89 |
// @Override
|
|
90 |
// protected IStatus run(IProgressMonitor monitor) {
|
|
91 |
// monitor.beginTask("Importing data", 100);
|
|
92 |
// configurator.setProgressMonitor(CdmProgressMonitorAdapter
|
|
93 |
// .CreateSubMonitor(monitor, 70));
|
|
94 |
// |
|
95 |
// monitor.worked(5);
|
|
96 |
// |
|
97 |
// CdmDefaultImport<IImportConfigurator> importer = new CdmDefaultImport<>();
|
|
98 |
// importer.setCdmAppController(applicationConfiguration);
|
|
99 |
// monitor.worked(5);
|
|
100 |
// ImportResult importResult = null;
|
|
101 |
// try {
|
|
102 |
// importResult = importer.invoke(configurator);
|
|
103 |
// |
|
104 |
// monitor.worked(80);
|
|
105 |
// } catch (RuntimeException e) {
|
|
106 |
// MessagingUtils.messageDialog(
|
|
107 |
// "Error importing data",
|
|
108 |
// this,
|
|
109 |
// "An error occurred while"
|
|
110 |
// + "importing from source '"
|
|
111 |
// + configurator.getSourceNameString()
|
|
112 |
// + "'.\n"
|
|
113 |
// + "Please check error log for details.", e);
|
|
114 |
// }
|
|
115 |
// |
|
116 |
// monitor.worked(5);
|
|
117 |
// monitor.done();
|
|
118 |
// |
|
119 |
// |
|
120 |
// final StringBuilder reportText = new StringBuilder();
|
|
121 |
// if(importResult!=null){
|
|
122 |
// List<byte[]> reports = importResult.getReports();
|
|
123 |
// for (byte[] bs : reports) {
|
|
124 |
// reportText.append(new String(bs));
|
|
125 |
// }
|
|
126 |
// }
|
|
127 |
// display.asyncExec(new Runnable() {
|
|
128 |
// |
|
129 |
// @Override
|
|
130 |
// public void run() {
|
|
131 |
// // display reports with possibility to save
|
|
132 |
// ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
|
|
133 |
// dialog.setTitle(configurator.getClass().getSimpleName()+" Report");
|
|
134 |
// dialog.setReportText(reportText.toString());
|
|
135 |
// dialog.open();
|
|
136 |
// |
|
137 |
// CdmStore.getContextManager().notifyContextRefresh();
|
|
138 |
// |
|
139 |
// }
|
|
140 |
// });
|
|
141 |
// |
|
142 |
// return Status.OK_STATUS;
|
|
143 |
// }
|
|
144 |
// };
|
|
145 |
// |
|
146 |
// return job;
|
|
147 |
// |
|
148 |
// }
|
|
153 | 149 |
|
154 | 150 |
public Job createIOServiceJob(IImportConfigurator configurator, InputStream is, SOURCE_TYPE type) { |
155 | 151 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/in/excel/specimen/OpenExcelSpecimenImportWizard.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
@Override |
25 | 25 |
protected Class<? extends AbstractImportWizard> getImportWizardClass() { |
26 |
return SpecimenCdmExcelImportWizardE4.class;
|
|
26 |
return SpecimenCdmExcelImportWizard.class; |
|
27 | 27 |
} |
28 | 28 |
|
29 | 29 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/in/excel/specimen/SpecimenCdmExcelImportWizard.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.io.e4.in.excel.specimen; |
|
10 |
|
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import javax.inject.Inject; |
|
15 |
|
|
16 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
|
17 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
18 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.common.URI; |
|
21 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
22 |
import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator; |
|
23 |
import eu.etaxonomy.taxeditor.io.e4.in.AbstractImportWizard; |
|
24 |
import eu.etaxonomy.taxeditor.io.e4.in.GenericConfiguratorWizardPageE4; |
|
25 |
import eu.etaxonomy.taxeditor.io.e4.in.ImportFromFileDataSourceWithReferenceWizardPage; |
|
26 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
28 |
|
|
29 |
/** |
|
30 |
* TODO adapt to remoting, currently not in use |
|
31 |
* |
|
32 |
* @author pplitzner |
|
33 |
* @since Oct 5, 2017 |
|
34 |
*/ |
|
35 |
public class SpecimenCdmExcelImportWizard |
|
36 |
extends AbstractImportWizard<SpecimenCdmExcelImportConfigurator> { |
|
37 |
|
|
38 |
private SpecimenCdmExcelImportConfigurator configurator; |
|
39 |
|
|
40 |
private ImportFromFileDataSourceWithReferenceWizardPage dataSourcePage; |
|
41 |
|
|
42 |
@Inject |
|
43 |
public SpecimenCdmExcelImportWizard(IEclipseContext context, EPartService partService) { |
|
44 |
super(context, partService); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public SpecimenCdmExcelImportConfigurator getConfigurator() { |
|
49 |
return configurator; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public void init() { |
|
54 |
configurator = CdmStore.getImportManager().SpecimenCdmExcelImportConfigurator(); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public boolean performFinish() { |
|
59 |
URI source = dataSourcePage.getUri(); |
|
60 |
configurator.setSource(source); |
|
61 |
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE); |
|
62 |
|
|
63 |
throw new RuntimeException("SpecimenCdmExcelImport is not yet transformed to remoting execution"); |
|
64 |
//TODO local IO not supportd anymore |
|
65 |
// CdmStore.getImportManager().run(configurator); |
|
66 |
// return true; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public void addPages() { |
|
71 |
dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWithReferenceWizardPage.class, context); |
|
72 |
dataSourcePage.setTitle("Choose Specimen CDM Excel"); |
|
73 |
dataSourcePage.setDescription("Please choose an xls file in the SpecimenCdmExcel format."); |
|
74 |
dataSourcePage.setExtensions(new String[]{"*.xlsx", "*.xls", "*.*"}); |
|
75 |
|
|
76 |
addPage(dataSourcePage); |
|
77 |
super.addPages(); |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
protected void addConfiguratorPage(){ |
|
82 |
List<String> ignoreMethods = new ArrayList<>(); |
|
83 |
ignoreMethods.add("setIgnoreNull"); |
|
84 |
ignoreMethods.add("setInteractWithUser"); |
|
85 |
ignoreMethods.add("setUseClassification"); |
|
86 |
ignoreMethods.add("setRegisterAuditing"); |
|
87 |
ignoreMethods.add("setDeduplicateAuthors"); |
|
88 |
ignoreMethods.add("setDeduplicateReferences"); |
|
89 |
pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context); |
|
90 |
pageConfiguration.initImport(getConfigurator(), ignoreMethods, Messages.ExcelSpecimenUpdateWizard_ConfiguratorWizard_label); |
|
91 |
addPage(pageConfiguration); |
|
92 |
} |
|
93 |
|
|
94 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/in/excel/specimen/SpecimenCdmExcelImportWizardE4.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package eu.etaxonomy.taxeditor.io.e4.in.excel.specimen; |
|
5 |
|
|
6 |
import eu.etaxonomy.cdm.common.URI; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
import javax.inject.Inject; |
|
11 |
|
|
12 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
|
13 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
|
14 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
17 |
import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator; |
|
18 |
import eu.etaxonomy.taxeditor.io.e4.in.AbstractImportWizard; |
|
19 |
import eu.etaxonomy.taxeditor.io.e4.in.GenericConfiguratorWizardPageE4; |
|
20 |
import eu.etaxonomy.taxeditor.io.e4.in.ImportFromFileDataSourceWithReferenceWizardPage; |
|
21 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
22 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
23 |
|
|
24 |
/** |
|
25 |
* |
|
26 |
* @author pplitzner |
|
27 |
* @since Oct 5, 2017 |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class SpecimenCdmExcelImportWizardE4 extends AbstractImportWizard<SpecimenCdmExcelImportConfigurator> { |
|
31 |
|
|
32 |
|
|
33 |
private SpecimenCdmExcelImportConfigurator configurator; |
|
34 |
|
|
35 |
private ImportFromFileDataSourceWithReferenceWizardPage dataSourcePage; |
|
36 |
|
|
37 |
@Inject |
|
38 |
public SpecimenCdmExcelImportWizardE4(IEclipseContext context, EPartService partService) { |
|
39 |
super(context, partService); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public SpecimenCdmExcelImportConfigurator getConfigurator() { |
|
44 |
return configurator; |
|
45 |
} |
|
46 |
|
|
47 |
/** {@inheritDoc} */ |
|
48 |
@Override |
|
49 |
public void init() { |
|
50 |
configurator = CdmStore.getImportManager().SpecimenCdmExcelImportConfigurator(); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public boolean performFinish() { |
|
55 |
URI source = dataSourcePage.getUri(); |
|
56 |
configurator.setSource(source); |
|
57 |
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE); |
|
58 |
|
|
59 |
CdmStore.getImportManager().run(configurator); |
|
60 |
|
|
61 |
return true; |
|
62 |
} |
|
63 |
|
|
64 |
/** {@inheritDoc} */ |
|
65 |
@Override |
|
66 |
public void addPages() { |
|
67 |
dataSourcePage = ContextInjectionFactory.make(ImportFromFileDataSourceWithReferenceWizardPage.class, context); |
|
68 |
dataSourcePage.setTitle("Choose Specimen CDM Excel"); |
|
69 |
dataSourcePage.setDescription("Please choose an xls file in the SpecimenCdmExcel format."); |
|
70 |
dataSourcePage.setExtensions(new String[]{"*.xlsx", "*.xls", "*.*"}); |
|
71 |
|
|
72 |
addPage(dataSourcePage); |
|
73 |
super.addPages(); |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
protected void addConfiguratorPage(){ |
|
78 |
List<String> ignoreMethods = new ArrayList<>(); |
|
79 |
ignoreMethods.add("setIgnoreNull"); |
|
80 |
ignoreMethods.add("setInteractWithUser"); |
|
81 |
ignoreMethods.add("setUseClassification"); |
|
82 |
ignoreMethods.add("setRegisterAuditing"); |
|
83 |
ignoreMethods.add("setDeduplicateAuthors"); |
|
84 |
ignoreMethods.add("setDeduplicateReferences"); |
|
85 |
pageConfiguration = ContextInjectionFactory.make(GenericConfiguratorWizardPageE4.class, context); |
|
86 |
pageConfiguration.initImport(getConfigurator(), ignoreMethods, Messages.ExcelSpecimenUpdateWizard_ConfiguratorWizard_label); |
|
87 |
addPage(pageConfiguration); |
|
88 |
} |
|
89 |
|
|
90 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/EndnoteImportWizard.java | ||
---|---|---|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.taxeditor.io.wizard; |
11 | 10 |
|
12 | 11 |
import java.io.File; |
... | ... | |
23 | 22 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
24 | 23 |
|
25 | 24 |
/** |
26 |
* <p>EndnoteImportWizard class.</p>
|
|
25 |
* TODO adapt to remoting, currently not in use
|
|
27 | 26 |
* |
28 | 27 |
* @author n.hoffmann |
29 | 28 |
* @created Sep 18, 2009 |
... | ... | |
45 | 44 |
File file = dataSourcePage.getFile(); |
46 | 45 |
configurator.setSource(URI.fromFile(file)); |
47 | 46 |
|
48 |
CdmStore.getImportManager().run(configurator); |
|
47 |
//TODO local IO not supportd anymore |
|
48 |
// CdmStore.getImportManager().run(configurator); |
|
49 | 49 |
|
50 | 50 |
return true; |
51 | 51 |
} |
... | ... | |
67 | 67 |
public EndnoteImportConfigurator getConfigurator() { |
68 | 68 |
return configurator; |
69 | 69 |
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 | 70 |
} |
Also available in: Unified diff
ref #10189 split CdmApplicationController into repository and application part in TaxEditor