/**
 * Pull in Client data
 */
function projectImport()
{
    $sql = "SELECT tid, name, description, field_client_tid AS clientId\n                FROM taxonomy_term_data\n                LEFT JOIN field_data_field_client relatedClient ON relatedClient.entity_id = taxonomy_term_data.tid\n                WHERE vid =3";
    try {
        $db = getConnectionMigrate();
        $stmt = $db->query($sql);
        $projects = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        foreach ($projects as $drupalRecord) {
            $seeIfExists = "SELECT p.clientId, p.drupalId, p.notes, p.id, p.name FROM projects as p\n                        LEFT JOIN client relatedClient on relatedClient.id = p.clientId\n                        WHERE p.drupalId = :drupalId";
            $dbExists = getConnection();
            $queryExists = $dbExists->prepare($seeIfExists);
            $queryExistTid = $drupalRecord->tid;
            $queryExists->bindParam("drupalId", $queryExistTid);
            $queryExists->execute();
            $rowExists = $queryExists->fetchAll(PDO::FETCH_OBJ);
            $dbExists = null;
            if (count($rowExists)) {
                $compareRows = migrateCompareProject($rowExists[0], $drupalRecord);
            } else {
                $insert = migrateInsertProject($drupalRecord);
            }
        }
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
/**
 * Pull in Client data
 */
function tasksImport()
{
    //1. Find all tasks in drupal
    //2. See if it exists
    //3. The pull in all the external relations for that task
    $sql = "SELECT \n\t\t\t\tnid, \n\t\t\t\ttitle, \n\t\t\t\tuid, \n\t\t\t\tcreated, \n\t\t\t\tbody_value as body, \n\t\t\t\ttaskStatus.field_status_tid as statusId,\n\t\t\t\tstatusName.name as statusName\n                FROM node \n                LEFT JOIN field_data_body body ON body.entity_id = node.nid \n\t\t\t\tLEFT JOIN field_data_field_status taskStatus ON taskStatus.entity_id = node.nid \n                LEFT JOIN taxonomy_term_data statusName on statusName.tid =  taskStatus.field_status_tid\n                WHERE type LIKE 'task' LIMIT 100";
    try {
        $db = getConnectionMigrate();
        $stmt = $db->query($sql);
        $tasks = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        foreach ($tasks as $drupalRecord) {
            $seeIfExists = "SELECT t.id, t.drupalId, t.project_id, t.name, t.assigned, t.notify, t.notes, t.created, t.due,\n                        t.expected_time, t.status, t.meeting, t.actual_time\n                        FROM tasks t\n                        WHERE t.drupalId = :drupalId";
            $dbExists = getConnection();
            $queryExists = $dbExists->prepare($seeIfExists);
            $queryExistNid = $drupalRecord->nid;
            $queryExists->bindParam("drupalId", $queryExistNid);
            $queryExists->execute();
            $rowExists = $queryExists->fetchAll(PDO::FETCH_OBJ);
            $dbExists = null;
            if (count($rowExists)) {
                //$compareRows = migrateCompareProject($rowExists[0], $drupalRecord);
            } else {
                $insert = migrateInsertTask($drupalRecord);
            }
        }
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
Esempio n. 3
0
/**
 * Pull in Client data
 */
function clientImport()
{
    $sql = "SELECT * FROM taxonomy_term_data WHERE vid = 2";
    try {
        $db = getConnectionMigrate();
        $stmt = $db->query($sql);
        $clients = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        foreach ($clients as $drupalRecord) {
            $seeIfExists = "SELECT * FROM client WHERE drupalId = :drupalId";
            $dbExists = getConnection();
            $queryExists = $dbExists->prepare($seeIfExists);
            $queryExistTid = $drupalRecord->tid;
            $queryExists->bindParam("drupalId", $queryExistTid);
            $queryExists->execute();
            $rowExists = $queryExists->fetchAll(PDO::FETCH_OBJ);
            $dbExists = null;
            if (count($rowExists)) {
                $compareRows = migrateCompareClient($rowExists[0], $drupalRecord);
            } else {
                $insert = migrateInsertClient($drupalRecord);
            }
        }
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
/**
 * Pull in Client data
 */
function featuresImport()
{
    $sql = "SELECT tid, name, description, p.field_related_project_tid as relatedProjectDrupalId, f.related_project\n                FROM taxonomy_term_data f\n\t\tLEFT JOIN field_data_field_related_project p ON p.entity_id = f.tid\n\t\tWHERE vid =8";
    try {
        $db = getConnectionMigrate();
        $stmt = $db->query($sql);
        $features = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        foreach ($features as $drupalRecord) {
            $seeIfExists = "SELECT f.id, f.drupalId, f.name, f.notes FROM features as f\n                        WHERE f.drupalId = :drupalId";
            $dbExists = getConnection();
            $queryExists = $dbExists->prepare($seeIfExists);
            $queryExistTid = $drupalRecord->tid;
            $queryExists->bindParam("drupalId", $queryExistTid);
            $queryExists->execute();
            $rowExists = $queryExists->fetchAll(PDO::FETCH_OBJ);
            $dbExists = null;
            if (count($rowExists)) {
                echo "Drupal tid of project {$drupalRecord->relatedProjectDrupalId}";
                $compareRows = migrateCompareFeatures($rowExists[0], $drupalRecord);
            } else {
                $insert = migrateInsertFeatures($drupalRecord);
            }
        }
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}
/**
 * Pull in Client data
 */
function peopleImport()
{
    $sql = "SELECT uid, mail, name, status from users";
    try {
        $db = getConnectionMigrate();
        $stmt = $db->query($sql);
        $users = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        foreach ($users as $drupalRecord) {
            $seeIfExists = "SELECT p.email, p.id, p.drupalId, p.fname, p.lname FROM people as p\n                        WHERE p.drupalId = :drupalId";
            $dbExists = getConnection();
            $queryExists = $dbExists->prepare($seeIfExists);
            $queryExistTid = $drupalRecord->uid;
            $queryExists->bindParam("drupalId", $queryExistTid);
            $queryExists->execute();
            $rowExists = $queryExists->fetchAll(PDO::FETCH_OBJ);
            $dbExists = null;
            if (count($rowExists)) {
                $compareRows = migrateComparePeople($rowExists[0], $drupalRecord);
            } else {
                $insert = migrateInsertPeople($drupalRecord);
            }
        }
    } catch (PDOException $e) {
        echo '{"error":{"text":' . $e->getMessage() . '}}';
    }
}