def test_twin_tags_projects(self, userA, userB, projects_userA,
                                tags_userA_userB):
        """
        Test two users annotate the two Projects with the same tag(s)
        """
        conn = get_connection(userA)
        tag1 = tags_userA_userB[0]
        tag2 = tags_userA_userB[1]
        project1 = projects_userA[0]
        project2 = projects_userA[1]
        link1 = annotate_project(tag1, project1, userA)
        link2 = annotate_project(tag1, project2, userB)
        link3 = annotate_project(tag2, project2, userB)
        link4 = annotate_project(tag2, project2, userA)
        expected = expected_annotations(userA, [link1, link2, link3, link4])
        pids = [p.id.val for p in projects_userA]
        marshaled = marshal_annotations(conn=conn, project_ids=pids)
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 4
        assert len(experimenters) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert annotations[2] == anns[2]
        assert annotations[3] == anns[3]
        assert experimenters == exps
Exemplo n.º 2
0
def well_annotations(request, screen, conn=None, **kwargs):
    """
    Return Annotations on child Wells.
    JSON format same as for webclient/api/annotations/?type=map
    """

    ann_type = request.GET.get('type', None)

    # get wells in Screen
    queryService = conn.getQueryService()
    params = ParametersI()
    params.addId(screen)
    query = """select well.id from Well as well
               join well.plate plate
               join plate.screenLinks screenLinks
               where screenLinks.parent.id=:id
            """
    result = queryService.projection(query, params, conn.SERVICE_OPTS)
    iids = [r[0].val for r in result]
    anns, exps = marshal_annotations(conn,
                                     well_ids=iids,
                                     ann_type=ann_type,
                                     limit=100000)

    return JsonResponse({'annotations': anns, 'experimenters': exps})
    def test_twin_tags_userA_userB(self, userA, userB, project_userA,
                                   tags_userA_userB):
        """
        Test two users annotate the same Project with the same tag
        """
        conn = get_connection(userA)
        tag1 = tags_userA_userB[0]
        tag2 = tags_userA_userB[1]
        project = project_userA
        link1 = annotate_project(tag1, project, userA)
        link2 = annotate_project(tag1, project, userB)
        link3 = annotate_project(tag2, project, userB)
        expected = expected_annotations(userA, [link1, link2, link3])
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 3
        assert len(experimenters) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert annotations[2] == anns[2]
        assert experimenters == exps
Exemplo n.º 4
0
def image_annotations(request, project, conn=None, **kwargs):
    """
    Return Annotations on child Images.
    JSON format same as for webclient/api/annotations/?type=map
    """

    ann_type = request.GET.get('type', None)

    # get images in Project
    queryService = conn.getQueryService()
    params = ParametersI()
    params.addId(project)
    query = """select image.id from Image as image
               join image.datasetLinks datasetLinks
               join datasetLinks.parent as dataset
               join dataset.projectLinks projectLinks
               where projectLinks.parent.id=:id
            """
    result = queryService.projection(query, params, conn.SERVICE_OPTS)
    iids = [r[0].val for r in result]
    anns, exps = marshal_annotations(conn,
                                     image_ids=iids,
                                     ann_type=ann_type,
                                     limit=100000)

    return JsonResponse({'annotations': anns, 'experimenters': exps})
    def test_twin_tags_projects(self, userA, userB, projects_userA,
                                tags_userA_userB):
        """
        Test two users annotate the two Projects with the same tag(s)
        """
        conn = get_connection(userA)
        tag1 = tags_userA_userB[0]
        tag2 = tags_userA_userB[1]
        project1 = projects_userA[0]
        project2 = projects_userA[1]
        link1 = annotate_project(tag1, project1, userA)
        link2 = annotate_project(tag1, project2, userB)
        link3 = annotate_project(tag2, project2, userB)
        link4 = annotate_project(tag2, project2, userA)
        expected = expected_annotations(userA, [link1, link2, link3, link4])
        pids = [p.id.val for p in projects_userA]
        marshaled = marshal_annotations(conn=conn, project_ids=pids)
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 4
        assert len(experimenters) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert annotations[2] == anns[2]
        assert annotations[3] == anns[3]
        assert experimenters == exps
    def test_twin_tags_userA_userB(self, userA, userB, project_userA,
                                   tags_userA_userB):
        """
        Test two users annotate the same Project with the same tag
        """
        conn = get_connection(userA)
        tag1 = tags_userA_userB[0]
        tag2 = tags_userA_userB[1]
        project = project_userA
        link1 = annotate_project(tag1, project, userA)
        link2 = annotate_project(tag1, project, userB)
        link3 = annotate_project(tag2, project, userB)
        expected = expected_annotations(userA, [link1, link2, link3])
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 3
        assert len(experimenters) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert annotations[2] == anns[2]
        assert experimenters == exps
Exemplo n.º 7
0
    def test_filter_by_namespace(self, userA, project_userA, rating_userA,
                                 comments_userA):
        """Test filtering of Annotations by Namespace."""
        conn = get_connection(userA)
        comment1, comment2 = comments_userA
        rating = rating_userA

        project = project_userA
        rating_link = annotate_project(rating, project, userA)
        annotate_project(comment1, project, userA)
        annotate_project(comment2, project, userA)

        # Filter by rating namespace should only return a single link
        rating_ns = omero.constants.metadata.NSINSIGHTRATING
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val],
                                        ns=rating_ns)
        expected = expected_annotations(userA, [rating_link])
        assert marshaled[0] == expected[0]

        # Confirm we get all 3 links when we don't filter
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val])
        assert len(marshaled[0]) == 3
    def test_single_tag(self, userA, project_userA, tags_userA_userB):
        """
        Test a single annotation added by userA
        """
        conn = get_connection(userA)
        tag = tags_userA_userB[0]
        project = project_userA
        link = annotate_project(tag, project, userA)
        expected = expected_annotations(userA, [link])
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val])
        annotations, experimenters = marshaled
        anns, exps = expected

        assert annotations == anns
        assert experimenters == exps
    def test_single_tag_userB(self, userB, project_userA, tags_userA_userB):
        """
        Test a single annotation added by userB
        """
        conn = get_connection(userB)
        tag = tags_userA_userB[0]
        project = project_userA
        link = annotate_project(tag, project, userB)
        expected = expected_annotations(userB, [link])
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val])
        annotations, experimenters = marshaled
        anns, exps = expected

        assert annotations == anns
        assert experimenters == exps
    def test_tags_comments_project(self, userA, project_userA,
                                   tags_userA_userB, comments_userA):
        """
        Test annotate Project with the Tags and Comments
        """
        conn = get_connection(userA)
        tag1, tag2 = tags_userA_userB
        comment1, comment2 = comments_userA
        project = project_userA
        link1 = annotate_project(tag1, project, userA)
        link2 = annotate_project(comment1, project, userA)
        link3 = annotate_project(tag2, project, userA)
        link4 = annotate_project(comment2, project, userA)

        # Get just the tags...
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val],
                                        ann_type='tag')
        expected = expected_annotations(userA, [link1, link3])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 2
        assert len(experimenters) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert experimenters == exps

        # Get just the comments...
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val],
                                        ann_type='comment')
        expected = expected_annotations(userA, [link2, link4])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert len(experimenters) == 1
        assert annotations == anns
        assert experimenters == exps

        # Get all annotations
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val])
        expected = expected_annotations(userA, [link1, link2, link3, link4])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected

        assert len(annotations) == 4
        assert len(experimenters) == 2
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert annotations[2] == anns[2]
        assert annotations[3] == anns[3]
        assert experimenters == exps
    def test_tags_comments_project(self, userA, project_userA,
                                   tags_userA_userB, comments_userA):
        """
        Test annotate Project with the Tags and Comments
        """
        conn = get_connection(userA)
        tag1, tag2 = tags_userA_userB
        comment1, comment2 = comments_userA
        project = project_userA
        link1 = annotate_project(tag1, project, userA)
        link2 = annotate_project(comment1, project, userA)
        link3 = annotate_project(tag2, project, userA)
        link4 = annotate_project(comment2, project, userA)

        # Get just the tags...
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val],
                                        ann_type='tag')
        expected = expected_annotations(userA, [link1, link3])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 2
        assert len(experimenters) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert experimenters == exps

        # Get just the comments...
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val],
                                        ann_type='comment')
        expected = expected_annotations(userA, [link2, link4])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])

        assert len(annotations) == 2
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert len(experimenters) == 1
        assert annotations == anns
        assert experimenters == exps

        # Get all annotations
        marshaled = marshal_annotations(conn=conn,
                                        project_ids=[project.id.val])
        expected = expected_annotations(userA, [link1, link2, link3, link4])
        annotations, experimenters = marshaled
        experimenters.sort(key=lambda x: x['id'])
        anns, exps = expected

        assert len(annotations) == 4
        assert len(experimenters) == 2
        # need to sort since marshal_annotations doesn't sort yet
        annotations.sort(key=lambda x: x['link']['id'])
        anns.sort(key=lambda x: x['link']['id'])
        assert annotations[0] == anns[0]
        assert annotations[1] == anns[1]
        assert annotations[2] == anns[2]
        assert annotations[3] == anns[3]
        assert experimenters == exps