Project

General

Profile

« Previous | Next » 

Revision bdd1bcf5

Added by Andreas Müller about 6 years ago

ref #5974 Remove synonym relationships (rename synRelType to synRel and others)

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.java
19 19
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
20 20
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
21 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
22
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
22
import eu.etaxonomy.cdm.model.taxon.SynonymType;
23 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24 24
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
25 25
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
......
92 92
				acc.removeSynonym(synonym);
93 93
			}
94 94
			
95
			SynonymRelationshipType type = SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF();
95
			SynonymType type = SynonymType.HETEROTYPIC_SYNONYM_OF();
96 96
			if(newHomotypicalGroup.getTypifiedNames().contains(element.getName())){
97
				type = SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF();
97
				type = SynonymType.HOMOTYPIC_SYNONYM_OF();
98 98
			}
99 99

  
100 100
			element.addSynonym(synonym, type);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java
19 19

  
20 20
import eu.etaxonomy.cdm.api.service.ITaxonService;
21 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
22
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
22
import eu.etaxonomy.cdm.model.taxon.SynonymType;
23 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24 24
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
25 25
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
......
38 38

  
39 39
	private final Synonym synonym;
40 40
	private Taxon misapplication;
41
	private Set<SynonymRelationshipType> synonymTypes;
41
	private Set<SynonymType> synonymTypes;
42 42

  
43 43
	/**
44 44
	 * <p>Constructor for ChangeSynonymToMisapplicationOperation.</p>
......
69 69
		CdmStore.getService(ITaxonService.class).saveOrUpdate(misapplication);
70 70
		monitor.worked(20);
71 71

  
72
		// store synonymRelationshipType for later undo operations
72
		// store SynonymType for later undo operations
73 73
		synonymTypes = synonym.getRelationType(element);
74 74

  
75 75
		// remove synonym from taxon
......
113 113
		element.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
114 114

  
115 115
		// add synonym to taxon
116
		for (SynonymRelationshipType synonymType : synonymTypes){
116
		for (SynonymType synonymType : synonymTypes){
117 117
			element.addSynonym(synonym, synonymType);
118 118
		}
119 119

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperation.java
21 21
import eu.etaxonomy.cdm.api.service.DeleteResult;
22 22
import eu.etaxonomy.cdm.api.service.ITaxonService;
23 23
import eu.etaxonomy.cdm.model.taxon.Synonym;
24
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
24
import eu.etaxonomy.cdm.model.taxon.SynonymType;
25 25
import eu.etaxonomy.cdm.model.taxon.Taxon;
26 26
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
27 27
import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
......
38 38
public class DeleteSynonymOperation extends AbstractPostTaxonOperation {
39 39

  
40 40
	private final Synonym synonym;
41
	private SynonymRelationshipType synonymType;
41
	private SynonymType synonymType;
42 42

  
43 43
	/**
44 44
	 * <p>Constructor for DeleteSynonymOperation.</p>
......
60 60
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
61 61
			throws ExecutionException {
62 62

  
63
		// Store synonymRelationshipType for later undo operations
63
		// Store SynonymType for later undo operations
64 64
		synonymType = synonym.getType();
65 65
		monitor.worked(20);
66 66

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperation.java
19 19
import eu.etaxonomy.cdm.api.service.ITaxonService;
20 20
import eu.etaxonomy.cdm.api.service.UpdateResult;
21 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
22
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
22
import eu.etaxonomy.cdm.model.taxon.SynonymType;
23 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24 24
import eu.etaxonomy.taxeditor.model.MessagingUtils;
25 25
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
......
32 32
 *
33 33
 * @author n.hoffmann
34 34
 * @created 23.04.2009
35
 * @version 1.0
36 35
 */
37 36
public class SwapSynonymAndAcceptedOperation extends AbstractPostTaxonOperation {
38 37

  
39 38
	private final Synonym synonym;
40 39
	// TODO store the old relationship for undo reasons
41
	private SynonymRelationshipType synonymRelationshipType;
40
	private SynonymType synonymType;
42 41

  
43 42
	/**
44 43
	 * <p>Constructor for SwapSynonymAndAcceptedOperation.</p>
......
57 56
		this.synonym = synonym;
58 57
	}
59 58

  
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
62
	 */
63 59
	/** {@inheritDoc} */
64 60
	@Override
65 61
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
......
74 70
		return postExecute(element);
75 71
	}
76 72

  
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
79
	 */
80 73
	/** {@inheritDoc} */
81 74
	@Override
82 75
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
......
85 78
		return execute(monitor, info);
86 79
	}
87 80

  
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90
	 */
91 81
	/** {@inheritDoc} */
92 82
	@Override
93 83
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToConceptOperationTest.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.editor.name.operation;
12 12

  
13
import junit.framework.Assert;
14

  
15 13
import org.apache.log4j.Logger;
16 14
import org.eclipse.core.commands.ExecutionException;
15
import org.junit.Assert;
17 16
import org.junit.BeforeClass;
18 17
import org.junit.Test;
19 18

  
20 19
import eu.etaxonomy.cdm.model.common.ICdmBase;
21 20
import eu.etaxonomy.cdm.model.name.NonViralName;
22 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
23
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
22
import eu.etaxonomy.cdm.model.taxon.SynonymType;
24 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
25 24
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
26 25
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
......
51 50
		synonym = Synonym.NewInstance(NonViralName.NewInstance(null), null);
52 51
		taxonRelationshipType = TaxonRelationshipType.CONTRADICTION();
53 52
		
54
		taxon.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF());
53
		taxon.addSynonym(synonym, SynonymType.SYNONYM_OF());
55 54
		
56 55
		operation = new ChangeSynonymToConceptOperation("Change Synonym To Concept", null, taxon, synonym, taxonRelationshipType, postOperation);
57 56
	}
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperationTest.java
19 19
import eu.etaxonomy.cdm.model.common.ICdmBase;
20 20
import eu.etaxonomy.cdm.model.name.NonViralName;
21 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
22
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
22
import eu.etaxonomy.cdm.model.taxon.SynonymType;
23 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToMisapplicationOperation;
25 24
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
26 25
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
27 26

  
......
40 39

  
41 40
	private static AbstractPostOperation operation;
42 41

  
43
	private static SynonymRelationshipType synonymRelationshipType;
42
	private static SynonymType synonymType;
44 43
	
45 44
	/**
46 45
	 * @throws java.lang.Exception
......
49 48
	public static void setUpBeforeClass() throws Exception {
50 49
		taxon = Taxon.NewInstance(null, null);
51 50
		synonym = Synonym.NewInstance(NonViralName.NewInstance(null), null);
52
		synonymRelationshipType = SynonymRelationshipType.SYNONYM_OF();
53
		taxon.addSynonym(synonym, synonymRelationshipType);
51
		synonymType = SynonymType.SYNONYM_OF();
52
		taxon.addSynonym(synonym, synonymType);
54 53
		
55 54
		operation = new ChangeSynonymToMisapplicationOperation("Change Synonym To Misapplication", null, taxon, synonym, postOperation);
56 55
	}
......
79 78
		Assert.assertTrue("Taxon should have synonyms.", taxon.getSynonyms().size() > 0);
80 79
		Assert.assertTrue("Taxon should not have taxon relationship.", taxon.getTaxonRelations().size() == 0);
81 80
		Assert.assertEquals("Not the expected synonym.", synonym, taxon.getSynonyms().toArray(new Synonym[0])[0]);
82
		Assert.assertEquals("SynonymRelationshipType is not the expected.", synonymRelationshipType, taxon.getSynonyms().iterator().next().getType());
81
		Assert.assertEquals("SynonymRelationshipType is not the expected.", synonymType, taxon.getSynonyms().iterator().next().getType());
83 82
	}
84 83
	
85 84
	/**
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExisitingHomotypicalGroupOperationTest.java
17 17

  
18 18
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
19 19
import eu.etaxonomy.cdm.model.name.NonViralName;
20
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
20
import eu.etaxonomy.cdm.model.taxon.SynonymType;
21 21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22 22
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
23 23

  
......
81 81

  
82 82
		Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
83 83
		Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0);
84
		Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonyms().iterator().next().getType());
84
		Assert.assertEquals("Synonym relationship should be heterotypic", SynonymType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonyms().iterator().next().getType());
85 85
	}
86 86

  
87 87

  
......
139 139

  
140 140
		Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
141 141
		Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0);
142
		Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonyms().iterator().next().getType());
142
		Assert.assertEquals("Synonym relationship should be heterotypic", SynonymType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonyms().iterator().next().getType());
143 143

  
144 144
	}
145 145
}
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperationTest.java
17 17
import org.junit.Test;
18 18

  
19 19
import eu.etaxonomy.cdm.model.taxon.Synonym;
20
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
20
import eu.etaxonomy.cdm.model.taxon.SynonymType;
21 21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
23 22
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
24 23

  
25 24
/**
26 25
 * @author n.hoffmann
27 26
 * @created 08.04.2009
28
 * @version 1.0
29 27
 */
30 28
public class DeleteSynonymOperationTest extends AbstractTaxeditorOperationTestBase{
29
	@SuppressWarnings("unused")
31 30
	private static final Logger logger = Logger
32 31
			.getLogger(DeleteSynonymOperationTest.class);
33 32

  
34 33
	private static Synonym synonym;
35 34

  
36
	private static SynonymRelationshipType synonymRelationshipType;
35
	private static SynonymType synonymRelationshipType;
37 36
	
38 37
	/**
39 38
	 * @throws java.lang.Exception
......
42 41
	public static void setUpBeforeClass() throws Exception {
43 42
		taxon = Taxon.NewInstance(null, null);
44 43
		synonym = Synonym.NewInstance(null, null);
45
		synonymRelationshipType = SynonymRelationshipType.SYNONYM_OF();
44
		synonymRelationshipType = SynonymType.SYNONYM_OF();
46 45
		
47 46
		taxon.addSynonym(synonym, synonymRelationshipType);
48 47
		
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperationTest.java
21 21
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
22 22
import eu.etaxonomy.cdm.model.name.NonViralName;
23 23
import eu.etaxonomy.cdm.model.taxon.Synonym;
24
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
24
import eu.etaxonomy.cdm.model.taxon.SynonymType;
25 25
import eu.etaxonomy.cdm.model.taxon.Taxon;
26 26
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
27 27
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
......
30 30
/**
31 31
 * @author n.hoffmann
32 32
 * @created 02.04.2009
33
 * @version 1.0
34 33
 */
35 34
public class SwapSynonymAndAcceptedOperationTest extends AbstractTaxeditorOperationTestBase {
36 35
	private static final Logger logger = Logger
......
96 95
//		oldTaxon.addS .addHeterotypicSynonym(oldHeterotypicSynonym, null, null);
97 96
		heteroypicalGroup = HomotypicalGroup.NewInstance();
98 97
		heteroypicalGroup.addTypifiedName(oldHeterotypicSynonym.getName());
99
		taxon.addSynonym(oldHeterotypicSynonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
98
		taxon.addSynonym(oldHeterotypicSynonym, SynonymType.HETEROTYPIC_SYNONYM_OF());
100 99

  
101 100
		// Create a misapplication
102 101
		misapplication = Taxon.NewInstance(NonViralName.NewInstance(null), null);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/IterableSynonymyList.java
66 66
				for (Synonym synonym : homotypicSynonyms) {
67 67

  
68 68
					// Make sure synonym belongs to the taxon
69
					if (synonym.getAcceptedTaxa().contains(taxon)) {
69
					if (synonym.getAcceptedTaxon() != null && synonym.getAcceptedTaxon().equals(taxon)) {
70 70
						synonymyList.add(synonym);
71 71
					}
72 72
				}
......
82 82
					for (Synonym synonym : heterotypicSynonyms) {
83 83

  
84 84
						// Make sure synonym belongs to the taxon
85
						if (synonym.getAcceptedTaxa().contains(taxon)) {
85
						if (synonym.getAcceptedTaxon() != null && synonym.getAcceptedTaxon().equals(taxon)) {
86 86
							synonymyList.add(synonym);
87 87
						}
88 88
					}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java
64 64
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
65 65
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
66 66
import eu.etaxonomy.cdm.model.taxon.Classification;
67
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
68 67
import eu.etaxonomy.cdm.model.taxon.Taxon;
69 68
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
70 69
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
......
377 376
		RelationshipTermBase<?> type = rel.getType();
378 377
		IdentifiableEntity<?> from;
379 378
		IdentifiableEntity<?> to;
380
		if (rel.isInstanceOf(SynonymRelationship.class)){
381
			from = ((SynonymRelationship)rel).getSynonym();
382
			to = ((SynonymRelationship)rel).getAcceptedTaxon();
383
		}else if (rel.isInstanceOf(NameRelationship.class)){
379
		if (rel.isInstanceOf(NameRelationship.class)){
384 380
			from = ((NameRelationship)rel).getFromName();
385 381
			to = ((NameRelationship)rel).getToName();
386 382
		}else if (rel.isInstanceOf(HybridRelationship.class)){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
101 101
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
102 102
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
103 103
import eu.etaxonomy.cdm.model.reference.Reference;
104
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
105 104
import eu.etaxonomy.cdm.model.taxon.Taxon;
106 105
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
107 106
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
......
206 205
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueElement;
207 206
import eu.etaxonomy.taxeditor.ui.section.name.ProtologueSection;
208 207
import eu.etaxonomy.taxeditor.ui.section.name.SpecimenTypeDesignationElement;
209
import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailElement;
210
import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailSection;
211 208
import eu.etaxonomy.taxeditor.ui.section.name.TypeDesignationSection;
212 209
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectingAreasDetailSection;
213 210
import eu.etaxonomy.taxeditor.ui.section.occurrence.CollectionDetailElement;
......
2368 2365
        return section;
2369 2366
    }
2370 2367

  
2371
    public SynonymRelationshipDetailSection createSynonymRelationshipDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2372
        SynonymRelationshipDetailSection section = new SynonymRelationshipDetailSection(this, conversation, parentElement, style);
2373
        addAndAdaptSection(parentElement, section);
2374
        return section;
2375
    }
2376

  
2377 2368
    public ProtologueSection createProtologueSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2378 2369
        ProtologueSection section = new ProtologueSection(this, conversation, parentElement, style);
2379 2370
        addAndAdaptSection(parentElement, section);
......
2591 2582
        } else if (entity instanceof ImageFile) {
2592 2583
            element = new ImageFileElement(this, parentElement, (ImageFile) entity, removeListener, style);
2593 2584
        } else if (entity instanceof MediaRepresentationPart) {
2594
            element = new MediaRepresentationPartElement(this, parentElement, (MediaRepresentationPart) entity,
2585
            element = new MediaRepresentationPartElement<>(this, parentElement, (MediaRepresentationPart) entity,
2595 2586
                    removeListener, style);
2596 2587
        } else if (entity instanceof NomenclaturalStatus) {
2597 2588
            element = new NomenclaturalStatusElement(this, parentElement, (NomenclaturalStatus) entity, removeListener,
......
2641 2632
        } else if (entity instanceof NameRelationship) {
2642 2633
            element = new NameRelationshipDetailElement(this, parentElement, (NameRelationship) entity, removeListener,
2643 2634
                    style);
2644
        } else if (entity instanceof SynonymRelationship) {
2645
            element = new SynonymRelationshipDetailElement(this, parentElement, (SynonymRelationship) entity, removeListener,
2646
                    style);
2647 2635
        } else if (entity instanceof SpecimenTypeDesignation) {
2648 2636
            if(parentElement instanceof DerivedUnitTypeDesignationSection){
2649 2637
                element = new DerivedUnitTypeDesignationElement(this, parentElement, (SpecimenTypeDesignation) entity,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java
41 41
 *
42 42
 * @author n.hoffmann
43 43
 * @created Nov 16, 2009
44
 * @version 1.0
45 44
 */
46 45
public abstract class AbstractEntityCollectionElement<ENTITY> extends
47 46
		AbstractCdmFormElement implements IEntityElement<ENTITY>,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SynonymRelationshipDetailElement.java
1
// $Id$
2
/**
3
* Copyright (C) 2014 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.section.name;
11

  
12
import org.eclipse.swt.events.SelectionListener;
13
import org.eclipse.swt.graphics.Color;
14

  
15
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
16
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
17
import eu.etaxonomy.taxeditor.model.MessagingUtils;
18
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
22
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.element.LabelElement;
24
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
25
import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
26
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
27

  
28
/**
29
 * @author pplitzner
30
 * @date 28.01.2014
31
 *
32
 */
33
public class SynonymRelationshipDetailElement extends AbstractReferencedEntityElement<SynonymRelationship>{
34

  
35
    private TextWithLabelElement text_ruleConsidered;
36
    private LabelElement label;
37
    private EntitySelectionElement selection_toName;
38
    private TermComboElement<SynonymRelationshipType> combo_relationshipType;
39
    private CheckboxElement checkProParte;
40
    private CheckboxElement checkPartial;
41

  
42
    /**
43
     * <p>Constructor for NameRelationshipDetailElement.</p>
44
     *
45
     * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
46
     * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
47
     * @param entity a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
48
     * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
49
     * @param style a int.
50
     */
51
    public SynonymRelationshipDetailElement(CdmFormFactory cdmFormFactory,
52
            AbstractFormSection formElement,
53
            SynonymRelationship entity, SelectionListener removeListener, int style) {
54
        super(cdmFormFactory, formElement, entity, removeListener, style);
55
    }
56

  
57
    /* (non-Javadoc)
58
     * @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#createControls(org.eclipse.swt.widgets.Composite, int)
59
     */
60
    /** {@inheritDoc} */
61
    @Override
62
    public void createControls(ICdmFormElement element, int style) {
63
        label = formFactory.createLabel(element, null);
64
        checkProParte = formFactory.createCheckbox(element, "Pro Parte Synonym", null, style);
65
        checkPartial= formFactory.createCheckbox(element, "Partial Synonym", null, style);
66
        super.createControls(element, style);
67
    }
68

  
69
    /** {@inheritDoc} */
70
    @Override
71
    public void setEntity(SynonymRelationship entity) {
72
        String text = entity.getSynonym().getTitleCache() + " is " + entity.getType().getLabel() + " " + entity.getAcceptedTaxon().getTitleCache();
73

  
74
        label.setText(text);
75

  
76
        checkPartial.setSelection(entity.isPartial());
77
        checkProParte.setSelection(entity.isProParte());
78

  
79
        super.setEntity(entity);
80
    }
81

  
82
    /** {@inheritDoc} */
83
    @Override
84
    public void handleEvent(Object eventSource) {
85
        if(eventSource == combo_relationshipType){
86
            getEntity().setType(combo_relationshipType.getSelection());
87
        }
88
        else if(eventSource == selection_toName){
89
            MessagingUtils.error(getClass(), "No API call available.", null);
90
        }
91
        else if(eventSource == checkPartial){
92
            getEntity().setPartial(checkPartial.getSelection());
93
        }
94
        else if(eventSource == checkProParte){
95
            getEntity().setProParte(checkProParte.getSelection());
96
        }
97
        else if(eventSource == selection_reference){
98
            getEntity().setCitation(selection_reference.getSelection());
99
        }
100
        else if(eventSource == text_referenceDetail){
101
            getEntity().setCitationMicroReference(text_referenceDetail.getText());
102
        }
103
    }
104

  
105
    /** {@inheritDoc} */
106
    @Override
107
    public void setBackground(Color color) {
108
        if(label != null) {
109
            label.setBackground(color);
110
        }
111
        super.setBackground(color);
112
    }
113

  
114
}
1
//// $Id$
2
///**
3
//* Copyright (C) 2014 EDIT
4
//* European Distributed Institute of Taxonomy
5
//* http://www.e-taxonomy.eu
6
//*
7
//* The contents of this file are subject to the Mozilla Public License Version 1.1
8
//* See LICENSE.TXT at the top of this package for the full license terms.
9
//*/
10
//package eu.etaxonomy.taxeditor.ui.section.name;
11
//
12
//import org.eclipse.swt.events.SelectionListener;
13
//import org.eclipse.swt.graphics.Color;
14
//
15
//import eu.etaxonomy.cdm.model.name.NameRelationship;
16
//import eu.etaxonomy.cdm.model.taxon.Synonym;
17
//import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
18
//import eu.etaxonomy.taxeditor.model.MessagingUtils;
19
//import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
20
//import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
21
//import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22
//import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
23
//import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24
//import eu.etaxonomy.taxeditor.ui.element.LabelElement;
25
//import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
26
//import eu.etaxonomy.taxeditor.ui.section.supplemental.AbstractReferencedEntityElement;
27
//import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
28
//
29
///**
30
// * @author pplitzner
31
// * @date 28.01.2014
32
// *
33
// */
34
//public class SynonymRelationshipDetailElement extends AbstractReferencedEntityElement<Synonym>{
35
//
36
//    private TextWithLabelElement text_ruleConsidered;
37
//    private LabelElement label;
38
//    private EntitySelectionElement selection_toName;
39
//    private TermComboElement<SynonymRelationshipType> combo_relationshipType;
40
//    private CheckboxElement checkProParte;
41
//    private CheckboxElement checkPartial;
42
//
43
//    /**
44
//     * <p>Constructor for NameRelationshipDetailElement.</p>
45
//     *
46
//     * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
47
//     * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
48
//     * @param entity a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
49
//     * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
50
//     * @param style a int.
51
//     */
52
//    public SynonymRelationshipDetailElement(CdmFormFactory cdmFormFactory,
53
//            AbstractFormSection formElement,
54
//            Synonym entity, SelectionListener removeListener, int style) {
55
//        super(cdmFormFactory, formElement, entity, removeListener, style);
56
//    }
57
//
58
//    /* (non-Javadoc)
59
//     * @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#createControls(org.eclipse.swt.widgets.Composite, int)
60
//     */
61
//    /** {@inheritDoc} */
62
//    @Override
63
//    public void createControls(ICdmFormElement element, int style) {
64
//        label = formFactory.createLabel(element, null);
65
//        checkProParte = formFactory.createCheckbox(element, "Pro Parte Synonym", null, style);
66
//        checkPartial= formFactory.createCheckbox(element, "Partial Synonym", null, style);
67
//        super.createControls(element, style);
68
//    }
69
//
70
//    /** {@inheritDoc} */
71
//    @Override
72
//    public void setEntity(Synonym entity) {
73
//        String text = entity.getTitleCache() + " is " + entity.getType().getLabel() + " " + entity.getAcceptedTaxon().getTitleCache();
74
//
75
//        label.setText(text);
76
//
77
//        checkPartial.setSelection(entity.isPartial());
78
//        checkProParte.setSelection(entity.isProParte());
79
//
80
//        super.setEntity(entity);
81
//    }
82
//
83
//    /** {@inheritDoc} */
84
//    @Override
85
//    public void handleEvent(Object eventSource) {
86
//        if(eventSource == combo_relationshipType){
87
//            getEntity().setType(combo_relationshipType.getSelection());
88
//        }
89
//        else if(eventSource == selection_toName){
90
//            MessagingUtils.error(getClass(), "No API call available.", null);
91
//        }
92
//        else if(eventSource == checkPartial){
93
//            getEntity().setPartial(checkPartial.getSelection());
94
//        }
95
//        else if(eventSource == checkProParte){
96
//            getEntity().setProParte(checkProParte.getSelection());
97
//        }
98
//        else if(eventSource == selection_reference){
99
//            getEntity().setSec(selection_reference.getSelection());
100
//        }
101
//        else if(eventSource == text_referenceDetail){
102
//            getEntity().setSecMicroReference(text_referenceDetail.getText());
103
//        }
104
//    }
105
//
106
//    /** {@inheritDoc} */
107
//    @Override
108
//    public void setBackground(Color color) {
109
//        if(label != null) {
110
//            label.setBackground(color);
111
//        }
112
//        super.setBackground(color);
113
//    }
114
//
115
//}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SynonymRelationshipDetailSection.java
1
// $Id$
2
/**
3
* Copyright (C) 2014 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.section.name;
11

  
12
import java.util.Collection;
13

  
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.jface.wizard.WizardDialog;
16

  
17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18
import eu.etaxonomy.cdm.model.taxon.Synonym;
19
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
20
import eu.etaxonomy.taxeditor.model.AbstractUtility;
21
import eu.etaxonomy.taxeditor.store.StoreUtil;
22
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
23
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
25

  
26
/**
27
 * @author pplitzner
28
 * @date 27.01.2014
29
 *
30
 */
31
public class SynonymRelationshipDetailSection extends AbstractEntityCollectionSection<Synonym, SynonymRelationship> {
32

  
33
    /**
34
     * <p>Constructor for NameRelationshipDetailSection.</p>
35
     *
36
     * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
37
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
38
     * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
39
     * @param style a int.
40
     */
41
    public SynonymRelationshipDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
42
            ICdmFormElement parentElement, int style) {
43
        super(formFactory, conversation, parentElement, "Synonym Relationship", style);
44
    }
45

  
46
    /** {@inheritDoc} */
47
    @Override
48
    public void addElement(SynonymRelationship element) {
49
        // nothing
50
    }
51

  
52
    /** {@inheritDoc} */
53
    @Override
54
    public SynonymRelationship createNewElement() {
55

  
56
        SynonymRelationshipWizard wizard = new SynonymRelationshipWizard(this);
57
        WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
58
        int status = dialog.open();
59

  
60
        if(status == IStatus.OK) {
61
            return wizard.getSynonymRelationship();
62
        }
63

  
64
        return null;
65
    }
66

  
67
    /** {@inheritDoc} */
68
    @Override
69
    public Collection<SynonymRelationship> getCollection(Synonym entity) {
70
        Collection<SynonymRelationship> allSynonymRelationships = entity.getSynonymRelations();
71
        return allSynonymRelationships;
72
    }
73

  
74
    /** {@inheritDoc} */
75
    @Override
76
    public String getEmptyString() {
77
        return "No synonym relationships yet.";
78
    }
79

  
80
    /** {@inheritDoc} */
81
    @Override
82
    protected String getTooltipString() {
83
        return "Add a new synonym relationship from this name.";
84
    }
85

  
86
    /** {@inheritDoc} */
87
    @Override
88
    public void removeElement(SynonymRelationship element) {
89
        getEntity().removeSynonymRelation(element);
90
    }
91

  
92
}
1
//// $Id$
2
///**
3
//* Copyright (C) 2014 EDIT
4
//* European Distributed Institute of Taxonomy
5
//* http://www.e-taxonomy.eu
6
//*
7
//* The contents of this file are subject to the Mozilla Public License Version 1.1
8
//* See LICENSE.TXT at the top of this package for the full license terms.
9
//*/
10
//package eu.etaxonomy.taxeditor.ui.section.name;
11
//
12
//import java.util.Collection;
13
//
14
//import org.eclipse.core.runtime.IStatus;
15
//import org.eclipse.jface.wizard.WizardDialog;
16
//
17
//import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18
//import eu.etaxonomy.cdm.model.taxon.Synonym;
19
//import eu.etaxonomy.taxeditor.store.StoreUtil;
20
//import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
//import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
//import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
23
//
24
///**
25
// * @author pplitzner
26
// * @date 27.01.2014
27
// *
28
// */
29
//public class SynonymRelationshipDetailSection extends AbstractEntityCollectionSection<Synonym, SynonymRelationship> {
30
//
31
//    /**
32
//     * <p>Constructor for NameRelationshipDetailSection.</p>
33
//     *
34
//     * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
35
//     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
36
//     * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
37
//     * @param style a int.
38
//     */
39
//    public SynonymRelationshipDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
40
//            ICdmFormElement parentElement, int style) {
41
//        super(formFactory, conversation, parentElement, "Synonym Relationship", style);
42
//    }
43
//
44
//    /** {@inheritDoc} */
45
//    @Override
46
//    public void addElement(Synonym element) {
47
//        // nothing
48
//    }
49
//
50
//    /** {@inheritDoc} */
51
//    @Override
52
//    public SynonymRelationship createNewElement() {
53
//
54
//        SynonymRelationshipWizard wizard = new SynonymRelationshipWizard(this);
55
//        WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
56
//        int status = dialog.open();
57
//
58
//        if(status == IStatus.OK) {
59
//            return wizard.getSynonymRelationship();
60
//        }
61
//
62
//        return null;
63
//    }
64
//
65
//    /** {@inheritDoc} */
66
//    @Override
67
//    public Collection<SynonymRelationship> getCollection(Synonym entity) {
68
//        Collection<SynonymRelationship> allSynonymRelationships = entity.getSynonymRelations();
69
//        return allSynonymRelationships;
70
//    }
71
//
72
//    /** {@inheritDoc} */
73
//    @Override
74
//    public String getEmptyString() {
75
//        return "No synonym relationships yet.";
76
//    }
77
//
78
//    /** {@inheritDoc} */
79
//    @Override
80
//    protected String getTooltipString() {
81
//        return "Add a new synonym relationship from this name.";
82
//    }
83
//
84
//    /** {@inheritDoc} */
85
//    @Override
86
//    public void removeElement(SynonymRelationship element) {
87
//        getEntity().removeSynonymRelation(element);
88
//    }
89
//
90
//}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SynonymRelationshipWizard.java
1
// $Id$
2
/**
3
* Copyright (C) 2014 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.section.name;
11

  
12
import org.eclipse.jface.wizard.Wizard;
13

  
14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
16
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
17
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
18

  
19
/**
20
 * @author pplitzner
21
 * @date 27.01.2014
22
 *
23
 */
24
public class SynonymRelationshipWizard  extends Wizard implements IConversationEnabled{
25

  
26
    private static SynonymRelationshipDetailSection callingSection;
27

  
28
    /**
29
     * <p>Constructor for NameRelationshipWizard.</p>
30
     *
31
     * @param callingSection a {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection} object.
32
     */
33
    public SynonymRelationshipWizard(SynonymRelationshipDetailSection callingSection) {
34
        SynonymRelationshipWizard.callingSection = callingSection;
35
    }
36

  
37
    private SynonymRelationshipWizardPage page;
38

  
39
    /** {@inheritDoc} */
40
    @Override
41
    public void addPages() {
42
        page = new SynonymRelationshipWizardPage(callingSection);
43

  
44
        addPage(page);
45
    }
46

  
47
    /* (non-Javadoc)
48
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
49
     */
50
    /** {@inheritDoc} */
51
    @Override
52
    public boolean performFinish() {
53
        return page.isPageComplete();
54
    }
55

  
56

  
57

  
58
    /**
59
     * <p>getNameRelationship</p>
60
     *
61
     * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
62
     */
63
    public SynonymRelationship getSynonymRelationship() {
64
        return page.getSynonymRelationship();
65
    }
66

  
67
    /**
68
     * <p>getConversationHolder</p>
69
     *
70
     * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
71
     */
72
    @Override
73
    public ConversationHolder getConversationHolder() {
74
        return callingSection.getConversationHolder();
75
    }
76

  
77
    /** {@inheritDoc} */
78
    @Override
79
    public void update(CdmDataChangeMap changeEvents) {}
80
}
1
//// $Id$
2
///**
3
//* Copyright (C) 2014 EDIT
4
//* European Distributed Institute of Taxonomy
5
//* http://www.e-taxonomy.eu
6
//*
7
//* The contents of this file are subject to the Mozilla Public License Version 1.1
8
//* See LICENSE.TXT at the top of this package for the full license terms.
9
//*/
10
//package eu.etaxonomy.taxeditor.ui.section.name;
11
//
12
//import org.eclipse.jface.wizard.Wizard;
13
//
14
//import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
//import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
16
//import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
17
//
18
///**
19
// * @author pplitzner
20
// * @date 27.01.2014
21
// *
22
// */
23
//public class SynonymRelationshipWizard  extends Wizard implements IConversationEnabled{
24
//
25
//    private static SynonymRelationshipDetailSection callingSection;
26
//
27
//    /**
28
//     * <p>Constructor for NameRelationshipWizard.</p>
29
//     *
30
//     * @param callingSection a {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection} object.
31
//     */
32
//    public SynonymRelationshipWizard(SynonymRelationshipDetailSection callingSection) {
33
//        SynonymRelationshipWizard.callingSection = callingSection;
34
//    }
35
//
36
//    private SynonymRelationshipWizardPage page;
37
//
38
//    /** {@inheritDoc} */
39
//    @Override
40
//    public void addPages() {
41
//        page = new SynonymRelationshipWizardPage(callingSection);
42
//
43
//        addPage(page);
44
//    }
45
//
46
//    /* (non-Javadoc)
47
//     * @see org.eclipse.jface.wizard.Wizard#performFinish()
48
//     */
49
//    /** {@inheritDoc} */
50
//    @Override
51
//    public boolean performFinish() {
52
//        return page.isPageComplete();
53
//    }
54
//
55
//
56
//
57
//    /**
58
//     * <p>getNameRelationship</p>
59
//     *
60
//     * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
61
//     */
62
//    public SynonymRelationship getSynonymRelationship() {
63
//        return page.getSynonymRelationship();
64
//    }
65
//
66
//    /**
67
//     * <p>getConversationHolder</p>
68
//     *
69
//     * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
70
//     */
71
//    @Override
72
//    public ConversationHolder getConversationHolder() {
73
//        return callingSection.getConversationHolder();
74
//    }
75
//
76
//    /** {@inheritDoc} */
77
//    @Override
78
//    public void update(CdmDataChangeMap changeEvents) {}
79
//}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SynonymRelationshipWizardPage.java
1
// $Id$
2
/**
3
 * Copyright (C) 2014 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.taxeditor.ui.section.name;
11

  
12
import org.eclipse.jface.util.IPropertyChangeListener;
13
import org.eclipse.jface.util.PropertyChangeEvent;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.widgets.Composite;
16

  
17
import eu.etaxonomy.cdm.model.common.TermType;
18
import eu.etaxonomy.cdm.model.taxon.Synonym;
19
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
20
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
23
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
24
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
25
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
26

  
27
/**
28
 * @author pplitzner
29
 * @date 27.01.2014
30
 *
31
 */
32
public class SynonymRelationshipWizardPage extends AbstractEntityCollectionElementWizardPage implements IPropertyChangeListener {
33

  
34

  
35
    private EntitySelectionElement<Taxon> selection_relatedTo;
36

  
37
    private TermComboElement<SynonymRelationshipType> combo_relationshipType;
38

  
39
    private CheckboxElement checkboxProParte;
40

  
41
    private boolean isProParte;
42

  
43
    private CheckboxElement checkboxPartial;
44

  
45
    private boolean isPartial;
46

  
47
    private final Synonym entity;
48

  
49
    private SynonymRelationshipType type;
50

  
51
    private Taxon taxon;
52

  
53

  
54
    /**
55
     * <p>
56
     * Constructor for NameRelationshipWizardPage.
57
     * </p>
58
     *
59
     * @param callingSection
60
     *            a
61
     *            {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
62
     *            object.
63
     */
64
    protected SynonymRelationshipWizardPage(
65
            SynonymRelationshipDetailSection callingSection) {
66
        super("SynonymRelationshipWizardPage");
67
        setTitle("New Synonym Relationship");
68
        setDescription(callingSection.getEntity().getTitleCache());
69
        this.entity = callingSection.getEntity();
70
        this.formFactory = callingSection.getFormFactory();
71

  
72
        formFactory.addPropertyChangeListener(this);
73
    }
74

  
75
    /*
76
     * (non-Javadoc)
77
     *
78
     * @see
79
     * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
80
     * .Composite)
81
     */
82
    /** {@inheritDoc} */
83
    @Override
84
    public void createControl(Composite parent) {
85
        super.createControl(parent);
86

  
87
        combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.SynonymRelationshipType,
88
                rootElement, "Synonym Relationship Type", null, SWT.NULL);
89

  
90
        selection_relatedTo = formFactory
91
                .createSelectionElement(Taxon.class,
92
                        ((SynonymRelationshipWizard) getWizard())
93
                        .getConversationHolder(), rootElement,
94
                        "Related to", null, EntitySelectionElement.ALL,
95
                        SWT.NULL);
96

  
97
        checkboxProParte = formFactory.createCheckbox(rootElement, "Pro Parte Synonym", null, SWT.NULL);
98

  
99
        checkboxPartial = formFactory.createCheckbox(rootElement, "Partial Synonym", null, SWT.NULL);
100

  
101
    }
102

  
103
    /**
104
     * <p>
105
     * getNameRelationship
106
     * </p>
107
     *
108
     * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
109
     */
110
    public SynonymRelationship getSynonymRelationship() {
111
        SynonymRelationship synonymRelationship = taxon.addSynonym(entity, combo_relationshipType.getSelection());
112
        synonymRelationship.setPartial(isPartial);
113
        synonymRelationship.setProParte(isProParte);
114
        return synonymRelationship;
115
    }
116

  
117
    /** {@inheritDoc} */
118
    @Override
119
    public void propertyChange(PropertyChangeEvent event) {
120
        if (event == null) {
121
            return;
122
        }
123
        Object eventSource = event.getSource();
124
        if (eventSource == combo_relationshipType) {
125
            type = combo_relationshipType.getSelection();
126
        } else if (eventSource == selection_relatedTo) {
127
            taxon = selection_relatedTo.getEntity();
128
        } else if (eventSource == checkboxProParte) {
129
            isProParte = checkboxProParte.getSelection();
130
        } else if (eventSource == checkboxPartial) {
131
            isPartial = checkboxPartial.getSelection();
132
        }
133

  
134
        boolean complete = type != null && taxon != null;
135
        setPageComplete(complete);
136
    }
137

  
138
}
1
//// $Id$
2
///**
3
// * Copyright (C) 2014 EDIT
4
// * European Distributed Institute of Taxonomy
5
// * http://www.e-taxonomy.eu
6
// *
7
// * The contents of this file are subject to the Mozilla Public License Version 1.1
8
// * See LICENSE.TXT at the top of this package for the full license terms.
9
// */
10
//package eu.etaxonomy.taxeditor.ui.section.name;
11
//
12
//import org.eclipse.jface.util.IPropertyChangeListener;
13
//import org.eclipse.jface.util.PropertyChangeEvent;
14
//import org.eclipse.swt.SWT;
15
//import org.eclipse.swt.widgets.Composite;
16
//
17
//import eu.etaxonomy.cdm.model.common.TermType;
18
//import eu.etaxonomy.cdm.model.taxon.Synonym;
19
//import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
20
//import eu.etaxonomy.cdm.model.taxon.Taxon;
21
//import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
22
//import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
23
//import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
24
//import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25
//
26
///**
27
// * @author pplitzner
28
// * @date 27.01.2014
29
// *
30
// */
31
//public class SynonymRelationshipWizardPage extends AbstractEntityCollectionElementWizardPage implements IPropertyChangeListener {
32
//
33
//
34
//    private EntitySelectionElement<Taxon> selection_relatedTo;
35
//
36
//    private TermComboElement<SynonymRelationshipType> combo_relationshipType;
37
//
38
//    private CheckboxElement checkboxProParte;
39
//
40
//    private boolean isProParte;
41
//
42
//    private CheckboxElement checkboxPartial;
43
//
44
//    private boolean isPartial;
45
//
46
//    private final Synonym entity;
47
//
48
//    private SynonymRelationshipType type;
49
//
50
//    private Taxon taxon;
51
//
52
//
53
//    /**
54
//     * <p>
55
//     * Constructor for NameRelationshipWizardPage.
56
//     * </p>
57
//     *
58
//     * @param callingSection
59
//     *            a
60
//     *            {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
61
//     *            object.
62
//     */
63
//    protected SynonymRelationshipWizardPage(
64
//            SynonymRelationshipDetailSection callingSection) {
65
//        super("SynonymRelationshipWizardPage");
66
//        setTitle("New Synonym Relationship");
67
//        setDescription(callingSection.getEntity().getTitleCache());
68
//        this.entity = callingSection.getEntity();
69
//        this.formFactory = callingSection.getFormFactory();
70
//
71
//        formFactory.addPropertyChangeListener(this);
72
//    }
73
//
74
//    /*
75
//     * (non-Javadoc)
76
//     *
77
//     * @see
78
//     * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
79
//     * .Composite)
80
//     */
81
//    /** {@inheritDoc} */
82
//    @Override
83
//    public void createControl(Composite parent) {
84
//        super.createControl(parent);
85
//
86
//        combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.SynonymRelationshipType,
87
//                rootElement, "Synonym Relationship Type", null, SWT.NULL);
88
//
89
//        selection_relatedTo = formFactory
90
//                .createSelectionElement(Taxon.class,
91
//                        ((SynonymRelationshipWizard) getWizard())
92
//                        .getConversationHolder(), rootElement,
93
//                        "Related to", null, EntitySelectionElement.ALL,
94
//                        SWT.NULL);
95
//
96
//        checkboxProParte = formFactory.createCheckbox(rootElement, "Pro Parte Synonym", null, SWT.NULL);
97
//
98
//        checkboxPartial = formFactory.createCheckbox(rootElement, "Partial Synonym", null, SWT.NULL);
99
//
100
//    }
101
//
102
//    /**
103
//     * <p>
104
//     * getNameRelationship
105
//     * </p>
106
//     *
107
//     * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
108
//     */
109
//    public SynonymRelationship getSynonymRelationship() {
110
//        SynonymRelationship synonymRelationship = taxon.addSynonym(entity, combo_relationshipType.getSelection());
111
//        synonymRelationship.setPartial(isPartial);
112
//        synonymRelationship.setProParte(isProParte);
113
//        return synonymRelationship;
114
//    }
115
//
116
//    /** {@inheritDoc} */
117
//    @Override
118
//    public void propertyChange(PropertyChangeEvent event) {
119
//        if (event == null) {
120
//            return;
121
//        }
122
//        Object eventSource = event.getSource();
123
//        if (eventSource == combo_relationshipType) {
124
//            type = combo_relationshipType.getSelection();
125
//        } else if (eventSource == selection_relatedTo) {
126
//            taxon = selection_relatedTo.getEntity();
127
//        } else if (eventSource == checkboxProParte) {
128
//            isProParte = checkboxProParte.getSelection();
129
//        } else if (eventSource == checkboxPartial) {
130
//            isPartial = checkboxPartial.getSelection();
131
//        }
132
//
133
//        boolean complete = type != null && taxon != null;
134
//        setPageComplete(complete);
135
//    }
136
//
137
//}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
30 30
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
31 31
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
32 32
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
33
import eu.etaxonomy.taxeditor.ui.section.name.SynonymRelationshipDetailSection;
34 33
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
35 34

  
36 35
/**
......
60 59

  
61 60
	private CheckboxElement checkbox_published;
62 61

  
63
	private SynonymRelationshipDetailSection sectionSynonymRelationship;
62
//	private SynonymRelationshipDetailSection sectionSynonymRelationship;
64 63

  
65 64
	/**
66 65
	 * <p>
......
130 129
		}
131 130

  
132 131

  
133
		if(entity instanceof Synonym){
134
		    sectionSynonymRelationship = formFactory.createSynonymRelationshipDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
135
		    sectionSynonymRelationship.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
136
		    sectionSynonymRelationship.setEntity((Synonym) entity);
137
		}
132
//		if(entity instanceof Synonym){
133
//		    sectionSynonymRelationship = formFactory.createSynonymRelationshipDetailSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE);
134
//		    sectionSynonymRelationship.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
135
//		    sectionSynonymRelationship.setEntity((Synonym) entity);
136
//		}
138 137
	}
139 138

  
140 139
    private void updateCheckboxPublish() {
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/AbstractLazyInitializerTest.java
31 31
import eu.etaxonomy.cdm.model.name.NonViralName;
32 32
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
33 33
import eu.etaxonomy.cdm.model.taxon.Classification;
34
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
35 34
import eu.etaxonomy.cdm.model.taxon.Taxon;
36 35
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
36
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
37 37
import eu.etaxonomy.taxeditor.httpinvoker.BaseRemotingTest;
38 38

  
39 39

  
......
171 171

  
172 172
        @Ignore
173 173
        @Test
174
        public void testCDMEntitySaveCollection() {
174
        public void testCdmEntitySaveCollection() {
175 175
            Taxon taxon = (Taxon)taxonService.find(taxonUuid1);
176 176

  
177
            Set<SynonymRelationship> synRelations = taxon.getSynonymRelations();
177
            Set<TaxonRelationship> taxRelations = taxon.getTaxonRelations();
178 178
            Set<String> relToTitles = new HashSet<String>();
179
            Iterator<SynonymRelationship> srItr = synRelations.iterator();
180
            while(srItr.hasNext()) {
181
                SynonymRelationship sr = srItr.next();
182
                System.out.println("Synonym Title Cache : " + sr.getSynonym().getTitleCache());
183
                relToTitles.add(sr.getSynonym().getTitleCache());
184
                sr.getSynonym().setTitleCache(sr.getSynonym().getTitleCache() + ":updated");
179
            Iterator<TaxonRelationship> trItr = taxRelations.iterator();
180
            while(trItr.hasNext()) {
181
                TaxonRelationship tr = trItr.next();
182
                System.out.println("Synonym Title Cache : " + tr.getFromTaxon().getTitleCache());
183
                relToTitles.add(tr.getFromTaxon().getTitleCache());
184
                tr.getFromTaxon().setTitleCache(tr.getFromTaxon().getTitleCache() + ":updated");
185 185

  
186 186
            }
187 187
            taxonService.merge(taxon);
188 188

  
189 189
            Taxon taxonNew = (Taxon)taxonService.find(taxonUuid1);
190
            Set<SynonymRelationship> synRelationsNew = taxonNew.getSynonymRelations();
190
            Set<TaxonRelationship> taxRelationsNew = taxonNew.getTaxonRelations();
191 191

  
192
            Iterator<SynonymRelationship> srItrNew = synRelationsNew.iterator();
192
            Iterator<TaxonRelationship> trItrNew = taxRelationsNew.iterator();
193 193
            Iterator<String> relToTitlesItr = relToTitles.iterator();
194
            while(srItrNew.hasNext() && relToTitlesItr.hasNext()) {
195
                SynonymRelationship srNew = srItrNew.next();
194
            while(trItrNew.hasNext() && relToTitlesItr.hasNext()) {
195
                TaxonRelationship trNew = trItrNew.next();
196 196
                String relToTitle = relToTitlesItr.next();
197
                System.out.println("New Synonym Title Cache: " + srNew.getSynonym().getTitleCache());
198
                Assert.assertTrue("Synonym Title caches should not be equal", srNew.getSynonym().getTitleCache().equals(relToTitle));
199
                srNew.getSynonym().setTitleCache(relToTitle);
197
                System.out.println("New Synonym Title Cache: " + trNew.getFromTaxon().getTitleCache());
198
                Assert.assertTrue("Synonym Title caches should not be equal", trNew.getFromTaxon().getTitleCache().equals(relToTitle));
199
                trNew.getFromTaxon().setTitleCache(relToTitle);
200 200
            }
201 201

  
202 202
            Taxon taxonOld = (Taxon)taxonService.find(taxonUuid1);
203 203

  
204
            Set<SynonymRelationship> synRelationsOld = taxonNew.getSynonymRelations();
205
            Iterator<SynonymRelationship> srItrOld = synRelationsOld.iterator();
204
            Set<TaxonRelationship> taxRelationsOld = taxonNew.getTaxonRelations();
205
            Iterator<TaxonRelationship> trItrOld = taxRelationsOld.iterator();
206 206
            relToTitlesItr = relToTitles.iterator();
207
            while(srItrOld.hasNext() && relToTitlesItr.hasNext()) {
208
                SynonymRelationship srOld = srItrOld.next();
207
            while(trItrOld.hasNext() && relToTitlesItr.hasNext()) {
208
                TaxonRelationship trOld = trItrOld.next();
209 209
                String relToTitle = relToTitlesItr.next();
210
                System.out.println("New Synonym Title Cache: " + srOld.getSynonym().getTitleCache());
211
                Assert.assertEquals("Synonym Title caches should be equal", srOld.getSynonym().getTitleCache(), relToTitle);
210
                System.out.println("New Synonym Title Cache: " + trOld.getFromTaxon().getTitleCache());
211
                Assert.assertEquals("Synonym Title caches should be equal", trOld.getFromTaxon().getTitleCache(), relToTitle);
212 212

  
213 213
            }
214 214
        }
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/PropertyPathsTest.java
21 21
import eu.etaxonomy.cdm.model.common.CdmBase;
22 22
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
23 23
import eu.etaxonomy.cdm.model.taxon.Synonym;
24
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
25 24
import eu.etaxonomy.cdm.model.taxon.Taxon;
26 25
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
26
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
27 27
import eu.etaxonomy.taxeditor.httpinvoker.BaseRemotingTest;
28 28
import eu.etaxonomy.taxeditor.store.CdmStore;
29 29

  
......
49 49
        });
50 50
        TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, taxonBasePropertyPaths);
51 51
        Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
52
        Set<SynonymRelationship> synonymRelations = taxon.getSynonymRelations();
53
        for(SynonymRelationship rel : synonymRelations) {
54
            rel.getSynonym().getName().getStatus().size();
52
        Set<TaxonRelationship> taxonRelations = taxon.getTaxonRelations();
53
        for(TaxonRelationship rel : taxonRelations) {
54
            rel.getFromTaxon().getName().getStatus().size();
55 55
        }
56 56
        Set<TaxonNameBase> typifiedNames = taxon.getName().getHomotypicalGroup().getTypifiedNames();
57 57
        for(TaxonNameBase name : typifiedNames) {
58 58
            Set<TaxonBase> taxonBases = name.getTaxonBases();
59 59
            for(TaxonBase tb : taxonBases) {
60
                if(tb instanceof Synonym) {
61
                    Synonym syn = CdmBase.deproxy(tb, Synonym.class);
62
                    Set<SynonymRelationship> rels = syn.getSynonymRelations();
63
                    for(SynonymRelationship rel : rels) {
64
                        rel.getSynonym().getName().getStatus().size();
65
                    }
66
                }
60
            	//TODO needs to be adapted after synonym relationship removal
61
//                if(tb instanceof Synonym) {
62
//                    Synonym syn = CdmBase.deproxy(tb, Synonym.class);
63
//                    Set<TaxonRelationship> rels = syn.getTaxonRelations();
64
//                    for(TaxonRelationship rel : rels) {
65
//                        rel.getSynonym().getName().getStatus().size();
66
//                    }
67
//                }
67 68
                if(tb instanceof Taxon) {
68
                    Taxon syn = CdmBase.deproxy(tb, Taxon.class);
69
                    Set<SynonymRelationship> rels = syn.getSynonymRelations();
70
                    for(SynonymRelationship rel : rels) {
71
                        rel.getSynonym().getName().getStatus().size();
69
                    Taxon tax = CdmBase.deproxy(tb, Taxon.class);
70
                    Set<TaxonRelationship> rels = tax.getTaxonRelations();
71
                    for(TaxonRelationship rel : rels) {
72
                        rel.getFromTaxon().getName().getStatus().size();
72 73
                    }
73 74
                }
74 75
            }
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/RemoteLazyLoadingTest.java
30 30
import eu.etaxonomy.cdm.model.name.BotanicalName;
31 31
import eu.etaxonomy.cdm.model.name.NonViralName;
32 32
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
33
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
34 33
import eu.etaxonomy.cdm.model.taxon.Taxon;
35 34
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff