no message

This commit is contained in:
Ioannis Kalyvas 2018-06-29 11:29:43 +03:00
parent 8eb3632fd2
commit efb7af10b5
23 changed files with 398 additions and 154 deletions

View File

@ -1,6 +1,6 @@
package eu.eudat.configurations.dynamicproject.entities;
import eu.eudat.logic.proxy.config.UrlConfig;
import eu.eudat.logic.proxy.config.UrlConfiguration;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
@ -14,7 +14,7 @@ public class MainProperty {
private String name;
private String queryProperty;
private String externalFieldId;
private UrlConfig urlConfig;
private UrlConfiguration urlConfig;
private String externalFieldLabel;
private List<Dependency> dependencies;
private Boolean required;
@ -85,12 +85,12 @@ public class MainProperty {
this.queryProperty = queryProperty;
}
public UrlConfig getUrlConfig() {
public UrlConfiguration getUrlConfig() {
return urlConfig;
}
@XmlElement(name = "urlConfig")
public void setUrlConfig(UrlConfig urlConfig) {
public void setUrlConfig(UrlConfiguration urlConfig) {
this.urlConfig = urlConfig;
}

View File

@ -1,9 +1,9 @@
package eu.eudat.controllers;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@ -27,10 +28,10 @@ public class DataRepositories extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/external/datarepos"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Map<String, String>>>> listExternalDataRepositories(
@RequestParam(value = "query", required = false) String query,@RequestParam(value = "type", required = false) String type
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
) {
try {
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getRepositories(query,type);
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getRepositories(query, type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(remoteRepos));
} catch (NoURLFound ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()).payload(null));

View File

@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@ -27,21 +28,20 @@ public class Registries extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/external/registries"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<RegistriesExternalSourcesModel>> listExternalRegistries(@RequestParam(value = "query", required = false) String query
ResponseEntity<ResponseItem<List<Map<String, String>>>> listExternalRegistries(@RequestParam(value = "query", required = false) String query
,@RequestParam(value = "type", required = false) String type) {
try {
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getRegistries(query,type);
RegistriesExternalSourcesModel registriesExternalSourcesModel = new RegistriesExternalSourcesModel().fromExternalItem(remoteRepos);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<RegistriesExternalSourcesModel>().payload(registriesExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Map<String, String>>>().payload(remoteRepos).status(ApiMessageCode.NO_MESSAGE));
} catch (NoURLFound ex) {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<RegistriesExternalSourcesModel>().status(ApiMessageCode.ERROR_MESSAGE).message("External Url Not Found"));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message("External Url Not Found"));
} catch (HugeResultSet ex) {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<RegistriesExternalSourcesModel>().status(ApiMessageCode.ERROR_MESSAGE).message("Huge Result Set"));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message("Huge Result Set"));
} catch (Exception ex) {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<RegistriesExternalSourcesModel>().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
}
}

View File

@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@ -27,19 +28,18 @@ public class Services extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/external/services"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<ServiceExternalSourcesModel>> listExternalServices(
ResponseEntity<ResponseItem<List<Map<String, String>>>> listExternalServices(
@RequestParam(value = "query", required = false) String query,@RequestParam(value = "type", required = false) String type
) {
try {
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getServices(query,type);
ServiceExternalSourcesModel serviceExternalSourcesModel = new ServiceExternalSourcesModel().fromExternalItem(remoteRepos);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ServiceExternalSourcesModel>().payload(serviceExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Map<String, String>>>().payload(remoteRepos).status(ApiMessageCode.NO_MESSAGE));
} catch (NoURLFound ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ServiceExternalSourcesModel>().status(ApiMessageCode.ERROR_MESSAGE).message("External Url Not Found"));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message("External Url Not Found"));
} catch (HugeResultSet ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ServiceExternalSourcesModel>().status(ApiMessageCode.ERROR_MESSAGE).message("Huge Result Set"));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message("Huge Result Set"));
} catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ServiceExternalSourcesModel>().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
}
}

View File

@ -0,0 +1,50 @@
package eu.eudat.logic.proxy.config;
import javax.xml.bind.annotation.XmlElement;
/**
* Created by ikalyvas on 6/29/2018.
*/
public class DataFieldsUrlConfiguration {
private String id;
private String name;
private String uri;
private String description;
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 getUri() {
return uri;
}
@XmlElement(name = "uri")
public void setUri(String uri) {
this.uri = uri;
}
public String getDescription() {
return description;
}
@XmlElement(name = "description")
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -0,0 +1,29 @@
package eu.eudat.logic.proxy.config;
import javax.xml.bind.annotation.XmlElement;
/**
* Created by ikalyvas on 6/29/2018.
*/
public class DataUrlConfiguration {
private String path;
private DataFieldsUrlConfiguration fieldsUrlConfiguration;
public String getPath() {
return path;
}
@XmlElement(name = "path")
public void setPath(String path) {
this.path = path;
}
public DataFieldsUrlConfiguration getFieldsUrlConfiguration() {
return fieldsUrlConfiguration;
}
@XmlElement(name = "fields")
public void setFieldsUrlConfiguration(DataFieldsUrlConfiguration fieldsUrlConfiguration) {
this.fieldsUrlConfiguration = fieldsUrlConfiguration;
}
}

View File

@ -3,13 +3,13 @@ package eu.eudat.logic.proxy.config;
import javax.xml.bind.annotation.XmlElement;
public class UrlConfig {
public class UrlConfiguration {
private String key;
private String label;
private Integer ordinal;
private String url;
private String dataPath;
private DataUrlConfiguration data;
private String paginationPath;
public String getKey() {
@ -48,13 +48,13 @@ public class UrlConfig {
this.ordinal = ordinal;
}
public String getDataPath() {
return dataPath;
public DataUrlConfiguration getData() {
return data;
}
@XmlElement(name = "datapath")
public void setDataPath(String dataPath) {
this.dataPath = dataPath;
@XmlElement(name = "data")
public void setData(DataUrlConfiguration data) {
this.data = data;
}
public String getPaginationPath() {
@ -66,5 +66,4 @@ public class UrlConfig {
this.paginationPath = paginationPath;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,8 +3,9 @@ package eu.eudat.logic.proxy.fetching;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
import eu.eudat.logic.proxy.config.DataUrlConfiguration;
import eu.eudat.logic.proxy.config.FetchStrategy;
import eu.eudat.logic.proxy.config.UrlConfig;
import eu.eudat.logic.proxy.config.UrlConfiguration;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
@ -34,8 +35,8 @@ public class RemoteFetcher {
@Cacheable("repositories")
public List<Map<String, String>> getRepositories(String query, String key) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs =
key != null ? configLoader.getExternalUrls().getRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getRepositories().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getRepositories().getFetchMode();
return getAll(urlConfigs, fetchStrategy, query);
@ -43,15 +44,15 @@ public class RemoteFetcher {
@Cacheable("projects")
public List<Map<String, String>> getProjects(String query) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs = Arrays.asList(this.dynamicProjectConfiguration.getConfiguration().getMainExternalField().getUrlConfig());
List<UrlConfiguration> urlConfigs = Arrays.asList(this.dynamicProjectConfiguration.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<UrlConfig> urlConfigs =
key != null ? configLoader.getExternalUrls().getOrganisations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getOrganisations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getOrganisations().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getOrganisations().getFetchMode();
return getAll(urlConfigs, fetchStrategy, query);
@ -59,64 +60,67 @@ public class RemoteFetcher {
@Cacheable("registries")
public List<Map<String, String>> getRegistries(String query, String key) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs =
key != null ? configLoader.getExternalUrls().getRegistries().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRegistries().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getRegistries().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getRegistries().getFetchMode();
return getAll(urlConfigs, fetchStrategy, query);
}
@Cacheable("services")
public List<Map<String, String>> getServices(String query,String key) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs =
key != null ? configLoader.getExternalUrls().getServices().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
public List<Map<String, String>> getServices(String query, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getServices().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getServices().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getServices().getFetchMode();
return getAll(urlConfigs, fetchStrategy, query);
}
@Cacheable("researchers")
public List<Map<String, String>> getResearchers(String query,String key) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs =
key != null ? configLoader.getExternalUrls().getResearchers().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
public List<Map<String, String>> getResearchers(String query, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getResearchers().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getResearchers().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getResearchers().getFetchMode();
return getAll(urlConfigs, fetchStrategy, query);
}
@Cacheable("datasets")
public List<Map<String, String>> getDatasets(String query,String key) throws NoURLFound, HugeResultSet {
List<UrlConfig> urlConfigs =
key != null ? configLoader.getExternalUrls().getDatasets().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
public List<Map<String, String>> getDatasets(String query, String key) throws NoURLFound, HugeResultSet {
List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getDatasets().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
: configLoader.getExternalUrls().getDatasets().getUrls();
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getDatasets().getFetchMode();
return getAll(urlConfigs, fetchStrategy, query);
}
private List<Map<String, String>> getAll(List<UrlConfig> urlConfigs, FetchStrategy fetchStrategy, String query) throws NoURLFound, HugeResultSet {
private List<Map<String, String>> getAll(List<UrlConfiguration> urlConfigs, FetchStrategy fetchStrategy, String query) throws NoURLFound, HugeResultSet {
if (urlConfigs == null || urlConfigs.isEmpty())
throw new NoURLFound("No Repository urls found in configuration");
Collections.sort(urlConfigs, Comparator.comparing(UrlConfig::getOrdinal));
return getAllResultsFromUrl(urlConfigs.get(0).getUrl(), fetchStrategy, urlConfigs.get(0).getDataPath(), urlConfigs.get(0).getPaginationPath(), query);
Collections.sort(urlConfigs, Comparator.comparing(UrlConfiguration::getOrdinal));
List<Map<String, String>> results = new LinkedList<>();
for (UrlConfiguration urlConfig : urlConfigs) {
results.addAll(getAllResultsFromUrl(urlConfig.getUrl(), fetchStrategy, urlConfig.getData(), urlConfig.getPaginationPath(), query, urlConfig.getLabel()));
}
return results;
}
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final String jsonDataPath, final String jsonPaginationPath, String query) throws HugeResultSet {
private List<Map<String, String>> getAllResultsFromUrl(String path, FetchStrategy fetchStrategy, final DataUrlConfiguration jsonDataPath, final String jsonPaginationPath, String query, String key) throws HugeResultSet {
Set<Integer> pages = new HashSet<Integer>();
final String searchQuery = (query != null) && !query.isEmpty() ? "&search=" + query : "";
//first call
Results results = getResultsFromUrl(path + "?page=1" + searchQuery, jsonDataPath, jsonPaginationPath);
//if fetch strategy is to get only first page, then return that
if (fetchStrategy == FetchStrategy.FIRST)
return results == null ? new LinkedList<>() : results.getResults();
return results == null ? new LinkedList<>() : results.getResults().stream().map(x -> {
x.put("tag", key);
return x;
}).collect(Collectors.toList());
if (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++)
@ -126,7 +130,6 @@ public class RemoteFetcher {
if ((maxResults > 0) && (results.getPagination().get("count") > maxResults))
throw new HugeResultSet("The submitted search query " + query + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
//remaining calls (if pages array has elements)
Optional<Results> optionalResults = pages.parallelStream()
.map(page -> getResultsFromUrl(path + "?page=" + page + searchQuery, jsonDataPath, jsonPaginationPath))
.reduce((result1, result2) -> {
@ -137,11 +140,14 @@ public class RemoteFetcher {
remainingResults.getResults().addAll(results.getResults());
return remainingResults.getResults();
return remainingResults.getResults().stream().map(x -> {
x.put("tag", key);
return x;
}).collect(Collectors.toList());
}
private Results getResultsFromUrl(String urlString, String jsonDataPath, String jsonPaginationPath) {
private Results getResultsFromUrl(String urlString, DataUrlConfiguration jsonDataPath, String jsonPaginationPath) {
try {
@ -155,12 +161,22 @@ public class RemoteFetcher {
if (responseCode == HttpURLConnection.HTTP_OK) { // success
//do here all the parsing
DocumentContext jsonContext = JsonPath.parse(con.getInputStream());
Results results = new Results(jsonContext.read(jsonDataPath), jsonContext.read(jsonPaginationPath));
Results results = new Results(jsonContext.read(jsonDataPath.getPath()
+ "[" + jsonDataPath.getFieldsUrlConfiguration().getName() + "," + jsonDataPath.getFieldsUrlConfiguration().getDescription()
+ "," + jsonDataPath.getFieldsUrlConfiguration().getUri() + "," + jsonDataPath.getFieldsUrlConfiguration().getId() + "]"),
jsonContext.read(jsonPaginationPath));
results.results = results.results.stream().map(e -> e.entrySet().stream().collect(Collectors.toMap(x -> this.transformKey(jsonDataPath,x.getKey()), Map.Entry::getValue)))
.collect(Collectors.toList());
return results;
}
} catch (MalformedURLException e1) {
e1.printStackTrace();
} //maybe print smth...
catch (IOException e2) {
e2.printStackTrace();
} //maybe print smth...
catch (Exception exception) {
exception.printStackTrace();
} //maybe print smth...
finally {
}
@ -169,6 +185,14 @@ public class RemoteFetcher {
}
private String transformKey(DataUrlConfiguration dataUrlConfiguration, String key) {
if (key.equals(dataUrlConfiguration.getFieldsUrlConfiguration().getId().replace("'",""))) return "pid";
if (key.equals(dataUrlConfiguration.getFieldsUrlConfiguration().getDescription().replace("'",""))) return "description";
if (key.equals(dataUrlConfiguration.getFieldsUrlConfiguration().getUri().replace("'",""))) return "uri";
if (key.equals(dataUrlConfiguration.getFieldsUrlConfiguration().getName().replace("'",""))) return "name";
return null;
}
class Results {

View File

@ -11,7 +11,15 @@
<label>Cristin</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/metadataschemarepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
<urlConfig>
@ -19,7 +27,15 @@
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/metadataschemarepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
@ -37,7 +53,15 @@
<label>Cristin</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/projectrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
<urlConfig>
@ -45,7 +69,15 @@
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/projectrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
@ -63,7 +95,15 @@
<label>Cristin</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/datarepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
<urlConfig>
@ -71,7 +111,15 @@
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/datarepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
</urls>
@ -88,7 +136,15 @@
<label>Cristin</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/servicerepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
<urlConfig>
@ -96,7 +152,15 @@
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/servicerepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
</urls>
@ -112,7 +176,15 @@
<label>Cristin</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/personrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
<urlConfig>
@ -120,7 +192,15 @@
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/personrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
</urls>
@ -136,7 +216,15 @@
<label>Cristin</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/organizationrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
<urlConfig>
@ -144,7 +232,15 @@
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/organizationrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
</urls>
@ -160,7 +256,15 @@
<label>Cristin</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/datasetrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
<urlConfig>
@ -168,7 +272,15 @@
<label>OpenAIRE</label>
<ordinal>1</ordinal>
<url>https://eestore.paas2.uninett.no/api/datasetrepo/</url>
<datapath>$['data'][*]['attributes']['pid','name','uri','description']</datapath>
<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>
</urls>

View File

@ -1,4 +1,4 @@
<app-navigation></app-navigation>
<app-navigation [(sidenavOpen)]="sideNavOpen"></app-navigation>
<div class="container-fluid">
<div class="row">

View File

@ -1,2 +1,6 @@
body {
}
.example-container {
width: 400px;
height: 200px;
margin: 10px;
border: 1px solid #555;
}

View File

@ -19,6 +19,8 @@ declare var $: any;
export class AppComponent implements OnInit {
hasBreadCrumb = Observable.of(false);
sideNavOpen = false;
constructor(
private router: Router,
private route: ActivatedRoute,
@ -30,7 +32,6 @@ export class AppComponent implements OnInit {
translate.setDefaultLang('en');
// the lang to use, if the lang isn't available, it will use the current loader to get them
translate.use('en');
}
onActivate(event: any) {

View File

@ -45,10 +45,10 @@ export class DatasetWizardComponent implements OnInit, IBreadCrumbComponent {
@ViewChild('stepper') stepper: MatStepper;
//autocomplete Display Functions;
externalDatasetDisplayFunc = (item) => item ? item.label : null;
registriesDisplayFunc = (item) => item ? item.label : null;
dataRepositoryDisplayFunc = (item) => item ? item.name : null;
servicesDisplayFunc = (item) => item ? item.label : null;
externalDatasetDisplayFunc = (item) => item ? item.label + " (" + item.tag + ")" : null;
registriesDisplayFunc = (item) => item ? item.label + " (" + item.tag + ")" : null;
dataRepositoryDisplayFunc = (item) => item ? (item.name + " (" + item.tag + ")") : null;
servicesDisplayFunc = (item) => item ? item.label + " (" + item.tag + ")" : null;
//autocomplete Configurations;
externalDatasetAutoCompleteConfiguration: AutoCompleteConfiguration;
@ -105,6 +105,10 @@ export class DatasetWizardComponent implements OnInit, IBreadCrumbComponent {
this.externalSourcesConfigurationService.getExternalSourcesConfiguration().subscribe(result => {
this.externalSourcesConfiguration = result;
this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: "All" })
this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: "All" })
this.externalSourcesConfiguration.registries.push({ key: '', label: "All" })
this.externalSourcesConfiguration.services.push({ key: '', label: "All" })
})
let dmpAutoCompleteConfiguration = {}
this.route.params.subscribe((params: Params) => {

View File

@ -6,25 +6,25 @@ import { JsonSerializer } from '../utilities/JsonSerializer';
import { FormBuilder, FormGroup } from '@angular/forms';
export class Page extends BaseModel implements Serializable<Page> {
public ordinal: number;
public title: string;
public sections: Array<Section>;
public ordinal: number;
public title: string;
public sections: Array<Section>;
fromJSONObject(item: any): Page {
this.ordinal = item.ordinal;
this.title = item.title;
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
return this;
}
fromJSONObject(item: any): Page {
this.ordinal = item.ordinal;
this.title = item.title;
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
return this;
}
buildForm(): FormGroup {
let formGroup: FormGroup = new FormBuilder().group({});
let sectionsFormArray = new Array<FormGroup>();
this.sections.forEach(item => {
let form: FormGroup = item.buildForm();
sectionsFormArray.push(form)
})
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
return formGroup;
}
}
buildForm(): FormGroup {
let formGroup: FormGroup = new FormBuilder().group({});
let sectionsFormArray = new Array<FormGroup>();
this.sections.forEach(item => {
let form: FormGroup = item.buildForm();
sectionsFormArray.push(form)
})
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
return formGroup;
}
}

View File

@ -1,28 +1,33 @@
<mat-toolbar color="primary">
<a [fxLayoutAlign]="'center'" class="app-logo" routerLink="/">
<img [src]="'/assets/images/openDmps.png'" alt="openDMPS">
</a>
<div *ngIf="isAuthenticated()">
<button mat-button class="navbar-button" routerLink="/projects">{{this.languageResolver.getBy('navbar') | translate}}</button>
<button mat-button class="navbar-button" routerLink="/dmps">{{'NAV-BAR.DMPS' | translate}}</button>
<button mat-button class="navbar-button" routerLink="/datasets">{{'NAV-BAR.DATASETS' | translate}}</button>
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/users">{{'NAV-BAR.USERS' | translate}}</button>
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/dmp-profiles">{{'NAV-BAR.DMP-PROFILES' | translate}}</button>
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/datasetsProfiles">{{'NAV-BAR.DATASETS-ADMIN' | translate}}</button>
</div>
<!--<button mat-button class="navbar-button" routerLink="/about">{{'NAV-BAR.ABOUT' | translate}}</button>-->
<a [fxLayoutAlign]="'center'" class="app-logo" routerLink="/">
<img [src]="'/assets/images/openDmps.png'" alt="openDMPS">
</a>
<div *ngIf="isAuthenticated()">
<button mat-button class="navbar-button" routerLink="/projects">{{this.languageResolver.getBy('navbar') | translate}}</button>
<button mat-button class="navbar-button" routerLink="/dmps">{{'NAV-BAR.DMPS' | translate}}</button>
<button mat-button class="navbar-button" routerLink="/datasets">{{'NAV-BAR.DATASETS' | translate}}</button>
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/users">{{'NAV-BAR.USERS' | translate}}</button>
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/dmp-profiles">{{'NAV-BAR.DMP-PROFILES' | translate}}</button>
<button *ngIf="isAdmin()" mat-button class="navbar-button" routerLink="/datasetsProfiles">{{'NAV-BAR.DATASETS-ADMIN' | translate}}</button>
</div>
<!--<button mat-button class="navbar-button" routerLink="/about">{{'NAV-BAR.ABOUT' | translate}}</button>-->
<span class="navbar-spacer"></span>
<div *ngIf="isAuthenticated();else loginoption">
<img mat-card-avatar *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()">
<span class="user-label">{{this.getPrincipalName()}}</span>
<button mat-icon-button class="navbar-icon" (click)="logout()">
<mat-icon class="navbar-icon">exit_to_app</mat-icon>
</button>
</div>
<ng-template #loginoption>
<button mat-button [routerLink]=" ['/login'] ">
<span class="login-label">Log in</span>
</button>
</ng-template>
</mat-toolbar>
<span class="navbar-spacer"></span>
<div *ngIf="isAuthenticated();else loginoption">
<img mat-card-avatar *ngIf="this.principalHasAvatar()" [src]="this.getPrincipalAvatar()">
<span class="user-label">{{this.getPrincipalName()}}</span>
<button mat-icon-button (click)="onSideNavClick()">
<mat-icon>speaker_notes</mat-icon>
</button>
<button mat-icon-button (click)="logout()">
<mat-icon>exit_to_app</mat-icon>
</button>
</div>
<ng-template #loginoption>
<button mat-button [routerLink]=" ['/login'] ">
<span class="login-label">Log in</span>
</button>
</ng-template>
</mat-toolbar>

View File

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { sample } from 'rxjs/operators';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Principal } from '../../../models/login/Principal';
import { AuthService } from '../../../services/auth/auth.service';
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
@ -24,6 +25,15 @@ export class NavigationComponent {
return !(!this.authentication.current())
}
@Input()
sidenavOpen = false;
@Output()
sidenavOpenChanges = new EventEmitter();
events: string[] = [];
opened: boolean;
public isAdmin(): boolean {
if (!this.authentication.current()) { return false }
const principalRoles = this.authentication.current().appRoles;
@ -48,4 +58,9 @@ export class NavigationComponent {
public getPrincipalAvatar(): string {
return this.authentication.current().avatarUrl;
}
onSideNavClick() {
this.sidenavOpen = !this.sidenavOpen;
this.sidenavOpenChanges.emit(this.sidenavOpen);
}
}