Project

General

Profile

« Previous | Next » 

Revision 29aeffbe

Added by Cherian Mathew over 7 years ago

EditConceptRelationshipComposite : show notification only when creating concept relationship
NewTaxonBaseComposite : added second sec. combobox for the case of creating synonyms
INewTaxonBaseComponentListener, NewTaxonBasePresenter : creating separate containers for acc. taxon and synonym references
NewTaxonBasePresenter, NewTaxonBasePresenterTest : updated new synonym method to include acc. taxon sec in input
StatusComposite : added move / change actions to context menu

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/EditConceptRelationshipComposite.java
406 406
    private static void showInDialog(String windowTitle,
407 407
            EditConceptRelationshipComposite ecrc) {
408 408
        //FIXME : hack for the moment to demonstrate checking of concept relationship rules
409
        if(!ecrc.canCreateRelationship()) {
409
        if(ecrc.action.equals(Action.Create) && !ecrc.canCreateRelationship()) {
410 410
            Notification.show("Cannot create relationship for a taxon which is already congruent to another taxon", Type.WARNING_MESSAGE);
411 411
            return;
412 412
        }
src/main/java/eu/etaxonomy/cdm/vaadin/component/NewTaxonBaseComposite.java
62 62
    @AutoGenerated
63 63
    private GridLayout gridLayout;
64 64
    @AutoGenerated
65
    private Label accTaxonNameValue;
65
    private ComboBox synComboBox;
66
    @AutoGenerated
67
    private Label synSecLabel;
66 68
    @AutoGenerated
67
    private ComboBox secComboBox;
69
    private ComboBox accTaxonSecComboBox;
68 70
    @AutoGenerated
69
    private Label secLabel;
71
    private Label accTaxonSecLabel;
70 72
    @AutoGenerated
71 73
    private TextField nameTextField;
72 74
    @AutoGenerated
73 75
    private Label nameLabel;
74 76
    @AutoGenerated
77
    private Label accTaxonNameValue;
78
    @AutoGenerated
75 79
    private Label accTaxonLabel;
76 80
    private INewTaxonBaseComponentListener listener;
77 81

  
......
107 111
        addUIListeners();
108 112

  
109 113
        if(accTaxonName == null || accTaxonName.isEmpty()) {
114
            // this is the case where we create a new taxon
110 115
            accTaxonLabel.setVisible(false);
111 116
            accTaxonNameValue.setVisible(false);
117
            synSecLabel.setVisible(false);
118
            synComboBox.setVisible(false);
112 119
        } else {
120
            // this is the case where we create a new synonym
113 121
            accTaxonNameValue.setValue(accTaxonName);
114 122
        }
115 123
        init();
116 124
    }
117 125

  
118 126
    public void init() {
119
        initSecComboBox();
127
        initAccTaxonSecComboBox();
128
        if(accTaxonIun != null) {
129
            initSynSecComboBox();
130
        }
120 131
    }
121 132

  
122
    private void initSecComboBox() {
123

  
124
        secComboBox.setNullSelectionAllowed(false);
125
        secComboBox.setItemCaptionPropertyId("titleCache");
126
        secComboBox.setImmediate(true);
133
    private void  initAccTaxonSecComboBox() {
134
        accTaxonSecComboBox.setNullSelectionAllowed(false);
135
        accTaxonSecComboBox.setItemCaptionPropertyId("titleCache");
136
        accTaxonSecComboBox.setImmediate(true);
127 137
        if(listener != null) {
128
            secComboBox.setContainerDataSource(listener.getSecRefContainer());
129
            Object selectedSecItemId = null;
130
            // if accTaxonIun is null then we are creating a new taxon
131
            // else a new synonym
132
            if(accTaxonIun == null) {
133
                selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
138
            accTaxonSecComboBox.setContainerDataSource(listener.getAccTaxonSecRefContainer());
139
            Object selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
140
            if(selectedSecItemId != null) {
141
                accTaxonSecComboBox.setValue(selectedSecItemId);
134 142
            } else {
135
                selectedSecItemId = listener.getAcceptedTaxonRefId(accTaxonIun.getUuid());
143
                accTaxonSecComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
136 144
            }
145
        }
146
    }
137 147

  
148
    private void initSynSecComboBox() {
149
        synComboBox.setNullSelectionAllowed(false);
150
        synComboBox.setItemCaptionPropertyId("titleCache");
151
        synComboBox.setImmediate(true);
152
        if(listener != null) {
153
            synComboBox.setContainerDataSource(listener.getSynSecRefContainer());
154
            Object selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
138 155
            if(selectedSecItemId != null) {
139
                secComboBox.setValue(selectedSecItemId);
156
                synComboBox.setValue(selectedSecItemId);
140 157
            } else {
141
                secComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
158
                synComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
142 159
            }
143 160
        }
144 161
    }
145 162

  
163

  
164

  
146 165
    private void addUIListeners() {
147 166
        addSaveButtonListener();
148 167
        addCancelButtonListener();
......
155 174
            public void buttonClick(ClickEvent event) {
156 175
                try {
157 176
                    nameTextField.validate();
158
                    secComboBox.validate();
177
                    accTaxonSecComboBox.validate();
178
                    if(accTaxonIun != null) {
179
                        synComboBox.validate();
180
                    }
159 181
                } catch (EmptyValueException e) {
160 182
                    Notification notification = new Notification("Invalid input", "Neither Name or Secundum can be empty", Type.WARNING_MESSAGE);
161 183
                    notification.setDelayMsec(2000);
......
171 193
                        setProgress("Saving Taxon " + nameTextField.getValue());
172 194
                        IdUuidName taxonBaseIdUuid;
173 195
                        if(accTaxonIun == null) {
174
                            taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),secComboBox.getValue(), classificationIun.getUuid());
196
                            taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),accTaxonSecComboBox.getValue(), classificationIun.getUuid());
175 197
                        } else {
176
                            taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),secComboBox.getValue(), accTaxonIun.getUuid());
198
                            taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),
199
                                    accTaxonSecComboBox.getValue(),
200
                                    accTaxonSecComboBox.getValue(),
201
                                    accTaxonIun.getUuid());
177 202
                        }
178 203
                        Object rowId = new RowId(taxonBaseIdUuid.getId());
179 204
                        registerDelayedEvent(new CdmChangeEvent(Action.Create, Arrays.asList(rowId), NewTaxonBaseComposite.class));
......
218 243
        // common part: create layout
219 244
        mainLayout = new VerticalLayout();
220 245
        mainLayout.setImmediate(false);
221
        mainLayout.setWidth("340px");
222
        mainLayout.setHeight("200px");
246
        mainLayout.setWidth("420px");
247
        mainLayout.setHeight("240px");
223 248
        mainLayout.setMargin(true);
224 249

  
225 250
        // top-level component properties
226
        setWidth("340px");
227
        setHeight("200px");
251
        setWidth("420px");
252
        setHeight("240px");
228 253

  
229 254
        // gridLayout
230 255
        gridLayout = buildGridLayout();
......
253 278
        gridLayout = new GridLayout();
254 279
        gridLayout.setImmediate(false);
255 280
        gridLayout.setWidth("-1px");
256
        gridLayout.setHeight("-1px");
281
        gridLayout.setHeight("140px");
257 282
        gridLayout.setMargin(false);
258 283
        gridLayout.setSpacing(true);
259 284
        gridLayout.setColumns(2);
......
268 293
        gridLayout.addComponent(accTaxonLabel, 0, 0);
269 294
        gridLayout.setComponentAlignment(accTaxonLabel, new Alignment(34));
270 295

  
296
        // accTaxonNameValue
297
        accTaxonNameValue = new Label();
298
        accTaxonNameValue.setImmediate(false);
299
        accTaxonNameValue.setWidth("-1px");
300
        accTaxonNameValue.setHeight("-1px");
301
        accTaxonNameValue.setValue("Taxon Name");
302
        gridLayout.addComponent(accTaxonNameValue, 1, 0);
303
        gridLayout.setComponentAlignment(accTaxonNameValue, new Alignment(33));
304

  
271 305
        // nameLabel
272 306
        nameLabel = new Label();
273 307
        nameLabel.setImmediate(false);
......
287 321
        gridLayout.addComponent(nameTextField, 1, 1);
288 322
        gridLayout.setComponentAlignment(nameTextField, new Alignment(33));
289 323

  
290
        // secLabel
291
        secLabel = new Label();
292
        secLabel.setImmediate(false);
293
        secLabel.setWidth("-1px");
294
        secLabel.setHeight("-1px");
295
        secLabel.setValue("Secundum : ");
296
        gridLayout.addComponent(secLabel, 0, 2);
297
        gridLayout.setComponentAlignment(secLabel, new Alignment(34));
298

  
299
        // secComboBox
300
        secComboBox = new ComboBox();
301
        secComboBox.setImmediate(false);
302
        secComboBox.setWidth("190px");
303
        secComboBox.setHeight("-1px");
304
        secComboBox.setInvalidAllowed(false);
305
        secComboBox.setRequired(true);
306
        gridLayout.addComponent(secComboBox, 1, 2);
307
        gridLayout.setComponentAlignment(secComboBox, new Alignment(33));
308

  
309
        // accTaxonNameValue
310
        accTaxonNameValue = new Label();
311
        accTaxonNameValue.setImmediate(false);
312
        accTaxonNameValue.setWidth("-1px");
313
        accTaxonNameValue.setHeight("-1px");
314
        accTaxonNameValue.setValue("Taxon Name");
315
        gridLayout.addComponent(accTaxonNameValue, 1, 0);
316
        gridLayout.setComponentAlignment(accTaxonNameValue, new Alignment(33));
324
        // accTaxonSecLabel
325
        accTaxonSecLabel = new Label();
326
        accTaxonSecLabel.setImmediate(false);
327
        accTaxonSecLabel.setWidth("-1px");
328
        accTaxonSecLabel.setHeight("-1px");
329
        accTaxonSecLabel.setValue("Acc. Taxon Secundum : ");
330
        gridLayout.addComponent(accTaxonSecLabel, 0, 2);
331
        gridLayout.setComponentAlignment(accTaxonSecLabel, new Alignment(34));
332

  
333
        // accTaxonSecComboBox
334
        accTaxonSecComboBox = new ComboBox();
335
        accTaxonSecComboBox.setImmediate(false);
336
        accTaxonSecComboBox.setWidth("190px");
337
        accTaxonSecComboBox.setHeight("-1px");
338
        accTaxonSecComboBox.setInvalidAllowed(false);
339
        accTaxonSecComboBox.setRequired(true);
340
        gridLayout.addComponent(accTaxonSecComboBox, 1, 2);
341
        gridLayout.setComponentAlignment(accTaxonSecComboBox, new Alignment(33));
342

  
343
        // synSecLabel
344
        synSecLabel = new Label();
345
        synSecLabel.setImmediate(false);
346
        synSecLabel.setWidth("-1px");
347
        synSecLabel.setHeight("-1px");
348
        synSecLabel.setValue("Synonym Secundum : ");
349
        gridLayout.addComponent(synSecLabel, 0, 3);
350

  
351
        // synComboBox
352
        synComboBox = new ComboBox();
353
        synComboBox.setImmediate(false);
354
        synComboBox.setWidth("190px");
355
        synComboBox.setHeight("-1px");
356
        synComboBox.setInvalidAllowed(false);
357
        synComboBox.setRequired(true);
358
        gridLayout.addComponent(synComboBox, 1, 3);
317 359

  
318 360
        return gridLayout;
319 361
    }
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java
106 106

  
107 107
    private final boolean taxaTreeTableMultiSelectMode = true;
108 108

  
109
    private static final String SELECT_FILTER = "Select filter ...";
110 109
    private static final String SELECT_CLASSIFICATION = "Select classification ...";
111 110

  
112
    private static final String ADD_TAXON_SYNONYM_INPUT = "Add ...";
111

  
113 112
    private static final String CREATE_ACC_TAXON = "Create Accepted Taxon";
113
    private static final String CHANGE_TO_ACC_TAXON = "Change to Accepted Taxon";
114
    private static final String REPLACE_ACC_TAXON = "Replace Accepted Taxon";
115
    private static final String CHANGE_TO_SYNONYM = "Change to Synonym";
114 116
    private static final String CREATE_SYNONYM = "Create Synonym";
115 117
    private static final String SET_AS_DELETED = "Set as Deleted";
116 118
    private static final String SET_AS_EXCLUDED = "Set as Excluded";
......
282 284
        container.addContainerProperty("filter", String.class, "");
283 285
        container.addContainerProperty("selected", Boolean.class, "");
284 286

  
285
//        Item item = container.addItem(FILTER_NOT_RESOLVED);
286
//        item.getItemProperty(PROPERTY_FILTER_ID).setValue(FILTER_NOT_RESOLVED);
287
//        item.getItemProperty(PROPERTY_SELECTED_ID).setValue(false);
288
//
289
//        item = container.addItem(FILTER_UNPLACED);
290
//        item.getItemProperty(PROPERTY_FILTER_ID).setValue(FILTER_UNPLACED);
291
//        item.getItemProperty(PROPERTY_SELECTED_ID).setValue(false);
292

  
293 287
        Item item = container.addItem(FILTER_UNFINISHED);
294 288
        item.getItemProperty(PROPERTY_FILTER_ID).setValue(FILTER_UNFINISHED);
295 289
        item.getItemProperty(PROPERTY_SELECTED_ID).setValue(false);
......
409 403
                        .fireSelectionEvent(new SelectionEvent(Arrays.asList(idUuidName, getSelectedClassificationUuid()), StatusComposite.class), true);
410 404
                    }
411 405
                    taxaTreeTable.setValue(Arrays.asList(itemId));
412
                    generateTaxaTreeTableContextMenu(!isSynonym);
406
                    generateTaxaTreeTableContextMenu(isSynonym);
413 407

  
414 408
                }
415 409
            }
......
424 418

  
425 419
        taxaTableContextMenu.removeAllItems();
426 420
        if(isSynonym) {
421

  
422

  
423
            ContextMenuItem changeToAccTaxonMenuItem = taxaTableContextMenu.addItem(CHANGE_TO_ACC_TAXON);
424
            changeToAccTaxonMenuItem.setData(CHANGE_TO_ACC_TAXON);
425

  
426
            ContextMenuItem replaceAccTaxonMenuItem = taxaTableContextMenu.addItem(REPLACE_ACC_TAXON);
427
            replaceAccTaxonMenuItem.setData(REPLACE_ACC_TAXON);
428

  
429
            replaceAccTaxonMenuItem.setSeparatorVisible(true);
430
        } else {
427 431
            ContextMenuItem createSynMenuItem = taxaTableContextMenu.addItem(CREATE_SYNONYM);
428 432
            createSynMenuItem.setData(CREATE_SYNONYM);
433

  
434
            ContextMenuItem changeToSynMenuItem = taxaTableContextMenu.addItem(CHANGE_TO_SYNONYM);
435
            changeToSynMenuItem.setData(CHANGE_TO_SYNONYM);
436

  
437
            changeToSynMenuItem.setSeparatorVisible(true);
429 438
        }
439

  
430 440
        ContextMenuItem setDeletedMenuItem = taxaTableContextMenu.addItem(SET_AS_DELETED);
431 441
        setDeletedMenuItem.setData(SET_AS_DELETED);
432 442

  
......
436 446
        ContextMenuItem setOutOfScopeMenuItem = taxaTableContextMenu.addItem(SET_AS_OUT_OF_SCOPE);
437 447
        setOutOfScopeMenuItem.setData(SET_AS_OUT_OF_SCOPE);
438 448

  
439
        setOutOfScopeMenuItem.setSeparatorVisible(true);
440

  
441 449
        ContextMenuItem createAccTaxonMenuItem = taxaTableContextMenu.addItem(CREATE_ACC_TAXON);
442 450
        createAccTaxonMenuItem.setData(CREATE_ACC_TAXON);
443 451

  
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/NewTaxonBasePresenter.java
46 46

  
47 47

  
48 48

  
49
    private final CdmSQLContainer secRefContainer;
49
    private final CdmSQLContainer accTaxonSecRefContainer;
50
    private final CdmSQLContainer synSecRefContainer;
50 51

  
51 52
    private final IReferenceService referenceService;
52 53
    private final ITaxonNodeService taxonNodeService;
......
55 56
    private final ICdmApplicationConfiguration app;
56 57

  
57 58

  
58
    /* (non-Javadoc)
59
     * @see eu.etaxonomy.cdm.vaadin.view.INewTaxonBaseComponentListener#getSecRefContainer()
60
     */
59

  
60
    @Override
61
    public CdmSQLContainer getAccTaxonSecRefContainer() {
62
        return accTaxonSecRefContainer;
63
    }
64

  
61 65
    @Override
62
    public CdmSQLContainer getSecRefContainer() {
63
        return secRefContainer;
66
    public CdmSQLContainer getSynSecRefContainer() {
67
        return synSecRefContainer;
64 68
    }
65 69

  
66 70
    public NewTaxonBasePresenter() throws SQLException {
67
        secRefContainer = CdmSQLContainer.newInstance("Reference");
71
        accTaxonSecRefContainer = CdmSQLContainer.newInstance("Reference");
72
        synSecRefContainer = CdmSQLContainer.newInstance("Reference");
68 73
        referenceService = CdmSpringContextHelper.getReferenceService();
69 74
        taxonNodeService = CdmSpringContextHelper.getTaxonNodeService();
70 75
        taxonService = CdmSpringContextHelper.getTaxonService();
......
78 83
    @Override
79 84
    public IdUuidName newTaxon(String scientificName, Object secRefItemId, UUID classificationUuid) {
80 85
        TransactionStatus tx = app.startTransaction();
81
        UUID uuid = secRefContainer.getUuid(secRefItemId);
86
        UUID uuid = accTaxonSecRefContainer.getUuid(secRefItemId);
82 87

  
83 88
        Reference sec = CdmBase.deproxy(referenceService.load(uuid), Reference.class);
84 89

  
......
102 107
     * @see eu.etaxonomy.cdm.vaadin.view.INewTaxonBaseComponentListener#newSynonym(java.lang.String, java.lang.Object, java.util.UUID)
103 108
     */
104 109
    @Override
105
    public IdUuidName newSynonym(String scientificName, Object secRefItemId, UUID accTaxonUuid) {
110
    public IdUuidName newSynonym(String scientificName, Object synSecRefItemId, Object accTaxonSecRefItemId, UUID accTaxonUuid) {
106 111
        TransactionStatus tx = app.startTransaction();
107 112
        List<String> ACC_TAXON_INIT_STRATEGY = Arrays.asList(new String []{
108 113
                "synonymRelations"
109 114
        });
110
        UUID refUuid = secRefContainer.getUuid(secRefItemId);
111
        Reference sec = CdmBase.deproxy(referenceService.load(refUuid), Reference.class);
115

  
116
        UUID synRefUuid = synSecRefContainer.getUuid(synSecRefItemId);
117
        Reference synSec = CdmBase.deproxy(referenceService.load(synRefUuid), Reference.class);
112 118
        NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
113 119
        NonViralName name = parser.parseFullName(scientificName);
114 120
        name.setTitleCache(scientificName, true);
121
        Synonym newSynonym = Synonym.NewInstance(name, synSec);
122

  
123

  
124
        UUID accTaxonRefUuid = accTaxonSecRefContainer.getUuid(accTaxonSecRefItemId);
125
        Reference accTaxonSec = CdmBase.deproxy(referenceService.load(accTaxonRefUuid), Reference.class);
115 126
        Taxon accTaxon = CdmBase.deproxy(taxonService.load(accTaxonUuid, ACC_TAXON_INIT_STRATEGY), Taxon.class);
116
        Synonym newSynonym = Synonym.NewInstance(name, sec);
127
        accTaxon.setSec(accTaxonSec);
128

  
117 129
        accTaxon.addSynonym(newSynonym, SynonymRelationshipType.SYNONYM_OF());
130

  
118 131
        UUID newUuid = taxonService.save(newSynonym);
119 132
        app.commitTransaction(tx);
120 133
        return new IdUuidName(newSynonym.getId(), newUuid, newSynonym.getTitleCache());
src/main/java/eu/etaxonomy/cdm/vaadin/view/INewTaxonBaseComponentListener.java
22 22
public interface INewTaxonBaseComponentListener {
23 23

  
24 24

  
25
    public CdmSQLContainer getSecRefContainer();
26 25

  
27 26

  
28 27
    /**
......
36 35

  
37 36
    /**
38 37
     * @param scientificName
39
     * @param secRefItemId
38
     * @param synSecRefItemId
39
     * @param accTaxonSecRefItemId
40 40
     * @param accTaxonUuid
41 41
     * @return
42 42
     */
43
    public IdUuidName newSynonym(String scientificName, Object secRefItemId, UUID accTaxonUuid);
43
    public IdUuidName newSynonym(String scientificName, Object synSecRefItemId, Object accTaxonSecRefItemId, UUID accTaxonUuid);
44 44

  
45 45

  
46 46
    /**
......
57 57
    public Object getClassificationRefId(UUID classificationUuid);
58 58

  
59 59

  
60
    /**
61
     * @return
62
     */
63
    public CdmSQLContainer getAccTaxonSecRefContainer();
64

  
65

  
66
    /**
67
     * @return
68
     */
69
    public CdmSQLContainer getSynSecRefContainer();
70

  
71

  
72

  
73

  
74

  
60 75

  
61 76

  
62 77

  
src/test/java/eu/etaxonomy/cdm/vaadin/presenter/NewTaxonBasePresenterTest.java
53 53
    @Test
54 54
    public void testNewTaxonBase() throws SQLException {
55 55
        RowId refId20 = new RowId(20);
56
        RowId refId21 = new RowId(21);
56 57
        UUID newTaxonUuid = ntbp.newTaxon("Taxon E", refId20, UUID.fromString("6595638e-4993-421a-9fe5-76b09d94f36a")).getUuid();
57 58
        List<String> ACC_TAXON_INIT_STRATEGY = Arrays.asList(new String []{
59
                "sec",
58 60
                "synonymRelations"
59 61
        });
60 62
        Taxon taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(newTaxonUuid,ACC_TAXON_INIT_STRATEGY),Taxon.class);
61 63

  
62
        UUID newSynonymUuid = ntbp.newSynonym("Synonym OfE", refId20, newTaxonUuid).getUuid();
64
        UUID newSynonymUuid = ntbp.newSynonym("Synonym OfE", refId20, refId21, newTaxonUuid).getUuid();
63 65
        taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(newTaxonUuid,ACC_TAXON_INIT_STRATEGY),Taxon.class);
64 66

  
65 67
        Set<Synonym> synonyms = taxon.getSynonyms();
......
68 70

  
69 71
        Synonym synonym = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(newSynonymUuid),Synonym.class);
70 72
        Assert.assertEquals(synonym, synonymOfTaxon);
73

  
74
        Assert.assertEquals(synonym.getSec().getId(), 20);
75

  
76
        taxon = CdmBase.deproxy(CdmSpringContextHelper.getTaxonService().load(newTaxonUuid,ACC_TAXON_INIT_STRATEGY),Taxon.class);
77

  
78
        Assert.assertEquals(taxon.getSec().getId(), 21);
71 79
    }
72 80

  
73 81

  

Also available in: Unified diff