Code cleanup
This commit is contained in:
parent
897d099c2c
commit
b7d1424e0c
|
@ -214,7 +214,7 @@ public class DescriptionPersist {
|
||||||
.iff(() -> !this.isNull(item.getProperties()))
|
.iff(() -> !this.isNull(item.getProperties()))
|
||||||
.on(DescriptionPersist._properties)
|
.on(DescriptionPersist._properties)
|
||||||
.over(item.getProperties())
|
.over(item.getProperties())
|
||||||
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class)),
|
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> item.getStatus() == DescriptionStatus.Finalized)
|
.iff(() -> item.getStatus() == DescriptionStatus.Finalized)
|
||||||
.must(() -> !this.isNull(item.getReferences()))
|
.must(() -> !this.isNull(item.getReferences()))
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package eu.eudat.model.persist.descriptionproperties;
|
package eu.eudat.model.persist.descriptionproperties;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.validation.BaseValidator;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import eu.eudat.commons.validation.ValidatorFactory;
|
import eu.eudat.commons.validation.ValidatorFactory;
|
||||||
import eu.eudat.commons.validation.specification.Specification;
|
import eu.eudat.commons.validation.specification.Specification;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
|
import eu.eudat.model.persist.validation.StatusAware;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
@ -30,7 +32,7 @@ public class PropertyDefinitionPersist {
|
||||||
|
|
||||||
@Component(PropertyDefinitionPersistValidator.ValidatorName)
|
@Component(PropertyDefinitionPersistValidator.ValidatorName)
|
||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public static class PropertyDefinitionPersistValidator extends BaseValidator<PropertyDefinitionPersist> {
|
public static class PropertyDefinitionPersistValidator extends BaseValidator<PropertyDefinitionPersist> implements StatusAware<DescriptionStatus> {
|
||||||
|
|
||||||
public static final String ValidatorName = "Description.PropertyDefinitionPersistValidator";
|
public static final String ValidatorName = "Description.PropertyDefinitionPersistValidator";
|
||||||
|
|
||||||
|
@ -38,6 +40,8 @@ public class PropertyDefinitionPersist {
|
||||||
|
|
||||||
private final ValidatorFactory validatorFactory;
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
private DescriptionStatus status;
|
||||||
|
|
||||||
protected PropertyDefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
protected PropertyDefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
||||||
super(conventionService, errors);
|
super(conventionService, errors);
|
||||||
this.messageSource = messageSource;
|
this.messageSource = messageSource;
|
||||||
|
@ -53,15 +57,22 @@ public class PropertyDefinitionPersist {
|
||||||
protected List<Specification> specifications(PropertyDefinitionPersist item) {
|
protected List<Specification> specifications(PropertyDefinitionPersist item) {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
this.spec()
|
this.spec()
|
||||||
|
.iff(() -> this.status == DescriptionStatus.Finalized)
|
||||||
.must(() -> !this.isNull(item.getFields()))
|
.must(() -> !this.isNull(item.getFields()))
|
||||||
.failOn(PropertyDefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionPersist._fields}, LocaleContextHolder.getLocale())),
|
.failOn(PropertyDefinitionPersist._fields).failWith(messageSource.getMessage("Validation_Required", new Object[]{PropertyDefinitionPersist._fields}, LocaleContextHolder.getLocale())),
|
||||||
this.navSpec()
|
this.navSpec()
|
||||||
.iff(() -> !this.isNull(item.getFields()))
|
.iff(() -> this.status == DescriptionStatus.Finalized && !this.isNull(item.getFields()))
|
||||||
.on(PropertyDefinitionPersist._fields)
|
.on(PropertyDefinitionPersist._fields)
|
||||||
.over(item.getFields())
|
.over(item.getFields())
|
||||||
.using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))
|
.using(() -> this.validatorFactory.validator(FieldPersist.FieldPersistValidator.class))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyDefinitionPersistValidator setStatus(DescriptionStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package eu.eudat.service.user;
|
package eu.eudat.service.user;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.model.DescriptionTemplateType;
|
|
||||||
import eu.eudat.model.User;
|
import eu.eudat.model.User;
|
||||||
import eu.eudat.model.persist.DescriptionTemplateTypePersist;
|
|
||||||
import eu.eudat.model.persist.UserPersist;
|
import eu.eudat.model.persist.UserPersist;
|
||||||
import eu.eudat.model.persist.UserRolePatchPersist;
|
import eu.eudat.model.persist.UserRolePatchPersist;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -20,8 +18,11 @@ import java.util.UUID;
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
|
|
||||||
User persist(UserPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JsonProcessingException;
|
User persist(UserPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JsonProcessingException;
|
||||||
|
|
||||||
void updateLanguageMine(String language) throws InvalidApplicationException, JsonProcessingException;
|
void updateLanguageMine(String language) throws InvalidApplicationException, JsonProcessingException;
|
||||||
|
|
||||||
void updateTimezoneMine(String timezone) throws JsonProcessingException;
|
void updateTimezoneMine(String timezone) throws JsonProcessingException;
|
||||||
|
|
||||||
void updateCultureMine(String culture) throws JsonProcessingException;
|
void updateCultureMine(String culture) throws JsonProcessingException;
|
||||||
|
|
||||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||||
|
|
|
@ -35,7 +35,6 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
@ -155,7 +154,7 @@ public class DescriptionController {
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@Transactional
|
||||||
@ValidationFilterAnnotation(validator = DescriptionPersist.DescriptionPersistValidator.ValidatorName, argumentName = "model")
|
@ValidationFilterAnnotation(validator = DescriptionPersist.DescriptionPersistValidator.ValidatorName, argumentName = "model")
|
||||||
public Description persist(@MyValidate @RequestBody DescriptionPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JsonProcessingException {
|
public Description persist(@RequestBody DescriptionPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JsonProcessingException {
|
||||||
logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
Description persisted = this.descriptionService.persist(model, fieldSet);
|
Description persisted = this.descriptionService.persist(model, fieldSet);
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ public class DescriptionController {
|
||||||
@PostMapping("persist-status")
|
@PostMapping("persist-status")
|
||||||
@Transactional
|
@Transactional
|
||||||
@ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model")
|
@ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model")
|
||||||
public Description persistStatus(@MyValidate @RequestBody DescriptionStatusPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
public Description persistStatus(@RequestBody DescriptionStatusPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||||
logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
Description persisted = this.descriptionService.persistStatus(model, fieldSet);
|
Description persisted = this.descriptionService.persistStatus(model, fieldSet);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -88,7 +87,6 @@ public class DmpBlueprintController {
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.DmpBlueprint_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.DmpBlueprint_Query, "lookup", lookup);
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
|
|
||||||
return new QueryResult<>(models, count);
|
return new QueryResult<>(models, count);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +106,6 @@ public class DmpBlueprintController {
|
||||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +113,7 @@ public class DmpBlueprintController {
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@Transactional
|
||||||
@ValidationFilterAnnotation(validator = DmpBlueprintPersist.DmpBlueprintPersistValidator.ValidatorName, argumentName = "model")
|
@ValidationFilterAnnotation(validator = DmpBlueprintPersist.DmpBlueprintPersistValidator.ValidatorName, argumentName = "model")
|
||||||
public DmpBlueprint persist(@MyValidate @RequestBody DmpBlueprintPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
|
public DmpBlueprint persist(@RequestBody DmpBlueprintPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
|
||||||
logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
@ -126,7 +123,7 @@ public class DmpBlueprintController {
|
||||||
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
return persisted;
|
return persisted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +135,6 @@ public class DmpBlueprintController {
|
||||||
this.dmpBlueprintService.deleteAndSave(id);
|
this.dmpBlueprintService.deleteAndSave(id);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.DmpBlueprint_Delete, "id", id);
|
this.auditService.track(AuditableAction.DmpBlueprint_Delete, "id", id);
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("clone/{id}")
|
@GetMapping("clone/{id}")
|
||||||
|
@ -153,7 +149,6 @@ public class DmpBlueprintController {
|
||||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +177,6 @@ public class DmpBlueprintController {
|
||||||
new AbstractMap.SimpleEntry<String, Object>("file", file),
|
new AbstractMap.SimpleEntry<String, Object>("file", file),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,12 @@ import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.file.transformer.model.file.FileFormat;
|
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.model.Dmp;
|
||||||
import eu.eudat.model.DmpUser;
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.model.builder.DmpBuilder;
|
import eu.eudat.model.builder.DmpBuilder;
|
||||||
import eu.eudat.model.censorship.DmpCensor;
|
import eu.eudat.model.censorship.DmpCensor;
|
||||||
import eu.eudat.model.file.FileEnvelope;
|
|
||||||
import eu.eudat.model.persist.*;
|
import eu.eudat.model.persist.*;
|
||||||
import eu.eudat.model.result.QueryResult;
|
import eu.eudat.model.result.QueryResult;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
import eu.eudat.query.lookup.DmpLookup;
|
import eu.eudat.query.lookup.DmpLookup;
|
||||||
|
@ -30,7 +27,6 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
|
@ -187,8 +183,8 @@ public class DmpController {
|
||||||
List<DmpUser> persisted = this.dmpService.assignUsers(id, model, fieldSet);
|
List<DmpUser> persisted = this.dmpService.assignUsers(id, model, fieldSet);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Dmp_Assign_Users, Map.ofEntries(
|
this.auditService.track(AuditableAction.Dmp_Assign_Users, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
|
|
||||||
return new QueryResult<>(persisted);
|
return new QueryResult<>(persisted);
|
||||||
|
@ -203,8 +199,8 @@ public class DmpController {
|
||||||
Dmp persisted = this.dmpService.removeUser(model, fieldSet);
|
Dmp persisted = this.dmpService.removeUser(model, fieldSet);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Dmp_RemoveUser, Map.ofEntries(
|
this.auditService.track(AuditableAction.Dmp_RemoveUser, Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
|
|
||||||
return new QueryResult<>(persisted);
|
return new QueryResult<>(persisted);
|
||||||
|
@ -220,7 +216,7 @@ public class DmpController {
|
||||||
@PostMapping("{id}/invite-users")
|
@PostMapping("{id}/invite-users")
|
||||||
@Transactional
|
@Transactional
|
||||||
@ValidationFilterAnnotation(validator = DmpUserInvitePersist.DmpUserInvitePersistValidator.ValidatorName, argumentName = "model")
|
@ValidationFilterAnnotation(validator = DmpUserInvitePersist.DmpUserInvitePersistValidator.ValidatorName, argumentName = "model")
|
||||||
public ResponseEntity<ResponseItem<String>> inviteUsers(@PathVariable("id") UUID id,@RequestBody DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException {
|
public ResponseEntity<ResponseItem<String>> inviteUsers(@PathVariable("id") UUID id, @RequestBody DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException {
|
||||||
logger.debug(new MapLogEntry("inviting users to dmp").And("model", model));
|
logger.debug(new MapLogEntry("inviting users to dmp").And("model", model));
|
||||||
|
|
||||||
this.dmpService.inviteUsers(id, model);
|
this.dmpService.inviteUsers(id, model);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.controllers.v2;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.controllers.BaseController;
|
import eu.eudat.controllers.BaseController;
|
||||||
import eu.eudat.data.ReferenceTypeEntity;
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -26,7 +27,6 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -46,12 +46,19 @@ import java.util.UUID;
|
||||||
public class ReferenceTypeController extends BaseController {
|
public class ReferenceTypeController extends BaseController {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeController.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceTypeController.class));
|
||||||
|
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
private final AuditService auditService;
|
private final AuditService auditService;
|
||||||
|
|
||||||
private final CensorFactory censorFactory;
|
private final CensorFactory censorFactory;
|
||||||
|
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
|
||||||
private final ReferenceTypeService referenceTypeService;
|
private final ReferenceTypeService referenceTypeService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -85,7 +92,7 @@ public class ReferenceTypeController extends BaseController {
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.ReferenceType_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.ReferenceType_Query, "lookup", lookup);
|
||||||
|
|
||||||
return new QueryResult(models, count);
|
return new QueryResult<>(models, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
|
@ -128,7 +135,8 @@ public class ReferenceTypeController extends BaseController {
|
||||||
|
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@Transactional
|
||||||
public ReferenceType persist(@MyValidate @RequestBody ReferenceTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException {
|
@ValidationFilterAnnotation(validator = ReferenceTypePersist.ReferenceTypePersistValidator.ValidatorName, argumentName = "model")
|
||||||
|
public ReferenceType persist(@RequestBody ReferenceTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("persisting" + ReferenceType.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
logger.debug(new MapLogEntry("persisting" + ReferenceType.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
@ -138,14 +146,14 @@ public class ReferenceTypeController extends BaseController {
|
||||||
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
));
|
));
|
||||||
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
|
||||||
return persisted;
|
return persisted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("retrieving" + ReferenceType.class.getSimpleName()).And("id", id));
|
logger.debug(new MapLogEntry("retrieving" + ReferenceType.class.getSimpleName()).And("id", id));
|
||||||
|
|
||||||
this.referenceTypeService.deleteAndSave(id);
|
this.referenceTypeService.deleteAndSave(id);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
|
@ -116,7 +115,7 @@ public class UserController {
|
||||||
logger.debug("querying {}", User.class.getSimpleName());
|
logger.debug("querying {}", User.class.getSimpleName());
|
||||||
|
|
||||||
this.censorFactory.censor(DmpAssociatedUserCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(DmpAssociatedUserCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
UserQuery query = lookup.enrich(this.queryFactory).dmpAssociated(true).isActive(IsActive.Active);
|
UserQuery query = lookup.enrich(this.queryFactory).dmpAssociated(true).isActive(IsActive.Active);
|
||||||
|
|
||||||
List<UserEntity> data = query.collectAs(lookup.getProject());
|
List<UserEntity> data = query.collectAs(lookup.getProject());
|
||||||
|
|
|
@ -23,7 +23,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.MyValidate;
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -112,7 +111,7 @@ public class UserSettingsController {
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@Transactional
|
||||||
@ValidationFilterAnnotation(validator = UserSettingsPersist.UserSettingsPersistValidator.ValidatorName, argumentName = "model")
|
@ValidationFilterAnnotation(validator = UserSettingsPersist.UserSettingsPersistValidator.ValidatorName, argumentName = "model")
|
||||||
public UserSettings Persist(@MyValidate @RequestBody UserSettingsPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
public UserSettings Persist(@RequestBody UserSettingsPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("persisting" + UserSettings.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
logger.debug(new MapLogEntry("persisting" + UserSettings.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
|
|
||||||
UserSettings persisted = this.settingsService.persist(model, fieldSet);
|
UserSettings persisted = this.settingsService.persist(model, fieldSet);
|
||||||
|
|
Loading…
Reference in New Issue