Merge Master in geni-v3 conflict resolution
[sfa.git] / sfa / importer / plimporter.py
index 7994c8c..8d197b6 100644 (file)
@@ -254,7 +254,7 @@ class PlImporter:
                     pass
                 node_record.stale=False
 
-            site_pis=[]
+            site_pis=set()
             # import persons
             for person_id in site['person_ids']:
                 proceed=False
@@ -362,17 +362,12 @@ class PlImporter:
                     # this is valid for all sites she is in..
                     # PI is coded with role_id==20
                     if 20 in person['role_ids']:
-                        site_pis.append (user_record)
+                        site_pis.add (user_record)
                 except:
                     self.logger.log_exc("PlImporter: failed to import person %d %s"%(person['person_id'],person['email']))
     
             # maintain the list of PIs for a given site
-            # for the record, Jordan had proposed the following addition as a welcome hotfix to a previous version:
-            # site_pis = list(set(site_pis)) 
-            # this was likely due to a bug in the above logic, that had to do with disabled persons
-            # being improperly handled, and where the whole loop on persons
-            # could be performed twice with the same person...
-            # so hopefully we do not need to eliminate duplicates explicitly here anymore
+            site_record.reg_pis = list(site_pis)
             site_record.reg_pis = site_pis
             dbsession.commit()
 
@@ -400,10 +395,13 @@ class PlImporter:
                     except:
                         self.logger.log_exc("PlImporter: failed to import slice %s (%s)"%(slice_hrn,slice['name']))
                 else:
+                    # update the pointer if it has changed
+                    if slice_id != slice_record.pointer:
+                        self.logger.info("updating record (slice) pointer")
+                        slice_record.pointer = slice_id
+                        dbsession.commit()             
                     # xxx update the record ...
-                    # given that we record the current set of users anyways, there does not seem to be much left to do here
-                    # self.logger.warning ("Slice update not yet implemented on slice %s (%s)"%(slice_hrn,slice['name']))
-                    pass
+                    #self.logger.warning ("Slice update not yet implemented")
                 # record current users affiliated with the slice
                 slice_record.reg_researchers = \
                     [ self.locate_by_type_pointer ('user',user_id) for user_id in slice['person_ids'] ]