Skip to content

Commit

Permalink
try remove first
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Dec 12, 2024
1 parent 1bd6d58 commit da06fea
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,22 @@ public Dataset execute(CommandContext ctxt) throws CommandException {
// and remove the file from the dataset's list
theDataset.getFiles().remove(fmd.getDataFile());
ctxt.em().remove(fmd.getDataFile());
ctxt.em().remove(fmd);
} else {
ctxt.em().remove(fmd);
// if we aren't removing the file, we need to remove it from the datafile's list
FileMetadataUtil.removeFileMetadataFromList(fmd.getDataFile().getFileMetadatas(), fmd);
}
// In either case, to fully remove the fmd, we have to remove any other possible
// In either case, we've removed from the context
// And, to fully remove the fmd, we have to remove any other possible
// references
// From the datasetversion
FileMetadataUtil.removeFileMetadataFromList(theDataset.getOrCreateEditVersion().getFileMetadatas(), fmd);
// and from the list associated with each category
for (DataFileCategory cat : theDataset.getCategories()) {
FileMetadataUtil.removeFileMetadataFromList(cat.getFileMetadatas(), fmd);
}
// And the context
ctxt.em().remove(fmd);

}
for(FileMetadata fmd: theDataset.getOrCreateEditVersion().getFileMetadatas()) {
logger.fine("FMD: " + fmd.getId() + " for file: " + fmd.getDataFile().getId() + "is in final draft version");
Expand Down

0 comments on commit da06fea

Please sign in to comment.