Skip to content
Snippets Groups Projects
Commit ff7f1f5d authored by buczekp's avatar buczekp
Browse files

[LMS-2421] partly fixed permanent deletion with enabled trash:

- deletion of samples works
- deletion of data sets & experiments fails

SVN: 22291
parent dc084d5b
No related branches found
No related tags found
No related merge requests found
......@@ -135,7 +135,7 @@ final class DeletionDAO extends AbstractGenericEntityDAO<DeletionPE> implements
public List<String> findTrashedDataSetCodes(final List<TechId> deletionIds)
{
final DetachedCriteria criteria =
DetachedCriteria.forClass(EntityKind.DATA_SET.getEntityClass());
DetachedCriteria.forClass(EntityKind.DATA_SET.getDeletedEntityClass());
final List<Long> longIds = TechId.asLongs(deletionIds);
criteria.setProjection(Projections.property("code"));
criteria.add(Restrictions.in("deletion.id", longIds));
......@@ -148,7 +148,8 @@ final class DeletionDAO extends AbstractGenericEntityDAO<DeletionPE> implements
private List<TechId> findTrashedEntityIds(final List<TechId> deletionIds,
final EntityKind entityKind)
{
final DetachedCriteria criteria = DetachedCriteria.forClass(entityKind.getEntityClass());
final DetachedCriteria criteria =
DetachedCriteria.forClass(entityKind.getDeletedEntityClass());
final List<Long> longIds = TechId.asLongs(deletionIds);
criteria.setProjection(Projections.id());
criteria.add(Restrictions.in("deletion.id", longIds));
......
......@@ -383,8 +383,10 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE>
public void delete(final List<TechId> sampleIds, final PersonPE registrator, final String reason)
throws DataAccessException
{
final String sqlPermId =
"SELECT perm_id FROM " + TableNames.SAMPLES_VIEW + " WHERE id = :sId";
// NOTE: we use SAMPLES_ALL_TABLE, not DELETED_SAMPLES_VIEW because we still want to be
// able to directly delete samples without going to trash (trash may be disabled)
final String samplesTable = TableNames.SAMPLES_ALL_TABLE;
final String sqlPermId = "SELECT perm_id FROM " + samplesTable + " WHERE id = :sId";
final String sqlDeleteProperties =
"DELETE FROM " + TableNames.SAMPLE_PROPERTIES_TABLE + " WHERE samp_id = :sId";
final String sqlAttachmentContentIds =
......@@ -393,8 +395,7 @@ public class SampleDAO extends AbstractGenericEntityWithPropertiesDAO<SamplePE>
"DELETE FROM " + TableNames.ATTACHMENT_CONTENT_TABLE + " WHERE id in (:aIds)";
final String sqlDeleteAttachments =
"DELETE FROM " + TableNames.ATTACHMENTS_TABLE + " WHERE samp_id = :sId";
final String sqlDeleteSample =
"DELETE FROM " + TableNames.SAMPLES_VIEW + " WHERE id = :sId";
final String sqlDeleteSample = "DELETE FROM " + samplesTable + " WHERE id = :sId";
final String sqlInsertEvent =
String.format(
"INSERT INTO %s (id, event_type, description, reason, pers_id_registerer, entity_type, identifier) "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment