예제 #1
0
 def getAggregateTagGroupsByImage(self, imageKey, isKey=True):
     metadata = WebServiceArray()
     
     try:
         if (isKey):
             image = Picture.objects.get(pk__exact=imageKey)
         else:
             image = imageKey
     except (ObjectDoesNotExist, ValueError):
         raise Errors.INVALID_IMAGE_KEY
             
     if not image.readPermissions(self.user):
         raise Errors.AUTHENTICATION
             
     # initialize tagging APIs
     tagGroupAPI = TagGroupAPI(self.limit, self.offset, self.user, self.fields, self.unlimited)
     tagAPI = TagAPI(user=self.user, unlimited=True)
     geneLinkAPI = GeneLinkAPI(user=self.user, unlimited=True)
     
     tagGroups = tagGroupAPI.getTagGroupsByImage(image, False).getObject()
     
     for group in tagGroups:
         tags = tagAPI.getTagsByTagGroup(group['id']).getObject()
         for tag in tags:
             geneLinks = geneLinkAPI.getGeneLinksByTag(tag['id']).getObject()
             tag['geneLinks'] = geneLinks
         group['tags'] = tags
         
     metadata.setObject(tagGroups)
 
     return metadata
예제 #2
0
    def getTagGroup(self, tagGroupKey, isKey=True):
        metadata = WebServiceObject()
        
        try:
            if isKey:
                group = TagGroup.objects.get(pk__exact=tagGroupKey)
            else:
                group = tagGroupKey
        except (ObjectDoesNotExist, ValueError):
            raise Errors.INVALID_TAG_GROUP_KEY
                
        # initialize tagging APIs
        tagGroupAPI = TagGroupAPI(self.user, self.fields)
        tagAPI = TagAPI(user=self.user, unlimited=True)
        geneLinkAPI = GeneLinkAPI(user=self.user, unlimited=True)
        
        group = tagGroupAPI.getTagGroup(group, isKey=False).getObject()

        tags = tagAPI.getTagsByTagGroup(group['id']).getObject()
        for tag in tags:
            geneLinks = geneLinkAPI.getGeneLinksByTag(tag['id']).getObject()
            tag['geneLinks'] = geneLinks
        group['tags'] = tags
            
        metadata.setObject(group)
    
        return metadata
예제 #3
0
    def doProcessRender(self, request):
        self.setLayout('admin/imageEditor.html')
        try:
            imageKey = request.GET.get('imageId', None)
            if (imageKey):
                image = Picture.objects.get(pk__exact=imageKey)

                # initialize tagging APIs
                tagGroupAPI = TagGroupAPI(unlimited=True)
                tagAPI = TagAPI(unlimited=True)
                geneLinkAPI = GeneLinkAPI(unlimited=True)
                tagGroups = tagGroupAPI.getTagGroupsByImage(image,
                                                            False).getObject()

                for group in tagGroups:

                    tags = tagAPI.getTagsByTagGroup(group['id']).getObject()
                    #tags = tagAPI.getTagsByImage(group['imageId']).getObject()
                    #print('tags= ' + json.dumps(tags))
                    #print('group id= ' + json.dumps(group))
                    for tag in tags:
                        geneLinks = geneLinkAPI.getGeneLinksByTag(
                            tag['id']).getObject()
                        tag['geneLinks'] = geneLinks
                        #print('tag= ' + json.dumps(tag))
                    group['tags'] = tags

                #print('tagGroups= ' + json.dumps(tagGroups))

                # initialize image metadata API
                imageMetadataAPI = ImageMetadataAPI(request.user)
                imageMetadata = imageMetadataAPI.getImageMetadata(
                    image, isKey=False).getObject()

                # add to recently viewed images - modified by ktcho, 2017.10.09
                # moved from get.py to here (add only when user view image via image editor/viewer)
                if (request.user):
                    RecentlyViewedPicture.objects.get_or_create(
                        user=request.user, picture=image)[0].save()

                return {
                    'imageMetadata': json.dumps(imageMetadata),
                    'tagGroups': json.dumps(tagGroups),
                    'image': image
                }
            else:
                self.setLayout('public/404Media.html')
                return {}
        except ObjectDoesNotExist:
            self.setLayout('public/404Media.html')
            return {}
        except KeyError:
            self.setLayout('public/404Media.html')
            return {}
예제 #4
0
    def doProcessRender(self, request):
        self.setLayout('admin/imageEditor.html')
        try:
            imageKey = request.GET.get('imageId', None)
            if (imageKey):
                image = Picture.objects.get(pk__exact=imageKey)

                # initialize tagging APIs
                tagGroupAPI = TagGroupAPI(unlimited=True)
                tagAPI = TagAPI(unlimited=True)
                geneLinkAPI = GeneLinkAPI(unlimited=True)

                tagGroups = tagGroupAPI.getTagGroupsByImage(image,
                                                            False).getObject()

                for group in tagGroups:
                    tags = tagAPI.getTagsByTagGroup(group['id']).getObject()
                    for tag in tags:
                        geneLinks = geneLinkAPI.getGeneLinksByTag(
                            tag['id']).getObject()
                        tag['geneLinks'] = geneLinks
                    group['tags'] = tags

                # initialize image metadata API
                imageMetadataAPI = ImageMetadataAPI(request.user)
                imageMetadata = imageMetadataAPI.getImageMetadata(
                    image, isKey=False).getObject()

                return {
                    'imageMetadata': json.dumps(imageMetadata),
                    'tagGroups': json.dumps(tagGroups),
                    'image': image
                }
            else:
                self.setLayout('public/404Media.html')
                return {}
        except ObjectDoesNotExist:
            self.setLayout('public/404Media.html')
            return {}
        except KeyError:
            self.setLayout('public/404Media.html')
            return {}
예제 #5
0
 def getAggregateTagGroups(self):
     metadata = WebServiceArray()
             
     # initialize tagging APIs
     tagGroupAPI = TagGroupAPI(self.limit, self.offset, self.user, self.fields, self.unlimited)
     tagAPI = TagAPI(user=self.user, unlimited=True)
     geneLinkAPI = GeneLinkAPI(user=self.user, unlimited=True)
     
     tagGroups = tagGroupAPI.getTagGroups().getObject()
     
     for group in tagGroups:
         tags = tagAPI.getTagsByTagGroup(group['id']).getObject()
         for tag in tags:
             geneLinks = geneLinkAPI.getGeneLinksByTag(tag['id']).getObject()
             tag['geneLinks'] = geneLinks
         group['tags'] = tags
         
     metadata.setObject(tagGroups)
 
     return metadata
 def doProcessRender(self, request):
     self.setLayout('admin/imageEditor.html')
     try:
         imageKey = request.GET.get('imageId', None)
         if (imageKey):
             image = Picture.objects.get(pk__exact=imageKey)
             
             # initialize tagging APIs
             tagGroupAPI = TagGroupAPI(unlimited=True)
             tagAPI = TagAPI(unlimited=True)
             geneLinkAPI = GeneLinkAPI(unlimited=True)
             
             tagGroups = tagGroupAPI.getTagGroupsByImage(image, False).getObject()
             
             for group in tagGroups:
                 tags = tagAPI.getTagsByTagGroup(group['id']).getObject()
                 for tag in tags:
                     geneLinks = geneLinkAPI.getGeneLinksByTag(tag['id']).getObject()
                     tag['geneLinks'] = geneLinks
                 group['tags'] = tags
                 
             # initialize image metadata API
             imageMetadataAPI = ImageMetadataAPI(request.user)
             imageMetadata = imageMetadataAPI.getImageMetadata(image, isKey=False).getObject()
     
             return {
                 'imageMetadata' : json.dumps(imageMetadata),
                 'tagGroups' : json.dumps(tagGroups),
                 'image' : image
             }
         else:
             self.setLayout('public/404Media.html')
             return {}
     except ObjectDoesNotExist:
         self.setLayout('public/404Media.html')
         return {}
     except KeyError:
         self.setLayout('public/404Media.html')
         return {}