Пример #1
0
    def _get_entity_types(self):

        entity_types = {}
        for stop_type in self.entity_type_definitions:
            et = self.entity_type_definitions[stop_type]

            try:
                entity_type = EntityType.objects.get(slug=et['slug'])
            except EntityType.DoesNotExist:
                entity_type = EntityType(slug=et['slug'])

            entity_type.uri = "http://mollyproject.org/schema/maps#%s" % et['uri-local']
            entity_type.article = et['article']
            entity_type.verbose_name = et['verbose-name']
            entity_type.verbose_name_plural = et['verbose-name-plural']
            entity_type.show_in_nearby_list = et['nearby']
            entity_type.show_in_category_list = et['category']
            entity_type.save()

            entity_types[stop_type] = entity_type

        for entity_type in entity_types.values():
            if entity_type.slug == 'public-transport-access-node':
                continue
            entity_type.subtype_of.add(entity_types[None])

        return entity_types
Пример #2
0
    def _get_entity_types(self):
        """
        Load the entity types into the database, returning a dictionary from
        rdf types (less the namespace) to EntityType objects.
        """

        # Define the types of OxPoints entities we'll be loading
        ENTITY_TYPES = {
            'college':               ('college', 'colleges', False, False, ('college-hall',)),
            'college-hall':          ('college or PPH', 'colleges and PPHs', True, True, ('university-entity',)),
            'university-entity':     ('University entity', 'University entities', False, False, ()),
            'department':            ('department', 'departments', False, False, ('faculty-department',)),
            'car-park':              ('car park', 'car parks', True, True, ()),
            'room':                  ('room', 'rooms', True, False, ('space',)),
            'space':                 ('space', 'spaces', False, False, ()),
            'library':               ('library', 'libraries', True, True, ()),
            'university-library':    ('University library', 'University libraries', True, True, ('university-entity','library',)),
            'library-collection':    ('library collection', 'library collections', False, False, ()),
            'museum':                ('museum', 'museums', True, True, ()),
            'building':              ('building', 'buildings', True, True, ()),
            'unit':                  ('unit', 'units', True, True, ('university-entity',)),
            'faculty':               ('faculty', 'faculties', False, False, ('faculty-department',)),
            'faculty-department':    ('faculty or department', 'faculties and departments', False, False, ('unit',)),
            'division':              ('division', 'divisions', False, False, ('unit',)),
            'university':            ('University', 'Universities', False, False, ('university-entity',)),
            'university-car-park':   ('University car park', 'University car parks', False, False, ('car-park', 'university-entity')),
            'wireless-access-point': ('wireless access point', 'wireless access points', False, False, ()),
            'site':                  ('site', 'site', False, False, ()),
            'hall':                  ('PPH', 'PPHs', False, False, ('college-hall',)),
        }

        entity_types = {}
        new_entity_types = set()
        for slug, (verbose_name, verbose_name_plural, nearby, category, subtype_of) in ENTITY_TYPES.items():
            try:
                entity_type = EntityType.objects.get(slug=slug)
            except EntityType.DoesNotExist:
                entity_type = EntityType(
                    slug = slug,
                    verbose_name = verbose_name,
                    verbose_name_plural = verbose_name_plural,
                    article = 'a',
                    show_in_nearby_list = nearby,
                    show_in_category_list = category,
                )
                entity_type.save()
                new_entity_types.add(slug)
            entity_types[slug] = entity_type
        
        for slug in new_entity_types:
            subtype_of = ENTITY_TYPES[slug][4]
            for s in subtype_of:
                entity_types[slug].subtype_of.add(entity_types[s])
            entity_types[slug].save()

        return entity_types
Пример #3
0
 def _get_entity_type(self):
     try:
         entity_type = EntityType.objects.get(slug='travel-alert')
     except EntityType.DoesNotExist:
         entity_type = EntityType(
             slug='travel-alert',
             verbose_name='travel alert',
             verbose_name_plural='travel alerts',
             article='a',
             show_in_nearby_list=False,
             show_in_category_list=False,
         )
         entity_type.save()
     return entity_type
Пример #4
0
 def _get_entity_type(self):
     try:
         return EntityType.objects.get(slug='post-code')
     except EntityType.DoesNotExist:
         entity_type = EntityType(
             slug = 'post-code',
             article = 'a',
             verbose_name = 'postcode',
             verbose_name_plural = 'postcodes',
             show_in_nearby_list = False,
             show_in_category_list = False,
         )
         entity_type.save()
         return entity_type
Пример #5
0
 def _get_entity_types(self):
     
     entity_types = {}
     new_entity_types = set()
     for slug, et in self._entity_types.items():
         et_category, created = EntityTypeCategory.objects.get_or_create(name=et['category'])
         try:
             entity_type = EntityType.objects.get(slug=slug)
             created = False
         except EntityType.DoesNotExist:
             entity_type = EntityType(slug=slug)
             created = True
         entity_type.category = et_category
         entity_type.slug = slug
         if created:
             entity_type.show_in_nearby_list = et['show_in_nearby_list']
             entity_type.show_in_category_list = et['show_in_category_list']
         entity_type.save()
         for lang_code, lang_name in settings.LANGUAGES:
             with override(lang_code):
                 set_name_in_language(entity_type, lang_code,
                                      verbose_name=_(et['verbose_name']),
                                      verbose_name_singular=_(et['verbose_name_singular']),
                                      verbose_name_plural=_(et['verbose_name_plural']))
         new_entity_types.add(slug)
         entity_types[slug] = entity_type
     
     for slug in new_entity_types:
         subtype_of = self._entity_types[slug]['parent-types']
         entity_types[slug].subtype_of.clear()
         for s in subtype_of:
             entity_types[slug].subtype_of.add(entity_types[s])
         entity_types[slug].save()
     
     return entity_types
Пример #6
0
 def _get_entity_types(self):
     
     entity_types = {}
     new_entity_types = set()
     for slug, et in self._entity_types.items():
         et_category, created = EntityTypeCategory.objects.get_or_create(name=et['category'])
         try:
             entity_type = EntityType.objects.get(slug=slug)
             created = False
         except EntityType.DoesNotExist:
             entity_type = EntityType(slug=slug)
             created = True
         entity_type.category = et_category
         entity_type.slug = slug
         if created:
             entity_type.show_in_nearby_list = et['show_in_nearby_list']
             entity_type.show_in_category_list = et['show_in_category_list']
         entity_type.save()
         for lang_code, lang_name in settings.LANGUAGES:
             with override(lang_code):
                 set_name_in_language(entity_type, lang_code,
                                      verbose_name=_(et['verbose_name']),
                                      verbose_name_singular=_(et['verbose_name_singular']),
                                      verbose_name_plural=_(et['verbose_name_plural']))
         new_entity_types.add(slug)
         entity_types[slug] = entity_type
     
     for slug in new_entity_types:
         subtype_of = self._entity_types[slug]['parent-types']
         entity_types[slug].subtype_of.clear()
         for s in subtype_of:
             entity_types[slug].subtype_of.add(entity_types[s])
         entity_types[slug].save()
     
     return entity_types
Пример #7
0
    def _get_entity_types(self):

        entity_types = {}
        category, created = EntityTypeCategory.objects.get_or_create(
            name=_('Transport'))
        category.save()

        for stop_type in self.entity_type_definitions:
            et = self.entity_type_definitions[stop_type]

            try:
                entity_type = EntityType.objects.get(slug=et['slug'])
            except EntityType.DoesNotExist:
                entity_type = EntityType(slug=et['slug'])

            entity_type.category = category
            entity_type.uri = "http://mollyproject.org/schema/maps#%s" % et[
                'uri-local']
            if created:
                entity_type.show_in_nearby_list = et['nearby']
                entity_type.show_in_category_list = et['category']
            entity_type.save()
            for lang_code, lang_name in settings.LANGUAGES:
                with override(lang_code):
                    set_name_in_language(entity_type,
                                         lang_code,
                                         verbose_name=ugettext(
                                             et['verbose-name']),
                                         verbose_name_singular=ugettext(
                                             et['verbose-name-singular']),
                                         verbose_name_plural=ugettext(
                                             et['verbose-name-plural']))

            entity_types[stop_type] = entity_type

        for stop_type, entity_type in entity_types.items():
            if entity_type.slug == 'public-transport-access-node':
                continue
            entity_type.subtype_of.add(entity_types[None])
            if stop_type.startswith(
                    'MET'
            ) and stop_type != 'MET' and entity_type.slug != self.RAIL_STATION_DEFINITION[
                    'slug']:
                entity_type.subtype_of.add(entity_types['MET'])

        return entity_types
Пример #8
0
 def _get_entity_type(self):
     try:
         entity_type = EntityType.objects.get(slug='travel-alert')
         created = False
     except EntityType.DoesNotExist:
         entity_type = EntityType(slug='travel-alert')
         created = True
     category, etc_created = EntityTypeCategory.objects.get_or_create(
         name=ugettext_noop('Transport'))
     if created:
         entity_type.show_in_nearby_list = False
         entity_type.show_in_category_list = False
     entity_type.category = category
     entity_type.save()
     for lang_code, lang_name in settings.LANGUAGES:
         with override(lang_code):
             set_name_in_language(entity_type,
                                  lang_code,
                                  verbose_name=_('travel alert'),
                                  verbose_name_singular=_('a travel alert'),
                                  verbose_name_plural=_('travel alerts'))
     return entity_type
Пример #9
0
    def _get_entity_types(self):

        entity_types = {}
        category, created = EntityTypeCategory.objects.get_or_create(name=_('Transport'))
        category.save()
        
        for stop_type in self.entity_type_definitions:
            et = self.entity_type_definitions[stop_type]
            
            try:
                entity_type = EntityType.objects.get(slug=et['slug'])
            except EntityType.DoesNotExist:
                entity_type = EntityType(slug=et['slug'])
            
            entity_type.category = category
            entity_type.uri = "http://mollyproject.org/schema/maps#%s" % et['uri-local']
            if created:
                entity_type.show_in_nearby_list = et['nearby']
                entity_type.show_in_category_list = et['category']
            entity_type.save()
            for lang_code, lang_name in settings.LANGUAGES:
                with override(lang_code):
                    set_name_in_language(entity_type, lang_code,
                                         verbose_name=ugettext(et['verbose-name']),
                                         verbose_name_singular=ugettext(et['verbose-name-singular']),
                                         verbose_name_plural=ugettext(et['verbose-name-plural']))
            
            entity_types[stop_type] = entity_type

        for stop_type, entity_type in entity_types.items():
            if entity_type.slug == 'public-transport-access-node':
                continue
            entity_type.subtype_of.add(entity_types[None])
            if stop_type.startswith('MET') and stop_type != 'MET' and entity_type.slug != self.RAIL_STATION_DEFINITION['slug']:
                entity_type.subtype_of.add(entity_types['MET'])
        

        return entity_types
Пример #10
0
 def _get_entity_type(self):
     try:
         entity_type = EntityType.objects.get(slug='travel-alert')
         created = False
     except EntityType.DoesNotExist:
         entity_type = EntityType(slug='travel-alert')
         created = True
     category, etc_created = EntityTypeCategory.objects.get_or_create(name=ugettext_noop('Transport'))
     if created:
         entity_type.show_in_nearby_list = False
         entity_type.show_in_category_list = False
     entity_type.category = category
     entity_type.save()
     for lang_code, lang_name in settings.LANGUAGES:
         with override(lang_code):
             set_name_in_language(entity_type, lang_code,
                                  verbose_name=_('travel alert'),
                                  verbose_name_singular=_('a travel alert'),
                                  verbose_name_plural=_('travel alerts'))
     return entity_type
Пример #11
0
    def _get_entity_types(self):
        ENTITY_TYPES = {
            'atm':                 ('an', 'ATM',                      'ATMs',                      True,  False, ()),
            'bank':                ('a',  'bank',                     'banks',                     True,  True,  ()),
            'bench':               ('a',  'bench',                    'benches',                   True,  False, ()),
            'bar':                 ('a',  'bar',                      'bars',                      True,  True,  ()),
            'bicycle-parking':     ('a',  'bicycle rack',             'bicycle racks',             True,  False, ()),
            'cafe':                ('a',  'café',                     'cafés',                     False, False, ('food',)),
            'car-park':            ('a',  'car park',                 'car parks',                 False, False, ()),
            'cathedral':           ('a',  'cathedral',                'cathedrals',                False, False, ('place-of-worship',)),
            'chapel':              ('a',  'chapel',                   'chapels',                   False, False, ('place-of-worship',)),
            'church':              ('a',  'church',                   'churches',                  False, False, ('place-of-worship',)),
            'cinema':              ('a',  'cinema',                   'cinemas',                   True,  True,  ()),
            'cycle-shop':          ('a',  'cycle shop',               'cycle shops',               False, False, ('shop',)),
            'dispensing-pharmacy': ('a',  'dispensing pharmacy',      'dispensing pharmacies',     False, False, ('pharmacy',)),
            'doctors':             ('a',  "doctor's surgery",         "doctors' surgeries",        False, False, ('medical',)),
            'fast-food':           ('a',  'fast food outlet',         'fast food outlets',         False, False, ('food',)),
            'food':                ('a',  'place to eat',             'places to eat',             True,  True,  ()),
            'hospital':            ('a',  'hospital',                 'hospitals',                 False, False, ('medical',)),
            'ice-cream':           ('an', 'ice cream café',           'ice cream cafés',           False, False, ('cafe','food',)),
            'ice-rink':            ('an', 'ice rink',                 'ice rinks',                 False, False, ('sport',)),
            'library':             ('a',  'library',                  'libraries',                 True,  True,  ()),
            'mandir':              ('a',  'mandir',                   'mandirs',                   False, False, ('place-of-worship',)),
            'medical':             ('a',  'place relating to health', 'places relating to health', True,  True,  ()),
            'mosque':              ('a',  'mosque',                   'mosques',                   False, False, ('place-of-worship',)),
            'museum':              ('a',  'museum',                   'museums',                   False, False, ()),
            'car-park':            ('a',  'car park',                 'car parks',                 True,  False, ()),
            'park':                ('a',  'park',                     'parks',                     False, False, ()),
            'park-and-ride':       ('a',  'park and ride',            'park and rides',            False, False, ('car-park',)),
            'pharmacy':            ('a',  'pharmacy',                 'pharmacies',                False, False, ('medical',)),
            'place-of-worship':    ('a',  'place of worship',         'places of worship',         False, False, ()),
            'post-box':            ('a',  'post box',                 'post boxes',                True,  False, ()),
            'post-office':         ('a',  'post office',              'post offices',              True,  False, ()),
            'pub':                 ('a',  'pub',                      'pubs',                      True,  True,  ()),
            'public-library':      ('a',  'public library',           'public libraries',          True,  True,  ('library',)),
            'punt-hire':           ('a',  'place to hire punts',      'places to hire punts',      False, False, ()),
            'recycling':           ('a',  'recycling facility',       'recycling facilities',      True,  False, ()),
            'restaurant':          ('a',  'restaurant',               'restaurants',               False, False, ('food',)),
            'shop':                ('a',  'shop',                     'shops',                     False, False, ()),
            'sport':               ('a',  'place relating to sport',  'places relating to sport',  False, False, ()),
            'sports-centre':       ('a',  'sports centre',            'sports centres',            False, False, ('sport',)),
            'swimming-pool':       ('a',  'swimming pool',            'swimming pools',            False, False, ('sport',)),
            'synagogue':           ('a',  'synagogue',                'synagogues',                False, False, ('place-of-worship',)),
            'taxi-rank':           ('a',  'taxi rank',                'taxi ranks',                False, False, ()),
            'theatre':             ('a',  'theatre',                  'theatres',                  True,  True,  ()),
        }

        entity_types = {}
        new_entity_types = set()
        for slug, (article, verbose_name, verbose_name_plural, nearby, category, subtype_of) in ENTITY_TYPES.items():
            try:
                entity_type = EntityType.objects.get(slug=slug)
            except EntityType.DoesNotExist:
                entity_type = EntityType(
                    slug = slug,
                    verbose_name = verbose_name,
                    verbose_name_plural = verbose_name_plural,
                    article = article,
                    show_in_nearby_list = nearby,
                    show_in_category_list = category,
                )
                entity_type.save()
                new_entity_types.add(slug)
            entity_types[slug] = entity_type

        for slug in new_entity_types:
            subtype_of = ENTITY_TYPES[slug][5]
            for s in subtype_of:
                entity_types[slug].subtype_of.add(entity_types[s])
            entity_types[slug].save()

        return entity_types
Пример #12
0
    def _get_entity_types(self):
        ENTITY_TYPES = {
            'atm': ('an', 'ATM', 'ATMs', True, False, ()),
            'bank': ('a', 'bank', 'banks', True, True, ()),
            'bench': ('a', 'bench', 'benches', True, False, ()),
            'bar': ('a', 'bar', 'bars', True, True, ()),
            'bicycle-parking':
            ('a', 'bicycle rack', 'bicycle racks', True, False, ()),
            'cafe': ('a', 'café', 'cafés', False, False, ('food', )),
            'car-park': ('a', 'car park', 'car parks', False, False, ()),
            'cathedral': ('a', 'cathedral', 'cathedrals', False, False,
                          ('place-of-worship', )),
            'chapel':
            ('a', 'chapel', 'chapels', False, False, ('place-of-worship', )),
            'church':
            ('a', 'church', 'churches', False, False, ('place-of-worship', )),
            'cinema': ('a', 'cinema', 'cinemas', True, True, ()),
            'cycle-shop': ('a', 'cycle shop', 'cycle shops', False, False,
                           ('shop', )),
            'dispensing-pharmacy':
            ('a', 'dispensing pharmacy', 'dispensing pharmacies', False, False,
             ('pharmacy', )),
            'doctors': ('a', "doctor's surgery", "doctors' surgeries", False,
                        False, ('medical', )),
            'fast-food': ('a', 'fast food outlet', 'fast food outlets', False,
                          False, ('food', )),
            'food': ('a', 'place to eat', 'places to eat', True, True, ()),
            'hospital': ('a', 'hospital', 'hospitals', False, False,
                         ('medical', )),
            'ice-cream': ('an', 'ice cream café', 'ice cream cafés', False,
                          False, (
                              'cafe',
                              'food',
                          )),
            'ice-rink': ('an', 'ice rink', 'ice rinks', False, False,
                         ('sport', )),
            'library': ('a', 'library', 'libraries', True, True, ()),
            'mandir': ('a', 'mandir', 'mandirs', False, False,
                       ('place-of-worship', )),
            'medical': ('a', 'place relating to health',
                        'places relating to health', True, True, ()),
            'mosque': ('a', 'mosque', 'mosques', False, False,
                       ('place-of-worship', )),
            'museum': ('a', 'museum', 'museums', False, False, ()),
            'car-park': ('a', 'car park', 'car parks', True, False, ()),
            'park': ('a', 'park', 'parks', False, False, ()),
            'park-and-ride': ('a', 'park and ride', 'park and rides', False,
                              False, ('car-park', )),
            'pharmacy': ('a', 'pharmacy', 'pharmacies', False, False,
                         ('medical', )),
            'place-of-worship': ('a', 'place of worship', 'places of worship',
                                 False, False, ()),
            'post-box': ('a', 'post box', 'post boxes', True, False, ()),
            'post-office': ('a', 'post office', 'post offices', True, False,
                            ()),
            'pub': ('a', 'pub', 'pubs', True, True, ()),
            'public-library': ('a', 'public library', 'public libraries', True,
                               True, ('library', )),
            'punt-hire': ('a', 'place to hire punts', 'places to hire punts',
                          False, False, ()),
            'recycling': ('a', 'recycling facility', 'recycling facilities',
                          True, False, ()),
            'restaurant': ('a', 'restaurant', 'restaurants', False, False,
                           ('food', )),
            'shop': ('a', 'shop', 'shops', False, False, ()),
            'sport': ('a', 'place relating to sport',
                      'places relating to sport', False, False, ()),
            'sports-centre': ('a', 'sports centre', 'sports centres', False,
                              False, ('sport', )),
            'swimming-pool': ('a', 'swimming pool', 'swimming pools', False,
                              False, ('sport', )),
            'synagogue': ('a', 'synagogue', 'synagogues', False, False,
                          ('place-of-worship', )),
            'taxi-rank': ('a', 'taxi rank', 'taxi ranks', False, False, ()),
            'theatre': ('a', 'theatre', 'theatres', True, True, ()),
        }

        entity_types = {}
        new_entity_types = set()
        for slug, (article, verbose_name, verbose_name_plural, nearby,
                   category, subtype_of) in ENTITY_TYPES.items():
            try:
                entity_type = EntityType.objects.get(slug=slug)
            except EntityType.DoesNotExist:
                entity_type = EntityType(
                    slug=slug,
                    verbose_name=verbose_name,
                    verbose_name_plural=verbose_name_plural,
                    article=article,
                    show_in_nearby_list=nearby,
                    show_in_category_list=category,
                )
                entity_type.save()
                new_entity_types.add(slug)
            entity_types[slug] = entity_type

        for slug in new_entity_types:
            subtype_of = ENTITY_TYPES[slug][5]
            for s in subtype_of:
                entity_types[slug].subtype_of.add(entity_types[s])
            entity_types[slug].save()

        return entity_types