Revision b0fdf0ab
Added by Andreas Kohlbecker about 7 years ago
src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java | ||
---|---|---|
28 | 28 |
@Configuration |
29 | 29 |
@ComponentScan(basePackages={ |
30 | 30 |
"eu.etaxonomy.cdm.vaadin", |
31 |
"eu.etaxonomy.vaadin.ui" |
|
31 |
"eu.etaxonomy.vaadin.ui", |
|
32 |
"eu.etaxonomy.cdm.mock" // FIXME remove once mocks are no longer needed |
|
32 | 33 |
}) |
33 | 34 |
@EnableVaadin // this imports VaadinConfiguration |
34 | 35 |
@EnableVaadinSpringNavigation // activate the NavigationManagerBean |
src/main/java/eu/etaxonomy/cdm/mock/Registration.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.mock; |
|
10 |
|
|
11 |
import java.util.HashSet; |
|
12 |
import java.util.Set; |
|
13 |
|
|
14 |
import org.joda.time.DateTime; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
17 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
18 |
import eu.etaxonomy.cdm.model.common.User; |
|
19 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
20 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
|
21 |
|
|
22 |
/** |
|
23 |
* @author a.kohlbecker |
|
24 |
* @since Mar 10, 2017 |
|
25 |
* |
|
26 |
*/ |
|
27 |
public class Registration extends CdmBase { |
|
28 |
|
|
29 |
private static final long serialVersionUID = -7214477130043178680L; |
|
30 |
|
|
31 |
private String identifier; |
|
32 |
|
|
33 |
private String specificIdentifier; //id without http-domain |
|
34 |
|
|
35 |
private DateTime registrationDate; |
|
36 |
|
|
37 |
private RegistrationStatus status; |
|
38 |
|
|
39 |
private Institution institution; |
|
40 |
|
|
41 |
private TaxonNameBase name; |
|
42 |
|
|
43 |
private Set<TypeDesignationBase> typeDesignations = new HashSet<>(); |
|
44 |
|
|
45 |
private Set<Registration> blockedBy = new HashSet<>(); |
|
46 |
|
|
47 |
private User submitter; |
|
48 |
|
|
49 |
static int idAutoincrement = 100000; |
|
50 |
|
|
51 |
|
|
52 |
/** |
|
53 |
* @param name |
|
54 |
*/ |
|
55 |
public Registration() { |
|
56 |
super(); |
|
57 |
status = RegistrationStatus.values()[(int) (Math.random() * RegistrationStatus.values().length)]; |
|
58 |
specificIdentifier = Integer.toString(idAutoincrement++); |
|
59 |
identifier = "http://pyhcobank.org/" + specificIdentifier; |
|
60 |
registrationDate = DateTime.now(); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* @return the identifier |
|
65 |
*/ |
|
66 |
public String getIdentifier() { |
|
67 |
return identifier; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* @param identifier the identifier to set |
|
72 |
*/ |
|
73 |
public void setIdentifier(String identifier) { |
|
74 |
this.identifier = identifier; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* @return the specificIdentifier |
|
79 |
*/ |
|
80 |
public String getSpecificIdentifier() { |
|
81 |
return specificIdentifier; |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* @param specificIdentifier the specificIdentifier to set |
|
86 |
*/ |
|
87 |
public void setSpecificIdentifier(String specificIdentifier) { |
|
88 |
this.specificIdentifier = specificIdentifier; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* @return the registrationDate |
|
93 |
*/ |
|
94 |
public org.joda.time.DateTime getRegistrationDate() { |
|
95 |
return registrationDate; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* @param registrationDate the registrationDate to set |
|
100 |
*/ |
|
101 |
public void setRegistrationDate(org.joda.time.DateTime registrationDate) { |
|
102 |
this.registrationDate = registrationDate; |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* @return the status |
|
107 |
*/ |
|
108 |
public RegistrationStatus getStatus() { |
|
109 |
return status; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* @param status the status to set |
|
114 |
*/ |
|
115 |
public void setStatus(RegistrationStatus status) { |
|
116 |
this.status = status; |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* @return the institution |
|
121 |
*/ |
|
122 |
public Institution getInstitution() { |
|
123 |
return institution; |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* @param institution the institution to set |
|
128 |
*/ |
|
129 |
public void setInstitution(Institution institution) { |
|
130 |
this.institution = institution; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* @return the name |
|
135 |
*/ |
|
136 |
public TaxonNameBase getName() { |
|
137 |
return name; |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* @param name the name to set |
|
142 |
*/ |
|
143 |
public void setName(TaxonNameBase name) { |
|
144 |
this.name = name; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* @return the submitter |
|
149 |
*/ |
|
150 |
public User getSubmitter() { |
|
151 |
return submitter; |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* @param submitter the submitter to set |
|
156 |
*/ |
|
157 |
public void setSubmitter(User submitter) { |
|
158 |
this.submitter = submitter; |
|
159 |
} |
|
160 |
|
|
161 |
public boolean addTypeDesignationBase(TypeDesignationBase typeDesignationBase){ |
|
162 |
return typeDesignations.add(typeDesignationBase); |
|
163 |
} |
|
164 |
|
|
165 |
public boolean addBlockedBy(Registration registration){ |
|
166 |
return blockedBy.add(registration); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* @return the typeDesignations |
|
171 |
*/ |
|
172 |
public Set<TypeDesignationBase> getTypeDesignations() { |
|
173 |
return typeDesignations; |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* @return the blockedBy |
|
178 |
*/ |
|
179 |
public Set<Registration> getBlockedBy() { |
|
180 |
return blockedBy; |
|
181 |
} |
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
} |
src/main/java/eu/etaxonomy/cdm/mock/RegistrationService.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.mock; |
|
10 |
|
|
11 |
import java.util.Collection; |
|
12 |
import java.util.HashMap; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Map; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import javax.annotation.PostConstruct; |
|
18 |
|
|
19 |
import org.springframework.beans.factory.annotation.Autowired; |
|
20 |
import org.springframework.beans.factory.annotation.Qualifier; |
|
21 |
import org.springframework.stereotype.Component; |
|
22 |
|
|
23 |
import eu.etaxonomy.cdm.api.application.CdmRepository; |
|
24 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
25 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
|
26 |
|
|
27 |
/** |
|
28 |
* @author a.kohlbecker |
|
29 |
* @since Mar 10, 2017 |
|
30 |
* |
|
31 |
*/ |
|
32 |
@Component("registrationServiceMock") |
|
33 |
public class RegistrationService { |
|
34 |
|
|
35 |
@Autowired |
|
36 |
@Qualifier("cdmRepository") |
|
37 |
private CdmRepository repo; |
|
38 |
|
|
39 |
private Map<UUID, Registration> registrationsByUUID = new HashMap<>(); |
|
40 |
private Map<String, Registration> registrationsByRegID = new HashMap<>(); |
|
41 |
|
|
42 |
public RegistrationService() { |
|
43 |
} |
|
44 |
|
|
45 |
@PostConstruct |
|
46 |
protected void init(){ |
|
47 |
List<TaxonNameBase> names = repo.getNameService().list(TaxonNameBase.class, 20, 0, null, null); |
|
48 |
names.forEach( |
|
49 |
name -> { |
|
50 |
Registration reg = new Registration(); |
|
51 |
reg.setName(name); |
|
52 |
registrationsByUUID.put(reg.getUuid(), reg); |
|
53 |
registrationsByRegID.put(reg.getSpecificIdentifier(), reg); |
|
54 |
} |
|
55 |
); |
|
56 |
List<TypeDesignationBase> tds = repo.getNameService().getAllTypeDesignations(20, 0); |
|
57 |
tds.forEach( |
|
58 |
type -> { |
|
59 |
Registration reg = new Registration(); |
|
60 |
reg.addTypeDesignationBase(type); |
|
61 |
registrationsByUUID.put(reg.getUuid(), reg); |
|
62 |
registrationsByRegID.put(reg.getSpecificIdentifier(), reg); |
|
63 |
} |
|
64 |
); |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
* {@inheritDoc} |
|
71 |
*/ |
|
72 |
public Registration load(UUID uuid) { |
|
73 |
return registrationsByUUID.get(uuid); |
|
74 |
} |
|
75 |
|
|
76 |
public Collection<Registration> list(){ |
|
77 |
return registrationsByUUID.values(); |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
/** |
|
82 |
* @param registrationID |
|
83 |
* @return |
|
84 |
*/ |
|
85 |
public Registration loadByRegistrationID(Integer registrationID) { |
|
86 |
return registrationsByRegID.get(registrationID); |
|
87 |
} |
|
88 |
|
|
89 |
|
|
90 |
} |
src/main/java/eu/etaxonomy/cdm/mock/RegistrationStatus.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.mock; |
|
10 |
|
|
11 |
public enum RegistrationStatus { |
|
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. |
|
18 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/event/phycobank/RegistrationStartEvent.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.event.phycobank; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author a.kohlbecker |
|
15 |
* @since Mar 3, 2017 |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class RegistrationStartEvent { |
|
19 |
|
|
20 |
private RegistrationType type; |
|
21 |
|
|
22 |
RegistrationStartEvent(RegistrationType type){ |
|
23 |
this.type = type; |
|
24 |
} |
|
25 |
|
|
26 |
/** |
|
27 |
* @return the type |
|
28 |
*/ |
|
29 |
public RegistrationType getType() { |
|
30 |
return type; |
|
31 |
} |
|
32 |
|
|
33 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/event/phycobank/RegistrationWorkflowEvent.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.event.phycobank; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author a.kohlbecker |
|
15 |
* @since Mar 3, 2017 |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class RegistrationWorkflowEvent { |
|
19 |
|
|
20 |
private RegistrationType type = null; |
|
21 |
private Action action; |
|
22 |
private Integer registrationID = null; |
|
23 |
|
|
24 |
public RegistrationWorkflowEvent(int registrationID){ |
|
25 |
this.action = Action.open; |
|
26 |
this.registrationID = registrationID; |
|
27 |
} |
|
28 |
|
|
29 |
public RegistrationWorkflowEvent(RegistrationType type){ |
|
30 |
this.type = type; |
|
31 |
this.action = Action.start; |
|
32 |
} |
|
33 |
|
|
34 |
/** |
|
35 |
* @return the type |
|
36 |
*/ |
|
37 |
public RegistrationType getType() { |
|
38 |
return type; |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* @return the action |
|
43 |
*/ |
|
44 |
public Action getAction() { |
|
45 |
return action; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* @return the registrationID |
|
50 |
*/ |
|
51 |
public Integer getRegistrationID() { |
|
52 |
return registrationID; |
|
53 |
} |
|
54 |
|
|
55 |
public boolean isStart() { |
|
56 |
return action.equals(Action.start); |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
enum Action { |
|
61 |
start, open; |
|
62 |
} |
|
63 |
|
|
64 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/ListPresenter.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Collection; |
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 | 13 |
|
16 |
import org.joda.time.DateTime;
|
|
14 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
17 | 15 |
|
18 | 16 |
import com.vaadin.spring.annotation.SpringComponent; |
19 | 17 |
import com.vaadin.spring.annotation.ViewScope; |
20 | 18 |
|
21 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
19 |
import eu.etaxonomy.cdm.mock.Registration; |
|
20 |
import eu.etaxonomy.cdm.mock.RegistrationService; |
|
22 | 21 |
import eu.etaxonomy.cdm.vaadin.view.phycobank.ListView; |
23 | 22 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
24 | 23 |
|
... | ... | |
31 | 30 |
@ViewScope |
32 | 31 |
public class ListPresenter extends AbstractPresenter<ListView> { |
33 | 32 |
|
33 |
@Autowired |
|
34 |
private RegistrationService serviceMock; |
|
35 |
|
|
34 | 36 |
@Override |
35 | 37 |
public void onViewEnter() { |
36 | 38 |
super.onViewEnter(); |
... | ... | |
41 | 43 |
* @return |
42 | 44 |
*/ |
43 | 45 |
private Collection<RegistrationDTO> listRegistrations() { |
44 |
List<TaxonNameBase> names = getRepo().getNameService().list(TaxonNameBase.class, 500, 0, null, null);
|
|
45 |
Collection<RegistrationDTO> dtos = new ArrayList<>(names.size());
|
|
46 |
names.forEach(name -> { dtos.add(new RegistrationDTO(name)); });
|
|
46 |
Collection<Registration> registrations = serviceMock.list();
|
|
47 |
Collection<RegistrationDTO> dtos = new ArrayList<>(registrations.size());
|
|
48 |
registrations.forEach(reg -> { dtos.add(new RegistrationDTO(reg)); });
|
|
47 | 49 |
return dtos; |
48 | 50 |
} |
49 | 51 |
|
50 |
private static int idAutoincrement = 100000; |
|
51 |
|
|
52 |
public class RegistrationDTO{ |
|
53 |
|
|
54 |
private String summary; |
|
55 |
private UUID registeredEntityUuid; |
|
56 |
|
|
57 |
private RegistrationType registrationType; |
|
58 |
private RegistrationStatus status; |
|
59 |
private String registrationId; |
|
60 |
private String internalRegId; |
|
61 |
private DateTime registrationDate = null; |
|
62 |
private DateTime created = null; |
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
/** |
|
67 |
* @param name |
|
68 |
*/ |
|
69 |
public RegistrationDTO(TaxonNameBase name) { |
|
70 |
summary = name.getTitleCache(); |
|
71 |
registeredEntityUuid = name.getUuid(); |
|
72 |
|
|
73 |
registrationType = RegistrationType.values()[(int) (Math.random() * RegistrationType.values().length)]; |
|
74 |
status = RegistrationStatus.values()[(int) (Math.random() * RegistrationStatus.values().length)]; |
|
75 |
internalRegId = Integer.toString(ListPresenter.idAutoincrement++); |
|
76 |
registrationId = "http://pyhcobank.org/" + internalRegId; |
|
77 |
created = DateTime.now(); |
|
78 |
|
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* @return the summary |
|
83 |
*/ |
|
84 |
public String getSummary() { |
|
85 |
return summary; |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
/** |
|
90 |
* @param summary the summary to set |
|
91 |
*/ |
|
92 |
public void setSummary(String summary) { |
|
93 |
this.summary = summary; |
|
94 |
} |
|
95 |
|
|
96 |
|
|
97 |
/** |
|
98 |
* @return the registrationType |
|
99 |
*/ |
|
100 |
public RegistrationType getRegistrationType() { |
|
101 |
return registrationType; |
|
102 |
} |
|
103 |
|
|
104 |
|
|
105 |
/** |
|
106 |
* @param registrationType the registrationType to set |
|
107 |
*/ |
|
108 |
public void setRegistrationType(RegistrationType registrationType) { |
|
109 |
this.registrationType = registrationType; |
|
110 |
} |
|
111 |
|
|
112 |
|
|
113 |
/** |
|
114 |
* @return the status |
|
115 |
*/ |
|
116 |
public RegistrationStatus getStatus() { |
|
117 |
return status; |
|
118 |
} |
|
119 |
|
|
120 |
|
|
121 |
/** |
|
122 |
* @param status the status to set |
|
123 |
*/ |
|
124 |
public void setStatus(RegistrationStatus status) { |
|
125 |
this.status = status; |
|
126 |
} |
|
127 |
|
|
128 |
|
|
129 |
/** |
|
130 |
* @return the registrationId |
|
131 |
*/ |
|
132 |
public String getRegistrationId() { |
|
133 |
return registrationId; |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
/** |
|
138 |
* @param registrationId the registrationId to set |
|
139 |
*/ |
|
140 |
public void setRegistrationId(String registrationId) { |
|
141 |
this.registrationId = registrationId; |
|
142 |
} |
|
143 |
|
|
144 |
|
|
145 |
/** |
|
146 |
* @return the internalRegId |
|
147 |
*/ |
|
148 |
public String getInternalRegId() { |
|
149 |
return internalRegId; |
|
150 |
} |
|
151 |
|
|
152 |
|
|
153 |
/** |
|
154 |
* @param internalRegId the internalRegId to set |
|
155 |
*/ |
|
156 |
public void setInternalRegId(String internalRegId) { |
|
157 |
this.internalRegId = internalRegId; |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
/** |
|
162 |
* @return the registeredEntityUuid |
|
163 |
*/ |
|
164 |
public UUID getRegisteredEntityUuid() { |
|
165 |
return registeredEntityUuid; |
|
166 |
} |
|
167 |
|
|
168 |
|
|
169 |
/** |
|
170 |
* @param registeredEntityUuid the registeredEntityUuid to set |
|
171 |
*/ |
|
172 |
public void setRegisteredEntityUuid(UUID registeredEntityUuid) { |
|
173 |
this.registeredEntityUuid = registeredEntityUuid; |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* @return the registrationDate |
|
178 |
*/ |
|
179 |
public DateTime getRegistrationDate() { |
|
180 |
return registrationDate; |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* @return the created |
|
185 |
*/ |
|
186 |
public DateTime getCreated() { |
|
187 |
return created; |
|
188 |
} |
|
189 |
|
|
190 |
} |
|
191 |
|
|
192 |
public enum RegistrationStatus { |
|
193 |
|
|
194 |
preparation,// A new record which is being edited by the Author |
|
195 |
curation, //A record ready for the curator to be validated. |
|
196 |
ready, //The record has passed the validation by the curator and is ready for publication. |
|
197 |
published, //The name or typification has finally been published. |
|
198 |
rejected //The registration has been rejected, the process is aborted and the record is preserved. |
|
199 |
} |
|
200 |
|
|
201 | 52 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/RegistrationDTO.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.presenter.phycobank; |
|
10 |
|
|
11 |
import org.joda.time.DateTime; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.mock.Registration; |
|
14 |
import eu.etaxonomy.cdm.mock.RegistrationStatus; |
|
15 |
|
|
16 |
public class RegistrationDTO{ |
|
17 |
|
|
18 |
private String summary = ""; |
|
19 |
|
|
20 |
private RegistrationType registrationType; |
|
21 |
|
|
22 |
private Registration reg; |
|
23 |
|
|
24 |
static int idAutoincrement = 100000; |
|
25 |
|
|
26 |
/** |
|
27 |
* @param reg |
|
28 |
*/ |
|
29 |
public RegistrationDTO(Registration reg) { |
|
30 |
|
|
31 |
this.reg = reg; |
|
32 |
|
|
33 |
registrationType = RegistrationType.from(reg); |
|
34 |
if(registrationType.isName()){ |
|
35 |
summary = reg.getName().getTitleCache(); |
|
36 |
} else if(registrationType.isTypification()){ |
|
37 |
StringBuffer sb = new StringBuffer(); |
|
38 |
reg.getTypeDesignations().forEach(td -> sb.append(td.toString()).append(' ')); |
|
39 |
summary = sb.toString(); |
|
40 |
} else { |
|
41 |
summary = "- INVALID REGISTRATION -"; |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* @return the summary |
|
47 |
*/ |
|
48 |
public String getSummary() { |
|
49 |
return summary; |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
/** |
|
54 |
* @return the registrationType |
|
55 |
*/ |
|
56 |
public RegistrationType getRegistrationType() { |
|
57 |
return registrationType; |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
/** |
|
62 |
* @return the status |
|
63 |
*/ |
|
64 |
public RegistrationStatus getStatus() { |
|
65 |
return reg.getStatus(); |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
* @return the registrationId |
|
71 |
*/ |
|
72 |
public String getRegistrationId() { |
|
73 |
return reg.getIdentifier(); |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
/** |
|
78 |
* @return the internalRegId |
|
79 |
*/ |
|
80 |
public String getInternalRegId() { |
|
81 |
return reg.getSpecificIdentifier(); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* @return the registrationDate |
|
86 |
*/ |
|
87 |
public DateTime getRegistrationDate() { |
|
88 |
return reg.getRegistrationDate(); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* @return the created |
|
93 |
*/ |
|
94 |
public DateTime getCreated() { |
|
95 |
return reg.getCreated(); |
|
96 |
} |
|
97 |
|
|
98 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/RegistrationType.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.presenter.phycobank; |
10 | 10 |
|
11 |
import eu.etaxonomy.cdm.mock.Registration; |
|
12 |
|
|
11 | 13 |
/** |
12 | 14 |
* @author a.kohlbecker |
13 | 15 |
* @since Mar 3, 2017 |
... | ... | |
15 | 17 |
*/ |
16 | 18 |
public enum RegistrationType { |
17 | 19 |
|
18 |
name, typification; |
|
20 |
name, typification, invalid; |
|
21 |
|
|
22 |
/** |
|
23 |
* @param reg |
|
24 |
* @return |
|
25 |
*/ |
|
26 |
public static RegistrationType from(Registration reg) { |
|
27 |
if(reg.getName() != null){ |
|
28 |
return name; |
|
29 |
} |
|
30 |
if(reg.getTypeDesignations().size() > 0){ |
|
31 |
return typification; |
|
32 |
} |
|
33 |
return invalid; |
|
34 |
} |
|
35 |
|
|
36 |
/** |
|
37 |
* @return |
|
38 |
*/ |
|
39 |
public boolean isName() { |
|
40 |
return name.equals(this); |
|
41 |
|
|
42 |
} |
|
43 |
/** |
|
44 |
* @return |
|
45 |
*/ |
|
46 |
public boolean isTypification() { |
|
47 |
return typification.equals(this); |
|
48 |
} |
|
19 | 49 |
|
20 | 50 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/RegistrationWorkflowPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.presenter.phycobank; |
10 | 10 |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
11 | 12 |
import org.springframework.context.event.EventListener; |
12 | 13 |
|
13 | 14 |
import com.vaadin.spring.annotation.SpringComponent; |
14 | 15 |
import com.vaadin.spring.annotation.ViewScope; |
15 | 16 |
|
16 |
import eu.etaxonomy.cdm.vaadin.event.phycobank.RegistrationStartEvent; |
|
17 |
import eu.etaxonomy.cdm.mock.Registration; |
|
18 |
import eu.etaxonomy.cdm.mock.RegistrationService; |
|
19 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
20 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
|
21 |
import eu.etaxonomy.cdm.vaadin.event.phycobank.RegistrationWorkflowEvent; |
|
17 | 22 |
import eu.etaxonomy.cdm.vaadin.view.phycobank.RegistrationWorkflowView; |
18 | 23 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
19 | 24 |
|
... | ... | |
26 | 31 |
@ViewScope |
27 | 32 |
public class RegistrationWorkflowPresenter extends AbstractPresenter<RegistrationWorkflowView> { |
28 | 33 |
|
29 |
private RegistrationType registrationType = null; |
|
30 | 34 |
|
35 |
@Autowired |
|
36 |
private RegistrationService serviceMock; |
|
37 |
|
|
38 |
private Registration registration; |
|
31 | 39 |
|
32 | 40 |
/** |
33 | 41 |
* |
... | ... | |
36 | 44 |
} |
37 | 45 |
|
38 | 46 |
@EventListener |
39 |
protected void onRegistrationStartEvent(RegistrationStartEvent e){ |
|
40 |
this.registrationType = e.getType(); |
|
41 |
getView().getTitle().setValue(getView().getTitle().getValue() + " " + registrationType.name()); |
|
47 |
protected void onRegistrationStartEvent(RegistrationWorkflowEvent e){ |
|
48 |
|
|
49 |
if(e.isStart()) { |
|
50 |
registration = new Registration(); |
|
51 |
registration.setName(TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES())); |
|
52 |
} else { |
|
53 |
registration = serviceMock.loadByRegistrationID(e.getRegistrationID()); |
|
54 |
} |
|
55 |
if(registration != null){ |
|
56 |
getView().getTitle().setValue(getView().getTitle().getValue() + " " + registrationType().name()); |
|
57 |
getView().makeWorflow(registrationType()); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* @return |
|
63 |
*/ |
|
64 |
private RegistrationType registrationType() { |
|
65 |
return RegistrationType.from(registration); |
|
42 | 66 |
} |
43 | 67 |
|
44 | 68 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/ListView.java | ||
---|---|---|
11 | 11 |
import java.util.Collection; |
12 | 12 |
|
13 | 13 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.ListPresenter; |
14 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.ListPresenter.RegistrationDTO;
|
|
14 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationDTO; |
|
15 | 15 |
import eu.etaxonomy.vaadin.mvp.ApplicationView; |
16 | 16 |
|
17 | 17 |
/** |
... | ... | |
26 | 26 |
*/ |
27 | 27 |
void populateTable(Collection<RegistrationDTO> registrations); |
28 | 28 |
|
29 |
|
|
29 | 30 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/ListViewBean.java | ||
---|---|---|
35 | 35 |
import com.vaadin.ui.themes.ValoTheme; |
36 | 36 |
|
37 | 37 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.ListPresenter; |
38 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.ListPresenter.RegistrationDTO;
|
|
38 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationDTO; |
|
39 | 39 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
40 | 40 |
import eu.etaxonomy.cdm.vaadin.util.JodaDateTimeConverter; |
41 | 41 |
import eu.etaxonomy.cdm.vaadin.util.UrlStringConverter; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/RegistrationWorkflowView.java | ||
---|---|---|
13 | 13 |
import com.vaadin.ui.CssLayout; |
14 | 14 |
import com.vaadin.ui.Label; |
15 | 15 |
|
16 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
|
16 | 17 |
import eu.etaxonomy.vaadin.mvp.ApplicationView; |
17 | 18 |
|
18 | 19 |
/** |
... | ... | |
38 | 39 |
@Deprecated |
39 | 40 |
void openNameEditor(UUID nameUuid); |
40 | 41 |
|
42 |
public void makeWorflow(RegistrationType type); |
|
43 |
|
|
41 | 44 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/phycobank/RegistrationWorkflowViewBean.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.vaadin.component.phycobank.RegistrationWorkflowComponent; |
22 | 22 |
import eu.etaxonomy.cdm.vaadin.component.phycobank.WorkflowSteps; |
23 |
import eu.etaxonomy.cdm.vaadin.event.phycobank.RegistrationWorkflowEvent; |
|
23 | 24 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType; |
24 | 25 |
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationWorkflowPresenter; |
25 | 26 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
... | ... | |
61 | 62 |
if(params[0].equals(ACTION_NEW)) { |
62 | 63 |
regType = RegistrationType.valueOf(params[1]); |
63 | 64 |
design.getTitle().setValue(design.getTitle().getValue() + " " + regType.name() + " ..."); |
64 |
makeWorflow(regType); |
|
65 |
eventBus.publishEvent(new RegistrationWorkflowEvent(regType)); |
|
66 |
|
|
65 | 67 |
} else if( params[0].equals(ACTION_EDIT)) { |
66 | 68 |
design.getTitle().setValue(design.getTitle().getValue() + " " + params[1]); |
69 |
eventBus.publishEvent(new RegistrationWorkflowEvent(Integer.parseInt(params[1]))); |
|
67 | 70 |
} |
68 | 71 |
|
69 | 72 |
} |
70 | 73 |
} |
71 | 74 |
|
72 |
private void makeWorflow(RegistrationType type){ |
|
75 |
@Override |
|
76 |
public void makeWorflow(RegistrationType type){ |
|
73 | 77 |
switch (type) { |
74 | 78 |
case name: |
75 | 79 |
addNameWorkflow(); |
Also available in: Unified diff
ref #6169 mock service for registrations