exposing CommonService through cdm store
authorn.hoffmann <n.hoffmann@localhost>
Mon, 10 Aug 2009 10:33:07 +0000 (10:33 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 10 Aug 2009 10:33:07 +0000 (10:33 +0000)
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractImportWizard.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/ImportFromFileDataSourceWizardPage.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsImportWizard.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java

index 120e49f4ad172c4cd70171c19ef70a08587003a2..50ff7fb69537f36a3a8bb4f5831896c6957148f3 100644 (file)
@@ -13,10 +13,14 @@ package eu.etaxonomy.taxeditor.io;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbenchPart;
 
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator;
 import eu.etaxonomy.cdm.io.common.IIoConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
@@ -123,6 +127,14 @@ public abstract class AbstractImportWizard<CONFIG extends IIoConfigurator> exten
                        throw new IllegalArgumentException("Configuration may not be null");
                }
                
+               // terminate any open transactions
+               IConversationEnabled activePart = (IConversationEnabled) StoreUtil.getActivePage().getActivePart();
+               activePart.getConversationHolder().commit(false);
+               
+               
+               
+//             ConversationHolder conversation = CdmStore.NewTransactionalConversation();
+               
                importer = new CdmDefaultImport();
 //             
 //             Job importJob = new Job("Import"){
@@ -136,7 +148,15 @@ public abstract class AbstractImportWizard<CONFIG extends IIoConfigurator> exten
                
                importer.setCdmAppController(configurator.getCdmAppController());
                
-               return importer.invoke(configurator);
+               boolean result = importer.invoke(configurator);
+
+               // restarting transaction and committing it to trigger change listener
+               // TODO verify correct behaviour
+               activePart.getConversationHolder().startTransaction();
+               activePart.getConversationHolder().commit();
+
+               
+               return result; 
        }
 
        /* (non-Javadoc)
index 24600619a2eed67c23d67ebbd87ab4e247650304..34993c9cfdfb44693a18c5953085999e3395cf78 100644 (file)
@@ -60,6 +60,8 @@ public class ImportFromFileDataSourceWizardPage extends WizardPage {
        public void createControl(Composite parent) {
                final Composite composite = new Composite(parent, SWT.NULL);
                
+               setPageComplete(false);
+               
                GridLayout gridLayout = new GridLayout();
                gridLayout.numColumns = 3;
                composite.setLayout(gridLayout);
index 4c8226a6fa6ae6fc20d394ba149526456e61da5d..dcce5b28e03780fb180946d70e38b0defd12d25c 100644 (file)
@@ -16,7 +16,6 @@ import org.eclipse.ui.IWorkbench;
 
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
 import eu.etaxonomy.cdm.io.tcsxml.in.TcsXmlImportConfigurator;
-import eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceSQLServerWizardPage;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -45,8 +44,6 @@ public class TcsImportWizard extends AbstractImportWizard<TcsXmlImportConfigurat
                
                file = "file://" + file;
                
-               CdmStore.NewTransactionalConversation();
-               
                configurator.setSource(file);
                configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
                configurator.setCdmAppController(CdmStore.getApplicationController());
index 2b05d45835409f5b3ea0a93b5ebcbc90a2ad3f06..c7c57ebf5731ebf82e6ffb5b16bf39f18d64a7cf 100644 (file)
@@ -20,6 +20,7 @@ import org.springframework.security.providers.ProviderManager;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationController;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.ICommonService;
 import eu.etaxonomy.cdm.api.service.ILocationService;
 import eu.etaxonomy.cdm.api.service.INameService;
 import eu.etaxonomy.cdm.api.service.IReferenceService;
@@ -241,6 +242,9 @@ public class CdmStore{
 
        public static IUserService getUserService() { return getDefault().getApplicationControllerInternal().getUserService(); }
        
+       public static ICommonService getCommonService() { return getDefault().getApplicationControllerInternal().getCommonService(); }
+       
+       
        /**
         * @param searchText
         * @return