Project

General

Profile

« Previous | Next » 

Revision 53c75a2d

Added by Cherian Mathew about 9 years ago

StatusPresenter : moved logic to container
StatusComposite, NewTaxonBasePresenterTest, NewTaxonBasePresenterTest : added classification id argument for taxon creation

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java
197 197

  
198 198
                @Override
199 199
                public String getStyle(Table source, Object itemId, Object propertyId) {
200
                    if(source.getItem(itemId) == null) {
201
                        return null;
202
                    }
200 203
                    Property hasSynProperty = source.getItem(itemId).getItemProperty(LeafNodeTaxonContainer.HAS_SYN_ID);
201 204
                    if(hasSynProperty == null) {
202 205
                        // this is a synonym, so we activate the corresponding css class
......
430 433
                            try {
431 434
                                Window dialog = new Window(windowTitle);
432 435
                                dialog.setModal(true);
436
                                dialog.setClosable(false);
437
                                dialog.setResizable(false);
433 438
                                UI.getCurrent().addWindow(dialog);
434 439

  
440
                                UUID classificationUuid = listener.getClassificationContainer().getUuid(classificationComboBox.getValue());
441
                                IdAndUuid classificationIdUuid = new IdAndUuid(classificationComboBox.getValue(), classificationUuid);
435 442
                                NewTaxonBaseComposite newTaxonComponent =
436 443
                                        new NewTaxonBaseComposite(dialog,
437 444
                                                new NewTaxonBasePresenter(),
438
                                                accTaxonIdUuid);
445
                                                accTaxonIdUuid,
446
                                                classificationIdUuid);
439 447
                                dialog.setContent(newTaxonComponent);
440 448
                            } catch (SQLException e) {
441 449
                                // TODO Auto-generated catch block
......
720 728
        if(event.getSourceType().equals(NewTaxonBaseComposite.class)) {
721 729
            Object itemId = event.getChangedObjects().get(0);
722 730
            listener.getCurrentLeafNodeTaxonContainer().removeTaxonFromCache(itemId);
723
            // FIXME : not really sure at the moment how to refresh a single node (taxon)
724
            //         in the tree table. As a workaround the node is explicitly collapsed
725
            //         so that when the user expands the synonyms will be refreshed
726
            taxaTreeTable.setCollapsed(itemId, true);
727
            taxaTreeTable.setValue(itemId);
731

  
732
            // FIXME : need to figure out how to programmatically select an item in the
733
            // table
734

  
735
            listener.getCurrentLeafNodeTaxonContainer().getItem(itemId);
736
            listener.refresh();
737
            taxaTreeTable.select(itemId);
728 738
        }
729 739

  
730 740
    }
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/StatusPresenter.java
30 30

  
31 31

  
32 32

  
33
    private LeafNodeTaxonContainer container;
33
    private LeafNodeTaxonContainer leafNodeTaxonContainer;
34

  
35
    private CdmSQLContainer classificationContainer;
34 36

  
35 37
    private final ITaxonService taxonService;
36 38

  
......
53 55
     */
54 56
    @Override
55 57
    public LeafNodeTaxonContainer loadTaxa(int classificationId) throws SQLException {
56
        container = new LeafNodeTaxonContainer(classificationId);
57
        totalNoOfTaxa = container.getTotalNoOfTaxa();
58
        return container;
58
        leafNodeTaxonContainer = new LeafNodeTaxonContainer(classificationId);
59
        totalNoOfTaxa = leafNodeTaxonContainer.getTotalNoOfTaxa();
60
        return leafNodeTaxonContainer;
59 61
    }
60 62

  
61 63
    @Override
62 64
    public void refresh() {
63
        container.refresh();
65
        leafNodeTaxonContainer.refresh();
64 66
    }
65 67
    @Override
66 68
    public void setUnplacedFilter() {
67
        container.setUnplacedFilter();
69
        leafNodeTaxonContainer.setUnplacedFilter();
68 70
    }
69 71

  
70 72
    @Override
71 73
    public void removeUnplacedFilter() {
72
        container.removeUnplacedFilter();
74
        leafNodeTaxonContainer.removeUnplacedFilter();
73 75
    }
74 76

  
75 77
    @Override
76 78
    public void setUnpublishedFilter() {
77
        container.setUnpublishedFilter();
79
        leafNodeTaxonContainer.setUnpublishedFilter();
78 80
    }
79 81

  
80 82
    @Override
81 83
    public void removeUnpublishedFilter() {
82
        container.removeUnpublishedFilter();
84
        leafNodeTaxonContainer.removeUnpublishedFilter();
83 85
    }
84 86

  
85 87
    @Override
86 88
    public void setNameFilter(String filterString) {
87
        container.setNameFilter(filterString);
89
        leafNodeTaxonContainer.setNameFilter(filterString);
88 90
    }
89 91

  
90 92
    @Override
91 93
    public void removeNameFilter() {
92
        container.removeNameFilter();
94
        leafNodeTaxonContainer.removeNameFilter();
93 95
    }
94 96

  
95 97
    @Override
96 98
    public int getCurrentNoOfTaxa() {
97
        return container.size();
99
        return leafNodeTaxonContainer.size();
98 100
    }
99 101

  
100 102
    @Override
......
104 106

  
105 107
    @Override
106 108
    public boolean isSynonym(Object itemId) {
107
        return container.isSynonym(itemId);
109
        return leafNodeTaxonContainer.isSynonym(itemId);
108 110
    }
109 111

  
110 112
    /* (non-Javadoc)
......
112 114
     */
113 115
    @Override
114 116
    public CdmSQLContainer loadClassifications() throws SQLException {
115
        CdmSQLContainer container = CdmSQLContainer.newInstance("Classification");
116
        return container;
117
        classificationContainer = CdmSQLContainer.newInstance("Classification");
118
        return classificationContainer;
117 119
    }
118 120

  
119 121

  
120 122
    @Override
121 123
    public void updatePublished(boolean pb, Object itemId) {
122
        UUID uuid = UUID.fromString((String)container.getItem(itemId).getItemProperty(CdmQueryFactory.UUID_ID).getValue());
124
        UUID uuid = UUID.fromString((String)leafNodeTaxonContainer.getItem(itemId).getItemProperty(CdmQueryFactory.UUID_ID).getValue());
123 125
        Taxon taxon = CdmBase.deproxy(taxonService.load(uuid), Taxon.class);
124 126
        boolean currentPb = taxon.isPublish();
125 127
        if(currentPb != pb) {
......
134 136
     */
135 137
    @Override
136 138
    public LeafNodeTaxonContainer getCurrentLeafNodeTaxonContainer() {
137
        return container;
139
        return leafNodeTaxonContainer;
140
    }
141

  
142
    @Override
143
    public CdmSQLContainer getClassificationContainer() {
144
        return classificationContainer;
138 145
    }
139 146

  
140 147
}
src/test/java/eu/etaxonomy/cdm/vaadin/presenter/NewTaxonBasePresenterTest.java
38 38
 *
39 39
 */
40 40

  
41
@DataSet
41
@DataSet("StatusPresenterTest.xml")
42 42
public class NewTaxonBasePresenterTest extends CdmVaadinBaseTest {
43 43

  
44 44
    private static final Logger logger = Logger.getLogger(NewTaxonBasePresenterTest.class);
......
50 50
        ntbp = new NewTaxonBasePresenter();
51 51
    }
52 52

  
53

  
53 54
    @Test
54 55
    public void testNewTaxonBase() throws SQLException {
55 56
        RowId refId20 = new RowId(20);
56
        UUID newTaxonUuid = ntbp.newTaxon("Taxon E", refId20).getUuid();
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 []{
58 59
                "synonymRelations"
59 60
        });
......
72 73
        CdmSQLContainer csc = CdmSQLContainer.newInstance("TaxonBase");
73 74
    }
74 75

  
75
    @Test
76
    public void testTaxonContainer() throws SQLException {
77

  
78
        //CdmSQLContainer csc = CdmSQLContainer.newInstance("TaxonBase");
79
        //Collection<?> propIds = csc.getContainerPropertyIds();
80
        //Collection<?> itemIds = csc.getItemIds();
81
        //Assert.assertEquals(itemIds.size(),38);
82
    }
83 76

  
84 77
    public static class MockNewTaxonBaseComposite implements INewTaxonBaseComposite {
85 78

  
src/test/resources/eu/etaxonomy/cdm/vaadin/presenter/NewTaxonBasePresenterTest.xml
1 1
<?xml version="1.0" encoding="UTF-8"?><!--
2
  generated by Jailer 4.3, Thu Apr 02 15:01:32 CEST 2015 from cmathew@cmbgbm-t530
2
  generated by Jailer 4.3, Fri Apr 10 15:48:47 CEST 2015 from cmathew@cmbgbm-t530
3 3
  
4
  Extraction Model:  TaxonBase where id=10 or id =16 (extractionmodel/by-example/SbE-TaxonBase-15-01-23-068.csv)
4
  Extraction Model:  all rows from Classification (extractionmodel/by-example/SbE-Classification-15-48-33-101.csv)
5 5
  Database URL:      jdbc:mysql://127.0.0.1:3306/local-redlist
6 6
  Database User:     root
7 7
  
8
  Exported Rows:     4
8
  Exported Rows:     22
9
      Classification                 2
10
      LanguageString                 2
9 11
      Reference                      2
10
      TaxonBase                      2
12
      TaxonBase                      7
13
      TaxonNode                      9
11 14
  
12 15
--><dataset>
13
  <TaxonBase DTYPE="Taxon" id="10" created="2015-03-09 15:49:22.0" uuid="666b484f-dc1e-4578-b404-86bc6d2e47fa" updated="2015-03-09 15:49:25.0" protectedtitlecache="false" titleCache="Taxon A sec. Book Reference 1" doubtful="false" publish="true" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="true" createdby_id="10" updatedby_id="10" name_id="10" sec_id="20"/>
16
  <TaxonNode id="11" created="2015-03-09 15:48:30.0" uuid="38f9a5e6-1a5c-4eae-8c63-3311a3102417" updated="2015-03-09 15:48:42.0" countchildren="4" sortindex="-1" treeindex="#t11#11#" createdby_id="10" updatedby_id="10" classification_id="11"/>
17
  <TaxonNode id="12" created="2015-03-09 15:49:25.0" uuid="70d6a47f-ec64-4e7e-9d92-299323adfdad" updated="2015-03-09 15:49:25.0" countchildren="0" sortindex="0" treeindex="#t11#11#12#" createdby_id="10" updatedby_id="10" classification_id="11" parent_id="11" taxon_id="10"/>
18
  <TaxonNode id="13" created="2015-03-09 15:51:14.0" uuid="8fe0c988-e1dd-4022-87e7-fe89f1f688db" updated="2015-03-09 15:51:14.0" countchildren="0" sortindex="1" treeindex="#t11#11#13#" createdby_id="10" updatedby_id="10" classification_id="11" parent_id="11" taxon_id="13"/>
19
  <TaxonNode id="14" created="2015-03-09 15:51:25.0" uuid="9d300433-a944-4768-b983-22e0236e716b" updated="2015-03-09 15:51:25.0" countchildren="0" sortindex="2" treeindex="#t11#11#14#" createdby_id="10" updatedby_id="10" classification_id="11" parent_id="11" taxon_id="14"/>
20
  <TaxonNode id="15" created="2015-03-09 15:52:08.0" uuid="ac4c95a7-640c-4910-8033-0a62b340e2a2" updated="2015-03-09 15:52:24.0" countchildren="3" sortindex="-1" treeindex="#t12#15#" createdby_id="10" updatedby_id="10" classification_id="12"/>
21
  <TaxonNode id="16" created="2015-03-09 15:52:42.0" uuid="33fb366c-1845-49ec-b5ae-9fb169a4aded" updated="2015-03-09 15:52:42.0" countchildren="0" sortindex="0" treeindex="#t12#15#16#" createdby_id="10" updatedby_id="10" classification_id="12" parent_id="15" taxon_id="16"/>
22
  <TaxonNode id="17" created="2015-03-09 15:53:23.0" uuid="e804ca8b-3520-41fd-8146-a93181ed57e4" updated="2015-03-09 15:53:23.0" countchildren="0" sortindex="1" treeindex="#t12#15#17#" createdby_id="10" updatedby_id="10" classification_id="12" parent_id="15" taxon_id="19"/>
23
  <TaxonNode id="18" created="2015-03-09 15:53:32.0" uuid="5c43f991-c4ad-414b-a4f3-2d6a26ff1ccf" updated="2015-03-09 15:53:32.0" countchildren="0" sortindex="2" treeindex="#t12#15#18#" createdby_id="10" updatedby_id="10" classification_id="12" parent_id="15" taxon_id="20"/>
24
  <TaxonNode id="20" created="2015-03-10 13:40:31.0" uuid="6a6ee4dd-5727-47ba-a53d-3a985623dd93" updated="2015-03-10 13:40:31.0" countchildren="0" sortindex="3" treeindex="#t11#11#20#" createdby_id="10" updatedby_id="10" classification_id="11" parent_id="11" taxon_id="30"/>
25

  
26
  <LanguageString id="11" created="2015-03-09 15:48:39.0" uuid="74793377-eeec-40e1-a971-b1b7e65c05f2" updated="2015-03-09 15:48:42.0" text="Classification1" createdby_id="10" updatedby_id="10" language_id="124"/>
27
  <LanguageString id="12" created="2015-03-09 15:52:14.0" uuid="0bcb7acf-a6c4-4715-a30e-d02614c9f799" updated="2015-03-09 15:52:24.0" text="Classification2" createdby_id="10" updatedby_id="10" language_id="124"/>
28

  
29
  <Classification id="11" created="2015-03-09 15:48:30.0" uuid="6595638e-4993-421a-9fe5-76b09d94f36a" updated="2015-03-09 15:48:42.0" protectedtitlecache="false" titleCache="Classification1" createdby_id="10" updatedby_id="10" name_id="11" rootnode_id="11"/>
30
  <Classification id="12" created="2015-03-09 15:52:08.0" uuid="1ef8aada-de72-4023-bbe1-14465b6bc60d" updated="2015-03-09 15:52:24.0" protectedtitlecache="false" titleCache="Classification2" createdby_id="10" updatedby_id="10" name_id="12" rootnode_id="15"/>
31

  
32
  <TaxonBase DTYPE="Taxon" id="10" created="2015-03-09 15:49:22.0" uuid="666b484f-dc1e-4578-b404-86bc6d2e47fa" updated="2015-03-09 15:49:25.0" protectedtitlecache="false" titleCache="Taxon A sec. Book Reference 1" doubtful="false" publish="false" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="true" createdby_id="10" updatedby_id="10" name_id="10" sec_id="20"/>
33
  <TaxonBase DTYPE="Taxon" id="13" created="2015-03-09 15:51:11.0" uuid="77e7d93e-75c6-4dd4-850d-7b5809654378" updated="2015-03-09 15:51:14.0" protectedtitlecache="false" titleCache="Taxon B sec. ???" doubtful="false" publish="true" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="false" createdby_id="10" updatedby_id="10" name_id="13"/>
34
  <TaxonBase DTYPE="Taxon" id="14" created="2015-03-09 15:51:24.0" uuid="b38d0d73-9a20-4894-99bb-2148ee6b10d0" updated="2015-04-09 13:50:03.0" protectedtitlecache="false" titleCache="Taxon C sec. ???" doubtful="false" publish="true" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="false" createdby_id="10" updatedby_id="10" name_id="14"/>
14 35
  <TaxonBase DTYPE="Taxon" id="16" created="2015-03-09 15:52:34.0" uuid="eaac797e-cac7-4649-97cf-c7b580076895" updated="2015-03-09 15:52:42.0" protectedtitlecache="false" titleCache="Taxon A sec. Journal Reference 1" doubtful="false" publish="true" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="true" createdby_id="10" updatedby_id="10" name_id="16" sec_id="21"/>
36
  <TaxonBase DTYPE="Taxon" id="19" created="2015-03-09 15:53:21.0" uuid="5004a8e7-b907-4744-b67e-44ccb057ab3b" updated="2015-03-09 15:53:23.0" protectedtitlecache="false" titleCache="Taxon B sec. ???" doubtful="false" publish="true" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="false" createdby_id="10" updatedby_id="10" name_id="19"/>
37
  <TaxonBase DTYPE="Taxon" id="20" created="2015-03-09 15:53:30.0" uuid="3d71c8b8-3bec-4f5f-ba23-6f9d55ef84e9" updated="2015-03-09 15:53:32.0" protectedtitlecache="false" titleCache="Taxon C sec. ???" doubtful="false" publish="true" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="false" createdby_id="10" updatedby_id="10" name_id="20"/>
38
  <TaxonBase DTYPE="Taxon" id="30" created="2015-03-10 13:40:30.0" uuid="5f713f69-e03e-4a11-8a55-700fbbf44805" updated="2015-04-09 13:50:03.0" protectedtitlecache="false" titleCache="Taxon D sec. ???" doubtful="false" publish="true" usenamecache="false" excluded="false" taxonstatusunknown="false" taxonomicchildrencount="0" unplaced="false" createdby_id="10" updatedby_id="10" name_id="30"/>
15 39

  
16 40
  <Reference id="20" created="2015-04-02 09:42:49.0" uuid="b7dbc26f-30a0-49e2-9ca6-bbeeefbb9909" updated="2015-04-02 09:42:53.0" protectedtitlecache="true" titleCache="Book Reference 1" abbrevtitlecache="" nomenclaturallyrelevant="false" parsingproblem="0" problemends="-1" problemstarts="-1" protectedabbrevtitlecache="false" refType="BK" createdby_id="10" updatedby_id="10"/>
17 41
  <Reference id="21" created="2015-04-02 09:43:04.0" uuid="300ac33d-478a-4a89-ab83-6d89c5142e41" updated="2015-04-02 09:43:07.0" protectedtitlecache="true" titleCache="Journal Reference 1" abbrevtitlecache="" nomenclaturallyrelevant="false" parsingproblem="0" problemends="-1" problemstarts="-1" protectedabbrevtitlecache="false" refType="JOU" createdby_id="10" updatedby_id="10"/>

Also available in: Unified diff