コード例 #1
0
def add_images_key_values(gateway, key_values, image_ids, group_id, description=None):
    """Adds some key:value pairs to a list of images"""
    map_data = _dict_to_map_annotation(key_values, description)

    data_manager, ctx = _data_manager_generator(gateway, group_id)

    # Link the data to the image
    if not hasattr(image_ids, '__iter__'):
        image_ids = [image_ids]
    for ID in image_ids:
        link = ImageAnnotationLinkI()
        link.setChild(map_data.asAnnotation())
        link.setParent(ImageI(ID, False))
        data_manager.saveAndReturnObject(ctx, link)
コード例 #2
0
def add_image_tag(gateway, tag_text, image_id, description=None):
    """Adds a tag to an image"""
    data_manager = gateway.getFacility(DataManagerFacility)
    user = gateway.getLoggedInUser()
    ctx = SecurityContext(user.getGroupId())

    # Arrange the data
    tag_data = TagAnnotationData(tag_text)
    if description:
        tag_data.setTagDescription(description)

    # Link the data to the image
    link = ImageAnnotationLinkI()
    link.setChild(tag_data.asAnnotation())
    link.setParent(ImageI(image_id, False))

    return data_manager.saveAndReturnObject(ctx, link)