Example #1
0
  @Override
  public void addFields(Document bannerDoc, AdDefinition bannerDefinition) {

    KeywordConditionDefinition kdef = null;
    if (bannerDefinition.hasConditionDefinition(ConditionDefinitions.KEYWORD)) {
      kdef =
          (KeywordConditionDefinition)
              bannerDefinition.getConditionDefinition(ConditionDefinitions.KEYWORD);
    }

    if (kdef != null && kdef.getKeywords().size() > 0) {
      // keywords im Dokument speichern
      List<Keyword> kws = kdef.getKeywords();
      for (Keyword k : kws) {
        bannerDoc.add(new StringField(AdDBConstants.ADDB_AD_KEYWORD, k.word, Field.Store.NO));
      }
    } else {
      /*
       * für alle Banner ohne angegebenem Keyword wird das default ALL-Keyword gesetzt
       */
      bannerDoc.add(
          new StringField(
              AdDBConstants.ADDB_AD_KEYWORD, AdDBConstants.ADDB_AD_KEYWORD_ALL, Field.Store.NO));
    }
  }
Example #2
0
  @Override
  public void addFields(BasicDBObject bannerDoc, AdDefinition bannerDefinition) {

    DateConditionDefinition ddef = null;
    if (bannerDefinition.hasConditionDefinition(ConditionDefinitions.DATE)) {
      ddef =
          (DateConditionDefinition)
              bannerDefinition.getConditionDefinition(ConditionDefinitions.DATE);
    }

    if (ddef != null && !ddef.getPeriods().isEmpty()) {
      /*
       * 	Um die Paare von/zu der Perioden zu erhalten, werden die jeweilige Felder geprefixt.
       *  Dadurch können bei der Suche die einzelnen Perioden unterschieden werden
       */
      int count = 0;
      for (Period p : ddef.getPeriods()) {
        if (p.getFrom() != null) {
          bannerDoc.put(AdDBConstants.ADDB_AD_DATE_FROM + count, p.getFrom());
        } else {
          bannerDoc.put(AdDBConstants.ADDB_AD_DATE_FROM + count, AdDBConstants.ADDB_AD_DATE_ALL);
        }

        if (p.getTo() != null) {
          bannerDoc.put(AdDBConstants.ADDB_AD_DATE_TO + count, p.getTo());
        } else {
          bannerDoc.put(AdDBConstants.ADDB_AD_DATE_TO + count, AdDBConstants.ADDB_AD_DATE_ALL);
        }
        count++;
      }
      //			for (; count < DateConditionDefinition.MAX_PERIOD_COUNT; count++) {
      //				bannerDoc.put(AdDBConstants.ADDB_AD_DATE_FROM + count, AdDBConstants.ADDB_AD_DATE_ALL);
      //				bannerDoc.put(AdDBConstants.ADDB_AD_DATE_TO + count, AdDBConstants.ADDB_AD_DATE_ALL);
      //			}
    } else {
      bannerDoc.put(AdDBConstants.ADDB_AD_DATE_FROM + 0, AdDBConstants.ADDB_AD_DATE_ALL);
      bannerDoc.put(AdDBConstants.ADDB_AD_DATE_TO + 0, AdDBConstants.ADDB_AD_DATE_ALL);
    }
  }
Example #3
0
  @Override
  public void addFields(BasicDBObject bannerDoc, AdDefinition bannerDefinition) {
    DayConditionDefinition ddef = null;

    if (bannerDefinition.hasConditionDefinition(ConditionDefinitions.DAY)) {
      ddef =
          (DayConditionDefinition)
              bannerDefinition.getConditionDefinition(ConditionDefinitions.DAY);
    }

    if (ddef != null && ddef.getDays().size() > 0) {
      List<Day> list = ddef.getDays();
      List<String> days = new ArrayList<String>();
      for (Day day : list) {
        days.add(String.valueOf(day.getDay()));
      }
      bannerDoc.put(AdDBConstants.ADDB_AD_DAY, days);
    } else {
      List<String> days = new ArrayList<String>();
      days.add(AdDBConstants.ADDB_AD_DAY_ALL);
      bannerDoc.put(AdDBConstants.ADDB_AD_DAY, days);
    }
  }