Esempio n. 1
0
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
//on met les bon types de tags pour les tags existants
$tree = new Tag('new');
$tree = $tree->getRoot();
$rows = $tree->queryAndFetch('SELECT * FROM pmd_tagtype');
$types = array();
foreach ($rows as $row) {
    $types[$row['qname']] = $row;
}
$children = $tree->getChildren();
$tree->autocommit(false);
$database = DataSource::get('old');
foreach ($children as $child) {
    if ($child->getValue('caption') == 'Entreprise') {
        $entreprises = $child->getChildren(true);
        foreach ($entreprises as $entreprise) {
            $caption = $entreprise->getValue('caption');
            if (preg_match('`\\w{2}\\w{10}`', $caption) && $entreprise->getValue('mastertag_id')) {
                $parentTag = $entreprise->getParent();
                if ($parentTag->getId()) {
                    $query = "SELECT * FROM entreprise_entreprise WHERE isin='" . $entreprise->getValue('caption') . "'";
                    $values = $database->queryAndFetchOne($query);
                    if (!empty($values)) {
                        echo $caption . "\t" . $parentTag->getValue('caption') . "\t" . $values['id'] . "\n";
                        $parentTag->setInheritableAttributesValues(array('attributes' => array('cofisemId' => $values['id'])));
                        $parentTag->update();
                    }
Esempio n. 2
0
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
ini_set('memory_limit', '-1');
$oldModel = DataSource::get('old');
$newModel = DataSource::get('new');
$ezObjectType = new ObjectType($newModel);
$ezObjectType->loadBy('qname', 'ezobject');
$defaultAssociation = new AssociationType($newModel);
$defaultAssociation->loadBy('qname', 'default');
$query = "\n    SELECT DISTINCT\n      tag.keyword,\n      association.object_id\n    FROM eztags_attribute_link association\n    JOIN eztags tag\n      ON tag.id=association.keyword_id\n\n";
$rows = $oldModel->queryAndFetch($query);
$newModel->autocommit(false);
foreach ($rows as $row) {
    $tag = new Tag($newModel);
    $tag->loadBy('caption', $row['keyword']);
    $association = new Association($newModel);
    $association->setValue('tag_id', $tag->getId());
    $association->setValue('object_id', $row['object_id']);
    $association->setObjectType($ezObjectType);
    $association->setType($defaultAssociation);
    $association->insert();
    echo $tag->getValue('caption') . "\t" . $row['object_id'] . "\n";
}
$newModel->commit();
//print_r($rows);
Esempio n. 3
0
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
$tagDataSource = DataSource::get('new');
echo "Create default association type\n";
$query = "\n        INSERT INTO " . AssociationType::getTableName() . " (\n          qname,\n          caption,\n          datecreation\n        ) VALUES (\n          'default',\n          'Association par défaut',\n          NOW()\n        );\n";
$tagDataSource->query($query);
echo "Create related object association type\n";
$query = "\n        INSERT INTO " . AssociationType::getTableName() . " (\n          qname,\n          caption,\n          datecreation\n        ) VALUES (\n          'related',\n          'Relation de contenu',\n          NOW()\n        );\n";
$tagDataSource->query($query);
echo "Create Default Object type\n";
$query = "\n    INSERT INTO pmd_objecttype (\n      qname,\n      caption,\n      datecreation\n    ) VALUES (\n      'default',\n      'Type par défaut',\n      NOW()\n    )\n";
$tagDataSource->query($query);
$parentId = $tagDataSource->getLastInsertId();
echo "Create Tag Object type\n";
$query = "\n    INSERT INTO pmd_objecttype (\n      parent_id,\n      qname,\n      caption,\n      datecreation\n    ) VALUES (\n      " . $parentId . ",\n      'tag',\n      'Tag',\n      NOW()\n    )\n";
$tagDataSource->query($query);
echo "Construction de l'arbre des types\n";
$tree = new ObjectType();
$tree->setSource($tagDataSource);
$tree->buildTree();
echo "Create Default tag type\n";
$query = "\n  INSERT INTO " . Type::getTableName() . " (\n    qname,\n    caption,\n    datecreation,\n    data\n  ) VALUES (\n    'default',\n    'Type par défaut',\n    NOW(),\n    ''\n  )\n";
$tagDataSource->query($query);
$tagTypeTree = new Type($tagDataSource);
$rootTypeNode = $tagTypeTree->getRoot();
Esempio n. 4
0
 public function getDataSource()
 {
     return DataSource::get('new');
 }
Esempio n. 5
0
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
$tagDataSource = DataSource::get('old');
//selection de toutes les relations pagehub/tag de l'ancien système
$query = "SELECT * FROM eztags";
$rows = $tagDataSource->queryAndFetch($query);
$relatedAssociation = new AssociationType('new');
$relatedAssociation->loadBy('qname', 'related');
$tagType = new ObjectType('new');
$tagType->loadBy('qname', 'tag');
foreach ($rows as $values) {
    $query = "\n    SELECT\n        DISTINCT\n            originTag.id as tagId,\n            originTag.remote_id as pagehubId,\n            originTag.keyword as fromKeyword,\n            destinationTag.id as destinationId,\n            destinationTag.keyword as destinationKeyword\n    FROM eztags originTag\n    JOIN eztags_attribute_link link\n        ON link.object_id=originTag.remote_id\n    JOIN eztags destinationTag\n        ON destinationTag.id=link.keyword_id\n    WHERE originTag.id=" . $values['id'] . "\n    ";
    $relationData = $tagDataSource->queryAndFetch($query);
    if (!empty($relationData)) {
        foreach ($relationData as $values) {
            //récupération du tag d'origine dans la nouvelle bdd
            $fromTag = new Tag('new');
            $fromTag->loadBy('caption', $values['fromKeyword']);
            $relatedTag = new Tag('new');
            $relatedTag->loadBy('caption', $values['destinationKeyword']);
            //récupération pour le related tag
            if ($fromTag->getId() && $relatedTag->getId()) {
                $association = new Association('new');
                $association->setType($relatedAssociation);
                $association->setObjectType($tagType);
Esempio n. 6
0
 public function getDefaultSource()
 {
     return \PMD\Capital\Configuration\DataSource::get('default');
 }