Revision 5454a90f
Added by Andreas Kohlbecker over 7 years ago
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/geo/EditGeoServiceUtilities.java | ||
---|---|---|
38 | 38 |
import com.fasterxml.jackson.databind.type.TypeFactory; |
39 | 39 |
|
40 | 40 |
import eu.etaxonomy.cdm.api.service.ITermService; |
41 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
41 | 42 |
import eu.etaxonomy.cdm.api.service.dto.CondensedDistribution; |
42 | 43 |
import eu.etaxonomy.cdm.api.utility.DescriptionUtility; |
43 | 44 |
import eu.etaxonomy.cdm.common.CdmUtils; |
45 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
44 | 46 |
import eu.etaxonomy.cdm.model.common.Language; |
45 | 47 |
import eu.etaxonomy.cdm.model.common.Representation; |
48 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
46 | 49 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
47 | 50 |
import eu.etaxonomy.cdm.model.description.Distribution; |
48 | 51 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
... | ... | |
99 | 102 |
|
100 | 103 |
private static HashMap<PresenceAbsenceTerm, Color> defaultPresenceAbsenceTermBaseColors = null; |
101 | 104 |
|
105 |
private static List<UUID> presenceAbsenceTermVocabularyUuids = null; |
|
106 |
|
|
102 | 107 |
private static HashMap<PresenceAbsenceTerm, Color> getDefaultPresenceAbsenceTermBaseColors() { |
103 | 108 |
if(defaultPresenceAbsenceTermBaseColors == null){ |
104 | 109 |
defaultPresenceAbsenceTermBaseColors = new HashMap<PresenceAbsenceTerm, Color>(); |
... | ... | |
359 | 364 |
if(status == null){ |
360 | 365 |
status = defaultStatus; |
361 | 366 |
} |
367 |
status = HibernateProxyHelper.deproxy(status, PresenceAbsenceTerm.class); |
|
362 | 368 |
if (! statusList.contains(status)){ |
363 | 369 |
statusList.add(status); |
364 | 370 |
} |
... | ... | |
682 | 688 |
|
683 | 689 |
/** |
684 | 690 |
* @param statusColorJson for example: {@code {"n":"#ff0000","p":"#ffff00"}} |
691 |
* @param vocabularyService TODO |
|
685 | 692 |
* @return |
686 | 693 |
* @throws IOException |
687 | 694 |
* @throws JsonParseException |
688 | 695 |
* @throws JsonMappingException |
689 | 696 |
*/ |
690 |
public static Map<PresenceAbsenceTerm, Color> buildStatusColorMap(String statusColorJson, ITermService termService) throws IOException, JsonParseException, |
|
697 |
public static Map<PresenceAbsenceTerm, Color> buildStatusColorMap(String statusColorJson, ITermService termService, IVocabularyService vocabularyService) throws IOException, JsonParseException,
|
|
691 | 698 |
JsonMappingException { |
692 | 699 |
|
693 | 700 |
Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors = null; |
... | ... | |
700 | 707 |
MapType mapType = typeFactory.constructMapType(HashMap.class, String.class, String.class); |
701 | 708 |
|
702 | 709 |
Map<String,String> statusColorMap = mapper.readValue(statusColorJson, mapType); |
703 |
UUID presenceTermVocabUuid = PresenceAbsenceTerm.NATIVE().getVocabulary().getUuid(); |
|
704 | 710 |
presenceAbsenceTermColors = new HashMap<PresenceAbsenceTerm, Color>(); |
705 | 711 |
PresenceAbsenceTerm paTerm = null; |
706 | 712 |
for(String statusId : statusColorMap.keySet()){ |
707 | 713 |
try { |
708 | 714 |
Color color = Color.decode(statusColorMap.get(statusId)); |
709 |
paTerm = termService.findByIdInVocabulary(statusId, presenceTermVocabUuid, PresenceAbsenceTerm.class); |
|
715 |
// the below loop is a hack for #4522 (custom status colors not working in cyprus portal) |
|
716 |
// remove it once the ticket is solved |
|
717 |
for(UUID vocabUuid : presenceAbsenceTermVocabularyUuids(vocabularyService)) { |
|
718 |
paTerm = termService.findByIdInVocabulary(statusId, vocabUuid, PresenceAbsenceTerm.class); |
|
719 |
if(paTerm != null) { |
|
720 |
break; |
|
721 |
} |
|
722 |
} |
|
710 | 723 |
if(paTerm != null){ |
711 | 724 |
presenceAbsenceTermColors.put(paTerm, color); |
712 | 725 |
} |
... | ... | |
718 | 731 |
return presenceAbsenceTermColors; |
719 | 732 |
} |
720 | 733 |
|
734 |
/** |
|
735 |
* this is a hack for #4522 (custom status colors not working in cyprus portal) |
|
736 |
* remove this method once the ticket is solved |
|
737 |
* |
|
738 |
* @param vocabularyService |
|
739 |
* @return |
|
740 |
*/ |
|
741 |
private static List<UUID> presenceAbsenceTermVocabularyUuids(IVocabularyService vocabularyService) { |
|
742 |
|
|
743 |
if(EditGeoServiceUtilities.presenceAbsenceTermVocabularyUuids == null) { |
|
744 |
|
|
745 |
List<UUID> uuids = new ArrayList<UUID>(); |
|
746 |
// the default as first entry |
|
747 |
UUID presenceTermVocabUuid = PresenceAbsenceTerm.NATIVE().getVocabulary().getUuid(); |
|
748 |
uuids.add(presenceTermVocabUuid); |
|
749 |
|
|
750 |
|
|
751 |
for(TermVocabulary vocab : vocabularyService.findByTermType(TermType.PresenceAbsenceTerm)) { |
|
752 |
if(!uuids.contains(vocab.getUuid())) { |
|
753 |
uuids.add(vocab.getUuid()); |
|
754 |
} |
|
755 |
} |
|
756 |
|
|
757 |
EditGeoServiceUtilities.presenceAbsenceTermVocabularyUuids = uuids; |
|
758 |
} |
|
759 |
|
|
760 |
return EditGeoServiceUtilities.presenceAbsenceTermVocabularyUuids; |
|
761 |
} |
|
762 |
|
|
721 | 763 |
|
722 | 764 |
/** |
723 | 765 |
* @param filteredDistributions |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionListController.java | ||
---|---|---|
39 | 39 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
40 | 40 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
41 | 41 |
import eu.etaxonomy.cdm.api.service.ITermService; |
42 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
42 | 43 |
import eu.etaxonomy.cdm.api.service.description.TransmissionEngineDistribution; |
43 | 44 |
import eu.etaxonomy.cdm.api.service.description.TransmissionEngineDistribution.AggregationMode; |
44 | 45 |
import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO; |
... | ... | |
79 | 80 |
@Autowired |
80 | 81 |
private ITermService termService; |
81 | 82 |
|
83 |
@Autowired |
|
84 |
private IVocabularyService vocabularyService ; |
|
85 |
|
|
82 | 86 |
@Autowired |
83 | 87 |
private ITaxonService taxonService; |
84 | 88 |
|
... | ... | |
258 | 262 |
|
259 | 263 |
EnumSet<InfoPart> parts = EnumSet.copyOf(partSet); |
260 | 264 |
|
261 |
Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors = EditGeoServiceUtilities.buildStatusColorMap(statusColorsString, termService); |
|
265 |
Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors = EditGeoServiceUtilities.buildStatusColorMap(statusColorsString, termService, vocabularyService);
|
|
262 | 266 |
|
263 | 267 |
DistributionInfoDTO dto = geoService.composeDistributionInfoFor(parts, taxonUuid, subAreaPreference, statusOrderPreference, |
264 | 268 |
hideMarkedAreas, omitLevels, presenceAbsenceTermColors, LocaleContext.getLanguages(), getDescriptionInfoInitStrategy(), recipe); |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionPortalController.java | ||
---|---|---|
42 | 42 |
import eu.etaxonomy.cdm.api.service.DistributionTree; |
43 | 43 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
44 | 44 |
import eu.etaxonomy.cdm.api.service.ITermService; |
45 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
45 | 46 |
import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO; |
46 | 47 |
import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO.InfoPart; |
47 | 48 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
... | ... | |
114 | 115 |
@Autowired |
115 | 116 |
private ITermService termService; |
116 | 117 |
|
118 |
@Autowired |
|
119 |
private IVocabularyService vocabularyService ; |
|
120 |
|
|
121 |
|
|
117 | 122 |
@Autowired |
118 | 123 |
private IEditGeoService geoService; |
119 | 124 |
|
... | ... | |
247 | 252 |
|
248 | 253 |
EnumSet<InfoPart> parts = EnumSet.copyOf(partSet); |
249 | 254 |
|
250 |
Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors = EditGeoServiceUtilities.buildStatusColorMap(statusColorsString, termService); |
|
255 |
Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors = EditGeoServiceUtilities.buildStatusColorMap(statusColorsString, termService, vocabularyService);
|
|
251 | 256 |
|
252 | 257 |
DistributionInfoDTO dto = geoService.composeDistributionInfoFor(parts, taxonUuid, subAreaPreference, statusOrderPreference, |
253 | 258 |
hideMarkedAreas, omitLevels, presenceAbsenceTermColors, LocaleContext.getLanguages(), DISTRIBUTION_INFO_INIT_STRATEGY, recipe); |
Also available in: Unified diff
#5479 preliminar solution for user defined presenceAbsence terms vocabularies