-
Notifications
You must be signed in to change notification settings - Fork 0
/
division.inc
185 lines (147 loc) · 6.04 KB
/
division.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
/**
* @file
* Implementation of migration from Commonspot Award custom element to Drupal award nodes.
*/
class NistDivisionMigration extends NistMigration {
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Import of Commonspot Divisions content type into the OU/lab content type');
$this->dependencies = array('NistUser');
$fields = array(
'changed' => 'Date the page was last modified',
'contact_block' => 'legacy contact info',
'created' => 'Date the page was last created',
'cs_uid' => 'Commonspot user that created the page',
'fic_division_highlights' => ' ',
'fic_division_id' => ' ',
'fic_division_selected_publications' => ' ',
'fic_division_welcome_text' => 'BODY',
'owner_name' => 'Plaintext username of the owner of the page',
'page_description' => 'Description of the page, often not used and same and title',
'page_title' => 'Title of the page',
'pageid' => 'CommonSpot PageID',
'pagename' => 'Name of the page used in the url',
'parsedimageids' => 'Image ids of any images parsed from body text',
'path' => 'URL in the CommonSpot system possibly used for Pathauto purposes',
'taxonomy_ids' => 'IDs of taxonomy terms from FLEET'
);
$this->highwaterField = array(
'name' => 'changed'
);
$this->source = new MigrateSourceJSON('', 'pageid', $fields);
$this->destination = new MigrateDestinationNode('laboratory_organizational_unit');
$this->map = new MigrateSQLMap(
$this->machineName,
array(
'pageid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Page ID',
)
),
MigrateDestinationNode::getKeySchema()
);
// fic_division_welcome_text
// Mapped fields
$this->addFieldMapping('body', 'formattedBodyContent');
$this->addFieldMapping('body:format')
->defaultValue('filtered_html');
$this->addFieldMapping('body:language')
->defaultValue('en');
$this->addFieldMapping('changed', 'changed');
$this->addFieldMapping('created', 'created');
$this->addFieldMapping('field_legacy_contact', 'contact_block');
$this->addFieldMapping('field_legacy_contact:format')
->defaultValue('filtered_html');
$this->addFieldMapping('field_legacy_contact:language')
->defaultValue('en');
$this->addFieldMapping('field_nist_org', 'generatedOrg');
$this->addFieldMapping('field_nist_topics', 'taxonomy_ids')
->separator(',')
->sourceMigration('NistTerm');
$this->addFieldMapping('field_nist_topics:create_term')
->defaultValue('False');
$this->addFieldMapping('field_nist_topics:source_type')
->defaultValue('tid');
$this->addFieldMapping('path', 'path');
$this->addFieldMapping('pathauto')
->defaultValue(1);
$this->addFieldMapping('status')
->defaultValue(1);
$this->addFieldMapping('title', 'page_title');
$this->addFieldMapping('translate')
->defaultValue(0);
$this->addFieldMapping('uid', 'cs_uid')
->sourceMigration('NistUser');
// field_access_rights
$this->addFieldMapping('field_access_rights', 'permissionTIDBasedOnSubSite')
->separator(',');
$this->addFieldMapping('field_access_rights:source_type')
->defaultValue('tid');
$this->addFieldMapping('field_access_rights:create_term')
->defaultValue('False');
// NEW field_nist_topic_areas
$this->addFieldMapping('field_nist_topic_areas', 'newTaxonomyTermList')
->separator(',');
$this->addFieldMapping('field_nist_topic_areas:source_type')
->defaultValue('tid');
$this->addFieldMapping('field_nist_topic_areas:create_term')
->defaultValue('False');
// Unmapped destination fields
$this->addUnmigratedDestinations(array('is_new', 'revision_uid', 'promote',
'sticky', 'revision', 'log', 'language', 'tnid', 'comment', 'body:summary',
'field_campus:ignore_case', 'field_campus:source_type', 'field_campus:create_term',
'field_nist_org:source_type', 'field_nist_org:create_term', 'field_nist_org:ignore_case',
'field_nist_topics:ignore_case'
));
// Unmapped source fields
$this->addUnmigratedSources(array('pagename', 'page_description', 'generatedOrg'));
}
/**
* Implementation of Migration::prepareRow($row).
*/
public function prepareRow( $row ) {
if (parent::prepareRow($row) === FALSE) :
return FALSE;
endif;
// get the new Taxonomy terms based on current Commonspot taxonomy ids
$row->newTaxonomyTermList = $this->getNewMappedTaxonomyTermsByOldIDList($row->taxonomy_ids);
$row->path = $this->_process_path($row->path);
// Translates CS Subsite to NIST organization
$row->generatedOrg = $this->_get_org_chart_name($row->path);
// add some time (one min) to the changed value so it is forced to be updated.
$row->changed = $this->_get_updated_time_for_force_updating($row->changed);
$row->cs_uid = $this->_translate_user_id($row->cs_uid);
$row->formattedBodyContent = $this->_process_body_text_native($row->fic_division_welcome_text, 'division-migrate-image');
// access rights taxonomy
$theTID = $this->getPermissionTaxonomyDataBySubSiteURL( $this->getSubSiteFromPath($row->path) );
$row->permissionTIDBasedOnSubSite = $theTID;
}
/**
* I am called by convention by the Migrate framework
* @param $node
* @param \stdClass $row
*/
public function prepare($node, stdClass $row) {
// sometimes the checkbox for pathauto isn't checked by default. Lets go ahead
// and force it.
$node->path['pathauto'] = TRUE;
}
/**
* I am called by convention by the Migrate framework
* @param $node
* @param \stdClass $row
*/
public function complete($node, stdClass $row) {
$this->addRedirect($node, $row);
}
/**
* I am called by convention. I call the completRollbck
* @param array $nids
*/
public function bulkRollback(array $nids) {
//$this->prepareRollback($nids, 'Award');
}
}