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 | private static final String FILENAME = "C:\\cdata";
|
---|
13 |
|
---|
14 | public RDFSchemaAnalyzerFactory(String fileName){
|
---|
15 | try{
|
---|
16 | setAcqiredRDFFiles(new File(fileName));
|
---|
17 | }catch(Exception e){
|
---|
18 | System.err.println(e);
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | public RDFSchemaAnalyzerFactory(){
|
---|
23 | try{
|
---|
24 | setAcqiredRDFFiles(new File(FILENAME));
|
---|
25 | }catch(Exception e){
|
---|
26 | System.err.println(e);
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | private void setAcqiredRDFFiles(String dirFile) throws Exception{
|
---|
31 | setAcqiredRDFFiles(new File(dirFile));
|
---|
32 | }
|
---|
33 |
|
---|
34 | private void setAcqiredRDFFiles(File data) throws Exception{
|
---|
35 | StructureCrawler sc = new StructureCrawler(data);
|
---|
36 | acquiredRDFFiles = sc.getAcquiredStructureFiles();
|
---|
37 | }
|
---|
38 |
|
---|
39 | public String[] getEndpointURIList(){
|
---|
40 | if( acquiredRDFFiles == null ){
|
---|
41 | return new String[0];
|
---|
42 | }else{
|
---|
43 | return acquiredRDFFiles.keySet().toArray(new String[0]);
|
---|
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 | }
|
---|