Search in sources :

Example 1 with VCellApiClient

use of org.vcell.api.client.VCellApiClient in project vcell by virtualcell.

the class RemoteRegistrationService method sendLostPassword.

@Override
public void sendLostPassword(String userid) throws DataAccessException, RemoteProxyException {
    // e.g. vcell.serverhost=vcellapi.cam.uchc.edu:8080
    String serverHost = PropertyLoader.getRequiredProperty(PropertyLoader.vcellServerHost);
    String[] parts = serverHost.split(":");
    String host = parts[0];
    int port = Integer.parseInt(parts[1]);
    boolean bIgnoreCertProblems = false;
    boolean bIgnoreHostMismatch = false;
    VCellApiClient apiClient;
    try {
        apiClient = new VCellApiClient(host, port, bIgnoreCertProblems, bIgnoreHostMismatch);
    } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
        e.printStackTrace();
        throw new RemoteProxyException("failure in send lost password request: " + e.getMessage(), e);
    }
    try {
        apiClient.sendLostPassword(userid);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RemoteProxyException("failed to request lost password: " + e.getMessage(), e);
    }
}
Also used : NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStoreException(java.security.KeyStoreException) VCellApiClient(org.vcell.api.client.VCellApiClient) KeyManagementException(java.security.KeyManagementException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) KeyStoreException(java.security.KeyStoreException) DataAccessException(org.vcell.util.DataAccessException) UseridIDExistsException(org.vcell.util.UseridIDExistsException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 2 with VCellApiClient

use of org.vcell.api.client.VCellApiClient in project vcell by virtualcell.

the class RemoteRegistrationService method insertUserInfo.

@Override
public UserInfo insertUserInfo(UserInfo newUserInfo, boolean bUpdate) throws RemoteProxyException, DataAccessException, UseridIDExistsException {
    // e.g. vcell.serverhost=vcellapi.cam.uchc.edu:8080
    String serverHost = PropertyLoader.getRequiredProperty(PropertyLoader.vcellServerHost);
    String[] parts = serverHost.split(":");
    String host = parts[0];
    int port = Integer.parseInt(parts[1]);
    boolean bIgnoreCertProblems = false;
    boolean bIgnoreHostMismatch = false;
    VCellApiClient apiClient;
    try {
        apiClient = new VCellApiClient(host, port, bIgnoreCertProblems, bIgnoreHostMismatch);
    } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
        e.printStackTrace();
        throw new RemoteProxyException("failure inserting user: " + e.getMessage(), e);
    }
    org.vcell.api.common.UserInfo apiUserInfo;
    try {
        apiUserInfo = apiClient.insertUserInfo(newUserInfo.getApiUserInfo());
    } catch (IOException e) {
        e.printStackTrace();
        throw new RemoteProxyException("failed to insert user: " + e.getMessage(), e);
    }
    return UserInfo.fromApiUserInfo(apiUserInfo);
}
Also used : NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) VCellApiClient(org.vcell.api.client.VCellApiClient) KeyManagementException(java.security.KeyManagementException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 3 with VCellApiClient

use of org.vcell.api.client.VCellApiClient in project vcell by virtualcell.

the class RemoteProxyVCellConnectionFactory method getVCellSoftwareVersion.

public static String getVCellSoftwareVersion(String apihost, Integer apiport) {
    boolean bIgnoreCertProblems = true;
    boolean bIgnoreHostMismatch = true;
    try {
        VCellApiClient tempApiClient = new VCellApiClient(apihost, apiport, bIgnoreCertProblems, bIgnoreHostMismatch);
        String serverSoftwareVersion = tempApiClient.getServerSoftwareVersion();
        return serverSoftwareVersion;
    } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
        e.printStackTrace();
        throw new RuntimeException("VCellApiClient configuration exception: " + e.getMessage(), e);
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException("VCellApiClient communication exception while retrieving server software version: " + e.getMessage(), e);
    }
}
Also used : NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) VCellApiClient(org.vcell.api.client.VCellApiClient) KeyManagementException(java.security.KeyManagementException)

Example 4 with VCellApiClient

use of org.vcell.api.client.VCellApiClient in project vcell by virtualcell.

the class OptimizationApiTest method main.

public static void main(String[] args) {
    try {
        boolean bIgnoreCertProblems = true;
        boolean bIgnoreHostMismatch = true;
        VCellApiClient apiClient = new VCellApiClient(host, port, bIgnoreCertProblems, bIgnoreHostMismatch);
        File optProbFile = new File("../pythonScripts/VCell_Opt/optprob.bin");
        System.out.println("using optProblem: " + optProbFile.getAbsolutePath());
        OptProblem optProblem = readOptProblem(optProbFile);
        TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
        String optProblemJson = serializer.toString(optProblem);
        ArrayList<String> jobIDs = new ArrayList<String>();
        jobIDs.add(apiClient.submitOptimization(optProblemJson));
        jobIDs.add(apiClient.submitOptimization(optProblemJson));
        jobIDs.add(apiClient.submitOptimization(optProblemJson));
        jobIDs.add(apiClient.submitOptimization(optProblemJson));
        boolean done = false;
        while (!done) {
            done = true;
            for (String jobID : jobIDs) {
                String optRunJson = apiClient.getOptRunJson(jobID);
                TDeserializer deserializer = new TDeserializer(new TJSONProtocol.Factory());
                OptRun optRun = new OptRun();
                deserializer.deserialize(optRun, optRunJson.getBytes());
                OptRunStatus status = optRun.status;
                if (status != OptRunStatus.Complete && status != OptRunStatus.Failed) {
                    done = false;
                }
                if (status == OptRunStatus.Complete) {
                    System.out.println("job " + jobID + ": status " + status + " " + optRun.getOptResultSet().toString());
                } else {
                    System.out.println("job " + jobID + ": status " + status);
                }
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
        }
        System.out.println("done with all jobs");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) OptProblem(org.vcell.optimization.thrift.OptProblem) ArrayList(java.util.ArrayList) VCellApiClient(org.vcell.api.client.VCellApiClient) TException(org.apache.thrift.TException) IOException(java.io.IOException) TSerializer(org.apache.thrift.TSerializer) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) OptRunStatus(org.vcell.optimization.thrift.OptRunStatus) OptRun(org.vcell.optimization.thrift.OptRun) File(java.io.File)

Example 5 with VCellApiClient

use of org.vcell.api.client.VCellApiClient in project vcell by virtualcell.

the class VCSchedulerPanel method main.

public static void main(String[] args) {
    try {
        if (args.length != 3) {
            System.out.println("usage: VCellApiClient host userid password");
            System.exit(1);
        }
        String host = args[0];
        int port = 8080;
        String username = args[1];
        String password = args[2];
        JFrame jframe = new JFrame();
        VCSchedulerPanel panel = new VCSchedulerPanel();
        panel.setUsername(username);
        panel.setPassword(password);
        boolean bIgnoreCertProblems = true;
        boolean bIgnoreHostMismatch = true;
        panel.vcellApiClient = new VCellApiClient(host, port, bIgnoreCertProblems, bIgnoreHostMismatch);
        jframe.getContentPane().add(panel);
        jframe.setSize(800, 500);
        jframe.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                super.windowClosing(e);
                System.exit(0);
            }
        });
        jframe.setVisible(true);
    // test /biomodel[? query string]
    // boolean bFirstSimulationToStartStop = true;
    // if (biomodelReps.length>0){
    // // test /biomodel/[bmkey]
    // System.out.println(" ... re-fetching first biomodel owned by me ...");
    // BioModelsQuerySpec bioModelsQuerySpec = new BioModelsQuerySpec();
    // bioModelsQuerySpec.owner = username;
    // BiomodelRepresentation firstBiomodelRep = vcellApiClient.getBioModels(bioModelsQuerySpec)[0];
    // System.out.println("biomodel : "+firstBiomodelRep.getBmKey()+" : "+firstBiomodelRep.getName());
    // for (ApplicationRepresentation appRep : firstBiomodelRep.getApplications()){
    // System.out.println("   appRep : "+appRep.getName());
    // }
    // for (SimulationRepresentation simRep : firstBiomodelRep.getSimulations()){
    // System.out.println("   simRep (returned with BioModelRep) : "+simRep.getKey()+" : "+simRep.getName());
    // 
    // // test /biomodel/[bmkey]/simulation/simkey
    // SimulationRepresentation simulation = vcellApiClient.getSimulation(firstBiomodelRep.getBmKey(), simRep.getKey());
    // System.out.println("   simRep (retrieved separately) : "+simulation.getKey()+" : "+simulation.getName());
    // 
    // if (bFirstSimulationToStartStop){
    // bFirstSimulationToStartStop = false;
    // // test /biomodel/[bmkey]/simulation/[simkey]/startSimulation
    // SimTasksQuerySpec simTasksQuerySpec = new SimTasksQuerySpec();
    // simTasksQuerySpec.simId = simRep.getKey();
    // SimulationTaskRepresentation[] beforeStartSimTasks = vcellApiClient.getSimTasks(simTasksQuerySpec);
    // System.out.println("SENDING START SIMULATION");
    // SimulationTaskRepresentation[] justAfterStartSimTasks = vcellApiClient.startSimulation(firstBiomodelRep.getBmKey(), simRep.getKey());
    // System.out.println("SENT START SIMULATION");
    // 
    // System.out.println("WAITING 5 seconds");
    // try {
    // Thread.sleep(5000);
    // }catch (Exception e){}
    // SimulationTaskRepresentation[] longAfterStartSimTasks = vcellApiClient.getSimTasks(simTasksQuerySpec);
    // 
    // 
    // System.out.println("SENDING STOP SIMULATION");
    // SimulationTaskRepresentation[] justAfterStopSimTasks = vcellApiClient.stopSimulation(firstBiomodelRep.getBmKey(), simRep.getKey());
    // System.out.println("SENT STOP SIMULATION");
    // 
    // System.out.println("WAITING 5 seconds");
    // try {
    // Thread.sleep(5000);
    // }catch (Exception e){}
    // SimulationTaskRepresentation[] longAfterStopSimTasks = vcellApiClient.getSimTasks(simTasksQuerySpec);
    // 
    // System.out.println("\n\nsimulation status:");
    // for (SimulationTaskRepresentation simTaskRep : beforeStartSimTasks){
    // System.out.println("    BEFORE START Job = "+simTaskRep.getJobIndex()+", Task = "+simTaskRep.getTaskId()+", Status = "+simTaskRep.getStatus());
    // }
    // for (SimulationTaskRepresentation simTaskRep : justAfterStartSimTasks){
    // System.out.println("    JUST AFTER START Job = "+simTaskRep.getJobIndex()+", Task = "+simTaskRep.getTaskId()+", Status = "+simTaskRep.getStatus());
    // }
    // for (SimulationTaskRepresentation simTaskRep : longAfterStartSimTasks){
    // System.out.println("    LONG AFTER START Job = "+simTaskRep.getJobIndex()+", Task = "+simTaskRep.getTaskId()+", Status = "+simTaskRep.getStatus());
    // }
    // for (SimulationTaskRepresentation simTaskRep : justAfterStopSimTasks){
    // System.out.println("    JUST AFTER STOP Job = "+simTaskRep.getJobIndex()+", Task = "+simTaskRep.getTaskId()+", Status = "+simTaskRep.getStatus());
    // }
    // for (SimulationTaskRepresentation simTaskRep : longAfterStopSimTasks){
    // System.out.println("    LONG AFTER STOP Job = "+simTaskRep.getJobIndex()+", Task = "+simTaskRep.getTaskId()+", Status = "+simTaskRep.getStatus());
    // }
    // System.out.println("\n\n");
    // }
    // System.out.println("\n");
    // }
    // }
    // 
    // // test /simtask
    // SimulationTaskRepresentation[] simTaskReps = vcellApiClient.getSimTasks(new SimTasksQuerySpec());
    // for (SimulationTaskRepresentation simTaskRep : simTaskReps){
    // System.out.println("simTask : "+simTaskRep.getSimKey()+" : "+simTaskRep.getSimName());
    // }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
}
Also used : JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) VCellApiClient(org.vcell.api.client.VCellApiClient)

Aggregations

VCellApiClient (org.vcell.api.client.VCellApiClient)8 IOException (java.io.IOException)7 KeyManagementException (java.security.KeyManagementException)4 KeyStoreException (java.security.KeyStoreException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)2 ArrayList (java.util.ArrayList)2 TDeserializer (org.apache.thrift.TDeserializer)2 TSerializer (org.apache.thrift.TSerializer)2 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)2 BioModelsQuerySpec (org.vcell.api.client.query.BioModelsQuerySpec)2 ApplicationRepresentation (org.vcell.api.common.ApplicationRepresentation)2 BiomodelRepresentation (org.vcell.api.common.BiomodelRepresentation)2 OptProblem (org.vcell.optimization.thrift.OptProblem)2 OptRun (org.vcell.optimization.thrift.OptRun)2 OptRunStatus (org.vcell.optimization.thrift.OptRunStatus)2 MathException (cbit.vcell.math.MathException)1 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)1 OptSolverResultSet (cbit.vcell.opt.OptSolverResultSet)1 OptRunResultSet (cbit.vcell.opt.OptSolverResultSet.OptRunResultSet)1