Package com.findwise.hydra.local

Examples of com.findwise.hydra.local.LocalDocument


            return;
        }

        DatabaseDocument<T> md;
        try {
            md = io.convert(new LocalDocument(requestContent));
        } catch (JsonException e) {
            HttpResponseWriter.printJsonException(response, e);
            return;
        } catch (ConversionException e) {
            logger.error("Caught Exception when trying to convert "+requestContent, e);
View Full Code Here


    client = node.client();

    stage = new ElasticsearchOutputStage();
    stage.setClient(client);

    addDocument = new LocalDocument();
    addDocument.setAction(Action.ADD);
    addDocument.putContentField(stage.getIdField(), "document");
    addDocument.putContentField("field", "value");
   
    deleteDocument = new LocalDocument();
    deleteDocument.setAction(Action.DELETE);
    deleteDocument.putContentField(stage.getIdField(), "document");
    deleteDocument.putContentField("field", "value");
  }
View Full Code Here

   @Before
  public void setUp() { 
    jsoup = new JsoupSelector();
    jsoup.setHtmlField("rawcontent");

    doc = new LocalDocument();
    doc.putContentField("rawcontent", "<html><head><link href=\"http://www.findwise.com\" rel=\"canonical\"></head><body><h1 class=\"BIG\">h1 #1</h1><h1>h1 #2</h1><h2>h2 #1</h2><h2>h2 #2</h2></body></html>");
   
    Map<String, String> config1 = new HashMap<String, String>();
    config1.put("selector", "h1");
    config1.put("fieldname", "h1");
View Full Code Here

  }
 
  @Test
  public void testUnavaiablefield() throws Exception {
   
    jsoup.process(new LocalDocument());
    assertNull(doc.getContentField("extracted_text"));
    assertNull(doc.getContentField("h1"));
    assertNull(doc.getContentField("h2"));
  }
View Full Code Here

  }

  @Override
  public void run() throws Exception {
    while (isRunning()) {
      LocalDocument doc = fetch();
      if (doc == null) {
        Thread.sleep(holdInterval);
      } else {
        stageRunner.performProcessing(doc);
      }
View Full Code Here

   @Before
  public void setUp() { 
    jsoup = new JsoupAttrSelector();
    jsoup.setHtmlField("rawcontent");

    doc = new LocalDocument();
    doc.putContentField("rawcontent", "<html><head><link href=\"http://www.findwise.com\" rel=\"canonical\"></head><body><h1 class=\"BIG\">h1 #1</h1><h1>h1 #2</h1><h2>h2 #1</h2><h2>h2 #2</h2></body></html>");
   
    Map<String, String> config1 = new HashMap<String, String>();
    config1.put("selector", "h1");
    config1.put("attribute", "class");
View Full Code Here

 
 
  @Test
  public void testUnavailablefield() throws Exception {
   
    jsoup.process(new LocalDocument());
                assertNull(doc.getContentField("h1-class"));
                assertNull(doc.getContentField("canonical-link"));
                assertNull(doc.getContentField("alllinks"));
  }
View Full Code Here

        List<String> inputFields = new LinkedList<String>();
        inputFields.add("html");
        inputFields.add("body");
        instance.setFields(inputFields);

    LocalDocument ld = new LocalDocument();
   
    instance.init();
    instance.process(ld);

    //Only really want to test that it doesn't throw a nullpointer when inputfields are empty
    Assert.assertFalse(htmlString.equals(ld.getContentField("html")));
    Assert.assertFalse(htmlString.equals(ld.getContentField("body")));
  }
View Full Code Here

        List<String> inputFields = new LinkedList<String>();
        inputFields.add("html");
        inputFields.add("body");
        instance.setFields(inputFields);

    LocalDocument ld = new LocalDocument();
   
   
    ld.putContentField("html", htmlString);
    ld.putContentField("body", htmlString);

    Assert.assertEquals(htmlString, ld.getContentField("html"));
    Assert.assertEquals(htmlString, ld.getContentField("body"));

    instance.init();
    instance.process(ld);

    Assert.assertFalse(htmlString.equals(ld.getContentField("html")));
    Assert.assertFalse(htmlString.equals(ld.getContentField("body")));
  }
View Full Code Here

    MergeFieldsStage mfs = new MergeFieldsStage();
    mfs.setOutputField("out");
    mfs.setAdditionIfNumbers(true);
    mfs.setFromFields(Arrays.asList("in1", "in2", "in3"));

    LocalDocument doc = new LocalDocument();
    doc.putContentField("in1", 1);
    doc.putContentField("in2", 2);
    doc.putContentField("in3", 5);

    LocalDocument doc2 = new LocalDocument(doc);
    mfs.process(doc2);
   
    Assert.assertEquals(1+2+5, doc2.getContentField("out"));
  }
View Full Code Here

TOP

Related Classes of com.findwise.hydra.local.LocalDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.