Merge pull request #236 from brianjlowe/issue/VIVO-1985

[VIVO-1985] Compare locales of equal rank alphabetically to provide consistent fallback
This commit is contained in:
Georgy Litvinov 2021-06-16 20:16:39 +02:00 committed by GitHub
commit 1e7cc745bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -16,6 +16,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.IdModelSelector;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.StandardModelSelector;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
@ -63,6 +64,7 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
setupModelSelectorsFromVitroRequest(vreq, editConfig);
OntModel queryModel = ModelAccess.on(vreq).getOntModel();
OntModel languageNeutralModel = vreq.getLanguageNeutralUnionFullModel();
if( editConfig.getSubjectUri() == null)
editConfig.setSubjectUri( EditConfigurationUtils.getSubjectUri(vreq));
@ -78,7 +80,10 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
editConfig.prepareForObjPropUpdate(queryModel);
} else if( dataKey != null ) { // edit of a data prop statement
//do nothing since the data prop form generator must take care of it
editConfig.prepareForDataPropUpdate(queryModel, vreq.getWebappDaoFactory().getDataPropertyDao());
// Use language-neutral model to ensure that a data property statement
// is found for any literal hash, even if the UI locale is changed.
editConfig.prepareForDataPropUpdate(languageNeutralModel,
vreq.getWebappDaoFactory().getDataPropertyDao());
} else{
//this might be a create new or a form
editConfig.prepareForNonUpdate(queryModel);

View file

@ -202,7 +202,7 @@ public class RequestModelAccessImpl implements RequestModelAccess {
@Override
public OntModel getOntModel(String name, LanguageOption... options) {
return addLanguageAwareness(getOntModel(new OntModelKey(name, options)));
return getOntModel(new OntModelKey(name, options));
}
private OntModel getOntModel(OntModelKey key) {

View file

@ -36,7 +36,13 @@ public class LangSort {
}
protected int compareLangs(String t1lang, String t2lang) {
return languageIndex(t1lang) - languageIndex(t2lang);
int index1 = languageIndex(t1lang);
int index2 = languageIndex(t2lang);
if(index1 == index2) {
return t1lang.compareTo(t2lang);
} else {
return languageIndex(t1lang) - languageIndex(t2lang);
}
}
/**