Adds Funder's entity its respected needed properties for external fetching. (Issue #145)

This commit is contained in:
gkolokythas 2019-08-20 18:22:53 +03:00
parent 5489a18c75
commit 43fbacc39f
21 changed files with 821 additions and 23 deletions

View File

@ -0,0 +1,16 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.FunderCriteria;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public interface FunderDao extends DatabaseAccessLayer<Funder, UUID> {
QueryableList<Funder> getWithCritetia(FunderCriteria criteria);
QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal);
}

View File

@ -0,0 +1,70 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.FunderCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.UserInfo;
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("funderDao")
public class FunderDaoImpl extends DatabaseAccess<Funder> implements FunderDao {
@Autowired
public FunderDaoImpl(DatabaseService<Funder> databaseService) {
super(databaseService);
}
@Override
public QueryableList<Funder> getWithCritetia(FunderCriteria criteria) {
QueryableList<Funder> query = getDatabaseService().getQueryable(Funder.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) ->
builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%"))));
if (criteria.getReference() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getReference()));
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
return query;
}
@Override
public QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal) {
return null;
}
@Override
public Funder createOrUpdate(Funder item) {
return this.getDatabaseService().createOrUpdate(item, Funder.class);
}
@Override
public CompletableFuture<Funder> createOrUpdateAsync(Funder item) {
return null;
}
@Override
public Funder find(UUID id) {
return this.getDatabaseService().getQueryable(Funder.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public Funder find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(Funder item) {
throw new UnsupportedOperationException();
}
@Override
public QueryableList<Funder> asQueryable() {
return this.getDatabaseService().getQueryable(Funder.class);
}
}

View File

@ -30,6 +30,7 @@ public class ResponsesCache {
caches.add(new GuavaCache("repositories", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("grants", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("projects", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("funders", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("organisations", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("registries", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("services", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));

View File

@ -0,0 +1,12 @@
package eu.eudat.configurations.dynamicfunder;
import eu.eudat.configurations.dynamicfunder.entities.Configuration;
import eu.eudat.models.data.dynamicfields.DynamicField;
import java.util.List;
public interface DynamicFunderConfiguration {
Configuration getConfiguration();
List<DynamicField> getFields();
}

View File

@ -0,0 +1,83 @@
package eu.eudat.configurations.dynamicfunder;
import eu.eudat.configurations.dynamicfunder.entities.Configuration;
import eu.eudat.configurations.dynamicfunder.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;
@Service("dynamicFunderConfiguration")
@Profile("devel")
public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfiguration {
private Configuration configuration;
private List<DynamicField> fields;
private Environment environment;
public DynamicFunderConfigurationDevelImpl(Environment environment) {
this.environment = environment;
}
@Override
public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicFunderUrl");
System.out.println("Loaded also config file: " + fileUrl);
String current = null;
InputStream is = null;
try {
current = new java.io.File(".").getCanonicalPath();
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL("file:///"+current + "/web/src/main/resources/FunderConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
} finally {
try {
if (is != null) is.close();
} catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl);
}
}
return this.configuration;
}
@Override
public List<DynamicField> getFields() {
if (this.fields != null) return this.fields;
Configuration configuration = this.getConfiguration();
List<DynamicField> fields = new LinkedList<>();
List<Property> properties = configuration.getConfigurationProperties();
properties.stream().forEach(item -> {
DynamicField dynamicField = new DynamicField();
dynamicField.setId(item.getId());
dynamicField.setName(item.getName());
dynamicField.setQueryProperty(item.getQueryProperty());
dynamicField.setRequired(item.getRequired());
List<Dependency> dependencies = new LinkedList<>();
item.getDependencies().stream().forEach(dependency -> {
Dependency modelDependency = new Dependency();
modelDependency.setId(dependency.getId());
modelDependency.setQueryProperty(dependency.getQueryProperty());
dependencies.add(modelDependency);
});
dynamicField.setDependencies(dependencies);
fields.add(dynamicField);
});
this.fields = fields;
return fields;
}
}

View File

@ -0,0 +1,84 @@
package eu.eudat.configurations.dynamicfunder;
import eu.eudat.configurations.dynamicfunder.entities.Configuration;
import eu.eudat.configurations.dynamicfunder.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.List;
@Service("dynamicFunderConfiguration")
@Profile({ "production", "staging" })
public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfiguration {
private Configuration configuration;
private List<DynamicField> fields;
private Environment environment;
public DynamicFunderConfigurationProdImpl(Environment environment) {
this.environment = environment;
}
@Override
public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl");
System.out.println("Loaded also config file: " + fileUrl);
String current = null;
InputStream is = null;
try {
current = new java.io.File(".").getCanonicalPath();
JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
} finally {
try {
if (is != null) is.close();
} catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl);
}
}
return this.configuration;
}
@Override
public List<DynamicField> getFields() {
if (this.fields != null) return this.fields;
Configuration configuration = this.getConfiguration();
List<DynamicField> fields = new LinkedList<>();
List<Property> properties = configuration.getConfigurationProperties();
properties.stream().forEach(item -> {
DynamicField dynamicField = new DynamicField();
dynamicField.setId(item.getId());
dynamicField.setName(item.getName());
dynamicField.setQueryProperty(item.getQueryProperty());
dynamicField.setRequired(item.getRequired());
List<Dependency> dependencies = new LinkedList<>();
item.getDependencies().stream().forEach(dependency -> {
Dependency modelDependency = new Dependency();
modelDependency.setId(dependency.getId());
modelDependency.setQueryProperty(dependency.getQueryProperty());
dependencies.add(modelDependency);
});
dynamicField.setDependencies(dependencies);
fields.add(dynamicField);
});
this.fields = fields;
return fields;
}
}

View File

@ -0,0 +1,31 @@
package eu.eudat.configurations.dynamicfunder.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement
public class Configuration {
private List<Property> configurationProperties;
private MainProperty mainExternalField;
public MainProperty getMainExternalField() {
return mainExternalField;
}
@XmlElement(name = "mainExternalField")
public void setMainExternalField(MainProperty mainExternalField) {
this.mainExternalField = mainExternalField;
}
public List<Property> getConfigurationProperties() {
return configurationProperties;
}
@XmlElementWrapper
@XmlElement(name = "property")
public void setConfigurationProperties(List<Property> configurationProperties) {
this.configurationProperties = configurationProperties;
}
}

View File

@ -0,0 +1,26 @@
package eu.eudat.configurations.dynamicfunder.entities;
import javax.xml.bind.annotation.XmlElement;
public class Dependency {
private String id;
private String queryProperty;
public String getId() {
return id;
}
public String getQueryProperty() {
return queryProperty;
}
@XmlElement(name = "id")
public void setId(String id) {
this.id = id;
}
@XmlElement(name = "queryProperty")
public void setQueryProperty(String queryProperty) {
this.queryProperty = queryProperty;
}
}

View File

@ -0,0 +1,26 @@
package eu.eudat.configurations.dynamicfunder.entities;
import javax.xml.bind.annotation.XmlElement;
public class Language {
private String key;
private String languageKey;
public String getKey() {
return key;
}
@XmlElement(name = "key")
public void setKey(String key) {
this.key = key;
}
public String getLanguageKey() {
return languageKey;
}
@XmlElement(name = "languageKey")
public void setLanguageKey(String languageKey) {
this.languageKey = languageKey;
}
}

View File

@ -0,0 +1,103 @@
package eu.eudat.configurations.dynamicfunder.entities;
import eu.eudat.logic.proxy.config.UrlConfiguration;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class MainProperty {
private String id;
private String name;
private String queryProperty;
private String externalFieldId;
private UrlConfiguration urlConfig;
private String externalFieldLabel;
private List<Dependency> dependencies;
private Boolean required;
private List<Language> language;
public String getId() {
return id;
}
@XmlElement(name = "id")
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
@XmlElement(name = "name")
public void setName(String name) {
this.name = name;
}
public String getExternalFieldId() {
return externalFieldId;
}
@XmlElement(name = "externalFieldId")
public void setExternalFieldId(String externalFieldId) {
this.externalFieldId = externalFieldId;
}
public String getExternalFieldLabel() {
return externalFieldLabel;
}
@XmlElement(name = "externalFieldLabel")
public void setExternalFieldLabel(String externalFieldLabel) {
this.externalFieldLabel = externalFieldLabel;
}
public List<Dependency> getDependencies() {
return dependencies;
}
@XmlElementWrapper
@XmlElement(name = "dependency")
public void setDependencies(List<Dependency> dependencies) {
this.dependencies = dependencies;
}
public Boolean getRequired() {
return required;
}
@XmlElement(name = "required")
public void setRequired(Boolean required) {
this.required = required;
}
public String getQueryProperty() {
return queryProperty;
}
@XmlElement(name = "queryProperty")
public void setQueryProperty(String queryProperty) {
this.queryProperty = queryProperty;
}
public UrlConfiguration getUrlConfig() {
return urlConfig;
}
@XmlElement(name = "urlConfig")
public void setUrlConfig(UrlConfiguration urlConfig) {
this.urlConfig = urlConfig;
}
public List<Language> getLanguage() {
return language;
}
@XmlElementWrapper
@XmlElement(name = "languageProperty")
public void setLanguage(List<Language> language) {
this.language = language;
}
}

View File

@ -0,0 +1,91 @@
package eu.eudat.configurations.dynamicfunder.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class Property {
private String id;
private String name;
private String sourceUrl;
private String queryProperty;
private String externalFieldId;
private String externalFieldLabel;
private List<Dependency> dependencies;
private Boolean required;
public String getId() {
return id;
}
@XmlElement(name = "id")
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
@XmlElement(name = "name")
public void setName(String name) {
this.name = name;
}
public String getSourceUrl() {
return sourceUrl;
}
@XmlElement(name = "sourceUrl")
public void setSourceUrl(String sourceUrl) {
this.sourceUrl = sourceUrl;
}
public String getExternalFieldId() {
return externalFieldId;
}
@XmlElement(name = "externalFieldId")
public void setExternalFieldId(String externalFieldId) {
this.externalFieldId = externalFieldId;
}
public String getExternalFieldLabel() {
return externalFieldLabel;
}
@XmlElement(name = "externalFieldLabel")
public void setExternalFieldLabel(String externalFieldLabel) {
this.externalFieldLabel = externalFieldLabel;
}
public List<Dependency> getDependencies() {
return dependencies;
}
@XmlElementWrapper
@XmlElement(name = "dependency")
public void setDependencies(List<Dependency> dependencies) {
this.dependencies = dependencies;
}
public Boolean getRequired() {
return required;
}
@XmlElement(name = "required")
public void setRequired(Boolean required) {
this.required = required;
}
public String getQueryProperty() {
return queryProperty;
}
@XmlElement(name = "queryProperty")
public void setQueryProperty(String queryProperty) {
this.queryProperty = queryProperty;
}
}

View File

@ -21,6 +21,7 @@ public class BuilderFactoryImpl implements BuilderFactory {
if (tClass.equals(PrincipalBuilder.class)) return (T) new PrincipalBuilder();
if (tClass.equals(GrantBuilder.class)) return (T) new GrantBuilder();
if (tClass.equals(ProjectBuilder.class)) return (T) new ProjectBuilder();
if (tClass.equals(FunderBuilder.class)) return (T) new FunderBuilder();
if (tClass.equals(RegistryCriteriaBuilder.class)) return (T) new RegistryCriteriaBuilder();
if (tClass.equals(UserInfoBuilder.class)) return (T) new UserInfoBuilder();
if (tClass.equals(UserRoleBuilder.class)) return (T) new UserRoleBuilder();

View File

@ -0,0 +1,73 @@
package eu.eudat.logic.builders.model.models;
import eu.eudat.logic.builders.Builder;
import eu.eudat.models.data.funder.Funder;
import java.util.Date;
import java.util.UUID;
public class FunderBuilder extends Builder<Funder> {
private UUID id;
private String label;
private String reference;
private String definition;
private eu.eudat.data.entities.Funder.Status status;
private Date created;
private Date modified;
private Integer type;
public FunderBuilder id(UUID id) {
this.id = id;
return this;
}
public FunderBuilder label(String label) {
this.label = label;
return this;
}
public FunderBuilder reference(String reference) {
this.reference = reference;
return this;
}
public FunderBuilder definition(String definition) {
this.definition = definition;
return this;
}
public FunderBuilder status(eu.eudat.data.entities.Funder.Status status) {
this.status = status;
return this;
}
public FunderBuilder created(Date created) {
this.created = created;
return this;
}
public FunderBuilder modified(Date modified) {
this.modified = modified;
return this;
}
public FunderBuilder type(int type) {
this.type = type;
return this;
}
@Override
public Funder build() {
Funder funder = new Funder();
funder.setId(id);
funder.setLabel(label);
funder.setReference(reference);
funder.setDefinition(definition);
if (status != null) funder.setStatus(status.getValue());
funder.setCreated(created);
funder.setModified(modified);
funder.setType(type);
return funder;
}
}

View File

@ -1,14 +1,14 @@
package eu.eudat.logic.managers;
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
import eu.eudat.logic.builders.model.models.FunderBuilder;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.external.ExternalSourcesItemModel;
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
import eu.eudat.models.data.external.FundersExternalSourcesModel;
import eu.eudat.models.data.funder.Funder;
import eu.eudat.models.data.project.Project;
import eu.eudat.models.data.security.Principal;
import eu.eudat.queryable.QueryableList;
import org.springframework.stereotype.Component;
@ -29,25 +29,22 @@ public class FunderManager {
}
public List<Funder> getCriteriaWithExternal(FunderCriteriaRequest funderCriteria, Principal principal) throws HugeResultSet, NoURLFound {
// eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
// userInfo.setId(principal.getId());
// QueryableList<Funder> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(projectCriteria.getCriteria());
// QueryableList<eu.eudat.data.entities.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
// List<Project> projects = authItems.select(item -> new eu.eudat.models.data.project.Project().fromDataModel(item));
// List<Map<String, String>> remoteRepos = remoteFetcher.getProjects(projectCriteria.getCriteria().getLike());
// ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
// for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
// eu.eudat.models.data.project.Project project = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ProjectBuilder.class)
// .reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
// .description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
// .abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.entities.Project.Status.fromInteger(0))
// .build();
//
// projects.add(project);
// }
// projects.sort(Comparator.comparing(x -> x.getLabel()));
// return projects;
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
userInfo.setId(principal.getId());
QueryableList<eu.eudat.data.entities.Funder> items = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(funderCriteria.getCriteria());
//QueryableList<eu.eudat.data.entities.Funder> authItems = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getAuthenticated(items, userInfo);
List<Funder> funders = items.select(item -> new eu.eudat.models.data.funder.Funder().fromDataModel(item));
List<Map<String, String>> remoteRepos = remoteFetcher.getFunders(funderCriteria.getCriteria().getLike());
FundersExternalSourcesModel fundersExternalSourcesModel = new FundersExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : fundersExternalSourcesModel) {
eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
.status(eu.eudat.data.entities.Funder.Status.fromInteger(0))
.build();
return null;
funders.add(funder);
}
funders.sort(Comparator.comparing(x -> x.getLabel()));
return funders;
}
}

View File

@ -23,6 +23,7 @@ public class ExternalUrls implements Serializable {
OrganisationUrls organisations;
DatasetUrls datasets;
TagUrls tags;
FunderUrls funders;
public RegistryUrls getRegistries() {
@ -105,6 +106,15 @@ public class ExternalUrls implements Serializable {
}
public FunderUrls getFunders() {
return funders;
}
public void setFunders(FunderUrls funders) {
this.funders = funders;
}
public Long getMaxresults() {
return maxresults;
}

View File

@ -0,0 +1,33 @@
package eu.eudat.logic.proxy.config.entities;
import eu.eudat.logic.proxy.config.FetchStrategy;
import eu.eudat.logic.proxy.config.UrlConfiguration;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class FunderUrls {
List<UrlConfiguration> urls;
FetchStrategy fetchMode;
public List<UrlConfiguration> getUrls() {
return urls;
}
@XmlElementWrapper
@XmlElement(name = "urlConfig")
public void setUrls(List<UrlConfiguration> urls) {
this.urls = urls;
}
public FetchStrategy getFetchMode() {
return fetchMode;
}
@XmlElement(name = "fetchMode")
public void setFetchMode(FetchStrategy fetchMode) {
this.fetchMode = fetchMode;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.logic.proxy.fetching;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import eu.eudat.configurations.dynamicfunder.DynamicFunderConfiguration;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
import eu.eudat.logic.proxy.config.DataUrlConfiguration;
@ -28,12 +29,14 @@ public class RemoteFetcher {
private DynamicGrantConfiguration dynamicGrantConfiguration;
private DynamicProjectConfiguration dynamicProjectConfiguration;
private DynamicFunderConfiguration dynamicFunderConfiguration;
@Autowired
public RemoteFetcher(ConfigLoader configLoader, DynamicGrantConfiguration dynamicGrantConfiguration, DynamicProjectConfiguration dynamicProjectConfiguration) {
public RemoteFetcher(ConfigLoader configLoader, DynamicGrantConfiguration dynamicGrantConfiguration, DynamicProjectConfiguration dynamicProjectConfiguration, DynamicFunderConfiguration dynamicFunderConfiguration) {
this.configLoader = configLoader;
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
this.dynamicFunderConfiguration = dynamicFunderConfiguration;
}
@Cacheable("repositories")
@ -59,6 +62,13 @@ public class RemoteFetcher {
return getAll(urlConfigs, fetchStrategy, query);
}
@Cacheable("funders")
public List<Map<String, String>> getFunders(String query) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs = Arrays.asList(this.dynamicFunderConfiguration.getConfiguration().getMainExternalField().getUrlConfig());
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getProjects().getFetchMode();
return getAll(urlConfigs, fetchStrategy, query);
}
@Cacheable("organisations")
public List<Map<String, String>> getOrganisations(String query, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =

View File

@ -50,5 +50,7 @@ public interface DatabaseRepository {
ProjectDao getProjectDao();
FunderDao getFunderDao();
<T> void detachEntity(T entity);
}

View File

@ -34,6 +34,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private DatasetServiceDao datasetServiceDao;
private LoginConfirmationEmailDao loginConfirmationEmailDao;
private ProjectDao projectDao;
private FunderDao funderDao;
private EntityManager entityManager;
@ -262,6 +263,16 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
this.projectDao = projectDao;
}
@Override
public FunderDao getFunderDao() {
return funderDao;
}
@Autowired
public void setFunderDao(FunderDao funderDao) {
this.funderDao = funderDao;
}
public <T> void detachEntity(T entity) {
this.entityManager.detach(entity);
}

View File

@ -0,0 +1,20 @@
package eu.eudat.models.data.external;
import java.util.List;
import java.util.Map;
public class FundersExternalSourcesModel extends ExternalListingItem<FundersExternalSourcesModel> {
@Override
public FundersExternalSourcesModel fromExternalItem(List<Map<String, String>> values) {
for (Map<String, String> item : values) {
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
model.setRemoteId(item.get("pid"));
model.setUri(item.get("uri"));
model.setName(item.get("name"));
model.setDescription(item.get("description"));
this.add(model);
}
return this;
}
}

View File

@ -0,0 +1,98 @@
<configuration>
<configurationProperties>
<property>
<id>field1</id>
<name>DMP-EDITOR.FIELDS.PROJECT</name>
<sourceUrl>http://localhost:9091/api/project/</sourceUrl>
<queryProperty>search</queryProperty>
<externalFieldId>id</externalFieldId>
<externalFieldLabel>name</externalFieldLabel>
<dependencies>
<dependency>
<id>field2</id>
<queryProperty>funder</queryProperty>
</dependency>
</dependencies>
<required>false</required>
</property>
<property>
<id>field2</id>
<name>DMP-EDITOR.FIELDS.FUNDER</name>
<sourceUrl>http://localhost:9091/api/funder/</sourceUrl>
<queryProperty>search</queryProperty>
<externalFieldId>id</externalFieldId>
<externalFieldLabel>name</externalFieldLabel>
<dependencies>
</dependencies>
<required>false</required>
</property>
<property>
<id>field3</id>
<name>DMP-EDITOR.FIELDS.GRANT</name>
<sourceUrl>http://localhost:9091/api/grant/</sourceUrl>
<queryProperty>search</queryProperty>
<externalFieldId>id</externalFieldId>
<externalFieldLabel>name</externalFieldLabel>
<dependencies>
</dependencies>
<required>false</required>
</property>
</configurationProperties>
<mainExternalField>
<id>field3</id>
<name>project.configuration.grant.name</name>
<urlConfig>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/projectrepo/</url>
<data>
<path>$['data'][*]['attributes']</path>
<fields>
<id>'pid'</id>
<name>'name'</name>
<uri>'uri'</uri>
<description>'description'</description>
</fields>
</data>
<paginationpath>$['meta']['pagination']['page','pages','count']</paginationpath>
</urlConfig>
<externalFieldId>pid</externalFieldId>
<externalFieldLabel>name</externalFieldLabel>
<language>
<languageProperty>
<key>navbar</key>
<languageKey>NAV-BAR.PROJECTS</languageKey>
</languageProperty>
<languageProperty>
<key>listingTitle</key>
<languageKey>PROJECT-LISTING.TITLE</languageKey>
</languageProperty>
<languageProperty>
<key>editorTitle</key>
<languageKey>PROJECT-EDITOR.TITLE.NEW</languageKey>
</languageProperty>
<languageProperty>
<key>editorLogo</key>
<languageKey>PROJECT-EDITOR.FIELDS.LOGO</languageKey>
</languageProperty>
<languageProperty>
<key>dmpEditor</key>
<languageKey>DMP-EDITOR.FIELDS.PROJECT</languageKey>
</languageProperty>
<languageProperty>
<key>criteriaStart</key>
<languageKey>CRITERIA.PROJECTS.PERIOD-FROM</languageKey>
</languageProperty>
<languageProperty>
<key>criteriaEnd</key>
<languageKey>CRITERIA.PROJECTS.PERIOD-TO</languageKey>
</languageProperty>
<languageProperty>
<key>dmpCriteria</key>
<languageKey>CRITERIA.DMP.PROJECTS</languageKey>
</languageProperty>
</language>
<dependencies>
</dependencies>
<required></required>
</mainExternalField>
</configuration>