toSexagesimalString for Point
authorAndreas Müller <a.mueller@bgbm.org>
Fri, 25 Jun 2010 13:43:50 +0000 (13:43 +0000)
committerAndreas Müller <a.mueller@bgbm.org>
Fri, 25 Jun 2010 13:43:50 +0000 (13:43 +0000)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/location/Point.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationBase.java

index c3274e0a0998e25b96bbf75620c01c1cafe6d830..46c59ace15c2d0696148c9b653335b2f77058fa2 100644 (file)
@@ -366,14 +366,16 @@ public class Point implements Cloneable, Serializable {
                }
 
                
-               public String toString(){
+               public String toString(boolean includeEmptySeconds){
                        String result;
                        result = String.valueOf(CdmUtils.Nz(degree)) + "°";
                        if (seconds != null || minutes != null){
                                result += String.valueOf(CdmUtils.Nz(minutes)) + "'";
                        }
-                       if (seconds != null){
-                               result += String.valueOf(CdmUtils.Nz(seconds)) + "\"";  
+                       if (seconds != null ){
+                               if (seconds != 0 || includeEmptySeconds){
+                                       result += String.valueOf(CdmUtils.Nz(seconds)) + "\"";
+                               }
                        }
                        result += direction; 
                        return result;
@@ -385,7 +387,7 @@ public class Point implements Cloneable, Serializable {
        @Transient
        public Sexagesimal getLongitudeSexagesimal (){
                boolean isLatitude = false;
-               return Sexagesimal.valueOf(longitude, isLatitude);
+               return Sexagesimal.valueOf(latitude, isLatitude);
        }
 
        @Transient
@@ -484,6 +486,25 @@ public class Point implements Cloneable, Serializable {
                this.errorRadius = errorRadius;
        }
        
+// **************** toString *************************/
+       
+       
+       /**
+        * Returns a string representation in sexagesimal coordinates.
+        * @return
+        */
+       public String toSexagesimalString(boolean includeEmptySeconds, boolean includeReferenceSystem){
+               String result = "";
+               result += getLatitudeSexagesimal() == null ? "" : getLatitudeSexagesimal().toString(includeEmptySeconds);
+               result = CdmUtils.concat(", ", result, getLongitudeSexagesimal() == null ? "" : getLongitudeSexagesimal().toString(includeEmptySeconds));
+               if (includeReferenceSystem && getReferenceSystem() != null){
+                       String refSys = CdmUtils.isEmpty(getReferenceSystem().getLabel()) ? "" : "(" + getReferenceSystem().getLabel() + ")";
+                       result = CdmUtils.concat(" ", result, refSys);
+               }
+               return result;
+       }
+       
+       
 //*********** CLONE **********************************/        
        
        /** 
index aad2ae4989e296c7b744ffd958726adc02fe2bcc..f4173d943e3d3df1eb689851ffae4cc6c11bdb93 100644 (file)
@@ -168,6 +168,7 @@ public abstract class SpecimenOrObservationBase<S extends IIdentifiableEntityCac
         * @see #getDescriptions()
         * @return
         */
+       @Transient
        public Set<SpecimenDescription> getSpecimenDescriptions(boolean includeImageGallery) {
                Set<SpecimenDescription> specimenDescriptions = new HashSet<SpecimenDescription>();
                for (DescriptionBase descriptionBase : getDescriptions()){
@@ -180,6 +181,23 @@ public abstract class SpecimenOrObservationBase<S extends IIdentifiableEntityCac
                }
                return specimenDescriptions;
        }
+       /**
+        * Returns the {@link SpecimenDescription specimen descriptions} this specimen is part of.
+        * @see #getDescriptions()
+        * @return
+        */
+       @Transient
+       public Set<SpecimenDescription> getSpecimenDescriptionImageGallery() {
+               Set<SpecimenDescription> specimenDescriptions = new HashSet<SpecimenDescription>();
+               for (DescriptionBase descriptionBase : getDescriptions()){
+                       if (descriptionBase.isInstanceOf(SpecimenDescription.class)){
+                               if (descriptionBase.isImageGallery() == true){
+                                       specimenDescriptions.add(descriptionBase.deproxy(descriptionBase, SpecimenDescription.class));
+                               }
+                       }
+               }
+               return specimenDescriptions;
+       }
 
        /**
         * Adds a new description to this specimen or observation