src/snac/server/validation/validators/IDValidator.php
/**
     * Validate a Generic AbstractData Object
     *
     * This method will validate any object that just has SCM and no other sub-objects.  This method takes
     * the object to be validated, an array of objects that may contain this object (this should be the list
     * from a validated parent object), and the type of the object (to check for no duplicates).
     *
     * This generic function also makes use of the fact that all AbstractData objects have the getDateList method that
     * always returns an array, even if empty.  This therefore automatically checks dates on any object that has them.
     *
     * @param \snac\data\AbstractData $object The object to validate
     * @param \snac\data\AbstractData[] $realObjects A list (from a valid constellation part) possibly containing the object
     * @param string $type Sting shorthand type of this object
     * @param string $preID optional Any string that should be used in front of the objects id in the array of
     * seen objects
     * @return boolean true if valid, false otherwise.
     */
Validate a Generic AbstractData Object
This method will validate any object that just has SCM and no other sub-objects.  This method takes
the object to be validated, an array of objects that may contain this object (this should be the list
from a validated parent object), and the type of the object (to check for no duplicates).

This generic function also makes use of the fact that all AbstractData objects have the getDateList method that
always returns an array, even if empty.  This therefore automatically checks dates on any object that has them.


Validate a Generic AbstractData Object This method will validate any object that just has SCM and no other sub - objects . This method takes the object to be validated an array of objects that may contain this object ( this should be the list from a validated parent object ) and the type of the object ( to check for no duplicates ) . This generic function also makes use of the fact that all AbstractData objects have the getDateList method that always returns an array even if empty . This therefore automatically checks dates on any object that has them .
private function validateGeneric($object, $realObjects, $type, $preID = "") {
        if ($object == null) {
            return true;
        }
        $success = true;
        if ($object->getID() == null) {
            $success = $success && $this->checkDates($object);
            $success = $success && $this->checkSCM($object);
            return $success;
        }
        if (isset($this->seen[$type]) && in_array($preID . $object->getID(), $this->seen[$type])) {
            $this->addError("ID used multiple times ($type, $preID".$object->getID().")", $object);
            $success = false;
        }
        $seenObject = false;
        foreach ($realObjects as $i => $current) {
            if ($current != null && $object->getID() == $current->getID()) {
                if (!isset($this->seen[$type]))
                    $this->seen[$type] = array();
                array_push($this->seen[$type], $preID . $object->getID());
                $success = $success && $this->validateAllDates($object, $current);
                $success = $success && $this->validateAllSCM($object, $current);
                $seenObject = true;
            }
        }
        return $success && $seenObject;
    }
private function validateGeneric ( $ object , $ realObjects , $ type , $ preID = " " ) { if ( $ object == null ) { return true ; } $ success = true ; if ( $ object -> getID ( ) == null ) { $ success = $ success && $ this -> checkDates ( $ object ) ; $ success = $ success && $ this -> checkSCM ( $ object ) ; return $ success ; } if ( isset ( $ this -> seen [ $ type ] ) && in_array ( $ preID . $ object -> getID ( ) , $ this -> seen [ $ type ] ) ) { $ this -> addError ( " ID used multiple times ( $ type ,  $ preID " . $ object -> getID ( ) . " ) " , $ object ) ; $ success = false ; } $ seenObject = false ; foreach ( $ realObjects as $ i => $ current ) { if ( $ current != null && $ object -> getID ( ) == $ current -> getID ( ) ) { if ( ! isset ( $ this -> seen [ $ type ] ) ) $ this -> seen [ $ type ] = array ( ) ; array_push ( $ this -> seen [ $ type ] , $ preID . $ object -> getID ( ) ) ; $ success = $ success && $ this -> validateAllDates ( $ object , $ current ) ; $ success = $ success && $ this -> validateAllSCM ( $ object , $ current ) ; $ seenObject = true ; } } return $ success && $ seenObject ; }
Validate a Generic AbstractData Object
 This method will validate any object that just has SCM and no other sub-objects.
Validate a Generic AbstractData Object This method will validate any object that just has SCM and no other sub - objects .
// If the object is null, stop and succeed (leaf node) // Set success to be true by default // If this object has no ID, but a subobject does, then success is false // If this object has already been seen, then success is false //$this->logger->addWarning("ID used multiple times ($type, $preID".$object->getID().")", $object->toArray()); // Validate this object's ID against the real object from the database, and // validate all it's subelements against their counterparts from the database // At this point, $object is not null and has an id.  So, we must see an object with that // id, or there is a problem here. // If the seen IDs list for this type doesn't exist, create it // Add this id to the list of ids seen for this type (duplicate check) // Validate the subelements // Return success