def get_collection_subtype_ids(self, supertype_id, altscope): """ Returns a iterator of type ids for all subtypes of the supplied type accessible in the indicated scope from the current collection, including the identified type itself. """ if not valid_id(supertype_id): log.warning( "EntityFinder.get_collection_subtype_ids: invalid type_id %s" % (supertype_id, )) return supertype_info = EntityTypeInfo(self._coll, supertype_id) supertype_uri = supertype_info.get_type_uri() if supertype_uri is not None: for try_subtype_id in self.get_collection_type_ids(altscope): try_subtype = self._coll.cache_get_type(try_subtype_id) if try_subtype: try_subtype_uri = try_subtype.get_uri() if ((supertype_uri == try_subtype_uri) or (supertype_uri in self._coll.cache_get_supertype_uris( try_subtype_uri))): yield try_subtype_id else: log.warning( "EntityFinder.get_collection_subtype_ids: no type_uri for %s" % (supertype_id, ))
def migrate_coll_data(coll): """ Migrate collection data for specified collection Returns list of error message strings, or empty list. """ log.info("Migrate Annalist collection data for %s"%(coll.get_id())) errs = migrate_coll_config_dirs(coll) if errs: return errs try: entityfinder = EntityFinder(coll) for e in entityfinder.get_entities(): log.info("migrate_coll_data: %s/%s"%(e[ANNAL.CURIE.type_id], e[ANNAL.CURIE.id])) typeinfo = EntityTypeInfo(coll, e[ANNAL.CURIE.type_id]) e[ANNAL.CURIE.type] = typeinfo.get_type_uri() coll.update_entity_types(e) e._save(post_update_flags={"nocontext"}) if e.get_errors(): errs.extend(e.get_errors()) except Annalist_Error as err: errs.append(str(err)) if errs: return errs # Rename _group directory errs = migrate_collection_dir(coll, layout.GROUP_DIR, layout.GROUP_DIR+".migrated") if errs: return errs coll.generate_coll_jsonld_context() return errs
def get_collection_subtypes(self, type_id, altscope): """ Returns a iterator of `entitytypeinfo` objects for all subtypes of the supplied type in the current collection, including the identified type itself. """ supertypeinfo = EntityTypeInfo(self._coll, type_id) supertypeuri = supertypeinfo.get_type_uri() if supertypeuri is None: log.warning("EntityFinder.get_collection_uri_subtypes: no type_uri for %s"%(type_id,)) return self.get_collection_uri_subtypes(supertypeuri, altscope)
def get_collection_subtypes(self, type_id, altscope): """ Returns a iterator of `entitytypeinfo` objects for all subtypes of the supplied type in the current collection, including the identified type itself. """ supertypeinfo = EntityTypeInfo(self._coll, type_id) supertypeuri = supertypeinfo.get_type_uri() if supertypeuri is None: log.warning( "EntityFinder.get_collection_uri_subtypes: no type_uri for %s" % (type_id, )) return self.get_collection_uri_subtypes(supertypeuri, altscope)
def get_collection_subtype_ids(self, supertype_id, altscope): """ Returns a iterator of type ids for all subtypes of the supplied type accessible in the indicated scope from the current collection, including the identified type itself. """ if not valid_id(supertype_id): log.warning("EntityFinder.get_collection_subtype_ids: invalid type_id %s"%(supertype_id,)) return supertype_info = EntityTypeInfo(self._coll, supertype_id) supertype_uri = supertype_info.get_type_uri() if supertype_uri is not None: for try_subtype_id in self.get_collection_type_ids(altscope): try_subtype = self._coll.cache_get_type(try_subtype_id) if try_subtype: try_subtype_uri = try_subtype.get_uri() if ( ( supertype_uri == try_subtype_uri ) or ( supertype_uri in self._coll.cache_get_supertype_uris(try_subtype_uri) ) ): yield try_subtype_id else: log.warning("EntityFinder.get_collection_subtype_ids: no type_uri for %s"%(supertype_id,))