4 package eu
.etaxonomy
.taxeditor
.editor
.name
.container
;
6 import java
.util
.ArrayList
;
7 import java
.util
.HashSet
;
11 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
12 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
13 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
14 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
16 import eu
.etaxonomy
.taxeditor
.editor
.name
.TaxonNameEditor
;
19 * <p>ContainerFactory class.</p>
24 public class ContainerFactory
{
27 * @param taxonNameEditor
29 public static void createOrUpdateAcceptedTaxonsHomotypicGroup(
30 TaxonNameEditor taxonNameEditor
) {
32 if(taxonNameEditor
.getAcceptedGroup() == null){
33 taxonNameEditor
.setAcceptedGroup(new AcceptedGroup(taxonNameEditor
, taxonNameEditor
.getTaxon().getHomotypicGroup()));
36 taxonNameEditor
.getAcceptedGroup().redraw(taxonNameEditor
.getTaxon().getHomotypicGroup());
42 * @param taxonNameEditor
44 public static void createOrUpdateHeterotypicSynonymyGroups(
45 TaxonNameEditor taxonNameEditor
) {
46 List
<HomotypicalSynonymGroup
> retainedGroups
= new ArrayList
<HomotypicalSynonymGroup
>();
48 List
<HomotypicalSynonymGroup
> heterotypicSynonymGroups
= taxonNameEditor
.getHeterotypicSynonymGroups();
50 if (heterotypicSynonymGroups
!= null) {
52 for(HomotypicalSynonymGroup group
: heterotypicSynonymGroups
){
53 retainedGroups
.add(group
);
57 for(HomotypicalGroup homotypicalGroup
: taxonNameEditor
.getTaxon().getHeterotypicSynonymyGroups()){
58 HomotypicalSynonymGroup group
= createOrUpdateHeterotypicSynonymyGroup(taxonNameEditor
, homotypicalGroup
);
60 retainedGroups
.remove(group
);
63 for(HomotypicalSynonymGroup retainedGroup
: retainedGroups
){
64 taxonNameEditor
.removeGroup(retainedGroup
);
69 public static HomotypicalSynonymGroup
createOrUpdateHeterotypicSynonymyGroup(
70 TaxonNameEditor taxonNameEditor
, HomotypicalGroup homotypicalGroup
){
71 HomotypicalSynonymGroup group
= null;
72 if(taxonNameEditor
.getHomotypicalGroupContainer(homotypicalGroup
) == null){
73 group
= new HomotypicalSynonymGroup(taxonNameEditor
, homotypicalGroup
);
74 taxonNameEditor
.addHeterotypicSynonymGroup(group
);
75 if(taxonNameEditor
.getMisappliedGroup() != null){
76 group
.getControl().moveAbove(taxonNameEditor
.getMisappliedGroup().getControl());
80 group
= taxonNameEditor
.getHomotypicalGroupContainer(homotypicalGroup
);
81 group
.redraw(homotypicalGroup
);
88 * @param taxonNameEditor
90 public static void createOrUpdateMisapplicationsGroup(
91 TaxonNameEditor taxonNameEditor
) {
92 MisappliedGroup group
= taxonNameEditor
.getMisappliedGroup();
93 Taxon taxon
= HibernateProxyHelper
.deproxy(taxonNameEditor
.getTaxon(), Taxon
.class);
94 if(taxon
.getMisappliedNames().isEmpty()){
95 taxonNameEditor
.removeGroup(group
);
96 taxonNameEditor
.setMisapplicationsGroup(null);
99 taxonNameEditor
.setMisapplicationsGroup(new MisappliedGroup(taxonNameEditor
));