Skip to content

Commit

Permalink
adding a search on the results screen, updating to the latest standar…
Browse files Browse the repository at this point in the history
…dizer jars.
  • Loading branch information
retroryan committed Jan 19, 2012
1 parent bd7816b commit 4d6740e
Show file tree
Hide file tree
Showing 6 changed files with 546 additions and 9 deletions.
34 changes: 25 additions & 9 deletions app/controllers/Application.java
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

public class Application extends Controller {

Expand Down Expand Up @@ -77,6 +78,8 @@ private static DisplayPlace getDisplayPlace(Place standardizedPlace) {
}

public static PlacesComparisonDTO comparePlacesFile(File scrapeFile) throws IOException {
Pattern compiledPattern = Pattern.compile("[, ]");

PlacesComparisonDTO placesComparisonDTO = new PlacesComparisonDTO();
placesComparisonDTO.displayPlaces = new ArrayList<DisplayPlace>();

Expand All @@ -100,23 +103,36 @@ public static PlacesComparisonDTO comparePlacesFile(File scrapeFile) throws IOEx
String standard_text = split[1];
int numDataRecords = Integer.parseInt(split[2]);

int indx=0;
List<DisplayPlace> placesSubList = getDisplayPlacesList(place);
for (DisplayPlace displayPlace : placesSubList) {
if (indx == 0)
displayPlace.setInputPlace(place);

indx++;
if (placesSubList.size() > 0) {
DisplayPlace displayPlace = placesSubList.get(0);
displayPlace.setInputPlace(place);
displayPlace.setStandard_text(standard_text);
displayPlace.setNumDataRecords(numDataRecords);

if (standard_text.equalsIgnoreCase(displayPlace.getFullName())) {
String fullName = displayPlace.getFullName();
if (standard_text.equalsIgnoreCase(fullName)) {
placesComparisonDTO.numExactMatches++;
continue;
displayPlace.setWasExactMatch("Yes!");
} else {
displayPlace.setWasExactMatch("no");
}


String modifedFolgName = compiledPattern.matcher(fullName).replaceAll("");
String modifiedStandardText = compiledPattern.matcher(standard_text).replaceAll("");
if (modifiedStandardText.equalsIgnoreCase(modifedFolgName)) {
placesComparisonDTO.numModifiedatches++;
displayPlace.setWasModifiedMatch("Yes!");
} else {
displayPlace.setWasModifiedMatch("no");
}


placesComparisonDTO.displayPlaces.add(displayPlace);

}

placesComparisonDTO.displayPlaces.addAll(placesSubList);
}

placesComparisonDTO.numPlacesCompared = lineCount;
Expand Down
18 changes: 18 additions & 0 deletions app/models/DisplayPlace.java
Expand Up @@ -19,6 +19,8 @@ public class DisplayPlace {
private String inputPlace;
private String standard_text;
private int numDataRecords;
private String wasExactMatch;
private String wasModifiedMatch;


public String getFullName() {
Expand Down Expand Up @@ -92,4 +94,20 @@ public int getNumDataRecords() {
public void setNumDataRecords(int numDataRecords) {
this.numDataRecords = numDataRecords;
}

public String getWasExactMatch() {
return wasExactMatch;
}

public void setWasExactMatch(String wasExactMatch) {
this.wasExactMatch = wasExactMatch;
}

public String getWasModifiedMatch() {
return wasModifiedMatch;
}

public void setWasModifiedMatch(String wasModifiedMatch) {
this.wasModifiedMatch = wasModifiedMatch;
}
}
1 change: 1 addition & 0 deletions app/models/PlacesComparisonDTO.java
Expand Up @@ -11,6 +11,7 @@ public class PlacesComparisonDTO {
public List<DisplayPlace> displayPlaces;

public int numExactMatches;
public int numModifiedatches;

public int numPlacesCompared;

Expand Down
5 changes: 5 additions & 0 deletions app/views/Application/comparePlaces.html
Expand Up @@ -14,19 +14,24 @@ <h2>Choose a places file for comparison</h2>
#{/form}

<h2>Out of ${placesComparisonDTO.numPlacesCompared} there were ${placesComparisonDTO.numExactMatches} exact matches</h2>
<h2>Modified FOLG places there were ${placesComparisonDTO.numModifiedatches} exact matches</h2>


<table border="1">
<tr>
<th>Input Place Name</th>
<th>FOLG Standardized Name</th>
<th>FamilySearch Standardized Name</th>
<th>Exact Match</th>
<th>Modified Name Matches</th>
</tr>
#{list items:placesComparisonDTO.displayPlaces, as: 'displayPlace'}
<tr>
<td>${displayPlace.inputPlace}</td>
<td>${displayPlace.fullName}</td>
<td>${displayPlace.standard_text}</td>
<td>${displayPlace.wasExactMatch}</td>
<td>${displayPlace.wasModifiedMatch}</td>
</tr>
#{/list}

Expand Down
4 changes: 4 additions & 0 deletions app/views/main.html
Expand Up @@ -36,6 +36,10 @@
<script src="@{'/public/javascripts/bootstrap-tabs.js'}" type="text/javascript"
charset="${_response_encoding}"></script>

<script src="@{'/public/javascripts/sorttable.js'}" type="text/javascript"
charset="${_response_encoding}"></script>


#{get 'moreScripts' /}

</head>
Expand Down

0 comments on commit 4d6740e

Please sign in to comment.