1. Made changes so that publication related visualization queries respect the 1.2 ontology's date proeprties & also pre-1.2 onotology data. It first attempts to get date using new property, failing which it sees if date is present in old property & proceeds accordingly.

2. Refactored code for temporal graph vis. Fixed couple of bugs in it.
This commit is contained in:
cdtank 2011-01-19 20:23:22 +00:00
parent c73cb28426
commit f6429af187
10 changed files with 180 additions and 214 deletions

View file

@ -30,11 +30,13 @@ var colorConstantQueue = [ DARK_BLUE, DARK_TURQUOISE,
var freeColors = colorConstantQueue.slice();
var globalDateObject = new Date();
var year = {
min: 1998,
max: 2018,
globalMin: 1995,
globalMax: 2025
min: globalDateObject.getFullYear() - 10,
max: globalDateObject.getFullYear(),
globalMin: globalDateObject.getFullYear() - 10,
globalMax: globalDateObject.getFullYear()
};
var colors = {};

View file

@ -284,9 +284,7 @@ function unStuffZerosFromLineGraphs(jsonObject, year) {
calcZeroLessMinAndMax(jsonObject, year);
var currentMinYear = year.globalMin, currentMaxYear = year.globalMax;
$
.each(
jsonObject,
$.each(jsonObject,
function(key, val) {
var i = 0;
for (i = 0; i < val.data.length; i++) {
@ -340,14 +338,16 @@ function stuffZerosIntoLineGraphs(jsonObject, year) {
var arrayOfMinAndMaxYears = [ year.globalMin, year.globalMax ];
$
.each(
jsonObject,
$.each(jsonObject,
function(key, val) {
var position = arrayOfMinAndMaxYears[0], i = 0;
//console.log(key, val, position, (arrayOfMinAndMaxYears[1] - arrayOfMinAndMaxYears[0]) + 1);
for (i = 0; i < (arrayOfMinAndMaxYears[1] - arrayOfMinAndMaxYears[0]) + 1; i++) {
//console.log("val.data[i]", val.data[i]);
if (val.data[i]) {
if (val.data[i][0] != position
@ -362,6 +362,8 @@ function stuffZerosIntoLineGraphs(jsonObject, year) {
position++;
}
});
//console.log("after stuffing", jsonObject);
}
/**
* During runtime, when the user checks/unchecks a checkbox, the zeroes have to
@ -375,36 +377,27 @@ function stuffZerosIntoLineGraphs(jsonObject, year) {
*/
function calcZeroLessMinAndMax(jsonObject, year) {
var globalMinYear = 5000, globalMaxYear = 0, minYear, maxYear, i = 0;
var validYearsInData = new Array();
$.each(jsonObject, function(key, val) {
for (i = 0; i < val.data.length; i++) {
if (val.data[i][1] != 0) {
minYear = val.data[i][0];
break;
}
}
for (i = val.data.length - 1; i >= 0; i--) {
/*
* TO make sure that,
* 1. Not to consider years that dont have any counts attached to it.
* 2. Not to consider unknown years indicated by "-1".
* */
if (val.data[i][1] != 0 && val.data[i][0] != -1) {
maxYear = val.data[i][0];
break;
validYearsInData.push(val.data[i][0]);
}
}
if (globalMinYear > minYear) {
globalMinYear = minYear;
}
if (globalMaxYear < maxYear) {
globalMaxYear = maxYear;
}
});
year.globalMin = globalMinYear;
year.globalMax = globalMaxYear;
year.globalMin = Math.min.apply(Math, validYearsInData);
year.globalMax = Math.max.apply(Math, validYearsInData);
}
/**
@ -416,86 +409,85 @@ function calcZeroLessMinAndMax(jsonObject, year) {
* @returns [minYear, maxYear]
*/
function calcMinandMaxYears(jsonObject, year) {
var minYear = 5000, maxYear = 0;
var validYearsInData = new Array();
$.each(jsonObject, function(key, val) {
if (minYear > val.data[0][0]) {
minYear = val.data[0][0];
}
if (maxYear < val.data[val.data.length - 1][0]
&& val.data[val.data.length - 1][0] != -1){
maxYear = val.data[val.data.length - 1][0];
}else {
if(val.data.length != 1){
maxYear = val.data[val.data.length - 2][0];
for (i = 0; i < val.data.length; i++) {
/*
* TO make sure that,
* 1. Not to consider years that dont have any counts attached to it.
* 2. Not to consider unknown years indicated by "-1".
* */
if (val.data[i][1] != 0 && val.data[i][0] != -1) {
validYearsInData.push(val.data[i][0]);
}
}
});
year.min = minYear;
year.max = maxYear;
year.min = Math.min.apply(Math, validYearsInData);
year.max = Math.max.apply(Math, validYearsInData);
}
/**
* y is an an object with two properties label and data. data is of the form
* [year,value] This function returns the max of all values.
*
* @param {Object}
* jsonObject
* This function returns the max from the counts of all the entities. Mainly used to
* normalize the width of bar below the line graph, also known as legend row.
* @returns maxCount
*/
function calcMaxOfComparisonParameter(jsonObject) {
var sum = 0, i = 0, maxCount = 0;
function calcMaxOfComparisonParameter(allEntities) {
$.each(jsonObject, function(key, val) {
for (i = 0; i < val.data.length; i++)
sum += val.data[i][1];
var validCountsInData = new Array();
if (maxCount < sum)
maxCount = sum;
sum = 0;
$.each(allEntities, function(key, currentEntity) {
validCountsInData.push(calcSumOfComparisonParameter(currentEntity));
});
// console.log('returning max value' + maxCount);
return maxCount;
return Math.max.apply(Math, validCountsInData);
}
function calcMaxWithinComparisonParameter(jsonObject){
var value = 0, i = 0, maxCount = 0;
var validCountsInData = new Array();
$.each(jsonObject, function(key, val) {
for (i = 0; i < val.data.length; i++){
value = val.data[i][1];
// console.log(val.data[i][1]);
if (maxCount < value){
maxCount = value;
for (i = 0; i < val.data.length; i++) {
/*
* TO make sure that,
* 1. Not to consider years that dont have any counts attached to it.
* 2. Not to consider unknown years indicated by "-1".
* */
if (val.data[i][1] != 0 && val.data[i][0] != -1) {
validCountsInData.push(val.data[i][1]);
}
}
});
//console.log('max value: ' + maxCount);
return maxCount;
return Math.max.apply(Math, validCountsInData);
}
/**
* x is an object and it has two properties label and data. data is a two
* dimensional array of the form [year, value] This function returns the sum of
* all the values.
*
* @param {Object}
* jsonObject
* This is used to find out the sum of all the counts of a particular entity. This is
* especially useful to render the bars below the line graph where it doesnt matter if
* a count has any associated year to it or not.
* @returns sum{values}.
*/
function calcSumOfComparisonParameter(jsonObject) {
function calcSumOfComparisonParameter(entity) {
var sum = 0, i = 0;
for (i = 0; i < jsonObject.data.length; i++) {
sum += jsonObject.data[i][1];
}
var sum = 0;
$.each(entity.data, function(index, data){
sum += this[1];
});
// sum += jsonObject.publicationCount;
return sum;
}
@ -715,7 +707,9 @@ function setOptionsForPagination(object, itemsPerPage, numberOfDisplayEntries,
*
* @jsonRecords the set of entities from which the unknowns have to be removed.
*/
function removeUnknowns(jsonRecords) {
var i = 0, j = 0;
while (j < jsonRecords.length) {
@ -731,9 +725,11 @@ function removeUnknowns(jsonRecords) {
}
j++;
}
}
function insertBackUnknowns(jsonRecords) {
var i = 0, j = 0;
while (j < jsonRecords.length) {
@ -853,7 +849,6 @@ function clearRenderedObjects(){
removeEntityUnChecked(renderedObjects, labelToEntityRecord[$(val).attr("value")]);
removeLegendRow(val);
displayLineGraphs();
//console.log(index);
}
});
@ -907,6 +902,7 @@ function prepareTableForDataTablePagination(jsonData){
table.attr('border', '0');
table.attr('id', 'datatable');
table.css('font-size', '0.9em');
table.css('width', '100%');
var thead = $('<thead>');
var tr = $('<tr>');
@ -1130,8 +1126,9 @@ function setTickSizeOfAxes(){
checkedLabelToEntityRecord[index] = labelToEntityRecord[index];
});
calcMinandMaxYears(checkedLabelToEntityRecord, year);
yearRange = (year.max - year.min);
//calcMinandMaxYears(checkedLabelToEntityRecord, year);
//yearRange = (year.max - year.min);
yearRange = (year.globalMax - year.globalMin);
setLineWidthAndTickSize(yearRange, FlotOptions);
setTickSizeOfYAxis(calcMaxWithinComparisonParameter(checkedLabelToEntityRecord), FlotOptions);

View file

@ -141,9 +141,13 @@ var organizationLabel = '${organizationLabel}';
}
});
//console.log("parse jaon", jQuery.parseJSON(jsonString));
//parse the json object and pass it to loadData
jsonObject.prepare(jQuery.parseJSON(jsonString));
//console.log(jsonObject);
function performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox) {
removeUsedColor(entity);
@ -198,14 +202,6 @@ var organizationLabel = '${organizationLabel}';
prepareTableForDataTablePagination(jsonData);
setEntityLevel();
/*
calcMinandMaxYears(labelToEntityRecord, year);
yearRange = (year.max - year.min);
setLineWidthAndTickSize(yearRange, FlotOptions);
setTickSizeOfYAxis(calcMaxOfComparisonParameter(labelToEntityRecord), FlotOptions);
*/
$(".disabled-checkbox-event-receiver").live("click", function () {
if ($(this).next().is(':disabled')) {
@ -252,7 +248,7 @@ var organizationLabel = '${organizationLabel}';
*/
$.each($("input.if_clicked_on_school"), function(index, checkbox) {
if (index > 2) {
if (index > 0) {
return false;
}

View file

@ -24,6 +24,7 @@ public class QueryFieldLabels {
public static final String DOCUMENT_BLURB = "documentBlurbLit";
public static final String DOCUMENT_DESCRIPTION = "documentDescriptionLit";
public static final String DOCUMENT_PUBLICATION_YEAR = "publicationYearLit";
public static final String DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY = "publicationYearOldLit";
public static final String DOCUMENT_PUBLICATION_YEAR_MONTH = "publicationYearMonthLit";
public static final String DOCUMENT_PUBLICATION_DATE = "publicationDateLit";

View file

@ -376,22 +376,19 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
biboDocument.setDocumentMoniker(documentMonikerNode.toString());
}
RDFNode publicationYearNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR);
if (publicationYearNode != null) {
biboDocument.setPublicationYear(publicationYearNode.toString());
}
RDFNode publicationYearMonthNode = solution.get(QueryFieldLabels
.DOCUMENT_PUBLICATION_YEAR_MONTH);
if (publicationYearMonthNode != null) {
biboDocument.setPublicationYearMonth(publicationYearMonthNode.toString());
}
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode.toString());
}
/*
* This is being used so that date in the data from pre-1.2 ontology can be captured.
* */
RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
if (publicationYearUsing_1_1_PropertyNode != null) {
biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
}
return biboDocument;
}
@ -418,11 +415,8 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") "
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") "
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") "
+ " (str(?publicationYear) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR + ") "
+ " (str(?publicationYearMonth) as ?"
+ QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_MONTH + ") "
+ " (str(?publicationDate) as ?"
+ QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ "WHERE { "
+ "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;"
@ -433,9 +427,9 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . "
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . "
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . "
+ "OPTIONAL { ?document core:year ?publicationYear } . "
+ "OPTIONAL { ?document core:yearMonth ?publicationYearMonth } . "
+ "OPTIONAL { ?document core:date ?publicationDate } . "
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . "
+ " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . "
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . "
+ "OPTIONAL { ?document vitro:description ?documentDescription } "

View file

@ -52,18 +52,17 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ " (str(?SecondaryPositionLabel) as ?SecondaryPositionLabelLit)"
+ " (str(?Document) as ?documentLit) "
+ " (str(?DocumentLabel) as ?documentLabelLit) "
+ " (str(?publicationYear) as ?publicationYearLit) "
+ " (str(?publicationYearMonth) as ?publicationYearMonthLit) "
+ " (str(?publicationDate) as ?publicationDateLit) "
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ " (str(?StartYear) as ?StartYearLit)";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?Document rdf:type bibo:Document ;"
+ " rdfs:label ?DocumentLabel ."
+ "OPTIONAL { ?Document core:year ?publicationYear } ."
+ "OPTIONAL { ?Document core:yearMonth ?publicationYearMonth } ."
+ "OPTIONAL { ?Document core:date ?publicationDate } ."
+ "OPTIONAL { ?Document core:dateTimeValue ?dateTimeValue . "
+ " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?Document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?SecondaryPosition core:startYear ?StartYear } .";
private static String ENTITY_LABEL;
@ -114,26 +113,17 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
biboDocument.setDocumentLabel(documentLabelNode.toString());
}
RDFNode publicationYearNode = solution
.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR);
if (publicationYearNode != null) {
biboDocument.setPublicationYear(publicationYearNode
.toString());
}
RDFNode publicationYearMonthNode = solution
.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_MONTH);
if (publicationYearMonthNode != null) {
biboDocument
.setPublicationYearMonth(publicationYearMonthNode
.toString());
}
RDFNode publicationDateNode = solution
.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode
.toString());
biboDocument.setPublicationDate(publicationDateNode.toString());
}
/*
* This is being used so that date in the data from pre-1.2 ontology can be captured.
* */
RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
if (publicationYearUsing_1_1_PropertyNode != null) {
biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
}
}

View file

@ -198,11 +198,12 @@ public class EntityPublicationCountRequestHandler implements
.entrySet()) {
List<Integer> currentPubYear = new ArrayList<Integer>();
if (pubEntry.getKey().equals(
VOConstants.DEFAULT_PUBLICATION_YEAR))
if (pubEntry.getKey().equals(VOConstants.DEFAULT_PUBLICATION_YEAR)) {
currentPubYear.add(-1);
else
} else {
currentPubYear.add(Integer.parseInt(pubEntry.getKey()));
}
currentPubYear.add(pubEntry.getValue());
yearPubCount.add(currentPubYear);
}

View file

@ -52,21 +52,20 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
private Log log;
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?authorLabelLit) "
+ " (str(?document) as ?documentLit) "
+ " (str(?documentMoniker) as ?documentMonikerLit) "
+ " (str(?documentLabel) as ?documentLabelLit) "
+ " (str(?documentBlurb) as ?documentBlurbLit) "
+ " (str(?publicationYear) as ?publicationYearLit) "
+ " (str(?publicationYearMonth) as ?publicationYearMonthLit) "
+ " (str(?publicationDate) as ?publicationDateLit) "
+ " (str(?documentDescription) as ?documentDescriptionLit) ";
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") "
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") "
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") "
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") "
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") "
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ " (str(?documentDescription) as ?" + QueryFieldLabels.DOCUMENT_DESCRIPTION + ") ";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel ."
+ "OPTIONAL { ?document core:year ?publicationYear } ."
+ "OPTIONAL { ?document core:yearMonth ?publicationYearMonth } ."
+ "OPTIONAL { ?document core:date ?publicationDate } ."
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . "
+ " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } ."
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } ."
+ "OPTIONAL { ?document vitro:description ?documentDescription }";
@ -111,23 +110,19 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
biboDocument.setDocumentDescription(documentDescriptionNode.toString());
}
RDFNode publicationYearNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR);
if (publicationYearNode != null) {
biboDocument.setPublicationYear(publicationYearNode.toString());
}
RDFNode publicationYearMonthNode = solution.get(
QueryFieldLabels
.DOCUMENT_PUBLICATION_YEAR_MONTH);
if (publicationYearMonthNode != null) {
biboDocument.setPublicationYearMonth(publicationYearMonthNode.toString());
}
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode.toString());
}
/*
* This is being used so that date in the data from pre-1.2 ontology can be captured.
* */
RDFNode publicationYearUsing_1_1_PropertyNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY);
if (publicationYearUsing_1_1_PropertyNode != null) {
biboDocument.setPublicationYear(publicationYearUsing_1_1_PropertyNode.toString());
}
/*
* Since we are getting publication count for just one author at a time we need
* to create only one "Individual" instance. We test against the null for "author" to
@ -170,6 +165,8 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}";
// System.out.println(sparqlQuery);
return sparqlQuery;
}

View file

@ -5,6 +5,10 @@ package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
/**
@ -17,7 +21,6 @@ public class BiboDocument extends Individual {
private String documentBlurb;
private String documentDescription;
private String publicationYear;
private String publicationYearMonth;
private String publicationDate;
private String parsedPublicationYear = VOConstants.DEFAULT_PUBLICATION_YEAR;
@ -98,47 +101,43 @@ public class BiboDocument extends Individual {
}
/**
* This method will be called when there is no usable core:year value found
* for the bibo:Document. It will first check & parse core:yearMonth failing
* which it will try core:date
* This method will be called to get the final/inferred year for the publication.
* The 3 choices, in order, are,
* 1. parsed year from xs:DateTime object saved in core:dateTimeValue
* 2. core:year which was property used in vivo 1.1 ontology
* 3. Default Publication Year
* @return
*/
public String getParsedPublicationYear() {
/*
* We are assuming that core:yearMonth has "YYYY-MM" format. This is based
* off of http://www.w3.org/TR/xmlschema-2/#gYearMonth , which is what
* core:yearMonth points to internally.
* */
if (publicationYearMonth != null
&& publicationYearMonth.length() >= VOConstants.NUM_CHARS_IN_YEAR_FORMAT
&& isValidPublicationYear(publicationYearMonth.substring(
0,
VOConstants.NUM_CHARS_IN_YEAR_FORMAT))) {
if (publicationDate != null) {
return publicationYearMonth.substring(0, VOConstants.NUM_CHARS_IN_YEAR_FORMAT);
DateTimeFormatter dateTimeFormat = ISODateTimeFormat.dateHourMinuteSecond();
try {
DateTime dateTime = dateTimeFormat.parseDateTime(publicationDate);
return String.valueOf(dateTime.getYear());
} catch (Exception e) {
return publicationYear != null ? publicationYear : VOConstants.DEFAULT_PUBLICATION_YEAR;
}
if (publicationDate != null
&& publicationDate.length() >= VOConstants.NUM_CHARS_IN_YEAR_FORMAT
&& isValidPublicationYear(publicationDate
.substring(0,
VOConstants.NUM_CHARS_IN_YEAR_FORMAT))) {
return publicationDate.substring(0, VOConstants.NUM_CHARS_IN_YEAR_FORMAT);
}
} else {
/*
* If all else fails return default unknown year identifier
* If all else fails return default unknown year identifier if publicationYear is
* not mentioned.
* */
return VOConstants.DEFAULT_PUBLICATION_YEAR;
return publicationYear != null ? publicationYear : VOConstants.DEFAULT_PUBLICATION_YEAR;
}
}
/*
* This publicationYear value is directly from the data supported by the ontology.
* If this is empty only then use the parsedPublicationYear.
*
* @Deprecated Use getParsedPublicationYear() instead.
* */
@Deprecated
public String getPublicationYear() {
if (publicationYear != null && isValidPublicationYear(publicationYear)) {
return publicationYear;
@ -152,14 +151,6 @@ public class BiboDocument extends Individual {
this.publicationYear = publicationYear;
}
public String getPublicationYearMonth() {
return publicationYearMonth;
}
public void setPublicationYearMonth(String publicationYearMonth) {
this.publicationYearMonth = publicationYearMonth;
}
public String getPublicationDate() {
return publicationDate;
}

View file

@ -53,14 +53,11 @@ public class UtilityFunctions {
* 1. We will be using getPub... multiple times & this will save us duplication of code
* 2. If we change the logic of validity of a pub year we would not have to make
* changes all throughout the codebase.
* 3. We are asking for a publication year & we should get a proper one or NOT at all.
* 3. We are asking for a publicationDate which is captured using the vivo 1.2 ontology
* & if not saved then we are being nice & checking if date is saved using core:year if so
* we use that else we return UNKOWN_YEAR.
* */
String publicationYear;
if (curr.getPublicationYear() != null) {
publicationYear = curr.getPublicationYear();
} else {
publicationYear = curr.getParsedPublicationYear();
}
String publicationYear = curr.getParsedPublicationYear();
if (yearToPublicationCount.containsKey(publicationYear)) {
yearToPublicationCount.put(publicationYear,