This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/1.1.x-WIP' into 1.1.x-WIP
- Loading branch information
Showing
4 changed files
with
428 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<?php | ||
/** | ||
* Contains CallList class. | ||
* | ||
* PHP version 5.3 | ||
* | ||
* LICENSE: | ||
* This file is part of 1.1.x-WIP | ||
* Copyright (C) 2014 Michael Cummings | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General | ||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* You should be able to find a copy of this license in the LICENSE.md file. A copy of the GNU GPL should also be | ||
* available in the GNU-GPL.md file. | ||
* | ||
* @copyright 2014 Michael Cummings | ||
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL | ||
* @author Michael Cummings <mgcummings@yahoo.com> | ||
* @author Stephen Gulick <stephenmg12@gmail.com> | ||
*/ | ||
namespace Yapeal\Database\Map; | ||
|
||
use Yapeal\Database\AbstractCommonEveApi; | ||
use Yapeal\Database\AttributesDatabasePreserver; | ||
use Yapeal\Database\DatabasePreserverInterface; | ||
use Yapeal\Xml\EveApiPreserverInterface; | ||
use Yapeal\Xml\EveApiReadWriteInterface; | ||
use Yapeal\Xml\EveApiRetrieverInterface; | ||
use Yapeal\Xml\EveApiXmlModifyInterface; | ||
|
||
/** | ||
* Class CallList | ||
*/ | ||
class Characters extends AbstractCommonEveApi | ||
{ | ||
/** | ||
* @param EveApiReadWriteInterface $data | ||
* @param EveApiRetrieverInterface $retrievers | ||
* @param EveApiPreserverInterface $preservers | ||
* @param int $interval | ||
*/ | ||
public function autoMagic( | ||
EveApiReadWriteInterface $data, | ||
EveApiRetrieverInterface $retrievers, | ||
EveApiPreserverInterface $preservers, | ||
$interval | ||
) { | ||
$this->getLogger() | ||
->info( | ||
sprintf( | ||
'Starting autoMagic for %1$s/%2$s', | ||
$this->getSectionName(), | ||
$this->getApiName() | ||
) | ||
); | ||
/** | ||
* @var EveApiReadWriteInterface|EveApiXmlModifyInterface $data | ||
*/ | ||
$data->setEveApiSectionName(strtolower($this->getSectionName())) | ||
->setEveApiName($this->getApiName()) | ||
->setEveApiXml(); | ||
if ($this->cacheNotExpired( | ||
$this->getApiName(), | ||
$this->getSectionName() | ||
) | ||
) { | ||
return; | ||
} | ||
$retrievers->retrieveEveApi($data); | ||
if ($data->getEveApiXml() === false) { | ||
$mess = sprintf( | ||
'Could NOT retrieve Eve Api data for %1$s/%2$s', | ||
strtolower($this->getSectionName()), | ||
$this->getApiName() | ||
); | ||
$this->getLogger() | ||
->debug($mess); | ||
return; | ||
} | ||
$this->transformRowset($data); | ||
if ($this->isInvalid($data)) { | ||
$mess = sprintf( | ||
'Data retrieved is invalid for %1$s/%2$s', | ||
strtolower($this->getSectionName()), | ||
$this->getApiName() | ||
); | ||
$this->getLogger() | ||
->warning($mess); | ||
$data->setEveApiName('Invalid' . $this->getApiName()); | ||
$preservers->preserveEveApi($data); | ||
return; | ||
} | ||
$preservers->preserveEveApi($data); | ||
$preserver = new AttributesDatabasePreserver( | ||
$this->getPdo(), | ||
$this->getLogger(), | ||
$this->getCsq() | ||
); | ||
$this->preserveToCharacters($preserver, $data->getEveApiXml()); | ||
$this->updateCachedUntil($data, $interval, '0'); | ||
} | ||
/** | ||
* @return string | ||
*/ | ||
protected function getSectionName() | ||
{ | ||
if (empty($this->sectionName)) { | ||
$this->sectionName = basename(str_replace('\\', '/', __DIR__)); | ||
} | ||
return $this->sectionName; | ||
} | ||
/** | ||
* @return string | ||
*/ | ||
protected function getApiName() | ||
{ | ||
if (empty($this->apiName)) { | ||
$this->apiName = basename(str_replace('\\', '/', __CLASS__)); | ||
} | ||
return $this->apiName; | ||
} | ||
/** | ||
* @param DatabasePreserverInterface $preserver | ||
* @param string $xml | ||
*/ | ||
protected function preserveToCharacters( | ||
DatabasePreserverInterface $preserver, | ||
$xml | ||
) { | ||
$columnDefaults = array( | ||
'name' => null, | ||
'characterID' => null, | ||
'corporationID' => null, | ||
'corporationName' => null | ||
); | ||
$preserver->setTableName('mapFacWarSystems') | ||
->setColumnDefaults($columnDefaults) | ||
->preserveData($xml); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xs:schema attributeFormDefault="unqualified" | ||
elementFormDefault="qualified" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:include schemaLocation="../common.xsd"/> | ||
<xs:complexType name="rowType"> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"> | ||
<xs:attribute type="eveIDType" name="characterID"/> | ||
<xs:attribute type="xs:string" name="name"/> | ||
<xs:attribute type="eveNEDTType" name="startDateTime"/> | ||
<xs:attribute type="eveIDType" name="baseID"/> | ||
<xs:attribute type="xs:string" name="base"/> | ||
<xs:attribute type="xs:string" name="title"/> | ||
<xs:attribute type="eveNEDTType" name="logonDateTime"/> | ||
<xs:attribute type="eveNEDTType" name="logoffDateTime"/> | ||
<xs:attribute type="eveIDType" name="locationID"/> | ||
<xs:attribute type="xs:string" name="location"/> | ||
<xs:attribute type="xs:long" name="shipTypeID"/> | ||
<xs:attribute type="xs:string" name="shipType"/> | ||
<xs:attribute type="eveIDType" name="roles"/> | ||
<xs:attribute type="eveIDType" name="grantableRoles"/> | ||
</xs:extension> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
<xs:complexType name="resultType"> | ||
<xs:sequence> | ||
<xs:element name="members"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element type="rowType" | ||
name="row" | ||
minOccurs="0" | ||
maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
<xs:attributeGroup ref="rowsetAttrs"/> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:schema> |
Oops, something went wrong.