Skip to content

Commit 9932d2f

Browse files
Merge pull request #1498 from virtualcell/parameter-estimation-results-in-login-request
Use Exsiting VCell Connection for Parmater Estimation Request
2 parents fb3ef7b + 310628c commit 9932d2f

14 files changed

Lines changed: 27 additions & 229 deletions

File tree

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package org.vcell.standalone;
22

33
import cbit.vcell.field.db.LocalExternalDataIdentifierServiceImpl;
4-
import cbit.vcell.message.VCMessagingService;
5-
import cbit.vcell.message.jms.activeMQ.VCMessagingServiceActiveMQ;
64
import cbit.vcell.message.server.bootstrap.LocalVCellConnectionFactory;
75
import cbit.vcell.message.server.bootstrap.LocalVCellConnectionServiceImpl;
86
import cbit.vcell.server.LocalVCellConnectionService;
97
import cbit.vcell.server.VCellConnectionFactory;
108
import cbit.vcell.simdata.ExternalDataIdentifierService;
119
import com.google.inject.AbstractModule;
1210
import org.vcell.api.utils.Auth0ConnectionUtils;
13-
import org.vcell.service.registration.RegistrationService;
14-
import org.vcell.service.registration.localdb.LocaldbRegistrationService;
1511

1612
public class VCellStandaloneModule extends AbstractModule {
1713
@Override
@@ -22,6 +18,5 @@ protected void configure() {
2218
bind(Auth0ConnectionUtils.class).toInstance(new Auth0ConnectionUtils());
2319
bind(VCellConnectionFactory.class).to(LocalVCellConnectionFactory.class).asEagerSingleton();
2420

25-
bind(RegistrationService.class).toInstance(new LocaldbRegistrationService());
2621
}
2722
}

vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ public String handleResponse(HttpResponse response) throws HttpResponseException
121121
}
122122

123123
public VCellApiClient(String host, int port, String pathPrefix_v0) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
124-
this(host, port, pathPrefix_v0, false, false);
125-
}
126-
127-
public VCellApiClient(String host, int port, String pathPrefix_v0, boolean bIgnoreCertProblems, boolean bIgnoreHostMismatch) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException{
128-
this(host, port, pathPrefix_v0, false, bIgnoreCertProblems, bIgnoreHostMismatch);
124+
this(host, port, pathPrefix_v0, false, false, false);
129125
}
130126

131127
public VCellApiClient(String host, int port, String pathPrefix_v0, boolean bSkipSSL, boolean bIgnoreCertProblems, boolean bIgnoreHostMismatch) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
@@ -363,22 +359,6 @@ public String handleResponse(final HttpResponse response) throws ClientProtocolE
363359
message = reader.lines().collect(Collectors.joining());
364360
}
365361
return message;
366-
// HttpEntity entity = response.getEntity();
367-
// if (lg.isInfoEnabled()) {
368-
// try (BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));){
369-
// lg.info("optimizationId = "+reader.readLine());
370-
// }
371-
// }
372-
// final Header locationHeader = response.getFirstHeader("location");
373-
// if (locationHeader == null) {
374-
// // got a redirect response, but no location header
375-
// throw new ClientProtocolException(
376-
// "Received redirect response " + response.getStatusLine()
377-
// + " but no location header");
378-
// }
379-
// final String location = locationHeader.getValue();
380-
// URI uri = createLocationURI(location);
381-
// return uri.toString();
382362
} else {
383363
HttpEntity entity = response.getEntity();
384364
String message = null;
@@ -398,8 +378,6 @@ public String handleResponse(final HttpResponse response) throws ClientProtocolE
398378
}
399379

400380
return responseUri;
401-
// String optimizationId = responseUri.substring(responseUri.lastIndexOf('/') + 1);
402-
// return optimizationId;
403381
}
404382

405383
/**

vcell-apiclient/src/main/java/org/vcell/api/server/ClientServerManager.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import cbit.vcell.simdata.VCDataManager;
2424
import org.apache.logging.log4j.LogManager;
2525
import org.apache.logging.log4j.Logger;
26+
import org.vcell.api.client.VCellApiClient;
2627
import org.vcell.api.messaging.RemoteProxyVCellConnectionFactory;
2728
import org.vcell.api.utils.Auth0ConnectionUtils;
28-
import org.vcell.service.registration.RegistrationService;
2929
import org.vcell.util.Compare;
3030
import org.vcell.util.DataAccessException;
3131
import org.vcell.util.VCellThreadChecker;
@@ -823,7 +823,11 @@ void setDisconnected() {
823823
setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), getClientServerInfo().getApihost(), getClientServerInfo().getApiport(), ConnectionStatus.DISCONNECTED));
824824
}
825825

826-
public RegistrationService getRegistrationProvider() {
827-
return new VCellConnectionRegistrationProvider(this.vcellConnection);
828-
}
826+
public VCellApiClient getVCellApiClient(){
827+
if (vcellConnectionFactory instanceof RemoteProxyVCellConnectionFactory remoteProxyVCellConnectionFactory){
828+
return remoteProxyVCellConnectionFactory.getVCellApiClient();
829+
}
830+
throw new UnsupportedOperationException("This function should only be called with RemoteProxyVCellConnectionFactory");
831+
}
832+
829833
}

vcell-client/src/main/java/cbit/vcell/client/ClientRequestManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ public AsynchMessageManager getAsynchMessageManager() {
28332833
return getClientServerManager().getAsynchMessageManager();
28342834
}
28352835

2836-
private ClientServerManager getClientServerManager() {
2836+
public ClientServerManager getClientServerManager() {
28372837
// shorthand
28382838
return getVcellClient().getClientServerManager();
28392839
}

vcell-client/src/main/java/cbit/vcell/client/VCellClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import cbit.vcell.server.VCellConnectionFactory;
2222
import com.google.inject.Inject;
2323
import com.install4j.api.launcher.ApplicationLauncher;
24+
import org.vcell.api.client.VCellApiClient;
2425
import org.vcell.api.messaging.RemoteProxyVCellConnectionFactory;
2526
import org.vcell.api.server.ClientServerManager;
2627
import org.vcell.api.server.ClientServerManager.InteractiveContextDefaultProvider;
@@ -47,7 +48,7 @@ public class VCellClient {
4748

4849
private static VCellClient instance = null;
4950

50-
public static void setInstance(VCellClient instance) {
51+
private static void setInstance(VCellClient instance) {
5152
VCellClient.instance = instance;
5253
}
5354
public static VCellClient getInstance() {

vcell-client/src/main/java/copasi/CopasiOptimizationSolverRemote.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package copasi;
22

3+
import cbit.vcell.client.ClientRequestManager;
4+
import cbit.vcell.client.RequestManager;
5+
import cbit.vcell.client.VCellClient;
36
import cbit.vcell.client.server.ClientServerInfo;
47
import cbit.vcell.modelopt.ParameterEstimationTask;
58
import cbit.vcell.opt.OptimizationException;
@@ -25,20 +28,13 @@ public static OptimizationResultSet solveRemoteApi(
2528
ParameterEstimationTask parameterEstimationTask,
2629
CopasiOptSolverCallbacks optSolverCallbacks,
2730
ClientTaskStatusSupport clientTaskStatusSupport,
28-
ClientServerInfo clientServerInfo) {
31+
ClientRequestManager requestManager) {
2932

3033
// return solveLocalPython(parameterEstimationTask);
3134

3235
try {
33-
boolean bIgnoreCertProblems = PropertyLoader.getBooleanProperty(PropertyLoader.sslIgnoreCertProblems, false);
34-
boolean bIgnoreHostMismatch = PropertyLoader.getBooleanProperty(PropertyLoader.sslIgnoreHostMismatch, false);
35-
36-
String host = clientServerInfo.getApihost();
37-
int port = clientServerInfo.getApiport();
38-
String pathPrefixV0 = clientServerInfo.getPathPrefix_v0();
3936
// e.g. vcell.serverhost=vcellapi.cam.uchc.edu:443
40-
VCellApiClient apiClient = new VCellApiClient(host, port, pathPrefixV0, bIgnoreCertProblems, bIgnoreHostMismatch);
41-
apiClient.authenticate(bIgnoreCertProblems);
37+
VCellApiClient apiClient = requestManager.getClientServerManager().getVCellApiClient();
4238

4339
OptProblem optProblem = CopasiUtils.paramTaskToOptProblem(parameterEstimationTask);
4440

vcell-client/src/main/java/org/vcell/dependency/client/VCellClientModule.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package org.vcell.dependency.client;
22

3-
import org.vcell.api.messaging.RemoteProxyVCellConnectionFactory;
43
import cbit.vcell.server.VCellConnectionFactory;
54
import cbit.vcell.simdata.ExternalDataIdentifierService;
65
import com.google.inject.AbstractModule;
76
import com.google.inject.name.Names;
87
import org.vcell.DependencyConstants;
9-
import org.vcell.service.registration.RegistrationService;
10-
import org.vcell.util.network.RemoteRegistrationService;
8+
import org.vcell.api.messaging.RemoteProxyVCellConnectionFactory;
119
import org.vcell.util.document.ExternalDataIdentifier;
1210
import org.vcell.util.document.User;
1311

@@ -49,8 +47,6 @@ protected void configure() {
4947

5048
bind(VCellConnectionFactory.class).to(RemoteProxyVCellConnectionFactory.class).asEagerSingleton();
5149

52-
// RegistrationService interface is not clean - mixes new registration with updates - is there another way?
53-
bind(RegistrationService.class).toInstance(new RemoteRegistrationService()); // used on remote client.
5450

5551
bind(String.class).annotatedWith(Names.named(DependencyConstants.VCELL_API_HOST)).toInstance(apiHost);
5652
bind(Integer.class).annotatedWith(Names.named(DependencyConstants.VCELL_API_PORT)).toInstance(apiPort);

vcell-client/src/main/java/org/vcell/optimization/gui/ParameterEstimationRunTaskPanel.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import cbit.plot.PlotData;
1515
import cbit.plot.gui.Plot2DPanel;
1616
import cbit.vcell.client.ClientRequestManager;
17+
import cbit.vcell.client.RequestManager;
1718
import cbit.vcell.client.TopLevelWindowManager;
1819
import cbit.vcell.client.VCellLookAndFeel;
1920
import cbit.vcell.client.constants.GuiConstants;
@@ -1162,14 +1163,18 @@ public void run(Hashtable<String, Object> hashTable) throws Exception {
11621163
};
11631164
taskList.add(task1);
11641165

1165-
AsynchClientTask task2 = new AsynchClientTask("Starting param esitmation job...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
1166+
AsynchClientTask task2 = new AsynchClientTask("Starting param estimation job...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
11661167
@Override
11671168
public void run(Hashtable<String, Object> hashTable) throws Exception {
11681169
// OptimizationResultSet optResultSet = CopasiOptimizationSolver.solveLocalPython(parameterEstimationTask);
1169-
ClientServerInfo clientServerInfo = TopLevelWindowManager.activeManager().getRequestManager().getClientServerInfo();
11701170
optSolverCallbacks.setProgressReport(new OptProgressReport());
1171-
OptimizationResultSet optResultSet = CopasiOptimizationSolverRemote.solveRemoteApi(parameterEstimationTask, optSolverCallbacks, getClientTaskStatusSupport(), clientServerInfo);
1172-
hashTable.put(ORS_KEY, optResultSet);
1171+
RequestManager requestManager = TopLevelWindowManager.activeManager().getRequestManager();
1172+
if (requestManager instanceof ClientRequestManager clientRequestManager){
1173+
OptimizationResultSet optResultSet = CopasiOptimizationSolverRemote.solveRemoteApi(parameterEstimationTask, optSolverCallbacks, getClientTaskStatusSupport(), clientRequestManager);
1174+
hashTable.put(ORS_KEY, optResultSet);
1175+
} else {
1176+
throw new UnsupportedOperationException("Requires remote connection to do parameter estimation.");
1177+
}
11731178
}
11741179

11751180
};

vcell-client/src/main/java/org/vcell/util/network/RemoteRegistrationService.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

vcell-core/src/main/java/cbit/vcell/client/server/ClientServerInterface.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import cbit.vcell.server.SessionManager;
99
import cbit.vcell.server.VCellConnection;
1010
import cbit.vcell.simdata.VCDataManager;
11-
import org.vcell.service.registration.RegistrationService;
1211

1312
import java.io.IOException;
1413

@@ -39,5 +38,4 @@ public interface ClientServerInterface extends SessionManager, DataSetController
3938
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener);
4039
public void sendErrorReport(Throwable exception );
4140
public void sendErrorReport(Throwable exception, VCellConnection.ExtraContext extraContext);
42-
public RegistrationService getRegistrationProvider();
4341
}

0 commit comments

Comments
 (0)