コード例 #1
0
ファイル: StoredAdDBTest.java プロジェクト: dhaube/AdServing
  /** @param args */
  public static void main(String[] args) throws IOException {
    AdDBManager.getInstance().getContext().useRamOnly = false;
    AdDBManager.getInstance().getContext().datadir = "D:/www/applicationData/adserver/temp/";
    AdDBManager.getInstance().getAdDB().open();

    ImageAdDefinition ib = new ImageAdDefinition();
    ib.setFormat(new MediumRectangleAdFormat());
    ib.setId("1");
    AdDBManager.getInstance().getAdDB().addBanner(ib);

    ib = new ImageAdDefinition();
    ib.setFormat(new MediumRectangleAdFormat());
    ib.setId("2");
    AdDBManager.getInstance().getAdDB().addBanner(ib);

    AdDBManager.getInstance().getAdDB().reopen();

    AdRequest request = new AdRequest();
    request.getFormats().add(new MediumRectangleAdFormat());
    request.getTypes().add(AdTypes.forName(ImageAdType.TYPE));

    List<AdDefinition> result = AdDBManager.getInstance().getAdDB().search(request);

    System.out.println(result.size());

    AdDBManager.getInstance().getAdDB().close();
  }
コード例 #2
0
  @Override
  public void addQuery(AdRequest request, BooleanQuery mainQuery) {
    if (request.getSite() == null) {
      return;
    }

    BooleanQuery query = new BooleanQuery();

    BooleanQuery temp = new BooleanQuery();

    // Seite einfügen
    temp.add(
        new TermQuery(new Term(AdDBConstants.ADDB_AD_SITE_EXCLUDE, request.getSite())),
        Occur.SHOULD);

    query.add(temp, Occur.MUST);
    mainQuery.add(query, Occur.MUST_NOT);
    //
    //		System.out.println(mainQuery.toString());
  }
コード例 #3
0
ファイル: ConditionHelper.java プロジェクト: dhaube/AdServing
  /**
   * Führt alle definierten Filter auf das Ergebnis der Bannersuche aus
   *
   * @param request
   * @param banners
   * @return
   */
  public List<AdDefinition> processFilter(AdRequest request, List<AdDefinition> banners) {
    if (!request.hasConditions()) {
      return banners;
    }

    Collection<AdDefinition> bcol = new ArrayList<AdDefinition>();
    bcol.addAll(banners);
    for (Condition condition : AdDBManager.getInstance().getConditions()) {
      if (Filter.class.isInstance(condition) && !banners.isEmpty()) {
        bcol =
            (Collection<AdDefinition>)
                Collections2.filter(bcol, ((Filter) condition).getFilterPredicate(request));
      }
    }
    banners.clear();
    banners.addAll(bcol);
    return banners;
  }