src/snac/server/validation/validators/IDValidator.php
/**
     * Validate a SCM Object
     *
     * @param \snac\data\SNACControlMetadata $scm Metadata to validate
     * @param mixed[] $context optional Any context information needed for validation
     * @return boolean true if valid, false otherwise
     */
Validate a SCM Object
@param \snac\data\SNACControlMetadata $scm Metadata to validate
@param mixed[] $context optional Any context information needed for validation
@return boolean true if valid, false otherwise
Validate a SCM Object @param \ snac \ data \ SNACControlMetadata $scm Metadata to validate @param mixed [] $context optional Any context information needed for validation @return boolean true if valid false otherwise
public function validateSNACControlMetadata($scm, $context=null) {
        if ($scm == null)
            return true;
        if ($scm->getID() == null) {
            if ($scm->getLanguage() == null ||
                        ($scm->getLanguage() != null && $scm->getLanguage()->getID() == null))
                return true;
            else {
                $this->addError("SNACControlMetadata with no ID has elements with ID", $scm);
                return false;
            }
        }
        if (isset($this->seen["scm"]) && in_array($scm->getID(), $this->seen["scm"])) {
            $this->addError("ID used multiple times", $scm);
            return false;
        }
        $scmList = $this->constellation->getSNACControlMetadata();
        if ($context != null) {
            $scmList = $context->getSNACControlMetadata();
        }
        foreach ($scmList as $i => $current) {
            if ($scm->getID() == $current->getID()) {
                if (!isset($this->seen["scm"]))
                    $this->seen["scm"] = array();
                array_push($this->seen["scm"], $scm->getID());
                if ($scm->getCitation() != null && $scm->getCitation()->getID() != null) {
                    $foundID = false;
                    foreach ($this->constellation->getSources() as $source) {
                        if ($scm->getCitation()->getID() == $source->getID()) {
                            $foundID = true;
                            break;
                        }
                    }
                    if (!$foundID)
                        return false;
                }
                return $this->validateLanguage($scm->getLanguage(), $current);
            }
        }
        return false;
    }
public function validateSNACControlMetadata ( $ scm , $ context = null ) { if ( $ scm == null ) return true ; if ( $ scm -> getID ( ) == null ) { if ( $ scm -> getLanguage ( ) == null || ( $ scm -> getLanguage ( ) != null && $ scm -> getLanguage ( ) -> getID ( ) == null ) ) return true ; else { $ this -> addError ( " SNACControlMetadata with no ID has elements with ID " , $ scm ) ; return false ; } } if ( isset ( $ this -> seen [ " scm " ] ) && in_array ( $ scm -> getID ( ) , $ this -> seen [ " scm " ] ) ) { $ this -> addError ( " ID used multiple times " , $ scm ) ; return false ; } $ scmList = $ this -> constellation -> getSNACControlMetadata ( ) ; if ( $ context != null ) { $ scmList = $ context -> getSNACControlMetadata ( ) ; } foreach ( $ scmList as $ i => $ current ) { if ( $ scm -> getID ( ) == $ current -> getID ( ) ) { if ( ! isset ( $ this -> seen [ " scm " ] ) ) $ this -> seen [ " scm " ] = array ( ) ; array_push ( $ this -> seen [ " scm " ] , $ scm -> getID ( ) ) ; if ( $ scm -> getCitation ( ) != null && $ scm -> getCitation ( ) -> getID ( ) != null ) { $ foundID = false ; foreach ( $ this -> constellation -> getSources ( ) as $ source ) { if ( $ scm -> getCitation ( ) -> getID ( ) == $ source -> getID ( ) ) { $ foundID = true ; break ; } } if ( ! $ foundID ) return false ; } return $ this -> validateLanguage ( $ scm -> getLanguage ( ) , $ current ) ; } } return false ; }
Validate a SCM Object
 @param \snac\data\SNACControlMetadata $scm Metadata to validate
 @param mixed[] $context optional Any context information needed for validation
 @return boolean true if valid, false otherwise
Validate a SCM Object @param \ snac \ data \ SNACControlMetadata $scm Metadata to validate @param mixed [] $context optional Any context information needed for validation @return boolean true if valid false otherwise
// If the seen list for scm IDs doesn't yet exist, create it // Add this id to the list of seen ids // Must check the source citation of the SCM.  Originally, we recursed, however // that method may produce an infinite loop if there are cyclical SCM on source on // SCM on source on ... // If we have a citation and that citation has an ID, we must check it