Add Dedup Confs
This commit is contained in:
parent
3aa5acd740
commit
5e86ab8723
|
@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||||
import eu.dnetlib.is.resource.model.SimpleResource;
|
|
||||||
import eu.dnetlib.is.vocabulary.model.Vocabulary;
|
import eu.dnetlib.is.vocabulary.model.Vocabulary;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -50,7 +49,7 @@ public class ImporterController extends AbstractDnetController {
|
||||||
@PostMapping(value = "/resource", consumes = {
|
@PostMapping(value = "/resource", consumes = {
|
||||||
MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE
|
MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE
|
||||||
})
|
})
|
||||||
public SimpleResource importResource(final HttpServletRequest request) throws Exception {
|
public String importResource(final HttpServletRequest request) throws Exception {
|
||||||
final String xml = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
|
final String xml = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
|
||||||
return oldProfilesImporter.importSimpleResource(xml);
|
return oldProfilesImporter.importSimpleResource(xml);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class OldProfilesImporter {
|
||||||
private VocabularyTermRepository vocabularyTermRepository;
|
private VocabularyTermRepository vocabularyTermRepository;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public SimpleResource importSimpleResource(final String xml) throws InformationServiceException {
|
public String importSimpleResource(final String xml) throws InformationServiceException {
|
||||||
final SAXReader reader = new SAXReader();
|
final SAXReader reader = new SAXReader();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -83,14 +83,20 @@ public class OldProfilesImporter {
|
||||||
res.setDescription(doc.valueOf("//HADOOP_JOB/DESCRIPTION"));
|
res.setDescription(doc.valueOf("//HADOOP_JOB/DESCRIPTION"));
|
||||||
resContent = doc.selectSingleNode("//HADOOP_JOB").asXML();
|
resContent = doc.selectSingleNode("//HADOOP_JOB").asXML();
|
||||||
break;
|
break;
|
||||||
|
case "DedupConfigurationDSResourceType":
|
||||||
|
res.setType("dedup_configuration");
|
||||||
|
res.setName(doc.valueOf("//DESCRIPTION"));
|
||||||
|
res.setDescription(doc.valueOf("//DESCRIPTION"));
|
||||||
|
resContent = doc.valueOf("//DEDUPLICATION");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InformationServiceException("Invalid resource type: " + doc.valueOf("//RESOURCE_TYPE/@value"));
|
throw new InformationServiceException("Invalid resource type: " + doc.valueOf("//RESOURCE_TYPE/@value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleResourceRepository.save(res);
|
simpleResourceRepository.save(res);
|
||||||
simpleResourceRepository.setContentById(id, resContent);
|
simpleResourceRepository.setContentById(id, resContent.trim());
|
||||||
|
|
||||||
return res;
|
return res.getId();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new InformationServiceException("Error parsing file", e);
|
throw new InformationServiceException("Error parsing file", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@ app.controller('resourcesController', function($scope, $http) {
|
||||||
$scope.tmpRes = angular.copy(r);
|
$scope.tmpRes = angular.copy(r);
|
||||||
$scope.tmpContent = "loading...";
|
$scope.tmpContent = "loading...";
|
||||||
$http.get('./api/resources/' + r.id + '/content?' + $.now()).then(function successCallback(res) {
|
$http.get('./api/resources/' + r.id + '/content?' + $.now()).then(function successCallback(res) {
|
||||||
$scope.tmpContent = res.data;
|
if (res.data instanceof Object) {
|
||||||
|
$scope.tmpContent = JSON.stringify(res.data, null, "\t");
|
||||||
|
} else {
|
||||||
|
$scope.tmpContent = res.data;
|
||||||
|
}
|
||||||
}, function errorCallback(res) {
|
}, function errorCallback(res) {
|
||||||
alert('ERROR: ' + res.data.message);
|
alert('ERROR: ' + res.data.message);
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,7 +90,8 @@ INSERT INTO resource_types(id, name, content_type) VALUES
|
||||||
('transformation_rule_xslt', 'Transformation Rules (xslt)', 'application/xml'),
|
('transformation_rule_xslt', 'Transformation Rules (xslt)', 'application/xml'),
|
||||||
('transformation_rule_legacy', 'Transformation Rules (legacy)', 'text/plain'),
|
('transformation_rule_legacy', 'Transformation Rules (legacy)', 'text/plain'),
|
||||||
('cleaning_rule', 'Cleaning Rules', 'application/xml'),
|
('cleaning_rule', 'Cleaning Rules', 'application/xml'),
|
||||||
('hadoop_job_configuration', 'Hadoop Job Configurations', 'application/xml');
|
('hadoop_job_configuration', 'Hadoop Job Configurations', 'application/xml')
|
||||||
|
('dedup_configuration', 'Dedup Configurations', 'application/json');
|
||||||
|
|
||||||
CREATE TABLE resources (
|
CREATE TABLE resources (
|
||||||
id text PRIMARY KEY,
|
id text PRIMARY KEY,
|
||||||
|
|
Loading…
Reference in New Issue