@@ -110,7 +110,46 @@ private function _createFolderForItem($collectionId, $parentFolderid)
110
110
$ Item ->addRevision ($ itemdao , $ itemRevisionDao );
111
111
112
112
// Add the metadata
113
+ $ MetadataModel = $ modelLoader ->loadModel ("Metadata " );
114
+ // Register the common metadata (this should move to the main function
115
+ try
116
+ {
117
+ $ MetadataModel ->addMetadata (MIDAS_METADATA_GLOBAL ,'contributor ' ,'author ' ,'Author of the data ' );
118
+ $ MetadataModel ->addMetadata (MIDAS_METADATA_GLOBAL ,'date ' ,'uploaded ' ,'Date when the data was uploaded to MIDAS ' );
119
+ $ MetadataModel ->addMetadata (MIDAS_METADATA_GLOBAL ,'date ' ,'issued ' ,'Date when the data was published ' );
120
+ $ MetadataModel ->addMetadata (MIDAS_METADATA_GLOBAL ,'date ' ,'created ' ,'Date when the data was created ' );
121
+ }
122
+ catch (Zend_Exception $ e )
123
+ {
124
+ //we continue
125
+ }
113
126
127
+ //
128
+ $ metadataquery = pg_query ("SELECT metadata_field_id,text_value FROM metadatavalue WHERE item_id= " .$ item_id );
129
+ while ($ metadata_array = pg_fetch_array ($ metadataquery ))
130
+ {
131
+ $ text_value = $ metadata_array ['text_value ' ];
132
+ $ metadata_field_id = $ metadata_array ['metadata_field_id ' ];
133
+
134
+ $ element = "" ;
135
+ $ qualifier = "" ;
136
+
137
+ // Do not check 64 and 27 because they are stored as field and not metadata
138
+ // in MIDAS3
139
+ switch ($ metadata_field_id )
140
+ {
141
+ case 3 : $ element ='contributor ' ; $ qualifier ='author ' ; break ;
142
+ case 11 : $ element ='date ' ; $ qualifier ='uploaded ' ; break ;
143
+ case 15 : $ element ='date ' ; $ qualifier ='issued ' ; break ;
144
+ case 14 : $ element ='date ' ; $ qualifier ='created ' ; break ;
145
+ }
146
+
147
+ if ($ element != "" )
148
+ {
149
+ $ MetadataModel ->addMetadataValue ($ itemRevisionDao ,MIDAS_METADATA_GLOBAL ,
150
+ $ element ,$ qualifier ,$ text_value );
151
+ }
152
+ }
114
153
115
154
// Add bitstreams to the revision
116
155
$ bitstreamDao = new BitstreamDao ;
@@ -285,8 +324,10 @@ function migrate($userid)
285
324
}
286
325
287
326
// Connect to the local PGSQL database
327
+ ob_start (); // disable warnings
288
328
$ pgdb = pg_connect ("host=' " .$ this ->midas2Host ."' port=' " .$ this ->midas2Port ."' dbname=' " .$ this ->midas2Database .
289
329
"' user=' " .$ this ->midas2User ."' password=' " .$ this ->midas2Password ."' " );
330
+ ob_end_clean ();
290
331
if ($ pgdb === false )
291
332
{
292
333
throw new Zend_Exception ("Cannot connect to the MIDAS2 database. " );
@@ -300,18 +341,6 @@ function migrate($userid)
300
341
301
342
$ modelLoader = new MIDAS_ModelLoader ;
302
343
303
- // Just to test the metadata
304
- $ MetadataModel = $ modelLoader ->loadModel ("Metadata " );
305
- $ Item = $ modelLoader ->loadModel ("Item " );
306
-
307
- $ itemDao = $ Item ->load (42 );
308
- $ itemRevisionDao = $ Item ->getLastRevision ($ itemDao );
309
- //$MetadataModel->addMetadata(MIDAS_METADATA_DOCUMENT,'contributor','author','Author of a text');
310
- $ MetadataModel ->addMetadataValue ($ itemRevisionDao ,MIDAS_METADATA_DOCUMENT ,
311
- 'contributor ' ,'author ' ,'Julien! ' );
312
-
313
- return false ;
314
-
315
344
// STEP 1: Import the users
316
345
$ User = $ modelLoader ->loadModel ("User " );
317
346
$ query = pg_query ("SELECT email,password,firstname,lastname FROM eperson " );
@@ -347,6 +376,9 @@ function migrate($userid)
347
376
$ communityDao = false ;
348
377
try
349
378
{
379
+ // Check the policies for the community
380
+
381
+
350
382
$ communityDao = $ Community ->createCommunity ($ name , $ short_description , MIDAS_COMMUNITY_PUBLIC , NULL ); // no user
351
383
}
352
384
catch (Zend_Exception $ e )
0 commit comments