Skip to content

Commit

Permalink
Use Rest Endpoint Delete On Java Client
Browse files Browse the repository at this point in the history
  • Loading branch information
AvocadoMoon committed Dec 18, 2024
1 parent 63c8404 commit d667a62
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,6 @@ public void run(Hashtable<String, Object> hash) throws Exception {
FieldDataFileOperationSpec fdos = FieldDataFileOperationSpec.createDeleteFieldDataFileOperationSpec(
fieldDataMainList.externalDataIdentifier);
clientRequestManager.getDocumentManager().fieldDataFileOperation(fdos);
//Remove from DB
fieldDataWindowManager.deleteExternalDataIdentifier(fieldDataMainList.externalDataIdentifier);
}
};
//
Expand Down Expand Up @@ -1173,12 +1171,6 @@ public void run(Hashtable<String, Object> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -83,6 +89,26 @@ public FieldDataFileOperationSpec(short[][][] shortSpecData, double[][][] double
this.sourceOwner = sourceOwner;
}

public static AnalyzedResultsFromFieldData fieldDataSpecToAnalyzedResultsDTO(FieldDataFileOperationSpec fieldDataFileOperationSpec){
List<List<List<Integer>>> listVersion = Arrays.stream(fieldDataFileOperationSpec.shortSpecData) // Stream of short[][]
.map(twoDArray -> Arrays.stream(twoDArray) // Stream of short[]
.map(oneDArray -> {
List<Integer> 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,
Expand All @@ -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 =
Expand All @@ -109,6 +137,8 @@ public static FieldDataFileOperationSpec createInfoFieldDataFileOperationSpec(
fieldDataFileOperationSpec.sourceSimParamScanJobIndex = argSimParamScanJobIndex;
return fieldDataFileOperationSpec;
}

@Deprecated
public static FieldDataFileOperationSpec createDeleteFieldDataFileOperationSpec(
ExternalDataIdentifier deleteExtDataID){
FieldDataFileOperationSpec fieldDataFileOperationSpec =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<List<List<Integer>>> listVersion = Arrays.stream(fieldDataFileOperationSpec.shortSpecData) // Stream of short[][]
.map(twoDArray -> Arrays.stream(twoDArray) // Stream of short[]
.map(oneDArray -> {
List<Integer> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d667a62

Please sign in to comment.