Project

General

Profile

« Previous | Next » 

Revision 4821643c

Added by Andreas Kohlbecker over 8 years ago

Store implementation using Neo4j and initial draft for a TinkerPop client

View differences:

src/main/java/org/bgbm/biovel/drf/checklist/EEA_BDC_Client.java
1 1
package org.bgbm.biovel.drf.checklist;
2 2

  
3
import java.io.IOException;
4 3
import java.net.URI;
5
import java.util.ArrayList;
6 4
import java.util.EnumSet;
7 5
import java.util.List;
8 6
import java.util.NoSuchElementException;
......
13 11
import org.apache.jena.rdf.model.Resource;
14 12
import org.apache.jena.rdf.model.StmtIterator;
15 13
import org.bgbm.biovel.drf.client.ServiceProviderInfo;
14
import org.bgbm.biovel.drf.query.IQueryClient;
16 15
import org.bgbm.biovel.drf.query.SparqlClient;
17
import org.bgbm.biovel.drf.store.TripleStore;
16
import org.bgbm.biovel.drf.query.TinkerPopClient;
17
import org.bgbm.biovel.drf.store.Neo4jStore;
18
import org.bgbm.biovel.drf.store.TDBStore;
18 19
import org.bgbm.biovel.drf.tnr.msg.Classification;
19 20
import org.bgbm.biovel.drf.tnr.msg.NameType;
20 21
import org.bgbm.biovel.drf.tnr.msg.Query;
......
29 30
import org.bgbm.biovel.drf.utils.IdentifierUtils;
30 31
import org.bgbm.biovel.drf.utils.TnrMsgUtils;
31 32

  
32
public class EEA_BDC_Client extends AggregateChecklistClient<SparqlClient> {
33
public class EEA_BDC_Client extends AggregateChecklistClient<TinkerPopClient> {
33 34

  
34 35
    /**
35 36
     *
......
40 41
    public static final String COPYRIGHT_URL = "http://www.eea.europa.eu/legal/eea-data-policy";
41 42
    private static final String SPARQL_ENDPOINT_URL = "http://semantic.eea.europa.eu/sparql";
42 43
    private static final String RDF_FILE_URL = "http://localhost/download/species.rdf.gz"; // http://eunis.eea.europa.eu/rdf/species.rdf.gz
43
    private static final boolean USE_REMOTE_SERVICE = true;
44
    private static final boolean REFRESH_TDB = true;
44
    private static final boolean USE_REMOTE_SERVICE = false;
45
    private static final boolean REFRESH_TDB = false;
46
    private static final Class<? extends IQueryClient> clientClass = TinkerPopClient.class;
45 47

  
46 48
    private static final int MAX_PAGING_LIMIT = 50;
47 49

  
......
118 120
    @Override
119 121
    public void initQueryClient() {
120 122

  
121
        if(USE_REMOTE_SERVICE) {
122
            // use SPARQL end point
123
            queryClient = new SparqlClient(SPARQL_ENDPOINT_URL);
124
        } else {
125
            TripleStore tripleStore = new TripleStore();
126
            if(REFRESH_TDB) {
127
                // use downloadable rdf
123
        if(SparqlClient.class.isAssignableFrom(clientClass)) {
124
            if(USE_REMOTE_SERVICE) {
125
                // use SPARQL end point
126
                //FIXME queryClient = new SparqlClient(SPARQL_ENDPOINT_URL);
127
            } else {
128
                TDBStore tripleStore;
128 129
                try {
129
                    tripleStore.loadIntoStore(RDF_FILE_URL);
130
                } catch (IOException e) {
131
                    logger.error("Loading " + RDF_FILE_URL + " into TripleStore failed",  e);
130
                    tripleStore = new TDBStore();
131
                } catch (Exception e1) {
132
                    throw new RuntimeException("Creation of TripleStore failed",  e1);
132 133
                }
134
                if(REFRESH_TDB) {
135
                    // use downloadable rdf
136
                    try {
137
                        tripleStore.loadIntoStore(RDF_FILE_URL);
138
                    } catch (Exception e) {
139
                        logger.error("Loading " + RDF_FILE_URL + " into TripleStore failed",  e);
140
                    }
141
                }
142
              //FIXME queryClient = new SparqlClient(tripleStore);
143

  
133 144
            }
134
            queryClient = new SparqlClient(tripleStore);
145
        } else if(TinkerPopClient.class.isAssignableFrom(clientClass)) {
146
            if(USE_REMOTE_SERVICE) {
147
                throw new RuntimeException("USE_REMOTE_SERVICE not suported by QueryClient class "+ clientClass);
148
            } else {
149
                Neo4jStore neo4jStore;
150
                try {
151
                    neo4jStore = new Neo4jStore();
152
                } catch (Exception e1) {
153
                    throw new RuntimeException("Creation of Neo4jStore failed",  e1);
154
                }
155
                if(REFRESH_TDB) {
156
                    // use downloadable rdf
157
                    try {
158
                        neo4jStore.loadIntoStore(RDF_FILE_URL);
159
                    } catch (Exception e) {
160
                        throw new RuntimeException("Loading " + RDF_FILE_URL + " into Neo4jStore failed",  e);
161
                    }
162
                }
163
                queryClient = new TinkerPopClient(neo4jStore);
135 164

  
165
            }
166

  
167
        } else {
168
            throw new RuntimeException("Unsuported QueryClient class "+ clientClass);
136 169
        }
137 170
    }
138 171

  
......
311 344
     * @return
312 345
     */
313 346
    private List<Resource> queryForSynonyms(Resource taxonR) {
314

  
347
 /* FIXME
315 348
        List<Resource> synonymRList = null;
316 349

  
317 350
        try {
......
332 365
        }
333 366

  
334 367
        return synonymRList;
335

  
368
*/ return null;
336 369
    }
337 370

  
338 371
    /**
......
377 410
                    );
378 411

  
379 412
            logger.debug("\n" + queryString.toString());
380

  
413
            /* FIXME
381 414
            Model model = queryClient.describe(queryString.toString());
382
            updateQueriesWithResponse(model, checklistInfo, query);
415
            updateQueriesWithResponse(model, checklistInfo, query); */
383 416
        }
384 417
    }
385 418

  
......
422 455
                    );
423 456

  
424 457
            logger.debug("\n" + queryString.toString());
425

  
458
 /* FIXME
426 459
            Model model = queryClient.describe(queryString.toString());
427
            updateQueriesWithResponse(model, checklistInfo, query);
460
            updateQueriesWithResponse(model, checklistInfo, query); */
428 461
        }
429 462

  
430 463
    }

Also available in: Unified diff