Skip to content

Commit

Permalink
Fixed: delete featured item inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Jan 10, 2025
1 parent d1c7a04 commit b8853b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Size;

@NamedQueries({
@NamedQuery(name = "DataverseFeaturedItem.deleteById",
query = "DELETE FROM DataverseFeaturedItem item WHERE item.id=:id")
})
@Entity
public class DataverseFeaturedItem {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public DataverseFeaturedItem save(DataverseFeaturedItem dataverseFeaturedItem) {
return dataverseFeaturedItem;
}

public void delete(Long id) {
em.createNamedQuery("DataverseFeaturedItem.deleteById", DataverseFeaturedItem.class)
.setParameter("id", id)
.executeUpdate();
}

public InputStream getImageFileAsInputStream(DataverseFeaturedItem dataverseFeaturedItem) throws IOException {
Path imagePath = Path.of(JvmSettings.DOCROOT_DIRECTORY.lookup(),
JvmSettings.FEATURED_ITEMS_IMAGE_UPLOADS_DIRECTORY.lookup(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public DeleteDataverseFeaturedItemCommand(DataverseRequest request, DataverseFea

@Override
protected void executeImpl(CommandContext ctxt) throws CommandException {
ctxt.em().merge(doomed.getDataverse());
DataverseFeaturedItem doomedAndMerged = ctxt.em().merge(doomed);
ctxt.em().remove(doomedAndMerged);
ctxt.dataverseFeaturedItems().delete(doomed.getId());
}
}

0 comments on commit b8853b7

Please sign in to comment.