1 | package org.biohackathon.SPARQLBuilder.OWL;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | import java.util.HashMap;
|
---|
5 | import java.util.Map;
|
---|
6 |
|
---|
7 | import jp.riken.accc.db.rdf.crawler.dataStructure.sparql.JenaModelGenerator;
|
---|
8 |
|
---|
9 | public class RDFSchemaAnalyzerFactory {
|
---|
10 |
|
---|
11 | private Map<String, String> acquiredRDFFiles = null;
|
---|
12 |
|
---|
13 | public void setAcqiredRDFFiles(File data){
|
---|
14 | if( data.isDirectory() ){
|
---|
15 | // read files
|
---|
16 | File[] files = data.listFiles();
|
---|
17 | acquiredRDFFiles = new HashMap<String, String>();
|
---|
18 | for(File file: files){
|
---|
19 | String uri = null;
|
---|
20 | try{
|
---|
21 | JenaModelGenerator jmGene = new JenaModelGenerator(file.getAbsolutePath());
|
---|
22 | uri = jmGene.getEndpointURI();
|
---|
23 | }catch(Exception ex){
|
---|
24 | //
|
---|
25 | }
|
---|
26 | if( uri != null ){
|
---|
27 | acquiredRDFFiles.put(uri, data.getAbsolutePath());
|
---|
28 | }
|
---|
29 | }
|
---|
30 | }else{
|
---|
31 | if( data.isFile() ){
|
---|
32 | String uri = null;
|
---|
33 | try{
|
---|
34 | JenaModelGenerator jmGene = new JenaModelGenerator(data.getAbsolutePath());
|
---|
35 | uri = jmGene.getEndpointURI();
|
---|
36 | }catch(Exception ex){
|
---|
37 | //
|
---|
38 | }
|
---|
39 | if( uri != null ){
|
---|
40 | acquiredRDFFiles = new HashMap<String, String>();
|
---|
41 | acquiredRDFFiles.put(uri, data.getAbsolutePath());
|
---|
42 | }
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public RDFSchemaAnalyzer create(String uri) throws Exception{
|
---|
48 | if( acquiredRDFFiles == null || !acquiredRDFFiles.containsKey(uri)){
|
---|
49 | return new EndpointAnalyzer(uri);
|
---|
50 | }else{
|
---|
51 | JenaModelGenerator jmGene = new JenaModelGenerator(acquiredRDFFiles.get(uri));
|
---|
52 | return new AcquiredStructureAnalyzer(jmGene.getEndpointURI(), jmGene.getGraphURIs(), jmGene.getModel());
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 | }
|
---|