@Override public UimaContext getUimaContext() { return ae.getUimaContext(); }
/** * Create a new UimaContext with the given configuration parameters set. * * @param configurationParameters * The parameters to be set. * @return The new UimaContext. * @throws ResourceInitializationException * If the context could not be created. */ public static UimaContext createUimaContext(Object... configurationParameters) throws ResourceInitializationException { AnalysisEngine engine = AnalysisEngineFactory.createEngine(NoOpAnnotator.class, null, configurationParameters); return engine.getUimaContext(); }
@Before public void beforeMongoRecordConsumerTest() throws ResourceInitializationException, ResourceAccessException { mongoExternalResourceDescription = ExternalResourceFactory.createExternalResourceDescription( MONGO, SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]"); analysisEngine = getAnalysisEngine("mongo", mongoExternalResourceDescription, "collection", "test"); SharedFongoResource sfr = (SharedFongoResource) analysisEngine.getUimaContext().getResourceObject(MONGO); recordsCollection = sfr.getDB().getCollection("records"); }
@Before public void setUp() throws ResourceInitializationException, ResourceAccessException { // Create a description of an external resource - a fongo instance, in the same way we would // have created a shared mongo resource final ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription( SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]"); // Create the analysis engine final AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription( MongoPatternSaver.class, MongoPatternSaver.KEY_MONGO, erd, "collection", "test"); ae = AnalysisEngineFactory.createEngine(aed); ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MongoPatternSaver.KEY_MONGO); }
private void createAnalysisEngine(String textBlockType) throws ResourceInitializationException, ResourceAccessException { AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription( MongoEvents.class, MONGO, erd, "collection", "test", MongoEvents.PARAM_TEXT_BLOCK_EXTRACTED_FROM, textBlockType, MongoEvents.PARAM_OUTPUT_HISTORY, true); ae = AnalysisEngineFactory.createEngine(aed); ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); events = sfr.getDB().getCollection("test"); assertEquals(0L, events.count()); } }
@Test public void test() throws ResourceInitializationException, AnalysisEngineProcessException, IOException, ResourceAccessException { final File file = File.createTempFile("test", "uimt"); Files.asCharSink(file, StandardCharsets.UTF_8) .write("Type,SubType\nMOVEMENT,went,source,target,went,VERB,gone"); final AnalysisEngine ae = create(UploadInteractionsToMongo.class, "mongo", fongoErd, "input", file); execute(ae); final SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject("mongo"); final MongoCollection<Document> relationTypes = sfr.getDB().getCollection("relationTypes"); assertTrue(relationTypes.count() > 0); final MongoCollection<Document> interactions = sfr.getDB().getCollection("interactions"); assertTrue(interactions.count() > 0); } }
@Before public void setUp() throws ResourceInitializationException, ResourceAccessException { // Create a description of an external resource - a fongo instance, in the same way we would // have created a shared mongo resource ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription( MONGO, SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]"); // Create the analysis engine AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription( MongoRelations.class, MONGO, erd, "collection", "test"); ae = AnalysisEngineFactory.createEngine(aed); ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); relations = sfr.getDB().getCollection("test"); // Ensure we start with no data! assertEquals(0L, relations.count()); }
ae = AnalysisEngineFactory.createEngine(aed); ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); history = (BaleenHistory) ae.getUimaContext().getResourceObject(PipelineBuilder.BALEEN_HISTORY);
ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap()); final SharedFongoResource sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO);
sfr = (SharedFongoResource) analysisEngine.getUimaContext().getResourceObject(MONGO); } catch (ResourceAccessException e) { throw new ResourceInitializationException();
ae.getUimaContext().getResourceObject(SharedMongoResource.RESOURCE_KEY); patternsCollection = sfr.getDB().getCollection(RENOUN_PATTERNS); scoredFactsCollection = sfr.getDB().getCollection(RENOUN_SCORED_FACTS);
sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO); output = sfr.getDB().getCollection("renoun_patterns"); } catch (ResourceAccessException e) {