Various fixes

This commit is contained in:
Thomas Georgios Giannos 2023-11-10 19:11:15 +02:00
parent 0c4cf467d8
commit 1cee5fb49f
5 changed files with 39 additions and 7 deletions

View File

@ -1,11 +1,10 @@
package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionReferenceEntity;
import eu.eudat.data.DmpEntity;
import eu.eudat.query.DescriptionReferenceQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.DmpReferenceQuery;
import eu.eudat.data.*;
import eu.eudat.model.DmpDescriptionTemplate;
import eu.eudat.model.DmpReference;
import eu.eudat.query.*;
import gr.cite.tools.data.deleter.Deleter;
import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory;
@ -23,6 +22,7 @@ import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ -67,6 +67,26 @@ public class DmpDeleter implements Deleter {
if (data == null || data.isEmpty())
return;
List<UUID> ids = data.stream().map(DmpEntity::getId).distinct().toList();
{
logger.debug("checking related - {}", DmpUserEntity.class.getSimpleName());
List<DmpUserEntity> items = this.queryFactory.query(DmpUserQuery.class).dmpIds(ids).collect();
DmpUserDeleter deleter = this.deleterFactory.deleter(DmpUserDeleter.class);
deleter.delete(items);
}
{
logger.debug("checking related - {}", DmpDescriptionTemplate.class.getSimpleName());
List<DmpDescriptionTemplateEntity> items = this.queryFactory.query(DmpDescriptionTemplateQuery.class).dmpIds(ids).collect();
DmpDescriptionTemplateDeleter deleter = this.deleterFactory.deleter(DmpDescriptionTemplateDeleter.class);
deleter.delete(items);
}
{
logger.debug("checking related - {}", DmpReference.class.getSimpleName());
List<DmpReferenceEntity> items = this.queryFactory.query(DmpReferenceQuery.class).dmpIds(ids).collect();
DmpReferenceDeleter deleter = this.deleterFactory.deleter(DmpReferenceDeleter.class);
deleter.delete(items);
}
Instant now = Instant.now();
for (DmpEntity item : data) {

View File

@ -1,7 +1,6 @@
package eu.eudat.model.deleter;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DescriptionTagEntity;
import eu.eudat.data.TagEntity;
import eu.eudat.query.DescriptionTagQuery;

View File

@ -1,5 +1,6 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.validation.ValidId;
import eu.eudat.model.persist.dmpproperties.DmpPropertiesPersist;
@ -24,6 +25,8 @@ public class DmpPersist {
private UUID blueprint;
private DmpAccessType accessType;
private List<DmpReferencePersist> references;
private List<DmpDescriptionTemplatePersist> descriptionTemplates;
@ -94,6 +97,14 @@ public class DmpPersist {
this.blueprint = blueprint;
}
public DmpAccessType getAccessType() {
return accessType;
}
public void setAccessType(DmpAccessType accessType) {
this.accessType = accessType;
}
public List<DmpDescriptionTemplatePersist> getDescriptionTemplates() {
return descriptionTemplates;
}

View File

@ -153,7 +153,7 @@ public class DescriptionServiceImpl implements DescriptionService {
newDescription.setId(UUID.randomUUID());
newDescription.setLabel(existing.getLabel());
newDescription.setDescription(existing.getDescription());
newDescription.setStatus(DescriptionStatus.Finalized);
newDescription.setStatus(DescriptionStatus.Draft);
newDescription.setProperties(existing.getProperties());
newDescription.setDmpId(dmpId);
newDescription.setDmpDescriptionTemplateId(existing.getDmpDescriptionTemplateId());
@ -198,6 +198,7 @@ public class DescriptionServiceImpl implements DescriptionService {
this.entityManager.persist(newTag);
}
this.entityManager.flush();
}

View File

@ -352,6 +352,7 @@ public class DmpServiceImpl implements DmpService {
data.setLabel(model.getLabel());
data.setProperties(this.jsonHandlingService.toJson(model.getProperties()));
data.setDescription(model.getDescription());
data.setAccessType(model.getAccessType());
data.setUpdatedAt(Instant.now());
if (isUpdate)
this.entityManager.merge(data);