Codota Logo
SharedFongoResource
Code IndexAdd Codota to your IDE (free)

How to use
SharedFongoResource
in
uk.gov.dstl.baleen.resources

Best Java code snippets using uk.gov.dstl.baleen.resources.SharedFongoResource (Showing top 16 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: dstl/baleen

 private void createContent(SharedFongoResource sfr) {
  MongoDatabase db = sfr.getDB();

  MongoCollection<Document> coll = db.getCollection(COLLECTION);
  coll.insertMany(
    Arrays.asList(
      new Document(CONTENT, "Hello World"),
      new Document(CONTENT, "Hello Test"),
      new Document(CONTENT, TEXT)
        .append("key1", "foo")
        .append("key2", "bar")
        .append("key3", Arrays.asList("howdy", "hey"))));
 }
}
origin: dstl/baleen

@BeforeClass
public static void beforeClass() throws ResourceInitializationException {
 sfr = new SharedFongoResource();
 MongoDatabase db = sfr.getDB();
 MongoCollection<Document> coll = db.getCollection("gazetteer");
 coll.insertMany(
   Arrays.asList(
     new Document(VALUE, EN_HELLO2),
     new Document(VALUE, Arrays.asList("hi", EN_HELLO, "heya")),
     new Document(VALUE, Arrays.asList("konnichiwa", JP_HELLO)).append(LANGUAGE, "jp"),
     new Document(VALUE, Arrays.asList(DE_HELLO))
       .append(LANGUAGE, "de")
       .append(TRANSLATION, "good day"),
     new Document(VALUE, Arrays.asList("hej")).append(LANGUAGE, "se")));
}
origin: dstl/baleen

@Before
public void setUp() throws ResourceInitializationException {
 fongo = new SharedFongoResource();
 history = new MongoHistory(fongo);
 history.initialize(new CustomResourceSpecifier_impl(), Maps.newHashMap());
 history.afterResourcesInitialized();
}
origin: dstl/baleen

 fongo.getDatabase(BALEEN).getCollection(fongoCollection).insertOne(data);
} else {
 getMonitor().error("Unsupported type");
 throw new ResourceInitializationException();
origin: dstl/baleen

@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");
}
origin: dstl/baleen

 @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);
 }
}
origin: dstl/baleen

 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());
 }
}
origin: dstl/baleen

history = (BaleenHistory) ae.getUimaContext().getResourceObject(PipelineBuilder.BALEEN_HISTORY);
entities = sfr.getDB().getCollection("entities");
documents = sfr.getDB().getCollection("documents");
relations = sfr.getDB().getCollection("relations");
origin: dstl/baleen

@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());
}
origin: dstl/baleen

@Test
public void testMalformedDocuments() {
 MongoCollection<Document> collection = fongo.getDB().getCollection(HISTORY2);
origin: dstl/baleen

  (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO);
final MongoDatabase db = sfr.getDB();
documentCollection = db.getCollection(Mongo.DEFAULT_DOCUMENTS_COLLECTION);
entityCollection = db.getCollection(Mongo.DEFAULT_ENTITY_COLLECTION);
origin: dstl/baleen

  (SharedFongoResource)
    ae.getUimaContext().getResourceObject(SharedMongoResource.RESOURCE_KEY);
patternsCollection = sfr.getDB().getCollection(RENOUN_PATTERNS);
scoredFactsCollection = sfr.getDB().getCollection(RENOUN_SCORED_FACTS);
origin: dstl/baleen

facts = sfr.getDB().getCollection(RENOUN_FACTS);
origin: dstl/baleen

try {
 sfr = (SharedFongoResource) ae.getUimaContext().getResourceObject(MONGO);
 output = sfr.getDB().getCollection("renoun_patterns");
} catch (ResourceAccessException e) {
 throw new ResourceInitializationException(e);
origin: dstl/baleen

final MongoCollection<Document> collection = sfr.getDB().getCollection("test");
Assert.assertEquals(1, collection.count());
origin: dstl/baleen

final MongoCollection<Document> collection = sfr.getDB().getCollection("test");
Assert.assertEquals(1, collection.count());
uk.gov.dstl.baleen.resourcesSharedFongoResource

Javadoc

Fake Mongo (fongo) for unit testing.

Match fongo.collection to the collection your annotator (other) is expecting. Provide fixture data as fongo.data for example:

 
private static final List DATA = Lists.newArrayList( 
new Document("fake", "doc1"), 
new Document("fake", "doc2"), 
new Document("fake", "doc3")); 
ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription("mongo", 
SharedFongoResource.class, SharedFongoResource.PARAM_FONGO_COLLECTION, "documents", 
SharedFongoResource.PARAM_FONGO_DATA, JSON.serialize(DATA)); 

Most used methods

  • getDB
  • <init>
  • getMonitor

Popular in Java

  • Start an intent from android
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now