IndividualTemplateModel.java: Add getQrData()

individual-qrCodeFoafPerson.ftl: Use getQrData()
individual-setup.ftl: Undo QR code changes
This commit is contained in:
mbarbier 2011-04-05 18:03:02 +00:00
parent 88aa698555
commit 3766dc25bd
3 changed files with 39 additions and 7 deletions

View file

@ -20,17 +20,18 @@ PHOTO;VALUE=URL;TYPE=JPG:https://vivo.ufl.edu/file/n34850/_main_image_491-NUCATS
REV:20080424T195243Z
END:VCARD
-->
<#local qrData = individual.qrData >
<#local core = "http://vivoweb.org/ontology/core#">
<#local foaf = "http://xmlns.com/foaf/0.1/">
<#local rdfs = "http://www.w3.org/2000/01/rdf-schema#">
<#local firstName = (allProperties.getProperty("${foaf}firstName").firstValue)! >
<#local lastName = (allProperties.getProperty("${foaf}lastName").firstValue)! >
<#local firstName = qrData.firstName! >
<#local lastName = qrData.lastName! >
<#local org = "" >
<#local title = (allProperties.getProperty("${core}preferredTitle").firstValue)! >
<#local phoneNumber = (allProperties.getProperty("${core}phoneNumber").firstValue)! >
<#local email = (allProperties.getProperty("${core}email").firstValue)! >
<#local title = qrData.preferredTitle! >
<#local phoneNumber = qrData.phoneNumber! >
<#local email = qrData.email! >
<#local url = urls.currentPage! >
<#local photo = individual.thumbUrl! >
<#local rev = "" >

View file

@ -8,6 +8,5 @@
<#assign editable = individual.editable>
<#assign propertyGroups = individual.propertyList>
<#assign allProperties = individual.fullPropertyList>
<#assign core = "http://vivoweb.org/ontology/core#">

View file

@ -2,14 +2,20 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class IndividualTemplateModel extends BaseIndividualTemplateModel {
@ -59,11 +65,37 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
public String getCoInvestigatorVisUrl() {
return getPersonVisUrl(new ParamMap("vis_mode", "copi"));
}
public String getTemporalGraphUrl() {
if (!isOrganization()) {
return null;
}
return getVisUrl("vis", "entity_comparison");
}
public Map<String, String> getQrData() {
String core = "http://vivoweb.org/ontology/core#";
String foaf = "http://xmlns.com/foaf/0.1/";
Map<String,String> qrData = new HashMap<String,String>();
WebappDaoFactory wdf = vreq.getAssertionsWebappDaoFactory();
Collection<DataPropertyStatement> firstNames = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, foaf + "firstName");
Collection<DataPropertyStatement> lastNames = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, foaf + "lastName");
Collection<DataPropertyStatement> preferredTitles = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, core + "preferredTitle");
Collection<DataPropertyStatement> phoneNumbers = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, core + "phoneNumber");
Collection<DataPropertyStatement> emails = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, core + "email");
if(firstNames.size() > 0)
qrData.put("firstName", firstNames.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
if(lastNames.size() > 0)
qrData.put("lastName", lastNames.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
if(preferredTitles.size() > 0)
qrData.put("preferredTitle", preferredTitles.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
if(phoneNumbers.size() > 0)
qrData.put("phoneNumber", phoneNumbers.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
if(emails.size() > 0)
qrData.put("email", emails.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
return qrData;
}
}