Search in sources :

Example 36 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class SimulationTaskServerResource method get_json.

@Override
public SimulationTaskRepresentation get_json() {
    VCellApiApplication application = ((VCellApiApplication) getApplication());
    User vcellUser = application.getVCellUser(getChallengeResponse(), AuthenticationPolicy.prohibitInvalidCredentials);
    // return sim;
    return null;
}
Also used : User(org.vcell.util.document.User) VCellApiApplication(org.vcell.rest.VCellApiApplication)

Example 37 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class TestRestServerBlinov method getVCellApiApplication.

public static VCellApiApplication getVCellApiApplication() throws DataAccessException {
    return new VCellApiApplication(getRestDatabaseService(), null, null, null, null, new Configuration(), null, null) {

        @Override
        public Restlet createInboundRoot() {
            // TODO Auto-generated method stub
            Router rootRouter = new Router(getContext());
            // rootRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
            rootRouter.attach("/" + BIOMODEL, BiomodelsServerResource.class);
            rootRouter.attach("/" + BIOMODEL + "/{" + BIOMODELID + "}", BiomodelServerResource.class);
            rootRouter.attach("/" + BIOMODEL + "/{" + BIOMODELID + "}/" + SBML_DOWNLOAD, BiomodelSBMLServerResource.class);
            rootRouter.attach("/" + BIOMODEL + "/{" + BIOMODELID + "}/" + VCML_DOWNLOAD, BiomodelVCMLServerResource.class);
            return rootRouter;
        }

        @Override
        public User getVCellUser(ChallengeResponse response, AuthenticationPolicy authPolicy) {
            // TODO Auto-generated method stub
            return new User("gsoc", new KeyValue("0"));
        }
    };
}
Also used : User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) Configuration(freemarker.template.Configuration) VCellApiApplication(org.vcell.rest.VCellApiApplication) Router(org.restlet.routing.Router) ChallengeResponse(org.restlet.data.ChallengeResponse)

Example 38 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class LoginRestlet method handle.

@Override
public void handle(Request request, Response response) {
    // String html =
    // "<html>" +
    // "/login ... should have been redirected."+
    // "</html>";
    // response.setEntity(html, MediaType.TEXT_HTML);
    VCellApiApplication application = ((VCellApiApplication) getApplication());
    User vcellUser = application.getVCellUser(request.getChallengeResponse(), AuthenticationPolicy.ignoreInvalidCredentials);
    String jsonString = "{}";
    if (vcellUser != null) {
        jsonString = "{user: \"" + vcellUser.getName() + "\"}";
    }
    response.setEntity(new JsonRepresentation(jsonString));
}
Also used : User(org.vcell.util.document.User) VCellApiApplication(org.vcell.rest.VCellApiApplication) JsonRepresentation(org.restlet.ext.json.JsonRepresentation)

Example 39 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class PublicationsServerResource method get_html.

@Override
public Representation get_html() {
    VCellApiApplication application = ((VCellApiApplication) getApplication());
    User vcellUser = application.getVCellUser(getChallengeResponse(), AuthenticationPolicy.ignoreInvalidCredentials);
    PublicationRepresentation[] publications = getPublicationRepresentations(vcellUser);
    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("pubId", getQueryValue(PARAM_PUB_ID));
    dataModel.put("orderBy", getQueryValue(PARAM_ORDERBY));
    dataModel.put("publications", Arrays.asList(publications));
    Gson gson = new Gson();
    dataModel.put("jsonResponse", gson.toJson(publications));
    Configuration templateConfiguration = application.getTemplateConfiguration();
    Representation formFtl = new ClientResource(LocalReference.createClapReference("/publications.ftl")).get();
    TemplateRepresentation templateRepresentation = new TemplateRepresentation(formFtl, templateConfiguration, dataModel, MediaType.TEXT_HTML);
    return templateRepresentation;
}
Also used : 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) PublicationRepresentation(org.vcell.rest.common.PublicationRepresentation) Representation(org.restlet.representation.Representation) PublicationRepresentation(org.vcell.rest.common.PublicationRepresentation) VCellApiApplication(org.vcell.rest.VCellApiApplication) ClientResource(org.restlet.resource.ClientResource)

Example 40 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class SimulationJobStatus method toRep.

public SimpleJobStatusRepresentation toRep() {
    String vcellServerID = getServerID().toString();
    String simulationKey = getVCSimulationIdentifier().getSimulationKey().toString();
    int taskID = getTaskID();
    int jobIndex = getJobIndex();
    long submitDate = getSubmitDate().getTime();
    User owner = getVCSimulationIdentifier().getOwner();
    SimpleJobStatusRepresentation.SchedulerStatus schedulerStatus = SimpleJobStatusRepresentation.SchedulerStatus.valueOf(getSchedulerStatus().name());
    SimpleJobStatusRepresentation.DetailedState detailedState = SimpleJobStatusRepresentation.DetailedState.valueOf(getSimulationMessage().getDetailedState().name());
    String detailedStateMessage = getSimulationMessage().getDisplayMessage();
    Long htcJobNumber = null;
    String htcComputeServer = null;
    SimpleJobStatusRepresentation.BatchSystemType htcBatchSystemType = null;
    Date simexe_startDate = null;
    Date simexe_latestUpdateDate = null;
    Date simexe_endDate = null;
    String computeHost = null;
    Boolean hasData = null;
    SimulationExecutionStatus simExeStatus = getSimulationExecutionStatus();
    if (simExeStatus != null) {
        HtcJobID htcJobID = simExeStatus.getHtcJobID();
        if (htcJobID != null) {
            htcJobNumber = htcJobID.getJobNumber();
            htcComputeServer = htcJobID.getServer();
            htcBatchSystemType = SimpleJobStatusRepresentation.BatchSystemType.valueOf(htcJobID.getBatchSystemType().name());
        }
        simexe_startDate = simExeStatus.getStartDate();
        simexe_latestUpdateDate = simExeStatus.getLatestUpdateDate();
        simexe_endDate = simExeStatus.getEndDate();
        computeHost = simExeStatus.getComputeHost();
        hasData = simExeStatus.hasData();
    }
    Integer queuePriority = null;
    Date queueDate = null;
    SimpleJobStatusRepresentation.SimulationQueueID queueId = null;
    SimulationQueueEntryStatus simQueueStatus = getSimulationQueueEntryStatus();
    if (simQueueStatus != null) {
        queuePriority = simQueueStatus.getQueuePriority();
        queueDate = simQueueStatus.getQueueDate();
        queueId = SimpleJobStatusRepresentation.SimulationQueueID.valueOf(simQueueStatus.getQueueID().name());
    }
    SimpleJobStatusRepresentation rep = new SimpleJobStatusRepresentation(vcellServerID, simulationKey, taskID, jobIndex, new Date(submitDate), owner.getName(), owner.getID().toString(), schedulerStatus, detailedState, detailedStateMessage, htcJobNumber, htcComputeServer, htcBatchSystemType, queuePriority, queueDate, queueId, simexe_startDate, simexe_latestUpdateDate, simexe_endDate, computeHost, hasData);
    return rep;
}
Also used : SimpleJobStatusRepresentation(org.vcell.api.common.SimpleJobStatusRepresentation) User(org.vcell.util.document.User) Date(java.util.Date)

Aggregations

User (org.vcell.util.document.User)192 KeyValue (org.vcell.util.document.KeyValue)89 DataAccessException (org.vcell.util.DataAccessException)60 SQLException (java.sql.SQLException)39 VCellApiApplication (org.vcell.rest.VCellApiApplication)34 File (java.io.File)32 ArrayList (java.util.ArrayList)28 BioModel (cbit.vcell.biomodel.BioModel)27 BigString (org.vcell.util.BigString)27 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)26 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)26 ResultSet (java.sql.ResultSet)21 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)20 Simulation (cbit.vcell.solver.Simulation)19 XMLSource (cbit.vcell.xml.XMLSource)18 XmlParseException (cbit.vcell.xml.XmlParseException)18 BioModelInfo (org.vcell.util.document.BioModelInfo)16 SimulationContext (cbit.vcell.mapping.SimulationContext)15 BigDecimal (java.math.BigDecimal)15 Date (java.util.Date)15