remove of deprecated methods and repo profiles
This commit is contained in:
parent
98a33dd9d8
commit
cf612424c9
|
@ -3,8 +3,8 @@ package eu.dnetlib.openaire.common;
|
|||
public class ExporterConstants {
|
||||
|
||||
/*
|
||||
Tags used to group the operations on the swagger UI
|
||||
*/
|
||||
* Tags used to group the operations on the swagger UI
|
||||
*/
|
||||
public final static String C = "Community";
|
||||
public final static String C_CP = "Community content providers";
|
||||
public final static String C_PJ = "Community projects";
|
||||
|
@ -27,21 +27,4 @@ public class ExporterConstants {
|
|||
public static final String OAI = "oai";
|
||||
public static final String SET = "set";
|
||||
|
||||
// Paths used in the repository profile mapping: Datasource
|
||||
public static final String ADMIN_INFO = "//CONFIGURATION/ADMIN_INFO";
|
||||
public static final String ENGLISH_NAME = "//CONFIGURATION/ENGLISH_NAME";
|
||||
public static final String OFFICIAL_NAME = "//CONFIGURATION/OFFICIAL_NAME";
|
||||
public static final String TIMEZONE = "//CONFIGURATION/LOCATION/TIMEZONE";
|
||||
public static final String LATITUDE = "//CONFIGURATION/LOCATION/LATITUDE";
|
||||
public static final String LONGITUDE = "//CONFIGURATION/LOCATION/LONGITUDE";
|
||||
public static final String PLATFORM = "//CONFIGURATION/TYPOLOGY";
|
||||
public static final String TYPOLOGY = "//CONFIGURATION/DATASOURCE_TYPE";
|
||||
public static final String WEBSITE_URL = "//CONFIGURATION/REPOSITORY_WEBPAGE";
|
||||
|
||||
// Paths used in the repository profile mapping: Interface
|
||||
public static final String OAI_SET = "/ACCESS_PROTOCOL/@set";
|
||||
public static final String BASE_URL = "/BASE_URL";
|
||||
public static final String COMPLIANCE = "/@compliance";
|
||||
public static final String REMOVABLE = "/@removable";
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmForbiddenException;
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
|
||||
public interface ISClient {
|
||||
|
||||
|
@ -31,25 +28,16 @@ public interface ISClient {
|
|||
|
||||
void removeConcept(String id, String categoryId, String conceptId);
|
||||
|
||||
void updateDatasourceFields(String dsId, Map<String, String> changes);
|
||||
|
||||
void addAPIAttribute(String dsId, String apiId, Map<String, String> changes);
|
||||
|
||||
void updateAPIField(String dsId, String apiId, Map<String, String> changes);
|
||||
|
||||
void registerDS(DatasourceDetails d);
|
||||
|
||||
void registerAPI(ApiDetails api);
|
||||
|
||||
void removeAPI(String apiId) throws DsmForbiddenException;
|
||||
|
||||
void dropCache();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id id of the concept to be updated (i.e. ni::projects::2)
|
||||
* @param name name of the attribute to be updated
|
||||
* @param value new value for the attribute
|
||||
* @param id
|
||||
* id of the concept to be updated (i.e. ni::projects::2)
|
||||
* @param name
|
||||
* name of the attribute to be updated
|
||||
* @param value
|
||||
* new value for the attribute
|
||||
*/
|
||||
void updateConceptAttribute(String id, String name, String value);
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package eu.dnetlib.openaire.common;
|
||||
|
||||
import static eu.dnetlib.openaire.common.Utils.escape;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
@ -10,27 +12,10 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.escape.Escaper;
|
||||
import com.google.common.xml.XmlEscapers;
|
||||
import eu.dnetlib.OpenaireExporterConfig;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmForbiddenException;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmRuntimeException;
|
||||
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
||||
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
||||
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
|
||||
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.context.ContextMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
@ -38,9 +23,19 @@ import org.springframework.core.io.ClassPathResource;
|
|||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils.asRepositoryInterfce;
|
||||
import static eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils.asRepositoryProfile;
|
||||
import static eu.dnetlib.openaire.common.Utils.escape;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.escape.Escaper;
|
||||
import com.google.common.xml.XmlEscapers;
|
||||
|
||||
import eu.dnetlib.OpenaireExporterConfig;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmException;
|
||||
import eu.dnetlib.enabling.datasources.common.DsmRuntimeException;
|
||||
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
||||
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
||||
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
|
||||
import eu.dnetlib.openaire.context.Context;
|
||||
import eu.dnetlib.openaire.context.ContextMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
|
||||
/**
|
||||
* Created by claudio on 20/10/2016.
|
||||
|
@ -48,7 +43,7 @@ import static eu.dnetlib.openaire.common.Utils.escape;
|
|||
@Component
|
||||
public class ISClientImpl implements ISClient {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ISClientImpl.class);
|
||||
private static final Log log = LogFactory.getLog(ISClientImpl.class);
|
||||
|
||||
@Autowired
|
||||
private OpenaireExporterConfig config;
|
||||
|
@ -110,240 +105,138 @@ public class ISClientImpl implements ISClient {
|
|||
final String xqueryTemplate = _getQuery(config.getFindContextProfilesByType());
|
||||
|
||||
final String xquery = String.format(xqueryTemplate, type.stream()
|
||||
.map(t -> String.format("./RESOURCE_PROFILE/BODY/CONFIGURATION/context/@type = '%s'", t))
|
||||
.collect(Collectors.joining(" or ")));
|
||||
.map(t -> String.format("./RESOURCE_PROFILE/BODY/CONFIGURATION/context/@type = '%s'", t))
|
||||
.collect(Collectors.joining(" or ")));
|
||||
|
||||
return _processContext(xquery);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = { "context-cache", "context-cache-funder"}, allEntries = true)
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void updateContextParam(final String id, final String name, final String value) {
|
||||
try {
|
||||
_quickSeachProfile(getXQuery(id, name, value));
|
||||
} catch (ISLookUpException e) {
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable update context param [id: %s, name: %s, value: %s]", id, name, value), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = { "context-cache", "context-cache-funder"}, allEntries = true)
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void updateContextAttribute(final String id, final String name, final String value) {
|
||||
final Escaper esc = XmlEscapers.xmlAttributeEscaper();
|
||||
try {
|
||||
_quickSeachProfile(String.format(
|
||||
"update value collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/@%s with '%s'", id, name, escape(esc, value)));
|
||||
} catch (ISLookUpException e) {
|
||||
_quickSeachProfile(String.format("update value collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/@%s with '%s'", id, name, escape(esc, value)));
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable update context attribute [id: %s, name: %s, data: %s]", id, name, value), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = { "context-cache", "context-cache-funder"}, allEntries = true)
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void addConcept(final String id, final String categoryId, final String data) {
|
||||
try {
|
||||
_quickSeachProfile(String.format(
|
||||
"update insert %s into collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/category[./@id = '%s']", data, id, categoryId));
|
||||
} catch (ISLookUpException e) {
|
||||
_quickSeachProfile(String.format("update insert %s into collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/category[./@id = '%s']", data, id, categoryId));
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable add concept [id: %s, categoryId: %s, data: %s]", id, categoryId, data), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = { "context-cache", "context-cache-funder"}, allEntries = true)
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void removeConcept(final String id, final String categoryId, final String conceptId) {
|
||||
try {
|
||||
_quickSeachProfile(String.format(
|
||||
"for $concept in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']" +
|
||||
"/category[./@id = '%s']/concept[./@id = '%s'] " +
|
||||
"return update delete $concept", id, categoryId, conceptId));
|
||||
} catch (ISLookUpException e) {
|
||||
_quickSeachProfile(String.format("for $concept in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']" +
|
||||
"/category[./@id = '%s']/concept[./@id = '%s'] " +
|
||||
"return update delete $concept", id, categoryId, conceptId));
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable remove concept [id: %s, categoryId: %s, conceptId: %s]", id, categoryId, conceptId), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = { "context-cache", "context-cache-community", "context-cache-funder"}, allEntries = true)
|
||||
public void updateConceptAttribute(String id, String name, String value) {
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-community", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void updateConceptAttribute(final String id, final String name, final String value) {
|
||||
final Escaper esc = XmlEscapers.xmlAttributeEscaper();
|
||||
try {
|
||||
_quickSeachProfile(String.format(
|
||||
"update value collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context/category/concept[./@id = '%s']/@%s with '%s'", id, name, escape(esc, value)));
|
||||
} catch (ISLookUpException e) {
|
||||
_quickSeachProfile(String.format("update value collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context/category/concept[./@id = '%s']/@%s with '%s'", id, name, escape(esc, value)));
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable update concept attribute [id: %s, name: %s, value: %s]", id, name, value), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = { "context-cache", "context-cache-funder"}, allEntries = true)
|
||||
public void updateConceptParam(String id, String name, String value) {
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void updateConceptParam(final String id, final String name, final String value) {
|
||||
try {
|
||||
_quickSeachProfile(getConceptXQuery(id, name, value));
|
||||
} catch (ISLookUpException e) {
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable update concept param [id: %s, name: %s, value: %s]", id, name, value), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = { "context-cache", "context-cache-funder"}, allEntries = true)
|
||||
public void updateConceptParamNoEscape(String id, String name, String value) {
|
||||
@CacheEvict(value = {
|
||||
"context-cache", "context-cache-funder"
|
||||
}, allEntries = true)
|
||||
public void updateConceptParamNoEscape(final String id, final String name, final String value) {
|
||||
try {
|
||||
_quickSeachProfile(getConceptXQueryNoEscape(id, name, value));
|
||||
} catch (ISLookUpException e) {
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable update concept param [id: %s, name: %s, value: %s]", id, name, value), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDatasourceFields(final String dsId, final Map<String, String> changes) {
|
||||
operationManager.addOperation(() -> {
|
||||
Thread.currentThread().setName("update-ds:" + dsId);
|
||||
changes.forEach((xpath, value) -> {
|
||||
try {
|
||||
_isLookUp(String.format(
|
||||
"for $x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')\n" +
|
||||
"where $x/RESOURCE_PROFILE/BODY/CONFIGURATION/DATASOURCE_ORIGINAL_ID[@provenance='OPENAIRE']/text() = '%s' \n" +
|
||||
"return update value $x%s with '%s'", dsId, xpath, value));
|
||||
} catch (ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable update datasource fields [id: %s, changes: %s]", dsId, changes), e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAPIAttribute(final String dsId, final String apiId, final Map<String, String> changes) {
|
||||
operationManager.addOperation(() -> {
|
||||
Thread.currentThread().setName("update-api:" + dsId);
|
||||
changes.forEach((xpath, value) -> {
|
||||
try {
|
||||
final String attribute = StringUtils.substringAfter(xpath, "@");
|
||||
final String parentElement = StringUtils.substringBeforeLast(xpath, "/");
|
||||
_isLookUp(String.format(
|
||||
"let $x:=/RESOURCE_PROFILE/BODY/CONFIGURATION/DATASOURCE_ORIGINAL_ID[@provenance='OPENAIRE' and ./text() = '%s']\n" +
|
||||
"return update insert attribute %s {'%s'} into $x/..//INTERFACE[./@id = '%s']%s",
|
||||
dsId, attribute, value, apiId, parentElement));
|
||||
} catch (ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable add API attribute [dsId: %s, apiId: %s, changes: %s]", dsId, apiId, changes), e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAPIField(final String dsId, final String apiId, final Map<String, String> changes) {
|
||||
operationManager.addOperation(() -> {
|
||||
Thread.currentThread().setName("update-api:" + dsId);
|
||||
changes.forEach((xpath, value) -> {
|
||||
try {
|
||||
_isLookUp(String.format(
|
||||
"let $x:=/RESOURCE_PROFILE/BODY/CONFIGURATION/DATASOURCE_ORIGINAL_ID[@provenance='OPENAIRE' and ./text() = '%s']\n" +
|
||||
"return update value $x/..//INTERFACE[./@id = '%s']%s with '%s'",
|
||||
dsId, apiId, xpath, value));
|
||||
} catch (ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable update API fields [dsId: %s, apiId: %s, changes: %s]", dsId, apiId, changes), e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDS(final DatasourceDetails d) {
|
||||
operationManager.addOperation(() -> {
|
||||
Thread.currentThread().setName("save-ds:" + d.getId());
|
||||
try {
|
||||
final String id = isRegistryService.registerProfile(asRepositoryProfile(d));
|
||||
log.debug(String.format("registered DS profile %s", id));
|
||||
} catch (ISRegistryException e) {
|
||||
throw new DsmRuntimeException("unable to register DS profile: " + d.getId(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAPI(final ApiDetails api) {
|
||||
operationManager.addOperation(() -> {
|
||||
Thread.currentThread().setName("save-api:" + api.getId());
|
||||
try {
|
||||
final String dsId = api.getDatasource();
|
||||
final String iface = asRepositoryInterfce(api);
|
||||
_isLookUp(String.format(
|
||||
"let $x:=/RESOURCE_PROFILE/BODY/CONFIGURATION/DATASOURCE_ORIGINAL_ID[@provenance='OPENAIRE' and ./text() = '%s']\n" +
|
||||
"return update insert %s into $x/../INTERFACES", dsId, iface));
|
||||
|
||||
log.debug(String.format("registered API %s", api.getId()));
|
||||
} catch (ISLookUpException e) {
|
||||
throw new DsmRuntimeException("unable to register API: " + api.getId(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAPI(final String apiId) throws DsmForbiddenException {
|
||||
try {
|
||||
final List<String> metaWorkflows = _quickSeachProfile(String.format(
|
||||
"distinct-values(for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType')\n" +
|
||||
"where $x/RESOURCE_PROFILE/BODY/DATAPROVIDER[./@interface = '%s']\n" +
|
||||
"return $x/RESOURCE_PROFILE/BODY/DATAPROVIDER/@id/string())", apiId));
|
||||
if (!metaWorkflows.isEmpty()) {
|
||||
throw new DsmForbiddenException(
|
||||
HttpStatus.SC_FORBIDDEN,
|
||||
String.format("cannot remove api '%s', it has workflows associated", apiId));
|
||||
}
|
||||
isLookUpService.quickSearchProfile(String.format(
|
||||
" update delete /RESOURCE_PROFILE/BODY/CONFIGURATION/INTERFACES/INTERFACE[./@id = '%s']", apiId));
|
||||
|
||||
log.info(String.format("deleted API %s", apiId));
|
||||
} catch (ISLookUpException e) {
|
||||
throw new DsmRuntimeException(String.format("unable to remove API %s", apiId), e);
|
||||
}
|
||||
}
|
||||
|
||||
/// HELPERS
|
||||
|
||||
private String getXQuery(final String id, final String name, final String value) {
|
||||
final Escaper esc = XmlEscapers.xmlContentEscaper();
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
return String.format(
|
||||
"update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name,
|
||||
escape(esc, value));
|
||||
return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name, escape(esc, value));
|
||||
} else {
|
||||
return String.format(
|
||||
"update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')" +
|
||||
"/RESOURCE_PROFILE/BODY/CONFIGURATION/context[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
}
|
||||
}
|
||||
|
||||
private String getConceptXQuery(final String id, final String name, final String value) {
|
||||
final Escaper esc = XmlEscapers.xmlContentEscaper();
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
return String.format(
|
||||
"update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//" +
|
||||
"concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name,
|
||||
escape(esc, value));
|
||||
return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//" +
|
||||
"concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name, escape(esc, value));
|
||||
} else {
|
||||
return String.format(
|
||||
"update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
return String
|
||||
.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
}
|
||||
}
|
||||
|
||||
private String getConceptXQueryNoEscape(final String id, final String name, final String value) {
|
||||
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
return String.format(
|
||||
"update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//" +
|
||||
"concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name,
|
||||
value);
|
||||
return String.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//" +
|
||||
"concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'>%s</param>", id, name, name, value);
|
||||
} else {
|
||||
return String.format(
|
||||
"update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
return String
|
||||
.format("update replace collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//concept[./@id = '%s']/param[./@name = '%s'] with <param name='%s'/>", id, name, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,15 +247,12 @@ public class ISClientImpl implements ISClient {
|
|||
private Map<String, Context> _processContext(final Queue<Throwable> errors, final String xquery) throws IOException {
|
||||
try {
|
||||
return getContextProfiles(errors, xquery).stream()
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.map(s -> ContextMappingUtils.parseContext(s, errors))
|
||||
.collect(Collectors.toMap(
|
||||
Context::getId,
|
||||
Function.identity(),
|
||||
(c1, c2) -> {
|
||||
log.warn(String.format("found duplicate context profile '%s'", c1.getId()));
|
||||
return c1;
|
||||
}));
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.map(s -> ContextMappingUtils.parseContext(s, errors))
|
||||
.collect(Collectors.toMap(Context::getId, Function.identity(), (c1, c2) -> {
|
||||
log.warn(String.format("found duplicate context profile '%s'", c1.getId()));
|
||||
return c1;
|
||||
}));
|
||||
} finally {
|
||||
if (!errors.isEmpty()) {
|
||||
log.error(errors);
|
||||
|
@ -375,7 +265,7 @@ public class ISClientImpl implements ISClient {
|
|||
log.warn("getContextProfiles(): not using cache");
|
||||
try {
|
||||
return _quickSeachProfile(xquery);
|
||||
} catch (ISLookUpException e) {
|
||||
} catch (final ISLookUpException e) {
|
||||
throw new DsmRuntimeException("unable to get context profiles", e);
|
||||
}
|
||||
}
|
||||
|
@ -386,28 +276,29 @@ public class ISClientImpl implements ISClient {
|
|||
|
||||
private String _isLookUp(final String xquery) throws ISLookUpException {
|
||||
log.debug(String.format("running xquery:\n%s", xquery));
|
||||
//log.debug(String.format("query result: %s", res));
|
||||
// log.debug(String.format("query result: %s", res));
|
||||
return isLookUpService.getResourceProfileByQuery(xquery);
|
||||
}
|
||||
|
||||
private List<String> _quickSeachProfile(final String xquery) throws ISLookUpException {
|
||||
final List<String> res = Lists.newArrayList();
|
||||
|
||||
log.debug(String.format("running xquery:\n%s", xquery));
|
||||
final List<String> list = isLookUpService.quickSearchProfile(xquery);
|
||||
if (list != null) {
|
||||
res.addAll(list);
|
||||
}
|
||||
log.debug(String.format("query result size: %s", res.size()));
|
||||
return res;
|
||||
log.debug(String.format("running xquery:\n%s", xquery));
|
||||
final List<String> list = isLookUpService.quickSearchProfile(xquery);
|
||||
if (list != null) {
|
||||
res.addAll(list);
|
||||
}
|
||||
log.debug(String.format("query result size: %s", res.size()));
|
||||
return res;
|
||||
}
|
||||
|
||||
@CacheEvict(cacheNames = { "context-cache", "indexdsinfo-cache", "objectstoreid-cache" }, allEntries = true)
|
||||
@Override
|
||||
@CacheEvict(cacheNames = {
|
||||
"context-cache", "indexdsinfo-cache", "objectstoreid-cache"
|
||||
}, allEntries = true)
|
||||
@Scheduled(fixedDelayString = "${openaire.exporter.cache.ttl}")
|
||||
public void dropCache() {
|
||||
log.debug("dropped dsManager IS cache");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.dnetlib.openaire.dsm;
|
||||
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.API;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.D;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.DS;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.M;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.R;
|
||||
|
@ -11,8 +10,6 @@ import java.util.List;
|
|||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
import eu.dnetlib.openaire.dsm.domain.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
@ -31,13 +28,28 @@ import eu.dnetlib.enabling.datasources.common.DsmForbiddenException;
|
|||
import eu.dnetlib.enabling.datasources.common.DsmNotFoundException;
|
||||
import eu.dnetlib.openaire.common.AbstractExporterController;
|
||||
import eu.dnetlib.openaire.common.OperationManager;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestFilter;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSort;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.dsm.domain.Response;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
|
||||
import eu.dnetlib.openaire.vocabularies.Country;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = { "*" })
|
||||
@CrossOrigin(origins = {
|
||||
"*"
|
||||
})
|
||||
@ConditionalOnProperty(value = "openaire.exporter.enable.dsm", havingValue = "true")
|
||||
@io.swagger.annotations.Api(tags = "OpenAIRE DSM API", description = "the OpenAIRE Datasource Manager API")
|
||||
public class DsmApiController extends AbstractExporterController {
|
||||
|
@ -45,181 +57,220 @@ public class DsmApiController extends AbstractExporterController {
|
|||
@Autowired
|
||||
private DsmCore dsmCore;
|
||||
|
||||
@RequestMapping(value = "/ds/countries", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "list the datasource countries", notes = "list the datasource countries", tags = { DS, R }, response = Country[].class)
|
||||
@RequestMapping(value = "/ds/countries", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "list the datasource countries", notes = "list the datasource countries", tags = {
|
||||
DS, R
|
||||
}, response = Country[].class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = Country[].class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = Country[].class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public List<Country> listCountries() throws DsmException {
|
||||
return dsmCore.listCountries();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/search/{page}/{size}", produces = { "application/json" }, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search datasources", notes = "Returns list of Datasource details.", tags = { DS, R }, response = DatasourceSearchResponse.class)
|
||||
@RequestMapping(value = "/ds/searchdetails/{page}/{size}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search datasources", notes = "Returns list of Datasource details.", tags = {
|
||||
DS, R
|
||||
}, response = DatasourceDetailResponse.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSearchResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public DatasourceSearchResponse search(
|
||||
@RequestParam final RequestSort requestSortBy,
|
||||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSearchResponse rsp = dsmCore.search(requestSortBy, order, requestFilter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/searchdetails/{page}/{size}", produces = { "application/json" }, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search datasources", notes = "Returns list of Datasource details.", tags = { DS, R }, response = DatasourceDetailResponse.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceDetailResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceDetailResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public DatasourceDetailResponse searchDsDetails(
|
||||
@RequestParam final RequestSort requestSortBy,
|
||||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@RequestParam final RequestSort requestSortBy,
|
||||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceDetailResponse rsp = dsmCore.searchDsDetails(requestSortBy, order, requestFilter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/aggregationhistory/{dsId}", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "search datasources", notes = "Returns list of Datasource details.", tags = { DS, R }, response = AggregationHistoryResponse.class)
|
||||
@RequestMapping(value = "/ds/aggregationhistory/{dsId}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "search datasources", notes = "Returns list of Datasource details.", tags = {
|
||||
DS, R
|
||||
}, response = AggregationHistoryResponse.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = AggregationHistoryResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = AggregationHistoryResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public AggregationHistoryResponse aggregationHistory(@PathVariable final String dsId) throws DsmException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final AggregationHistoryResponse rsp = dsmCore.aggregationhistory(dsId);
|
||||
return prepareResponse(0, rsp.getAggregationInfo().size(), stop, rsp);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/searchsnippet/{page}/{size}", produces = { "application/json" }, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search datasources", notes = "Returns list of Datasource basic info.", tags = { DS, R }, response = DatasourceSnippetResponse.class)
|
||||
@RequestMapping(value = "/ds/searchsnippet/{page}/{size}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search datasources", notes = "Returns list of Datasource basic info.", tags = {
|
||||
DS, R
|
||||
}, response = DatasourceSnippetResponse.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSnippetResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSnippetResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public DatasourceSnippetResponse searchSnippet(
|
||||
@RequestParam final RequestSort requestSortBy,
|
||||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@RequestParam final RequestSort requestSortBy,
|
||||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSnippetResponse rsp = dsmCore.searchSnippet(requestSortBy, order, requestFilter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/searchregistered/{page}/{size}", produces = { "application/json" }, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search among registered datasources", notes = "Returns list of Datasource basic info.", tags = { DS,
|
||||
R }, response = DatasourceSnippetResponse.class)
|
||||
@RequestMapping(value = "/ds/searchregistered/{page}/{size}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search among registered datasources", notes = "Returns list of Datasource basic info.", tags = {
|
||||
DS,
|
||||
R
|
||||
}, response = DatasourceSnippetResponse.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSnippetResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSnippetResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public DatasourceSnippetResponse searchRegistered(
|
||||
@RequestParam final RequestSort requestSortBy,
|
||||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@RequestParam final RequestSort requestSortBy,
|
||||
@RequestParam final RequestSortOrder order,
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSnippetResponse rsp = dsmCore.searchRegistered(requestSortBy, order, requestFilter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/recentregistered/{size}", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "return the latest datasources that were registered through Provide", notes = "Returns list of Datasource basic info.", tags = { DS,
|
||||
R }, response = SimpleResponse.class)
|
||||
@RequestMapping(value = "/ds/recentregistered/{size}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "return the latest datasources that were registered through Provide", notes = "Returns list of Datasource basic info.", tags = {
|
||||
DS,
|
||||
R
|
||||
}, response = SimpleResponse.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public SimpleResponse recentRegistered(@PathVariable final int size) throws Throwable {
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final SimpleResponse rsp = dsmCore.searchRecentRegistered(size);
|
||||
return prepareResponse(1, size, stop, rsp);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/countregistered", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "return the number of datasources registered after the given date", notes = "Returns a number.", tags = { DS,
|
||||
R }, response = Long.class)
|
||||
@RequestMapping(value = "/ds/countregistered", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "return the number of datasources registered after the given date", notes = "Returns a number.", tags = {
|
||||
DS,
|
||||
R
|
||||
}, response = Long.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = Long.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = Long.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public Long countRegistered(@RequestParam final String fromDate,
|
||||
@RequestParam(required = false) final String typologyFilter) throws Throwable {
|
||||
@RequestParam(required = false) final String typologyFilter) throws Throwable {
|
||||
return dsmCore.countRegisteredAfter(fromDate, typologyFilter);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/api/{dsId}", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "get the list of API for a given datasource", notes = "Returns the list of API for a given datasource.", tags = { API,
|
||||
R }, response = ApiDetailsResponse.class)
|
||||
@RequestMapping(value = "/ds/api/{dsId}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.GET)
|
||||
@ApiOperation(value = "get the list of API for a given datasource", notes = "Returns the list of API for a given datasource.", tags = {
|
||||
API,
|
||||
R
|
||||
}, response = ApiDetailsResponse.class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = ApiDetailsResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = ApiDetailsResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public ApiDetailsResponse getApi(
|
||||
@PathVariable final String dsId) throws DsmException {
|
||||
@PathVariable final String dsId) throws DsmException {
|
||||
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final ApiDetailsResponse rsp = dsmCore.getApis(dsId);
|
||||
return prepareResponse(0, rsp.getApi().size(), stop, rsp);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/api/baseurl/{page}/{size}", produces = { "application/json" }, method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/api/baseurl/{page}/{size}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.POST)
|
||||
@ApiOperation(value = "search for the list of base URLs of Datasource APIs managed by a user", notes = "Returns the list of base URLs of Datasource APIs managed by a user", tags = {
|
||||
DS, API, R }, response = String[].class)
|
||||
DS, API, R
|
||||
}, response = String[].class)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = String[].class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK", response = String[].class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public List<String> searchBaseUrls(
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
@RequestBody final RequestFilter requestFilter,
|
||||
@PathVariable final int page,
|
||||
@PathVariable final int size) throws DsmException {
|
||||
|
||||
return dsmCore.findBaseURLs(requestFilter, page, size);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/api/{apiId}", method = RequestMethod.DELETE)
|
||||
@ApiOperation(value = "delete an API", notes = "delete an API, if removable", tags = { API, W })
|
||||
@ApiOperation(value = "delete an API", notes = "delete an API, if removable", tags = {
|
||||
API, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 400, message = "Api not found", response = ErrorMessage.class),
|
||||
@ApiResponse(code = 403, message = "Api not removable", response = ErrorMessage.class),
|
||||
@ApiResponse(code = 500, message = "DSM Server error", response = ErrorMessage.class)})
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 400, message = "Api not found", response = ErrorMessage.class),
|
||||
@ApiResponse(code = 403, message = "Api not removable", response = ErrorMessage.class),
|
||||
@ApiResponse(code = 500, message = "DSM Server error", response = ErrorMessage.class)
|
||||
})
|
||||
public void deleteApi(@PathVariable final String apiId) throws DsmForbiddenException, DsmNotFoundException {
|
||||
dsmCore.deleteApi(apiId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/manage", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "set the managed status for a given datasource", notes = "set the managed status for a given datasource", tags = { DS, W })
|
||||
@ApiOperation(value = "set the managed status for a given datasource", notes = "set the managed status for a given datasource", tags = {
|
||||
DS, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void setManaged(
|
||||
@RequestParam final String id,
|
||||
@RequestParam final boolean managed) throws DsmException {
|
||||
@RequestParam final String id,
|
||||
@RequestParam final boolean managed) throws DsmException {
|
||||
|
||||
dsmCore.setManaged(id, managed);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/managed/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "get the datasource managed status", notes = "get the datasource managed status", tags = { DS, R })
|
||||
@ApiOperation(value = "get the datasource managed status", notes = "get the datasource managed status", tags = {
|
||||
DS, R
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public boolean isManaged(@PathVariable final String id) throws DsmException {
|
||||
return dsmCore.isManaged(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/add", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "add a new Datasource", notes = "add a new Datasource", tags = { DS, W })
|
||||
@ApiOperation(value = "add a new Datasource", notes = "add a new Datasource", tags = {
|
||||
DS, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 400, message = "Malformed request", response = ErrorMessage[].class),
|
||||
@ApiResponse(code = 500, message = "Unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 400, message = "Malformed request", response = ErrorMessage[].class),
|
||||
@ApiResponse(code = 500, message = "Unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmException {
|
||||
|
||||
if (dsmCore.exist(datasource)) { // TODO further check that the DS doesn't have any API
|
||||
|
@ -229,155 +280,76 @@ public class DsmApiController extends AbstractExporterController {
|
|||
}
|
||||
|
||||
@RequestMapping(value = "/ds/update", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update Datasource details", notes = "update Datasource details", tags = { DS, W })
|
||||
@ApiOperation(value = "update Datasource details", notes = "update Datasource details", tags = {
|
||||
DS, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void updateDatasource(
|
||||
@RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException {
|
||||
@RequestBody final DatasourceDetailsUpdate ds) throws DsmException, DsmNotFoundException {
|
||||
|
||||
dsmCore.updateDatasource(ds);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/logourl", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update a datasource name", notes = "update a datasource name", tags = { DS, W, D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public void updateDatasourceLogoURL(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String logourl) throws DsmException {
|
||||
|
||||
dsmCore.updateDatasourceLogoUrl(dsId, logourl);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/name", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update a datasource name", notes = "update a datasource name", tags = { DS, W, D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public void updateDatasourceName(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String officialname,
|
||||
@RequestParam final String englishname) throws DsmException {
|
||||
|
||||
dsmCore.updateDatasourcename(dsId, officialname, englishname);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/coordinates", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update the datasource coordinates (latitude, longitude)", notes = "update the datasource coordinates (latitude, longitude)", tags = {
|
||||
DS, W, D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public void updateCoordinates(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final Double latitude,
|
||||
@RequestParam final Double longitude) throws DsmException {
|
||||
|
||||
dsmCore.updateCoordinates(dsId, latitude, longitude);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/timezone", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update a datasource timezone", notes = "update a datasource timezone", tags = { DS, W, D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public void updateTimezone(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String timezone) throws DsmException {
|
||||
|
||||
dsmCore.updateTimezone(dsId, timezone);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/typology", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update a datasource typology code", notes = "update a datasource typology code", tags = { DS, W, D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public void updateTypology(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String typology) throws DsmException {
|
||||
|
||||
dsmCore.updateDsTypology(dsId, typology);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/registeredby", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update a datasource registeredBy", notes = "update a datasource registeredBy", tags = { DS, W, D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public void updateRegisteringUser(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String registeredBy) throws DsmException {
|
||||
|
||||
dsmCore.updateDsRegisteringUser(dsId, registeredBy);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/ds/platform", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update a datasource platform", notes = "update a datasource platform", tags = { DS, W, D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
public void updatePlatform(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String platform) throws DsmException {
|
||||
|
||||
dsmCore.updateDsPlatform(dsId, platform);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/api/baseurl", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update the base URL of a datasource interface", notes = "update the base URL of a datasource interface", tags = { API, W })
|
||||
@ApiOperation(value = "update the base URL of a datasource interface", notes = "update the base URL of a datasource interface", tags = {
|
||||
API, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void updateBaseUrl(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String baseUrl) throws DsmException {
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String baseUrl) throws DsmException {
|
||||
|
||||
dsmCore.updateApiBaseurl(dsId, apiId, baseUrl);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/api/compliance", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update the compatibility of a datasource interface", notes = "update the compatibility of a datasource interface", tags = { API, W })
|
||||
@ApiOperation(value = "update the compatibility of a datasource interface", notes = "update the compatibility of a datasource interface", tags = {
|
||||
API, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void updateCompliance(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String compliance,
|
||||
@RequestParam(required = false, defaultValue = "false") final boolean override) throws DsmException {
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String compliance,
|
||||
@RequestParam(required = false, defaultValue = "false") final boolean override) throws DsmException {
|
||||
|
||||
dsmCore.updateApiCompatibility(dsId, apiId, compliance, override);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/api/oaiset", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "update the OAI set of a datasource interface", notes = "update the OAI set of a datasource interface", tags = { API, W })
|
||||
@ApiOperation(value = "update the OAI set of a datasource interface", notes = "update the OAI set of a datasource interface", tags = {
|
||||
API, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void updateOaiSetl(
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String oaiSet) throws DsmException {
|
||||
@RequestParam final String dsId,
|
||||
@RequestParam final String apiId,
|
||||
@RequestParam final String oaiSet) throws DsmException {
|
||||
|
||||
dsmCore.updateApiOaiSet(dsId, apiId, oaiSet);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ds/api/add", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "adds a new Interface to one Datasource", notes = "adds an Interface to one Datasource", tags = { API, W })
|
||||
@ApiOperation(value = "adds a new Interface to one Datasource", notes = "adds an Interface to one Datasource", tags = {
|
||||
API, W
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void addApi(@RequestBody final ApiDetails api) throws DsmException {
|
||||
if (StringUtils.isBlank(api.getDatasource())) { throw new DsmException(HttpStatus.SC_BAD_REQUEST, "missing datasource id"); }
|
||||
dsmCore.addApi(api);
|
||||
|
@ -389,110 +361,47 @@ public class DsmApiController extends AbstractExporterController {
|
|||
private OperationManager operationManager;
|
||||
|
||||
@RequestMapping(value = "/dsm/ops", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "get the number of pending operations", notes = "get the number of pending operations", tags = { R, M })
|
||||
@ApiOperation(value = "get the number of pending operations", notes = "get the number of pending operations", tags = {
|
||||
R, M
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public int getOps() throws DsmException {
|
||||
return operationManager.getOpSize();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/dsm/killops", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "interrupts the pending operations", notes = "return the number of interrupted operations", tags = { W, M })
|
||||
@ApiOperation(value = "interrupts the pending operations", notes = "return the number of interrupted operations", tags = {
|
||||
W, M
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public int killOps() throws DsmException {
|
||||
return operationManager.dropAll();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/dsm/dropcache", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "drop the caches", notes = "drop the internal caches", tags = { W, M })
|
||||
@ApiOperation(value = "drop the caches", notes = "drop the internal caches", tags = {
|
||||
W, M
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@ApiResponse(code = 200, message = "OK"),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class)
|
||||
})
|
||||
public void dropCache() throws DsmException {
|
||||
dsmCore.dropCaches();
|
||||
}
|
||||
|
||||
// OLD DEPRECATED METHODS
|
||||
|
||||
@Deprecated
|
||||
@ApiOperation(value = "search datasources by name", notes = "Returns list of Datasource details.", tags = { D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSearchResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@RequestMapping(value = "/ds/search/name/{page}/{size}", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
DatasourceSearchResponse searchByName(final String name, final int page, final int size) throws DsmException {
|
||||
final RequestSort sort = RequestSort.id;
|
||||
final RequestSortOrder order = RequestSortOrder.ASCENDING;
|
||||
final RequestFilter filter = new RequestFilter();
|
||||
filter.put(FilterName.englishname, name);
|
||||
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSearchResponse rsp = dsmCore.search(sort, order, filter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiOperation(value = "search datasources by contact email", notes = "Returns list of Datasource details.", tags = { D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSearchResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@RequestMapping(value = "/ds/search/email/{page}/{size}", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
DatasourceSearchResponse searchByContactemail(final String contactemail, final int page, final int size) throws DsmException {
|
||||
final RequestSort sort = RequestSort.id;
|
||||
final RequestSortOrder order = RequestSortOrder.ASCENDING;
|
||||
final RequestFilter filter = new RequestFilter();
|
||||
filter.put(FilterName.contactemail, contactemail);
|
||||
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSearchResponse rsp = dsmCore.search(sort, order, filter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiOperation(value = "search datasources by country", notes = "Returns list of Datasource details.", tags = { D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSearchResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@RequestMapping(value = "/ds/search/country/{page}/{size}", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
DatasourceSearchResponse searchByCountry(final String country, final Boolean managed, final int page, final int size) throws DsmException {
|
||||
final RequestSort sort = RequestSort.id;
|
||||
final RequestSortOrder order = RequestSortOrder.ASCENDING;
|
||||
final RequestFilter filter = new RequestFilter();
|
||||
filter.put(FilterName.country, country);
|
||||
filter.put(FilterName.managed, managed);
|
||||
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSearchResponse rsp = dsmCore.search(sort, order, filter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiOperation(value = "search datasources by registering user", notes = "Returns list of Datasource details.", tags = { D })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "OK", response = DatasourceSearchResponse.class),
|
||||
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) })
|
||||
@RequestMapping(value = "/ds/search/registeredby/{page}/{size}", produces = { "application/json" }, method = RequestMethod.GET)
|
||||
DatasourceSearchResponse searchByRegisteringUser(final String registeredBy, final int page, final int size) throws DsmException {
|
||||
final RequestSort sort = RequestSort.id;
|
||||
final RequestSortOrder order = RequestSortOrder.ASCENDING;
|
||||
final RequestFilter filter = new RequestFilter();
|
||||
filter.put(FilterName.registeredby, registeredBy);
|
||||
|
||||
final StopWatch stop = StopWatch.createStarted();
|
||||
final DatasourceSearchResponse rsp = dsmCore.search(sort, order, filter, page, size);
|
||||
return prepareResponse(page, size, stop, rsp);
|
||||
}
|
||||
|
||||
// HELPERS
|
||||
|
||||
private <T extends Response> T prepareResponse(final int page, final int size, final StopWatch stopWatch, final T rsp) {
|
||||
rsp.getHeader()
|
||||
.setTime(stopWatch.getTime())
|
||||
.setPage(page)
|
||||
.setSize(size);
|
||||
.setTime(stopWatch.getTime())
|
||||
.setPage(page)
|
||||
.setSize(size);
|
||||
return rsp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
package eu.dnetlib.openaire.dsm;
|
||||
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.BASE_URL;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.COMPLIANCE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.ENGLISH_NAME;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.LATITUDE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.LONGITUDE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.OAI_SET;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.OFFICIAL_NAME;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.PLATFORM;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.REMOVABLE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.TIMEZONE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.TYPOLOGY;
|
||||
import static eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils.asDbEntry;
|
||||
import static eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils.asDetails;
|
||||
import static eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils.asMapOfChanges;
|
||||
import static eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils.copyNonNullProperties;
|
||||
import static eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils.createId;
|
||||
|
||||
|
@ -21,7 +9,6 @@ import java.nio.charset.Charset;
|
|||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -34,9 +21,6 @@ import java.util.stream.Stream;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import eu.dnetlib.openaire.dsm.domain.*;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
@ -49,15 +33,11 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.common.xml.XmlEscapers;
|
||||
|
||||
import eu.dnetlib.OpenaireExporterConfig;
|
||||
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||
|
@ -77,6 +57,19 @@ import eu.dnetlib.openaire.dsm.dao.VocabularyClient;
|
|||
import eu.dnetlib.openaire.dsm.dao.utils.DsmMappingUtils;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexDsInfo;
|
||||
import eu.dnetlib.openaire.dsm.dao.utils.IndexRecordsInfo;
|
||||
import eu.dnetlib.openaire.dsm.domain.AggregationHistoryResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetailsResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceInfo;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.RegisteredDatasourceInfo;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestFilter;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSort;
|
||||
import eu.dnetlib.openaire.dsm.domain.RequestSortOrder;
|
||||
import eu.dnetlib.openaire.dsm.domain.SimpleResponse;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.DatasourceDbEntry;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.IdentityDbEntry;
|
||||
|
@ -120,7 +113,7 @@ public class DsmCore {
|
|||
@PostConstruct
|
||||
public void init() {
|
||||
executor = MoreExecutors.listeningDecorator(new ScheduledThreadPoolExecutor(config.getRequestWorkers(),
|
||||
new ThreadFactoryBuilder().setNameFormat("dsm-client-%d").build()));
|
||||
new ThreadFactoryBuilder().setNameFormat("dsm-client-%d").build()));
|
||||
}
|
||||
|
||||
public List<Country> listCountries() throws DsmException {
|
||||
|
@ -132,48 +125,16 @@ public class DsmCore {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DatasourceSearchResponse search(final RequestSort requestSortBy,
|
||||
final RequestSortOrder order,
|
||||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
|
||||
try {
|
||||
final List<DatasourceInfo> datasourceInfo = Lists.newArrayList();
|
||||
final Queue<Throwable> errors = Queues.newLinkedBlockingQueue();
|
||||
final CountDownLatch outerLatch = new CountDownLatch(2);
|
||||
|
||||
final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size);
|
||||
if (dsPage.getTotalElements() > 0 && dsPage.getNumberOfElements() > 0) {
|
||||
dsPage.forEach(d -> datasourceInfo.add(enrichDatasourceInfo(asDetails(d), outerLatch, errors)));
|
||||
waitLatch(outerLatch, errors, config.getRequestTimeout());
|
||||
}
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
// TODO report on error metrics
|
||||
errors.forEach(log::error);
|
||||
}
|
||||
return ResponseUtils.searchResponse(datasourceInfo, dsPage.getTotalElements());
|
||||
} catch (final Throwable e) {
|
||||
log.error("error searching datasources", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public DatasourceDetailResponse searchDsDetails(final RequestSort requestSortBy,
|
||||
final RequestSortOrder order,
|
||||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
final RequestSortOrder order,
|
||||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
|
||||
try {
|
||||
final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size);
|
||||
return ResponseUtils.detailsResponse(
|
||||
dsPage.map(d -> asDetails(d)).getContent(),
|
||||
dsPage.getTotalElements());
|
||||
return ResponseUtils.detailsResponse(dsPage.map(d -> asDetails(d)).getContent(), dsPage.getTotalElements());
|
||||
} catch (final Throwable e) {
|
||||
log.error("error searching datasources", e);
|
||||
throw e;
|
||||
|
@ -181,16 +142,14 @@ public class DsmCore {
|
|||
}
|
||||
|
||||
public DatasourceSnippetResponse searchSnippet(final RequestSort requestSortBy,
|
||||
final RequestSortOrder order,
|
||||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
final RequestSortOrder order,
|
||||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
try {
|
||||
final Page<DatasourceDbEntry> dsPage = dsDao.search(requestSortBy, order, requestFilter, page, size);
|
||||
return ResponseUtils.snippetResponse(
|
||||
dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(),
|
||||
dsPage.getTotalElements());
|
||||
return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements());
|
||||
} catch (final Throwable e) {
|
||||
log.error("error searching datasources", e);
|
||||
throw e;
|
||||
|
@ -198,16 +157,14 @@ public class DsmCore {
|
|||
}
|
||||
|
||||
public DatasourceSnippetResponse searchRegistered(final RequestSort requestSortBy,
|
||||
final RequestSortOrder order,
|
||||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
final RequestSortOrder order,
|
||||
final RequestFilter requestFilter,
|
||||
final int page,
|
||||
final int size)
|
||||
throws DsmException {
|
||||
try {
|
||||
final Page<DatasourceDbEntry> dsPage = dsDao.searchRegistered(requestSortBy, order, requestFilter, page, size);
|
||||
return ResponseUtils.snippetResponse(
|
||||
dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(),
|
||||
dsPage.getTotalElements());
|
||||
return ResponseUtils.snippetResponse(dsPage.map(DsmMappingUtils::asSnippetExtended).getContent(), dsPage.getTotalElements());
|
||||
} catch (final Throwable e) {
|
||||
log.error("error searching datasources", e);
|
||||
throw e;
|
||||
|
@ -227,8 +184,8 @@ public class DsmCore {
|
|||
try {
|
||||
final List<ApiDbEntry> apis = dsDao.getApis(dsId);
|
||||
final List<ApiDetails> api = apis.stream()
|
||||
.map(DsmMappingUtils::asDetails)
|
||||
.collect(Collectors.toList());
|
||||
.map(DsmMappingUtils::asDetails)
|
||||
.collect(Collectors.toList());
|
||||
return ResponseUtils.apiResponse(api, api.size());
|
||||
} catch (final Throwable e) {
|
||||
log.error(String.format("error searching datasource api %s", dsId), e);
|
||||
|
@ -239,17 +196,6 @@ public class DsmCore {
|
|||
public void setManaged(final String dsId, final boolean managed) throws DsmException {
|
||||
log.info(String.format("updated ds '%s' managed with '%s'", dsId, managed));
|
||||
dsDao.setManaged(dsId, managed);
|
||||
final List<ApiDbEntry> apis = dsDao.getApis(dsId);
|
||||
for (final ApiDbEntry a : apis) {
|
||||
setApiRemovable(dsId, a.getId(), true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setApiRemovable(final String dsId, final String apiId, final boolean removable) {
|
||||
log.info(String.format("updated api '%s' removable with '%s'", apiId, removable));
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(REMOVABLE, String.valueOf(removable));
|
||||
isClient.updateAPIField(dsId, apiId, changes);
|
||||
}
|
||||
|
||||
public boolean isManaged(final String dsId) throws DsmException {
|
||||
|
@ -263,7 +209,6 @@ public class DsmCore {
|
|||
public void save(final DatasourceDetails d) throws DsmException {
|
||||
try {
|
||||
dsDao.saveDs(asDbEntry(d));
|
||||
isClient.registerDS(d);
|
||||
} catch (final Throwable e) {
|
||||
log.error(ExceptionUtils.getStackTrace(e));
|
||||
throw e;
|
||||
|
@ -281,10 +226,10 @@ public class DsmCore {
|
|||
final DatasourceDbEntry update = asDbEntry(d);
|
||||
if (d.getIdentities() != null) {
|
||||
final Set<IdentityDbEntry> identities = new HashSet<>(
|
||||
Stream.of(update.getIdentities(), dbEntry.getIdentities())
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toMap(i -> i.getIssuertype() + i.getPid(), Function.identity(), (i1, i2) -> i1))
|
||||
.values());
|
||||
Stream.of(update.getIdentities(), dbEntry.getIdentities())
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toMap(i -> i.getIssuertype() + i.getPid(), Function.identity(), (i1, i2) -> i1))
|
||||
.values());
|
||||
copyNonNullProperties(update, dbEntry);
|
||||
dbEntry.setIdentities(identities);
|
||||
} else {
|
||||
|
@ -292,79 +237,12 @@ public class DsmCore {
|
|||
}
|
||||
|
||||
dsDao.saveDs(dbEntry);
|
||||
isClient.updateDatasourceFields(d.getId(), asMapOfChanges(d));
|
||||
} catch (final Throwable e) {
|
||||
log.error(ExceptionUtils.getStackTrace(e));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateDatasourcename(final String dsId, final String officialname, final String englishname) throws DsmException {
|
||||
log.info(String.format("updated datasource '%s' with officialname '%s' and englishname '%s'", dsId, officialname, englishname));
|
||||
dsDao.updateName(dsId, officialname, englishname);
|
||||
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(OFFICIAL_NAME, XmlEscapers.xmlContentEscaper().escape(officialname));
|
||||
changes.put(ENGLISH_NAME, XmlEscapers.xmlContentEscaper().escape(englishname));
|
||||
isClient.updateDatasourceFields(dsId, changes);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateDatasourceLogoUrl(final String dsId, final String logourl) throws DsmException {
|
||||
log.info(String.format("updated datasource '%s' with logo URL '%s'", dsId, logourl));
|
||||
|
||||
dsDao.updateLogoUrl(dsId, logourl);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateCoordinates(final String dsId, final Double latitude, final Double longitude) throws DsmException {
|
||||
log.info(String.format("updated datasource '%s' with coordinates Lat:'%s', Lon:'%s'", dsId, latitude, longitude));
|
||||
dsDao.updateCoordinates(dsId, latitude, longitude);
|
||||
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(LATITUDE, XmlEscapers.xmlContentEscaper().escape(String.valueOf(latitude)));
|
||||
changes.put(LONGITUDE, XmlEscapers.xmlContentEscaper().escape(String.valueOf(longitude)));
|
||||
isClient.updateDatasourceFields(dsId, changes);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateTimezone(final String dsId, final String timezone) throws DsmException {
|
||||
log.info(String.format("updated datasource '%s' timezone with '%s'", dsId, timezone));
|
||||
dsDao.updateTimezone(dsId, timezone);
|
||||
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(TIMEZONE, XmlEscapers.xmlContentEscaper().escape(timezone));
|
||||
isClient.updateDatasourceFields(dsId, changes);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateDsTypology(final String dsId, final String typology) throws DsmException {
|
||||
log.info(String.format("updated datasource '%s' typology with '%s'", dsId, typology));
|
||||
dsDao.updateTypology(dsId, typology);
|
||||
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(TYPOLOGY, XmlEscapers.xmlContentEscaper().escape(typology));
|
||||
isClient.updateDatasourceFields(dsId, changes);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateDsRegisteringUser(final String dsId, final String registeredBy) throws DsmException {
|
||||
log.info(String.format("setting datasource '%s' registering user with '%s'", dsId, registeredBy));
|
||||
dsDao.updateRegisteringUser(dsId, registeredBy);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void updateDsPlatform(final String dsId, final String platform) throws DsmException {
|
||||
log.info(String.format("updated datasource '%s' platform with '%s'", dsId, platform));
|
||||
dsDao.updatePlatform(dsId, platform);
|
||||
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(PLATFORM, XmlEscapers.xmlContentEscaper().escape(platform)); // this is not a typo, Repository profiles map the platform
|
||||
// in the DATASOURCE_TYPE field.
|
||||
isClient.updateDatasourceFields(dsId, changes);
|
||||
}
|
||||
|
||||
// TODO remove if unused
|
||||
public void deleteDs(final String dsId) throws DsmException {
|
||||
log.info(String.format("deleted datasource '%s'", dsId));
|
||||
|
@ -374,35 +252,17 @@ public class DsmCore {
|
|||
// API
|
||||
|
||||
public void updateApiOaiSet(final String dsId, final String apiId, final String oaiSet) throws DsmException {
|
||||
final boolean insert = dsDao.upsertApiOaiSet(apiId, oaiSet);
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(OAI_SET, XmlEscapers.xmlContentEscaper().escape(oaiSet));
|
||||
|
||||
if (!insert) {
|
||||
isClient.updateAPIField(dsId, apiId, changes);
|
||||
} else {
|
||||
isClient.addAPIAttribute(dsId, apiId, changes);
|
||||
}
|
||||
dsDao.upsertApiOaiSet(apiId, oaiSet);
|
||||
}
|
||||
|
||||
public void updateApiBaseurl(final String dsId, final String apiId, final String baseUrl) throws DsmException {
|
||||
log.info(String.format("updated api '%s' baseurl with '%s'", apiId, baseUrl));
|
||||
dsDao.updateApiBaseUrl(apiId, baseUrl);
|
||||
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(BASE_URL, XmlEscapers.xmlContentEscaper().escape(baseUrl));
|
||||
|
||||
isClient.updateAPIField(dsId, apiId, changes);
|
||||
}
|
||||
|
||||
public void updateApiCompatibility(final String dsId, final String apiId, final String compliance, final boolean override) throws DsmException {
|
||||
log.info(String.format("updated api '%s' compliance with '%s'", apiId, compliance));
|
||||
dsDao.updateCompliance(null, apiId, compliance, override);
|
||||
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
changes.put(COMPLIANCE, XmlEscapers.xmlAttributeEscaper().escape(compliance));
|
||||
|
||||
isClient.updateAPIField(dsId, apiId, changes);
|
||||
}
|
||||
|
||||
public void addApi(final ApiDetails api) throws DsmException {
|
||||
|
@ -410,14 +270,11 @@ public class DsmCore {
|
|||
api.setId(createId(api));
|
||||
log.info(String.format("missing api id, created '%s'", api.getId()));
|
||||
}
|
||||
|
||||
dsDao.addApi(asDbEntry(api));
|
||||
isClient.registerAPI(api);
|
||||
}
|
||||
|
||||
public void deleteApi(final String apiId) throws DsmForbiddenException, DsmNotFoundException {
|
||||
// TODO handle the api removal in case of associated workflows.
|
||||
isClient.removeAPI(apiId);
|
||||
dsDao.deleteApi(null, apiId);
|
||||
}
|
||||
|
||||
|
@ -438,9 +295,9 @@ public class DsmCore {
|
|||
}
|
||||
|
||||
private void getAggregationHistory(final String dsId,
|
||||
final CountDownLatch outerLatch,
|
||||
final Queue<Throwable> errors,
|
||||
final DatasourceInfo datasourceInfo) {
|
||||
final CountDownLatch outerLatch,
|
||||
final Queue<Throwable> errors,
|
||||
final DatasourceInfo datasourceInfo) {
|
||||
Futures.addCallback(executor.submit(() -> mongoLoggerClient.getAggregationHistory(dsId)), new FutureCallback<List<AggregationInfo>>() {
|
||||
|
||||
@Override
|
||||
|
@ -462,15 +319,15 @@ public class DsmCore {
|
|||
datasourceInfo.setAggregationHistory(info);
|
||||
if (!info.isEmpty()) {
|
||||
datasourceInfo
|
||||
.setLastCollection(info.stream().filter(a -> AggregationStage.COLLECT.equals(a.getAggregationStage())).findFirst().get())
|
||||
.setLastTransformation(info.stream().filter(a -> AggregationStage.TRANSFORM.equals(a.getAggregationStage())).findFirst().get());
|
||||
.setLastCollection(info.stream().filter(a -> AggregationStage.COLLECT.equals(a.getAggregationStage())).findFirst().get())
|
||||
.setLastTransformation(info.stream().filter(a -> AggregationStage.TRANSFORM.equals(a.getAggregationStage())).findFirst().get());
|
||||
}
|
||||
}
|
||||
|
||||
private void getIndexDsInfo(final String dsId,
|
||||
final CountDownLatch outerLatch,
|
||||
final Queue<Throwable> errors,
|
||||
final DatasourceInfo datasourceInfo) {
|
||||
final CountDownLatch outerLatch,
|
||||
final Queue<Throwable> errors,
|
||||
final DatasourceInfo datasourceInfo) {
|
||||
Futures.addCallback(executor.submit(() -> isClient.calculateCurrentIndexDsInfo()), new FutureCallback<IndexDsInfo>() {
|
||||
|
||||
@Override
|
||||
|
@ -483,9 +340,9 @@ public class DsmCore {
|
|||
@Override
|
||||
public void onSuccess(final IndexRecordsInfo info) {
|
||||
datasourceInfo
|
||||
.setIndexRecords(info.getTotal())
|
||||
.setFundedContent(info.getFunded())
|
||||
.setLastIndexingDate(info.getDate());
|
||||
.setIndexRecords(info.getTotal())
|
||||
.setFundedContent(info.getFunded())
|
||||
.setLastIndexingDate(info.getDate());
|
||||
innerLatch.countDown();
|
||||
}
|
||||
|
||||
|
@ -538,7 +395,7 @@ public class DsmCore {
|
|||
public SimpleResponse searchRecentRegistered(final int size) throws Throwable {
|
||||
try {
|
||||
final String sql =
|
||||
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/openaire/sql/recent_registered_datasources.sql.st"), Charset.defaultCharset());
|
||||
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/openaire/sql/recent_registered_datasources.sql.st"), Charset.defaultCharset());
|
||||
|
||||
final List<RegisteredDatasourceInfo> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(RegisteredDatasourceInfo.class), size);
|
||||
|
||||
|
@ -548,28 +405,34 @@ public class DsmCore {
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public Long countRegisteredAfter(final String fromDate, final String typologyFilter) throws Throwable {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(typologyFilter)) {
|
||||
final String sql =
|
||||
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/openaire/sql/recent_registered_datasources_fromDate_typology.st.sql"), Charset.defaultCharset());
|
||||
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/openaire/sql/recent_registered_datasources_fromDate_typology.st.sql"), Charset
|
||||
.defaultCharset());
|
||||
|
||||
return jdbcTemplate.queryForObject(sql, new Object[] { fromDate, typologyFilter + "%" }, Long.class);
|
||||
return jdbcTemplate.queryForObject(sql, new Object[] {
|
||||
fromDate, typologyFilter + "%"
|
||||
}, Long.class);
|
||||
} else {
|
||||
final String sql =
|
||||
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/openaire/sql/recent_registered_datasources_fromDate.st.sql"), Charset.defaultCharset());
|
||||
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/openaire/sql/recent_registered_datasources_fromDate.st.sql"), Charset
|
||||
.defaultCharset());
|
||||
|
||||
return jdbcTemplate.queryForObject(sql, new Object[] { fromDate }, Long.class);
|
||||
return jdbcTemplate.queryForObject(sql, new Object[] {
|
||||
fromDate
|
||||
}, Long.class);
|
||||
}
|
||||
|
||||
|
||||
} catch (final Throwable e) {
|
||||
log.error("error searching recent datasources", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public AggregationHistoryResponse aggregationhistory(String dsId) throws DsmException {
|
||||
public AggregationHistoryResponse aggregationhistory(final String dsId) throws DsmException {
|
||||
final List<AggregationInfo> history = mongoLoggerClient.getAggregationHistory(dsId);
|
||||
final AggregationHistoryResponse rsp = new AggregationHistoryResponse(history);
|
||||
rsp.setHeader(ResponseUtils.header(history.size()));
|
||||
|
|
|
@ -1,18 +1,7 @@
|
|||
package eu.dnetlib.openaire.dsm.dao.utils;
|
||||
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.ADMIN_INFO;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.ENGLISH_NAME;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.LATITUDE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.LONGITUDE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.OFFICIAL_NAME;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.PLATFORM;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.TIMEZONE;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.TYPOLOGY;
|
||||
import static eu.dnetlib.openaire.common.ExporterConstants.WEBSITE_URL;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -25,15 +14,12 @@ import org.springframework.beans.BeanWrapper;
|
|||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.xml.XmlEscapers;
|
||||
|
||||
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions;
|
||||
import eu.dnetlib.miscutils.datetime.DateUtils;
|
||||
import eu.dnetlib.openaire.dsm.domain.ApiDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceDetailsUpdate;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippet;
|
||||
import eu.dnetlib.openaire.dsm.domain.DatasourceSnippetExtended;
|
||||
import eu.dnetlib.openaire.dsm.domain.OrganizationDetails;
|
||||
import eu.dnetlib.openaire.dsm.domain.db.ApiDbEntry;
|
||||
|
@ -57,15 +43,6 @@ public class DsmMappingUtils {
|
|||
return details.setOpenaireId(asOpenaireId(details.getId()));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static DatasourceSnippet asSnippet(final DatasourceDbEntry d) {
|
||||
final DatasourceSnippet ds = new DatasourceSnippet();
|
||||
ds.setId(d.getId());
|
||||
ds.setOfficialname(d.getOfficialname());
|
||||
ds.setEnglishname(d.getEnglishname());
|
||||
return ds;
|
||||
}
|
||||
|
||||
public static DatasourceSnippetExtended asSnippetExtended(final DatasourceDbEntry d) {
|
||||
final DatasourceSnippetExtended ds = new DatasourceSnippetExtended();
|
||||
ds.setId(d.getId());
|
||||
|
@ -88,11 +65,11 @@ public class DsmMappingUtils {
|
|||
|
||||
private static OrganizationDetails asOrganizationDetail(final OrganizationDbEntry o) {
|
||||
return new OrganizationDetails()
|
||||
.setCountry(o.getCountry())
|
||||
.setLegalname(o.getLegalname())
|
||||
.setLegalshortname(o.getLegalshortname())
|
||||
.setWebsiteurl(o.getWebsiteurl())
|
||||
.setLogourl(o.getLogourl());
|
||||
.setCountry(o.getCountry())
|
||||
.setLegalname(o.getLegalname())
|
||||
.setLegalshortname(o.getLegalshortname())
|
||||
.setWebsiteurl(o.getWebsiteurl())
|
||||
.setLogourl(o.getLogourl());
|
||||
}
|
||||
|
||||
public static ApiDetails asDetails(final ApiDbEntry d) {
|
||||
|
@ -112,7 +89,7 @@ public class DsmMappingUtils {
|
|||
final DatasourceDbEntry dbe = _convert(d, DatasourceDbEntry.class);
|
||||
if (dbe.getOrganizations() != null) {
|
||||
dbe.getOrganizations().forEach(o -> {
|
||||
String prefix = StringUtils.isNotBlank(dbe.getNamespaceprefix()) ? dbe.getNamespaceprefix() : dbe.getId();
|
||||
final String prefix = StringUtils.isNotBlank(dbe.getNamespaceprefix()) ? dbe.getNamespaceprefix() : dbe.getId();
|
||||
o.setId(prefix + ID_SEPARATOR + o.getLegalname());
|
||||
if (o.getDateofcollection() == null) {
|
||||
o.setDateofcollection(new Date(System.currentTimeMillis()));
|
||||
|
@ -203,12 +180,12 @@ public class DsmMappingUtils {
|
|||
final Element iface = DocumentHelper.createElement("INTERFACE");
|
||||
|
||||
iface.addAttribute("active", String.valueOf(api.getActive()))
|
||||
.addAttribute("compliance", api.getCompatibility())
|
||||
.addAttribute("contentDescription", api.getContentdescription())
|
||||
.addAttribute("id", api.getId())
|
||||
.addAttribute("label", String.format("%s (%s)", api.getTypology(), api.getCompatibility()))
|
||||
.addAttribute("removable", String.valueOf(api.getRemovable()))
|
||||
.addAttribute("typology", api.getTypology());
|
||||
.addAttribute("compliance", api.getCompatibility())
|
||||
.addAttribute("contentDescription", api.getContentdescription())
|
||||
.addAttribute("id", api.getId())
|
||||
.addAttribute("label", String.format("%s (%s)", api.getTypology(), api.getCompatibility()))
|
||||
.addAttribute("removable", String.valueOf(api.getRemovable()))
|
||||
.addAttribute("typology", api.getTypology());
|
||||
iface.addElement("ACCESS_PROTOCOL").setText(api.getProtocol());
|
||||
if (api.getApiParams() != null) {
|
||||
final Element accessProtocol = (Element) iface.selectSingleNode("./ACCESS_PROTOCOL");
|
||||
|
@ -277,36 +254,4 @@ public class DsmMappingUtils {
|
|||
return emptyNames.toArray(result);
|
||||
}
|
||||
|
||||
public static Map<String, String> asMapOfChanges(final DatasourceDetailsUpdate d) {
|
||||
final Map<String, String> changes = Maps.newHashMap();
|
||||
|
||||
if (d.getContactemail() != null) {
|
||||
changes.put(ADMIN_INFO, XmlEscapers.xmlContentEscaper().escape(d.getContactemail()));
|
||||
}
|
||||
if (d.getEnglishname() != null) {
|
||||
changes.put(ENGLISH_NAME, XmlEscapers.xmlContentEscaper().escape(d.getEnglishname()));
|
||||
}
|
||||
if (d.getOfficialname() != null) {
|
||||
changes.put(OFFICIAL_NAME, XmlEscapers.xmlContentEscaper().escape(d.getOfficialname()));
|
||||
}
|
||||
if (d.getTimezone() != null) {
|
||||
changes.put(TIMEZONE, XmlEscapers.xmlContentEscaper().escape(d.getTimezone()));
|
||||
}
|
||||
if (d.getLatitude() != null) {
|
||||
changes.put(LATITUDE, XmlEscapers.xmlContentEscaper().escape(String.valueOf(d.getLatitude())));
|
||||
}
|
||||
if (d.getLongitude() != null) {
|
||||
changes.put(LONGITUDE, XmlEscapers.xmlContentEscaper().escape(String.valueOf(d.getLongitude())));
|
||||
}
|
||||
if (d.getPlatform() != null) {
|
||||
changes.put(PLATFORM, XmlEscapers.xmlContentEscaper().escape(d.getPlatform()));
|
||||
}
|
||||
if (d.getTypology() != null) {
|
||||
changes.put(TYPOLOGY, XmlEscapers.xmlContentEscaper().escape(d.getTypology()));
|
||||
}
|
||||
if (d.getWebsiteurl() != null) {
|
||||
changes.put(WEBSITE_URL, XmlEscapers.xmlContentEscaper().escape(d.getWebsiteurl()));
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,176 +0,0 @@
|
|||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('77', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('680', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('260', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('637', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('528', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('577', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('566', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('241', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('491', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('324', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('375', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('152', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('1025', 'roar');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/100004440', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/100000001', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/100000002', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100007601', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100001871', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100008982', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100000925', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100000923', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100001602', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100002428', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100000690', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('10.13039/501100002341', 'doi');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2242 8989', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0004 5900 900X', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2169 9189', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2181 2823', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0004 0427 7672', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 1958 7073', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2169 1945', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2154 0709', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2176 1982', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 0789 9694', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2228 3249', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2176 7727', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0004 0611 9213', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0004 0609 4140', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0004 4663 8325', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 1092 7772', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0004 0452 5752', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2297 5165', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 0672 3101', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 1957 0992', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 1091 8438', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 0507 0997', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 0665 7300', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 0685 2712', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0004 0647 6886', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 0943 9683', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 2096 9829', 'isni');
|
||||
INSERT INTO dsm_identities(pid, issuertype) VALUES ('0000 0001 1957 9997', 'isni');
|
||||
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('H2020', '680');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('H2020', '10.13039/501100007601');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('H2020', '0000 0001 2242 8989');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FP7', '0000 0004 5900 900X');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FCT', '260');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FCT', '10.13039/501100001871');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FCT', '0000 0001 2169 9189');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FCT', '0000 0001 2181 2823');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('WT', '637');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('WT', '10.13039/100004440');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('WT', '0000 0004 0427 7672');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NSF', '528');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NSF', '10.13039/501100008982');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NSF', '10.13039/100000001');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NSF', '0000 0001 1958 7073');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NSF', '0000 0001 2169 1945');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NSF', '0000 0001 2154 0709');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '577');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '10.13039/501100000925');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '0000 0001 2176 1982');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '0000 0001 0789 9694');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '0000 0001 2228 3249');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '0000 0001 2176 7727');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '0000 0001 0789 9694');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NHMRC', '0000 0001 2228 3249');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('ARC', '566');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('ARC', '10.13039/501100000923');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('ARC', '0000 0004 0611 9213');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('MSES', '0000 0004 0609 4140');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('CSF', '0000 0004 4663 8325');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NWO', '241');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NWO', '0000 0001 1092 7772');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('SFI', '10.13039/501100001602');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('SFI', '0000 0004 0452 5752');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NIH', '10.13039/100000002');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NIH', '0000 0001 2297 5165');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('NIH', '491');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('SNSF', '324');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('SNSF', '0000 0001 0672 3101');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('SNSF', '0000 0001 1957 0992');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FWF', '77');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FWF', '10.13039/501100002428');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('FWF', '0000 0001 1091 8438');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('RCUK', '375');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('RCUK', '10.13039/501100000690');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('RCUK', '0000 0001 0507 0997');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('TBT', '0000 0001 0665 7300');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('TBT', '0000 0001 0685 2712');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('AFF', '1025');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('AFF', '10.13039/501100002341');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('AFF', '0000 0004 0647 6886');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('CONICYT', '0000 0001 0943 9683');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('DFG', '152');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('DFG', '0000 0001 2096 9829');
|
||||
INSERT INTO funder_identity(funder, pid) VALUES ('DFG', '0000 0001 1957 9997');
|
||||
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('H2020', 'European Commission - Horizon 2020', 'H2020', 'EU', 'http://ec.europa.eu/research/participants/data/ref/h2020/grants_manual/hi/oa_pilot/h2020-hi-oa-pilot-guide_en.pdf', 'OA mandate for publications; OA to research data by default', '2015-08-24');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('FP7', 'European Commission - 7th Framework program', 'FP7', 'EU', 'http://ec.europa.eu/research/fp7', 'OA advised for publications; 2012 – 2013 (FP7)Special Clause 39 ERC on Open Access applies', '2013-05-07');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('FCT', 'Portuguese Foundation for Science and Technology', 'FCT', 'PT', 'https://www.fct.pt/acessoaberto/index.phtml.en', 'OA mandate for publications; OA to research data advised', '2015-02-27');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('WT', 'Wellcome Trust', 'WT', '', 'https://wellcome.ac.uk/funding/managing-grant/open-access-policy', 'OA mandate for articles, monographs and book chapters; CC-BY licence required', '2013-05-07');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('NSF', 'National Science Foundation', 'NSF', 'US', 'https://www.nsf.gov/news/special_reports/public_access', 'Version of record or AAM of articles, conferences and data deposited into the repository; persistent identifier to full text on publisher’s website', '2016-03-04');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('NHMRC', 'National Health and Medical Research Council', 'NHMRC', 'AU', 'https://www.nhmrc.gov.au/grants-funding/policy/nhmrc-open-access-policy', 'OA mandate for publications', '2015-08-24');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('ARC', 'Australian Research Council', 'ARC', 'AU', 'http://www.arc.gov.au/arc-open-access-policy', 'OA mandate for research outputs, except for research data', '2015-08-24');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('MESTD', 'Ministry of Education, Science and Technological Development', 'MESTD', 'RS', 'NOAD', 'NOAD', '2017-01-23');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('MSES', 'Ministry of Science Education and Sport', 'MSES/MZOS', 'HR', 'NOAD', 'NOAD', '2015-09-14');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('CSF', 'Croatian Science Foundation', 'CSF/HRZZ', 'HR', 'NOAD', 'NOAD', '2015-09-14');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('NWO', 'Netherlands Organisation for Scientific Research', 'NWO', 'NL', 'NOAD', 'NOAD', '2016-06-23');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('SFI', 'Science Foundation Ireland', 'SFI', 'IE', 'http://www.sfi.ie/resources/open-access-dec-10.pdf', 'OA mandate to publications, conference proceedings and technical reports', '2015-07-21');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('NIH', 'National Institute of Health', 'NIH', 'US', 'https://publicaccess.nih.gov/policy.htm', 'OA to articles', '2017-09-21');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('SNSF', 'Swiss National Science Foundation', 'SNSF', 'CH', 'NOAD', 'NOAD', '2016-11-16');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('FWF', 'Austrian Science Fund', 'FWF', 'AT', 'NOAD', 'NOAD', '2017-09-21');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('RCUK', 'Research Council UK', 'RCUK', 'UK', 'NOAD', 'NOAD', '2017-11-02');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('TBT', 'Scientific and Technological Research Council of Turkey', 'Tubitak', 'TR', 'NOAD', 'NOAD', '2017-11-02');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('DFG', 'German Research Foundation', 'DFG', 'DE', 'NOAD', 'NOAD', '2017-09-29');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('TARA', 'Tara Expedition Foundation', 'TARA', 'FR', 'NOAD', 'NOAD', '2016-12-02');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('AFF', 'Academy of Finland', 'AFF', 'FI', 'NOAD', 'NOAD', '2017-09-21');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('CONICYT', 'Comisión Nacional de Investigación Científica y Tecnológica', 'CONICYT', 'CL', 'http://www.lareferencia.info', '', '2017-09-08');
|
||||
|
||||
INSERT INTO funders(id, name, shortname, jurisdiction, websiteurl, policy, registrationdate)
|
||||
VALUES ('SGOV', 'Ministry of Economy, Industry and Competitiveness', 'SGOV', 'ES', 'NOAD', 'NOAD', '2017-09-14');
|
|
@ -1,510 +0,0 @@
|
|||
|
||||
CREATE TABLE dsm_api (
|
||||
id character varying(255) NOT NULL,
|
||||
protocol character varying(255),
|
||||
datasource character varying(255),
|
||||
contentdescription character varying(255) DEFAULT 'metadata'::character varying,
|
||||
active boolean DEFAULT false,
|
||||
removable boolean DEFAULT false,
|
||||
typology character varying(255) DEFAULT 'UNKNOWN'::character varying,
|
||||
compatibility character varying(255) DEFAULT 'UNKNOWN'::character varying,
|
||||
metadata_identifier_path character varying(512) DEFAULT NULL::character varying,
|
||||
last_collection_total integer,
|
||||
last_collection_date timestamp without time zone,
|
||||
last_collection_mdid character varying(255) DEFAULT NULL::character varying,
|
||||
last_aggregation_total integer,
|
||||
last_aggregation_date timestamp without time zone,
|
||||
last_aggregation_mdid character varying(255) DEFAULT NULL::character varying,
|
||||
last_download_total integer,
|
||||
last_download_date timestamp without time zone,
|
||||
last_download_objid character varying(255) DEFAULT NULL::character varying,
|
||||
last_validation_job character varying(255) DEFAULT NULL::character varying,
|
||||
baseurl text,
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text)),
|
||||
compatibility_override character varying(255) DEFAULT NULL::character varying
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_api OWNER TO dnetapi;
|
||||
|
||||
|
||||
CREATE TABLE dsm_datasource_organization (
|
||||
datasource character varying(255) NOT NULL,
|
||||
organization character varying(255) NOT NULL,
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_datasource_organization OWNER TO dnetapi;
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources; Type: TABLE; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE dsm_datasources (
|
||||
id character varying(255) NOT NULL,
|
||||
officialname character varying(512) NOT NULL,
|
||||
englishname character varying(512),
|
||||
websiteurl character varying(255),
|
||||
logourl character varying(255),
|
||||
contactemail character varying(255),
|
||||
latitude double precision DEFAULT 0.0,
|
||||
longitude double precision DEFAULT 0.0,
|
||||
timezone character varying(10) DEFAULT '0.0'::character varying,
|
||||
namespaceprefix character(12) NOT NULL,
|
||||
languages text,
|
||||
od_contenttypes text,
|
||||
collectedfrom character varying(255),
|
||||
dateofvalidation date,
|
||||
optional1 character varying(255),
|
||||
optional2 character varying(255),
|
||||
typology character varying(255) NOT NULL,
|
||||
provenanceaction character varying(255) DEFAULT 'UNKNOWN'::character varying,
|
||||
dateofcollection date DEFAULT ('now'::text)::date NOT NULL,
|
||||
platform character varying(255),
|
||||
activationid character varying(255),
|
||||
description text,
|
||||
releasestartdate date,
|
||||
releaseenddate date,
|
||||
missionstatementurl character varying(512),
|
||||
dataprovider boolean,
|
||||
serviceprovider boolean,
|
||||
databaseaccesstype character varying(64),
|
||||
datauploadtype character varying(64),
|
||||
databaseaccessrestriction character varying(64),
|
||||
datauploadrestriction character varying(64),
|
||||
versioning boolean,
|
||||
citationguidelineurl character varying(512),
|
||||
qualitymanagementkind character varying(64),
|
||||
pidsystems text,
|
||||
certificates text,
|
||||
aggregator character varying(64) DEFAULT 'OPENAIRE'::character varying NOT NULL,
|
||||
issn character varying(20),
|
||||
eissn character varying(20),
|
||||
lissn character varying(20),
|
||||
registeredby character varying(255),
|
||||
subjects text,
|
||||
managed boolean DEFAULT false,
|
||||
registrationdate date,
|
||||
consentTermsOfUse boolean default null,
|
||||
fullTextDownload boolean default null,
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_datasources OWNER TO dnetapi;
|
||||
|
||||
--
|
||||
-- Name: dsm_organizations; Type: TABLE; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE dsm_organizations (
|
||||
id character varying(255) NOT NULL,
|
||||
legalshortname character varying(255),
|
||||
legalname character varying(255),
|
||||
websiteurl text,
|
||||
logourl character varying(255),
|
||||
ec_legalbody boolean DEFAULT false,
|
||||
ec_legalperson boolean DEFAULT false,
|
||||
ec_nonprofit boolean DEFAULT false,
|
||||
ec_researchorganization boolean DEFAULT false,
|
||||
ec_highereducation boolean DEFAULT false,
|
||||
ec_internationalorganizationeurinterests boolean DEFAULT false,
|
||||
ec_internationalorganization boolean DEFAULT false,
|
||||
ec_enterprise boolean DEFAULT false,
|
||||
ec_smevalidated boolean DEFAULT false,
|
||||
ec_nutscode boolean DEFAULT false,
|
||||
country character varying(255),
|
||||
collectedfrom character varying(255),
|
||||
optional1 character varying(255),
|
||||
optional2 character varying(255),
|
||||
dateofcollection date DEFAULT ('now'::text)::date NOT NULL,
|
||||
provenanceaction character varying(255) DEFAULT 'UNKNOWN'::character varying,
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text)),
|
||||
lastupdate date DEFAULT ('now'::text)::date NOT NULL,
|
||||
trust double precision DEFAULT 0.9
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_organizations OWNER TO dnetapi;
|
||||
|
||||
--
|
||||
-- Name: browse_countries; Type: VIEW; Schema: public; Owner: dnet
|
||||
--
|
||||
|
||||
CREATE VIEW browse_countries AS
|
||||
SELECT o.country AS term,
|
||||
count(*) AS total
|
||||
FROM (((dsm_api a
|
||||
LEFT JOIN dsm_datasources d ON (((a.datasource)::text = (d.id)::text)))
|
||||
LEFT JOIN dsm_datasource_organization dao ON (((d.id)::text = (dao.datasource)::text)))
|
||||
LEFT JOIN dsm_organizations o ON (((dao.organization)::text = (o.id)::text)))
|
||||
GROUP BY o.country
|
||||
ORDER BY count(*) DESC;
|
||||
|
||||
|
||||
ALTER TABLE public.browse_countries OWNER TO dnet;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE dsm_apiparams (
|
||||
param character varying(255) NOT NULL,
|
||||
value text DEFAULT ''::character varying NOT NULL,
|
||||
api character varying(255) NOT NULL,
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_apiparams OWNER TO dnetapi;
|
||||
|
||||
--
|
||||
-- Name: dsm_datasource_api; Type: VIEW; Schema: public; Owner: dnet
|
||||
--
|
||||
|
||||
CREATE OR REPLACE VIEW dsm_datasource_api AS
|
||||
SELECT
|
||||
row_number() OVER (ORDER BY a.id) AS rowid,
|
||||
d.id,
|
||||
d.officialname,
|
||||
d.englishname,
|
||||
d.websiteurl,
|
||||
d.contactemail,
|
||||
d.collectedfrom,
|
||||
d.typology,
|
||||
d.platform,
|
||||
d.registeredby,
|
||||
d.managed,
|
||||
a.protocol,
|
||||
a.contentdescription,
|
||||
a.active,
|
||||
a.removable,
|
||||
a.typology AS apitypology,
|
||||
a.compatibility,
|
||||
a.baseurl
|
||||
FROM (dsm_datasources d
|
||||
LEFT JOIN dsm_api a ON (((d.id)::text = (a.datasource)::text)));
|
||||
|
||||
--
|
||||
-- Name: dsm_datasourcepids; Type: TABLE; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE dsm_datasourcepids (
|
||||
datasource character varying(255) NOT NULL,
|
||||
pid character varying(255) NOT NULL,
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_datasourcepids OWNER TO dnetapi;
|
||||
|
||||
--
|
||||
-- Name: dsm_identities; Type: TABLE; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE dsm_identities (
|
||||
pid character varying(255) NOT NULL,
|
||||
issuertype character varying(255),
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_identities OWNER TO dnetapi;
|
||||
|
||||
--
|
||||
-- Name: dsm_organizationpids; Type: TABLE; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE dsm_organizationpids (
|
||||
organization character varying(255) NOT NULL,
|
||||
pid character varying(255) NOT NULL,
|
||||
_dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text))
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.dsm_organizationpids OWNER TO dnetapi;
|
||||
|
||||
--
|
||||
-- Name: funder_identity; Type: TABLE; Schema: public; Owner: dnet; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE funder_identity (
|
||||
funder character varying(255),
|
||||
pid character varying(255)
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.funder_identity OWNER TO dnet;
|
||||
|
||||
--
|
||||
-- Name: funders; Type: TABLE; Schema: public; Owner: dnet; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE funders (
|
||||
id character varying(255) NOT NULL,
|
||||
name character varying(255),
|
||||
shortname character varying(255),
|
||||
jurisdiction character varying(255),
|
||||
websiteurl text,
|
||||
policy character varying(255),
|
||||
registrationdate date DEFAULT ('now'::text)::date NOT NULL,
|
||||
lastupdatedate date
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.funders OWNER TO dnet;
|
||||
|
||||
--
|
||||
-- Name: fundingpaths; Type: TABLE; Schema: public; Owner: dnet; Tablespace:
|
||||
--
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: project_organization; Type: TABLE; Schema: public; Owner: dnet; Tablespace:
|
||||
--
|
||||
|
||||
--CREATE TABLE project_organization (
|
||||
-- participantnumber integer,
|
||||
-- project character varying(255) NOT NULL,
|
||||
-- resporganization character varying(255) NOT NULL,
|
||||
-- semanticclass character varying(255) DEFAULT 'UNKNOWN'::character varying,
|
||||
-- trust double precision DEFAULT 0.9,
|
||||
-- _dnet_resource_identifier_ character varying(2048) DEFAULT ((('temp_'::text || md5((clock_timestamp())::text)) || '_'::text) || md5((random())::text))
|
||||
--);
|
||||
|
||||
|
||||
--ALTER TABLE public.project_organization OWNER TO dnet;
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_api_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_api
|
||||
ADD CONSTRAINT dsm_api_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_apicollection_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_apiparams
|
||||
ADD CONSTRAINT dsm_apicollection_pkey PRIMARY KEY (api, param);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasourcepids_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasourcepids
|
||||
ADD CONSTRAINT dsm_datasourcepids_pkey PRIMARY KEY (datasource, pid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_namespaceprefix_key; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasources
|
||||
ADD CONSTRAINT dsm_datasources_namespaceprefix_key UNIQUE (namespaceprefix);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasources
|
||||
ADD CONSTRAINT dsm_datasources_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_identities_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_identities
|
||||
ADD CONSTRAINT dsm_identities_pkey PRIMARY KEY (pid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_organization_datasource_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasource_organization
|
||||
ADD CONSTRAINT dsm_organization_datasource_pkey PRIMARY KEY (datasource, organization);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_organizationpids_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_organizationpids
|
||||
ADD CONSTRAINT dsm_organizationpids_pkey PRIMARY KEY (organization, pid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_organizations_pkey; Type: CONSTRAINT; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_organizations
|
||||
ADD CONSTRAINT dsm_organizations_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_contactemail_idx; Type: INDEX; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX dsm_datasources_contactemail_idx ON dsm_datasources USING btree (contactemail);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_englishname_idx; Type: INDEX; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX dsm_datasources_englishname_idx ON dsm_datasources USING btree (englishname);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_managed_idx; Type: INDEX; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX dsm_datasources_managed_idx ON dsm_datasources USING btree (managed);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_officialname_idx; Type: INDEX; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX dsm_datasources_officialname_idx ON dsm_datasources USING btree (officialname);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_registeredby_idx; Type: INDEX; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX dsm_datasources_registeredby_idx ON dsm_datasources USING btree (registeredby);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_organizations_country_idx; Type: INDEX; Schema: public; Owner: dnetapi; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX dsm_organizations_country_idx ON dsm_organizations USING btree (country);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY dsm_api
|
||||
ADD CONSTRAINT dsm_api_datasource_fkey FOREIGN KEY (datasource) REFERENCES dsm_datasources(id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_apicollections_api_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_apiparams
|
||||
ADD CONSTRAINT dsm_apicollections_api_fkey FOREIGN KEY (api) REFERENCES dsm_api(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasource_organization_datasource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasource_organization
|
||||
ADD CONSTRAINT dsm_datasource_organization_datasource_fkey FOREIGN KEY (datasource) REFERENCES dsm_datasources(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasource_organization_organization_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasource_organization
|
||||
ADD CONSTRAINT dsm_datasource_organization_organization_fkey FOREIGN KEY (organization) REFERENCES dsm_organizations(id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasourcepids_datasource_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasourcepids
|
||||
ADD CONSTRAINT dsm_datasourcepids_datasource_fkey FOREIGN KEY (datasource) REFERENCES dsm_datasources(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasourcepids_pid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasourcepids
|
||||
ADD CONSTRAINT dsm_datasourcepids_pid_fkey FOREIGN KEY (pid) REFERENCES dsm_identities(pid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_datasources_collectedfrom_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_datasources
|
||||
ADD CONSTRAINT dsm_datasources_collectedfrom_fkey FOREIGN KEY (collectedfrom) REFERENCES dsm_datasources(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_organizationpids_organization_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_organizationpids
|
||||
ADD CONSTRAINT dsm_organizationpids_organization_fkey FOREIGN KEY (organization) REFERENCES dsm_organizations(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_organizationpids_pid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_organizationpids
|
||||
ADD CONSTRAINT dsm_organizationpids_pid_fkey FOREIGN KEY (pid) REFERENCES dsm_identities(pid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: dsm_organizations_collectedfrom_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dnetapi
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY dsm_organizations
|
||||
ADD CONSTRAINT dsm_organizations_collectedfrom_fkey FOREIGN KEY (collectedfrom) REFERENCES dsm_datasources(id);
|
||||
|
||||
|
||||
|
||||
REVOKE ALL ON SCHEMA public FROM PUBLIC;
|
||||
REVOKE ALL ON SCHEMA public FROM postgres;
|
||||
GRANT ALL ON SCHEMA public TO postgres;
|
||||
GRANT ALL ON SCHEMA public TO PUBLIC;
|
||||
|
||||
|
||||
REVOKE ALL ON TABLE browse_countries FROM PUBLIC;
|
||||
REVOKE ALL ON TABLE browse_countries FROM dnet;
|
||||
GRANT ALL ON TABLE browse_countries TO dnet;
|
||||
GRANT ALL ON TABLE browse_countries TO dnetapi;
|
||||
|
||||
|
||||
REVOKE ALL ON TABLE dsm_datasource_api FROM PUBLIC;
|
||||
REVOKE ALL ON TABLE dsm_datasource_api FROM dnet;
|
||||
GRANT ALL ON TABLE dsm_datasource_api TO dnet;
|
||||
GRANT SELECT ON TABLE dsm_datasource_api TO dnetapi;
|
||||
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
|
||||
CREATE TABLE info (
|
||||
key character varying(255) NOT NULL PRIMARY KEY,
|
||||
value DATE
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE info TO dnet;
|
||||
GRANT ALL ON TABLE info TO dnetapi;
|
||||
|
||||
INSERT INTO info(key) VALUES ('oaf_load_date');
|
||||
INSERT INTO info(key) VALUES ('odf_load_date');
|
||||
INSERT INTO info(key) VALUES ('inference_date');
|
||||
INSERT INTO info(key) VALUES ('claim_load_date');
|
||||
INSERT INTO info(key) VALUES ('stats_update_date');
|
||||
|
||||
INSERT INTO info(key) VALUES ('crossref_update_date');
|
||||
INSERT INTO info(key) VALUES ('unpaywall_update_date');
|
||||
INSERT INTO info(key) VALUES ('orcid_update_date');
|
||||
INSERT INTO info(key) VALUES ('mag_update_date');
|
||||
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
<RESOURCE_PROFILE>
|
||||
<HEADER>
|
||||
<RESOURCE_IDENTIFIER value=""/>
|
||||
<RESOURCE_TYPE value="RepositoryServiceResourceType"/>
|
||||
<RESOURCE_KIND value="RepositoryServiceResources"/>
|
||||
<RESOURCE_URI value=""/>
|
||||
<DATE_OF_CREATION value=""/>
|
||||
<PROTOCOL/>
|
||||
</HEADER>
|
||||
<BODY>
|
||||
<CONFIGURATION>
|
||||
<DATASOURCE_TYPE></DATASOURCE_TYPE>
|
||||
<DATASOURCE_ORIGINAL_ID provenance="OPENAIRE"></DATASOURCE_ORIGINAL_ID>
|
||||
<DATASOURCE_AGGREGATED>false</DATASOURCE_AGGREGATED>
|
||||
<ENVIRONMENTS>
|
||||
<ENVIRONMENT>OPENAIRE</ENVIRONMENT>
|
||||
</ENVIRONMENTS>
|
||||
<TYPOLOGY></TYPOLOGY>
|
||||
<MAX_SIZE_OF_DATASTRUCTURE>0</MAX_SIZE_OF_DATASTRUCTURE>
|
||||
<AVAILABLE_DISKSPACE>0</AVAILABLE_DISKSPACE>
|
||||
<MAX_NUMBER_OF_DATASTRUCTURE>0</MAX_NUMBER_OF_DATASTRUCTURE>
|
||||
<OFFICIAL_NAME></OFFICIAL_NAME>
|
||||
<ENGLISH_NAME></ENGLISH_NAME>
|
||||
<ICON_URI></ICON_URI>
|
||||
<COUNTRY></COUNTRY>
|
||||
<LOCATION>
|
||||
<LONGITUDE></LONGITUDE>
|
||||
<LATITUDE></LATITUDE>
|
||||
<TIMEZONE></TIMEZONE>
|
||||
</LOCATION>
|
||||
<REPOSITORY_WEBPAGE></REPOSITORY_WEBPAGE>
|
||||
<REPOSITORY_INSTITUTION></REPOSITORY_INSTITUTION>
|
||||
<ADMIN_INFO></ADMIN_INFO>
|
||||
<INTERFACES></INTERFACES>
|
||||
<EXTRA_FIELDS>
|
||||
<FIELD>
|
||||
<key>OpenAireDataSourceId</key>
|
||||
<value></value>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<key>NamespacePrefix</key>
|
||||
<value></value>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<key>VERIFIED</key>
|
||||
<value>NO</value>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<key>aggregatorName</key>
|
||||
<value></value>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<key>dateOfValidation</key>
|
||||
<value></value>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<key>dateOfCollection</key>
|
||||
<value></value>
|
||||
</FIELD>
|
||||
<FIELD>
|
||||
<key>ACTID</key>
|
||||
<value></value>
|
||||
</FIELD>
|
||||
</EXTRA_FIELDS>
|
||||
<REGISTERED_BY></REGISTERED_BY>
|
||||
</CONFIGURATION>
|
||||
<STATUS>
|
||||
<NUMBER_OF_OBJECTS></NUMBER_OF_OBJECTS>
|
||||
<LAST_UPDATE value=""/>
|
||||
</STATUS>
|
||||
<QOS>
|
||||
<AVAILABILITY>0</AVAILABILITY>
|
||||
<CAPACITY/>
|
||||
<THROUGHPUT>0.0</THROUGHPUT>
|
||||
</QOS>
|
||||
<SECURITY_PARAMETERS/>
|
||||
<BLACKBOARD/>
|
||||
</BODY>
|
||||
</RESOURCE_PROFILE>
|
Loading…
Reference in New Issue