示例#1
0
    def setUp(self):
        conceptscheme = ConceptScheme()
        conceptscheme.uri = 'urn:x-atramhasis-demo'
        conceptscheme.id = 1
        self.concept = Concept()
        self.concept.type = 'concept'
        self.concept.id = 11
        self.concept.concept_id = 101
        self.concept.uri = 'urn:x-atramhasis-demo:TREES:101'
        self.concept.conceptscheme_id = 1
        self.concept.conceptscheme = conceptscheme

        notes = []
        note = Note(note='test note', notetype_id='example', language_id='en')
        note2 = Note(note='note def',
                     notetype_id='definition',
                     language_id='en')
        notes.append(note)
        notes.append(note2)
        self.concept.notes = notes

        labels = []
        label = Label(label='een label',
                      labeltype_id='prefLabel',
                      language_id='nl')
        label2 = Label(label='other label',
                       labeltype_id='altLabel',
                       language_id='en')
        label3 = Label(label='and some other label',
                       labeltype_id='altLabel',
                       language_id='en')
        labels.append(label)
        labels.append(label2)
        labels.append(label3)
        self.concept.labels = labels

        matches = []
        match1 = Match()
        match1.uri = 'urn:test'
        match1.concept = self.concept
        match1.matchtype = MatchType(name='closeMatch', description='')
        match2 = Match()
        match2.uri = 'urn:test'
        match2.concept = self.concept
        match2.matchtype = MatchType(name='closeMatch', description='')
        matches.append(match1)
        matches.append(match2)
        self.matches = matches

        self.collection = Collection()
        self.collection.type = 'collection'
        self.collection.id = 12
        self.collection.concept_id = 102
        self.collection.uri = 'urn:x-atramhasis-demo:TREES:102'
        self.collection.conceptscheme_id = 1
        self.collection.conceptscheme = conceptscheme
示例#2
0
    def setUp(self):
        self.concept = Concept()
        self.concept.type = 'concept'
        self.concept.id = 11
        self.concept.concept_id = 101
        self.concept.uri = 'urn:x-atramhasis-demo:TREES:101'
        self.concept.conceptscheme_id = 1

        notes = []
        note = Note(note='test note', notetype_id='example', language_id='en')
        note2 = Note(note='note def',
                     notetype_id='definition',
                     language_id='en')
        notes.append(note)
        notes.append(note2)
        self.concept.notes = notes

        labels = []
        label = Label(label='een label',
                      labeltype_id='prefLabel',
                      language_id='nl')
        label2 = Label(label='other label',
                       labeltype_id='altLabel',
                       language_id='en')
        label3 = Label(label='and some other label',
                       labeltype_id='altLabel',
                       language_id='en')
        labels.append(label)
        labels.append(label2)
        labels.append(label3)
        self.concept.labels = labels

        matches = []
        match = Match()
        match.matchtype = MatchType(name='closeMatch', description='test')
        match.uri = 'urn:somethingelse:st1'
        matches.append(match)
        match2 = Match()
        match2.matchtype = MatchType(name='closeMatch', description='test')
        match2.uri = 'urn:somethingelse:st2'
        matches.append(match2)
        match3 = Match()
        match3.matchtype = MatchType(name='exactMatch', description='test')
        match3.uri = 'urn:something:thingy'
        matches.append(match3)
        self.concept.matches = matches

        self.collection = Collection()
        self.collection.type = 'collection'
        self.collection.id = 12
        self.collection.concept_id = 102
        self.collection.uri = 'urn:x-atramhasis-demo:TREES:102'
        self.collection.conceptscheme_id = 1

        self.concept.member_of.add(self.collection)
        self.collection.members.add(self.concept)
示例#3
0
    def setUp(self):
        conceptscheme = ConceptScheme()
        conceptscheme.uri = 'urn:x-atramhasis-demo'
        conceptscheme.id = 1
        self.concept = Concept()
        self.concept.type = 'concept'
        self.concept.id = 11
        self.concept.concept_id = 101
        self.concept.uri = 'urn:x-atramhasis-demo:TREES:101'
        self.concept.conceptscheme_id = 1
        self.concept.conceptscheme = conceptscheme

        notes = []
        note = Note(note='test note', notetype_id='example', language_id='en')
        note2 = Note(note='note def', notetype_id='definition', language_id='en')
        notes.append(note)
        notes.append(note2)
        self.concept.notes = notes

        labels = []
        label = Label(label='een label', labeltype_id='prefLabel', language_id='nl')
        label2 = Label(label='other label', labeltype_id='altLabel', language_id='en')
        label3 = Label(label='and some other label', labeltype_id='altLabel', language_id='en')
        labels.append(label)
        labels.append(label2)
        labels.append(label3)
        self.concept.labels = labels

        sources = []
        source = Source(citation='Kinsella S. & Carlisle P. 2015: Alice.')
        sources.append(source)
        self.concept.sources = sources

        matches = []
        match1 = Match()
        match1.uri ='urn:test'
        match1.concept = self.concept
        match1.matchtype = MatchType(name='closeMatch', description='')
        match2 = Match()
        match2.uri ='urn:test'
        match2.concept = self.concept
        match2.matchtype = MatchType(name='closeMatch', description='')
        matches.append(match1)
        matches.append(match2)
        self.matches = matches

        self.collection = Collection()
        self.collection.type = 'collection'
        self.collection.id = 12
        self.collection.concept_id = 102
        self.collection.uri = 'urn:x-atramhasis-demo:TREES:102'
        self.collection.conceptscheme_id = 1
        self.collection.conceptscheme = conceptscheme
示例#4
0
    def setUp(self):
        self.concept = Concept()
        self.concept.type = 'concept'
        self.concept.id = 11
        self.concept.concept_id = 101
        self.concept.uri = 'urn:x-atramhasis-demo:TREES:101'
        self.concept.conceptscheme_id = 1

        notes = []
        note = Note(note='test note', notetype_id='example', language_id='en')
        note2 = Note(note='note def', notetype_id='definition', language_id='en')
        notes.append(note)
        notes.append(note2)
        self.concept.notes = notes

        labels = []
        label = Label(label='een label', labeltype_id='prefLabel', language_id='nl')
        label2 = Label(label='other label', labeltype_id='altLabel', language_id='en')
        label3 = Label(label='and some other label', labeltype_id='altLabel', language_id='en')
        labels.append(label)
        labels.append(label2)
        labels.append(label3)
        self.concept.labels = labels

        matches = []
        match = Match()
        match.matchtype = MatchType(name='closeMatch', description='test')
        match.uri = 'urn:somethingelse:st1'
        matches.append(match)
        match2 = Match()
        match2.matchtype = MatchType(name='closeMatch', description='test')
        match2.uri = 'urn:somethingelse:st2'
        matches.append(match2)
        match3 = Match()
        match3.matchtype = MatchType(name='exactMatch', description='test')
        match3.uri = 'urn:something:thingy'
        matches.append(match3)
        self.concept.matches = matches

        self.collection = Collection()
        self.collection.type = 'collection'
        self.collection.id = 12
        self.collection.concept_id = 102
        self.collection.uri = 'urn:x-atramhasis-demo:TREES:102'
        self.collection.conceptscheme_id = 1

        self.concept.member_of.add(self.collection)
        self.collection.members.add(self.concept)
示例#5
0
def filter_by_mock_match(uri, matchtype_id, concept_id):
    filter_mock = Mock()
    if concept_id == -1:
        raise NoResultFound()
    else:
        match = Match()
        match.uri = uri
        match.concept_id = concept_id
        if matchtype_id in ['broadMatch', 'closeMatch', 'exactMatch', 'narrowMatch', 'relatedMatch']:
            match.matchtype = MatchType(matchtype_id, 'test')
        else:
            raise NoResultFound()
    filter_mock.one = Mock(return_value=match)
    return filter_mock
def filter_by_mock_match(uri, matchtype_id, concept_id):
    filter_mock = Mock()
    if concept_id == -1:
        raise NoResultFound()
    else:
        match = Match()
        match.uri = uri
        match.concept_id = concept_id
        if matchtype_id in [
                'broadMatch', 'closeMatch', 'exactMatch', 'narrowMatch',
                'relatedMatch'
        ]:
            match.matchtype = MatchType(matchtype_id, 'test')
        else:
            raise NoResultFound()
    filter_mock.one = Mock(return_value=match)
    return filter_mock
示例#7
0
def map_concept(concept, concept_json, skos_manager):
    """
    Map a concept from json to the database.

    :param skosprovider_sqlalchemy.models.Thing concept: A concept or
        collection as known to the database.
    :param dict concept_json: A dict representing the json sent to our REST
        service.
    :param skos_manager: A skos_manager to acces db operations
    :returns: The :class:`skosprovider_sqlalchemy.models.Thing` enhanced
        with the information from the json object.
    """
    concept_json_type = concept_json.get('type', None)
    if concept.type != concept_json_type:

        if concept_json_type == 'concept':
            members = concept.members
            concept = skos_manager.change_type(concept,
                                               concept.concept_id,
                                               concept.conceptscheme_id,
                                               concept_json_type)
            for member in members:
                if member.type == 'concept':
                    concept.narrower_concepts.add(member)
                elif member.type == 'collection':
                    concept.narrower_collections.add(member)
        elif concept_json_type == 'collection':
            narrower_concepts = concept.narrower_concepts
            narrower_collections = concept.narrower_collections
            concept = skos_manager.change_type(concept,
                                               concept.concept_id,
                                               concept.conceptscheme_id,
                                               concept_json_type)
            for narrower_concept in narrower_concepts:
                concept.members.add(narrower_concept)
            for narrower_collection in narrower_collections:
                concept.members.add(narrower_collection)
    elif concept_json_type == 'collection':
        concept.members.clear()
    elif concept_json_type == 'concept':
        concept.narrower_collections.clear()
        concept.narrower_concepts.clear()
    if concept.type in ('concept', 'collection'):
        concept.labels[:] = []
        labels = concept_json.get('labels', [])
        for l in labels:
            label = Label(label=l.get('label', ''), labeltype_id=l.get('type', ''), language_id=l.get('language', ''))
            concept.labels.append(label)
        concept.notes[:] = []
        notes = concept_json.get('notes', [])
        for n in notes:
            note = Note(note=n.get('note', ''), notetype_id=n.get('type', ''), language_id=n.get('language', ''))
            if is_html(note.note):
                note.markup = 'HTML'
            concept.notes.append(note)
        concept.sources[:] = []
        sources = concept_json.get('sources', [])
        for s in sources:
            source = Source(citation=s.get('citation', ''))
            if is_html(source.citation):
                source.markup = 'HTML'
            concept.sources.append(source)

        concept.member_of.clear()
        member_of = concept_json.get('member_of', [])
        for memberof in member_of:
            try:
                memberof_collection = skos_manager.get_thing(
                    concept_id=memberof['id'],
                    conceptscheme_id=concept.conceptscheme_id)
            except NoResultFound:
                memberof_collection = Collection(concept_id=memberof['id'], conceptscheme_id=concept.conceptscheme_id)
            concept.member_of.add(memberof_collection)

        if concept.type == 'concept':
            concept.related_concepts.clear()
            related = concept_json.get('related', [])
            for related in related:
                try:
                    related_concept = skos_manager.get_thing(
                        concept_id=related['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                except NoResultFound:
                    related_concept = Concept(concept_id=related['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.related_concepts.add(related_concept)

            concept.broader_concepts.clear()
            broader = concept_json.get('broader', [])
            for broader in broader:
                try:
                    broader_concept = skos_manager.get_thing(
                        concept_id=broader['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                except NoResultFound:
                    broader_concept = Concept(concept_id=broader['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.broader_concepts.add(broader_concept)
            narrower = concept_json.get('narrower', [])
            for narrower in narrower:
                try:
                    narrower_concept = skos_manager.get_thing(
                        concept_id=narrower['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                except NoResultFound:
                    narrower_concept = Concept(concept_id=narrower['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.narrower_concepts.add(narrower_concept)

            matches = []
            matchdict = concept_json.get('matches', {})
            for type in matchdict:
                db_type = type + "Match"
                matchtype = skos_manager.get_match_type(db_type)
                for uri in matchdict[type]:
                    concept_id = concept_json.get('id', -1)
                    try:
                        match = skos_manager.get_match(uri=uri, matchtype_id=matchtype.name,
                                                       concept_id=concept_id)
                    except NoResultFound:
                        match = Match()
                        match.matchtype = matchtype
                        match.uri = uri
                    matches.append(match)
            concept.matches = matches

            narrower_collections = concept_json.get('subordinate_arrays', [])
            for narrower in narrower_collections:
                try:
                    narrower_collection = skos_manager.get_thing(
                        concept_id=narrower['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                except NoResultFound:
                    narrower_collection = Collection(concept_id=narrower['id'],
                                                     conceptscheme_id=concept.conceptscheme_id)
                concept.narrower_collections.add(narrower_collection)

        if concept.type == 'collection':
            members = concept_json.get('members', [])
            for member in members:
                try:
                    member_concept = skos_manager.get_thing(
                        concept_id=member['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                except NoResultFound:
                    member_concept = Concept(concept_id=member['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.members.add(member_concept)

            concept.broader_concepts.clear()
            broader_concepts = concept_json.get('superordinates', [])
            for broader in broader_concepts:
                try:
                    broader_concept = skos_manager.get_thing(
                        concept_id=broader['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                except NoResultFound:
                    broader_concept = Concept(concept_id=broader['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.broader_concepts.add(broader_concept)
    return concept
示例#8
0
def map_concept(concept, concept_json, db_session):
    '''
    Map a concept from json to the database.

    :param skosprovider_sqlalchemy.models.Thing concept: A concept or 
        collection as known to the database.
    :param dict concept_json: A dict representing the json sent to our REST 
        service.
    :param session: A :class:`sqlalchemy.orm.session.Session`.
    :returns: The :class:`skosprovider_sqlalchemy.models.Thing` enhanced 
        with the information from the json object.
    '''
    concept.type = concept_json.get('type', None)
    if concept.type in ('concept', 'collection'):
        for label in concept.labels:
            concept.labels.remove(label)
        labels = concept_json.get('labels', [])
        for l in labels:
            label = Label(label=l.get('label', ''),
                          labeltype_id=l.get('type', ''),
                          language_id=l.get('language', ''))
            concept.labels.append(label)
        for note in concept.notes:
            concept.notes.remove(note)
        notes = concept_json.get('notes', [])
        for n in notes:
            note = Note(note=n.get('note', ''),
                        notetype_id=n.get('type', ''),
                        language_id=n.get('language', ''))
            concept.notes.append(note)

        concept.member_of.clear()
        member_of = concept_json.get('member_of', [])
        for memberof in member_of:
            try:
                memberof_collection = db_session.query(Collection)\
                    .filter_by(concept_id=memberof['id'], conceptscheme_id=concept.conceptscheme_id).one()
            except NoResultFound:
                memberof_collection = Collection(
                    concept_id=memberof['id'],
                    conceptscheme_id=concept.conceptscheme_id)
            concept.member_of.add(memberof_collection)

        if concept.type == 'concept':
            concept.related_concepts.clear()
            related = concept_json.get('related', [])
            for related in related:
                try:
                    related_concept = db_session.query(Concept).filter_by(
                        concept_id=related['id'],
                        conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    related_concept = Concept(
                        concept_id=related['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                concept.related_concepts.add(related_concept)
            concept.narrower_concepts.clear()

            concept.broader_concepts.clear()
            broader = concept_json.get('broader', [])
            for broader in broader:
                try:
                    broader_concept = db_session.query(Concept).filter_by(
                        concept_id=broader['id'],
                        conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    broader_concept = Concept(
                        concept_id=broader['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                concept.broader_concepts.add(broader_concept)
            narrower = concept_json.get('narrower', [])
            for narrower in narrower:
                try:
                    narrower_concept = db_session.query(Concept).filter_by(
                        concept_id=narrower['id'],
                        conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    narrower_concept = Concept(
                        concept_id=narrower['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                concept.narrower_concepts.add(narrower_concept)

            matches = []
            matchdict = concept_json.get('matches', {})
            for type in matchdict:
                db_type = type + "Match"
                matchtype = db_session.query(MatchType).filter_by(
                    name=db_type).one()
                for uri in matchdict[type]:
                    concept_id = concept_json.get('id', -1)
                    try:
                        match = db_session.query(Match).filter_by(
                            uri=uri,
                            matchtype_id=matchtype.name,
                            concept_id=concept_id).one()
                    except NoResultFound:
                        match = Match()
                        match.matchtype = matchtype
                        match.uri = uri
                    matches.append(match)
            concept.matches = matches

            concept.narrower_collections.clear()
            narrower_collections = concept_json.get('subordinate_arrays', [])
            for narrower in narrower_collections:
                try:
                    narrower_collection = db_session.query(Collection)\
                        .filter_by(concept_id=narrower['id'], conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    narrower_collection = Collection(
                        concept_id=narrower['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                concept.narrower_collections.add(narrower_collection)

        if concept.type == 'collection':
            concept.members.clear()
            members = concept_json.get('members', [])
            for member in members:
                try:
                    member_concept = db_session.query(Thing).filter_by(
                        concept_id=member['id'],
                        conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    member_concept = Concept(
                        concept_id=member['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                concept.members.add(member_concept)

            concept.broader_concepts.clear()
            broader_concepts = concept_json.get('superordinates', [])
            for broader in broader_concepts:
                try:
                    broader_concept = db_session.query(Concept)\
                        .filter_by(concept_id=broader['id'], conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    broader_concept = Concept(
                        concept_id=broader['id'],
                        conceptscheme_id=concept.conceptscheme_id)
                concept.broader_concepts.add(broader_concept)

    return concept
示例#9
0
def map_concept(concept, concept_json, db_session):
    '''
    Map a concept from json to the database.

    :param skosprovider_sqlalchemy.models.Thing concept: A concept or 
        collection as known to the database.
    :param dict concept_json: A dict representing the json sent to our REST 
        service.
    :param session: A :class:`sqlalchemy.orm.session.Session`.
    :returns: The :class:`skosprovider_sqlalchemy.models.Thing` enhanced 
        with the information from the json object.
    '''
    concept.type = concept_json.get('type', None)
    if concept.type in ('concept', 'collection'):
        for label in concept.labels:
            concept.labels.remove(label)
        labels = concept_json.get('labels', [])
        for l in labels:
            label = Label(label=l.get('label', ''), labeltype_id=l.get('type', ''), language_id=l.get('language', ''))
            concept.labels.append(label)
        for note in concept.notes:
            concept.notes.remove(note)
        notes = concept_json.get('notes', [])
        for n in notes:
            note = Note(note=n.get('note', ''), notetype_id=n.get('type', ''), language_id=n.get('language', ''))
            concept.notes.append(note)

        concept.member_of.clear()
        member_of = concept_json.get('member_of', [])
        for memberof in member_of:
            try:
                memberof_collection = db_session.query(Collection)\
                    .filter_by(concept_id=memberof['id'], conceptscheme_id=concept.conceptscheme_id).one()
            except NoResultFound:
                memberof_collection = Collection(concept_id=memberof['id'], conceptscheme_id=concept.conceptscheme_id)
            concept.member_of.add(memberof_collection)

        if concept.type == 'concept':
            concept.related_concepts.clear()
            related = concept_json.get('related', [])
            for related in related:
                try:
                    related_concept = db_session.query(Concept).filter_by(concept_id=related['id'],
                                                                          conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    related_concept = Concept(concept_id=related['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.related_concepts.add(related_concept)
            concept.narrower_concepts.clear()

            concept.broader_concepts.clear()
            broader = concept_json.get('broader', [])
            for broader in broader:
                try:
                    broader_concept = db_session.query(Concept).filter_by(concept_id=broader['id'],
                                                                          conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    broader_concept = Concept(concept_id=broader['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.broader_concepts.add(broader_concept)
            narrower = concept_json.get('narrower', [])
            for narrower in narrower:
                try:
                    narrower_concept = db_session.query(Concept).filter_by(concept_id=narrower['id'],
                                                                           conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    narrower_concept = Concept(concept_id=narrower['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.narrower_concepts.add(narrower_concept)

            matches = []
            matchdict = concept_json.get('matches', {})
            for type in matchdict:
                db_type = type + "Match"
                matchtype = db_session.query(MatchType).filter_by(name=db_type).one()
                for uri in matchdict[type]:
                    concept_id = concept_json.get('id', -1)
                    try:
                        match = db_session.query(Match).filter_by(uri=uri, matchtype_id=matchtype.name, concept_id=concept_id).one()
                    except NoResultFound:
                        match = Match()
                        match.matchtype = matchtype
                        match.uri = uri
                    matches.append(match)
            concept.matches = matches

            concept.narrower_collections.clear()
            narrower_collections = concept_json.get('subordinate_arrays', [])
            for narrower in narrower_collections:
                try:
                    narrower_collection = db_session.query(Collection)\
                        .filter_by(concept_id=narrower['id'], conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    narrower_collection = Collection(concept_id=narrower['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.narrower_collections.add(narrower_collection)

        if concept.type == 'collection':
            concept.members.clear()
            members = concept_json.get('members', [])
            for member in members:
                try:
                    member_concept = db_session.query(Thing).filter_by(concept_id=member['id'],
                                                                           conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    member_concept = Concept(concept_id=member['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.members.add(member_concept)

            concept.broader_concepts.clear()
            broader_concepts = concept_json.get('superordinates', [])
            for broader in broader_concepts:
                try:
                    broader_concept = db_session.query(Concept)\
                        .filter_by(concept_id=broader['id'], conceptscheme_id=concept.conceptscheme_id).one()
                except NoResultFound:
                    broader_concept = Concept(concept_id=broader['id'], conceptscheme_id=concept.conceptscheme_id)
                concept.broader_concepts.add(broader_concept)

    return concept
    def setUp(self):
        self.concept = Concept()
        self.concept.type = 'concept'
        self.concept.id = 11
        self.concept.concept_id = 101
        self.concept.uri = 'urn:x-atramhasis-demo:TREES:101'
        self.concept.conceptscheme_id = 1

        notes = []
        note = Note(note='test note', notetype_id='example', language_id='en')
        note2 = Note(note='note def',
                     notetype_id='definition',
                     language_id='en')
        notes.append(note)
        notes.append(note2)
        self.concept.notes = notes

        labels = []
        label = Label(label='een label',
                      labeltype_id='prefLabel',
                      language_id='nl')
        label2 = Label(label='other label',
                       labeltype_id='altLabel',
                       language_id='en')
        label3 = Label(label='and some other label',
                       labeltype_id='altLabel',
                       language_id='en')
        labels.append(label)
        labels.append(label2)
        labels.append(label3)
        self.concept.labels = labels

        sources = []
        source = Source('Van Daele K. 2009')
        sources.append(source)
        self.concept.sources = sources

        matches = []
        match = Match()
        match.matchtype = MatchType(name='closeMatch', description='test')
        match.uri = 'urn:somethingelse:st1'
        matches.append(match)
        match2 = Match()
        match2.matchtype = MatchType(name='closeMatch', description='test')
        match2.uri = 'urn:somethingelse:st2'
        matches.append(match2)
        match3 = Match()
        match3.matchtype = MatchType(name='exactMatch', description='test')
        match3.uri = 'urn:something:thingy'
        matches.append(match3)
        self.concept.matches = matches

        self.collection = Collection()
        self.collection.type = 'collection'
        self.collection.id = 12
        self.collection.concept_id = 102
        self.collection.uri = 'urn:x-atramhasis-demo:TREES:102'
        self.collection.conceptscheme_id = 1

        self.conceptscheme = ConceptScheme()
        self.conceptscheme.id = 1
        self.conceptscheme.labels = labels
        self.conceptscheme.notes = notes
        self.conceptscheme.sources = sources
        self.conceptscheme.uri = None

        self.regis = Registry()
        self.regis.register_provider(trees)
        self.request = testing.DummyRequest()
        self.request.skos_registry = self.regis
        self.request.matchdict = {'scheme_id': 'TREES'}
        self.request.locale_name = 'nl'

        self.concept.member_of.add(self.collection)
        self.collection.members.add(self.concept)
示例#11
0
    def setUp(self):
        self.concept = Concept()
        self.concept.type = 'concept'
        self.concept.id = 11
        self.concept.concept_id = 101
        self.concept.uri = 'urn:x-atramhasis-demo:TREES:101'
        self.concept.conceptscheme_id = 1

        notes = []
        note = Note(note='test note', notetype_id='example', language_id='en')
        note2 = Note(note='note def', notetype_id='definition', language_id='en')
        notes.append(note)
        notes.append(note2)
        self.concept.notes = notes

        labels = []
        label = Label(label='een label', labeltype_id='prefLabel', language_id='nl')
        label2 = Label(label='other label', labeltype_id='altLabel', language_id='en')
        label3 = Label(label='and some other label', labeltype_id='altLabel', language_id='en')
        labels.append(label)
        labels.append(label2)
        labels.append(label3)
        self.concept.labels = labels

        sources = []
        source = Source('Van Daele K. 2009')
        sources.append(source)
        self.concept.sources = sources

        matches = []
        match = Match()
        match.matchtype = MatchType(name='closeMatch', description='test')
        match.uri = 'urn:somethingelse:st1'
        matches.append(match)
        match2 = Match()
        match2.matchtype = MatchType(name='closeMatch', description='test')
        match2.uri = 'urn:somethingelse:st2'
        matches.append(match2)
        match3 = Match()
        match3.matchtype = MatchType(name='exactMatch', description='test')
        match3.uri = 'urn:something:thingy'
        matches.append(match3)
        self.concept.matches = matches

        self.collection = Collection()
        self.collection.type = 'collection'
        self.collection.id = 12
        self.collection.concept_id = 102
        self.collection.uri = 'urn:x-atramhasis-demo:TREES:102'
        self.collection.conceptscheme_id = 1

        self.conceptscheme = ConceptScheme()
        self.conceptscheme.id = 1
        self.conceptscheme.labels = labels
        self.conceptscheme.notes = notes
        self.conceptscheme.sources = sources
        self.conceptscheme.uri = None

        self.regis = Registry()
        self.regis.register_provider(trees)
        self.request = testing.DummyRequest()
        self.request.skos_registry = self.regis
        self.request.matchdict = {'scheme_id': 'TREES'}

        self.concept.member_of.add(self.collection)
        self.collection.members.add(self.concept)