<commit_before><?php

/*
 * This file is part of the Access to Memory (AtoM) software.
 *
 * Access to Memory (AtoM) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Access to Memory (AtoM) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Access to Memory (AtoM).  If not, see <http://www.gnu.org/licenses/>.
 */

class arDacsPluginIndexAction extends InformationObjectIndexAction
{
  public function execute($request)
  {
    parent::execute($request);

    $this->dacs = new arDacsPlugin($this->resource);

    if (1 > strlen($title = $this->resource->__toString()))
    {
      $title = $this->context->i18n->__('Untitled');
    }

    $this->response->setTitle("$title - {$this->response->getTitle()}");

    // Function relations
    $criteria = new Criteria;
    $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
    $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitFunction::ID);

    $this->functionRelations = QubitRelation::get($criteria);

    // Set creator history label
    $this->creatorHistoryLabels = array(
      NULL => $this->context->i18n->__('Administrative / Biographical history'),
      QubitTerm::CORPORATE_BODY_ID => $this->context->i18n->__('Administrative history'),
      QubitTerm::PERSON_ID => $this->context->i18n->__('Biographical history'),
      QubitTerm::FAMILY_ID => $this->context->i18n->__('Biographical history')
    );

    if (QubitAcl::check($this->resource, 'update'))
    {
      $validatorSchema = new sfValidatorSchema;
      $values = array();

      $validatorSchema->identifier = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Identifier - This is a mandatory element.')));
      $values['identifier'] = $this->resource->identifier;

      $validatorSchema->repository = new QubitValidatorCountable(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Name and location of repository - This is a mandatory element.')));
      if (null !== $repository = $this->resource->repository)
      {
        $values['repository'] = $repository;
      }

      $validatorSchema->title = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Title - This is a mandatory element.')));
      $values['title'] = $this->resource->getTitle(array('cultureFallback' => true));

      $validatorSchema->dateRange = new QubitValidatorDates(array(), array(
        'invalid' => $this->context->i18n->__('Date(s) - are not consistent with higher levels.')));
      $values['dateRange'] = $this->resource;

      $validatorSchema->dates = new QubitValidatorCountable(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Date(s) - This is a mandatory element.')));
      $values['dates'] = $this->resource->getDates();

      $validatorSchema->extentAndMedium = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Extent - This is a mandatory element.')));
      $values['extentAndMedium'] = $this->resource->getExtentAndMedium(array('cultureFallback' => true));

      $validatorSchema->creators = new QubitValidatorCountable(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('This archival description, or one of its higher levels, requires at least one creator.')));
      foreach ($this->resource->ancestors->andSelf()->orderBy('rgt') as $item)
      {
        $values['creators'] = $item->getCreators();
        if (0 < count($values['creators']))
        {
          break;
        }
      }

      $validatorSchema->scopeAndContent = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Scope and content - This is a mandatory element.')));
      $values['scopeAndContent'] = $this->resource->getScopeAndContent(array('cultureFallback' => true));

      try
      {
        $validatorSchema->clean($values);
      }
      catch (sfValidatorErrorSchema $e)
      {
        $this->errorSchema = $e;
      }

    }
  }
}
<commit_msg>Inherited repos in DACS validation, refs #12246<commit_after><?php

/*
 * This file is part of the Access to Memory (AtoM) software.
 *
 * Access to Memory (AtoM) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Access to Memory (AtoM) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Access to Memory (AtoM).  If not, see <http://www.gnu.org/licenses/>.
 */

class arDacsPluginIndexAction extends InformationObjectIndexAction
{
  public function execute($request)
  {
    parent::execute($request);

    $this->dacs = new arDacsPlugin($this->resource);

    if (1 > strlen($title = $this->resource->__toString()))
    {
      $title = $this->context->i18n->__('Untitled');
    }

    $this->response->setTitle("$title - {$this->response->getTitle()}");

    // Function relations
    $criteria = new Criteria;
    $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
    $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitFunction::ID);

    $this->functionRelations = QubitRelation::get($criteria);

    // Set creator history label
    $this->creatorHistoryLabels = array(
      NULL => $this->context->i18n->__('Administrative / Biographical history'),
      QubitTerm::CORPORATE_BODY_ID => $this->context->i18n->__('Administrative history'),
      QubitTerm::PERSON_ID => $this->context->i18n->__('Biographical history'),
      QubitTerm::FAMILY_ID => $this->context->i18n->__('Biographical history')
    );

    if (QubitAcl::check($this->resource, 'update'))
    {
      $validatorSchema = new sfValidatorSchema;
      $values = array();

      $validatorSchema->identifier = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Identifier - This is a mandatory element.')));
      $values['identifier'] = $this->resource->identifier;

      $validatorSchema->repository = new QubitValidatorCountable(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Name and location of repository - This is a mandatory element.')));
      if (null !== $repository = $this->resource->getRepository(array('inherit' => true)))
      {
        $values['repository'] = $repository;
      }

      $validatorSchema->title = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Title - This is a mandatory element.')));
      $values['title'] = $this->resource->getTitle(array('cultureFallback' => true));

      $validatorSchema->dateRange = new QubitValidatorDates(array(), array(
        'invalid' => $this->context->i18n->__('Date(s) - are not consistent with higher levels.')));
      $values['dateRange'] = $this->resource;

      $validatorSchema->dates = new QubitValidatorCountable(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Date(s) - This is a mandatory element.')));
      $values['dates'] = $this->resource->getDates();

      $validatorSchema->extentAndMedium = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Extent - This is a mandatory element.')));
      $values['extentAndMedium'] = $this->resource->getExtentAndMedium(array('cultureFallback' => true));

      $validatorSchema->creators = new QubitValidatorCountable(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('This archival description, or one of its higher levels, requires at least one creator.')));
      foreach ($this->resource->ancestors->andSelf()->orderBy('rgt') as $item)
      {
        $values['creators'] = $item->getCreators();
        if (0 < count($values['creators']))
        {
          break;
        }
      }

      $validatorSchema->scopeAndContent = new sfValidatorString(array(
        'required' => true), array(
        'required' => $this->context->i18n->__('Scope and content - This is a mandatory element.')));
      $values['scopeAndContent'] = $this->resource->getScopeAndContent(array('cultureFallback' => true));

      try
      {
        $validatorSchema->clean($values);
      }
      catch (sfValidatorErrorSchema $e)
      {
        $this->errorSchema = $e;
      }

    }
  }
}

{'fraction_non_alphanumeric': 0.1541114344218127, 'fraction_numerical': 0.006789524733268671, 'mean_word_length': 3.4465740297077145, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 216, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5013649', 'n_tokens_mistral': 2735, 'n_tokens_neox': 2663, 'n_words': 667}