9 |
9 |
package eu.etaxonomy.cdm.vaadin.view.registration;
|
10 |
10 |
|
11 |
11 |
import java.util.ArrayList;
|
|
12 |
import java.util.Arrays;
|
|
13 |
import java.util.Collection;
|
12 |
14 |
import java.util.EnumSet;
|
13 |
15 |
import java.util.HashSet;
|
14 |
16 |
import java.util.List;
|
... | ... | |
30 |
32 |
import com.vaadin.ui.UI;
|
31 |
33 |
|
32 |
34 |
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
|
|
35 |
import eu.etaxonomy.cdm.api.service.dto.TypeDesignationStatusFilter;
|
33 |
36 |
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
34 |
37 |
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
|
|
38 |
import eu.etaxonomy.cdm.model.common.Language;
|
35 |
39 |
import eu.etaxonomy.cdm.model.common.User;
|
36 |
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
|
37 |
40 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
|
38 |
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
39 |
41 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
|
40 |
42 |
import eu.etaxonomy.cdm.model.reference.Reference;
|
41 |
43 |
import eu.etaxonomy.cdm.service.CdmBeanItemContainerFactory;
|
42 |
|
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
|
43 |
44 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
|
44 |
45 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
|
45 |
46 |
import eu.etaxonomy.cdm.vaadin.event.PagingEvent;
|
... | ... | |
69 |
70 |
|
70 |
71 |
private static final long serialVersionUID = 5419947244621450665L;
|
71 |
72 |
|
72 |
|
protected TypeDesignationStatusBase<?> NULL_TYPE_STATUS = NameTypeDesignationStatus.NewInstance("- none -", "- none -", "- none -");
|
|
73 |
// protected TypeDesignationStatusBase<?> NULL_TYPE_STATUS = NameTypeDesignationStatus.NewInstance("- none -", "- none -", "- none -");
|
73 |
74 |
|
74 |
75 |
@Autowired
|
75 |
76 |
private IRegistrationWorkingSetService workingSetService;
|
... | ... | |
116 |
117 |
List<UUID> typeDesignationStatusUUIDS = new ArrayList<>();
|
117 |
118 |
typeDesignationStatusUUIDS.addAll(RegistrationTermLists.NAME_TYPE_DESIGNATION_STATUS_UUIDS());
|
118 |
119 |
typeDesignationStatusUUIDS.addAll(RegistrationTermLists.SPECIMEN_TYPE_DESIGNATION_STATUS_UUIDS());
|
119 |
|
BeanItemContainer<DefinedTermBase> buildTermItemContainer = cdmBeanItemContainerFactory.buildTermItemContainer(typeDesignationStatusUUIDS);
|
120 |
|
buildTermItemContainer.addItem(NULL_TYPE_STATUS);
|
|
120 |
BeanItemContainer<TypeDesignationStatusFilter> buildTermItemContainer = new BeanItemContainer<>(TypeDesignationStatusFilter.class);
|
|
121 |
// TODO use UI.getCurrent().getPage().getWebBrowser().getLocale() or the LocaleContext component to get the preferredLanguage?
|
|
122 |
Collection<TypeDesignationStatusFilter> statusFilterTerms = new ArrayList<>(getRepo().getNameService().getTypeDesignationStatusFilterTerms(Arrays.asList(Language.DEFAULT())));
|
|
123 |
statusFilterTerms.add(TypeDesignationStatusFilter.NULL_ELEMENT);
|
|
124 |
buildTermItemContainer.addAll(statusFilterTerms);
|
121 |
125 |
getView().getStatusTypeFilter().setContainerDataSource(buildTermItemContainer);
|
122 |
|
for(DefinedTermBase dt : buildTermItemContainer.getItemIds()){
|
123 |
|
String caption;
|
124 |
|
if(dt == NULL_TYPE_STATUS){
|
125 |
|
caption = "- NONE -";
|
126 |
|
} else {
|
127 |
|
caption = (dt instanceof SpecimenTypeDesignationStatus ? "ST" : "NT") + " - " + dt.getLabel();
|
128 |
|
}
|
129 |
|
getView().getStatusTypeFilter().setItemCaption(dt, caption);
|
|
126 |
for(TypeDesignationStatusFilter dt : buildTermItemContainer.getItemIds()){
|
|
127 |
getView().getStatusTypeFilter().setItemCaption(dt, dt.toString());
|
130 |
128 |
}
|
|
129 |
buildTermItemContainer.sort(new String[]{"label"}, new boolean[]{true});
|
131 |
130 |
|
132 |
131 |
loadSearchFilterFromSession();
|
133 |
132 |
|
... | ... | |
163 |
162 |
if(filter.typeStatus.isEmpty()){
|
164 |
163 |
filter.typeStatus = null;
|
165 |
164 |
} else {
|
166 |
|
if(filter.typeStatus.contains(NULL_TYPE_STATUS)){
|
167 |
|
Set<TypeDesignationStatusBase> tmpSet = new HashSet<>();
|
|
165 |
if(filter.typeStatus.contains(TypeDesignationStatusFilter.NULL_ELEMENT)){
|
|
166 |
Set<TypeDesignationStatusFilter> tmpSet = new HashSet<>();
|
168 |
167 |
tmpSet.addAll(filter.typeStatus);
|
169 |
|
tmpSet.remove(NULL_TYPE_STATUS);
|
|
168 |
tmpSet.remove(TypeDesignationStatusFilter.NULL_ELEMENT);
|
170 |
169 |
tmpSet.add(null);
|
171 |
170 |
filter.typeStatus = tmpSet;
|
172 |
171 |
}
|
... | ... | |
176 |
175 |
filter.registrationStatus = inProgressStatus;
|
177 |
176 |
}
|
178 |
177 |
|
|
178 |
Set<TypeDesignationStatusBase> typeDesignationStatus = null;
|
|
179 |
if(filter.typeStatus != null){
|
|
180 |
typeDesignationStatus = TypeDesignationStatusFilter.toTypeDesignationStatus(filter.typeStatus);
|
|
181 |
}
|
|
182 |
|
179 |
183 |
Pager<RegistrationDTO> dtoPager = getWorkingSetService().pageDTOs(
|
180 |
184 |
filter.submitter,
|
181 |
185 |
filter.registrationStatus,
|
182 |
186 |
StringUtils.trimToNull(filter.identifierPattern),
|
183 |
187 |
StringUtils.trimToNull(filter.namePattern),
|
184 |
|
filter.typeStatus ,
|
|
188 |
typeDesignationStatus,
|
185 |
189 |
pageSize,
|
186 |
190 |
pageIndex,
|
187 |
191 |
null);
|
... | ... | |
271 |
275 |
filter.submitter = (User) authentication.getPrincipal();
|
272 |
276 |
}
|
273 |
277 |
}
|
274 |
|
filter.typeStatus = (Set<TypeDesignationStatusBase>) getView().getStatusTypeFilter().getValue();
|
|
278 |
filter.typeStatus = (Set<TypeDesignationStatusFilter>) getView().getStatusTypeFilter().getValue();
|
275 |
279 |
EnumSet<RegistrationStatus> registrationStatusFilter = null;
|
276 |
280 |
Object o = getView().getRegistrationStatusFilter().getValue();
|
277 |
281 |
if(o != null){
|
fix #7965 using the TypeDesignationStatusFilter elements to simplify the type filter select