Add transactional to makeFinalize on DMP and remove jackson parsing when depositing to zenodo

This commit is contained in:
George Kalampokis 2021-11-18 18:27:20 +02:00
parent 4eb15da95a
commit 38cd336bc9
3 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import eu.eudat.queryable.queryableentity.DataEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.Set; import java.util.Set;
@ -28,6 +29,7 @@ public class DatabaseService<T extends DataEntity> {
return this.databaseCtx.getQueryable(tClass); return this.databaseCtx.getQueryable(tClass);
} }
@Transactional
public T createOrUpdate(T item, Class<T> tClass) { public T createOrUpdate(T item, Class<T> tClass) {
return this.databaseCtx.createOrUpdate(item, tClass); return this.databaseCtx.createOrUpdate(item, tClass);
} }

View File

@ -16,6 +16,7 @@ import org.springframework.stereotype.Component;
import javax.persistence.criteria.Join; import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
import javax.transaction.Transactional;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -106,6 +107,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
} }
@Override @Override
@Transactional
public DMP createOrUpdate(DMP item) { public DMP createOrUpdate(DMP item) {
return this.getDatabaseService().createOrUpdate(item, DMP.class); return this.getDatabaseService().createOrUpdate(item, DMP.class);
} }

View File

@ -79,6 +79,7 @@ import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import javax.transaction.Transactional;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
@ -1034,6 +1035,7 @@ public class DataManagementPlanManager {
} }
} }
@Transactional
public void makeFinalize(UUID id, Principal principal, DatasetsToBeFinalized datasetsToBeFinalized) throws Exception { public void makeFinalize(UUID id, Principal principal, DatasetsToBeFinalized datasetsToBeFinalized) throws Exception {
DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id); DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(id);
if (!isUserOwnerOfDmp(dmp, principal)) if (!isUserOwnerOfDmp(dmp, principal))
@ -2093,10 +2095,10 @@ public class DataManagementPlanManager {
} }
dataBuilder.append(" }\n").append("}"); dataBuilder.append(" }\n").append("}");
createData = dataBuilder.toString(); createData = dataBuilder.toString();
ObjectMapper mapper = new ObjectMapper(); /*ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
JsonNode createDataJSON = mapper.readTree(createData); JsonNode createDataJSON = mapper.readTree(createData);*/
HttpEntity<JsonNode> request = new HttpEntity<>(createDataJSON, headers); HttpEntity<String> request = new HttpEntity<>(createData, headers);
Map createResponse = null; Map createResponse = null;
LinkedHashMap<String, String> links = null; LinkedHashMap<String, String> links = null;
String previousDOI = this.getPreviousDOI(dmp.getGroupId(), dmp.getId()); String previousDOI = this.getPreviousDOI(dmp.getGroupId(), dmp.getId());