Revision fb292f92
Added by Alex Theys almost 12 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java | ||
---|---|---|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.Iterator; |
5 | 5 |
import java.util.List; |
6 |
import java.util.ListIterator; |
|
6 | 7 |
import java.util.Map; |
7 | 8 |
import java.util.Set; |
8 | 9 |
import org.apache.log4j.Logger; |
... | ... | |
261 | 262 |
if (eventSource == combo_UseCategory) { |
262 | 263 |
if (combo_UseCategory.getSelection() != null) { |
263 | 264 |
boolean isChanged = false; |
264 |
boolean isUnchanged =false;
|
|
265 |
boolean isUseCategoryChanged = false;
|
|
265 | 266 |
if (!getEntity().getStates().isEmpty()) { |
266 |
for (StateData existingStateData : getEntity().getStates()) { |
|
267 |
for (StateData useCategoryStateDataCheck : getEntity().getStates()) { |
|
268 |
Map<Language, LanguageString> modText = useCategoryStateDataCheck.getModifyingText(); |
|
269 |
if(modText.get(CdmStore.getDefaultLanguage()) != null && modText.get(CdmStore.getDefaultLanguage()).getText().equals("Use Category")) { |
|
270 |
if(!useCategoryStateDataCheck.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) { |
|
271 |
isUseCategoryChanged = true; |
|
272 |
} |
|
273 |
|
|
274 |
} |
|
275 |
} |
|
276 |
ListIterator<StateData> itrExistingStates = getEntity().getStates().listIterator(); |
|
277 |
while(itrExistingStates.hasNext()) { |
|
278 |
StateData existingStateData = itrExistingStates.next(); |
|
267 | 279 |
Map<Language, LanguageString> modifyingText = existingStateData |
268 | 280 |
.getModifyingText(); |
269 | 281 |
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) { |
270 | 282 |
if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals("Use Category")) { |
271 | 283 |
isChanged = true; |
272 | 284 |
if(!existingStateData.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) { |
273 |
getEntity().removeState(existingStateData); |
|
285 |
//getEntity().removeState(existingStateData); |
|
286 |
itrExistingStates.remove(); |
|
274 | 287 |
StateData stateData = StateData.NewInstance(combo_UseCategory.getSelection()); |
275 | 288 |
stateData.setState(combo_UseCategory.getSelection()); |
276 | 289 |
//stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage()); |
277 | 290 |
stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use Category"); |
278 |
getEntity().addState(stateData); |
|
291 |
itrExistingStates.add(stateData); |
|
292 |
//getEntity().addState(stateData); |
|
279 | 293 |
} |
294 |
} else if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals("Use SubCategory") && isUseCategoryChanged == true) { |
|
295 |
itrExistingStates.remove(); |
|
280 | 296 |
} |
281 | 297 |
} |
282 | 298 |
} |
... | ... | |
314 | 330 |
if (combo_UseSubCategory.getSelection() != null) { |
315 | 331 |
boolean isChanged = false; |
316 | 332 |
if (!getEntity().getStates().isEmpty()) { |
317 |
for (StateData existingStateData : getEntity().getStates()) { |
|
333 |
ListIterator<StateData> itrExistingStates = getEntity().getStates().listIterator(); |
|
334 |
//for (StateData existingStateData : getEntity().getStates()) { |
|
335 |
while(itrExistingStates.hasNext()) { |
|
336 |
StateData existingStateData = itrExistingStates.next(); |
|
318 | 337 |
Map<Language, LanguageString> modifyingText = existingStateData |
319 | 338 |
.getModifyingText(); |
320 |
|
|
321 | 339 |
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) { |
322 | 340 |
if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals("Use SubCategory")) { |
323 | 341 |
isChanged = true; |
324 |
if(!existingStateData.getState().getTitleCache().equals(combo_UseSubCategory .getSelection().getTitleCache())) { |
|
325 |
getEntity().removeState(existingStateData); |
|
342 |
if(!existingStateData.getState().getTitleCache().equals(combo_UseSubCategory.getSelection().getTitleCache())) { |
|
343 |
//getEntity().removeState(existingStateData); |
|
344 |
itrExistingStates.remove(); |
|
326 | 345 |
StateData stateData = StateData.NewInstance(combo_UseSubCategory.getSelection()); |
327 | 346 |
stateData.setState(combo_UseSubCategory.getSelection()); |
328 |
//stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());
|
|
347 |
//stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage()); |
|
329 | 348 |
stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use SubCategory"); |
330 |
getEntity().addState(stateData); |
|
349 |
itrExistingStates.add(stateData); |
|
350 |
//getEntity().addState(stateData); |
|
331 | 351 |
} |
332 |
} |
|
333 |
|
|
352 |
} |
|
334 | 353 |
} |
335 | 354 |
} |
336 | 355 |
} |
... | ... | |
345 | 364 |
|
346 | 365 |
} else { |
347 | 366 |
if (!getEntity().getStates().isEmpty()) { |
348 |
for (StateData existingStateData : getEntity().getStates()) { |
|
367 |
Iterator<StateData> itrStateData = getEntity().getStates().iterator(); |
|
368 |
while(itrStateData.hasNext()) { |
|
369 |
//for (StateData existingStateData : getEntity().getStates()) { |
|
370 |
StateData existingStateData = itrStateData.next(); |
|
349 | 371 |
Map<Language, LanguageString> modifyingText = existingStateData |
350 | 372 |
.getModifyingText(); |
351 | 373 |
|
352 | 374 |
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) { |
353 | 375 |
if (modifyingText.get(CdmStore.getDefaultLanguage()).getText() == "Use SubCategory") { |
354 |
getEntity().removeState(existingStateData); |
|
376 |
itrStateData.remove(); |
|
377 |
//getEntity().removeState(existingStateData); |
|
355 | 378 |
} |
356 | 379 |
} |
357 | 380 |
} |
... | ... | |
362 | 385 |
if (combo_PlantPart.getSelection() != null) { |
363 | 386 |
boolean isChanged = false; |
364 | 387 |
//MarkerType markerType = MarkerType.NewInstance("Plant Part", "Plant Part", null); |
365 |
Set<Modifier> modifiers = getEntity().getModifiers(); |
|
366 |
if(!modifiers.isEmpty()) { |
|
367 |
for (Modifier modifier : modifiers) { |
|
368 |
if(GetVocabularyType(modifier, "Plant Part")) { |
|
369 |
getEntity().removeModifier(modifier); |
|
370 |
getEntity().addModifier(combo_PlantPart.getSelection()); |
|
371 |
isChanged = true; |
|
372 |
} |
|
388 |
/*Set<Modifier> modifiers = getEntity().getModifiers(); |
|
389 |
List<Modifier> lModifiers = new ArrayList<Modifier>(modifiers); |
|
390 |
ListIterator<Modifier> itrExistingModifiers = lModifiers.listIterator();*/ |
|
391 |
Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator(); |
|
392 |
//if(!modifiers.isEmpty()) { |
|
393 |
//for (Modifier modifier : modifiers) { |
|
394 |
while (itrExistingModifiers.hasNext()) { |
|
395 |
Modifier modifier = itrExistingModifiers.next(); |
|
396 |
if(GetVocabularyType(modifier, "Plant Part")) { |
|
397 |
//getEntity().removeModifier(modifier); |
|
398 |
itrExistingModifiers.remove(); |
|
399 |
//getEntity().addModifier(combo_PlantPart.getSelection()); |
|
400 |
//itrExistingModifiers.add(combo_PlantPart.getSelection()); |
|
401 |
isChanged = true; |
|
402 |
} |
|
373 | 403 |
|
374 |
}
|
|
375 |
} |
|
376 |
if(isChanged == false) { |
|
404 |
} |
|
405 |
//}
|
|
406 |
//if(isChanged == false) {
|
|
377 | 407 |
|
378 |
Modifier plantPart = combo_PlantPart.getSelection();
|
|
379 |
getEntity().addModifier(plantPart);
|
|
380 |
} |
|
408 |
Modifier plantPart = combo_PlantPart.getSelection(); |
|
409 |
getEntity().addModifier(plantPart); |
|
410 |
//}
|
|
381 | 411 |
} else { |
382 | 412 |
Set<Modifier> modifiers = getEntity().getModifiers(); |
383 | 413 |
if(!modifiers.isEmpty()) { |
384 |
for (Modifier modifier : modifiers) { |
|
414 |
Iterator<Modifier> itr = modifiers.iterator(); |
|
415 |
while (itr.hasNext()) { |
|
416 |
Modifier currentMod = itr.next(); |
|
417 |
if(GetVocabularyType(currentMod, "Plant Part")) { |
|
418 |
itr.remove(); |
|
419 |
} |
|
420 |
} |
|
421 |
/*for (Modifier modifier : modifiers) { |
|
385 | 422 |
if(GetVocabularyType(modifier, "Plant Part")) { |
386 | 423 |
getEntity().removeModifier(modifier); |
387 | 424 |
|
388 | 425 |
} |
389 |
} |
|
426 |
}*/
|
|
390 | 427 |
} |
391 | 428 |
|
392 | 429 |
} |
... | ... | |
394 | 431 |
if (eventSource == combo_Country) { |
395 | 432 |
if (combo_Country.getSelection() != null) { |
396 | 433 |
boolean isChanged = false; |
397 |
Set<Modifier> modifiers = getEntity().getModifiers(); |
|
398 |
if(!modifiers.isEmpty()) { |
|
399 |
for (Modifier modifier : modifiers) { |
|
400 |
if(GetVocabularyType(modifier, "Country")) { |
|
401 |
getEntity().removeModifier(modifier); |
|
402 |
getEntity().addModifier(combo_Country.getSelection()); |
|
403 |
isChanged = true; |
|
404 |
} |
|
434 |
//Set<Modifier> modifiers = getEntity().getModifiers(); |
|
435 |
//List<Modifier> lModifiers = new ArrayList<Modifier>(modifiers); |
|
436 |
//ListIterator<Modifier> itrExistingModifiers = lModifiers.listIterator(); |
|
437 |
//ListIterator<Modifier> itrExistingModifiers = new ArrayList(getEntity().getModifiers()).listIterator(); |
|
438 |
//if(!modifiers.isEmpty()) { |
|
439 |
//for (Modifier modifier : modifiers) { |
|
440 |
Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator(); |
|
441 |
while (itrExistingModifiers.hasNext()) { |
|
442 |
Modifier modifier = itrExistingModifiers.next(); |
|
443 |
if(GetVocabularyType(modifier, "Country")) { |
|
444 |
//getEntity().removeModifier(modifier); |
|
445 |
itrExistingModifiers.remove(); |
|
446 |
//getEntity().addModifier(combo_PlantPart.getSelection()); |
|
447 |
//itrExistingModifiers.add(combo_Country.getSelection()); |
|
448 |
isChanged = true; |
|
449 |
} |
|
405 | 450 |
|
406 |
} |
|
407 | 451 |
} |
408 |
if (isChanged == false) { |
|
452 |
//} |
|
453 |
//if (isChanged == false) { |
|
409 | 454 |
Modifier country = combo_Country.getSelection(); |
410 | 455 |
getEntity().addModifier(country); |
411 |
} |
|
456 |
//}
|
|
412 | 457 |
} else { |
413 | 458 |
Set<Modifier> modifiers = getEntity().getModifiers(); |
414 | 459 |
if(!modifiers.isEmpty()) { |
415 |
for (Modifier modifier : modifiers) { |
|
460 |
Iterator<Modifier> itr = modifiers.iterator(); |
|
461 |
while (itr.hasNext()) { |
|
462 |
Modifier currentMod = itr.next(); |
|
463 |
if(GetVocabularyType(currentMod, "Country")) { |
|
464 |
itr.remove(); |
|
465 |
} |
|
466 |
} |
|
467 |
/*for (Modifier modifier : modifiers) { |
|
416 | 468 |
if(GetVocabularyType(modifier, "Country")) { |
417 | 469 |
getEntity().removeModifier(modifier); |
418 | 470 |
|
419 | 471 |
} |
420 |
} |
|
472 |
}*/
|
|
421 | 473 |
} |
422 | 474 |
} |
423 | 475 |
} |
424 | 476 |
if (eventSource == combo_HumanGroup) { |
425 | 477 |
if (combo_HumanGroup.getSelection() != null) { |
426 |
boolean isChanged = false; |
|
427 |
Set<Modifier> modifiers = getEntity().getModifiers(); |
|
428 |
if(!modifiers.isEmpty()) { |
|
429 |
for (Modifier modifier : modifiers) { |
|
430 |
if(GetVocabularyType(modifier, "Human Group")) { |
|
431 |
getEntity().removeModifier(modifier); |
|
432 |
getEntity().addModifier(combo_HumanGroup.getSelection()); |
|
433 |
isChanged = true; |
|
434 |
} |
|
435 |
} |
|
478 |
//boolean toCreate = false; |
|
479 |
boolean isHumanGroupChanged = true; |
|
480 |
/*Set<Modifier> modifiers = getEntity().getModifiers(); |
|
481 |
List<Modifier> lModifiers = new ArrayList<Modifier>(modifiers); |
|
482 |
ListIterator<Modifier> itrExistingModifiers = lModifiers.listIterator();*/ |
|
483 |
|
|
484 |
for (Modifier modToCheck: getEntity().getModifiers()) { |
|
485 |
if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, "Human Group"))) { |
|
486 |
isHumanGroupChanged = false; |
|
487 |
//toCreate = false; |
|
488 |
} |
|
489 |
|
|
490 |
|
|
436 | 491 |
} |
437 |
if(isChanged == false){ |
|
492 |
//if(!modifiers.isEmpty()) { |
|
493 |
//for (Modifier modifier : modifiers) { |
|
494 |
Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator(); |
|
495 |
while (itrExistingModifiers.hasNext()) { |
|
496 |
Modifier modifier = itrExistingModifiers.next(); |
|
497 |
if((GetVocabularyType(modifier, "Human Group") || GetVocabularyType(modifier, "Ethnic Group")) && isHumanGroupChanged) { |
|
498 |
//getEntity().removeModifier(modifier); |
|
499 |
itrExistingModifiers.remove(); |
|
500 |
//getEntity().addModifier(combo_PlantPart.getSelection()); |
|
501 |
//itrExistingModifiers.add(combo_HumanGroup.getSelection()); |
|
502 |
//toCreate = true; |
|
503 |
} |
|
504 |
|
|
505 |
} |
|
506 |
//} |
|
507 |
if(isHumanGroupChanged){ |
|
438 | 508 |
Modifier humanGroup = combo_HumanGroup.getSelection(); |
439 | 509 |
getEntity().addModifier(humanGroup); |
440 | 510 |
} |
... | ... | |
461 | 531 |
if (eventSource == combo_EthnicGroup) { |
462 | 532 |
if (combo_EthnicGroup.getSelection() != null) { |
463 | 533 |
boolean isChanged = false; |
464 |
Set<Modifier> modifiers = getEntity().getModifiers(); |
|
534 |
/*Set<Modifier> modifiers = getEntity().getModifiers(); |
|
535 |
List<Modifier> lModifiers = new ArrayList<Modifier>(modifiers); |
|
536 |
ListIterator<Modifier> itrExistingModifiers = lModifiers.listIterator();*/ |
|
537 |
Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator(); |
|
538 |
//if(!modifiers.isEmpty()) { |
|
539 |
//for (Modifier modifier : modifiers) { |
|
540 |
while (itrExistingModifiers.hasNext()) { |
|
541 |
Modifier modifier = itrExistingModifiers.next(); |
|
542 |
if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) { |
|
543 |
//getEntity().removeModifier(modifier); |
|
544 |
itrExistingModifiers.remove(); |
|
545 |
//getEntity().addModifier(combo_PlantPart.getSelection()); |
|
546 |
//itrExistingModifiers.add(combo_EthnicGroup.getSelection()); |
|
547 |
isChanged = true; |
|
548 |
} |
|
549 |
|
|
550 |
} |
|
551 |
//} |
|
552 |
|
|
553 |
/*Set<Modifier> modifiers = getEntity().getModifiers(); |
|
465 | 554 |
if(!modifiers.isEmpty()) { |
466 | 555 |
for (Modifier modifier : modifiers) { |
467 | 556 |
if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) { |
... | ... | |
470 | 559 |
isChanged = true; |
471 | 560 |
} |
472 | 561 |
} |
473 |
} |
|
474 |
if(isChanged == false) { |
|
562 |
}*/
|
|
563 |
//if(isChanged == false) {
|
|
475 | 564 |
Modifier ethnicGroup = combo_EthnicGroup.getSelection(); |
476 | 565 |
getEntity().addModifier(ethnicGroup); |
477 |
} |
|
566 |
//}
|
|
478 | 567 |
} else { |
479 | 568 |
Set<Modifier> modifiers = getEntity().getModifiers(); |
480 | 569 |
if(!modifiers.isEmpty()) { |
481 |
for (Modifier modifier : modifiers) { |
|
570 |
|
|
571 |
Iterator<Modifier> itr = modifiers.iterator(); |
|
572 |
while (itr.hasNext()) { |
|
573 |
Modifier currentMod = itr.next(); |
|
574 |
if(GetVocabularyType(currentMod, "Ethnic Group")) { |
|
575 |
itr.remove(); |
|
576 |
} |
|
577 |
} |
|
578 |
|
|
579 |
/*for (Modifier modifier : modifiers) { |
|
482 | 580 |
if(GetVocabularyType(modifier, "Ethnic Group")) { |
483 | 581 |
getEntity().removeModifier(modifier); |
484 | 582 |
} |
485 |
} |
|
583 |
}*/
|
|
486 | 584 |
} |
487 | 585 |
} |
488 | 586 |
} |
... | ... | |
517 | 615 |
for (Object object: combo_UseCategory.getControls()) { |
518 | 616 |
if (object == eventSource) { |
519 | 617 |
State selectedUseCategory = combo_UseCategory.getSelection(); |
618 |
//List<State> newSubCategories = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory); |
|
520 | 619 |
if (selectedUseCategory != null) { |
620 |
combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory)); |
|
621 |
|
|
521 | 622 |
if (!getEntity().getStates().isEmpty()) { |
522 | 623 |
Iterator<StateData> itrExistingState = getEntity().getStates().iterator(); |
523 | 624 |
while(itrExistingState.hasNext()) { |
... | ... | |
525 | 626 |
Map<Language, LanguageString> modifyingText = existingStateData.getModifyingText(); |
526 | 627 |
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) { |
527 | 628 |
if (modifyingText.get(CdmStore.getDefaultLanguage()) |
528 |
.getText() == "Use SubCategory") { |
|
529 |
itrExistingState.remove(); |
|
530 |
combo_UseSubCategory.setSelection(null); |
|
531 |
combo_UseSubCategory.getSelection(); |
|
629 |
.getText().equals("Use SubCategory")) { |
|
630 |
//itrExistingState.remove(); |
|
631 |
combo_UseSubCategory.setSelection(stateSelection("Use SubCategory")); |
|
532 | 632 |
} |
533 | 633 |
} |
534 | 634 |
} |
... | ... | |
544 | 644 |
}*/ |
545 | 645 |
} |
546 | 646 |
|
547 |
List<State> newSubCategories = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory); |
|
548 |
combo_UseSubCategory.setTerms(newSubCategories); |
|
647 |
/*List<State> newSubCategories = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory);
|
|
648 |
combo_UseSubCategory.setTerms(newSubCategories);*/
|
|
549 | 649 |
} |
550 | 650 |
} |
551 | 651 |
} |
... | ... | |
554 | 654 |
Modifier selectedHumanGroup = combo_HumanGroup.getSelection(); |
555 | 655 |
if (selectedHumanGroup != null) { |
556 | 656 |
combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), selectedHumanGroup)); |
657 |
if (!getEntity().getModifiers().isEmpty()) { |
|
658 |
Iterator<Modifier> iterModifiers = getEntity().getModifiers().iterator(); |
|
659 |
while (iterModifiers.hasNext()) { |
|
660 |
Modifier existingModifier = iterModifiers.next(); |
|
661 |
if(GetVocabularyType(existingModifier, "Ethnic Group")) { |
|
662 |
combo_EthnicGroup.setSelection(modifierSelection("Ethnic Group")); |
|
663 |
} |
|
664 |
} |
|
665 |
} |
|
666 |
|
|
557 | 667 |
} |
558 | 668 |
} |
559 | 669 |
} |
670 |
//this.refresh(); |
|
560 | 671 |
} |
561 | 672 |
|
562 | 673 |
@Override |
Also available in: Unified diff
AT: committing fixes post Unit Testing