Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->doa = new Doa();
     $this->doa->setId(1);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $this->doa->setProgram($program);
     $organisation = new Organisation();
     $organisation->setId(1);
     $organisation->setOrganisation("Organisation");
     $this->doa->setOrganisation($organisation);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->doa)) {
         $this->authorizeService->getAcl()->addResource($this->doa);
         $this->authorizeService->getAcl()->allow([], $this->doa, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Doa())) {
         $this->authorizeService->getAcl()->addResource(new Doa());
     }
     $this->authorizeService->getAcl()->allow([], new Doa(), []);
     $this->doaLink = $this->serviceManager->get('viewhelpermanager')->get('programDoaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->program = new Program();
     $this->program->setId(1);
     $this->program->setProgram('This is the program');
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->program)) {
         $this->authorizeService->getAcl()->addResource($this->program);
         $this->authorizeService->getAcl()->allow([], $this->program, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Program())) {
         $this->authorizeService->getAcl()->addResource(new Program());
     }
     $this->authorizeService->getAcl()->allow([], new Program(), []);
     $this->programLink = $this->serviceManager->get('viewhelpermanager')->get('programlink');
     $routeMatch = new RouteMatch(['program' => 1]);
     $routeMatch->setMatchedRouteName('route-program_entity_program');
     $this->programLink->setRouteMatch($routeMatch);
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->call = new Call();
     $this->call->setId(1);
     $this->call->setCall('This is the call');
     $program = new Program();
     $program->setProgram('This is the program');
     $this->call->setProgram($program);
     $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize');
     if (!$this->authorizeService->getAcl()->hasResource($this->call)) {
         $this->authorizeService->getAcl()->addResource($this->call);
         $this->authorizeService->getAcl()->allow([], $this->call, []);
     }
     /**
      * Add the resource on the fly
      */
     if (!$this->authorizeService->getAcl()->hasResource(new Call())) {
         $this->authorizeService->getAcl()->addResource(new Call());
     }
     $this->authorizeService->getAcl()->allow([], new Call(), []);
     $this->callLink = $this->serviceManager->get('viewhelpermanager')->get('calllink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Esempio n. 4
0
 public function testCanRenderDoa()
 {
     /**
      * Bootstrap the application to have the other information available
      */
     $renderDoa = new RenderDoa();
     $renderDoa->setServiceLocator($this->serviceManager);
     $contact = new Contact();
     $contact->setFirstName('Johan');
     $contact->setLastName('van der Heide');
     $program = new Program();
     $program->setProgram('testProgram');
     $doa = new Doa();
     $doa->setContact($contact);
     $doa->setProgram($program);
     $pdf = $renderDoa->renderForDoa($doa);
     $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf);
     $this->assertTrue(strlen($pdf->getPDFData()) > 0);
 }
Esempio n. 5
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->nda = new Nda();
     $this->nda->setId(1);
     $contact = new Contact();
     $contact->setId(1234);
     $this->nda->setContact($contact);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $call = new Call();
     $call->setId(1);
     $call->setCall("Call");
     $call->setProgram($program);
     $this->nda->setCall(new ArrayCollection([$call]));
     $this->ndaLink = $this->serviceManager->get('viewhelpermanager')->get('ndaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Esempio n. 6
0
 /**
  * @return bool
  */
 public function isEmpty()
 {
     return is_null($this->program) || is_null($this->program->getId());
 }
Esempio n. 7
0
 public function testHasInputFilter()
 {
     $program = new Program();
     $this->assertInstanceOf('Zend\\InputFilter\\InputFilter', $program->getInputFilter());
 }
 /**
  * Checks if the affiliation has a DOA.
  *
  * @param Program $program
  *
  * @return bool
  */
 public function hasDoaForProgram(Program $program)
 {
     foreach ($this->organisation->getProgramDoa() as $doa) {
         if ($doa->getProgram()->getId() === $program->getId()) {
             return true;
         }
     }
     return false;
 }
Esempio n. 9
0
 /**
  * @return string
  */
 public function parseInvoiceName()
 {
     return sprintf("%s %s", $this->call, $this->program->getProgram());
 }
Esempio n. 10
0
 /**
  * @param Program $program
  *
  * @return string
  */
 public function __invoke(Program $program)
 {
     set_time_limit(0);
     $document = new DOMDocument('1.0', 'UTF-8');
     $eureka = $document->createElement('EurekaCluster');
     $eureka->setAttribute('version', '1.0');
     $eureka->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:noNamespaceSchemaLocation', 'http://clusters.eurekanetwork.org/resources/xsd/EurekaCluster.xsd');
     $document->appendChild($eureka);
     /*
      * Add the status of the export
      */
     $status = $document->createElement('status', 'OK');
     $status->setAttribute('code', '200');
     $eureka->appendChild($status);
     /*
      * Append the result of the export itself
      */
     $result = $document->createElement('result');
     /*
      * Add the details of the request
      */
     $request = $document->createElement('request');
     $request->appendChild($document->createElement('type', 'rest'));
     $request->appendChild($document->createElement('url', 'https://itea3.org'));
     $request->appendChild($document->createElement('query', ''));
     $result->appendChild($request);
     /*
      * Add the cluster details
      */
     $cluster = $document->createElement('cluster', $program->getProgram());
     $cluster->setAttribute('cluster_id', $program->getNumber());
     $result->appendChild($cluster);
     /*
      * Add the projects
      */
     $projects = $document->createElement('projects');
     /*
      * Add each project.
      *
      * @var Project
      */
     foreach ($this->getProjectService()->findProjectByProgram($program, ProjectService::WHICH_LABELLED)->getQuery()->getResult() as $project) {
         $projectService = $this->getProjectService()->setProject($project);
         //Get some required versions
         $fpp = $this->getVersionService()->findLatestVersionByType($projectService->getProject(), $this->getVersionService()->findEntityById('Version\\Type', Type::TYPE_FPP));
         /*
          * Find the latest version which was approved
          */
         $version = $this->getProjectService()->getLatestProjectVersion(null, null, false, true);
         $this->getVersionService()->setVersion($version);
         /*
          * Keep local variables with heavy database intensive numbers
          */
         $totalCost = $this->getVersionService()->findTotalCostVersionByProjectVersion($version);
         $totalEffort = $this->getVersionService()->findTotalEffortVersionByProjectVersion($version);
         $projectElement = $document->createElement('project');
         /*
          * Go over the project information
          */
         $projectElement->appendChild($document->createElement('project_id', $projectService->getProject()->getNumber()));
         $projectElement->appendChild($document->createElement('title', $this->xmlEntities($projectService->getProject()->getTitle())));
         $summary = $document->createElement('summary');
         $summary->appendChild($document->createCDATASection($this->xmlEntities($projectService->getProject()->getSummary())));
         $projectElement->appendChild($summary);
         $projectElement->appendChild($document->createElement('acronym', substr($this->xmlEntities($projectService->getProject()->getProject()), 0, 20)));
         $projectElement->appendChild($document->createElement('label_date', $fpp->getDateReviewed()->format('Y-m-d')));
         if (!is_null($projectService->parseOfficialDateStart())) {
             $projectElement->appendChild($document->createElement('start_date', $projectService->parseOfficialDateStart()->format('Y-m-d')));
         } else {
             /*
              * @todo, the XSD needs an upgrade to have these values passed correctly
              */
             $projectElement->appendChild($document->createElement('start_date', '1970-01-01'));
         }
         if (!is_null($version->getDateStart()) and !is_null($version->getDateEnd())) {
             $projectElement->appendChild($document->createElement('duration', $this->getVersionService()->parseDuration()));
         } else {
             $projectElement->appendChild($document->createElement('duration', 0));
         }
         $projectElement->appendChild($document->createElement('total_cost', ceil($totalCost)));
         $projectElement->appendChild($document->createElement('total_man_year', ceil($totalEffort)));
         if (!is_null($projectService->parseOfficialDateEnd())) {
             $projectElement->appendChild($document->createElement('end_date', $projectService->parseOfficialDateEnd()->format('Y-m-d')));
         } else {
             /*
              * @todo, the XSD needs an upgrade to have these values passed correctly
              */
             $projectElement->appendChild($document->createElement('end_date', '1970-01-01'));
         }
         /*
          * Include an element to indicate the the project is withdrawn (cancelled)
          */
         if ($projectService->isCancelled()) {
             $projectElement->appendChild($document->createElement('withdrawal_date', $version->getDateReviewed()->format('Y-m-d')));
         } else {
             $projectElement->appendChild($document->createElement('withdrawal_date', null));
         }
         /*
          * Do a very simple mapping of the status of the project
          */
         switch (strtolower($projectService->parseStatus())) {
             case 'labelled':
                 $status = 'LAB';
                 break;
             case 'running':
                 $status = 'RUN';
                 break;
             case 'cancelled':
                 $status = 'FIN';
                 break;
             default:
                 $status = 'FIN';
         }
         /*
          * Define the role in the project (Main or Partner)
          */
         $statusName = $document->createElement('status_name');
         $statusName->setAttribute('status_id', $status);
         $projectElement->appendChild($statusName);
         //Add now the organisations.
         $organisationElement = $document->createElement('organisations');
         /*
          * @var Affiliation
          */
         foreach ($this->getAffiliationService()->findAffiliationByProjectVersionAndWhich($version, AffiliationService::WHICH_ALL) as $affiliation) {
             $affiliationElement = $document->createElement('prj_organisation');
             $affiliationElement->setAttribute('org_id', $affiliation->getOrganisation()->getId());
             /*
              * Go over the partner information
              */
             $affiliationElement->appendChild($document->createElement('org_name', $this->xmlEntities($affiliation->getOrganisation()->getOrganisation())));
             /*
              * Mapping of the organisation type on the EUREKA values
              */
             $orgType = $document->createElement('org_type');
             switch ($affiliation->getOrganisation()->getType()->getId()) {
                 case OrganisationType::TYPE_SME:
                     $typeNumber = 'S';
                     break;
                 case OrganisationType::TYPE_LARGE_INDUSTRY:
                 case OrganisationType::TYPE_IFC:
                     $typeNumber = 'I';
                     break;
                 case OrganisationType::TYPE_RESEARCH:
                     $typeNumber = 'R';
                     break;
                 case OrganisationType::TYPE_UNIVERSITY:
                     $typeNumber = 'U';
                     break;
                 case OrganisationType::TYPE_GOVERNMENT:
                     $typeNumber = 'A';
                     break;
                 case OrganisationType::TYPE_OTHER:
                 default:
                     $typeNumber = 'O';
             }
             $orgType->setAttribute('org_type_id', $typeNumber);
             $affiliationElement->appendChild($orgType);
             /*
              * Define the role in the project (Main or Partner)
              */
             $role = $document->createElement('role');
             $role->setAttribute('role_id', $affiliation->getContact()->getId() === $project->getContact()->getId() ? 'M' : 'P');
             $affiliationElement->appendChild($role);
             /*
              * Add the country
              */
             $country = $document->createElement('country', $affiliation->getOrganisation()->getCountry()->getIso3());
             $country->setAttribute('code', $affiliation->getOrganisation()->getCountry()->getCd());
             $affiliationElement->appendChild($country);
             /*
              * Add the country
              */
             $contactService = $this->getContactService()->setContact($affiliation->getContact());
             $affiliationElement->appendChild($document->createElement('zip_code', !is_null($contactService->getMailAddress()) ? $contactService->getMailAddress()->getAddress()->getZipCode() : '0000'));
             $affiliationElement->appendChild($document->createElement('contact_email', $this->xmlEntities($contactService->getContact()->getEmail())));
             $affiliationElement->appendChild($document->createElement('contribution_cost', ceil($this->getVersionService()->findTotalCostVersionByAffiliationAndVersion($affiliation, $version))));
             $affiliationElement->appendChild($document->createElement('contribution_man_year', $this->getVersionService()->findEffortVersionByAffiliationAndVersion($affiliation, $version)));
             $affiliationElement->appendChild($document->createElement('VAT_number', !is_null($affiliation->getOrganisation()->getFinancial()) ? $affiliation->getOrganisation()->getFinancial()->getVat() : null));
             $affiliationElement->appendChild($document->createElement('partner_withdrawn_date', !is_null($affiliation->getDateEnd()) ? $affiliation->getdateEnd()->format('Y-m-d') : null));
             $organisationElement->appendChild($affiliationElement);
         }
         $projectElement->appendChild($organisationElement);
         $projects->appendChild($projectElement);
     }
     $result->appendChild($projects);
     $eureka->appendChild($result);
     return $document->saveXML();
 }