<?php
namespace App\Entity;
use App\Repository\PublicationRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass=PublicationRepository::class)
*/
class Publication
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
*/
private $UT;
/**
* @ORM\Column(type="string", length=50)
*/
private $doctype;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $pages;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $ISSUE;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $volume;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $publishedMonth;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $publishedYear;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $doi;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ISSN;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ISBN;
/**
* Many Publications have Many Keywords.
* @ORM\ManyToMany(targetEntity="Keyword", inversedBy="publications")
* @ORM\JoinTable(name="publications_keywords")
*/
private $keywords;
/**
* Many Publications have Many KeywordsPlus.
* @ORM\ManyToMany(targetEntity="KeywordPlus", inversedBy="publications")
* @ORM\JoinTable(name="publications_keywordsPlus")
*/
private $keywordsPlus;
/**
* One publication has many wosRecords. This is the inverse side.
* @ORM\OneToMany(targetEntity="WosRecord", mappedBy="publication")
*/
private $wosRecords;
/**
* One publication has many Grants. This is the inverse side.
* @ORM\OneToMany(targetEntity="Grant", mappedBy="publication")
*/
private $grants;
/**
* One publication has many PublicationAuthors. This is the inverse side.
* @ORM\OneToMany(targetEntity="PublicationAuthor", mappedBy="publication")
*/
private $publicationAuthors;
/**
* @ORM\Column(type="date")
*/
private $updatedDate;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $abstract;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $timesCited;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $fundingText;
/**
* Many Publications have one Journal. This is the owning side.
* @ORM\ManyToOne(targetEntity="Journal", inversedBy="publications", cascade={"persist"})
* @ORM\JoinColumn(name="journal_id", referencedColumnName="id")
*/
private $journal;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $interdisciplinary;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $validated;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $sidingId;
/**
* @ORM\ManyToOne(targetEntity=Publisher::class, inversedBy="publications")
*/
private $publisher;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $publicComments;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $privateComments;
/**
* @ORM\Column(type="string", length=50)
*/
private $publicationType = 'paper'; //para saber si son publicaciones tipo paper, conferencias o conferencia a*
public function __construct() {
$this->validated = false;
$this->keywords = new ArrayCollection();
$this->wosRecords = new ArrayCollection();
$this->grants = new ArrayCollection();
$this->publicationAuthors = new ArrayCollection();
$this->keywordsPlus = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getUT(): ?string
{
return $this->UT;
}
public function setUT(string $UT): self
{
$this->UT = $UT;
return $this;
}
public function getDoctype(): ?string
{
return $this->doctype;
}
public function setDoctype(string $doctype): self
{
$this->doctype = $doctype;
return $this;
}
public function getPages(): ?string
{
return $this->pages;
}
public function setPages(?string $pages): self
{
$this->pages = $pages;
return $this;
}
public function getISSUE(): ?string
{
return $this->ISSUE;
}
public function setISSUE(?string $ISSUE): self
{
$this->ISSUE = $ISSUE;
return $this;
}
public function getVolume(): ?string
{
return $this->volume;
}
public function setVolume(?string $volume): self
{
$this->volume = $volume;
return $this;
}
public function getPublishedMonth(): ?string
{
return $this->publishedMonth;
}
public function setPublishedMonth(?string $publishedMonth): self
{
$this->publishedMonth = $publishedMonth;
return $this;
}
public function getPublishedYear(): ?int
{
return $this->publishedYear;
}
public function setPublishedYear(?int $publishedYear): self
{
$this->publishedYear = $publishedYear;
return $this;
}
/**
* @return Collection<int, Keyword>
*/
public function getKeywords(): Collection
{
return $this->keywords;
}
public function addKeyword(Keyword $keyword): self
{
if (!$this->keywords->contains($keyword)) {
$this->keywords[] = $keyword;
}
return $this;
}
public function removeKeyword(Keyword $keyword): self
{
$this->keywords->removeElement($keyword);
return $this;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function setUpdatedDate(\DateTimeInterface $updatedDate): self
{
$this->updatedDate = $updatedDate;
return $this;
}
public function getDoi(): ?string
{
return $this->doi;
}
public function setDoi(?string $doi): self
{
$this->doi = $doi;
return $this;
}
/**
* @return Collection<int, WosRecord>
*/
public function getWosRecords(): Collection
{
return $this->wosRecords;
}
public function addWosRecord(WosRecord $wosRecord): self
{
if (!$this->wosRecords->contains($wosRecord)) {
$this->wosRecords[] = $wosRecord;
$wosRecord->setPublication($this);
}
return $this;
}
public function removeWosRecord(WosRecord $wosRecord): self
{
if ($this->wosRecords->removeElement($wosRecord)) {
// set the owning side to null (unless already changed)
if ($wosRecord->getPublication() === $this) {
$wosRecord->setPublication(null);
}
}
return $this;
}
public function getAbstract(): ?string
{
return $this->abstract;
}
public function setAbstract(?string $abstract): self
{
$this->abstract = $abstract;
return $this;
}
public function getTimesCited(): ?int
{
return $this->timesCited;
}
public function setTimesCited(?int $timesCited): self
{
$this->timesCited = $timesCited;
return $this;
}
/**
* @return Collection<int, Grant>
*/
public function getGrants(): Collection
{
return $this->grants;
}
public function addGrant(Grant $grant): self
{
if (!$this->grants->contains($grant)) {
$this->grants[] = $grant;
$grant->setPublication($this);
}
return $this;
}
public function removeGrant(Grant $grant): self
{
if ($this->grants->removeElement($grant)) {
// set the owning side to null (unless already changed)
if ($grant->getPublication() === $this) {
$grant->setPublication(null);
}
}
return $this;
}
/**
* @return Collection<int, PublicationAuthor>
*/
public function getPublicationAuthors(): Collection
{
return $this->publicationAuthors;
}
public function addPublicationAuthor(PublicationAuthor $publicationAuthor): self
{
if (!$this->publicationAuthors->contains($publicationAuthor)) {
$this->publicationAuthors[] = $publicationAuthor;
$publicationAuthor->setPublication($this);
}
return $this;
}
public function removePublicationAuthor(PublicationAuthor $publicationAuthor): self
{
if ($this->publicationAuthors->removeElement($publicationAuthor)) {
// set the owning side to null (unless already changed)
if ($publicationAuthor->getPublication() === $this) {
$publicationAuthor->setPublication(null);
}
}
return $this;
}
/**
* @return Collection<int, KeywordPlus>
*/
public function getKeywordsPlus(): Collection
{
return $this->keywordsPlus;
}
public function addKeywordsPlu(KeywordPlus $keywordsPlu): self
{
if (!$this->keywordsPlus->contains($keywordsPlu)) {
$this->keywordsPlus[] = $keywordsPlu;
}
return $this;
}
public function removeKeywordsPlu(KeywordPlus $keywordsPlu): self
{
$this->keywordsPlus->removeElement($keywordsPlu);
return $this;
}
public function getFundingText(): ?string
{
return $this->fundingText;
}
public function setFundingText(?string $fundingText): self
{
$this->fundingText = $fundingText;
return $this;
}
public function getIngAuthors() {
$ingAuthors = new ArrayCollection();
foreach ($this->publicationAuthors as $publicationAuthor) {
if(!is_null($publicationAuthor->getAuthor())) {
$ingAuthors->add($publicationAuthor->getAuthor());
}
}
return $ingAuthors;
}
public function getIngPublicationAuthors() {
$ingPublicationAuthors = new ArrayCollection();
foreach ($this->publicationAuthors as $publicationAuthor) {
if(!is_null($publicationAuthor->getAuthor())) {
$ingPublicationAuthors->add($publicationAuthor);
}
}
return $ingPublicationAuthors;
}
public function getExternalAuthors() {
$externalAuthors = new ArrayCollection();
foreach ($this->publicationAuthors as $publicationAuthor) {
if(!is_null($publicationAuthor->getExternalAuthor())) {
$externalAuthors->add($publicationAuthor->getExternalAuthor());
}
}
return $externalAuthors;
}
public function getISSN(): ?string
{
return $this->ISSN;
}
public function setISSN(?string $ISSN): self
{
$this->ISSN = $ISSN;
return $this;
}
public function getISBN(): ?string
{
return $this->ISBN;
}
public function setISBN(?string $ISBN): self
{
$this->ISBN = $ISBN;
return $this;
}
public function getJournal(): ?Journal
{
return $this->journal;
}
public function setJournal(?Journal $journal): self
{
$this->journal = $journal;
return $this;
}
public function getInterdisciplinary(): ?bool
{
return $this->interdisciplinary;
}
public function setInterdisciplinary(?bool $interdisciplinary): self
{
$this->interdisciplinary = $interdisciplinary;
return $this;
}
public function getValidated(): ?bool
{
return $this->validated;
}
public function setValidated(bool $validated):self
{
$this->validated = $validated;
return $this;
}
public function getSidingId(): ?int
{
return $this->sidingId;
}
public function setSidingId(?int $sidingId): self
{
$this->sidingId = $sidingId;
return $this;
}
public function getPublisher(): ?Publisher
{
return $this->publisher;
}
public function setPublisher(?Publisher $publisher): self
{
$this->publisher = $publisher;
return $this;
}
public function getAuthorsCite() {
$authors = [];
foreach ($this->publicationAuthors as $author) {
$authors[] = $this->remove_accents($author->getCiteName());
}
return implode(', ', $authors);
}
public function withFacultyUC() {
$with = false;
foreach ($this->getPublicationAuthors() as $publicationAuthor) {
if($publicationAuthor->getUcNotIng()) {
$with = true;
break;
}
}
return $with;
}
public function withNational() {
$with = false;
foreach ($this->getPublicationAuthors() as $publicationAuthor) {
if( !$publicationAuthor->isIng()) {
foreach ($publicationAuthor->getOrganizations() as $organization) {
if( $organization->getCountry() == 'Chile') {
$with = true;
break;
}
}
if($with) break; //esto para evitar seguir con el loop
}
}
return $with;
}
public function withInternational() {
$with = false;
foreach ($this->getPublicationAuthors() as $publicationAuthor) {
if( !$publicationAuthor->isIng()) {
foreach ($publicationAuthor->getOrganizations() as $organization) {
if( $organization->getCountry() != 'Chile') {
$with = true;
break;
}
}
if($with) break; //esto para evitar seguir con el loop
}
}
return $with;
}
public function withTop50() {
$with = false;
foreach ($this->getPublicationAuthors() as $publicationAuthor) {
$organizations = $publicationAuthor->getOrganizations();
//revisamos si organization tiene top50
foreach ($organizations as $organization) {
if( count($organization->getTop50s()) > 0) {
foreach ($organization->getTop50s() as $top50) {
if( $top50->getYear() == $this->getPublishedYear() ) {
$with = true;
break;
}
}
if($with) break; //esto para evitar seguir con el loop
}
}
}
return $with;
}
public function hasPDHStudent() {
$with = false;
foreach ($this->getPublicationAuthors() as $publicationAuthor) {
if( $publicationAuthor->getPhdStudent()) {
$with = true;
break;
}
}
return $with;
}
public function hasMasterStudent() {
$with = false;
foreach ($this->getPublicationAuthors() as $publicationAuthor) {
if( $publicationAuthor->getMasterStudent()) {
$with = true;
break;
}
}
return $with;
}
public function remove_accents($string) {
return iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string);
}
public function getPublicComments(): ?string
{
return $this->publicComments;
}
public function setPublicComments(?string $publicComments): self
{
$this->publicComments = $publicComments;
return $this;
}
public function getPrivateComments(): ?string
{
return $this->privateComments;
}
public function setPrivateComments(?string $privateComments): self
{
$this->privateComments = $privateComments;
return $this;
}
public function getPublicationType(): ?string
{
return $this->publicationType;
}
public function getPublicationTypeChoices(): array
{
return [
'paper' => 'paper',
'conference' => 'conference',
'conference_a*' => 'conference_a*',
];
}
public function setPublicationType(string $publicationType): self
{
// validar que el valor sea uno de los permitidos
if (!in_array($publicationType, $this->getPublicationTypeChoices())) {
throw new \InvalidArgumentException('Invalid publication type');
}
$this->publicationType = $publicationType;
return $this;
}
}