src/snac/client/webui/util/ConstellationPostMapper.php
/**
     * Reconcile Objects
     *
     * Reconciles two objects.  If they match, this method fills in the class' updates field
     * to reflect that the incoming object should be linked to this object.  It adds the new ID
     * and version number to be eventually returned to the edit interface.
     *
     * @param \snac\data\AbstractData $object Main object to reconcile
     * @param \snac\data\AbstractData $other Object to reconcile against
     * @param boolean $checkLang optional Whether or not to check the language
     * @return boolean true if the objects reconcile (equal) or false otherwise
     */
Reconcile Objects
Reconciles two objects.  If they match, this method fills in the class' updates field
to reflect that the incoming object should be linked to this object.  It adds the new ID
and version number to be eventually returned to the edit interface.


Reconcile Objects Reconciles two objects . If they match this method fills in the class ' updates field to reflect that the incoming object should be linked to this object . It adds the new ID and version number to be eventually returned to the edit interface .
public function reconcileObject($object, $other, $checkLang = false) {
        if ($object == null && $other == null) {
            return true;
        }
        if ($object == null || $other == null) {
            return false;
        }
        $success = false;
        if ($object->getOperation() != null &&
                $object->equals($other, false) && $object->getOperation() == $other->getOperation()) {
            $piece = $this->getMatchInfo($object);
            if ($piece != null && !empty($piece)) {
                $this->logger->addDebug("Reconciling an object", array("info"=>$piece, "object"=>$object->toArray(), "other"=>$other->toArray()));
                $this->updates[$piece["idField"]] = $other->getID();
                $this->updates[$piece["versionField"]] = $other->getVersion();
            }
            $success = true;
        }
        if ($object->getDateList() != null) {
            foreach($object->getDateList() as $date) {
                foreach ($other->getDateList() as $otherdate) {
                    $this->reconcileObject($date, $otherdate);
                }
            }
        }
        if ($object->getSNACControlMetadata() != null) {
            foreach($object->getSNACControlMetadata() as $scm) {
                foreach ($other->getSNACControlMetadata() as $otherscm) {
                    $this->reconcileObject($scm, $otherscm, true);
                }
            }
        }
        if ($checkLang) {
           $this->reconcileObject($object->getLanguage(), $other->getLanguage());
        }
        return $success;
    }
public function reconcileObject ( $ object , $ other , $ checkLang = false ) { if ( $ object == null && $ other == null ) { return true ; } if ( $ object == null || $ other == null ) { return false ; } $ success = false ; if ( $ object -> getOperation ( ) != null && $ object -> equals ( $ other , false ) && $ object -> getOperation ( ) == $ other -> getOperation ( ) ) { $ piece = $ this -> getMatchInfo ( $ object ) ; if ( $ piece != null && ! empty ( $ piece ) ) { $ this -> logger -> addDebug ( " Reconciling an object " , array ( " info " => $ piece , " object " => $ object -> toArray ( ) , " other " => $ other -> toArray ( ) ) ) ; $ this -> updates [ $ piece [ " idField " ] ] = $ other -> getID ( ) ; $ this -> updates [ $ piece [ " versionField " ] ] = $ other -> getVersion ( ) ; } $ success = true ; } if ( $ object -> getDateList ( ) != null ) { foreach ( $ object -> getDateList ( ) as $ date ) { foreach ( $ other -> getDateList ( ) as $ otherdate ) { $ this -> reconcileObject ( $ date , $ otherdate ) ; } } } if ( $ object -> getSNACControlMetadata ( ) != null ) { foreach ( $ object -> getSNACControlMetadata ( ) as $ scm ) { foreach ( $ other -> getSNACControlMetadata ( ) as $ otherscm ) { $ this -> reconcileObject ( $ scm , $ otherscm , true ) ; } } } if ( $ checkLang ) { $ this -> reconcileObject ( $ object -> getLanguage ( ) , $ other -> getLanguage ( ) ) ; } return $ success ; }
Reconcile Objects
 Reconciles two objects.
Reconcile Objects Reconciles two objects .
// loose equality (not checking IDs, since they may not exist) // Other object is the one that we received from the server (with new ID and/or version) // Set success to be true (they matched) // This is highly inefficient! // This is highly inefficient! // Reconcile the language if we need to, based on the parameter