Search in sources :

Example 6 with BiomodelRepresentation

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;
}
Also used : BiomodelRepresentation(org.vcell.rest.common.BiomodelRepresentation) TemplateRepresentation(org.restlet.ext.freemarker.TemplateRepresentation) User(org.vcell.util.document.User) Configuration(freemarker.template.Configuration) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) TemplateRepresentation(org.restlet.ext.freemarker.TemplateRepresentation) BiomodelRepresentation(org.vcell.rest.common.BiomodelRepresentation) Representation(org.restlet.representation.Representation) VCellApiApplication(org.vcell.rest.VCellApiApplication) ClientResource(org.restlet.resource.ClientResource)

Aggregations

VCellApiApplication (org.vcell.rest.VCellApiApplication)6 BiomodelRepresentation (org.vcell.rest.common.BiomodelRepresentation)6 User (org.vcell.util.document.User)4 BioModelRep (cbit.vcell.modeldb.BioModelRep)2 Gson (com.google.gson.Gson)2 Configuration (freemarker.template.Configuration)2 ParseException (java.text.ParseException)2 HashMap (java.util.HashMap)2 TemplateRepresentation (org.restlet.ext.freemarker.TemplateRepresentation)2 Representation (org.restlet.representation.Representation)2 ClientResource (org.restlet.resource.ClientResource)2 ResourceException (org.restlet.resource.ResourceException)2 PermissionException (org.vcell.util.PermissionException)2 ExpressionException (cbit.vcell.parser.ExpressionException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 DataAccessException (org.vcell.util.DataAccessException)1 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)1