import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.strategy.merge.MergeException;
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityContainer;
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* <p>MergeGroupHandler class.</p>
}
Object targetEntity = ((IEntityContainer<?>) targetAnnotation).getEntity();
+ TeamOrPersonBase teamOrPerson = null;
+ Reference ref = null;
+ if (targetEntity instanceof TeamOrPersonBase){
+ teamOrPerson = HibernateProxyHelper.deproxy(targetEntity, TeamOrPersonBase.class);
+ } else if(targetEntity instanceof Reference){
+ ref = HibernateProxyHelper.deproxy(targetEntity, Reference.class);
+ }
logger.info("Merging group");
// model.printAnnotations();
for (LineAnnotation annotation : candidateAnnotations) {
+ //first check whether entities are mergeable
+
+ try{
+ if (ref != null){
+ Reference ref2 = HibernateProxyHelper.deproxy(annotation.getEntity(), Reference.class);
+
+ if (!CdmStore.getCommonService().isMergeable(ref, ref2, null)){
+ MessageDialog.openWarning(HandlerUtil.getActiveShell(event),
+ "No merge possible", "A merge of " + ref.getTitleCache() + " and " + ref2.getTitleCache() + " is not possible.");
+ return null;
+ }
+ }
+ if (teamOrPerson != null){
+ TeamOrPersonBase teamOrPerson2 = HibernateProxyHelper.deproxy(annotation.getEntity(), TeamOrPersonBase.class);
+
+ if (!CdmStore.getCommonService().isMergeable(teamOrPerson, teamOrPerson2, null)){
+ MessageDialog.openWarning(HandlerUtil.getActiveShell(event),
+ "No merge possible", "A merge of " + teamOrPerson.getTitleCache() + " and " + teamOrPerson2.getTitleCache() + " is not possible.");
+ return null;
+ }
+ }
+ }catch(MergeException e){
+
+ }
((BulkEditor) editor).removeAnnotatedLine(annotation);
// Mark entity container for merging with target entity