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);
}
}
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);
}
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);
}
}
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();
}
}
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);
}
}
Aggregations