/**
     * @param \SchemaPropertyElement | \SchemaPropertyElement[] $dbElement
     * @param                                                   $value
     * @param                                                   $rowStatus
     * @param \SchemaProperty                                   $property
     * @param \ProfileProperty                                  $profileProperty
     * @param                                                   $language
     *
     * @param                                                   $key
     *
     * @return bool
     * @throws \Exception
     * @throws \PropelException
     */
    private function upsertElementFromRow(
        &$dbElement,
        $value,
        $rowStatus,
        &$property,
        $profileProperty,
        $language,
        $key
    ) {
        if ( ! is_array($dbElement)) {
            if (empty( $dbElement ) and $value) {
                $dbElement = new \SchemaPropertyElement();
                $dbElement->setProfilePropertyId($profileProperty->getId());
                $dbElement->setSchemaPropertyId($property->getId());
                $dbElement->setLanguage($language);
                $dbElement->setCreatedUserId($this->userId);
                $property->addSchemaPropertyElementRelatedBySchemaPropertyId($dbElement);
            }
            if ($dbElement and $value !== $dbElement->getObject()) {
                if (empty( $value )) {
                    $dbElement->delete();
                } else {
                    $dbElement->setStatusId($rowStatus);
                    $dbElement->setObject($value);
                    $dbElement->setUpdatedUserId($this->userId);
                    $dbElement->importId = $this->importId;
                    $dbElement->setDeletedAt(null);
                }
                //$dbElement->save();
                if ($profileProperty->getIsInForm()) {
                    if (( $profileProperty->getHasLanguage() and $property->getLanguage() == $dbElement->getLanguage() ) or ! $profileProperty->getHasLanguage()) {
                        $this->setPropertyValue($value,
                                                $property,
                                                $profileProperty->getName(), ! $profileProperty->getIsObjectProp(),
                                                $key);
                        $dbElement->setIsSchemaProperty(true);
                    }
                }

                return true;
            }
        } else {
            $foundOne = false;
            foreach ($dbElement as &$oneElement) {
                if ( ! $foundOne) {
                    $foundOne = $this->upsertElementFromRow($oneElement,
                                                            $value,
                                                            $rowStatus,
                                                            $property,
                                                            $profileProperty,
                                                            $language,
                                                            $key);
                }
            }
        }

        return true;
    }
 /**
  * Declares an association between this object and a ProfileProperty object.
  *
  * @param      ProfileProperty $v
  * @return     void
  * @throws     PropelException
  */
 public function setProfileProperty($v)
 {
     if ($v === null) {
         $this->setProfilePropertyId(NULL);
     } else {
         $this->setProfilePropertyId($v->getId());
     }
     $this->aProfileProperty = $v;
 }
 /**
  * Declares an association between this object and a ProfileProperty object.
  *
  * @param      ProfileProperty $v
  * @return     void
  * @throws     PropelException
  */
 public function setProfilePropertyRelatedByInverseProfilePropertyId($v)
 {
     if ($v === null) {
         $this->setInverseProfilePropertyId(NULL);
     } else {
         $this->setInverseProfilePropertyId($v->getId());
     }
     $this->aProfilePropertyRelatedByInverseProfilePropertyId = $v;
 }