def loadTable(self, rf2file): print("Reading active relationships from relationship snapshot table") db = RF2DBConnection() rdb = RelationshipDB() fname = self._fname if not cp_values.ss: print("Error: Transitive closure not implemented for FULL tables") return if not rdb.hascontent(): print("Error: Transitive table load requires Snapshot releationship table") return db.execute("SELECT sourceId, destinationId FROM %s WHERE %s AND typeId = %s" % (rdb._fname, self.fltr, is_a)) print("Computing transitive closure") tc = list(transitive_closure(db)) print("Dropping indices") TransitiveClosureDB._dropindices(self._fname) print("Writing records to table") for s in range(0, len(tc), chunksize): TransitiveClosureDB._writeblock(tc[s:s+chunksize], db, fname) print("Creating indices") TransitiveClosureDB._createindices(fname) print("Computing root entries") db.execute_query("UPDATE %(fname)s t1 LEFT JOIN %(fname)s t2 ON t1.parent=t2.child " "SET t1.isRoot=1 WHERE t1.depth=1 AND t2.child IS null" % vars()) db.commit()
def loadTable(self, rf2file): from rf2db.db.RF2RelationshipFile import RelationshipDB from rf2db.db.RF2StatedRelationshipFile import StatedRelationshipDB rdb = RelationshipDB() srdb = StatedRelationshipDB() if not rdb.hascontent() or not srdb.hascontent(): print(("Relationship databases must be loaded before loading %s" % self._fname)) return super(CanonicalCoreDB, self).loadTable(rf2file) print("Updating Stated Relationship File") srdb.updateFromCanonical(self._fname) print("Updating Relationship File") rdb.updateFromCanonical(self._fname)