4 package eu
.etaxonomy
.taxeditor
.editor
.name
.container
;
6 import java
.util
.ArrayList
;
7 import java
.util
.HashSet
;
11 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
12 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
13 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
14 import eu
.etaxonomy
.taxeditor
.editor
.name
.TaxonNameEditor
;
17 * <p>ContainerFactory class.</p>
22 public class ContainerFactory
{
25 * @param taxonNameEditor
27 public static void createOrUpdateAcceptedTaxonsHomotypicGroup(
28 TaxonNameEditor taxonNameEditor
) {
30 if(taxonNameEditor
.getAcceptedGroup() == null){
31 taxonNameEditor
.setAcceptedGroup(new AcceptedGroup(taxonNameEditor
, taxonNameEditor
.getTaxon().getHomotypicGroup()));
34 taxonNameEditor
.getAcceptedGroup().redraw(taxonNameEditor
.getTaxon().getHomotypicGroup());
40 * @param taxonNameEditor
42 public static void createOrUpdateHeterotypicSynonymyGroups(
43 TaxonNameEditor taxonNameEditor
) {
44 List
<HomotypicalSynonymGroup
> retainedGroups
= new ArrayList
<HomotypicalSynonymGroup
>();
46 for(HomotypicalSynonymGroup group
: taxonNameEditor
.getHeterotypicSynonymGroups()){
47 retainedGroups
.add(group
);
50 for(HomotypicalGroup homotypicalGroup
: taxonNameEditor
.getTaxon().getHeterotypicSynonymyGroups()){
51 HomotypicalSynonymGroup group
= createOrUpdateHeterotypicSynonymyGroup(taxonNameEditor
, homotypicalGroup
);
53 retainedGroups
.remove(group
);
56 for(HomotypicalSynonymGroup retainedGroup
: retainedGroups
){
57 taxonNameEditor
.removeGroup(retainedGroup
);
62 public static HomotypicalSynonymGroup
createOrUpdateHeterotypicSynonymyGroup(
63 TaxonNameEditor taxonNameEditor
, HomotypicalGroup homotypicalGroup
){
64 HomotypicalSynonymGroup group
= null;
65 if(taxonNameEditor
.getHomotypicalGroupContainer(homotypicalGroup
) == null){
66 group
= new HomotypicalSynonymGroup(taxonNameEditor
, homotypicalGroup
);
67 taxonNameEditor
.addHeterotypicSynonymGroup(group
);
68 if(taxonNameEditor
.getMisappliedGroup() != null){
69 group
.getControl().moveAbove(taxonNameEditor
.getMisappliedGroup().getControl());
73 group
= taxonNameEditor
.getHomotypicalGroupContainer(homotypicalGroup
);
74 group
.redraw(homotypicalGroup
);
81 * @param taxonNameEditor
83 public static void createOrUpdateMisapplicationsGroup(
84 TaxonNameEditor taxonNameEditor
) {
85 MisappliedGroup group
= taxonNameEditor
.getMisappliedGroup();
86 if(taxonNameEditor
.getTaxon().getMisappliedNames().isEmpty()){
87 taxonNameEditor
.removeGroup(group
);
88 taxonNameEditor
.setMisapplicationsGroup(null);
91 taxonNameEditor
.setMisapplicationsGroup(new MisappliedGroup(taxonNameEditor
));
100 * @param taxonNameEditor
102 public static void createOrUpdateConceptGroup(
103 TaxonNameEditor taxonNameEditor
) {
104 Set
<TaxonRelationship
> filteredTaxonRelations
= new HashSet
<TaxonRelationship
>();
106 for (TaxonRelationship relationship
: taxonNameEditor
.getTaxon().getTaxonRelations()) {
107 if (! relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR()) ||
108 relationship
.getType().equals(TaxonRelationshipType
.TAXONOMICALLY_INCLUDED_IN())) {
109 filteredTaxonRelations
.add(relationship
);
113 if(! filteredTaxonRelations
.isEmpty()){
114 taxonNameEditor
.setConceptGroup(new ConceptGroup(taxonNameEditor
));