use of org.vcell.rest.common.BiomodelRepresentation in project vcell by virtualcell.
the class BiomodelServerResource method get_html.
@Override
public Representation get_html() {
VCellApiApplication application = ((VCellApiApplication) getApplication());
User vcellUser = application.getVCellUser(getChallengeResponse(), AuthenticationPolicy.ignoreInvalidCredentials);
BiomodelRepresentation biomodel = getBiomodelRepresentation(vcellUser);
if (biomodel == null) {
throw new RuntimeException("biomodel not found");
}
Map<String, Object> dataModel = new HashMap<String, Object>();
// +"?"+VCellApiApplication.REDIRECTURL_FORMNAME+"="+getRequest().getResourceRef().toUrl());
dataModel.put("loginurl", "/" + VCellApiApplication.LOGINFORM);
dataModel.put("logouturl", "/" + VCellApiApplication.LOGOUT + "?" + VCellApiApplication.REDIRECTURL_FORMNAME + "=" + Reference.encode(getRequest().getResourceRef().toUrl().toString()));
if (vcellUser != null) {
dataModel.put("userid", vcellUser.getName());
}
dataModel.put("bmId", getQueryValue(VCellApiApplication.BIOMODELID));
dataModel.put("biomodel", biomodel);
Gson gson = new Gson();
dataModel.put("jsonResponse", gson.toJson(biomodel));
Configuration templateConfiguration = application.getTemplateConfiguration();
Representation formFtl = new ClientResource(LocalReference.createClapReference("/biomodel.ftl")).get();
TemplateRepresentation templateRepresentation = new TemplateRepresentation(formFtl, templateConfiguration, dataModel, MediaType.TEXT_HTML);
return templateRepresentation;
}
Aggregations