Project

General

Profile

Download (1.38 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package org.cybertaxonomy.utis.store;
11

    
12
import java.util.HashMap;
13
import java.util.Map;
14

    
15
import org.cybertaxonomy.utis.checklist.UpdatableStoreInfo;
16

    
17
/**
18
 * @author a.kohlbecker
19
 * @date Oct 29, 2015
20
 *
21
 */
22
public class Neo4jStoreManager {
23

    
24
    private final static Map<Class<? extends UpdatableStoreInfo>, Neo4jStore> storemap = new HashMap<Class<? extends UpdatableStoreInfo>, Neo4jStore>();
25

    
26
    public static Neo4jStore provideStoreFor(UpdatableStoreInfo storeClient) {
27
        if(!storemap.containsKey(storeClient.getClass())) {
28
            Neo4jStore neo4jStore;
29
            try {
30
                neo4jStore = new Neo4jStore();
31
                Neo4jStoreUpdater updater = new Neo4jStoreUpdater(neo4jStore, storeClient.getTestUrl());
32
                updater.addResources(storeClient.updatableResources());
33
                updater.watch(storeClient.pollIntervalMinutes());
34
            } catch (Exception e1) {
35
                throw new RuntimeException("Creation of Neo4jStore failed",  e1);
36
            }
37
            storemap.put(storeClient.getClass(), neo4jStore);
38
        }
39
        return storemap.get(storeClient.getClass());
40
    }
41

    
42
}
(2-2/5)