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 eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.is.resource.model.SimpleResource;
|
||||
import eu.dnetlib.is.vocabulary.model.Vocabulary;
|
||||
|
||||
@RestController
|
||||
|
@ -50,7 +49,7 @@ public class ImporterController extends AbstractDnetController {
|
|||
@PostMapping(value = "/resource", consumes = {
|
||||
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);
|
||||
return oldProfilesImporter.importSimpleResource(xml);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class OldProfilesImporter {
|
|||
private VocabularyTermRepository vocabularyTermRepository;
|
||||
|
||||
@Transactional
|
||||
public SimpleResource importSimpleResource(final String xml) throws InformationServiceException {
|
||||
public String importSimpleResource(final String xml) throws InformationServiceException {
|
||||
final SAXReader reader = new SAXReader();
|
||||
|
||||
try {
|
||||
|
@ -83,14 +83,20 @@ public class OldProfilesImporter {
|
|||
res.setDescription(doc.valueOf("//HADOOP_JOB/DESCRIPTION"));
|
||||
resContent = doc.selectSingleNode("//HADOOP_JOB").asXML();
|
||||
break;
|
||||
case "DedupConfigurationDSResourceType":
|
||||
res.setType("dedup_configuration");
|
||||
res.setName(doc.valueOf("//DESCRIPTION"));
|
||||
res.setDescription(doc.valueOf("//DESCRIPTION"));
|
||||
resContent = doc.valueOf("//DEDUPLICATION");
|
||||
break;
|
||||
default:
|
||||
throw new InformationServiceException("Invalid resource type: " + doc.valueOf("//RESOURCE_TYPE/@value"));
|
||||
}
|
||||
|
||||
simpleResourceRepository.save(res);
|
||||
simpleResourceRepository.setContentById(id, resContent);
|
||||
simpleResourceRepository.setContentById(id, resContent.trim());
|
||||
|
||||
return res;
|
||||
return res.getId();
|
||||
} catch (final Exception e) {
|
||||
throw new InformationServiceException("Error parsing file", e);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,11 @@ app.controller('resourcesController', function($scope, $http) {
|
|||
$scope.tmpRes = angular.copy(r);
|
||||
$scope.tmpContent = "loading...";
|
||||
$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) {
|
||||
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_legacy', 'Transformation Rules (legacy)', 'text/plain'),
|
||||
('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 (
|
||||
id text PRIMARY KEY,
|
||||
|
|
Loading…
Reference in New Issue