src/AppDomain/CommandHandler.php
/**
     * Validate an EjpPaper blob, and publish EjpPaperImported if anything has changed
     *
     * @param EjpPaper $ejpPaper
     */
Validate an EjpPaper blob, and publish EjpPaperImported if anything has changed
@param EjpPaper $ejpPaper
Validate an EjpPaper blob and publish EjpPaperImported if anything has changed @param EjpPaper $ejpPaper
public function importFromEjp(EjpPaper $ejpPaper)
    {
        if ($paperId = $this->findIdByManuscriptNo($ejpPaper->getManuscriptNo())) {
            $existingPaper = $this->loadPaper($paperId);
            if ($existingPaper->getEjpHashForComparison() !== EjpHasher::RevisedPaperHash($ejpPaper)|| EjpHasher::AcceptedPaperHash($ejpPaper)) {
                $nextVersion = $existingPaper->getVersion() + 1;
                $event = (new EjpPaperImported($paperId, $nextVersion, $ejpPaper));
                $this->publish($event);
                $nextVersion++;
                if ($ejpPaper->isAccepted() === true && $existingPaper->isAccepted() === null) {
                    $this->publish(new PaperAcceptedEvent($paperId, $nextVersion, $ejpPaper));
                }
            }
            return;
        }
        $newPaperId = Uuid::uuid4();
        $event = (new EjpPaperImported($newPaperId, 1, $ejpPaper));
        $this->publish($event);
        if ($ejpPaper->isAccepted() === true) {
            $this->publish(new PaperAcceptedEvent($newPaperId, 2, $ejpPaper));
        }
    }
public function importFromEjp ( EjpPaper $ ejpPaper ) { if ( $ paperId = $ this -> findIdByManuscriptNo ( $ ejpPaper -> getManuscriptNo ( ) ) ) { $ existingPaper = $ this -> loadPaper ( $ paperId ) ; if ( $ existingPaper -> getEjpHashForComparison ( ) !== EjpHasher :: RevisedPaperHash ( $ ejpPaper ) || EjpHasher :: AcceptedPaperHash ( $ ejpPaper ) ) { $ nextVersion = $ existingPaper -> getVersion ( ) + 1 ; $ event = ( new EjpPaperImported ( $ paperId , $ nextVersion , $ ejpPaper ) ) ; $ this -> publish ( $ event ) ; $ nextVersion ++ ; if ( $ ejpPaper -> isAccepted ( ) === true && $ existingPaper -> isAccepted ( ) === null ) { $ this -> publish ( new PaperAcceptedEvent ( $ paperId , $ nextVersion , $ ejpPaper ) ) ; } } return ; } $ newPaperId = Uuid :: uuid4 ( ) ; $ event = ( new EjpPaperImported ( $ newPaperId , 1 , $ ejpPaper ) ) ; $ this -> publish ( $ event ) ; if ( $ ejpPaper -> isAccepted ( ) === true ) { $ this -> publish ( new PaperAcceptedEvent ( $ newPaperId , 2 , $ ejpPaper ) ) ; } }
Validate an EjpPaper blob, and publish EjpPaperImported if anything has changed
 @param EjpPaper $ejpPaper
Validate an EjpPaper blob and publish EjpPaperImported if anything has changed @param EjpPaper $ejpPaper
//We've seen this paper before. Publish an event only if it's different //Update paper //Check to see if paper's been accepted //We haven't seen this paper before. //if new paper has also been accepted