1
|
package eu.dnetlib.utils.ontologies;
|
2
|
|
3
|
import javax.annotation.PostConstruct;
|
4
|
|
5
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
6
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
7
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
8
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
import org.springframework.stereotype.Component;
|
10
|
|
11
|
/**
|
12
|
* Created by claudio on 12/12/2016.
|
13
|
*/
|
14
|
@Component
|
15
|
public class OntologyLoader {
|
16
|
|
17
|
private static UniqueServiceLocator staticServiceLocator;
|
18
|
|
19
|
@Autowired
|
20
|
private UniqueServiceLocator serviceLocator;
|
21
|
|
22
|
// <TERM code="merges" encoding="organizationOrganization_dedup_merges" english_name="merges" native_name="merges">
|
23
|
public static String fetchInverse(final String relType) throws ISLookUpException {
|
24
|
final String xquery = "let $x:= /RESOURCE_PROFILE["
|
25
|
+ " .//RESOURCE_TYPE/@value = 'OntologyDSResourceType' and "
|
26
|
+ " .//TERM/@encoding='"+relType+"']"
|
27
|
+ "let $y:= $x//TERM[./@encoding='"+relType+"']//RELATION[./@type='inverseOf']/@code/string() "
|
28
|
+ "return $x//TERM[./@code = $y]/@encoding/string()";
|
29
|
return staticServiceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
|
30
|
}
|
31
|
|
32
|
@PostConstruct
|
33
|
public void init() {
|
34
|
OntologyLoader.staticServiceLocator = serviceLocator;
|
35
|
}
|
36
|
|
37
|
}
|