Revision fc7a7c4a
Added by Katja Luther over 7 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/ConvertPerson2TeamHandler.java | ||
---|---|---|
21 | 21 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
24 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
24 | 25 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
25 | 26 |
import eu.etaxonomy.cdm.model.agent.Person; |
26 | 27 |
import eu.etaxonomy.cdm.model.agent.Team; |
... | ... | |
74 | 75 |
Team team ; |
75 | 76 |
for(Object object : structuredSelection.toList()){ |
76 | 77 |
LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object); |
77 |
team = null; |
|
78 |
UpdateResult result = null; |
|
79 |
team = null; |
|
78 | 80 |
if (object instanceof Person){ |
79 | 81 |
Person person = HibernateProxyHelper.deproxy(object, Person.class); |
80 | 82 |
try { |
81 |
team = CdmStore.getService(IAgentService.class).convertPerson2Team(person.getUuid());
|
|
83 |
result = CdmStore.getService(IAgentService.class).convertPerson2Team(person.getUuid());
|
|
82 | 84 |
} catch (IllegalArgumentException e) { |
83 | 85 |
MessagingUtils.errorDialog("Can not convert Person into a Team", null, e.getLocalizedMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID,e, true); |
84 | 86 |
} catch (MergeException e) { |
... | ... | |
87 | 89 |
}else{ |
88 | 90 |
MessagingUtils.informationDialog("Can not convert Person into a Team", "convert Person to Team can only be called on a person."); |
89 | 91 |
} |
90 |
|
|
92 |
if (result != null &&result.isOk()){ |
|
93 |
team = (Team)result.getCdmEntity(); |
|
94 |
} |
|
91 | 95 |
if (team != null){ |
92 | 96 |
((BulkEditor) editor).removeAnnotatedLine(annotation); |
93 | 97 |
((BulkEditor) editor).createAnnotatedLine(team); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/ConvertTeam2PersonHandler.java | ||
---|---|---|
21 | 21 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
24 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
24 | 25 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
25 | 26 |
import eu.etaxonomy.cdm.model.agent.Person; |
26 | 27 |
import eu.etaxonomy.cdm.model.agent.Team; |
... | ... | |
74 | 75 |
for(Object object : structuredSelection.toList()){ |
75 | 76 |
LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object); |
76 | 77 |
person = null; |
78 |
UpdateResult result = null; |
|
77 | 79 |
if (object instanceof Team){ |
78 | 80 |
Team team = HibernateProxyHelper.deproxy(object, Team.class); |
79 | 81 |
try { |
80 |
person = CdmStore.getService(IAgentService.class).convertTeam2Person(team.getUuid());
|
|
82 |
result = CdmStore.getService(IAgentService.class).convertTeam2Person(team.getUuid());
|
|
81 | 83 |
} catch (IllegalArgumentException e) { |
82 | 84 |
MessagingUtils.informationDialog("Can not convert Team to Person", e.getMessage()); |
83 | 85 |
} catch (MergeException e) { |
... | ... | |
86 | 88 |
}else{ |
87 | 89 |
MessagingUtils.informationDialog("Can not convert Team to Person", "convertTeam2Person can only be called on a team."); |
88 | 90 |
} |
89 |
|
|
91 |
if (result != null && result.isOk()){ |
|
92 |
person = (Person)result.getCdmEntity(); |
|
93 |
} |
|
90 | 94 |
if (person != null){ |
91 | 95 |
((BulkEditor) editor).removeAnnotatedLine(annotation); |
92 | 96 |
((BulkEditor) editor).createAnnotatedLine(person); |
Also available in: Unified diff
convert methods has updateResult as return type