Revision 2658
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/repository/KnowledgeRepositoryManager.java (revision 2658) | ||
---|---|---|
26 | 26 |
public class KnowledgeRepositoryManager extends DatabasePersistenceManager { |
27 | 27 |
|
28 | 28 |
// private static KnowledgeRepositoryManager INSTANCE = null; |
29 |
private static HashMap<String, KnowledgeRepository> repositories = new HashMap<String, KnowledgeRepository>();
|
|
29 |
private static HashMap<String, KnowledgeRepository> repositories = new HashMap<>(); |
|
30 | 30 |
|
31 | 31 |
// public static KnowledgeRepositoryManager getInstance(){ |
32 | 32 |
// if (INSTANCE == null) { |
... | ... | |
123 | 123 |
return repositories.values().toArray(new KnowledgeRepository[repositories.size()]); |
124 | 124 |
} |
125 | 125 |
|
126 |
/** |
|
127 |
* Creates&Registerd a simple KR with a given name |
|
128 |
* |
|
129 |
* @param name |
|
130 |
* @return a KR. If the KR already exists returns the KR |
|
131 |
*/ |
|
132 |
public static KnowledgeRepository createSimpleKnowledgeRepository(String name) { |
|
133 |
if (getKnowledgeRepository(name) != null) { |
|
134 |
return getKnowledgeRepository(name); |
|
135 |
} |
|
136 |
|
|
137 |
HashMap<String, HashMap<String, ?>> conf = new HashMap<>(); |
|
138 |
HashMap<String, String> access = new HashMap<>(); |
|
139 |
conf.put(KRAnnotationEngine.KNOWLEDGE_ACCESS, access); |
|
140 |
HashMap<String, HashMap<String, String>> fields = new HashMap<>(); |
|
141 |
conf.put(KRAnnotationEngine.KNOWLEDGE_TYPES, fields); |
|
142 |
HashMap<String, HashMap<String, String>> strings = new HashMap<>(); |
|
143 |
conf.put(KRAnnotationEngine.KNOWLEDGE_STRINGS, strings); |
|
144 |
|
|
145 |
access.put("mode", DatabasePersistenceManager.ACCESS_FILE); //$NON-NLS-1$ |
|
146 |
access.put("version", "0"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
147 |
KnowledgeRepository currentKnowledgeRepository = KnowledgeRepositoryManager.createKnowledgeRepository(name, conf); |
|
148 |
KnowledgeRepositoryManager.registerKnowledgeRepository(currentKnowledgeRepository); |
|
149 |
// KRAnnotationEngine.registerKnowledgeRepositoryName(corpus, corpus.getMainCorpus().getName()); |
|
150 |
return currentKnowledgeRepository; |
|
151 |
} |
|
152 |
|
|
126 | 153 |
public static KnowledgeRepository getKnowledgeRepository(String name) { |
127 | 154 |
KnowledgeRepository kr = null; |
128 | 155 |
File krconf = new File(Toolbox.getTxmHomePath(), "repositories/" + name + "/conf.xml"); |
Also available in: Unified diff