NIHVIVO-2057 Add additional values to login widget template data model.
This commit is contained in:
parent
22be097879
commit
ccfb017593
4 changed files with 59 additions and 50 deletions
|
@ -92,7 +92,7 @@ public class SiteAdminController extends FreemarkerHttpServlet {
|
|||
// Create map for data input entry form options list
|
||||
List classGroups = wadf.getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false); // order by displayRank, include uninstantiated classes, don't get the counts of individuals
|
||||
|
||||
boolean classGroupDisplayAssumptionsMeet = checkClassGroupDisplayAssumptions(classGroups);
|
||||
//boolean classGroupDisplayAssumptionsMet = checkClassGroupDisplayAssumptions(classGroups);
|
||||
|
||||
Set<String> seenGroupNames = new HashSet<String>();
|
||||
|
||||
|
@ -102,10 +102,10 @@ public class SiteAdminController extends FreemarkerHttpServlet {
|
|||
VClassGroup group = (VClassGroup)classGroupIt.next();
|
||||
List opts = FormUtils.makeOptionListFromBeans(group.getVitroClassList(),"URI","PickListName",null,null,false);
|
||||
if( seenGroupNames.contains(group.getPublicName() )){
|
||||
//have a duplicat classgroup name, stick in the URI
|
||||
//have a duplicate classgroup name, stick in the URI
|
||||
orderedClassGroups.put(group.getPublicName() + " ("+group.getURI()+")", opts);
|
||||
}else if( group.getPublicName() == null ){
|
||||
//have an unlabeled group, use stick in the URI
|
||||
//have an unlabeled group, stick in the URI
|
||||
orderedClassGroups.put("unnamed group ("+group.getURI()+")", opts);
|
||||
}else{
|
||||
orderedClassGroups.put(group.getPublicName(),opts);
|
||||
|
@ -199,11 +199,11 @@ public class SiteAdminController extends FreemarkerHttpServlet {
|
|||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
Map<String, String> urls = new HashMap<String, String>();
|
||||
urls.put("ingest", urlBuilder.getUrl("/ingest"));
|
||||
urls.put("ingest", UrlBuilder.getUrl("/ingest"));
|
||||
urls.put("rdfData", urlBuilder.getPortalUrl("/uploadRDFForm"));
|
||||
urls.put("rdfExport", urlBuilder.getPortalUrl("/export"));
|
||||
urls.put("sparqlQuery", urlBuilder.getUrl("/admin/sparqlquery"));
|
||||
urls.put("sparqlQueryBuilder", urlBuilder.getUrl("/admin/sparqlquerybuilder"));
|
||||
urls.put("sparqlQuery", UrlBuilder.getUrl("/admin/sparqlquery"));
|
||||
urls.put("sparqlQueryBuilder", UrlBuilder.getUrl("/admin/sparqlquerybuilder"));
|
||||
map.put("urls", urls);
|
||||
|
||||
return map;
|
||||
|
@ -218,33 +218,33 @@ public class SiteAdminController extends FreemarkerHttpServlet {
|
|||
* Check the assumptions and use the URIs as the key if the assumptions are not
|
||||
* meet. see issue NIHVIVO-1635.
|
||||
*/
|
||||
private boolean checkClassGroupDisplayAssumptions( List<VClassGroup> groups){
|
||||
//Assumption A: all of the classgroups have a non-null rdfs:label
|
||||
//Assumption B: none of the classgroups have the same rdfs:label
|
||||
//the assumption that all classgroups have only one rdfs:label is not checked
|
||||
boolean rvalue = true;
|
||||
Set<String> seenPublicNames = new HashSet<String>();
|
||||
|
||||
for( VClassGroup group :groups ){
|
||||
//check Assumption A
|
||||
if( group.getPublicName() == null){
|
||||
rvalue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//check Assumption B
|
||||
if( seenPublicNames.contains(group.getPublicName()) ){
|
||||
rvalue = false;
|
||||
break;
|
||||
}
|
||||
seenPublicNames.add(group.getPublicName());
|
||||
}
|
||||
|
||||
|
||||
if( !rvalue )
|
||||
log.error("The rdfs:labels on the classgroups in the system do " +
|
||||
"not meet the display assumptions. Falling back to alternative.");
|
||||
return rvalue;
|
||||
}
|
||||
// private boolean checkClassGroupDisplayAssumptions( List<VClassGroup> groups){
|
||||
// //Assumption A: all of the classgroups have a non-null rdfs:label
|
||||
// //Assumption B: none of the classgroups have the same rdfs:label
|
||||
// //the assumption that all classgroups have only one rdfs:label is not checked
|
||||
// boolean rvalue = true;
|
||||
// Set<String> seenPublicNames = new HashSet<String>();
|
||||
//
|
||||
// for( VClassGroup group :groups ){
|
||||
// //check Assumption A
|
||||
// if( group.getPublicName() == null){
|
||||
// rvalue = false;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// //check Assumption B
|
||||
// if( seenPublicNames.contains(group.getPublicName()) ){
|
||||
// rvalue = false;
|
||||
// break;
|
||||
// }
|
||||
// seenPublicNames.add(group.getPublicName());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if( !rvalue )
|
||||
// log.error("The rdfs:labels on the classgroups in the system do " +
|
||||
// "not meet the display assumptions. Falling back to alternative.");
|
||||
// return rvalue;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ public class DumpAllDirective extends BaseTemplateDirectiveModel {
|
|||
|
||||
private static final Log log = LogFactory.getLog(DumpAllDirective.class);
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars,
|
||||
TemplateDirectiveBody body) throws TemplateException, IOException {
|
||||
|
@ -45,12 +44,12 @@ public class DumpAllDirective extends BaseTemplateDirectiveModel {
|
|||
}
|
||||
|
||||
TemplateHashModel dataModel = env.getDataModel();
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> dm = (Map<String, Object>) DeepUnwrap.permissiveUnwrap(dataModel);
|
||||
List<String> varNames = new ArrayList(dm.keySet());
|
||||
List<String> varNames = new ArrayList<String>(dm.keySet());
|
||||
Collections.sort(varNames);
|
||||
|
||||
DumpHelper helper = new DumpHelper(env);
|
||||
Configuration config = env.getConfiguration();
|
||||
DumpHelper helper = new DumpHelper(env);
|
||||
List<String> models = new ArrayList<String>();
|
||||
List<String> directives = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.web.widgets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -20,8 +18,10 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User;
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateModel;
|
||||
import freemarker.template.TemplateHashModel;
|
||||
import freemarker.template.utility.DeepUnwrap;
|
||||
|
||||
public class LoginWidget extends Widget {
|
||||
private static final Log log = LogFactory.getLog(LoginWidget.class);
|
||||
|
@ -74,15 +74,14 @@ public class LoginWidget extends Widget {
|
|||
HttpServletRequest request, ServletContext context) {
|
||||
|
||||
WidgetTemplateValues values = null;
|
||||
TemplateModel urls = null;
|
||||
|
||||
|
||||
try {
|
||||
urls = env.getDataModel().get("urls");
|
||||
|
||||
State state = getCurrentLoginState(request);
|
||||
log.debug("State on exit: " + state);
|
||||
|
||||
String siteName = env.getDataModel().get("siteName").toString();
|
||||
|
||||
TemplateHashModel dataModel = env.getDataModel();
|
||||
|
||||
switch (state) {
|
||||
case LOGGED_IN:
|
||||
// On the login page itself, show a message that the user is already logged in.
|
||||
|
@ -98,15 +97,24 @@ public class LoginWidget extends Widget {
|
|||
values = showPasswordChangeScreen(request);
|
||||
break;
|
||||
default:
|
||||
values = showLoginScreen(request, siteName);
|
||||
values = showLoginScreen(request, dataModel.get("siteName").toString());
|
||||
}
|
||||
|
||||
values.put("urls", dataModel.get("urls"));
|
||||
values.put("currentPage", dataModel.get("currentPage"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> dm = (Map<String, Object>) DeepUnwrap.permissiveUnwrap(dataModel);
|
||||
User user = (User) dm.get("user");
|
||||
values.put("user", user);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
// This widget should display an error message rather than throwing the exception
|
||||
// up to the doMarkup() method, which would result in no display.
|
||||
values = showError(e);
|
||||
}
|
||||
values.put("urls", urls);
|
||||
|
||||
return values;
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue