diff --git a/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java b/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java index 10a57e3c8f..fcbfb2803c 100644 --- a/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java +++ b/vcell-client/src/main/java/cbit/vcell/field/gui/FieldDataGUIPanel.java @@ -798,8 +798,6 @@ public void run(Hashtable hash) throws Exception { FieldDataFileOperationSpec fdos = FieldDataFileOperationSpec.createDeleteFieldDataFileOperationSpec( fieldDataMainList.externalDataIdentifier); clientRequestManager.getDocumentManager().fieldDataFileOperation(fdos); - //Remove from DB - fieldDataWindowManager.deleteExternalDataIdentifier(fieldDataMainList.externalDataIdentifier); } }; // @@ -1173,12 +1171,6 @@ public void run(Hashtable hashTable) throws Exception { FieldDataFileOperationResults results = documentManager.fieldDataFileOperation(generatedFieldDataOpSpec); generatedFieldDataOpSpec.specEDI = results.externalDataIdentifier; } catch (Exception e) { - try { - //try to cleanup new ExtDataID - documentManager.fieldDataDBOperation(FieldDataDBOperationSpec.createDeleteExtDataIDSpec(generatedFieldDataOpSpec.specEDI)); - } catch (Exception e2) { - //ignore - } generatedFieldDataOpSpec.specEDI = null; throw e; } diff --git a/vcell-core/src/main/java/cbit/vcell/field/io/FieldDataFileOperationSpec.java b/vcell-core/src/main/java/cbit/vcell/field/io/FieldDataFileOperationSpec.java index 4dd83ee254..9ae1569fac 100644 --- a/vcell-core/src/main/java/cbit/vcell/field/io/FieldDataFileOperationSpec.java +++ b/vcell-core/src/main/java/cbit/vcell/field/io/FieldDataFileOperationSpec.java @@ -10,6 +10,7 @@ package cbit.vcell.field.io; +import org.vcell.restclient.model.AnalyzedResultsFromFieldData; import org.vcell.restclient.model.FieldDataFileOperationResults; import org.vcell.util.Extent; import org.vcell.util.ISize; @@ -21,6 +22,11 @@ import cbit.vcell.math.VariableType; import cbit.vcell.solvers.CartesianMesh; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * Insert the type's description here. * Creation date: (1/10/2007 11:00:51 AM) @@ -83,6 +89,26 @@ public FieldDataFileOperationSpec(short[][][] shortSpecData, double[][][] double this.sourceOwner = sourceOwner; } +public static AnalyzedResultsFromFieldData fieldDataSpecToAnalyzedResultsDTO(FieldDataFileOperationSpec fieldDataFileOperationSpec){ + List>> listVersion = Arrays.stream(fieldDataFileOperationSpec.shortSpecData) // Stream of short[][] + .map(twoDArray -> Arrays.stream(twoDArray) // Stream of short[] + .map(oneDArray -> { + List list = new ArrayList<>(); + for (short j : oneDArray) { + list.add((int) j); + } + return list; + }).collect(Collectors.toList())).collect(Collectors.toList()); + AnalyzedResultsFromFieldData analyzedResultsFromFieldData = new AnalyzedResultsFromFieldData(); + analyzedResultsFromFieldData.annotation(fieldDataFileOperationSpec.annotation); analyzedResultsFromFieldData.isize(ISize.iSizeToDTO(fieldDataFileOperationSpec.isize)); + analyzedResultsFromFieldData.extent(Extent.extentToDTO(fieldDataFileOperationSpec.extent)); analyzedResultsFromFieldData.origin(Origin.originToDTO(fieldDataFileOperationSpec.origin)); + analyzedResultsFromFieldData.times(Arrays.stream(fieldDataFileOperationSpec.times).boxed().toList()); analyzedResultsFromFieldData.setName(fieldDataFileOperationSpec.fieldDataName); + analyzedResultsFromFieldData.varNames(Arrays.stream(fieldDataFileOperationSpec.varNames).toList()); analyzedResultsFromFieldData.shortSpecData(listVersion); + return analyzedResultsFromFieldData; +} + + +@Deprecated public static FieldDataFileOperationSpec createCopySimFieldDataFileOperationSpec( ExternalDataIdentifier newExtDataID, KeyValue argSourceSimDataKey, @@ -99,6 +125,8 @@ public static FieldDataFileOperationSpec createCopySimFieldDataFileOperationSpec fieldDataFileOperationSpec.owner = destinationOwner; return fieldDataFileOperationSpec; } + +@Deprecated public static FieldDataFileOperationSpec createInfoFieldDataFileOperationSpec( KeyValue argSourceSimDataKey,User argSourceOwner,int argSimParamScanJobIndex){ FieldDataFileOperationSpec fieldDataFileOperationSpec = @@ -109,6 +137,8 @@ public static FieldDataFileOperationSpec createInfoFieldDataFileOperationSpec( fieldDataFileOperationSpec.sourceSimParamScanJobIndex = argSimParamScanJobIndex; return fieldDataFileOperationSpec; } + +@Deprecated public static FieldDataFileOperationSpec createDeleteFieldDataFileOperationSpec( ExternalDataIdentifier deleteExtDataID){ FieldDataFileOperationSpec fieldDataFileOperationSpec = diff --git a/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalDataSetControllerMessaging.java b/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalDataSetControllerMessaging.java index 07e1e3ba34..7716722725 100644 --- a/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalDataSetControllerMessaging.java +++ b/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalDataSetControllerMessaging.java @@ -13,14 +13,14 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.vcell.api.client.VCellApiClient; -import org.vcell.restclient.model.SaveFieldDataFromFile; -import org.vcell.restclient.model.VariableType; +import org.vcell.restclient.model.*; import org.vcell.solver.nfsim.NFSimMolecularConfigurations; import org.vcell.util.DataAccessException; import org.vcell.util.Extent; import org.vcell.util.ISize; import org.vcell.util.Origin; import org.vcell.util.document.ExternalDataIdentifier; +import org.vcell.util.document.KeyValue; import org.vcell.util.document.UserLoginInfo; import org.vcell.util.document.VCDataIdentifier; import org.vcell.vis.io.VtuFileContainer; @@ -72,25 +72,18 @@ public LocalDataSetControllerMessaging (UserLoginInfo userLoginInfo, RpcSender r public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws DataAccessException { if (lg.isTraceEnabled()) lg.trace("LocalDataSetControllerMessaging.fieldDataFileOperationSpec(...)"); try { - if (fieldDataFileOperationSpec.opType != FieldDataFileOperationSpec.FDOS_ADD){ + if (fieldDataFileOperationSpec.opType == FieldDataFileOperationSpec.FDOS_ADD){ + AnalyzedResultsFromFieldData analyzedResultsFromFieldData = FieldDataFileOperationSpec.fieldDataSpecToAnalyzedResultsDTO(fieldDataFileOperationSpec); + FieldDataSaveResults results = vCellApiClient.getFieldDataApi().createNewFieldDataFromFileAlreadyAnalyzed(analyzedResultsFromFieldData); + FieldDataFileOperationResults fieldDataFileOperationResults = new FieldDataFileOperationResults(); + fieldDataFileOperationResults.externalDataIdentifier = new ExternalDataIdentifier(new KeyValue(results.getFieldDataID()), fieldDataFileOperationSpec.owner, results.getFieldDataName()); + return fieldDataFileOperationResults; + } else if (fieldDataFileOperationSpec.opType == FieldDataFileOperationSpec.FDOS_DELETE) { + vCellApiClient.getFieldDataApi().deleteFieldData(fieldDataFileOperationSpec.specEDI.getKey().toString()); + return null; + } + else { return dataServerProxy.fieldDataFileOperation(fieldDataFileOperationSpec); - } else { - List>> listVersion = Arrays.stream(fieldDataFileOperationSpec.shortSpecData) // Stream of short[][] - .map(twoDArray -> Arrays.stream(twoDArray) // Stream of short[] - .map(oneDArray -> { - List list = new ArrayList<>(); - for (short j : oneDArray) { - list.add((int) j); - } - return list; - }).collect(Collectors.toList())).collect(Collectors.toList()); - SaveFieldDataFromFile saveFieldDataFromFile = new SaveFieldDataFromFile(); - saveFieldDataFromFile.annotation(fieldDataFileOperationSpec.annotation); saveFieldDataFromFile.isize(ISize.iSizeToDTO(fieldDataFileOperationSpec.isize)); - saveFieldDataFromFile.extent(Extent.extentToDTO(fieldDataFileOperationSpec.extent)); saveFieldDataFromFile.origin(Origin.originToDTO(fieldDataFileOperationSpec.origin)); - saveFieldDataFromFile.times(Arrays.stream(fieldDataFileOperationSpec.times).boxed().toList()); saveFieldDataFromFile.setName(fieldDataFileOperationSpec.fieldDataName); - saveFieldDataFromFile.varNames(Arrays.stream(fieldDataFileOperationSpec.varNames).toList()); saveFieldDataFromFile.shortSpecData(listVersion); - org.vcell.restclient.model.FieldDataFileOperationResults results = vCellApiClient.getFieldDataApi().createNewFieldDataFromFile(saveFieldDataFromFile); - return FieldDataFileOperationResults.dtoToFieldDataFileOperationResults(results); } } catch (DataAccessException e){ lg.error(e.getMessage(),e); diff --git a/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalUserMetaDbServerMessaging.java b/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalUserMetaDbServerMessaging.java index b4351b9660..22bc284c90 100644 --- a/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalUserMetaDbServerMessaging.java +++ b/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/LocalUserMetaDbServerMessaging.java @@ -122,6 +122,9 @@ public FieldDataDBOperationResults fieldDataDBOperation(FieldDataDBOperationSpec try { if (lg.isTraceEnabled()) lg.trace("LocalUserMetaDbServerMessaging.fieldDataDBOperation(...)"); + if (fieldDataDBOperationSpec.opType == FieldDataDBOperationSpec.FDDBOS_DELETE){ + throw new RuntimeException("Can not call deletion on field data DB entry. Have to do both file, and DB deletion."); + } return dbServerProxy.fieldDataDBOperation(fieldDataDBOperationSpec); } catch (DataAccessException e) { lg.error(e.getMessage(),e);