commit b51ccdd4ad42d3e2dc5c747e838f6f9397265267
Author: Katja Luther <k.luther@bgbm.org>
Date:   Mon May 7 11:32:59 2018 +0200

    use longRunningTasksService for setSecundumReference

diff --git a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
index 9f4f6986e..4d2302375 100644
--- a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
+++ b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Export-Package: com.google.api,
  eu.etaxonomy.cdm.api.cache,
  eu.etaxonomy.cdm.api.conversation,
  eu.etaxonomy.cdm.api.facade,
+ eu.etaxonomy.cdm.api.longrunningService,
  eu.etaxonomy.cdm.api.service,
  eu.etaxonomy.cdm.api.service.config,
  eu.etaxonomy.cdm.api.service.description,
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
index 07dbbf1ea..e21879cb1 100644
--- a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
+++ b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
@@ -37,6 +37,7 @@ import org.springframework.transaction.TransactionStatus;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
+import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService;
 import eu.etaxonomy.cdm.api.service.IAgentService;
 import eu.etaxonomy.cdm.api.service.IAnnotationService;
 import eu.etaxonomy.cdm.api.service.IClassificationService;
@@ -423,7 +424,7 @@ public class CdmApplicationRemoteConfiguration implements ICdmRepository, Applic
     @Override
     public IRegistrationService getRegistrationService() {
         return (IRegistrationService) getService(IRegistrationService.class, "/remoting/registration.service", new CdmServiceRequestExecutor());
-    
+
     }
 
     @Override
@@ -497,6 +498,10 @@ public class CdmApplicationRemoteConfiguration implements ICdmRepository, Applic
         return (IIOService) getService(IIOService.class, "/remoting/io.service", new CdmServiceRequestExecutor());
     }
 
+    public ILongRunningTasksService getLongRunningTasksService() {
+        return (ILongRunningTasksService) getService(ILongRunningTasksService.class, "/remoting/longrunningtasks.service", new CdmServiceRequestExecutor());
+    }
+
     public ITestService getTestService() {
         return (ITestService) getService(ITestService.class, "/remoting/test.service", new CdmServiceRequestExecutor());
     }
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java
index 9d6bd88ef..56aa1d483 100644
--- a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java
+++ b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java
@@ -19,6 +19,7 @@ import org.springframework.context.ApplicationListener;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 
+import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService;
 import eu.etaxonomy.cdm.api.service.ITestService;
 import eu.etaxonomy.cdm.cache.CdmRemoteCacheManager;
 import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
@@ -181,6 +182,10 @@ public class CdmApplicationRemoteController  extends CdmApplicationController {
         return ((CdmApplicationRemoteConfiguration)configuration).getIOService();
     }
 
+    public ILongRunningTasksService getLongRunningTasksService(){
+        return ((CdmApplicationRemoteConfiguration)configuration).getLongRunningTasksService();
+    }
+
     public ITestService getTestService(){
         return ((CdmApplicationRemoteConfiguration)configuration).getTestService();
     }
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationState.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationState.java
index 796727a2c..c3e670ad3 100644
--- a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationState.java
+++ b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationState.java
@@ -30,6 +30,7 @@ import org.osgi.framework.Constants;
 import org.springframework.security.core.context.SecurityContext;
 
 import eu.etaxonomy.cdm.api.cache.CdmServiceCacher;
+import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService;
 import eu.etaxonomy.cdm.api.service.ICommonService;
 import eu.etaxonomy.cdm.api.service.IService;
 import eu.etaxonomy.cdm.api.service.ITestService;
@@ -206,6 +207,14 @@ public class CdmApplicationState {
 
     }
 
+    public static ILongRunningTasksService getLongRunningTasksService() {
+        ICdmRepository configuration = getCurrentAppConfig();
+
+        return ((CdmApplicationRemoteController)configuration).getLongRunningTasksService();
+
+    }
+
+
 
     public static ITestService getTestService() {
         ICdmRepository configuration = getCurrentAppConfig();
diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml b/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml
index 1451f3721..21891b06d 100644
--- a/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml
+++ b/eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml
@@ -629,6 +629,23 @@
       </bean>
     </property>
   </bean>
+  
+   <bean id="longRunningTasksService" lazy-init="true"
+    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
+    <property name="serviceUrl">
+      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/longrunningtasks.service
+      </value>
+    </property>
+    <property name="serviceInterface">
+      <value>eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService
+      </value>
+    </property>
+    <property name="httpInvokerRequestExecutor">
+      <bean class="eu.etaxonomy.taxeditor.service.CdmAuthenticatedHttpInvokerRequestExecutor">
+        <property name="readTimeout" value="0" />
+      </bean>
+    </property>
+  </bean>
 
   <bean id="testService" lazy-init="true"
     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java
index ace8d0bc8..8119916b3 100755
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java
@@ -25,10 +25,7 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.progress.IProgressConstants;
 
-import eu.etaxonomy.cdm.api.application.CdmApplicationException;
-import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
@@ -63,15 +60,15 @@ public class SetSecundumForSubtreeOperation extends UpdateSubtreeOperation imple
      */
     @Override
     protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
-//        runMoniteredOperation();
-
-        Job job = createJob(monitor);
-        // configure the job
-        job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
-        job.setUser(true);
-        // schedule job
-        job.schedule();
-
+       runMoniteredOperation();
+       updateNameEditors();
+//        Job job = createJob(monitor);
+//        // configure the job
+//        job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
+//        job.setUser(true);
+//        // schedule job
+//        job.schedule();
+//
         return updateResult;
 
 
@@ -102,10 +99,10 @@ public class SetSecundumForSubtreeOperation extends UpdateSubtreeOperation imple
 
     public void runMoniteredOperation() {
         ITaxonNodeService nodeService;
-        try {
-            nodeService = CdmApplicationState.getService(ITaxonNodeService.class);
+//        try {
+//            nodeService = CdmApplicationState.getService(ITaxonNodeService.class);
 
-            final UUID uuid = nodeService.monitSetSecundum((SecundumForSubtreeConfigurator)config);
+            final UUID uuid = longRunningTaskService.monitLongRunningTask((SecundumForSubtreeConfigurator)config);
             Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
@@ -117,10 +114,10 @@ public class SetSecundumForSubtreeOperation extends UpdateSubtreeOperation imple
                         null);
             }
         });
-        } catch (CdmApplicationException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
+//        } catch (CdmApplicationException e) {
+//            // TODO Auto-generated catch block
+//            e.printStackTrace();
+//        }
 
     }
 
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java
index 397c0a9b0..69e242056 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java
@@ -11,7 +11,9 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.swt.widgets.Display;
 
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
+import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase;
@@ -33,6 +35,8 @@ public abstract class UpdateSubtreeOperation extends RemotingCdmUpdateOperation
 
 	 TaxonNode subtreeNode;
 	 ITaxonNodeService taxonNodeService;
+	 ILongRunningTasksService longRunningTaskService;
+
 	 protected EModelService modelService = null;
 
 	 public UpdateSubtreeOperation(Object source,
@@ -49,8 +53,8 @@ public abstract class UpdateSubtreeOperation extends RemotingCdmUpdateOperation
 	        this.config = config;
 	        this.updateResult = new UpdateResult();
 	        this.modelService = modelService;
-	        taxonNodeService = CdmStore.getService(ITaxonNodeService.class);
-	        subtreeNode = taxonNodeService.load(config.getSubtreeUuid());
+	        longRunningTaskService = CdmApplicationState.getLongRunningTasksService();
+	        subtreeNode = CdmStore.getService(ITaxonNodeService.class).load(config.getSubtreeUuid());
 	    }
 	  public void updateNameEditors(){
 	      List<TaxonNode> nodesToUpdate = new ArrayList();
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairWizard.java
index dc6abd109..eed5602aa 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairWizard.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairWizard.java
@@ -12,10 +12,9 @@ import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.wizard.Wizard;
 
 import eu.etaxonomy.cdm.config.ICdmSource;
-import eu.etaxonomy.cdm.io.operation.config.CacheUpdaterConfigurator;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
+import eu.etaxonomy.cdm.io.operation.config.CacheUpdaterConfigurator;
 import eu.etaxonomy.cdm.io.operation.config.SortIndexUpdaterConfigurator;
-import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
@@ -56,7 +55,7 @@ public class DatabaseRepairWizard extends Wizard {
                 config = SortIndexUpdaterConfigurator.NewInstance(null);
                 config.setDoFeatureNode(false);
                 config.setDoPolytomousKeyNode(false);
-                
+
 
              }
             if (config.isDoFeatureNode() || config.isDoPolytomousKeyNode() || config.isDoTaxonNode()){
