Changes to QR code generation to support swapping in a different model in IndividualController: fixed NPEs, and change getQrCode() to doQrCode() so it's invoked only when the template asks for it.
This commit is contained in:
parent
c15bdb8f3d
commit
d18b02782e
5 changed files with 13 additions and 13 deletions
|
@ -6,13 +6,13 @@
|
|||
|
||||
<h3>What is QR?</h3>
|
||||
|
||||
<p>QR stands for <i>Quick Response</i> is a standard for two-dimensional barcodes that can be read by mobile devices equipped with cameras (such as a smartphone).</p>
|
||||
<p>QR, which stands for <i>Quick Response</i>, is a standard for two-dimensional barcodes that can be read by mobile devices equipped with cameras (such as a smartphone).</p>
|
||||
|
||||
<h3>What kind of data is in a QR code?</h3>
|
||||
|
||||
<p>QR codes can encode many different types of data. The QR code on the profile page of a person in VIVO encodes information about that person in <i>vCard</i> format. This is a sort of digital business card, containing information about the person's name, address, telephone number, email address, and more.</p>
|
||||
|
||||
<p>If you click on a person's QR code in VIVO, you will be taken to the <i>QR Export</i> page for that person. On this page contains the vCard QR code seen on the front page, as well as a QR code containing a simple hyperlink to the user's VIVO profile. It also contains an HTML tag for each code, that can be embedded in a web page to display that code on other sites.</p>
|
||||
<p>If you click on a person's QR code in VIVO, you will be taken to the <i>QR Export</i> page for that person. This page contains the vCard QR code seen on the front page, as well as a QR code containing a simple hyperlink to the user's VIVO profile. It also contains an HTML tag for each code, that can be embedded in a web page to display that code on other sites.</p>
|
||||
<#-- todo: make VIVO API? Currently pasting Google API code into export area, this will be static and not change if VIVO data is updated. -->
|
||||
|
||||
<h3>How do I read a QR code?</h3>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<#assign qrCodeWidth = "150">
|
||||
|
||||
<h2>Export QR Code <em>(<a href="${individual.qrData.aboutQrCodesUrl}" title="More info on QR codes">What is this?</a>)</em></h2>
|
||||
<h2>Export QR Code <em>(<a href="${individual.doQrData().aboutQrCodesUrl}" title="More info on QR codes">What is this?</a>)</em></h2>
|
||||
|
||||
<#assign thumbUrl = individual.thumbUrl! "${urls.images}/placeholders/person.thumbnail.jpg" >
|
||||
<img class="qrCode" src="${thumbUrl}" />
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
<#include "individual-qrCodeGenerator.ftl">
|
||||
|
||||
<#if hasValidVCard()>
|
||||
<li role="listitem"><a title="Export QR codes" href="${individual.qrData.exportQrCodeUrl}"><img class="middle" src="${urls.images}/individual/qr_icon.png" alt="qr icon" /></a></li>
|
||||
<li role="listitem"><a title="Export QR codes" href="${individual.doQrData().exportQrCodeUrl}"><img class="middle" src="${urls.images}/individual/qr_icon.png" alt="qr icon" /></a></li>
|
||||
</#if>
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<#function getQrCodeUrlForVCard qrCodeWidth>
|
||||
|
||||
<#local qrData = individual.qrData >
|
||||
<#local qrData = individual.doQrData() >
|
||||
|
||||
<#local core = "http://vivoweb.org/ontology/core#">
|
||||
<#local foaf = "http://xmlns.com/foaf/0.1/">
|
||||
|
@ -69,7 +69,7 @@
|
|||
|
||||
<#function getQrCodeUrlForLink qrCodeWidth>
|
||||
|
||||
<#local qrData = individual.qrData >
|
||||
<#local qrData = individual.doQrData() >
|
||||
|
||||
<#local url = qrData.externalUrl! >
|
||||
|
||||
|
@ -105,7 +105,7 @@
|
|||
|
||||
<#function hasValidVCard>
|
||||
|
||||
<#local qrData = individual.qrData >
|
||||
<#local qrData = individual.doQrData() >
|
||||
|
||||
<#local firstName = qrData.firstName! >
|
||||
<#local lastName = qrData.lastName! >
|
||||
|
|
|
@ -102,7 +102,7 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
|||
return id;
|
||||
}
|
||||
|
||||
public Map<String, String> getQrData() {
|
||||
public Map<String, String> doQrData() {
|
||||
if(qrData == null)
|
||||
qrData = generateQrData();
|
||||
return qrData;
|
||||
|
@ -120,15 +120,15 @@ public class IndividualTemplateModel extends BaseIndividualTemplateModel {
|
|||
Collection<DataPropertyStatement> phoneNumbers = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, core + "phoneNumber");
|
||||
Collection<DataPropertyStatement> emails = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, core + "email");
|
||||
|
||||
if(firstNames.size() > 0)
|
||||
if(firstNames != null && ! firstNames.isEmpty())
|
||||
qrData.put("firstName", firstNames.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
|
||||
if(lastNames.size() > 0)
|
||||
if(lastNames != null && ! lastNames.isEmpty())
|
||||
qrData.put("lastName", lastNames.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
|
||||
if(preferredTitles.size() > 0)
|
||||
if(preferredTitles != null && ! preferredTitles.isEmpty())
|
||||
qrData.put("preferredTitle", preferredTitles.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
|
||||
if(phoneNumbers.size() > 0)
|
||||
if(phoneNumbers != null && ! phoneNumbers.isEmpty())
|
||||
qrData.put("phoneNumber", phoneNumbers.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
|
||||
if(emails.size() > 0)
|
||||
if(emails != null && ! emails.isEmpty())
|
||||
qrData.put("email", emails.toArray(new DataPropertyStatement[firstNames.size()])[0].getData());
|
||||
|
||||
String tempUrl = vreq.getRequestURL().toString();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue