Refactors Funder, Grant and Project external fetching by adding distinct values for key, indicating the source it was fetched, and it's respected display value.
This commit is contained in:
parent
ff9aa14047
commit
3aa7dc0481
|
@ -17,6 +17,7 @@ public class FunderBuilder extends Builder<Funder> {
|
||||||
private Date modified;
|
private Date modified;
|
||||||
private Integer type;
|
private Integer type;
|
||||||
private String source;
|
private String source;
|
||||||
|
private String key;
|
||||||
|
|
||||||
public FunderBuilder id(UUID id) {
|
public FunderBuilder id(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -63,6 +64,11 @@ public class FunderBuilder extends Builder<Funder> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FunderBuilder key(String key) {
|
||||||
|
this.key = key;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Funder build() {
|
public Funder build() {
|
||||||
Funder funder = new Funder();
|
Funder funder = new Funder();
|
||||||
|
@ -75,6 +81,7 @@ public class FunderBuilder extends Builder<Funder> {
|
||||||
funder.setModified(modified);
|
funder.setModified(modified);
|
||||||
funder.setType(type);
|
funder.setType(type);
|
||||||
funder.setSource(source);
|
funder.setSource(source);
|
||||||
|
funder.setKey(key);
|
||||||
return funder;
|
return funder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,6 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 2/15/2018.
|
|
||||||
*/
|
|
||||||
public class GrantBuilder extends Builder<Grant> {
|
public class GrantBuilder extends Builder<Grant> {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
@ -44,6 +41,8 @@ public class GrantBuilder extends Builder<Grant> {
|
||||||
|
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
public GrantBuilder id(UUID id) {
|
public GrantBuilder id(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return this;
|
||||||
|
@ -119,6 +118,11 @@ public class GrantBuilder extends Builder<Grant> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GrantBuilder key(String key) {
|
||||||
|
this.key = key;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Grant build() {
|
public Grant build() {
|
||||||
Grant grant = new Grant();
|
Grant grant = new Grant();
|
||||||
|
@ -137,6 +141,7 @@ public class GrantBuilder extends Builder<Grant> {
|
||||||
grant.setCreationUser(creationUser);
|
grant.setCreationUser(creationUser);
|
||||||
grant.setStartDate(startDate);
|
grant.setStartDate(startDate);
|
||||||
grant.setSource(source);
|
grant.setSource(source);
|
||||||
|
grant.setKey(key);
|
||||||
return grant;
|
return grant;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class ProjectBuilder extends Builder<Project> {
|
||||||
private Date modified;
|
private Date modified;
|
||||||
private String description;
|
private String description;
|
||||||
private String source;
|
private String source;
|
||||||
|
private String key;
|
||||||
|
|
||||||
public ProjectBuilder id(UUID id) {
|
public ProjectBuilder id(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -109,6 +110,11 @@ public class ProjectBuilder extends Builder<Project> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProjectBuilder key(String key) {
|
||||||
|
this.key = key;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Project build() {
|
public Project build() {
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
|
@ -127,6 +133,7 @@ public class ProjectBuilder extends Builder<Project> {
|
||||||
project.setCreationUser(creationUser);
|
project.setCreationUser(creationUser);
|
||||||
project.setStartDate(startDate);
|
project.setStartDate(startDate);
|
||||||
project.setSource(source);
|
project.setSource(source);
|
||||||
|
project.setKey(key);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
|
||||||
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
||||||
import eu.eudat.logic.builders.model.models.FunderBuilder;
|
import eu.eudat.logic.builders.model.models.FunderBuilder;
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
||||||
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||||
|
@ -47,6 +48,8 @@ public class FunderManager {
|
||||||
eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)
|
eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
||||||
.status(eu.eudat.data.entities.Funder.Status.fromInteger(0))
|
.status(eu.eudat.data.entities.Funder.Status.fromInteger(0))
|
||||||
|
.key(externalListingItem.getKey())
|
||||||
|
.source(externalListingItem.getTag())
|
||||||
.build();
|
.build();
|
||||||
if (externalListingItem.getSource() != null) {
|
if (externalListingItem.getSource() != null) {
|
||||||
funder.setSource(externalListingItem.getSource());
|
funder.setSource(externalListingItem.getSource());
|
||||||
|
|
|
@ -134,6 +134,7 @@ public class GrantManager {
|
||||||
eu.eudat.models.data.grant.Grant grant = apiContext.getOperationsContext().getBuilderFactory().getBuilder(GrantBuilder.class)
|
eu.eudat.models.data.grant.Grant grant = apiContext.getOperationsContext().getBuilderFactory().getBuilder(GrantBuilder.class)
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
||||||
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
||||||
|
.key(externalListingItem.getKey())
|
||||||
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.entities.Grant.Status.fromInteger(0))
|
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.entities.Grant.Status.fromInteger(0))
|
||||||
.source(externalListingItem.getTag())
|
.source(externalListingItem.getTag())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class ProjectManager {
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
||||||
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
||||||
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.entities.Project.Status.fromInteger(0))
|
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.entities.Project.Status.fromInteger(0))
|
||||||
|
.key(externalListingItem.getKey())
|
||||||
.source(externalListingItem.getTag())
|
.source(externalListingItem.getTag())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class RemoteFetcher {
|
||||||
for (UrlConfiguration urlConfig : urlConfigs) {
|
for (UrlConfiguration urlConfig : urlConfigs) {
|
||||||
ifFunderQueryExist(urlConfig, externalUrlCriteria);
|
ifFunderQueryExist(urlConfig, externalUrlCriteria);
|
||||||
if (urlConfig.getType() == null || urlConfig.getType().equals("External")) {
|
if (urlConfig.getType() == null || urlConfig.getType().equals("External")) {
|
||||||
results.addAll(getAllResultsFromUrl(urlConfig.getUrl(), fetchStrategy, urlConfig.getData(), urlConfig.getPaginationPath(), externalUrlCriteria, urlConfig.getLabel(), urlConfig.getContentType(), urlConfig.getFirstpage()));
|
results.addAll(getAllResultsFromUrl(urlConfig.getUrl(), fetchStrategy, urlConfig.getData(), urlConfig.getPaginationPath(), externalUrlCriteria, urlConfig.getLabel(), urlConfig.getKey(), urlConfig.getContentType(), urlConfig.getFirstpage()));
|
||||||
} else if (urlConfig.getType() != null && urlConfig.getType().equals("Internal")) {
|
} else if (urlConfig.getType() != null && urlConfig.getType().equals("Internal")) {
|
||||||
results.addAll(getAllResultsFromMockUpJson(urlConfig.getUrl(), externalUrlCriteria.getLike()));
|
results.addAll(getAllResultsFromMockUpJson(urlConfig.getUrl(), externalUrlCriteria.getLike()));
|
||||||
}
|
}
|
||||||
|
@ -184,14 +184,14 @@ public class RemoteFetcher {
|
||||||
return completedPath;
|
return completedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String key, String contentType, String firstPage) throws HugeResultSet {
|
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage) throws HugeResultSet {
|
||||||
Set<Integer> pages = new HashSet<>();
|
Set<Integer> pages = new HashSet<>();
|
||||||
|
|
||||||
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage);
|
String replacedPath = replaceCriteriaOnUrl(path, externalUrlCriteria, firstPage);
|
||||||
|
|
||||||
Results results = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType);
|
Results results = getResultsFromUrl(replacedPath, jsonDataPath, jsonPaginationPath, contentType);
|
||||||
if (fetchStrategy == FetchStrategy.FIRST)
|
if (fetchStrategy == FetchStrategy.FIRST)
|
||||||
return results == null ? new LinkedList<>() : results.getResults().stream().peek(x -> x.put("tag", key)).collect(Collectors.toList());
|
return results == null ? new LinkedList<>() : results.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||||
|
|
||||||
if (results != null && results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
if (results != null && results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
||||||
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
||||||
|
@ -210,7 +210,7 @@ public class RemoteFetcher {
|
||||||
Results remainingResults = optionalResults.orElseGet(Results::new);
|
Results remainingResults = optionalResults.orElseGet(Results::new);
|
||||||
remainingResults.getResults().addAll(results.getResults());
|
remainingResults.getResults().addAll(results.getResults());
|
||||||
|
|
||||||
return remainingResults.getResults().stream().peek(x -> x.put("tag", key)).collect(Collectors.toList());
|
return remainingResults.getResults().stream().peek(x -> x.put("tag", tag)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,8 +271,7 @@ public class RemoteFetcher {
|
||||||
String filePath = Paths.get(path).toUri().toURL().toString();
|
String filePath = Paths.get(path).toUri().toURL().toString();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
internalResults = mapper.readValue(new File(filePath), new TypeReference<List<Map<String, Object>>>(){});
|
internalResults = mapper.readValue(new File(filePath), new TypeReference<List<Map<String, Object>>>(){});
|
||||||
searchListMap(internalResults, query);
|
return searchListMap(internalResults, query);
|
||||||
return internalResults;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return new LinkedList<>();
|
return new LinkedList<>();
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class FundersExternalSourcesModel extends ExternalListingItem<FundersExte
|
||||||
model.setDescription(item.get("description"));
|
model.setDescription(item.get("description"));
|
||||||
model.setSource(item.get("source"));
|
model.setSource(item.get("source"));
|
||||||
model.setTag(item.get("tag"));
|
model.setTag(item.get("tag"));
|
||||||
|
model.setKey(item.get("key"));
|
||||||
this.add(model);
|
this.add(model);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class GrantsExternalSourcesModel extends ExternalListingItem<GrantsExtern
|
||||||
model.setName(item.get("name"));
|
model.setName(item.get("name"));
|
||||||
model.setDescription(item.get("description"));
|
model.setDescription(item.get("description"));
|
||||||
model.setTag(item.get("tag"));
|
model.setTag(item.get("tag"));
|
||||||
|
model.setKey(item.get("key"));
|
||||||
this.add(model);
|
this.add(model);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -51,6 +51,13 @@ public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsEx
|
||||||
model.setTag(item.get("tag"));
|
model.setTag(item.get("tag"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JsonNode key = node.get("key");
|
||||||
|
if (key != null && !key.isNull() && key.isObject()) {
|
||||||
|
model.setKey(node.get("key").get("$").asText());
|
||||||
|
} else {
|
||||||
|
model.setKey(item.get("key"));
|
||||||
|
}
|
||||||
|
|
||||||
this.add(model);
|
this.add(model);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
||||||
private Date modified;
|
private Date modified;
|
||||||
private Integer type;
|
private Integer type;
|
||||||
private String source;
|
private String source;
|
||||||
|
private String key;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -80,6 +81,13 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Funder fromDataModel(eu.eudat.data.entities.Funder entity) {
|
public Funder fromDataModel(eu.eudat.data.entities.Funder entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
|
@ -93,9 +101,9 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
||||||
if (entity.getReference() != null) {
|
if (entity.getReference() != null) {
|
||||||
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
if (source.equals("dmp")) {
|
if (source.equals("dmp")) {
|
||||||
this.source = "Internal";
|
this.key = "Internal";
|
||||||
} else {
|
} else {
|
||||||
this.source = source;
|
this.key = source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,19 +113,26 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
||||||
@Override
|
@Override
|
||||||
public eu.eudat.data.entities.Funder toDataModel() {
|
public eu.eudat.data.entities.Funder toDataModel() {
|
||||||
eu.eudat.data.entities.Funder entity = new eu.eudat.data.entities.Funder();
|
eu.eudat.data.entities.Funder entity = new eu.eudat.data.entities.Funder();
|
||||||
entity.setId(UUID.randomUUID());
|
if (this.getId() != null) {
|
||||||
|
entity.setId(this.getId());
|
||||||
|
} else {
|
||||||
|
entity.setId(UUID.randomUUID());
|
||||||
|
}
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setType(this.type);
|
entity.setType(this.type);
|
||||||
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
// If internal, key has no value, fill it.
|
||||||
if (this.source == null && this.reference != null && this.reference.startsWith("dmp:")) {
|
if ((this.source != null && this.source.equals("Internal")) || (this.key != null && this.key.equals("Internal"))) this.key = "dmp";
|
||||||
entity.setReference(this.reference);
|
// Logic for the different "key" cases.
|
||||||
|
if ((this.key == null || this.key.trim().isEmpty()) && (this.source != null && !this.source.trim().isEmpty())) {
|
||||||
|
this.key = this.source;
|
||||||
}
|
}
|
||||||
if (this.reference != null && !this.reference.trim().isEmpty()
|
if (this.reference != null && this.reference.startsWith("dmp:")) {
|
||||||
&& this.source != null && !this.source.trim().isEmpty()) {
|
entity.setReference(this.reference);
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
} else if (this.reference != null && !this.reference.trim().isEmpty() && this.key != null && !this.key.trim().isEmpty()) {
|
||||||
|
if (this.key.equals(this.reference.substring(0, this.key.length()))) {
|
||||||
entity.setReference(this.reference);
|
entity.setReference(this.reference);
|
||||||
} else {
|
} else {
|
||||||
entity.setReference(this.source.toLowerCase() + ":" + this.reference);
|
entity.setReference(this.key.toLowerCase() + ":" + this.reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entity.setDefinition(this.definition);
|
entity.setDefinition(this.definition);
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
||||||
private List<ContentFile> files;
|
private List<ContentFile> files;
|
||||||
private UUID funderId;
|
private UUID funderId;
|
||||||
private String source;
|
private String source;
|
||||||
|
private String key;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -159,6 +160,13 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Grant fromDataModel(eu.eudat.data.entities.Grant entity) {
|
public Grant fromDataModel(eu.eudat.data.entities.Grant entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
|
@ -180,9 +188,9 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
||||||
if (entity.getReference() != null) {
|
if (entity.getReference() != null) {
|
||||||
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
if (source.equals("dmp")) {
|
if (source.equals("dmp")) {
|
||||||
this.source = "Internal";
|
this.key = "Internal";
|
||||||
} else {
|
} else {
|
||||||
this.source = source;
|
this.key = source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,20 +200,22 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
||||||
@Override
|
@Override
|
||||||
public eu.eudat.data.entities.Grant toDataModel() {
|
public eu.eudat.data.entities.Grant toDataModel() {
|
||||||
eu.eudat.data.entities.Grant entity = new eu.eudat.data.entities.Grant();
|
eu.eudat.data.entities.Grant entity = new eu.eudat.data.entities.Grant();
|
||||||
entity.setId(UUID.randomUUID());
|
if (this.getId() != null) {
|
||||||
|
entity.setId(this.getId());
|
||||||
|
} else {
|
||||||
|
entity.setId(UUID.randomUUID());
|
||||||
|
}
|
||||||
entity.setAbbreviation(this.abbreviation);
|
entity.setAbbreviation(this.abbreviation);
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setType(this.type);
|
entity.setType(this.type);
|
||||||
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
if ((this.source != null && this.source.equals("Internal")) || (this.key != null && this.key.equals("Internal"))) this.key = "dmp";
|
||||||
if (this.source == null && this.reference != null && this.reference.startsWith("dmp:")) {
|
if (this.reference != null && this.reference.startsWith("dmp:")) {
|
||||||
entity.setReference(this.reference);
|
entity.setReference(this.reference);
|
||||||
}
|
} else if (this.reference != null && !this.reference.trim().isEmpty() && this.key != null && !this.key.trim().isEmpty()) {
|
||||||
if (this.reference != null && !this.reference.trim().isEmpty()
|
if (this.key.equals(this.reference.substring(0, this.key.length()))) {
|
||||||
&& this.source != null && !this.source.trim().isEmpty()) {
|
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
|
||||||
entity.setReference(this.reference);
|
entity.setReference(this.reference);
|
||||||
} else {
|
} else {
|
||||||
entity.setReference(this.source.toLowerCase() + ":" + this.reference);
|
entity.setReference(this.key.toLowerCase() + ":" + this.reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entity.setUri(this.uri);
|
entity.setUri(this.uri);
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
||||||
private String description;
|
private String description;
|
||||||
private List<ContentFile> files;
|
private List<ContentFile> files;
|
||||||
private String source;
|
private String source;
|
||||||
|
private String key;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -149,6 +150,13 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Project fromDataModel(eu.eudat.data.entities.Project entity) {
|
public Project fromDataModel(eu.eudat.data.entities.Project entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
|
@ -168,9 +176,9 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
||||||
if (entity.getReference() != null) {
|
if (entity.getReference() != null) {
|
||||||
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
if (source.equals("dmp")) {
|
if (source.equals("dmp")) {
|
||||||
this.source = "Internal";
|
this.key = "Internal";
|
||||||
} else {
|
} else {
|
||||||
this.source = source;
|
this.key = source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,16 +192,14 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
||||||
entity.setAbbreviation(this.abbreviation);
|
entity.setAbbreviation(this.abbreviation);
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setType(this.type);
|
entity.setType(this.type);
|
||||||
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
if ((this.source != null && this.source.equals("Internal")) || (this.key != null && this.key.equals("Internal"))) this.key = "dmp";
|
||||||
if (this.source == null && this.reference != null && this.reference.startsWith("dmp:")) {
|
if (this.reference != null && this.reference.startsWith("dmp:")) {
|
||||||
entity.setReference(this.reference);
|
entity.setReference(this.reference);
|
||||||
}
|
} else if (this.reference != null && !this.reference.trim().isEmpty() && this.key != null && !this.key.trim().isEmpty()) {
|
||||||
if (this.reference != null && !this.reference.trim().isEmpty()
|
if (this.key.equals(this.reference.substring(0, this.key.length()))) {
|
||||||
&& this.source != null && !this.source.trim().isEmpty()) {
|
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
|
||||||
entity.setReference(this.reference);
|
entity.setReference(this.reference);
|
||||||
} else {
|
} else {
|
||||||
entity.setReference(this.source.toLowerCase() + ":" + this.reference);
|
entity.setReference(this.key.toLowerCase() + ":" + this.reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entity.setUri(this.uri);
|
entity.setUri(this.uri);
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/RegistriesInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/RegistriesInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
<label>internal</label>
|
<label>internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/TagsInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/TagsInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||||
</urlConfig>
|
</urlConfig>
|
||||||
<urlConfig>
|
<urlConfig>
|
||||||
<key>openAIRE</key>
|
<key>openaire</key>
|
||||||
<label>OpenAIRE</label>
|
<label>OpenAIRE</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype%20exact%20project)%20and%20((projectcode_nt%20exact%20%22{like}%22)or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
<url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype%20exact%20project)%20and%20((projectcode_nt%20exact%20%22{like}%22)or({like}))){funderQuery}&page={page}&size={pageSize}&format=json</url>
|
||||||
|
@ -185,7 +185,7 @@
|
||||||
<key>internal</key>
|
<key>internal</key>
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<url>mockData/GrantInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/GrantInternalMockUpData.json</url>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
|
@ -224,7 +224,7 @@
|
||||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||||
</urlConfig>
|
</urlConfig>
|
||||||
<urlConfig>
|
<urlConfig>
|
||||||
<key>openAIRE</key>
|
<key>openaire</key>
|
||||||
<label>OpenAIRE</label>
|
<label>OpenAIRE</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>External</type>
|
<type>External</type>
|
||||||
|
@ -265,7 +265,7 @@
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/ProjectInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/ProjectInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -283,6 +283,74 @@
|
||||||
|
|
||||||
<funders>
|
<funders>
|
||||||
<urls>
|
<urls>
|
||||||
|
<urlConfig>
|
||||||
|
<key>openaire</key>
|
||||||
|
<label>OpenAIRE</label>
|
||||||
|
<ordinal>1</ordinal>
|
||||||
|
<type>External</type>
|
||||||
|
<url>https://services.openaire.eu/search/v2/api/publications?&refine=true&fields=relfunder&page={page}&size=0&format=json</url>
|
||||||
|
<firstPage>0</firstPage>
|
||||||
|
<contenttype>application/json; charset=utf-8</contenttype>
|
||||||
|
<data>
|
||||||
|
<path>$['refineResults']['relfunder'][*]</path>
|
||||||
|
<fields>
|
||||||
|
<name>'name'</name>
|
||||||
|
<id>'id'</id>
|
||||||
|
<count>'count'</count>
|
||||||
|
</fields>
|
||||||
|
</data>
|
||||||
|
</urlConfig>
|
||||||
|
<urlConfig>
|
||||||
|
<key>openaire</key>
|
||||||
|
<label>OpenAIRE</label>
|
||||||
|
<ordinal>1</ordinal>
|
||||||
|
<type>External</type>
|
||||||
|
<url>https://services.openaire.eu/search/v2/api/datasets?&refine=true&fields=relfunder&page=0&size={page}&format=json</url>
|
||||||
|
<firstPage>0</firstPage>
|
||||||
|
<contenttype>application/json; charset=utf-8</contenttype>
|
||||||
|
<data>
|
||||||
|
<path>$['refineResults']['relfunder'][*]</path>
|
||||||
|
<fields>
|
||||||
|
<name>'name'</name>
|
||||||
|
<id>'id'</id>
|
||||||
|
<count>'count'</count>
|
||||||
|
</fields>
|
||||||
|
</data>
|
||||||
|
</urlConfig>
|
||||||
|
<urlConfig>
|
||||||
|
<key>openaire</key>
|
||||||
|
<label>OpenAIRE</label>
|
||||||
|
<ordinal>1</ordinal>
|
||||||
|
<type>External</type>
|
||||||
|
<url>https://services.openaire.eu/search/v2/api/software?&refine=true&fields=relfunder&page={page}&size=0&format=json</url>
|
||||||
|
<firstPage>0</firstPage>
|
||||||
|
<contenttype>application/json; charset=utf-8</contenttype>
|
||||||
|
<data>
|
||||||
|
<path>$['refineResults']['relfunder'][*]</path>
|
||||||
|
<fields>
|
||||||
|
<name>'name'</name>
|
||||||
|
<id>'id'</id>
|
||||||
|
<count>'count'</count>
|
||||||
|
</fields>
|
||||||
|
</data>
|
||||||
|
</urlConfig>
|
||||||
|
<urlConfig>
|
||||||
|
<key>openaire</key>
|
||||||
|
<label>OpenAIRE</label>
|
||||||
|
<ordinal>1</ordinal>
|
||||||
|
<type>External</type>
|
||||||
|
<url>https://services.openaire.eu/search/v2/api/other?&refine=true&fields=relfunder&page={page}&size=0&format=json</url>
|
||||||
|
<firstPage>0</firstPage>
|
||||||
|
<contenttype>application/json; charset=utf-8</contenttype>
|
||||||
|
<data>
|
||||||
|
<path>$['refineResults']['relfunder'][*]</path>
|
||||||
|
<fields>
|
||||||
|
<name>'name'</name>
|
||||||
|
<id>'id'</id>
|
||||||
|
<count>'count'</count>
|
||||||
|
</fields>
|
||||||
|
</data>
|
||||||
|
</urlConfig>
|
||||||
<!-- <urlConfig>
|
<!-- <urlConfig>
|
||||||
<key>cristin</key>
|
<key>cristin</key>
|
||||||
<label>Cristin</label>
|
<label>Cristin</label>
|
||||||
|
@ -303,8 +371,8 @@
|
||||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||||
</urlConfig>-->
|
</urlConfig>-->
|
||||||
<urlConfig>
|
<urlConfig>
|
||||||
<key>openAire</key>
|
<key>cristin</key>
|
||||||
<label>OpenAIRE</label>
|
<label>Cristin</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>External</type>
|
<type>External</type>
|
||||||
<url>https://eestore.paas2.uninett.no/api/projectrepo/?search={like}&page={page}&size={pageSize}</url>
|
<url>https://eestore.paas2.uninett.no/api/projectrepo/?search={like}&page={page}&size={pageSize}</url>
|
||||||
|
@ -317,11 +385,26 @@
|
||||||
<name>'name'</name>
|
<name>'name'</name>
|
||||||
<uri>'uri'</uri>
|
<uri>'uri'</uri>
|
||||||
<description>'description'</description>
|
<description>'description'</description>
|
||||||
<source>'source'</source>
|
|
||||||
</fields>
|
</fields>
|
||||||
</data>
|
</data>
|
||||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||||
</urlConfig>
|
</urlConfig>
|
||||||
|
<urlConfig>
|
||||||
|
<key>crossref</key>
|
||||||
|
<label>Crossref Funder Registry</label>
|
||||||
|
<ordinal>1</ordinal>
|
||||||
|
<type>External</type>
|
||||||
|
<url>https://api.crossref.org/funders?query={like}&rows={pageSize}</url>
|
||||||
|
<contenttype>application/json; charset=utf-8</contenttype>
|
||||||
|
<data>
|
||||||
|
<path>$['message']['items'][*]</path>
|
||||||
|
<fields>
|
||||||
|
<name>'name'</name>
|
||||||
|
<id>'id'</id>
|
||||||
|
<count>'count'</count>
|
||||||
|
</fields>
|
||||||
|
</data>
|
||||||
|
</urlConfig>
|
||||||
<!-- <urlConfig>
|
<!-- <urlConfig>
|
||||||
<key>servicesOpenAire</key>
|
<key>servicesOpenAire</key>
|
||||||
<label>OpenAIRE</label>
|
<label>OpenAIRE</label>
|
||||||
|
@ -395,7 +478,7 @@
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>FunderInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/FunderInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -452,12 +535,12 @@
|
||||||
</data>
|
</data>
|
||||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||||
</urlConfig>-->
|
</urlConfig>-->
|
||||||
<!-- <urlConfig>
|
<!--<urlConfig>
|
||||||
<key>internal</key>
|
<key>internal</key>
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/RepositoriesInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/RepositoriesInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -520,7 +603,7 @@
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/ServicesInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/ServicesInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -583,7 +666,7 @@
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/ResearcherInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/ResearcherInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -646,7 +729,7 @@
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/OrganisationInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/OrganisationInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
@ -679,6 +762,7 @@
|
||||||
<name>'name'</name>
|
<name>'name'</name>
|
||||||
<uri>'uri'</uri>
|
<uri>'uri'</uri>
|
||||||
<description>'description'</description>
|
<description>'description'</description>
|
||||||
|
<source>'source'</source>
|
||||||
</fields>
|
</fields>
|
||||||
</data>
|
</data>
|
||||||
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
|
||||||
|
@ -707,7 +791,7 @@
|
||||||
<label>Internal</label>
|
<label>Internal</label>
|
||||||
<ordinal>1</ordinal>
|
<ordinal>1</ordinal>
|
||||||
<type>Internal</type>
|
<type>Internal</type>
|
||||||
<url>mockData/DatasetsInternalMockUpData.json</url>
|
<url>web/src/main/resources/mockData/DatasetsInternalMockUpData.json</url>
|
||||||
<data>
|
<data>
|
||||||
<path>$['data'][*]['attributes']</path>
|
<path>$['data'][*]['attributes']</path>
|
||||||
<fields>
|
<fields>
|
||||||
|
|
Loading…
Reference in New Issue