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:
parent
c73cb28426
commit
f6429af187
10 changed files with 180 additions and 214 deletions
|
@ -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";
|
||||
|
||||
|
|
|
@ -376,21 +376,18 @@ 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 } "
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,22 +110,18 @@ 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
|
||||
|
@ -170,6 +165,8 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
|
|||
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
|
||||
+ "}";
|
||||
|
||||
// System.out.println(sparqlQuery);
|
||||
|
||||
return sparqlQuery;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
} 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.
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue