public SegmentsAndScores getSegmentsAndScoresForProfile(Profile profile) { Set<String> segments = new HashSet<String>(); Map<String, Integer> scores = new HashMap<String, Integer>(); List<Segment> allSegments = this.allSegments; for (Segment segment : allSegments) { if (persistenceService.testMatch(segment.getCondition(), profile)) { segments.add(segment.getMetadata().getId()); } } List<Scoring> allScoring = this.allScoring; Map<String, Integer> scoreModifiers = (Map<String, Integer>) profile.getSystemProperties().get("scoreModifiers"); for (Scoring scoring : allScoring) { if (scoring.getMetadata().isEnabled()) { int score = 0; for (ScoringElement scoringElement : scoring.getElements()) { if (persistenceService.testMatch(scoringElement.getCondition(), profile)) { score += scoringElement.getValue(); } } String scoringId = scoring.getMetadata().getId(); if (scoreModifiers != null && scoreModifiers.containsKey(scoringId) && scoreModifiers.get(scoringId) != null) { score += scoreModifiers.get(scoringId); } if (score > 0) { scores.put(scoringId, score); } } } return new SegmentsAndScores(segments, scores); }