convert methods has updateResult as return type
authorKatja Luther <k.luther@bgbm.org>
Tue, 15 Mar 2016 12:45:29 +0000 (13:45 +0100)
committerKatja Luther <k.luther@bgbm.org>
Tue, 15 Mar 2016 12:45:29 +0000 (13:45 +0100)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/ConvertPerson2TeamHandler.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/ConvertTeam2PersonHandler.java

index dd2a4979d58dddce3703a8332b55ebbfe482df42..ed211575e3dc59efd5b18337805ad3ec83e7fb73 100644 (file)
@@ -21,6 +21,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
 import org.eclipse.ui.texteditor.IDocumentProvider;\r
 \r
 import eu.etaxonomy.cdm.api.service.IAgentService;\r
+import eu.etaxonomy.cdm.api.service.UpdateResult;\r
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;\r
 import eu.etaxonomy.cdm.model.agent.Person;\r
 import eu.etaxonomy.cdm.model.agent.Team;\r
@@ -74,11 +75,12 @@ public class ConvertPerson2TeamHandler extends AbstractHandler {
                        Team team ;\r
                        for(Object object : structuredSelection.toList()){\r
                                LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object);\r
-                               team = null;\r
+                               UpdateResult result = null;\r
+                               team  = null;\r
                                if (object instanceof Person){\r
                                        Person person = HibernateProxyHelper.deproxy(object, Person.class);\r
                                        try {\r
-                                               team = CdmStore.getService(IAgentService.class).convertPerson2Team(person.getUuid());\r
+                                           result = CdmStore.getService(IAgentService.class).convertPerson2Team(person.getUuid());\r
                                        } catch (IllegalArgumentException e) {\r
                                                MessagingUtils.errorDialog("Can not convert Person into a Team", null, e.getLocalizedMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID,e, true);\r
                                        } catch (MergeException e) {\r
@@ -87,7 +89,9 @@ public class ConvertPerson2TeamHandler extends AbstractHandler {
                                }else{\r
                                        MessagingUtils.informationDialog("Can not convert Person into a Team", "convert Person to Team can only be called on a person.");\r
                                }\r
-\r
+                               if (result != null &&result.isOk()){\r
+                                   team = (Team)result.getCdmEntity();\r
+                               }\r
                                if (team != null){\r
                                        ((BulkEditor) editor).removeAnnotatedLine(annotation);\r
                                        ((BulkEditor) editor).createAnnotatedLine(team);\r
index 047cad68c31de532220da0adb89d1f715bf6292b..d26b3ed5fc0c238081bdf805cbc63c55a74de65a 100644 (file)
@@ -21,6 +21,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
 import org.eclipse.ui.texteditor.IDocumentProvider;\r
 \r
 import eu.etaxonomy.cdm.api.service.IAgentService;\r
+import eu.etaxonomy.cdm.api.service.UpdateResult;\r
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;\r
 import eu.etaxonomy.cdm.model.agent.Person;\r
 import eu.etaxonomy.cdm.model.agent.Team;\r
@@ -74,10 +75,11 @@ public class ConvertTeam2PersonHandler extends AbstractHandler {
                        for(Object object : structuredSelection.toList()){\r
                                LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object);\r
                                person = null;\r
+                               UpdateResult result = null;\r
                                if (object instanceof Team){\r
                                        Team team = HibernateProxyHelper.deproxy(object, Team.class);\r
                                        try {\r
-                                               person = CdmStore.getService(IAgentService.class).convertTeam2Person(team.getUuid());\r
+                                               result = CdmStore.getService(IAgentService.class).convertTeam2Person(team.getUuid());\r
                                        } catch (IllegalArgumentException e) {\r
                                                MessagingUtils.informationDialog("Can not convert Team to Person", e.getMessage());\r
                                        } catch (MergeException e) {\r
@@ -86,7 +88,9 @@ public class ConvertTeam2PersonHandler extends AbstractHandler {
                                }else{\r
                                        MessagingUtils.informationDialog("Can not convert Team to Person", "convertTeam2Person can only be called on a team.");\r
                                }\r
-\r
+                               if (result != null && result.isOk()){\r
+                                   person = (Person)result.getCdmEntity();\r
+                               }\r
                                if (person != null){\r
                                        ((BulkEditor) editor).removeAnnotatedLine(annotation);\r
                                        ((BulkEditor) editor).createAnnotatedLine(person);\r