class ConceptVersionIndex(OCLSearchIndex, indexes.Indexable): text = indexes.CharField( document=True, use_template=True) mnemonic = SortOrFilterField( model_attr='name', indexed=True, stored=True, default="") name = SortOrFilterField( model_attr='display_name', indexed=True, stored=True, default="") lastUpdate = indexes.DateTimeField( model_attr='updated_at', indexed=True, stored=True) num_stars = indexes.IntegerField( model_attr='versioned_object__num_stars', indexed=True, stored=True) conceptClass = SortOrFilterField( model_attr='concept_class', indexed=True, stored=True, faceted=True) datatype = SortOrFilterField( model_attr='datatype', null=True, indexed=True, stored=True, faceted=True) locale = FilterField( indexed=True, stored=True, faceted=True) is_latest_version = indexes.BooleanField( model_attr='is_latest_version', indexed=True, stored=True) public_can_view = indexes.BooleanField( model_attr='public_can_view', indexed=True, stored=True) retired = indexes.BooleanField( model_attr='retired', indexed=True, stored=True, faceted=True) source = SortOrFilterField(model_attr='parent_resource', indexed=True, stored=True, faceted=True) owner = SortOrFilterField( model_attr='owner_name', indexed=True, stored=True, faceted=True) ownerType = SortOrFilterField( model_attr='owner_type', indexed=True, stored=True, faceted=True) source_version = FilterField() collection = FilterField() collection_version = FilterField() is_active = indexes.BooleanField(model_attr='is_active', indexed=True, stored=True) def get_model(self): return ConceptVersion def prepare_locale(self, obj): locales = set() if obj.names: for name in obj.names: if name.locale is not None: locales.add(name.locale) return list(locales) def prepare_source_version(self, obj): return list(obj.source_version_ids) def prepare_collection_version(self, obj): return obj.get_collection_version_ids() def prepare_collection(self, obj): return obj.get_collection_ids()
class MappingVersionIndex(OCLSearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) external_id = SortOrFilterField(model_attr='external_id', indexed=True, stored=True, null=True) lastUpdate = indexes.DateTimeField(model_attr='updated_at', indexed=True, stored=True) retired = indexes.BooleanField(model_attr='retired', indexed=True, stored=True, faceted=True) mapType = SortOrFilterField(model_attr='map_type', indexed=True, stored=True, faceted=True) source = SortOrFilterField(model_attr='source', indexed=True, stored=True, faceted=True) owner = SortOrFilterField(model_attr='owner', indexed=True, stored=True, faceted=True) ownerType = SortOrFilterField(model_attr='owner_type', indexed=True, stored=True, faceted=True) concept = FilterField(indexed=True, stored=True, faceted=True) fromConcept = FilterField(indexed=True, stored=True, faceted=True) toConcept = FilterField(indexed=True, stored=True, null=True, faceted=True) conceptSource = FilterField(indexed=True, stored=True, faceted=True) fromConceptSource = SortOrFilterField(indexed=True, stored=True, faceted=True) toConceptSource = SortOrFilterField(indexed=True, stored=True, faceted=True) conceptOwner = FilterField(faceted=True) fromConceptOwner = SortOrFilterField(indexed=True, stored=True, faceted=True) toConceptOwner = SortOrFilterField(indexed=True, stored=True, faceted=True) conceptOwnerType = FilterField(faceted=True) fromConceptOwnerType = SortOrFilterField(indexed=True, stored=True, faceted=True) toConceptOwnerType = SortOrFilterField(indexed=True, stored=True, faceted=True) source_version = FilterField() collection = FilterField() collection_version = FilterField() public_can_view = indexes.BooleanField(model_attr='public_can_view', indexed=True, stored=True) is_active = indexes.BooleanField(model_attr='is_active', indexed=True, stored=True) is_latest_version = indexes.BooleanField(model_attr='is_latest_version', indexed=True, stored=True) def get_model(self): return MappingVersion def prepare(self, obj): self.prepared_data = super(MappingVersionIndex, self).prepare(obj) self.prepared_data['fromConcept'] = [obj.from_concept_url, obj.from_concept_code, obj.from_concept_name] self.prepared_data['toConcept'] = [obj.get_to_concept_code(), obj.get_to_concept_name()] self.prepared_data['concept'] = self.prepared_data['fromConcept'] + self.prepared_data['toConcept'] self.prepared_data['fromConceptSource'] = obj.from_source_name self.prepared_data['toConceptSource'] = obj.to_source_name self.prepared_data['conceptSource'] = [obj.from_source_name, obj.to_source_name] self.prepared_data['fromConceptOwner'] = obj.from_source_owner self.prepared_data['toConceptOwner'] = obj.to_source_owner self.prepared_data['conceptOwner'] = [obj.from_source_owner, obj.to_source_owner] self.prepared_data['fromConceptOwnerType'] = obj.from_source_owner_type self.prepared_data['toConceptOwnerType'] = obj.to_source_owner_type self.prepared_data['conceptOwnerType'] = [obj.from_source_owner_type, obj.to_source_owner_type] self.prepared_data['source_version'] = list(obj.source_version_ids) return self.prepared_data def prepare_collection_version(self, obj): return obj.collection_version_ids def prepare_collection(self, obj): return obj.collection_ids
class SourceIndex(OCLSearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) name = SortOrFilterField(model_attr='name', indexed=True, stored=True) full_name = indexes.CharField(model_attr='full_name', null=True, indexed=True, stored=True) lastUpdate = indexes.DateTimeField(model_attr='updated_at', indexed=True, stored=True) sourceType = SortOrFilterField(model_attr='source_type', null=True, indexed=True, stored=True, faceted=True) locale = FilterField(model_attr='supported_locales', null=True, indexed=True, stored=True, faceted=True) owner = SortOrFilterField(model_attr='owner_name', indexed=True, stored=True, faceted=True) ownerType = SortOrFilterField(model_attr='owner_type', indexed=True, stored=True, faceted=True) is_active = indexes.BooleanField(model_attr='is_active', indexed=True, stored=True) public_can_view = indexes.BooleanField(model_attr='public_can_view', indexed=True, stored=True) customValidationSchema = SortOrFilterField( model_attr='custom_validation_schema', indexed=True, stored=True, faceted=True, null=True) def get_model(self): return Source
class ConceptVersionIndex(OCLSearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) name = SortOrFilterField(model_attr='display_name', indexed=True, stored=True) lastUpdate = indexes.DateTimeField(model_attr='updated_at', indexed=True, stored=True) num_stars = indexes.IntegerField(model_attr='versioned_object__num_stars', indexed=True, stored=True) conceptClass = SortOrFilterField(model_attr='concept_class', indexed=True, stored=True, faceted=True) datatype = SortOrFilterField(model_attr='datatype', null=True, indexed=True, stored=True, faceted=True) locale = FilterField(indexed=True, stored=True, faceted=True) is_latest_version = indexes.BooleanField(model_attr='is_latest_version', indexed=True, stored=True) public_can_view = indexes.BooleanField(model_attr='public_can_view', indexed=True, stored=True) retired = indexes.BooleanField(model_attr='retired', indexed=True, stored=True, faceted=True) source = SortOrFilterField(model_attr='parent_resource', indexed=True, stored=True, faceted=True) owner = SortOrFilterField(model_attr='owner_name', indexed=True, stored=True, faceted=True) ownerType = SortOrFilterField(model_attr='owner_type', indexed=True, stored=True, faceted=True) source_version = FilterField() collection = FilterField() collection_version = FilterField() is_active = indexes.BooleanField(model_attr='is_active', indexed=True, stored=True) def get_model(self): return ConceptVersion def prepare_locale(self, obj): locales = set() for name in obj.names: if name.locale is not None: locales.add(name.locale) return list(locales) def prepare_source_version(self, obj): source_version_ids = [] source = obj.source source_versions = SourceVersion.objects.filter( versioned_object_id=source.id, versioned_object_type=ContentType.objects.get_for_model(Source)) for sv in source_versions: if obj.id in sv.concepts: source_version_ids.append(sv.id) return source_version_ids def prepare_collection_version(self, obj): return obj.collection_version_ids def prepare_collection(self, obj): return obj.collection_ids
class MappingIndex(OCLSearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) external_id = SortOrFilterField(model_attr='external_id', indexed=True, stored=True, null=True) lastUpdate = indexes.DateTimeField(model_attr='updated_at', indexed=True, stored=True) retired = indexes.BooleanField(model_attr='retired', indexed=True, stored=True, faceted=True) mapType = SortOrFilterField(model_attr='map_type', indexed=True, stored=True, faceted=True) source = SortOrFilterField(model_attr='source', indexed=True, stored=True, faceted=True) owner = SortOrFilterField(model_attr='owner', indexed=True, stored=True, faceted=True) ownerType = SortOrFilterField(model_attr='owner_type', indexed=True, stored=True, faceted=True) concept = FilterField(indexed=True, stored=True, faceted=True) fromConcept = FilterField(indexed=True, stored=True, faceted=True) toConcept = FilterField(indexed=True, stored=True, null=True, faceted=True) conceptSource = FilterField(indexed=True, stored=True, faceted=True) fromConceptSource = SortOrFilterField(indexed=True, stored=True, faceted=True) toConceptSource = SortOrFilterField(indexed=True, stored=True, faceted=True) conceptOwner = FilterField(faceted=True) fromConceptOwner = SortOrFilterField(indexed=True, stored=True, faceted=True) toConceptOwner = SortOrFilterField(indexed=True, stored=True, faceted=True) conceptOwnerType = FilterField(faceted=True) fromConceptOwnerType = SortOrFilterField(indexed=True, stored=True, faceted=True) toConceptOwnerType = SortOrFilterField(indexed=True, stored=True, faceted=True) source_version = FilterField() collection = FilterField() collection_version = FilterField() public_can_view = indexes.BooleanField(model_attr='public_can_view', indexed=True, stored=True) is_active = indexes.BooleanField(model_attr='is_active', indexed=True, stored=True) def get_model(self): return Mapping def prepare(self, obj): self.prepared_data = super(MappingIndex, self).prepare(obj) self.prepared_data['fromConcept'] = [ obj.from_concept_url, obj.from_concept_code, obj.from_concept_name ] self.prepared_data['toConcept'] = [ obj.to_concept_url ] if obj.to_concept_url else [ obj.to_concept_code, obj.to_concept_name ] self.prepared_data['concept'] = self.prepared_data[ 'fromConcept'] + self.prepared_data['toConcept'] self.prepared_data['fromConceptSource'] = obj.from_source_name self.prepared_data['toConceptSource'] = obj.to_source_name self.prepared_data['conceptSource'] = [ obj.from_source_name, obj.to_source_name ] self.prepared_data['fromConceptOwner'] = obj.from_source_owner self.prepared_data['toConceptOwner'] = obj.to_source_owner self.prepared_data['conceptOwner'] = [ obj.from_source_owner, obj.to_source_owner ] self.prepared_data['fromConceptOwnerType'] = obj.from_source_owner_type self.prepared_data['toConceptOwnerType'] = obj.to_source_owner_type self.prepared_data['conceptOwnerType'] = [ obj.from_source_owner_type, obj.to_source_owner_type ] self.prepared_data['collection_version'] = obj.collection_version_ids self.prepared_data['collection'] = obj.collection_ids source_version_ids = [] source = obj.parent source_versions = SourceVersion.objects.filter( versioned_object_id=source.id, ) for sv in source_versions: if obj.id in sv.mappings: source_version_ids.append(sv.id) self.prepared_data['source_version'] = source_version_ids return self.prepared_data def prepare_collection_version(self, obj): return obj.collection_version_ids def prepare_collection(self, obj): return obj.collection_ids