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:
commit
1e7cc745bc
3 changed files with 14 additions and 3 deletions
|
@ -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.IdModelSelector;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.StandardModelSelector;
|
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;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
||||||
|
|
||||||
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
public abstract class BaseEditConfigurationGenerator implements EditConfigurationGenerator {
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
|
||||||
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
setupModelSelectorsFromVitroRequest(vreq, editConfig);
|
||||||
|
|
||||||
OntModel queryModel = ModelAccess.on(vreq).getOntModel();
|
OntModel queryModel = ModelAccess.on(vreq).getOntModel();
|
||||||
|
OntModel languageNeutralModel = vreq.getLanguageNeutralUnionFullModel();
|
||||||
|
|
||||||
if( editConfig.getSubjectUri() == null)
|
if( editConfig.getSubjectUri() == null)
|
||||||
editConfig.setSubjectUri( EditConfigurationUtils.getSubjectUri(vreq));
|
editConfig.setSubjectUri( EditConfigurationUtils.getSubjectUri(vreq));
|
||||||
|
@ -78,7 +80,10 @@ public abstract class BaseEditConfigurationGenerator implements EditConfiguratio
|
||||||
editConfig.prepareForObjPropUpdate(queryModel);
|
editConfig.prepareForObjPropUpdate(queryModel);
|
||||||
} else if( dataKey != null ) { // edit of a data prop statement
|
} else if( dataKey != null ) { // edit of a data prop statement
|
||||||
//do nothing since the data prop form generator must take care of it
|
//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{
|
} else{
|
||||||
//this might be a create new or a form
|
//this might be a create new or a form
|
||||||
editConfig.prepareForNonUpdate(queryModel);
|
editConfig.prepareForNonUpdate(queryModel);
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class RequestModelAccessImpl implements RequestModelAccess {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OntModel getOntModel(String name, LanguageOption... options) {
|
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) {
|
private OntModel getOntModel(OntModelKey key) {
|
||||||
|
|
|
@ -36,8 +36,14 @@ public class LangSort {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int compareLangs(String t1lang, String t2lang) {
|
protected int compareLangs(String t1lang, String t2lang) {
|
||||||
|
int index1 = languageIndex(t1lang);
|
||||||
|
int index2 = languageIndex(t2lang);
|
||||||
|
if(index1 == index2) {
|
||||||
|
return t1lang.compareTo(t2lang);
|
||||||
|
} else {
|
||||||
return languageIndex(t1lang) - languageIndex(t2lang);
|
return languageIndex(t1lang) - languageIndex(t2lang);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return index of exact match, or index of partial match, or
|
* Return index of exact match, or index of partial match, or
|
||||||
|
|
Loading…
Add table
Reference in a new issue