fix referenceTypePersist
This commit is contained in:
parent
5001968da7
commit
cfb7da7968
|
@ -4,19 +4,14 @@ import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
import eu.eudat.commons.types.referencetype.*;
|
||||||
import eu.eudat.commons.types.referencetype.ReferenceTypeFieldEntity;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.ReferenceTypeEntity;
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
import eu.eudat.model.ReferenceType;
|
import eu.eudat.model.ReferenceType;
|
||||||
import eu.eudat.model.SupportiveMaterial;
|
|
||||||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||||
import eu.eudat.model.builder.SupportiveMaterialBuilder;
|
|
||||||
import eu.eudat.model.deleter.ReferenceTypeDeleter;
|
import eu.eudat.model.deleter.ReferenceTypeDeleter;
|
||||||
import eu.eudat.model.deleter.SupportiveMaterialDeleter;
|
|
||||||
import eu.eudat.model.persist.ReferenceTypePersist;
|
import eu.eudat.model.persist.ReferenceTypePersist;
|
||||||
import eu.eudat.model.persist.referencetypedefinition.ReferenceTypeDefinitionPersist;
|
import eu.eudat.model.persist.referencetypedefinition.*;
|
||||||
import eu.eudat.model.persist.referencetypedefinition.ReferenceTypeFieldPersist;
|
|
||||||
import eu.eudat.service.dmpblueprint.DmpBlueprintServiceImpl;
|
import eu.eudat.service.dmpblueprint.DmpBlueprintServiceImpl;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
@ -77,7 +72,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
public ReferenceType persist(ReferenceTypePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException{
|
public ReferenceType persist(ReferenceTypePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException{
|
||||||
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.EditSupportiveMaterial);
|
this.authorizationService.authorizeForce(Permission.EditReferenceType);
|
||||||
|
|
||||||
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||||
|
|
||||||
|
@ -116,6 +111,12 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getUrlConfig())){
|
||||||
|
data.setUrlConfig(new ArrayList<>());
|
||||||
|
for (ReferenceTypeUrlConfigurationPersist urlConfigPersist: persist.getUrlConfig()) {
|
||||||
|
data.getUrlConfig().add(this.buildUrlConfigEntity(urlConfigPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -130,10 +131,92 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @NotNull ReferenceTypeUrlConfigurationEntity buildUrlConfigEntity(ReferenceTypeUrlConfigurationPersist persist){
|
||||||
|
ReferenceTypeUrlConfigurationEntity data = new ReferenceTypeUrlConfigurationEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setKey(persist.getKey());
|
||||||
|
data.setLabel(persist.getLabel());
|
||||||
|
data.setOrdinal(persist.getOrdinal());
|
||||||
|
data.setUrl(persist.getUrl());
|
||||||
|
if (persist.getData() != null ) data.setData(this.buildDataUrlConfigEntity(persist.getData()));
|
||||||
|
data.setType(persist.getType());
|
||||||
|
data.setPaginationPath(persist.getPaginationPath());
|
||||||
|
data.setContentType(persist.getContentType());
|
||||||
|
data.setFunderQuery(persist.getFunderQuery());
|
||||||
|
data.setFirstpage(persist.getFirstpage());
|
||||||
|
data.setRequestType(persist.getRequestType());
|
||||||
|
data.setRequestBody(persist.getRequestBody());
|
||||||
|
data.setFilterType(persist.getFilterType());
|
||||||
|
if (data.getAuth() != null) data.setAuth(this.buildAuthConfigEntity(persist.getAuth()));
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getQueries())){
|
||||||
|
data.setQueries(new ArrayList<>());
|
||||||
|
for (QueryConfigPersist queryConfigPersist: persist.getQueries()) {
|
||||||
|
data.getQueries().add(this.buildQueryConfigEntity(queryConfigPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull DataUrlConfigurationEntity buildDataUrlConfigEntity(DataUrlConfigurationPersist persist){
|
||||||
|
DataUrlConfigurationEntity data = new DataUrlConfigurationEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setPath(persist.getPath());
|
||||||
|
if (persist.getFieldsUrlConfiguration() != null ) data.setFieldsUrlConfiguration(this.buildDataFieldsUrlConfigEntity(persist.getFieldsUrlConfiguration()));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull DataFieldsUrlConfigurationEntity buildDataFieldsUrlConfigEntity(DataFieldsUrlConfigurationPersist persist){
|
||||||
|
DataFieldsUrlConfigurationEntity data = new DataFieldsUrlConfigurationEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setId(persist.getId());
|
||||||
|
data.setName(persist.getName());
|
||||||
|
data.setPid(persist.getPid());
|
||||||
|
data.setPidTypeField(persist.getPidTypeField());
|
||||||
|
data.setUri(persist.getUri());
|
||||||
|
data.setDescription(persist.getDescription());
|
||||||
|
data.setSource(persist.getSource());
|
||||||
|
data.setCount(persist.getCount());
|
||||||
|
data.setTypes(persist.getTypes());
|
||||||
|
data.setFirstName(persist.getFirstName());
|
||||||
|
data.setLastName(persist.getLastName());
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull AuthenticationConfigurationEntity buildAuthConfigEntity(AuthenticationConfigurationPersist persist){
|
||||||
|
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setAuthMethod(persist.getAuthMethod());
|
||||||
|
data.setAuthRequestBody(persist.getAuthRequestBody());
|
||||||
|
data.setType(persist.getType());
|
||||||
|
data.setAuthTokenPath(persist.getAuthTokenPath());
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull QueryConfigEntity buildQueryConfigEntity(QueryConfigPersist persist){
|
||||||
|
QueryConfigEntity data = new QueryConfigEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setCondition(persist.getCondition());
|
||||||
|
data.setSeparator(persist.getSeparator());
|
||||||
|
data.setValue(persist.getValue());
|
||||||
|
data.setOrdinal(persist.getOrdinal());
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
logger.debug("deleting : {}", id);
|
logger.debug("deleting : {}", id);
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.DeleteSupportiveMaterial);
|
this.authorizationService.authorizeForce(Permission.DeleteReferenceType);
|
||||||
|
|
||||||
this.deleterFactory.deleter(ReferenceTypeDeleter.class).deleteAndSaveByIds(List.of(id));
|
this.deleterFactory.deleter(ReferenceTypeDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue