src/AppBundle/EJPImport/CSVParser.php
// the following currently only handles accepted papers that have already been imported on a previous occasion
the following currently only handles accepted papers that have already been imported on a previous occasion
the following currently only handles accepted papers that have already been imported on a previous occasion
private function parseAcceptedPaperCSV(CSVReader $reader)
    {
        $ejpPapers = [];
        $em = $this->em;
        if (!in_array('MS Tracking No.', $reader->getColumnHeaders())) {
            throw new \Exception('Please upload a correctly formatted .csv file (column headers in 4th row');
        }
        foreach ($reader as $row) {
            $matches = [];
            preg_match('#(?<articleType>[A-Z]+)-\w+-(?<manuscriptNo>[0-9]{5})(R(?<revision>\d+))?(-(?<hadAppeal>\w))?#',
                $row['MS No.'], $matches);
            var_dump($matches);
            $subjectArea = $em->getRepository(SubjectArea::class)
                ->findOneBy(['description' => $row['Major Subject Area(s)']]);
            if (array_key_exists(intval($matches['manuscriptNo']), $ejpPapers)) {
                $ejpPapers[intval($matches['manuscriptNo'])]->subjectAreaId2 = $subjectArea->getId();
                continue;
            }
            $ejpPaper = new EjpPaper();
            $ejpPaper->setManuscriptNo(intval($matches['manuscriptNo']));
            $ejpPaper->setArticleTypeCode($matches['articleType']);
            $ejpPaper->setCorrespondingAuthor(html_entity_decode($row['Corresponding Author']));
            $ejpPaper->setRevision(isset($matches['revision']) ? intval($matches['revision']) : 0);
            $ejpPaper->setHadAppeal(isset($matches['hadAppeal']) && $matches['hadAppeal'] == 'A');
            $ejpPaper->setSubjectAreaId1($subjectArea->getId());
            $ejpPaper->setInsightDecision($row['Insight?']);
            $ejpPaper->setInsightComment($row['Justification']);
            $ejpPaper->setAbstract($row['Abstract']);
            $ejpPaper->setImpactStatement($row['Impact statement']);
            $ejpPaper->setDigestQuestionsAsked($row['Digest question?']);
            $ejpPaper->setDigestAnswersGiven($row['Digest answers?']);
            $ejpPaper->setAccepted(True);
            $matches = [];
            preg_match('#([0-9]{4}-[0-9]{2}-[0-9]{2})#',
                $row['Decision date'], $matches);
            $ejpPaper->setAcceptedDate(date_create_from_format('Y-m-d', $matches[0]));
            $ejpPapers[$ejpPaper->manuscriptNo] = $ejpPaper;
        }
        return $ejpPapers;
    }
private function parseAcceptedPaperCSV ( CSVReader $ reader ) { $ ejpPapers = [ ] ; $ em = $ this -> em ; if ( ! in_array ( 'MS Tracking No.' , $ reader -> getColumnHeaders ( ) ) ) { throw new \ Exception ( 'Please upload a correctly formatted .csv file (column headers in 4th row' ) ; } foreach ( $ reader as $ row ) { $ matches = [ ] ; preg_match ( '#(?<articleType>[A-Z]+)-\w+-(?<manuscriptNo>[0-9]{5})(R(?<revision>\d+))?(-(?<hadAppeal>\w))?#' , $ row [ 'MS No.' ] , $ matches ) ; var_dump ( $ matches ) ; $ subjectArea = $ em -> getRepository ( SubjectArea :: class ) -> findOneBy ( [ 'description' => $ row [ 'Major Subject Area(s)' ] ] ) ; if ( array_key_exists ( intval ( $ matches [ 'manuscriptNo' ] ) , $ ejpPapers ) ) { $ ejpPapers [ intval ( $ matches [ 'manuscriptNo' ] ) ] -> subjectAreaId2 = $ subjectArea -> getId ( ) ; continue ; } $ ejpPaper = new EjpPaper ( ) ; $ ejpPaper -> setManuscriptNo ( intval ( $ matches [ 'manuscriptNo' ] ) ) ; $ ejpPaper -> setArticleTypeCode ( $ matches [ 'articleType' ] ) ; $ ejpPaper -> setCorrespondingAuthor ( html_entity_decode ( $ row [ 'Corresponding Author' ] ) ) ; $ ejpPaper -> setRevision ( isset ( $ matches [ 'revision' ] ) ? intval ( $ matches [ 'revision' ] ) : 0 ) ; $ ejpPaper -> setHadAppeal ( isset ( $ matches [ 'hadAppeal' ] ) && $ matches [ 'hadAppeal' ] == 'A' ) ; $ ejpPaper -> setSubjectAreaId1 ( $ subjectArea -> getId ( ) ) ; $ ejpPaper -> setInsightDecision ( $ row [ 'Insight?' ] ) ; $ ejpPaper -> setInsightComment ( $ row [ 'Justification' ] ) ; $ ejpPaper -> setAbstract ( $ row [ 'Abstract' ] ) ; $ ejpPaper -> setImpactStatement ( $ row [ 'Impact statement' ] ) ; $ ejpPaper -> setDigestQuestionsAsked ( $ row [ 'Digest question?' ] ) ; $ ejpPaper -> setDigestAnswersGiven ( $ row [ 'Digest answers?' ] ) ; $ ejpPaper -> setAccepted ( True ) ; $ matches = [ ] ; preg_match ( '#([0-9]{4}-[0-9]{2}-[0-9]{2})#' , $ row [ 'Decision date' ] , $ matches ) ; $ ejpPaper -> setAcceptedDate ( date_create_from_format ( 'Y-m-d' , $ matches [ 0 ] ) ) ; $ ejpPapers [ $ ejpPaper -> manuscriptNo ] = $ ejpPaper ; } return $ ejpPapers ; }
the following currently only handles accepted papers that have already been imported on a previous occasion
the following currently only handles accepted papers that have already been imported on a previous occasion
/**
         * @var $ejpPapers EjpPaper[]
         */ /**
         * @var $em EntityManager
         */ /**
             * @var $subjectArea SubjectArea
             */