use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.
the class AbstractEmbeddedTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
clearDb();
this.keyValueStore = new GraphKeyValueStore(getDatabase());
}
use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.
the class DynamicConfigurationTest method testWorfklowItemsInfosShouldBeLoadedFromPreviousState.
@Test
public void testWorfklowItemsInfosShouldBeLoadedFromPreviousState() throws Exception {
resetSingleton();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
keyValueStore = new GraphKeyValueStore(getDatabase());
QueryBasedWorkflowInput workflowInput = new QueryBasedWorkflowInput("test", getDatabase());
DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
workflowInput.setConfiguration(new WorkflowInputQueryConfiguration(new HashMap<>()));
try (Transaction tx = getDatabase().beginTx()) {
configuration.storeWorkflowInstanceItem(workflowInput);
tx.success();
}
GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
runtime.start();
runtime.waitUntilStarted();
}
use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.
the class DynamicConfigurationTest method testConfigurationValuesShouldBeLoadedFromPreviousState.
@Test
public void testConfigurationValuesShouldBeLoadedFromPreviousState() throws Exception {
resetSingleton();
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
keyValueStore = new GraphKeyValueStore(getDatabase());
PipelineSpecification specification = new PipelineSpecification("custom", StubTextProcessor.class.getName());
specification.setStopWords("hello,hihi");
specification.setThreadNumber(4);
try (Transaction tx = getDatabase().beginTx()) {
String writeValueAsString = mapper.writeValueAsString(specification);
keyValueStore.set("GA__NLP__PIPELINE_custom", writeValueAsString);
keyValueStore.set("GA__NLP__SETTING_fallbackLanguage", "en");
tx.success();
}
GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
runtime.start();
runtime.waitUntilStarted();
assertTrue(getStartedRuntime(getDatabase()).getModule(NLPModule.class).getNlpManager().getTextProcessorsManager().getTextProcessor(StubTextProcessor.class.getName()).getPipelines().contains("custom"));
assertTrue(getStartedRuntime(getDatabase()).getModule(NLPModule.class).getNlpManager().getConfiguration().hasSettingValue(SettingsConstants.FALLBACK_LANGUAGE));
}
use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.
the class DynamicConfigurationTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
clearDb();
this.keyValueStore = new GraphKeyValueStore(getDatabase());
}
use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.
the class DynamicConfigurationTest method testLoadingInstances.
@Test
public void testLoadingInstances() throws Exception {
resetSingleton();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
keyValueStore = new GraphKeyValueStore(getDatabase());
WorkflowTask workflowInput = new WorkflowTask("test", getDatabase());
DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
HashMap<String, Object> properties = new HashMap<>();
properties.put(WorkflowTaskConfiguration.WORFKLOW_INPUT_NAME, "");
properties.put(WorkflowTaskConfiguration.WORFKLOW_OUTPUT_NAME, "");
properties.put(WorkflowTaskConfiguration.WORFKLOW_PROCESSOR_NAME, "");
workflowInput.setConfiguration(new WorkflowTaskConfiguration(properties));
try (Transaction tx = getDatabase().beginTx()) {
configuration.storeWorkflowInstanceItem(workflowInput);
tx.success();
}
List<WorkflowInstanceItemInfo> pipelineInstanceItems = configuration.loadWorkflowInstanceItems(WorkflowTask.WORFKLOW_TASK_KEY_PREFIX);
assertTrue(pipelineInstanceItems.size() == 1);
WorkflowInstanceItemInfo info = pipelineInstanceItems.get(0);
assertTrue(info instanceof WorkflowTaskInstanceItemInfo);
assertEquals("test", info.getName());
assertEquals("com.graphaware.nlp.workflow.task.WorkflowTask", info.getClassName());
}
Aggregations