public void setScoringDefinition(Scoring scoring) {
    for (ScoringElement element : scoring.getElements()) {
      ParserHelper.resolveConditionType(definitionsService, element.getCondition());
    }
    for (ScoringElement element : scoring.getElements()) {
      if (scoring.getMetadata().isEnabled() && !scoring.getMetadata().isMissingPlugins()) {
        updateAutoGeneratedRules(scoring.getMetadata(), element.getCondition());
      }
    }
    // make sure we update the name and description metadata that might not match, so first we
    // remove the entry from the map
    persistenceService.save(scoring);

    persistenceService.createMapping(
        Profile.ITEM_TYPE,
        String.format(
            "{\n"
                + "    \"profile\": {\n"
                + "        \"properties\" : {\n"
                + "            \"scores\": {\n"
                + "                \"properties\": {\n"
                + "                    \"%s\": {\n"
                + "                        \"type\": \"long\"\n"
                + "                    }\n"
                + "                }\n"
                + "            }\n"
                + "        }\n"
                + "    }\n"
                + "}\n",
            scoring.getItemId()));

    updateExistingProfilesForScoring(scoring);
  }
 public Segment getSegmentDefinition(String segmentId) {
   Segment definition = persistenceService.load(segmentId, Segment.class);
   if (definition != null) {
     ParserHelper.resolveConditionType(definitionsService, definition.getCondition());
   }
   return definition;
 }
 private List<Segment> getAllSegmentDefinitions() {
   List<Segment> allItems = persistenceService.getAllItems(Segment.class);
   for (Segment segment : allItems) {
     ParserHelper.resolveConditionType(definitionsService, segment.getCondition());
   }
   return allItems;
 }
 public Scoring getScoringDefinition(String scoringId) {
   Scoring definition = persistenceService.load(scoringId, Scoring.class);
   if (definition != null) {
     for (ScoringElement element : definition.getElements()) {
       ParserHelper.resolveConditionType(definitionsService, element.getCondition());
     }
   }
   return definition;
 }
 private List<Scoring> getAllScoringDefinitions() {
   List<Scoring> allItems = persistenceService.getAllItems(Scoring.class);
   for (Scoring scoring : allItems) {
     for (ScoringElement element : scoring.getElements()) {
       ParserHelper.resolveConditionType(definitionsService, element.getCondition());
     }
   }
   return allItems;
 }
  public void setSegmentDefinition(Segment segment) {
    ParserHelper.resolveConditionType(definitionsService, segment.getCondition());
    if (segment.getMetadata().isEnabled() && !segment.getMetadata().isMissingPlugins()) {
      updateAutoGeneratedRules(segment.getMetadata(), segment.getCondition());
    }
    // make sure we update the name and description metadata that might not match, so first we
    // remove the entry from the map
    persistenceService.save(segment);

    updateExistingProfilesForSegment(segment);
  }