Added dmp description template deletions on description template deleter
This commit is contained in:
parent
cfb7da7968
commit
001cd0828b
|
@ -2,9 +2,11 @@ package eu.eudat.model.deleter;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.data.UserDescriptionTemplateEntity;
|
import eu.eudat.data.UserDescriptionTemplateEntity;
|
||||||
import eu.eudat.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
import eu.eudat.query.UserDescriptionTemplateQuery;
|
import eu.eudat.query.UserDescriptionTemplateQuery;
|
||||||
import gr.cite.tools.data.deleter.Deleter;
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
@ -63,24 +65,30 @@ public class DescriptionTemplateDeleter implements Deleter {
|
||||||
logger.trace("changes saved");
|
logger.trace("changes saved");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(List<DescriptionTemplateEntity> datas) throws InvalidApplicationException {
|
public void delete(List<DescriptionTemplateEntity> data) throws InvalidApplicationException {
|
||||||
logger.debug("will delete {} items", Optional.ofNullable(datas).map(List::size).orElse(0));
|
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
if (datas == null || datas.isEmpty())
|
if (data == null || data.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<UUID> ids = datas.stream().map(DescriptionTemplateEntity::getId).distinct().collect(Collectors.toList());
|
List<UUID> ids = data.stream().map(DescriptionTemplateEntity::getId).distinct().collect(Collectors.toList());
|
||||||
{
|
{
|
||||||
logger.debug("checking related - {}", UserDescriptionTemplateEntity.class.getSimpleName());
|
logger.debug("checking related - {}", UserDescriptionTemplateEntity.class.getSimpleName());
|
||||||
List<UserDescriptionTemplateEntity> items = this.queryFactory.query(UserDescriptionTemplateQuery.class).descriptionTemplateIds(ids).collect();
|
List<UserDescriptionTemplateEntity> items = this.queryFactory.query(UserDescriptionTemplateQuery.class).descriptionTemplateIds(ids).collect();
|
||||||
UserDescriptionTemplateDeleter deleter = this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class);
|
UserDescriptionTemplateDeleter deleter = this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class);
|
||||||
deleter.delete(items);
|
deleter.delete(items);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
logger.debug("checking related - {}", DmpDescriptionTemplateEntity.class.getSimpleName());
|
||||||
|
List<DmpDescriptionTemplateEntity> items = this.queryFactory.query(DmpDescriptionTemplateQuery.class).descriptionTemplateIds(ids).collect();
|
||||||
|
DmpDescriptionTemplateDeleter deleter = this.deleterFactory.deleter(DmpDescriptionTemplateDeleter.class);
|
||||||
|
deleter.delete(items);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO can not delete profile if has Datasets
|
//TODO can not delete profile if has Datasets
|
||||||
|
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
|
|
||||||
for (DescriptionTemplateEntity item : datas) {
|
for (DescriptionTemplateEntity item : data) {
|
||||||
logger.trace("deleting item {}", item.getId());
|
logger.trace("deleting item {}", item.getId());
|
||||||
item.setIsActive(IsActive.Inactive);
|
item.setIsActive(IsActive.Inactive);
|
||||||
item.setUpdatedAt(now);
|
item.setUpdatedAt(now);
|
||||||
|
|
Loading…
Reference in New Issue