Package com.mockey.model

Examples of com.mockey.model.SearchResult


     
      // ******************************
      // SERVICE PLAN LIST
      // ******************************
      for (ServicePlan servicePlan : store.getServicePlans()) {
        SearchResult sr = buildSearchResult(term, servicePlan.getName() + " " + servicePlan.getTag());
        if (sr != null) {
          sr.setType(SearchResultType.SERVICE_PLAN);
          sr.setServicePlanId("" + servicePlan.getId());
          sr.setServicePlanName(servicePlan.getName());
          searchResultList.add(sr);
        }
      }
     
      // ******************************
      // SERVICE LIST
      // ******************************
      for (Service service : store.getServices()) {

        boolean serviceAdded = false;
        SearchResult sr = buildSearchResult(term,
            service.getServiceName() + " " +service.getTag() + " ");
        if (sr != null) {
          sr.setType(SearchResultType.SERVICE);
          sr.setServiceId("" + service.getId());
          searchResultList.add(sr);
          serviceAdded = true;
        }

        if (!serviceAdded) {
          // No match; lets check RealServiceUrls
          for (Url url : service.getRealServiceUrls()) {
            SearchResult subresult = buildSearchResult(term,
                url.toString());
            if (subresult != null) {
              subresult.setType(SearchResultType.SERVICE);
              subresult.setServiceId("" + service.getId());
              searchResultList.add(subresult);
              serviceAdded = true;
              break;
            }
          }
        }

        if (!serviceAdded) {
          // No match; lets check RealServiceUrls
          String mockurl = service.getUrl();
          SearchResult subresult = buildSearchResult(term, mockurl);
          if (subresult != null) {
            subresult.setType(SearchResultType.SERVICE);
            subresult.setServiceId("" + service.getId());
            searchResultList.add(subresult);
            serviceAdded = true;

          }

        }

        // *****************************
        // SERVICE SCENARIO
        // ****************************
        // REGARDLESS of Service being added, let's see if there is a
        // matching scenario by Scenario RESPONSE
        for (Scenario scenario : service.getScenarios()) {
          // Append tags, name, and response...
          // Why not? It's a hack to jumble all things together
          SearchResult subresult = buildSearchResult(
              term,
              scenario.getResponseMessage() + " "
                  + scenario.getScenarioName() + " "
                  + scenario.getTag());

          if (subresult != null) {
            subresult.setType(SearchResultType.SERVICE_SCENARIO);
            subresult.setServiceId("" + service.getId());
            subresult.setScenarioId("" + scenario.getId());
            subresult.setScenarioName(scenario.getScenarioName());
            searchResultList.add(subresult);
          }
        }

      }
View Full Code Here


    return searchResultList;
  }

  private SearchResult buildSearchResult(String term, String content) {

    SearchResult result = null;
    if (term != null && content != null) {
      int index = content.trim().toLowerCase().indexOf(term.trim().toLowerCase());
      if (index > -1) {
        result = new SearchResult();

        String teaserContent = content.substring(index);

        if (teaserContent.length() > 150) {
          teaserContent.substring(0, 148);

        }
        result.setContent(teaserContent);

      }

    }
    return result;
View Full Code Here

TOP

Related Classes of com.mockey.model.SearchResult

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.