Package de.metalcon.autocompleteServer.Helper

Examples of de.metalcon.autocompleteServer.Helper.SuggestTree$Node


    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServlet servlet = mock(HttpServlet.class);
    when(this.servletConfig.getServletContext()).thenReturn(
        this.servletContext);

    SuggestTree generalIndex = new SuggestTree(7);
    generalIndex.put("Metallica", 100, "Metallica");
    generalIndex.put("Megadeth", 99, "Metallica");
    generalIndex.put("Megaherz", 98, "Metallica");
    generalIndex.put("Meshuggah", 97, "Metallica");
    generalIndex.put("Menhir", 96, "Metallica");
    generalIndex.put("Meat Loaf", 95, "Metallica");
    generalIndex.put("Melechesh", 94, "Metallica");

    when(
        this.servletContext.getAttribute("indexName:"
            + ProtocolConstants.DEFAULT_INDEX_NAME)).thenReturn(
        generalIndex);

    SuggestTree venueIndex = new SuggestTree(7);
    venueIndex.put("Das Kult", 55, "http://www.daskult.de");
    venueIndex.put("Die Halle", 44, "http://www.diehalle-frankfurt.de");
    venueIndex.put("Die Mühle", 30, "http://www.die-muehle.net");
    venueIndex.put("Dreams", 30, "http://www.discothek-dreams.de");
    venueIndex.put("Dudelsack", 27, "http://www.dudelsack-bk.de");
    venueIndex.put("Das Haus", 25, "http://www.dashaus-lu.de/home.html");
    venueIndex.put("Druckluftkammer", 25, "http://www.druckluftkammer.de/");

    when(this.servletContext.getAttribute("indexName:" + "venueIndex"))
        .thenReturn(venueIndex);

    HashMap<String, String> imageIndex = new HashMap<String, String>();
View Full Code Here


    return this.suggestionComponents;
  }

  @Override
  public void run() {
    SuggestTree suggestTree = ContextListener.getIndex(
        this.suggestionComponents.getIndexName(), this.context);

    suggestTree.put(this.suggestionComponents.getSuggestString(),
        this.suggestionComponents.getWeight(),
        this.suggestionComponents.getKey());
    System.out.println(suggestTree.size());
    if (this.suggestionComponents.getImageBase64() != null) {
      HashMap<String, String> map = ContextListener
          .getImageIndex(this.context);
      map.put(this.suggestionComponents.getKey(),
          this.suggestionComponents.getImageBase64());
View Full Code Here

    Integer numItems = checkNumItems(request, response);
    String term = checkTerm(request, response);
    if (term == null) {
      return response;
    }
    SuggestTree index = checkIndexName(request, response, context);
    if (index == null) {
      response.addError(RetrieveStatusCodes.NO_INDEX_AVAILABLE);
      return response;
    }
    retrieveSuggestions(request, response, index, term, numItems);
View Full Code Here

   */
  private static SuggestTree checkIndexName(HttpServletRequest request,
      ProcessRetrieveResponse response, ServletContext context) {
    String indexName = request
        .getParameter(ProtocolConstants.INDEX_PARAMETER);
    SuggestTree index = null;
    // if no indexName Parameter was provided use the default index.
    if (indexName == null) {
      indexName = ProtocolConstants.DEFAULT_INDEX_NAME;
      response.addIndexWarning(RetrieveStatusCodes.NO_INDEX_GIVEN);
      index = ContextListener.getIndex(indexName, context);
View Full Code Here

  }

  @Test
  public void testServerInitialization() {
    SuggestTree suggestTree = new SuggestTree(
        ProtocolConstants.MAX_NUMBER_OF_SUGGESTIONS);

    HashMap<String, String> imageIndex = new HashMap<String, String>();

    try {
      FileInputStream saveFile = new FileInputStream("TestFile.save");
      ObjectInputStream restore = new ObjectInputStream(saveFile);

      while (true) {
        try {
          SuggestionComponents suggestTreeEntry = (SuggestionComponents) restore
              .readObject();
          suggestTree.put(suggestTreeEntry.getSuggestString(),
              suggestTreeEntry.getWeight(),
              suggestTreeEntry.getKey());
          imageIndex.put(suggestTreeEntry.getKey(),
              suggestTreeEntry.getImageBase64());
        } catch (EOFException e) {
          restore.close();
          break;
        }

      }

    } catch (IOException | ClassNotFoundException e1) {

      e1.printStackTrace();
      fail("Data could not be restored");

    }
    assertEquals(suggestTree.getBestSuggestions("test").getSuggestion(0),
        "testTerm");
    this.testFile.deleteOnExit();
  }
View Full Code Here

  // }
  // return resultList.toString();
  // }

  public static void initilizeSuggestTree(ServletContext context) {
    SuggestTree suggestTree = new SuggestTree(
        ProtocolConstants.MAX_NUMBER_OF_SUGGESTIONS);

    HashMap<String, String> imageIndex = new HashMap<String, String>();

    try {
      // FIXME change after debugging
      File saveFile = new File("/var/lib/tomcat/Database.save");

      if (saveFile.exists()) {

        FileInputStream fileInputStream = new FileInputStream(saveFile);

        ObjectInputStream restore = new ObjectInputStream(
            fileInputStream);

        while (true) {
          try {
            SuggestionComponents suggestTreeEntry = (SuggestionComponents) restore
                .readObject();
            suggestTree.put(suggestTreeEntry.getSuggestString(),
                suggestTreeEntry.getWeight(),
                suggestTreeEntry.getKey());
            imageIndex.put(suggestTreeEntry.getKey(),
                suggestTreeEntry.getImageBase64());
          } catch (EOFException e) {
View Full Code Here

    this.request = mock(HttpServletRequest.class);
    HttpServlet servlet = mock(HttpServlet.class);
    when(this.servletConfig.getServletContext()).thenReturn(
        this.servletContext);
    SuggestTree generalIndex = new SuggestTree(7);
    when(
        this.servletContext
            .getAttribute(ProtocolConstants.INDEX_PARAMETER
                + "testIndex")).thenReturn(generalIndex);
View Full Code Here

    // create list for SortContainers...
    final LinkedList<SortContainer> scl = new LinkedList<SortContainer>();

    // walk through children...
    for (int i = 0; i < node.jjtGetNumChildren(); ++i) {
      Node n = node.jjtGetChild(i); // get current child

      boolean desc = false; // set order ASC as default

      // current node is Order node...
      if (n instanceof ASTAscOrder || n instanceof ASTDescOrder) {
        if (n instanceof ASTDescOrder) // reset order value to DESC...
          desc = true;

        i++; // increase counter to get next child (which is sort
        // condition)
      }

      n = node.jjtGetChild(i); // get next child (which is sort condition)

      // parse node with the filter...
      final SPARQLParserVisitorImplementationDumper filterDumper = new SPARQLParserVisitorImplementationDumper();
      final String sortString = n.accept(filterDumper);

      try {
        final SortContainer sc = new SortContainer(this.prefix, desc,
            sortString); // create SortContainer
View Full Code Here

  @SuppressWarnings("unchecked")
  public Object visit(final ASTTripleSet node, final Object data) {
    final Item[] item = { null, null, null };

    for (int i = 0; i < 3; i++) {
      final Node n = node.jjtGetChild(i);
      item[i] = lupos.sparql1_1.operatorgraph.SPARQLCoreParserVisitorImplementation.getItem(n);
    }

    final HashMap<Item, QueryRDFTerm> rdfHash = (HashMap<Item, QueryRDFTerm>) data;
View Full Code Here

    // if AST exists...
    if (debugViewerCreator!=null && debugViewerCreator instanceof SPARQLDebugViewerCreator
        && ((SPARQLDebugViewerCreator) debugViewerCreator).getAST() != null) {

      final Node ast = ((SPARQLDebugViewerCreator) debugViewerCreator).getAST(); // get AST

      // walk through first level children of AST...
      for (int i = 0; i < ast.jjtGetNumChildren(); ++i) {
        final Node child = ast.jjtGetChild(i); // get current child

        if (child instanceof ASTSelectQuery) {
          final ASTSelectQuery selectChild = (ASTSelectQuery) child;

          // SELECT is not the wildcard *...
          if (!selectChild.isSelectAll()) {
            // walk through select children...
            for (int j = 0; j < selectChild.jjtGetNumChildren(); ++j) {
              final Node selectChildChild = selectChild
              .jjtGetChild(j);

              // child of select is variable...
              if (selectChildChild instanceof ASTVar) {
                final ASTVar var = (ASTVar) selectChildChild;

                // add name of variable to order...
                if (!resultOrder.contains(var.getName())) {
                  resultOrder.add(var.getName());
                }
              } else if (selectChildChild instanceof ASTAs) {
                for (int j1 = 0; j1 < selectChildChild
                .jjtGetNumChildren(); ++j1) {
                  final Node selectChildChildChild = selectChildChild
                  .jjtGetChild(j1);
                  if (selectChildChildChild instanceof ASTVar) {
                    final ASTVar var = (ASTVar) selectChildChildChild;

                    // add name of variable to order...
View Full Code Here

TOP

Related Classes of de.metalcon.autocompleteServer.Helper.SuggestTree$Node

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.