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)
|
||||
private String definition;
|
||||
|
||||
@Column(name = "\"StartDate\"", nullable = false)
|
||||
@Column(name = "\"StartDate\"", nullable = true)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date startdate = null;
|
||||
|
||||
@Column(name = "\"EndDate\"", nullable = false)
|
||||
@Column(name = "\"EndDate\"", nullable = true)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date enddate = null;
|
||||
|
||||
|
|
|
@ -151,8 +151,11 @@ public class DataManagementPlanManager {
|
|||
items = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (items == null) {
|
||||
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||
}
|
||||
|
||||
List<Integer> roles = new LinkedList<>();
|
||||
if (!dataManagementPlanTableRequest.getCriteria().isOnlyPublic()) {
|
||||
if (dataManagementPlanTableRequest.getCriteria().getRole() != null)
|
||||
|
@ -161,8 +164,11 @@ public class DataManagementPlanManager {
|
|||
} else {
|
||||
authItems = items;
|
||||
}
|
||||
if (items == null) {
|
||||
totalData = authItems.count();
|
||||
items = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||
} else {
|
||||
items = authItems;
|
||||
}
|
||||
|
||||
|
||||
|
@ -534,6 +540,10 @@ public class DataManagementPlanManager {
|
|||
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||
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);
|
||||
|
||||
if (setNotification) {
|
||||
|
@ -625,13 +635,16 @@ public class DataManagementPlanManager {
|
|||
assignGrandUserIfInternal(newDmp, user);
|
||||
assignFunderUserIfInternal(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());
|
||||
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
|
||||
newDmp.setId(tempDmp.getId());
|
||||
|
||||
// Assign creator.
|
||||
assignUser(newDmp, user);
|
||||
|
||||
copyDatasets(newDmp, databaseRepository.getDatasetDao());
|
||||
|
||||
databaseRepository
|
||||
|
@ -797,6 +810,12 @@ public class DataManagementPlanManager {
|
|||
else {
|
||||
grant.setType(Grant.GrantType.EXTERNAL.getValue());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1749,7 +1768,16 @@ public class DataManagementPlanManager {
|
|||
userDMP.setDmp(dmp);
|
||||
userDMP.setUser(userInfo);
|
||||
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) {
|
||||
|
@ -2147,7 +2175,9 @@ public class DataManagementPlanManager {
|
|||
jsonFos.flush();
|
||||
}
|
||||
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);
|
||||
addFileUrl = links.get("bucket") + "/" + jsonFileName + "?access_token=" + zenodoToken;
|
||||
restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
|
|
|
@ -1095,7 +1095,7 @@ public class DatasetManager {
|
|||
if (!tagNodes.isEmpty()) {
|
||||
tagNodes.forEach(node -> {
|
||||
JsonNode value = node.get("value");
|
||||
String stringValue = value.asText().replaceAll("=", ":");
|
||||
String stringValue = value.toString().replaceAll("=", ":");
|
||||
JSONArray values = new JSONArray(stringValue);
|
||||
if (values != null) {
|
||||
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.project.ProjectDMPEditorModel;
|
||||
import eu.eudat.models.data.userinfo.UserInfo;
|
||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -16,6 +19,8 @@ import java.util.stream.Collectors;
|
|||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataManagementPlanNewVersionModel> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanNewVersionModel.class);
|
||||
|
||||
private UUID id;
|
||||
private String label;
|
||||
private UUID groupId;
|
||||
|
@ -26,7 +31,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
private eu.eudat.models.data.grant.GrantDMPEditorModel grant;
|
||||
private List<Organisation> organisations;
|
||||
private List<Researcher> researchers;
|
||||
private List<UserDMP> associatedUsers;
|
||||
private List<UserListingModel> associatedUsers;
|
||||
private eu.eudat.models.data.userinfo.UserInfo creator;
|
||||
private Date created;
|
||||
private List<Dataset> datasets;
|
||||
|
@ -104,10 +109,10 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
this.researchers = researchers;
|
||||
}
|
||||
|
||||
public List<UserDMP> getAssociatedUsers() {
|
||||
public List<UserListingModel> getAssociatedUsers() {
|
||||
return associatedUsers;
|
||||
}
|
||||
public void setAssociatedUsers(List<UserDMP> associatedUsers) {
|
||||
public void setAssociatedUsers(List<UserListingModel> associatedUsers) {
|
||||
this.associatedUsers = associatedUsers;
|
||||
}
|
||||
|
||||
|
@ -163,7 +168,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
public DMP toDataModel() throws Exception {
|
||||
DMP entity = new DMP();
|
||||
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.setStatus((short) this.status);
|
||||
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
||||
|
@ -227,7 +232,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
|||
funder.setModified(new Date());
|
||||
|
||||
entity.getGrant().setFunder(funder);
|
||||
} else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
|
||||
} else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null) {
|
||||
entity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
|
||||
entity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue