7
7
class MIDAS2MigrationComponent extends AppComponent
8
8
{
9
9
10
- /** function to create the items */
10
+ /** function to create the items */
11
11
private function _createFolderForItem ($ collectionId , $ parentFolderid )
12
12
{
13
13
set_time_limit (0 );
@@ -20,10 +20,10 @@ private function _createFolderForItem($collectionId, $parentFolderid)
20
20
$ Folderpolicyuser = $ modelLoader ->loadModel ("Folderpolicyuser " );
21
21
$ Itempolicygroup = $ modelLoader ->loadModel ("Itempolicygroup " );
22
22
23
- $ colquery = pg_query ("SELECT i.item_id,mtitle.text_value AS title,mabstract.text_value AS abstract " .
23
+ $ colquery = pg_query ("SELECT i.item_id,mtitle.text_value AS title,mabstract.text_value AS abstract " .
24
24
"FROM item AS i " .
25
- "LEFT JOIN metadatavalue AS mtitle ON (i.item_id = mtitle.item_id AND mtitle.metadata_field_id = 64) " .
26
- "LEFT JOIN metadatavalue AS mabstract ON (i.item_id = mabstract.item_id AND mabstract.metadata_field_id = 27) " .
25
+ "LEFT JOIN metadatavalue AS mtitle ON (i.item_id = mtitle.item_id AND mtitle.metadata_field_id = 64) " .
26
+ "LEFT JOIN metadatavalue AS mabstract ON (i.item_id = mabstract.item_id AND mabstract.metadata_field_id = 27) " .
27
27
"WHERE i.owning_collection= " .$ collectionId );
28
28
while (pg_fetch_array ($ colquery ))
29
29
{
@@ -34,7 +34,7 @@ private function _createFolderForItem($collectionId, $parentFolderid)
34
34
$ folderDao = false ;
35
35
try
36
36
{
37
- // Create the folder for the community
37
+ // Create the folder for the item
38
38
$ folderDao = $ Folder ->createFolder ($ title , $ abstract , $ parentFolderid );
39
39
40
40
// Assign the policies to the folder as the same as the parent folder
@@ -57,15 +57,16 @@ private function _createFolderForItem($collectionId, $parentFolderid)
57
57
catch (Zend_Exception $ e )
58
58
{
59
59
$ this ->getLogger ()->info ($ e ->getMessage ());
60
- // Zend_Debug::dump($e);
60
+ Zend_Debug::dump ($ e );
61
61
//we continue
62
+ exit ();
62
63
}
63
64
64
65
if ($ folderDao )
65
66
{
66
67
// Create the item from the bitstreams
67
- $ bitquery = pg_query ("SELECT b.bitstream_id,b.name,b.description,b.internal_id FROM bitstream AS b,item2bitstream AS i2b " .
68
- "WHERE i2b.bitstream_id = b.bitstream_id AND i2b.item_id= " .$ item_id );
68
+ $ bitquery = pg_query ("SELECT b.bitstream_id,b.name,b.description,b.internal_id FROM bitstream AS b,item2bitstream AS i2b " .
69
+ "WHERE i2b.bitstream_id = b.bitstream_id AND i2b.item_id= " .$ item_id );
69
70
while ($ bitquery_array = pg_fetch_array ($ bitquery ))
70
71
{
71
72
$ filename = $ bitquery_array ['name ' ];
@@ -112,7 +113,7 @@ private function _createFolderForItem($collectionId, $parentFolderid)
112
113
}
113
114
} // end _createFolderForItem()
114
115
115
- /** function to create the collections */
116
+ /** function to create the collections */
116
117
private function _createFolderForCollection ($ communityId , $ parentFolderid )
117
118
{
118
119
set_time_limit (0 );
@@ -172,15 +173,19 @@ private function _createFolderForCollection($communityId, $parentFolderid)
172
173
173
174
174
175
/** Recursive function to create the communities */
175
- private function _createFolderForCommunity ($ parentidMIDAS2 , $ parentFolderid )
176
+ private function _createFolderForCommunity ($ communityidMIDAS2 , $ parentFolderid )
176
177
{
177
178
set_time_limit (0 );
178
179
$ modelLoader = new MIDAS_ModelLoader ;
179
180
$ Folder = $ modelLoader ->loadModel ("Folder " );
180
181
$ Folderpolicygroup = $ modelLoader ->loadModel ("Folderpolicygroup " );
181
182
$ Folderpolicyuser = $ modelLoader ->loadModel ("Folderpolicyuser " );
182
183
183
- $ comquery = pg_query ("SELECT community_id,name,short_description,introductory_text FROM community WHERE owning_community= " .$ parentidMIDAS2 );
184
+ // Create the collections attached to this community
185
+ $ this ->_createFolderForCollection ($ communityidMIDAS2 ,$ parentFolderid );
186
+
187
+ // Find the subcommunities
188
+ $ comquery = pg_query ("SELECT community_id,name,short_description,introductory_text FROM community WHERE owning_community= " .$ communityidMIDAS2 );
184
189
while ($ comquery_array = pg_fetch_array ($ comquery ))
185
190
{
186
191
$ community_id = $ comquery_array ['community_id ' ];
@@ -215,21 +220,18 @@ private function _createFolderForCommunity($parentidMIDAS2, $parentFolderid)
215
220
$ this ->getLogger ()->info ($ e ->getMessage ());
216
221
//Zend_Debug::dump($e);
217
222
//we continue
218
- }
219
-
220
- if ($ folderDao )
223
+ }
224
+
225
+ if ($ folderDao ) // The folder has been created for the community
221
226
{
227
+ // Find the subcommunities
222
228
$ this ->_createFolderForCommunity ($ community_id , $ folderDao ->getFolderId ());
223
229
}
224
- else
230
+ else
225
231
{
226
232
echo "Cannot create Folder for community: " .$ name ."<br> " ;
227
- }
228
- }
229
-
230
- // Create the collections attached to this community
231
- $ this ->_createFolderForCollection ($ parentidMIDAS2 , $ parentFolderid );
232
-
233
+ } // end cannot create folder
234
+ } // end find information about the current community
233
235
} // end _createCommunity()
234
236
235
237
/** */
@@ -244,7 +246,7 @@ function migrate()
244
246
}
245
247
246
248
// Connect to the local PGSQL database
247
- $ pgdb = pg_connect ("host = localhost port = 5432 dbname = midasopen user = midas password = midas " );
249
+ $ pgdb = pg_connect ("host=' localhost' port=' 5432' dbname=' midasopen' user=' midas' password=' midas' " );
248
250
if ($ pgdb === false )
249
251
{
250
252
throw new Zend_Exception ("Cannot connect to the MIDAS2 database. " );
@@ -253,7 +255,7 @@ function migrate()
253
255
// Check that the password prefix is not defined
254
256
if (Zend_Registry::get ('configGlobal ' )->password ->prefix != '' )
255
257
{
256
- throw new Zend_Exception ("Cannot connect to the MIDAS2 database . " );
258
+ throw new Zend_Exception ("Password prefix cannot be set because MIDAS2 doesn't use salt . " );
257
259
}
258
260
259
261
$ modelLoader = new MIDAS_ModelLoader ;
0 commit comments