updates for label management
This commit is contained in:
parent
4179900ea4
commit
b970fb42d8
2 changed files with 8 additions and 35 deletions
|
@ -43,7 +43,14 @@ public class FoafNameToRdfsLabelPreprocessor implements ModelChangePreprocessor
|
||||||
|
|
||||||
String firstNameLanguage = firstNameLiteral.getLanguage();
|
String firstNameLanguage = firstNameLiteral.getLanguage();
|
||||||
String lastNameLanguage = lastNameLiteral.getLanguage();
|
String lastNameLanguage = lastNameLiteral.getLanguage();
|
||||||
|
//Start creating string for new label
|
||||||
String newLabel = lname.getString() + ", " + fname.getString();
|
String newLabel = lname.getString() + ", " + fname.getString();
|
||||||
|
|
||||||
|
//Middle name handling
|
||||||
|
if(mname != null && mname.getString() != null) {
|
||||||
|
newLabel += " " + mname.getString();
|
||||||
|
}
|
||||||
|
|
||||||
if(firstNameLanguage != null && lastNameLanguage != null && firstNameLanguage.equals(lastNameLanguage)) {
|
if(firstNameLanguage != null && lastNameLanguage != null && firstNameLanguage.equals(lastNameLanguage)) {
|
||||||
//create a literal with the appropriate value and the language
|
//create a literal with the appropriate value and the language
|
||||||
Literal labelWithLanguage = additionsModel.createLiteral(newLabel, firstNameLanguage);
|
Literal labelWithLanguage = additionsModel.createLiteral(newLabel, firstNameLanguage);
|
||||||
|
|
|
@ -64,45 +64,11 @@ public class ManageLabelsForIndividualPreprocessor extends BaseEditSubmissionPre
|
||||||
inputSubmission.setLiteralsFromForm(literalsFromForm);
|
inputSubmission.setLiteralsFromForm(literalsFromForm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//First name and last name would also have a language selected so make sure those literals are also
|
|
||||||
//correctly typed
|
|
||||||
if(inputSubmission.hasLiteralValue("firstName") && inputSubmission.hasLiteralValue("lastName") && inputSubmission.hasLiteralValue("newLabelLanguage")) {
|
|
||||||
Map<String, List<Literal>> literalsFromForm = inputSubmission.getLiteralsFromForm();
|
|
||||||
List<Literal> newLabelLanguages = literalsFromForm.get("newLabelLanguage");
|
|
||||||
List<Literal> firstNames = literalsFromForm.get("firstName");
|
|
||||||
List<Literal> lastNames = literalsFromForm.get("lastName");
|
|
||||||
|
|
||||||
//Expecting only one language
|
|
||||||
if(firstNames.size() > 0 && lastNames.size() > 0 && newLabelLanguages.size() > 0) {
|
|
||||||
Literal newLabelLanguage = newLabelLanguages.get(0);
|
|
||||||
Literal firstNameLiteral = firstNames.get(0);
|
|
||||||
Literal lastNameLiteral = lastNames.get(0);
|
|
||||||
//Get the string
|
|
||||||
String lang = this.getLanguage(newLabelLanguage.getString());
|
|
||||||
String firstNameValue = firstNameLiteral.getString();
|
|
||||||
String lastNameValue = lastNameLiteral.getString();
|
|
||||||
//Now add the language category to the literal
|
|
||||||
Literal firstNameWithLanguage = inputSubmission.createLiteral(firstNameValue,
|
|
||||||
null,
|
|
||||||
lang);
|
|
||||||
Literal lastNameWithLanguage = inputSubmission.createLiteral(lastNameValue,
|
|
||||||
null,
|
|
||||||
lang);
|
|
||||||
firstNames = new ArrayList<Literal>();
|
|
||||||
lastNames = new ArrayList<Literal>();
|
|
||||||
firstNames.add(firstNameWithLanguage);
|
|
||||||
lastNames.add(lastNameWithLanguage);
|
|
||||||
//replace the label with one with language, again assuming only one label being returned
|
|
||||||
literalsFromForm.put("firstName", firstNames);
|
|
||||||
literalsFromForm.put("lastName", lastNames);
|
|
||||||
inputSubmission.setLiteralsFromForm(literalsFromForm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//The language code returned from JAVA locales has an underscore whereas we need a hyphen
|
//The language code returned from JAVA locales has an underscore whereas we need a hyphen
|
||||||
private String getLanguage(String inputLanguageCode) {
|
protected String getLanguage(String inputLanguageCode) {
|
||||||
if(inputLanguageCode.contains("_")) {
|
if(inputLanguageCode.contains("_")) {
|
||||||
return inputLanguageCode.replace("_", "-");
|
return inputLanguageCode.replace("_", "-");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue