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 freeColors = colorConstantQueue.slice();
var globalDateObject = new Date();
var year = { var year = {
min: 1998, min: globalDateObject.getFullYear() - 10,
max: 2018, max: globalDateObject.getFullYear(),
globalMin: 1995, globalMin: globalDateObject.getFullYear() - 10,
globalMax: 2025 globalMax: globalDateObject.getFullYear()
}; };
var colors = {}; var colors = {};

View file

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

View file

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

View file

@ -24,6 +24,7 @@ public class QueryFieldLabels {
public static final String DOCUMENT_BLURB = "documentBlurbLit"; public static final String DOCUMENT_BLURB = "documentBlurbLit";
public static final String DOCUMENT_DESCRIPTION = "documentDescriptionLit"; public static final String DOCUMENT_DESCRIPTION = "documentDescriptionLit";
public static final String DOCUMENT_PUBLICATION_YEAR = "publicationYearLit"; 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_YEAR_MONTH = "publicationYearMonthLit";
public static final String DOCUMENT_PUBLICATION_DATE = "publicationDateLit"; public static final String DOCUMENT_PUBLICATION_DATE = "publicationDateLit";

View file

@ -376,21 +376,18 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
biboDocument.setDocumentMoniker(documentMonikerNode.toString()); 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); RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) { 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());
}
return biboDocument; return biboDocument;
} }
@ -418,11 +415,8 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
+ " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") " + " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") "
+ " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") " + " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") "
+ " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") " + " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") "
+ " (str(?publicationYear) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR + ") " + " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearMonth) as ?" + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_MONTH + ") "
+ " (str(?publicationDate) as ?"
+ QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ "WHERE { " + "WHERE { "
+ "<" + queryURI + "> rdf:type foaf:Person ;" + "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;" + " rdfs:label ?authorLabel ;"
@ -433,9 +427,9 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . " + "?document core:informationResourceInAuthorship ?coAuthorshipNode . "
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . " + "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . "
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . " + "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . "
+ "OPTIONAL { ?document core:year ?publicationYear } . " + "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . "
+ "OPTIONAL { ?document core:yearMonth ?publicationYearMonth } . " + " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?document core:date ?publicationDate } . " + "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } . " + "OPTIONAL { ?document vitro:moniker ?documentMoniker } . "
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } . " + "OPTIONAL { ?document vitro:blurb ?documentBlurb } . "
+ "OPTIONAL { ?document vitro:description ?documentDescription } " + "OPTIONAL { ?document vitro:description ?documentDescription } "

View file

@ -52,18 +52,17 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ " (str(?SecondaryPositionLabel) as ?SecondaryPositionLabelLit)" + " (str(?SecondaryPositionLabel) as ?SecondaryPositionLabelLit)"
+ " (str(?Document) as ?documentLit) " + " (str(?Document) as ?documentLit) "
+ " (str(?DocumentLabel) as ?documentLabelLit) " + " (str(?DocumentLabel) as ?documentLabelLit) "
+ " (str(?publicationYear) as ?publicationYearLit) " + " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearMonth) as ?publicationYearMonthLit) " + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ " (str(?publicationDate) as ?publicationDateLit) "
+ " (str(?StartYear) as ?StartYearLit)"; + " (str(?StartYear) as ?StartYearLit)";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = "" private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?Document rdf:type bibo:Document ;" + "?Document rdf:type bibo:Document ;"
+ " rdfs:label ?DocumentLabel ." + " rdfs:label ?DocumentLabel ."
+ "OPTIONAL { ?Document core:year ?publicationYear } ." + "OPTIONAL { ?Document core:dateTimeValue ?dateTimeValue . "
+ "OPTIONAL { ?Document core:yearMonth ?publicationYearMonth } ." + " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?Document core:date ?publicationDate } ." + "OPTIONAL { ?Document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?SecondaryPosition core:startYear ?StartYear } ."; + "OPTIONAL { ?SecondaryPosition core:startYear ?StartYear } .";
private static String ENTITY_LABEL; private static String ENTITY_LABEL;
@ -114,26 +113,17 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
biboDocument.setDocumentLabel(documentLabelNode.toString()); biboDocument.setDocumentLabel(documentLabelNode.toString());
} }
RDFNode publicationYearNode = solution RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
.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) { if (publicationDateNode != null) {
biboDocument.setPublicationDate(publicationDateNode biboDocument.setPublicationDate(publicationDateNode.toString());
.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()) { .entrySet()) {
List<Integer> currentPubYear = new ArrayList<Integer>(); List<Integer> currentPubYear = new ArrayList<Integer>();
if (pubEntry.getKey().equals( if (pubEntry.getKey().equals(VOConstants.DEFAULT_PUBLICATION_YEAR)) {
VOConstants.DEFAULT_PUBLICATION_YEAR))
currentPubYear.add(-1); currentPubYear.add(-1);
else } else {
currentPubYear.add(Integer.parseInt(pubEntry.getKey())); currentPubYear.add(Integer.parseInt(pubEntry.getKey()));
}
currentPubYear.add(pubEntry.getValue()); currentPubYear.add(pubEntry.getValue());
yearPubCount.add(currentPubYear); yearPubCount.add(currentPubYear);
} }

View file

@ -52,21 +52,20 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
private Log log; private Log log;
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = "" private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?authorLabelLit) " + "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") "
+ " (str(?document) as ?documentLit) " + " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") "
+ " (str(?documentMoniker) as ?documentMonikerLit) " + " (str(?documentMoniker) as ?" + QueryFieldLabels.DOCUMENT_MONIKER + ") "
+ " (str(?documentLabel) as ?documentLabelLit) " + " (str(?documentLabel) as ?" + QueryFieldLabels.DOCUMENT_LABEL + ") "
+ " (str(?documentBlurb) as ?documentBlurbLit) " + " (str(?documentBlurb) as ?" + QueryFieldLabels.DOCUMENT_BLURB + ") "
+ " (str(?publicationYear) as ?publicationYearLit) " + " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearMonth) as ?publicationYearMonthLit) " + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") "
+ " (str(?publicationDate) as ?publicationDateLit) " + " (str(?documentDescription) as ?" + QueryFieldLabels.DOCUMENT_DESCRIPTION + ") ";
+ " (str(?documentDescription) as ?documentDescriptionLit) ";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = "" private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel ." + "?document rdfs:label ?documentLabel ."
+ "OPTIONAL { ?document core:year ?publicationYear } ." + "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . "
+ "OPTIONAL { ?document core:yearMonth ?publicationYearMonth } ." + " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?document core:date ?publicationDate } ." + "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } ."
+ "OPTIONAL { ?document vitro:moniker ?documentMoniker } ." + "OPTIONAL { ?document vitro:moniker ?documentMoniker } ."
+ "OPTIONAL { ?document vitro:blurb ?documentBlurb } ." + "OPTIONAL { ?document vitro:blurb ?documentBlurb } ."
+ "OPTIONAL { ?document vitro:description ?documentDescription }"; + "OPTIONAL { ?document vitro:description ?documentDescription }";
@ -111,22 +110,18 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
biboDocument.setDocumentDescription(documentDescriptionNode.toString()); 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); RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) { 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());
}
/* /*
* Since we are getting publication count for just one author at a time we need * Since we are getting publication count for just one author at a time we need
@ -170,6 +165,8 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}"; + "}";
// System.out.println(sparqlQuery);
return 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.Matcher;
import java.util.regex.Pattern; 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; import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
/** /**
@ -17,7 +21,6 @@ public class BiboDocument extends Individual {
private String documentBlurb; private String documentBlurb;
private String documentDescription; private String documentDescription;
private String publicationYear; private String publicationYear;
private String publicationYearMonth;
private String publicationDate; private String publicationDate;
private String parsedPublicationYear = VOConstants.DEFAULT_PUBLICATION_YEAR; 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 * This method will be called to get the final/inferred year for the publication.
* for the bibo:Document. It will first check & parse core:yearMonth failing * The 3 choices, in order, are,
* which it will try core:date * 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 * @return
*/ */
public String getParsedPublicationYear() { public String getParsedPublicationYear() {
/* if (publicationDate != null) {
* 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))) {
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;
}
} else {
/*
* If all else fails return default unknown year identifier if publicationYear is
* not mentioned.
* */
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);
}
/*
* If all else fails return default unknown year identifier
* */
return VOConstants.DEFAULT_PUBLICATION_YEAR;
} }
/* /*
* This publicationYear value is directly from the data supported by the ontology. * This publicationYear value is directly from the data supported by the ontology.
* If this is empty only then use the parsedPublicationYear. * If this is empty only then use the parsedPublicationYear.
*
* @Deprecated Use getParsedPublicationYear() instead.
* */ * */
@Deprecated
public String getPublicationYear() { public String getPublicationYear() {
if (publicationYear != null && isValidPublicationYear(publicationYear)) { if (publicationYear != null && isValidPublicationYear(publicationYear)) {
return publicationYear; return publicationYear;
@ -152,14 +151,6 @@ public class BiboDocument extends Individual {
this.publicationYear = publicationYear; this.publicationYear = publicationYear;
} }
public String getPublicationYearMonth() {
return publicationYearMonth;
}
public void setPublicationYearMonth(String publicationYearMonth) {
this.publicationYearMonth = publicationYearMonth;
}
public String getPublicationDate() { public String getPublicationDate() {
return publicationDate; 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 * 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 * 2. If we change the logic of validity of a pub year we would not have to make
* changes all throughout the codebase. * 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; String publicationYear = curr.getParsedPublicationYear();
if (curr.getPublicationYear() != null) {
publicationYear = curr.getPublicationYear();
} else {
publicationYear = curr.getParsedPublicationYear();
}
if (yearToPublicationCount.containsKey(publicationYear)) { if (yearToPublicationCount.containsKey(publicationYear)) {
yearToPublicationCount.put(publicationYear, yearToPublicationCount.put(publicationYear,