Fix various issues with spring update
This commit is contained in:
parent
a805e823e5
commit
1ae2788453
|
@ -106,11 +106,11 @@ public class Grant implements DataEntity<Grant, UUID> {
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
@Column(name = "\"StartDate\"", nullable = false)
|
@Column(name = "\"StartDate\"", nullable = true)
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Date startdate = null;
|
private Date startdate = null;
|
||||||
|
|
||||||
@Column(name = "\"EndDate\"", nullable = false)
|
@Column(name = "\"EndDate\"", nullable = true)
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Date enddate = null;
|
private Date enddate = null;
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,11 @@ public class DataManagementPlanManager {
|
||||||
items = null;
|
items = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||||
|
}
|
||||||
|
|
||||||
List<Integer> roles = new LinkedList<>();
|
List<Integer> roles = new LinkedList<>();
|
||||||
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
||||||
if (dataManagementPlanTableRequest.getCriteria().getRole() != null)
|
if (dataManagementPlanTableRequest.getCriteria().getRole() != null)
|
||||||
|
@ -161,8 +164,11 @@ public class DataManagementPlanManager {
|
||||||
} else {
|
} else {
|
||||||
authItems = items;
|
authItems = items;
|
||||||
}
|
}
|
||||||
|
if (items == null) {
|
||||||
totalData = authItems.count();
|
totalData = authItems.count();
|
||||||
items = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
items = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||||
|
} else {
|
||||||
|
items = authItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -534,6 +540,10 @@ public class DataManagementPlanManager {
|
||||||
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||||
assignUser(newDmp, user);
|
assignUser(newDmp, user);
|
||||||
|
|
||||||
|
UUID dmpId = newDmp.getId();
|
||||||
|
Set<UserDMP> users = new HashSet<>(databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList());
|
||||||
|
newDmp.setUsers(users);
|
||||||
|
|
||||||
this.updateIndex(newDmp);
|
this.updateIndex(newDmp);
|
||||||
|
|
||||||
if (setNotification) {
|
if (setNotification) {
|
||||||
|
@ -625,13 +635,16 @@ public class DataManagementPlanManager {
|
||||||
assignGrandUserIfInternal(newDmp, user);
|
assignGrandUserIfInternal(newDmp, user);
|
||||||
assignFunderUserIfInternal(newDmp, user);
|
assignFunderUserIfInternal(newDmp, user);
|
||||||
assignProjectUserIfInternal(newDmp, user);
|
assignProjectUserIfInternal(newDmp, user);
|
||||||
|
if (newDmp.getGrant().getStartdate() == null) {
|
||||||
|
newDmp.getGrant().setStartdate(new Date());
|
||||||
|
}
|
||||||
|
if (newDmp.getGrant().getEnddate() == null) {
|
||||||
|
newDmp.getGrant().setEnddate(Date.from(Instant.now().plus(365, ChronoUnit.DAYS)));
|
||||||
|
}
|
||||||
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
|
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
|
||||||
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
|
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
|
||||||
newDmp.setId(tempDmp.getId());
|
newDmp.setId(tempDmp.getId());
|
||||||
|
|
||||||
// Assign creator.
|
|
||||||
assignUser(newDmp, user);
|
|
||||||
|
|
||||||
copyDatasets(newDmp, databaseRepository.getDatasetDao());
|
copyDatasets(newDmp, databaseRepository.getDatasetDao());
|
||||||
|
|
||||||
databaseRepository
|
databaseRepository
|
||||||
|
@ -797,6 +810,12 @@ public class DataManagementPlanManager {
|
||||||
else {
|
else {
|
||||||
grant.setType(Grant.GrantType.EXTERNAL.getValue());
|
grant.setType(Grant.GrantType.EXTERNAL.getValue());
|
||||||
grant.setCreationUser(null);
|
grant.setCreationUser(null);
|
||||||
|
if (grant.getStartdate() == null) {
|
||||||
|
grant.setStartdate(new Date());
|
||||||
|
}
|
||||||
|
if (grant.getEnddate() == null) {
|
||||||
|
grant.setEnddate(Date.from(Instant.now().plus(365, ChronoUnit.DAYS)));
|
||||||
|
}
|
||||||
grantDao.createOrUpdate(grant);
|
grantDao.createOrUpdate(grant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1749,7 +1768,16 @@ public class DataManagementPlanManager {
|
||||||
userDMP.setDmp(dmp);
|
userDMP.setDmp(dmp);
|
||||||
userDMP.setUser(userInfo);
|
userDMP.setUser(userInfo);
|
||||||
userDMP.setRole(role.getValue());
|
userDMP.setRole(role.getValue());
|
||||||
databaseRepository.getUserDmpDao().createOrUpdate(userDMP);
|
userDMP = databaseRepository.getUserDmpDao().createOrUpdate(userDMP);
|
||||||
|
logger.debug("UserDMP Id: " + userDMP.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean userExists(UserDMP userDMP, UserInfo userInfo, UserDMP.UserDMPRoles role) {
|
||||||
|
UserDMP tempUser = userDMP;
|
||||||
|
if (userDMP.getUser() == null) {
|
||||||
|
tempUser = databaseRepository.getUserDmpDao().find(userDMP.getId());
|
||||||
|
}
|
||||||
|
return tempUser.getUser().getId().equals(userInfo.getId()) && tempUser.getRole().equals(role.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearUsers(DMP dmp) {
|
private void clearUsers(DMP dmp) {
|
||||||
|
@ -2147,7 +2175,9 @@ public class DataManagementPlanManager {
|
||||||
jsonFos.flush();
|
jsonFos.flush();
|
||||||
}
|
}
|
||||||
fileSystemResource = new FileSystemResource(tempJsonFile);
|
fileSystemResource = new FileSystemResource(tempJsonFile);
|
||||||
addFileMapRequest = new HttpEntity<>(fileSystemResource, null);
|
HttpHeaders jsonHeaders = new HttpHeaders();
|
||||||
|
jsonHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
addFileMapRequest = new HttpEntity<>(fileSystemResource, jsonHeaders);
|
||||||
String jsonFileName = jsonFile.getHeaders().get("Content-Disposition").get(0).substring(jsonFile.getHeaders().get("Content-Disposition").get(0).lastIndexOf('=') + 1);
|
String jsonFileName = jsonFile.getHeaders().get("Content-Disposition").get(0).substring(jsonFile.getHeaders().get("Content-Disposition").get(0).lastIndexOf('=') + 1);
|
||||||
addFileUrl = links.get("bucket") + "/" + jsonFileName + "?access_token=" + zenodoToken;
|
addFileUrl = links.get("bucket") + "/" + jsonFileName + "?access_token=" + zenodoToken;
|
||||||
restTemplate.put(addFileUrl, addFileMapRequest);
|
restTemplate.put(addFileUrl, addFileMapRequest);
|
||||||
|
|
|
@ -1095,7 +1095,7 @@ public class DatasetManager {
|
||||||
if (!tagNodes.isEmpty()) {
|
if (!tagNodes.isEmpty()) {
|
||||||
tagNodes.forEach(node -> {
|
tagNodes.forEach(node -> {
|
||||||
JsonNode value = node.get("value");
|
JsonNode value = node.get("value");
|
||||||
String stringValue = value.asText().replaceAll("=", ":");
|
String stringValue = value.toString().replaceAll("=", ":");
|
||||||
JSONArray values = new JSONArray(stringValue);
|
JSONArray values = new JSONArray(stringValue);
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
values.iterator().forEachRemaining(element -> {
|
values.iterator().forEachRemaining(element -> {
|
||||||
|
|
|
@ -7,7 +7,10 @@ import eu.eudat.models.data.funder.FunderDMPEditorModel;
|
||||||
import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
||||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
||||||
import eu.eudat.models.data.userinfo.UserInfo;
|
import eu.eudat.models.data.userinfo.UserInfo;
|
||||||
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -16,6 +19,8 @@ import java.util.stream.Collectors;
|
||||||
* Created by ikalyvas on 2/5/2018.
|
* Created by ikalyvas on 2/5/2018.
|
||||||
*/
|
*/
|
||||||
public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataManagementPlanNewVersionModel> {
|
public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataManagementPlanNewVersionModel> {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanNewVersionModel.class);
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
|
@ -26,7 +31,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
|
private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
|
||||||
private List<Organisation> organisations;
|
private List<Organisation> organisations;
|
||||||
private List<Researcher> researchers;
|
private List<Researcher> researchers;
|
||||||
private List<UserDMP> associatedUsers;
|
private List<UserListingModel> associatedUsers;
|
||||||
private eu.eudat.models.data.userinfo.UserInfo creator;
|
private eu.eudat.models.data.userinfo.UserInfo creator;
|
||||||
private Date created;
|
private Date created;
|
||||||
private List<Dataset> datasets;
|
private List<Dataset> datasets;
|
||||||
|
@ -104,10 +109,10 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
this.researchers = researchers;
|
this.researchers = researchers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserDMP> getAssociatedUsers() {
|
public List<UserListingModel> getAssociatedUsers() {
|
||||||
return associatedUsers;
|
return associatedUsers;
|
||||||
}
|
}
|
||||||
public void setAssociatedUsers(List<UserDMP> associatedUsers) {
|
public void setAssociatedUsers(List<UserListingModel> associatedUsers) {
|
||||||
this.associatedUsers = associatedUsers;
|
this.associatedUsers = associatedUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +168,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
public DMP toDataModel() throws Exception {
|
public DMP toDataModel() throws Exception {
|
||||||
DMP entity = new DMP();
|
DMP entity = new DMP();
|
||||||
entity.setId(this.id);
|
entity.setId(this.id);
|
||||||
entity.setUsers(new HashSet<>(new ArrayList<>(this.associatedUsers)));
|
// entity.setUsers(new HashSet<>(new ArrayList<>(this.associatedUsers)));
|
||||||
entity.setDescription(this.description);
|
entity.setDescription(this.description);
|
||||||
entity.setStatus((short) this.status);
|
entity.setStatus((short) this.status);
|
||||||
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
||||||
|
|
Loading…
Reference in New Issue