160 |
160 |
return -1;
|
161 |
161 |
}
|
162 |
162 |
|
163 |
|
public Set<DefinedTermBase> getChosenTerms() {
|
164 |
|
VaadinSession session = VaadinSession.getCurrent();
|
165 |
|
UUID vocUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID);
|
166 |
|
// getConversationHolder().getSession();
|
167 |
|
TermVocabulary<DefinedTermBase> voc = CdmSpringContextHelper.getVocabularyService().load(vocUUID, Arrays.asList("terms")); //$NON-NLS-1$
|
168 |
|
// voc = CdmBase.deproxy(voc);
|
169 |
|
return voc.getTerms();
|
170 |
|
}
|
|
163 |
public LazyQueryContainer getAreaDistributionStatusContainer() {
|
|
164 |
List<UUID> nodeUuids = getAllNodes().stream().map(n -> n.getUuid()).collect(Collectors.toCollection(ArrayList::new));
|
|
165 |
List<NamedArea> namedAreas = getNamedAreas();
|
|
166 |
if(namedAreas!=null){
|
|
167 |
QueryFactory factory = new DistributionStatusQueryFactory(this.repo, nodeUuids, namedAreas);
|
|
168 |
QueryDefinition defintion = new DistributionStatusQueryDefinition(namedAreas, true, 50);
|
|
169 |
return new LazyQueryContainer(defintion, factory);
|
|
170 |
}
|
|
171 |
return null;
|
|
172 |
}
|
|
173 |
|
|
174 |
public CdmSQLContainer getSQLContainer() throws SQLException{
|
|
175 |
List<Integer> nodeIds = new ArrayList<>();
|
|
176 |
for (TaxonNode taxonNode : getAllNodes()) {
|
|
177 |
nodeIds.add(taxonNode.getId());
|
|
178 |
}
|
|
179 |
List<NamedArea> namedAreas = getNamedAreas();
|
|
180 |
if(namedAreas!=null){
|
|
181 |
return new CdmSQLContainer(CdmQueryFactory.generateTaxonDistributionQuery(nodeIds, namedAreas));
|
|
182 |
}
|
|
183 |
return null;
|
|
184 |
}
|
171 |
185 |
|
172 |
|
public List<String> getAbbreviatedTermList() {
|
173 |
|
List<NamedArea> terms = getTermSet();
|
174 |
|
List<String> list = new ArrayList<>();
|
175 |
|
for(DefinedTermBase<?> dtb: terms){
|
176 |
|
for(Representation r : dtb.getRepresentations()){
|
177 |
|
list.add(r.getAbbreviatedLabel());
|
178 |
|
}
|
179 |
|
}
|
180 |
|
return list;
|
181 |
|
}
|
|
186 |
public PresenceAbsenceTermContainer getPresenceAbsenceTermContainer() {
|
|
187 |
return PresenceAbsenceTermContainer.getInstance();
|
|
188 |
}
|
|
189 |
|
|
190 |
public List<DescriptionElementBase> listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> setFeature){
|
|
191 |
List<DescriptionElementBase> listDescriptionElementsForTaxon = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
|
192 |
sort(listDescriptionElementsForTaxon);
|
|
193 |
return listDescriptionElementsForTaxon;
|
|
194 |
}
|
|
195 |
|
|
196 |
private List<Distribution> getDistributions(Taxon taxon) {
|
|
197 |
Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
|
|
198 |
List<Distribution> listTaxonDescription = CdmSpringContextHelper.getDescriptionService()
|
|
199 |
.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
|
200 |
return listTaxonDescription;
|
|
201 |
|
|
202 |
}
|
|
203 |
|
|
204 |
private Set<DefinedTermBase> getChosenTerms() {
|
|
205 |
VaadinSession session = VaadinSession.getCurrent();
|
|
206 |
UUID vocUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID);
|
|
207 |
// getConversationHolder().getSession();
|
|
208 |
TermVocabulary<DefinedTermBase> voc = CdmSpringContextHelper.getVocabularyService().load(vocUUID, Arrays.asList("terms")); //$NON-NLS-1$
|
|
209 |
// voc = CdmBase.deproxy(voc);
|
|
210 |
return voc.getTerms();
|
|
211 |
}
|
182 |
212 |
|
183 |
|
public List<NamedArea> getNamedAreas(){
|
|
213 |
private List<NamedArea> getNamedAreas(){
|
184 |
214 |
List<NamedArea> namedAreas = (List<NamedArea>)VaadinSession.getCurrent().getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREAS);
|
185 |
215 |
if(namedAreas!=null && namedAreas.isEmpty()){
|
186 |
|
return getTermSet();
|
|
216 |
return getNamedAreasFromVoc();
|
187 |
217 |
}
|
188 |
218 |
return namedAreas;
|
189 |
219 |
}
|
190 |
220 |
|
191 |
|
private List<NamedArea> getTermSet(){
|
|
221 |
private List<NamedArea> getNamedAreasFromVoc(){
|
192 |
222 |
VaadinSession session = VaadinSession.getCurrent();
|
193 |
223 |
UUID vocUUID = (UUID) session.getAttribute(DistributionEditorUtil.SATTR_SELECTED_AREA_VOCABULARY_UUID);
|
194 |
224 |
TermVocabulary<NamedArea> vocabulary = CdmSpringContextHelper.getVocabularyService().load(vocUUID, Arrays.asList("terms")); //$NON-NLS-1$
|
... | ... | |
203 |
233 |
|
204 |
234 |
}
|
205 |
235 |
|
206 |
|
public HashMap<DescriptionElementBase, Distribution> getDistribution(DefinedTermBase dt, Taxon taxon) {
|
207 |
|
Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
|
208 |
|
List<DescriptionElementBase> listTaxonDescription = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
209 |
|
HashMap<DescriptionElementBase, Distribution> map = null;
|
210 |
|
for(DescriptionElementBase deb : listTaxonDescription){
|
211 |
|
if(deb instanceof Distribution){
|
212 |
|
Distribution db = (Distribution)deb;
|
213 |
|
String titleCache = dt.getTitleCache();
|
214 |
|
if(db.getArea().getTitleCache().equalsIgnoreCase(titleCache)){
|
215 |
|
map = new HashMap<DescriptionElementBase, Distribution>();
|
216 |
|
map.put(deb, db);
|
217 |
|
}
|
218 |
|
}
|
219 |
|
}
|
220 |
|
return map;
|
221 |
|
}
|
222 |
|
|
223 |
|
public List<DescriptionElementBase> listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> setFeature){
|
224 |
|
List<DescriptionElementBase> listDescriptionElementsForTaxon = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
225 |
|
sort(listDescriptionElementsForTaxon);
|
226 |
|
return listDescriptionElementsForTaxon;
|
227 |
|
}
|
228 |
|
|
229 |
|
public List<Distribution> getDistributions(Taxon taxon) {
|
230 |
|
Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
|
231 |
|
List<Distribution> listTaxonDescription = CdmSpringContextHelper.getDescriptionService()
|
232 |
|
.listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
233 |
|
return listTaxonDescription;
|
234 |
|
|
235 |
|
}
|
236 |
|
|
237 |
|
public List<TaxonNode> getAllNodes(){
|
|
236 |
private List<TaxonNode> getAllNodes(){
|
238 |
237 |
List<TaxonNode> allNodes = new ArrayList<>();
|
239 |
238 |
|
240 |
239 |
List<TaxonNode> taxonNodes = getChosenTaxonNodes();
|
... | ... | |
247 |
246 |
return allNodes;
|
248 |
247 |
}
|
249 |
248 |
|
250 |
|
|
251 |
|
public List<TaxonNode> getChosenTaxonNodes() {
|
|
249 |
private List<TaxonNode> getChosenTaxonNodes() {
|
252 |
250 |
VaadinSession session = VaadinSession.getCurrent();
|
253 |
251 |
List<UUID> taxonNodeUUIDs = (List<UUID>) session.getAttribute(DistributionEditorUtil.SATTR_TAXON_NODES_UUID);
|
254 |
252 |
UUID classificationUuid = (UUID)session.getAttribute(DistributionEditorUtil.SATTR_CLASSIFICATION);
|
... | ... | |
265 |
263 |
return Collections.emptyList();
|
266 |
264 |
}
|
267 |
265 |
|
268 |
|
public LazyQueryContainer getAreaDistributionStatusContainer() {
|
269 |
|
List<UUID> nodeUuids = getAllNodes().stream().map(n -> n.getUuid()).collect(Collectors.toCollection(ArrayList::new));
|
270 |
|
List<NamedArea> namedAreas = getNamedAreas();
|
271 |
|
if(namedAreas!=null){
|
272 |
|
QueryFactory factory = new DistributionStatusQueryFactory(this.repo, nodeUuids, namedAreas);
|
273 |
|
QueryDefinition defintion = new DistributionStatusQueryDefinition(namedAreas, true, 50);
|
274 |
|
return new LazyQueryContainer(defintion, factory);
|
275 |
|
}
|
276 |
|
return null;
|
277 |
|
}
|
278 |
|
|
279 |
|
public CdmSQLContainer getSQLContainer() throws SQLException{
|
280 |
|
List<Integer> nodeIds = new ArrayList<>();
|
281 |
|
for (TaxonNode taxonNode : getAllNodes()) {
|
282 |
|
nodeIds.add(taxonNode.getId());
|
283 |
|
}
|
284 |
|
List<NamedArea> namedAreas = getNamedAreas();
|
285 |
|
if(namedAreas!=null){
|
286 |
|
return new CdmSQLContainer(CdmQueryFactory.generateTaxonDistributionQuery(nodeIds, namedAreas));
|
287 |
|
}
|
288 |
|
return null;
|
289 |
|
}
|
290 |
|
|
291 |
|
public PresenceAbsenceTermContainer getPresenceAbsenceTermContainer() {
|
292 |
|
return PresenceAbsenceTermContainer.getInstance();
|
293 |
|
}
|
294 |
|
|
295 |
266 |
protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
|
296 |
267 |
"$", //$NON-NLS-1$
|
297 |
268 |
"elements.*", //$NON-NLS-1$
|
... | ... | |
354 |
325 |
}
|
355 |
326 |
}
|
356 |
327 |
|
|
328 |
/**Unused Methods*/
|
|
329 |
// TODO: Currently unused. Remove?
|
|
330 |
private List<String> getAbbreviatedNamedAreas() {
|
|
331 |
List<NamedArea> terms = getNamedAreasFromVoc();
|
|
332 |
List<String> list = new ArrayList<>();
|
|
333 |
for(DefinedTermBase<?> dtb: terms){
|
|
334 |
for(Representation r : dtb.getRepresentations()){
|
|
335 |
list.add(r.getAbbreviatedLabel());
|
|
336 |
}
|
|
337 |
}
|
|
338 |
return list;
|
|
339 |
}
|
|
340 |
|
|
341 |
// TODO: Currently unused. Remove?
|
|
342 |
private HashMap<DescriptionElementBase, Distribution> getDistribution(DefinedTermBase dt, Taxon taxon) {
|
|
343 |
Set<Feature> setFeature = new HashSet<>(Arrays.asList(Feature.DISTRIBUTION()));
|
|
344 |
List<DescriptionElementBase> listTaxonDescription = CdmSpringContextHelper.getDescriptionService().listDescriptionElementsForTaxon(taxon, setFeature, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
|
345 |
HashMap<DescriptionElementBase, Distribution> map = null;
|
|
346 |
for(DescriptionElementBase deb : listTaxonDescription){
|
|
347 |
if(deb instanceof Distribution){
|
|
348 |
Distribution db = (Distribution)deb;
|
|
349 |
String titleCache = dt.getTitleCache();
|
|
350 |
if(db.getArea().getTitleCache().equalsIgnoreCase(titleCache)){
|
|
351 |
map = new HashMap<DescriptionElementBase, Distribution>();
|
|
352 |
map.put(deb, db);
|
|
353 |
}
|
|
354 |
}
|
|
355 |
}
|
|
356 |
return map;
|
|
357 |
}
|
|
358 |
|
|
359 |
|
357 |
360 |
}
|
refactoring