-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
113 changed files
with
18,282 additions
and
21,885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/org/jbei/ice/lib/bulkupload/BulkUploadDeleteTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.jbei.ice.lib.bulkupload; | ||
|
||
import org.jbei.ice.lib.common.logging.Logger; | ||
import org.jbei.ice.lib.dao.DAOFactory; | ||
import org.jbei.ice.lib.dao.hibernate.BulkUploadDAO; | ||
import org.jbei.ice.lib.dto.entry.Visibility; | ||
import org.jbei.ice.lib.entry.model.Entry; | ||
import org.jbei.ice.lib.executor.Task; | ||
|
||
|
||
/** | ||
* Task to delete bulk uploads with a status of draft and their contents. | ||
* | ||
* @author Hector Plahar | ||
*/ | ||
public class BulkUploadDeleteTask extends Task { | ||
|
||
private final long bulkUploadId; | ||
private final String userId; | ||
|
||
public BulkUploadDeleteTask(final String userId, final long id) { | ||
this.bulkUploadId = id; | ||
this.userId = userId; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
BulkUploadDAO dao = DAOFactory.getBulkUploadDAO(); | ||
|
||
BulkUpload upload = dao.get(bulkUploadId); | ||
if (upload == null) { | ||
Logger.error("Could not locate bulk upload " + bulkUploadId + " for deletion"); | ||
return; | ||
} | ||
|
||
BulkUploadAuthorization authorization = new BulkUploadAuthorization(); | ||
authorization.expectWrite(userId, upload); | ||
|
||
if (upload.getStatus() != BulkUploadStatus.IN_PROGRESS) | ||
return; | ||
|
||
// delete all associated entries that have a status of draft | ||
for (Entry entry : upload.getContents()) { | ||
for (Entry linkedEntry : entry.getLinkedEntries()) { | ||
if (linkedEntry.getVisibility() != Visibility.DRAFT.getValue()) | ||
continue; | ||
|
||
DAOFactory.getEntryDAO().fullDelete(linkedEntry); | ||
// entryController.fullDelete(userId, linkedEntry.getId()); | ||
} | ||
|
||
if (entry.getVisibility() == Visibility.DRAFT.getValue()) { | ||
DAOFactory.getEntryDAO().fullDelete(entry); | ||
// entryController.fullDelete(userId, entry.getId()); | ||
} | ||
} | ||
|
||
dao.delete(upload); | ||
} | ||
} |
Oops, something went wrong.