<commit_before><?php

/**
 * validates the uniqueness of a prefLabel in the context of a Vocabulary
 *
 * Takes as input the prefLabel of the concept
 * Gets the vocabulary id from the request object
 *
 * <b>Optional parameters:</b>
 *
 * # <b>unique_error</b> - [Uniqueness error]   - An error message to use when
 *                                                the value for this column already
 *                                                exists in the database.
 *
 * @package    symfony
 * @subpackage validator
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id: sfPropelUniqueValidator.class.php 2995 2006-12-09 18:01:32Z fabien $
 */
class myPropelUniqueSchemaPropertyValidator extends sfValidator
{
  public function execute(&$value, &$error)
  {
    $schemaId   = $this->getContext()->getRequest()->getParameter('schema_id');
    $propertyId = $this->getContext()->getRequest()->getParameter('id');

    $c = new Criteria();
    $c->add(SchemaPropertyPeer::NAME, $value);
    $c->add(SchemaPropertyPeer::SCHEMA_ID, $schemaId);

    $object = SchemaPropertyPeer::doSelectOne($c);

    if ($object)
    {
       //check to see if the retrieved object has the same id
       if ($propertyId && ($object->getId() == $propertyId))
       {
         return true;
       }
       else
       {
         $error = $this->getParameter('unique_error');

         return false;
       }
    }

    return true;
  }

  /**<commit_msg>Allow the re-use of deprecated names<commit_after><?php

/**
 * validates the uniqueness of a prefLabel in the context of a Vocabulary
 *
 * Takes as input the prefLabel of the concept
 * Gets the vocabulary id from the request object
 *
 * <b>Optional parameters:</b>
 *
 * # <b>unique_error</b> - [Uniqueness error]   - An error message to use when
 *                                                the value for this column already
 *                                                exists in the database.
 *
 * @package    symfony
 * @subpackage validator
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id: sfPropelUniqueValidator.class.php 2995 2006-12-09 18:01:32Z fabien $
 */
class myPropelUniqueSchemaPropertyValidator extends sfValidator
{
  public function execute(&$value, &$error)
  {
    $schemaId   = $this->getContext()->getRequest()->getParameter('schema_id');
    $propertyId = $this->getContext()->getRequest()->getParameter('id');

    $c = new Criteria();
    $c->add(SchemaPropertyPeer::NAME, $value);
    $c->add(SchemaPropertyPeer::SCHEMA_ID, $schemaId);

    $object = SchemaPropertyPeer::doSelectOne($c);

    if ($object)
    {
      //it's ok to use if the status is deprecated
      if ($object->getStatusId() == 8) {
        return true;
      }

      //check to see if the retrieved object has the same id
       if ($propertyId && ($object->getId() == $propertyId))
       {
         return true;
       }
       else
       {
         $error = $this->getParameter('unique_error');

         return false;
       }
    }

    return true;
  }

  /**
{'fraction_non_alphanumeric': 0.12598944591029024, 'fraction_numerical': 0.012203166226912929, 'mean_word_length': 2.3366336633663365, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6271938', 'n_tokens_mistral': 894, 'n_tokens_neox': 854, 'n_words': 243}