protected function addConditionGroup(Filter $filter, $conditionGroupData)
    {
        if (array_key_exists('id', $conditionGroupData)) {
            throw new EntityIdAlreadySetException(self::$conditionGroupEntityName, $conditionGroupData['id']);
        } elseif (array_key_exists('conditions', $conditionGroupData)) {
            $conditionGroup = new ConditionGroupEntity();
            $conditionGroup->setFilter($filter->getEntity());

            foreach ($conditionGroupData['conditions'] as $conditionData) {
                if (array_key_exists('id', $conditionData)) {
                    throw new EntityIdAlreadySetException(self::$conditionEntityName, $conditionData['id']);
                } elseif ($this->isValidConditionData($conditionData)) {
                    $condition = new ConditionEntity();
                    $condition->setType($conditionData['type']);
                    $value = $this->getValueForCondition(
                        $conditionData['value'],
                        $conditionData['type']
                    );
                    $condition->setValue($value);
                    $condition->setOperator($conditionData['operator']);
                    $condition->setField($conditionData['field']);
                    $condition->setConditionGroup($conditionGroup);
                    $conditionGroup->addCondition($condition);
                    $conditionGroup->setFilter($filter->getEntity());
                    $this->em->persist($condition);
                }
            }

            $filter->getEntity()->addConditionGroup($conditionGroup);
            $this->em->persist($conditionGroup);
        }

        return true;
    }