Add openaire grant on DOI creation (ref #257)
This commit is contained in:
parent
42b2ff67f6
commit
0eb0707fd5
|
@ -0,0 +1,11 @@
|
||||||
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
|
import eu.eudat.data.entities.DoiFunder;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface DoiFunderDao extends DatabaseAccessLayer<DoiFunder, UUID> {
|
||||||
|
|
||||||
|
DoiFunder findFunderByName(String name);
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
|
import eu.eudat.data.entities.DoiFunder;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Component("DoiFunderDao")
|
||||||
|
public class DoiFunderDaoImpl extends DatabaseAccess<DoiFunder> implements DoiFunderDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DoiFunderDaoImpl(DatabaseService<DoiFunder> databaseService) {
|
||||||
|
super(databaseService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder findFunderByName(String name) {
|
||||||
|
return this.asQueryable().toList().stream().filter(doiFunder -> name.contains(doiFunder.getName()) || doiFunder.getName().contains(name)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder createOrUpdate(DoiFunder item) {
|
||||||
|
return this.getDatabaseService().createOrUpdate(item, DoiFunder.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<DoiFunder> createOrUpdateAsync(DoiFunder item) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder find(UUID id) {
|
||||||
|
return this.getDatabaseService().getQueryable(DoiFunder.class).where(((builder, root) -> builder.equal(root.get("id"), id))).getSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder find(UUID id, String hint) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(DoiFunder item) {
|
||||||
|
this.getDatabaseService().delete(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<DoiFunder> asQueryable() {
|
||||||
|
return this.getDatabaseService().getQueryable(DoiFunder.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package eu.eudat.data.entities;
|
||||||
|
|
||||||
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "\"DoiFunder\"")
|
||||||
|
public class DoiFunder implements DataEntity<DoiFunder, UUID> {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(name = "name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "doi")
|
||||||
|
private String doi;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDoi() {
|
||||||
|
return doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDoi(String doi) {
|
||||||
|
this.doi = doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DoiFunder entity) {
|
||||||
|
this.name = entity.name;
|
||||||
|
this.doi = entity.doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getKeys() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1667,6 +1667,14 @@ public class DataManagementPlanManager {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
dataBuilder.append("],\n");
|
dataBuilder.append("],\n");
|
||||||
|
String grantReferenceHead = dmp.getGrant().getReference().split(":")[0];
|
||||||
|
if (grantReferenceHead.equals("openaire")) {
|
||||||
|
String grantReferenceTail = dmp.getGrant().getReference().split(":")[3];
|
||||||
|
DoiFunder doiFunder = this.apiContext.getOperationsContext().getDatabaseRepository().getDoiFunderDao().findFunderByName(dmp.getGrant().getFunder().getLabel());
|
||||||
|
String finalId = doiFunder.getDoi() + "::" + grantReferenceTail;
|
||||||
|
dataBuilder.append(" \"grants\": [{\n");
|
||||||
|
dataBuilder.append(" \t\t\"id\": \"").append(finalId).append("\"\n}],\n");
|
||||||
|
}
|
||||||
dataBuilder.append(" \"creators\": [{\n");
|
dataBuilder.append(" \"creators\": [{\n");
|
||||||
dataBuilder.append(" \t\t\"name\": \"").append(dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser().getName()).append("\",\n");
|
dataBuilder.append(" \t\t\"name\": \"").append(dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser().getName()).append("\",\n");
|
||||||
dataBuilder.append(" \t\t\"affiliation\": \"OpenDMP\"}]\n");
|
dataBuilder.append(" \t\t\"affiliation\": \"OpenDMP\"}]\n");
|
||||||
|
|
|
@ -58,5 +58,7 @@ public interface DatabaseRepository {
|
||||||
|
|
||||||
UserAssociationDao getUserAssociationDao();
|
UserAssociationDao getUserAssociationDao();
|
||||||
|
|
||||||
|
DoiFunderDao getDoiFunderDao();
|
||||||
|
|
||||||
<T> void detachEntity(T entity);
|
<T> void detachEntity(T entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
||||||
private LockDao lockDao;
|
private LockDao lockDao;
|
||||||
private NotificationDao notificationDao;
|
private NotificationDao notificationDao;
|
||||||
private UserAssociationDao userAssociationDao;
|
private UserAssociationDao userAssociationDao;
|
||||||
|
private DoiFunderDao doiFunderDao;
|
||||||
|
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@ -296,6 +297,16 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
||||||
return userAssociationDao;
|
return userAssociationDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunderDao getDoiFunderDao() {
|
||||||
|
return doiFunderDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setDoiFunderDao(DoiFunderDao doiFunderDao) {
|
||||||
|
this.doiFunderDao = doiFunderDao;
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setUserAssociationDao(UserAssociationDao userAssociationDao) {
|
public void setUserAssociationDao(UserAssociationDao userAssociationDao) {
|
||||||
this.userAssociationDao = userAssociationDao;
|
this.userAssociationDao = userAssociationDao;
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
CREATE TABLE public."DoiFunder" (
|
||||||
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
||||||
|
name character varying,
|
||||||
|
doi character varying
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public."DoiFunder" OWNER TO dmptool;
|
||||||
|
|
||||||
|
COPY public."DoiFunder" (id, name, doi) FROM stdin;
|
||||||
|
ad9bad58-52a9-4c0c-85e1-ca8d0bf72c5f Australian Research Council 10.13039/501100000923
|
||||||
|
a778e6fe-17d1-4e5b-978f-2a290f096530 European Commission 10.13039/501100000780
|
||||||
|
ef314bc9-b72c-4c88-9ca8-e23d4f564136 Fundação para a Ciência e a Tecnologia 10.13039/501100001871
|
||||||
|
19a21b03-9313-4497-b69c-91c8396aeda8 Ministarstvo Prosvete, Nauke i Tehnološkog Razvoja 10.13039/501100004564
|
||||||
|
d6430393-daac-403a-bb76-36100662b4d6 Ministarstvo Znanosti, Obrazovanja i Sporta 10.13039/501100006588
|
||||||
|
4b06a13f-8392-4aa4-ae28-6b6ab68fc266 National Health and Medical Research Council 10.13039/501100000925
|
||||||
|
cbcac800-69cb-42fe-95af-5de1594987e2 National Science Foundation 10.13039/100000001
|
||||||
|
3c8b88c6-710c-4a9c-bf39-bc35259cc7bf Nederlandse Organisatie voor Wetenschappelijk Onderzoek 10.13039/501100003246
|
||||||
|
1816a401-cf74-4ff9-939d-faf1aad21b60 Wellcome Trust 10.13039/100004440
|
||||||
|
\.
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public."DoiFunder"
|
||||||
|
ADD CONSTRAINT "DoiFunder_pkey" PRIMARY KEY (id);
|
||||||
|
|
Loading…
Reference in New Issue