Skip to content

Commit

Permalink
Added: featured items deletion in DeleteDataverseCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Jan 13, 2025
1 parent e265ae8 commit bff8e94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataverse.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ public List<DataverseFeaturedItem> getDataverseFeaturedItems() {
return this.dataverseFeaturedItems;
}

public void setDataverseFeaturedItems(List<DataverseFeaturedItem> dataverseFeaturedItems) {
this.dataverseFeaturedItems = dataverseFeaturedItems;
}

public List<Guestbook> getParentGuestbooks() {
List<Guestbook> retList = new ArrayList<>();
Dataverse testDV = this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.harvard.iq.dataverse.engine.command.impl;

import edu.harvard.iq.dataverse.Dataverse;
import edu.harvard.iq.dataverse.DataverseFeaturedItem;
import edu.harvard.iq.dataverse.DataverseFieldTypeInputLevel;
import edu.harvard.iq.dataverse.authorization.DataverseRole;
import edu.harvard.iq.dataverse.RoleAssignment;
Expand Down Expand Up @@ -78,6 +79,14 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {
ctxt.em().remove(merged);
}
doomed.setDataverseFieldTypeInputLevels(new ArrayList<>());

// Featured Items
for (DataverseFeaturedItem featuredItem : doomed.getDataverseFeaturedItems()) {
DataverseFeaturedItem merged = ctxt.em().merge(featuredItem);
ctxt.em().remove(merged);
}
doomed.setDataverseFeaturedItems(new ArrayList<>());

// DATAVERSE
Dataverse doomedAndMerged = ctxt.em().merge(doomed);
ctxt.em().remove(doomedAndMerged);
Expand Down

0 comments on commit bff8e94

Please sign in to comment.