Project

General

Profile

« Previous | Next » 

Revision 5465eca0

Added by Andreas Kohlbecker about 7 years ago

ref #6169 showing citation in list and eums items in UPPERCASE

View differences:

src/main/java/eu/etaxonomy/cdm/mock/Registration.java
51 51

  
52 52

  
53 53
    /**
54
     * @param name
54
     * @param NAME
55 55
     */
56 56
    public Registration() {
57 57
        super();
src/main/java/eu/etaxonomy/cdm/mock/RegistrationStatus.java
10 10

  
11 11
public enum RegistrationStatus {
12 12

  
13
    preparation,// A new record which is being edited by the Author
14
    curation, //A record ready for the curator to be validated.
15
    ready, //The record has passed the validation by the curator and is ready for publication.
16
    published, //The name or typification has finally been published.
17
    rejected //The registration has been rejected, the process is aborted and the record is preserved.
13
    PREPARATION,// A new record which is being edited by the Author
14
    CURATION, //A record ready for the curator to be validated.
15
    READY, //The record has passed the validation by the curator and is ready for publication.
16
    PUBLISHED, //The name or typification has finally been published.
17
    REJECTED //The registration has been rejected, the process is aborted and the record is preserved.
18 18
}
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/RegistrationDTO.java
19 19

  
20 20
    private String summary = "";
21 21

  
22
    private String citation = "";
23

  
22 24
    private RegistrationType registrationType;
23 25

  
24 26
    private Registration reg;
......
36 38
        registrationType = RegistrationType.from(reg);
37 39
        if(registrationType.isName()){
38 40
            summary = reg.getName().getTitleCache();
41
            if(reg.getName().getNomenclaturalReference() != null){
42
                citation = reg.getName().getNomenclaturalReference().generateTitle();
43
            }
39 44
        } else if(registrationType.isTypification()){
40 45
            summary = new TypeDesignationConverter(reg.getTypeDesignations(), typifiedName)
41 46
                    .buildString().print();
47
            if(!reg.getTypeDesignations().isEmpty()){
48
                if(reg.getTypeDesignations().iterator().next().getCitation() != null) {
49
                    citation = reg.getTypeDesignations().iterator().next().getCitation().generateTitle();
50
                }
51
            }
42 52
        } else {
43 53
            summary = "- INVALID REGISTRATION -";
44 54
        }
......
77 87

  
78 88

  
79 89
    /**
80
     * @return the internalRegId
90
     * @return the specificIdentifier
81 91
     */
82
    public String getInternalRegId() {
92
    public String getSpecificIdentifier() {
83 93
        return reg.getSpecificIdentifier();
84 94
    }
85 95

  
......
97 107
        return reg.getCreated();
98 108
    }
99 109

  
110
    public String getCitation() {
111
        return citation;
112
    }
113

  
100 114
}
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/RegistrationType.java
17 17
 */
18 18
public enum RegistrationType {
19 19

  
20
    name, typification, invalid;
20
    NAME, TYPIFICATION, INVALID;
21 21

  
22 22
    /**
23 23
     * @param reg
......
25 25
     */
26 26
    public static RegistrationType from(Registration reg) {
27 27
        if(reg.getName() != null){
28
            return name;
28
            return NAME;
29 29
        }
30 30
        if(reg.getTypeDesignations().size() > 0){
31
            return typification;
31
            return TYPIFICATION;
32 32
        }
33
        return invalid;
33
        return INVALID;
34 34
    }
35 35

  
36 36
    /**
37 37
     * @return
38 38
     */
39 39
    public boolean isName() {
40
        return name.equals(this);
40
        return NAME.equals(this);
41 41

  
42 42
  }
43 43
    /**
44 44
     * @return
45 45
     */
46 46
    public boolean isTypification() {
47
        return typification.equals(this);
47
        return TYPIFICATION.equals(this);
48 48
    }
49 49

  
50 50
}
src/main/java/eu/etaxonomy/cdm/vaadin/util/UrlStringConverter.java
13 13
import com.vaadin.data.util.converter.Converter;
14 14

  
15 15
/**
16
 * Creates a link from the values in the column.
17
 *
16 18
 * @author a.kohlbecker
17 19
 * @since Mar 7, 2017
18 20
 *
19 21
 */
20 22
public final class UrlStringConverter implements Converter<String, String> {
23

  
24
    private String regex = null;
25
    private String replacement = "";
26

  
27
    public UrlStringConverter() {
28

  
29
    }
30

  
31
    /**
32
     * @param regex Regular expression for creating an alternative label by string replacement on the value.
33
     *  This is optional. No string replacement will be done when this is <code>null</code>.
34
     */
35
    public UrlStringConverter(String regex) {
36
        this(regex, null);
37
    }
38

  
39
    /**
40
     * @param regex Regular expression for creating an alternative label by string replacement on the value.
41
     *  This is optional. No string replacement will be done when this is <code>null</code>.
42
     * @param replacement The replacement to be used with the <code>regex</code>.
43
     * Defaults to an empty string when null.
44
     */
45
    public UrlStringConverter(String regex, String replacement) {
46
        this.regex = regex;
47
        if(replacement != null){
48
            this.replacement = replacement;
49
        }
50
    }
51

  
21 52
    @Override
22 53
    public String convertToModel(String value, Class<? extends String> targetType, Locale locale)
23 54
            throws com.vaadin.data.util.converter.Converter.ConversionException {
......
27 58
    @Override
28 59
    public String convertToPresentation(String value, Class<? extends String> targetType, Locale locale)
29 60
            throws com.vaadin.data.util.converter.Converter.ConversionException {
30
        // TODO Auto-generated method stub
31
        return "<a href=\"" + value + "\" target=\"external\">" + value + "</a>";
61
        String label = value;
62
        if(regex != null){
63
            label = label.replace(regex, replacement);
64
        }
65
        return "<a href=\"" + value + "\" target=\"external\">" + label + "</a>";
32 66
    }
33 67

  
34 68
    @Override
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/ListViewBean.java
66 66
        @Override
67 67
        public String convertToPresentation(RegistrationType value, Class<? extends String> targetType,
68 68
                Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
69
            if(value.equals(RegistrationType.name)) {
69
            if(value.equals(RegistrationType.NAME)) {
70 70
                return FontAwesome.TAG.getHtml();
71 71
            }
72
            if(value.equals(RegistrationType.typification)) {
72
            if(value.equals(RegistrationType.TYPIFICATION)) {
73 73
                return FontAwesome.TAGS.getHtml();
74 74
            }
75 75
            return FontAwesome.WARNING.getHtml();
......
157 157
    public void populateTable(Collection<RegistrationDTO> registrations) {
158 158

  
159 159
        BeanContainer<String, RegistrationDTO> registrationItems = new BeanContainer<String, RegistrationDTO>(RegistrationDTO.class);
160
        registrationItems.setBeanIdProperty("internalRegId");
160
        registrationItems.setBeanIdProperty("specificIdentifier");
161 161
        registrationItems.addAll(registrations);
162 162

  
163 163
        grid.setContainerDataSource(buildGeneratedProperties(registrationItems));
......
167 167
        Column typeColumn = grid.addColumn("registrationType");
168 168
        typeColumn.setRenderer(new HtmlRenderer(), new RegistrationTypeConverter());
169 169
        typeColumn.setHeaderCaption("");
170
        typeColumn.setExpandRatio(0);
171 170

  
172 171
        Column statusColumn = grid.addColumn("status");
173
        statusColumn.setExpandRatio(0);
172

  
173
        Column citationColumn = grid.addColumn("citation");
174 174

  
175 175
        Column summaryColumn = grid.addColumn("summary");
176
        summaryColumn.setExpandRatio(1);
177 176

  
178 177
        Column regidColumn = grid.addColumn("registrationId");
179 178
        regidColumn.setHeaderCaption("Id");
180
        regidColumn.setRenderer(new HtmlRenderer(), new UrlStringConverter());
179
        regidColumn.setRenderer(new HtmlRenderer(), new UrlStringConverter("http://pyhcobank.org/"));
181 180

  
182 181
        Column createdColumn = grid.addColumn("created");
183 182
        createdColumn.setRenderer(new DateRenderer(), new JodaDateTimeConverter());
......
199 198
                ))));
200 199
        buttonColumn.setSortable(false);
201 200

  
201
        grid.setFrozenColumnCount(1);
202

  
202 203
    }
203 204

  
204 205
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/RegistrationWorkflowViewBean.java
75 75
    @Override
76 76
    public void makeWorflow(RegistrationType type){
77 77
        switch (type) {
78
        case name:
78
        case NAME:
79 79
            addNameWorkflow();
80 80
            break;
81
        case typification:
81
        case TYPIFICATION:
82 82
            addTypificationWorkflow();
83 83
            break;
84 84
        default:
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/StartRegistrationView.java
38 38
        buttonName.addClickListener(e -> eventBus.publishEvent(new NavigationEvent(
39 39
                RegistrationWorkflowViewBean.NAME,
40 40
                RegistrationWorkflowViewBean.ACTION_NEW,
41
                RegistrationType.name.name()
41
                RegistrationType.NAME.name()
42 42
                )));
43 43
    }
44 44

  
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss
60 60
$hue-offset: hue($status-reference-color);
61 61
$plain-red: adjust-color($status-reference-color, $hue: -1 * $hue-offset);  // red as 0 degree hue
62 62
$status-rejected-color: adjust-color($plain-red, $hue: 0deg);
63
$status-curation-color: adjust-color($plain-red, $hue: 30deg); 
63
$status-curation-color: adjust-color($plain-red, $hue: 35deg); 
64 64
$status-preparation-color: adjust-color($plain-red, $hue: 60deg); 
65 65
$status-published-color: adjust-color($plain-red, $hue: 105deg); 
66 66
$status-ready-color: adjust-color($plain-red, $hue: 180deg);
......
172 172
    
173 173
    
174 174
    #registration-list {
175
        .status-rejected {
175
        .status-REJECTED {
176 176
            td.registrationType, td.status {
177 177
                color: $status-rejected-color;
178 178
            }
179 179
        }
180
        .status-curation {
180
        .status-CURATION {
181 181
            td.registrationType, td.status {
182 182
                color: $status-curation-color;
183 183
            }
184 184
        }
185
        .status-preparation {
185
        .status-PREPARATION {
186 186
            td.registrationType, td.status {
187 187
                color: $status-preparation-color;
188 188
            }
189 189
        }
190
        .status-published {
190
        .status-PUBLISHED {
191 191
            td.registrationType, td.status {
192 192
                color: $status-published-color;
193 193
            }
194 194
        }
195
        .status-ready {
195
        .status-READY {
196 196
            td.registrationType, td.status {
197 197
                color: $status-ready-color;
198 198
            }
......
200 200
    }
201 201

  
202 202

  
203

  
204 203
}

Also available in: Unified diff