+
+ //elevation
+ String elevationStr;
+ if (isNotBlank(gatheringEvent.getAbsoluteElevationText())){
+ elevationStr = gatheringEvent.getAbsoluteElevationText();
+ }else{
+ String text = gatheringEvent.getAbsoluteElevationText();
+ Integer min = gatheringEvent.getAbsoluteElevation();
+ Integer max = gatheringEvent.getAbsoluteElevationMax();
+ elevationStr = DerivedUnitFacade.distanceString(min, max, text, METER);
+ }
+ if (isNotBlank(elevationStr)){
+ result = CdmUtils.concat(", " , result, ALTITUDE_PREFIX);
+ result += elevationStr;
+ }
+
+ //exact locality
+ if (gatheringEvent.getExactLocation() != null){
+ String exactLocation = gatheringEvent.getExactLocation().toSexagesimalString(false, false);
+ result = CdmUtils.concat(", ", result, exactLocation);
+ }
+
+ return result;
+ }
+
+
+ private static String getCache(DeterminationEvent detEvent) {
+ //taxon
+ String taxonStr = null;
+ TaxonName taxonName = detEvent.getTaxonName();
+ TaxonBase<?> taxon = detEvent.getTaxon();
+ if (taxonName != null){
+ taxonStr = taxonName.getTitleCache();
+ }
+ if (isBlank(taxonStr) && taxon != null){
+ taxonStr = taxon.getTitleCache();
+ }
+ if (isBlank(taxonStr)){
+ taxonStr = "no or unlabled taxon";
+ }
+
+
+ //unit
+ SpecimenOrObservationBase<?> unit = detEvent.getIdentifiedUnit();
+ String unitStr;
+ if (unit != null){
+ unitStr = unit.getTitleCache();
+ if (isBlank(unitStr)){
+ unitStr = "Unlabled unit";
+ }
+ }else{
+ unitStr = "no unit";
+ }
+
+ String result = CdmUtils.concat(" determined as ", unitStr, taxonStr);
+
+ return result;
+ }
+
+ private static String getCache(TaxonNode taxonNode) {
+ String result = "";
+ Classification classification = taxonNode.getClassification();
+ if (classification != null){
+ String classificationStr = classification.getName() == null ? "" : classification.getName().getText();
+ result = CdmUtils.concat("" , result, classificationStr);
+ if (isBlank(result)){
+ result = classification.toString();
+ }
+ }
+ String parentStr;
+ TaxonNode parentNode = taxonNode.getParent();
+ if (parentNode == null){
+ parentStr = "no parent";
+ }else{
+ Taxon parentTaxon = parentNode.getTaxon();
+ if (parentTaxon == null){
+ parentStr = "no parent taxon";
+ }else{
+ TaxonName parentName = parentTaxon.getName();
+ if (parentName == null){
+ parentStr = "child of " + parentTaxon.getTitleCache();
+ }else{
+ parentStr = "child of " + parentName.getTitleCache();
+ }
+ }
+ }
+ result = CdmUtils.concat(": ", result, parentStr);
+
+ return result;
+ }
+
+ private static String getCache(TypeDesignationBase<?> designation) {
+ designation = CdmBase.deproxy(designation);
+ TypeDesignationStatusBase<?> status = designation.getTypeStatus();
+ Set<TaxonName> from;
+ IdentifiableEntity<?> to;
+ from = designation.getTypifiedNames();
+ if (designation.isInstanceOf(SpecimenTypeDesignation.class)){
+ to = ((SpecimenTypeDesignation)designation).getTypeSpecimen();
+ }else if (designation.isInstanceOf(NameTypeDesignation.class)){
+ to = ((NameTypeDesignation)designation).getTypeName();
+ }else{
+ throw new RuntimeException("Type Designation class not supported: " + designation.getClass().getName());
+ }
+ String typeLabel = null;
+ if (status != null){
+ Representation typeRepr = status.getPreferredRepresentation(CdmStore.getDefaultLanguage());
+ if (typeRepr != null){
+ typeLabel = typeRepr.getAbbreviatedLabel();
+ }
+ if (isBlank(typeLabel) && typeRepr != null){
+ typeLabel = typeRepr.getLabel();
+ }
+ if (isBlank(typeLabel) ){
+ typeLabel = status.getSymbol();
+ }
+ if (isBlank(typeLabel)){
+ typeLabel = status.getTitleCache();
+ }
+ }
+ if (isBlank(typeLabel)){
+ typeLabel = "->";
+ }
+ String fromString = "";
+ for (TaxonName name : from){
+ CdmUtils.concat(",", fromString, name.getTitleCache());
+ }
+ String result = CdmUtils.concat(" ", new String[]{from == null ? null : fromString,
+ typeLabel, to == null? null : to.getTitleCache()});
+ return result;
+ }
+
+ private static String getCache(RelationshipBase<?, ?, ?> rel) {
+ rel = CdmBase.deproxy(rel);
+ RelationshipTermBase<?> type = rel.getType();
+ IdentifiableEntity<?> from;
+ IdentifiableEntity<?> to;
+ if (rel.isInstanceOf(NameRelationship.class)){
+ from = ((NameRelationship)rel).getFromName();
+ to = ((NameRelationship)rel).getToName();
+ }else if (rel.isInstanceOf(HybridRelationship.class)){
+ from = ((HybridRelationship)rel).getParentName();
+ to = ((HybridRelationship)rel).getHybridName();
+ }else if (rel.isInstanceOf(TaxonRelationship.class)){
+ from = ((TaxonRelationship)rel).getFromTaxon();
+ to = ((TaxonRelationship)rel).getToTaxon();
+ }else{
+ try {
+ Method fromMethod = rel.getClass().getMethod("getRelatedFrom");
+ Method toMethod = rel.getClass().getMethod("getRelatedFrom");
+ fromMethod.setAccessible(true);
+ toMethod.setAccessible(true);
+ from = (IdentifiableEntity<?>)fromMethod.invoke(rel);
+ to = (IdentifiableEntity<?>)toMethod.invoke(rel);
+ } catch (NoSuchMethodException | SecurityException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }