From: jenkins Date: Thu, 28 Jan 2021 12:56:07 +0000 (+0100) Subject: Merge branch 'release/5.19.0' X-Git-Tag: 5.19.0~1 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/0e8e733e3382d50cc12579e114400286252cdf69?hp=-c Merge branch 'release/5.19.0' --- 0e8e733e3382d50cc12579e114400286252cdf69 diff --combined eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java index e3285560f,ad6bf55ff..f22294844 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java @@@ -1,6 -1,11 +1,11 @@@ /** - * - */ + * Copyright (C) 2007 EDIT + * European Distributed Institute of Taxonomy + * http://www.e-taxonomy.eu + * + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * See LICENSE.TXT at the top of this package for the full license terms. + */ package eu.etaxonomy.taxeditor.newWizard; import java.util.Map; @@@ -20,7 -25,6 +25,7 @@@ import eu.etaxonomy.cdm.model.descripti import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.TaxonNode; import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus; +import eu.etaxonomy.cdm.persistence.dto.MergeResult; import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; import eu.etaxonomy.taxeditor.l10n.Messages; import eu.etaxonomy.taxeditor.model.MessagingUtils; @@@ -29,7 -33,7 +34,7 @@@ import eu.etaxonomy.taxeditor.ui.sectio import eu.etaxonomy.taxeditor.ui.section.classification.TaxonNodeWizardPage; /** - *

NewTaxonNodeWizard class.

+ * NewTaxonNodeWizard class. * * @author n.hoffmann * @created Sep 15, 2009 @@@ -73,18 -77,15 +78,15 @@@ public class NewTaxonNodeWizard extend if (status == null){ notes = null; } - result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, source, parent.getMicroReference(), + + result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, source, parent.getMicroReference(), status, notes); + if (result.isOk()){ this.setEntity((TaxonNode)result.getCdmEntity()); - this.getEntity().getTaxon().setPublish(taxon.isPublish()); - MergeResult mergeResult = CdmStore.getService(ITaxonNodeService.class).merge(this.getEntity(), true); - this.setEntity(mergeResult.getMergedEntity()); CdmApplicationState.getCurrentDataChangeService() .fireChangeEvent(new CdmChangeEvent(Action.Create, result.getUpdatedObjects(), NewTaxonNodeWizard.class), true); - CdmApplicationState.getCurrentDataChangeService() - .fireChangeEvent(new CdmChangeEvent(Action.Create, mergeResult.getMergedEntity(), NewTaxonNodeWizard.class), true); }else{ setSuccess(false); @@@ -103,25 -104,6 +105,6 @@@ } } - // @Override - // protected TaxonNode createNewEntity() { - // if(getSelection() != null){ - // Object selectedObject = getSelection().getFirstElement(); - // if(selectedObject instanceof TaxonNodeDto){ - // TaxonNodeDto taxonNodeDto = (TaxonNodeDto) selectedObject; - // TaxonNode node = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeDto.getUuid()); - // Reference sec = node.getTaxon() != null? node.getTaxon().getSec():null; - // Taxon newTaxon = Taxon.NewInstance(TaxonNameFactory.NewNameInstance(PreferencesUtil.getPreferredNomenclaturalCode(), null), sec); - // TaxonNode child = node.addChildTaxon(newTaxon, null, null); - // - // return child; - // - // } - // } - // - // return null; - // } - public boolean openInEditor() { return isOpenInEditor ; } @@@ -172,4 -154,4 +155,4 @@@ } } } - } + } diff --combined eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/SourceComparator.java index 3e37e3acd,8f4e885cb..a01f31295 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/SourceComparator.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/SourceComparator.java @@@ -1,6 -1,13 +1,13 @@@ + /** + * Copyright (C) 2007 EDIT + * European Distributed Institute of Taxonomy + * http://www.e-taxonomy.eu + * + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * See LICENSE.TXT at the top of this package for the full license terms. + */ package eu.etaxonomy.taxeditor.ui.section.description; - import java.util.Comparator; import eu.etaxonomy.cdm.model.description.DescriptionElementSource; @@@ -11,22 -18,29 +18,30 @@@ import eu.etaxonomy.cdm.model.reference /** * @author pplitzner * @date Apr 13, 2016 - * */ public class SourceComparator implements Comparator { + @Override public int compare(T o1, T o2) { - int id1 = o1.getId(); - int id2 = o2.getId(); + + //same and null compare, to be on the save side + if (o1 == o2){ + return 0; + }else if (o1 == null){ + return -1; + }else if (o2 == null){ + return 1; + } + boolean isDescriptionElementSource1 = false; boolean isDescriptionElementSource2 = false; - if (o1 instanceof DescriptionElementSource){ + if (o1.isInstanceOf(DescriptionElementSource.class)){ isDescriptionElementSource1 = true; } - if (o2 instanceof DescriptionElementSource){ + if (o2.isInstanceOf(DescriptionElementSource.class)){ isDescriptionElementSource2 = true; } + int result = 0; if (isDescriptionElementSource1 != isDescriptionElementSource2){ if (isDescriptionElementSource1){ return -1; @@@ -34,72 -48,63 +49,63 @@@ return 1; } } - OriginalSourceType type1 = o1.getType(); - OriginalSourceType type2 = o2.getType(); - Reference citation1 = o1.getCitation(); - Reference citation2 = o2.getCitation(); - - // the newly created should always be on top - if (id1 == 0){ - if(id2!=0) { - return -1; - } - else{ - result = 0; - } - } else if(id2==0){ + if (!o1.isPersited() && o2.isPersited()) { + return -1; + } else if(o1.isPersited() && !o2.isPersited()){ return 1; } // sort by type (Primary taxonomic > Primary Media > others // alphabetically by reference title cache) - else if (type1 == null){ - if(type2==null){ - result = 0; - } - else{ - result = -1; + OriginalSourceType type1 = o1.getType(); + OriginalSourceType type2 = o2.getType(); + if (type1 == null){ + if (type2!=null){ + return -1; } } else if (type2 == null){ - result = 1; + return 1; } else if(type1.equals(type2)){ - result = 0; + //continue with citation compare } else if (type1.equals(OriginalSourceType.PrimaryTaxonomicSource)){ - result = 1; + return 1; } else if (type2.equals(OriginalSourceType.PrimaryTaxonomicSource)){ - result = -1; + return -1; } else if (type1.equals(OriginalSourceType.PrimaryMediaSource)){ - result = 1; + return 1; } else if (type2.equals(OriginalSourceType.PrimaryMediaSource)){ - result = -1; + return -1; } + int result; + //sort by citation title cache if types are equal - if (result == 0){ - if(citation1!=null && citation2!=null){ - result = citation1.getTitleCache().compareTo(citation2.getTitleCache()); + Reference citation1 = o1.getCitation(); + Reference citation2 = o2.getCitation(); + if(citation1!=null && citation2!=null){ + result = citation1.getTitleCache().compareTo(citation2.getTitleCache()); + if (result != 0){ + return result; } + } - if(o2.getCreated()!=null && o1.getCreated()!=null){ - result = o1.getCreated().compareTo(o2.getCreated()); - }else if (o1.getCreated() == null ){ - if (o2.getCreated() == null){ - result = 0; - }else{ - return -1; - } - }else if (o2.getCreated() == null){ - return 1; + //sort by created + if(o2.getCreated()!=null && o1.getCreated()!=null){ + result = o1.getCreated().compareTo(o2.getCreated()); + if (result != 0){ + return result; } - if (result == 0){ - //default fallback - return o1.getUuid().compareTo(o2.getUuid()); + }else if (o1.getCreated() == null){ + if (o2.getCreated() != null){ + return -1; } + }else if (o2.getCreated() == null){ + return 1; } - return result; - + //default fallback + return o1.getUuid().compareTo(o2.getUuid()); } - } + }