Skip to content

Commit c0c13e6

Browse files
committed
Frontend Field Data From Sim
1 parent 285b8ea commit c0c13e6

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

vcell-apiclient/src/main/java/org/vcell/api/messaging/LocalUserMetaDbServerMessaging.java

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.apache.logging.log4j.LogManager;
2828
import org.apache.logging.log4j.Logger;
2929
import org.vcell.api.client.VCellApiClient;
30+
import org.vcell.restclient.ApiException;
31+
import org.vcell.restclient.model.CreateFieldDataFromSimulation;
3032
import org.vcell.restclient.model.FieldDataReference;
3133
import org.vcell.restclient.utils.DtoModelTransforms;
3234
import org.vcell.util.BigString;
@@ -141,6 +143,15 @@ public FieldDataDBOperationResults fieldDataDBOperation(FieldDataDBOperationSpec
141143
}
142144
}
143145

146+
public void fieldDataFromSimulation(KeyValue sourceSim, int jobIndex, String newFieldDataName) {
147+
try {
148+
vCellApiClient.getFieldDataApi().createNewFieldDataFromSimulation(sourceSim.toString(), jobIndex, newFieldDataName);
149+
} catch (ApiException e) {
150+
throw new RuntimeException(e);
151+
}
152+
}
153+
154+
144155

145156
/**
146157
* Insert the method's description here.

vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java

+10-29
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import cbit.vcell.solver.SimulationInfo;
3434
import org.vcell.util.*;
3535
import org.vcell.util.document.ExternalDataIdentifier;
36+
import org.vcell.util.document.KeyValue;
3637
import org.vcell.util.document.VCDocument;
3738
import org.vcell.util.document.Version;
3839
import org.vcell.util.gui.DialogUtils;
@@ -611,6 +612,9 @@ private void fdFromSim(java.awt.event.ActionEvent actionEvent) {
611612
PopupGenerator.showErrorDialog(this, "Please open a Bio or Math model containing the spatial (non-compartmental) simulation you wish to use to create a new Field Data");
612613
return;
613614
}
615+
616+
String newFieldDataName = PopupGenerator.showInputDialog(this, "Field Data Name:", "");
617+
614618
//Check that the sim is in a state that can be copied
615619
final SimulationInfo simInfo = simInfoHolder.getSimInfo();
616620
if (simInfo == null) {
@@ -625,36 +629,13 @@ private void fdFromSim(java.awt.event.ActionEvent actionEvent) {
625629
(simInfo.getParentSimulationReference() != null ? simInfo.getParentSimulationReference() : simInfo.getSimulationVersion().getVersionKey()),
626630
simInfo.getOwner(), simInfoHolder.getJobIndex(), clientRequestManager.getDocumentManager().getUser());
627631

628-
AsynchClientTask[] addTasks = addNewExternalData(this, this, true);
629-
AsynchClientTask[] taskArray = new AsynchClientTask[1 + addTasks.length];
630-
System.arraycopy(addTasks, 0, taskArray, 1, addTasks.length); // add to the end
632+
AsynchClientTask[] taskArray = new AsynchClientTask[1];
631633

632-
taskArray[0] = new AsynchClientTask("Create Field Data from Simulation", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
634+
taskArray[0] = new AsynchClientTask("Saving Field Data From Simulation", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
633635
public void run(Hashtable<String, Object> hashTable) throws Exception {
634-
FieldDataFileOperationResults fdor =
635-
clientRequestManager.getDocumentManager().fieldDataFileOperation(
636-
FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(
637-
(simInfo.getParentSimulationReference() != null ?
638-
simInfo.getParentSimulationReference() :
639-
simInfo.getSimulationVersion().getVersionKey()
640-
),
641-
simInfo.getOwner(),
642-
simInfoHolder.getJobIndex()));
643-
//Create (non-editable) info for display
644-
fdos.origin = fdor.origin;
645-
fdos.extent = fdor.extent;
646-
fdos.isize = fdor.iSize;
647-
fdos.times = fdor.times;
648-
fdos.varNames = new String[fdor.dataIdentifierArr.length];
649-
for (int i = 0; i < fdor.dataIdentifierArr.length; i += 1) {
650-
fdos.varNames[i] =
651-
(fdor.dataIdentifierArr[i].getVariableType().equals(VariableType.VOLUME) ? "(vol) " : "") +
652-
(fdor.dataIdentifierArr[i].getVariableType().equals(VariableType.MEMBRANE) ? "(mbr) " : "") +
653-
fdor.dataIdentifierArr[i].getName();
654-
}
655-
hashTable.put("fdos", fdos);
656-
hashTable.put("initFDName", simInfo.getName());
657-
//addNewExternalData(clientRequestManager, fdos, simInfoHolder.simInfo.getName(), true);
636+
KeyValue simReference = simInfo.getParentSimulationReference() != null ? simInfo.getParentSimulationReference() : simInfo.getSimulationVersion().getVersionKey();
637+
clientRequestManager.getDocumentManager().fieldDataFromSimulation(simReference, simInfoHolder.getJobIndex(), newFieldDataName);
638+
updateJTree(clientRequestManager);
658639
}
659640
};
660641

@@ -1050,7 +1031,7 @@ public void checkFieldDataName(String fieldDataName) throws Exception {
10501031
}
10511032
}
10521033
}
1053-
1034+
10541035
// creation and saving of file is separate act from saving file info into DB
10551036

10561037
public static AsynchClientTask[] addNewExternalData(final Component requester, final FieldDataGUIPanel fieldDataGUIPanel, final boolean isFromSimulation) {

vcell-core/src/main/java/cbit/vcell/clientdb/ClientDocumentManager.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,11 @@ public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperati
512512
}
513513

514514

515-
public TestSuiteOPResults doTestSuiteOP(TestSuiteOP tsop) throws DataAccessException {
515+
public void fieldDataFromSimulation(KeyValue sourceSim, int jobIndex, String newFieldDataName) throws DataAccessException {
516+
sessionManager.getUserMetaDbServer().fieldDataFromSimulation(sourceSim, jobIndex, newFieldDataName);
517+
}
518+
519+
public TestSuiteOPResults doTestSuiteOP(TestSuiteOP tsop) throws DataAccessException {
516520
if(!getUser().isTestAccount()){
517521
throw new PermissionException("User="+getUser().getName()+" not allowed TestSuiteInfo");
518522
}

vcell-core/src/main/java/cbit/vcell/clientdb/DocumentManager.java

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public interface DocumentManager {
165165

166166
FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws DataAccessException;
167167

168+
void fieldDataFromSimulation(KeyValue sourceSim, int jobIndex, String newFieldDataName) throws DataAccessException;
169+
168170
/**
169171
* Insert the method's description here.
170172
* Creation date: (10/28/00 12:07:09 AM)

0 commit comments

Comments
 (0)