Skip to content

Commit

Permalink
new places jar; add sources
Browse files Browse the repository at this point in the history
  • Loading branch information
DallanQ committed Feb 29, 2012
1 parent 66c885a commit 269d952
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 10 deletions.
5 changes: 3 additions & 2 deletions app/controllers/PlacesUtil.java
Expand Up @@ -30,8 +30,7 @@ public static DisplayPlace getDisplayPlace(Place standardizedPlace) {
displayPlace.setAlsoLocatedIn(alsoLocatedStrs.toString());
}

String altNames = StringUtils.join(standardizedPlace.getAltNames(), ",");
displayPlace.setAltNames(altNames);
displayPlace.setAltNames(standardizedPlace.getAltNames());

String types = StringUtils.join(standardizedPlace.getTypes(), ",");
displayPlace.setTypes(types);
Expand All @@ -41,6 +40,8 @@ public static DisplayPlace getDisplayPlace(Place standardizedPlace) {
displayPlace.setLongitude(Double.toString(standardizedPlace.getLongitude()));
}

displayPlace.setSources(standardizedPlace.getSources());

displayPlace.setId(standardizedPlace.getId());
displayPlace.setPlaceName(standardizedPlace.getName());

Expand Down
44 changes: 40 additions & 4 deletions app/models/DisplayPlace.java
@@ -1,18 +1,28 @@
package models;

import org.folg.places.standardize.Place;

/**
* User: Ryan K.
* Date: 1/12/12
*/
public class DisplayPlace {

public static class Source {
public String source;
public String link;
public Source(String source, String link) {
this.source = source;
this.link = link;
}
}

private String fullName;
private String altNames;
private Place.AltName[] altNames;
private String types;
private String alsoLocatedIn;
private String latitude;
private String longitude;
private DisplayPlace.Source[] sources;


//This is not used on the main display site. It is only used for the
Expand All @@ -32,18 +42,44 @@ public String getFullName() {
return fullName;
}

public String getLink() {
return "http://www.werelate.org/wiki/Place:"+fullName.replace(' ','_');
}

public void setFullName(String fullName) {
this.fullName = fullName;
}

public String getAltNames() {
public Place.AltName[] getAltNames() {
return altNames;
}

public void setAltNames(String altNames) {
public void setAltNames(Place.AltName[] altNames) {
this.altNames = altNames;
}

public DisplayPlace.Source[] getSources() {
return sources;
}

public void setSources(Place.Source[] sources) {
this.sources = new Source[sources.length];
for (int i = 0; i < sources.length; i++) {
Place.Source src = sources[i];
String link = "";
if (src.source.equals("fhlc")) {
link = "http://www.familysearch.org/eng/library/fhlcatalog/supermainframeset.asp?display=localitydetails&subject="+src.id+"&columns=*,0,0";
}
else if (src.source.equals("getty")) {
link = "http://www.getty.edu/vow/TGNFullDisplay?find=&place=&nation=&english=Y&subjectid="+src.id;
}
else if (src.source.equals("wikipedia")) {
link = "http://en.wikipedia.org/wiki/"+src.id.replace(' ','_');
}
this.sources[i] = new Source(src.source, link);
}
}

public String getTypes() {
return types;
}
Expand Down
10 changes: 8 additions & 2 deletions app/views/Application/searchForPlace.html
Expand Up @@ -19,15 +19,21 @@ <h2>Search for a place</h2>
<th>Also located in</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Sources</th>
</tr>
#{list items:displayPlaces, as: 'displayPlace'}
<tr>
<td>${displayPlace.fullName}</td>
<td>${displayPlace.altNames}</td>
<td><a href="${displayPlace.link}">${displayPlace.fullName}</a></td>
<td>#{list items:displayPlace.altNames, as: 'altName'}
${altName.altName} #{if altName.source}<i>(${altName.source})</i>#{/if}<br>
#{/list}</td>
<td>${displayPlace.types}</td>
<td>${displayPlace.alsoLocatedIn}</td>
<td>${displayPlace.latitude}</td>
<td>${displayPlace.longitude}</td>
<td>#{list items:displayPlace.sources, as: 'source'}
<a href="${source.link}">${source.source}</a><br>
#{/list}</td>
</tr>
#{/list}

Expand Down
34 changes: 32 additions & 2 deletions app/views/Labeler/labelNextPlace.html
Expand Up @@ -20,11 +20,12 @@
$.each(ambigPlaceList, function (index, item) {
var tableRowStr = '<tr>' + addColumn('<input type="submit" class="btn primary" name="' + index + '" value="Select">');
tableRowStr += addLinkColumn(item.id, item.fullName);
tableRowStr += addColumn(item.altNames);
tableRowStr += addAltNameColumn(item.altNames);
tableRowStr += addColumn(item.types);
tableRowStr += addColumn(item.alsoLocatedIn);
tableRowStr += addColumn(item.latitude);
tableRowStr += addColumn(item.longitude) + "</tr>";
tableRowStr += addColumn(item.longitude);
tableRowStr += addSourceColumn(item.sources) + "</tr>";
$("#nextPlaceTable").append(tableRowStr);
placesMap[index] = item;
});
Expand All @@ -47,6 +48,34 @@
return "<td></td>";
}

function escapeHtml(s) {
return s.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
}

function addAltNameColumn(altNames) {
var result = '';
if (typeof(altNames) != "undefined") {
for (var i = 0; i < altNames.length; i++) {
if (result) result += '<br>';
result += escapeHtml(altNames[i].altName);
if (altNames[i].source) {
result += ' <i>('+escapeHtml(altNames[i].source)+')</i>';
}
}
}
return addColumn(result);
}

function addSourceColumn(sources) {
var result = '';
if (typeof(sources) != "undefined") {
for (var i = 0; i < sources.length; i++) {
if (result) result += '<br>';
result += '<a href="'+sources[i].link+'">'+escapeHtml(sources[i].source)+'</a>';
}
}
return addColumn(result);
}

function addLinkColumn(id, fullName) {
var rowString;
Expand Down Expand Up @@ -100,6 +129,7 @@ <h1 id="ambigPlaceLabel"></h1>
<th>Also located in</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Sources</th>
</tr>


Expand Down
Binary file removed lib/standardize-1.0.jar
Binary file not shown.
Binary file added lib/standardize-1.1.jar
Binary file not shown.
Binary file renamed lib/tools-1.0.jar → lib/tools-1.1.jar
Binary file not shown.

0 comments on commit 269d952

Please sign in to comment.