Skip to content
Snippets Groups Projects
Commit 49ac8288 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Fixing JSON recursivity

Fixing date handling
parent 406e1e70
Branches
Tags
No related merge requests found
......@@ -19,6 +19,7 @@
package no.nibio.vips.logic.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
......@@ -54,6 +55,7 @@ public class OrganismExternalResource implements Serializable {
private String resourceIdentifier;
@JoinColumn(name = "organism_id", referencedColumnName = "organism_id", insertable = false, updatable = false)
@ManyToOne(optional = false)
@JsonIgnore
private Organism organism;
@JoinColumn(name = "external_resource_id", referencedColumnName = "external_resource_id", insertable = false, updatable = false)
@ManyToOne(optional = false)
......
......@@ -415,5 +415,5 @@ var getObservationRelativeAge = function(feature)
console.info("No obs with id=" + feature.get("observationId"));
return null; // Means invisible
}
return Math.floor((currentDateInMillis - observation.timeOfObservation) / (1000 * 60 * 60 * 24)) + 1;
return Math.floor((currentDateInMillis - getUnixTimestampFromJSON(observation.timeOfObservation)) / (1000 * 60 * 60 * 24)) + 1;
};
\ No newline at end of file
......@@ -146,3 +146,20 @@ function getLocalizedCropCategoryName(cropCategory)
return "Unnamed";
}
/** Ensure that we're able to handle both a unix timestamp and an ISO timestamp
*
* @param {type} ambiguousValue
* @returns {Number}
*/
function getUnixTimestampFromJSON(ambiguousValue)
{
var possibleDateObject = new Date(ambiguousValue);
if(possibleDateObject.getTime() === NaN && typeof parseInt(ambiguousValue) === "number")
{
return parseInt(ambiguousValue);
}
else
{
return possibleDateObject.getTime();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment