Exemplo n.º 1
0
     print ""
     #print rv_message
     print "*******"
     return rv_message
 
 ##########################################
 # SERIALIZATION TEST
 ##########################################
 
 # URL of target ActiveMQ bus
 # To monitor bus activity for cimcollege browse to the following URL
 # http://www.cimcollege.rs:8161/admin/topics.jsp
 url = 'tcp://www.cimcollege.rs:61616'
 #url = 'tcp://laus.perimeter.fzi.de:61616'
 # General purpose event composer
 event_composer = EventComposer()
 
 ## Socrates
 ## issue recommendation
 #tx_message = event_composer.serial_metadata(EventComposer.header_issues_recomm, 
                             #EventComposer.params_issues_recommend,
                             #False, True, EventComposer.topic_req_issues_recomm)
 #print tx_message
 #test_recomm = BusQuery(url, EventComposer.topic_req_issues_recomm, tx_message,
                          #EventComposer.topic_res_issues_recomm)
 #send_receive(test_recomm)
 
 ## developer recommendation
 #tx_message = event_composer.serial_metadata(EventComposer.header_devs_recomm, 
                             #EventComposer.params_devs_recommend,
                             #False, True, EventComposer.topic_req_devs_recomm)
Exemplo n.º 2
0
def query_handler(request):
    """
    Entry method to handle incoming search queries for hound service.
    Query fields come embedded in request search arguments.
    """
    
    ec = EventComposer()
    
    if request.method == 'GET':
        
        query = request.GET
        
        if 'commit_option' in query:
            
            if (query['commit_option'] == 'info'):
                if 'commit_uri' in query and query['commit_uri'] != '':
                    # Case of retrieving information from a commit
                    print "Case commit.getInfo"

                    params_commit_get_info = {"apiCall": "commit.getInfo",
                        "in_params": (("commitUri", 
                        query['commit_uri'],),)
                        }
                    
                    response = ec.send_recv_metadata(BUS_URL, params_commit_get_info)

                    print("Received: ALERT.Metadata.APICallResponse")
                    
                    data = ec.deserial_metadata('commit.getInfo',
                                StringIO(response))
                else:
                    return HttpResponse("You must provide the commit URI")
                
            elif (query['commit_option'] == 'prod'):
                if 'product' in query and query['product'] != '':
                    # Case of retrieving all commits related to a method
                    # To: Metadata service
                    print "Case commit.getAllForProduct"
                    
                    if 'from_date' in query and query['from_date'] != '':
                        params_commit_get_all_for_product = {"apiCall": "commit.getAllForProduct",
                        "in_params": (("productID", query['product'],),
                                    ("fromDate",query['from_date'],),)
                        }
                        
                    else:
                        params_commit_get_all_for_product = {"apiCall": "commit.getAllForProduct",
                        "in_params": (("productID", query['product'],),)
                        }
                    
                    response = ec.send_recv_metadata(BUS_URL, params_commit_get_all_for_product)

                    print("Received: ALERT.Metadata.APICallResponse")
                    
                    data = ec.deserial_metadata('commit.getAllForProduct',
                            StringIO(response))
                else:
                    return HttpResponse("You must provide a product name.")
                        
        elif ('issue_id' in query and query['issue_id'] != ''):
            
            if ('issue_option' in query and query['issue_option'] != ''):
                if (query['issue_option'] == 'sug'):
                    # Case of suggesting developers for an issue
                    # To: Recommendation service
                    print "Case Recommender.identity.Recommendation"
                    
                    params_devs_recommend = {"issues": ((query['issue_id'],"owl#1"),) 
                                        }
                    
                    response = ec.send_recv_recommender(BUS_URL, params_devs_recommend, 'devs')
                    
                    print("Received: Response from Recommendation service")
                    response = response.replace('encoding="UTF-8"', 'encoding="iso-8859-1"')
                    
                    data = ec.deserial_recommendation('identity.Recommendation',
                            StringIO(response))
                
                elif (query['issue_option'] == 'sim'):
                    # Case of finding related issues
                    # To: KEUI
                    print "Case KEUI-similarThreads"
                    
                    params_similar_threads = {"type": "similarThreads",
                                              "threadId": "-1",
                                              "bugId": query['issue_id'],
                                              "count": 10,
                                              "itemDataSnipLen" : 200,
                                              "includeItemIds": "True",
                                              "includeItemData": "True",
                                              "includeOnlyFirstInThread": "True",                          
                                              "maxCount": 10,
                                              "offset": 0,
                                              "includePeopleData" : "False"
                                              }

                    response = ec.send_recv_keui(BUS_URL, params_similar_threads)
                    response = response.replace('encoding="UTF-8"', 'encoding="iso-8859-1"')
                    data = ec.deserial_keui('similarThreads',
                                    StringIO(response))
                
                elif (query['issue_option'] == 'ext'):
                    # Case of presented extended info about issue
                    # To: Metadata service
                    print "Case issue.getInfo"
                                  
                    params_issue_get_info = {"apiCall": "issue.getInfo",
                                "in_params": (("issueID",query['issue_id'],),)
                                }

                    response = ec.send_recv_metadata(BUS_URL, params_issue_get_info)

                    print("Received: ALERT.Metadata.APICallResponse")
                    response = response.replace('encoding="UTF-8"', 'encoding="iso-8859-1"')
                    data = ec.deserial_metadata('issue.getInfo',
                                    StringIO(response))
     
            else:
                return HttpResponse("You must select an issue option for this particular ID.")
                                        
        elif 'product' in query and query['product'] != '':
            # Case of getting all issues for a product
            # To: Metadata service
            print "Case issue.getAllForProduct"
            
            if 'from_date' in query and query['from_date'] != '':
                params_issue_get_all_for_product = {"apiCall": "issue.getAllForProduct",
                    "in_params": (("productID", query['product'],),
                                    ("fromDate", query['from_date'],),)
                    }
                    
            else:
                params_issue_get_all_for_product = {"apiCall": "issue.getAllForProduct",
                    "in_params": (("productID", query['product'],),)
                    }
            
            response = ec.send_recv_metadata(BUS_URL, params_issue_get_all_for_product)

            print("Received: ALERT.Metadata.APICallResponse")
            
            data = ec.deserial_metadata('issue.getAllForProduct',
                    StringIO(response))
            
        elif 'method_uri' in query and query['method_uri'] != '':
            # Case of getting all issues for a method
            # To: Metadata service
            print "Case issue.getAllForMethod"
            
            #TODO: Handle input for more than one method
            params_issue_get_all_for_method = {"apiCall": "issue.getAllForMethod",
                "in_params": (("methodUri", query['method'],),)
                }
            
            response = ec.send_recv_metadata(BUS_URL, params_issue_get_all_for_method)

            print("Received: ALERT.Metadata.APICallResponse")
            
            data = ec.deserial_metadata('issue.getAllForMethod',
                    StringIO(response))
       
        elif 'keywords' in query and query['keywords'] != '':
            # Case of issues related to keywords
            # To: KEUI
            print "Case KEUI-keywords"
            
            params_issues_for_keywords = {'keywords': (query['keywords'],),
                        "offset": 0, "maxCount": 100, 'resultData': 'itemData',
                        "includeAttachments": 1, 'sortBy': 'dateDesc',
                        'itemDataSnipLen': 200, 'snipMatchKeywords': 1,
                        'keywordMatchOffset': 25, 'includePeopleData':0
                        }
            
            response = ec.send_recv_keui(BUS_URL, params_issues_for_keywords)
            
            data = ec.deserial_keui('issuesForKeywords',
                                    StringIO(response))
            
        elif 'developer' in query and query['developer'] != '':
            # Case of suggest issues for a developer
            # To: Recommendation service
            print "Case Recommender.issuesRecommended"
            
            # Example developer UUID:
            # "ff9dc34d-774e-47ad-9eab-07c46ab3e765ff0df1c4-4c8d-4703-97ea-267d83b4ac08"
            params_issues_recommend = {"identities": (query['developer'],)
                }
            
            response = send_recv_recommender(BUS_URL, params_issues_recommend, 'issues')
            
            data = ec.deserial_recommendation('issue.Recommendation',
                                    StringIO(response))
        
        else:
            # Error: there must be one option selected
            return HttpResponse("Unsupported query petition.</br>"+\
                "You must provide at least a commit_id, issue_id, "+\
                "list of keywords (separated by blank spaces) "+\
                "or developer name for searching.")
                
        return HttpResponse(json.dumps(data), mimetype="application/json")
Exemplo n.º 3
0
def query_test(request):
    """
    Test method for REST API
    http://127.0.0.1:8000/hound/search/query/?issue_id=1&project=kde
    &keywords=hola,adios,tururu&commit_id=123&component=solid
    &start_date=20100901&end_date=20110901
    """
    
    deserial_test = EventComposer()
    
    if request.method == 'GET':
        
        query = request.GET
        
        if 'commit_option' in query:
            
            if (query['commit_option'] == 'info'):
                if 'commit_uri' in query and query['commit_uri'] != '':
                    print "Case commit.getInfo"
                    data = deserial_test.deserial_metadata('commit.getInfo',
                                'templates/events/metadata-commit.getInfo.xml')
                                
                else:
                    return HttpResponse("You must provide the commit URI")
                
            elif (query['commit_option'] == 'prod'):
                if 'product' in query and query['product'] != '':
                    # Case of retrieving all commits related to a method
                    # To: Metadata service
                    print "Case commit.getAllForProduct"
                    data = deserial_test.deserial_metadata('commit.getAllForProduct',
                        'templates/events/metadata-commit.getAllForProduct.xml')
                else:
                    return HttpResponse("You must provide a product name.")
                        
        elif ('issue_id' in query and query['issue_id'] != ''):
            
            if ('issue_option' in query and query['issue_option'] != ''):
                if (query['issue_option'] == 'sug'):
                    # Case of suggesting developers for an issue
                    # To: Recommendation service
                    print "Case Recommender.identity.Recommendation"
                    data = deserial_test.deserial_recommendation('identity.Recommendation',
                            'templates/events/recommender-IdentityRecommendation.xml')
                
                elif (query['issue_option'] == 'sim'):
                    # Case of finding related issues
                    # To: KEUI
                    print "Case KEUI-similarThreads"
                    data = deserial_test.deserial_keui('similarThreads',
                                    'templates/events/KEUI-similarThreads.xml')
                
                elif (query['issue_option'] == 'ext'):
                    # Case of presented extended info about issue
                    # To: Metadata service
                    print "Case issue.getInfo"
                    data = deserial_test.deserial_metadata('issue.getInfo',
                                    'templates/events/metadata-issue.getInfo.xml')
                                   
            else:
                return HttpResponse("You must select an issue option for this particular ID.")
                                        
        elif 'product' in query and query['product'] != '':
            # Case of getting all issues for a product
            # To: Metadata service
            print "Case issue.getAllForProduct"
            data = deserial_test.deserial_metadata('issue.getAllForProduct',
                    'templates/events/metadata-issue.getAllForProduct.xml')
            
        elif 'method_uri' in query and query['method_uri'] != '':
            # Case of getting all issues for a method
            # To: Metadata service
            print "Case issue.getAllForMethod"
            data = deserial_test.deserial_metadata('issue.getAllForMethod',
                    'templates/events/metadata-issue.getAllForMethod.xml')
       
        elif 'keywords' in query and query['keywords'] != '':
            # Case of issues related to keywords
            # To: KEUI
            print "Case KEUI-keywords"
            data = deserial_test.deserial_keui('issuesForKeywords',
                                    'templates/events/KEUI-keywords.xml')
            
        elif 'developer' in query and query['developer'] != '':
            # Case of suggest issues for a developer
            # To: Recommendation service
            print "Case Recommender.issuesRecommended"
            data = deserial_test.deserial_recommendation('issue.Recommendation',
                                    'templates/events/recommender-issuesRecommended.xml')
        
        else:
            # Error: there must be one option selected
            return HttpResponse("Unsupported query petition.</br>"+\
                "You must provide at least a commit_id, issue_id, "+\
                "list of keywords (separated by blank spaces) "+\
                "or developer name for searching.")
                
        return HttpResponse(json.dumps(data), mimetype="application/json")
Exemplo n.º 4
0
def query_handler(request):
    """
    Entry method to handle incoming search queries for hound service.
    Query fields come embedded in request search arguments.
    """

    ec = EventComposer()

    if request.method == 'GET':

        query = request.GET

        if 'commit_option' in query:

            if (query['commit_option'] == 'info'):
                if 'commit_uri' in query and query['commit_uri'] != '':
                    # Case of retrieving information from a commit
                    print "Case commit.getInfo"

                    params_commit_get_info = {
                        "apiCall": "commit.getInfo",
                        "in_params": ((
                            "commitUri",
                            query['commit_uri'],
                        ), )
                    }

                    response = ec.send_recv_metadata(BUS_URL,
                                                     params_commit_get_info)

                    print("Received: ALERT.Metadata.APICallResponse")

                    data = ec.deserial_metadata('commit.getInfo',
                                                StringIO(response))
                else:
                    return HttpResponse("You must provide the commit URI")

            elif (query['commit_option'] == 'prod'):
                if 'product' in query and query['product'] != '':
                    # Case of retrieving all commits related to a method
                    # To: Metadata service
                    print "Case commit.getAllForProduct"

                    if 'from_date' in query and query['from_date'] != '':
                        params_commit_get_all_for_product = {
                            "apiCall":
                            "commit.getAllForProduct",
                            "in_params": (
                                (
                                    "productID",
                                    query['product'],
                                ),
                                (
                                    "fromDate",
                                    query['from_date'],
                                ),
                            )
                        }

                    else:
                        params_commit_get_all_for_product = {
                            "apiCall": "commit.getAllForProduct",
                            "in_params": ((
                                "productID",
                                query['product'],
                            ), )
                        }

                    response = ec.send_recv_metadata(
                        BUS_URL, params_commit_get_all_for_product)

                    print("Received: ALERT.Metadata.APICallResponse")

                    data = ec.deserial_metadata('commit.getAllForProduct',
                                                StringIO(response))
                else:
                    return HttpResponse("You must provide a product name.")

        elif ('issue_id' in query and query['issue_id'] != ''):

            if ('issue_option' in query and query['issue_option'] != ''):
                if (query['issue_option'] == 'sug'):
                    # Case of suggesting developers for an issue
                    # To: Recommendation service
                    print "Case Recommender.identity.Recommendation"

                    params_devs_recommend = {
                        "issues": ((query['issue_id'], "owl#1"), )
                    }

                    response = ec.send_recv_recommender(
                        BUS_URL, params_devs_recommend, 'devs')

                    print("Received: Response from Recommendation service")
                    response = response.replace('encoding="UTF-8"',
                                                'encoding="iso-8859-1"')

                    data = ec.deserial_recommendation(
                        'identity.Recommendation', StringIO(response))

                elif (query['issue_option'] == 'sim'):
                    # Case of finding related issues
                    # To: KEUI
                    print "Case KEUI-similarThreads"

                    params_similar_threads = {
                        "type": "similarThreads",
                        "threadId": "-1",
                        "bugId": query['issue_id'],
                        "count": 10,
                        "itemDataSnipLen": 200,
                        "includeItemIds": "True",
                        "includeItemData": "True",
                        "includeOnlyFirstInThread": "True",
                        "maxCount": 10,
                        "offset": 0,
                        "includePeopleData": "False"
                    }

                    response = ec.send_recv_keui(BUS_URL,
                                                 params_similar_threads)
                    response = response.replace('encoding="UTF-8"',
                                                'encoding="iso-8859-1"')
                    data = ec.deserial_keui('similarThreads',
                                            StringIO(response))

                elif (query['issue_option'] == 'ext'):
                    # Case of presented extended info about issue
                    # To: Metadata service
                    print "Case issue.getInfo"

                    params_issue_get_info = {
                        "apiCall": "issue.getInfo",
                        "in_params": ((
                            "issueID",
                            query['issue_id'],
                        ), )
                    }

                    response = ec.send_recv_metadata(BUS_URL,
                                                     params_issue_get_info)

                    print("Received: ALERT.Metadata.APICallResponse")
                    response = response.replace('encoding="UTF-8"',
                                                'encoding="iso-8859-1"')
                    data = ec.deserial_metadata('issue.getInfo',
                                                StringIO(response))

            else:
                return HttpResponse(
                    "You must select an issue option for this particular ID.")

        elif 'product' in query and query['product'] != '':
            # Case of getting all issues for a product
            # To: Metadata service
            print "Case issue.getAllForProduct"

            if 'from_date' in query and query['from_date'] != '':
                params_issue_get_all_for_product = {
                    "apiCall":
                    "issue.getAllForProduct",
                    "in_params": (
                        (
                            "productID",
                            query['product'],
                        ),
                        (
                            "fromDate",
                            query['from_date'],
                        ),
                    )
                }

            else:
                params_issue_get_all_for_product = {
                    "apiCall": "issue.getAllForProduct",
                    "in_params": ((
                        "productID",
                        query['product'],
                    ), )
                }

            response = ec.send_recv_metadata(BUS_URL,
                                             params_issue_get_all_for_product)

            print("Received: ALERT.Metadata.APICallResponse")

            data = ec.deserial_metadata('issue.getAllForProduct',
                                        StringIO(response))

        elif 'method_uri' in query and query['method_uri'] != '':
            # Case of getting all issues for a method
            # To: Metadata service
            print "Case issue.getAllForMethod"

            #TODO: Handle input for more than one method
            params_issue_get_all_for_method = {
                "apiCall": "issue.getAllForMethod",
                "in_params": ((
                    "methodUri",
                    query['method'],
                ), )
            }

            response = ec.send_recv_metadata(BUS_URL,
                                             params_issue_get_all_for_method)

            print("Received: ALERT.Metadata.APICallResponse")

            data = ec.deserial_metadata('issue.getAllForMethod',
                                        StringIO(response))

        elif 'keywords' in query and query['keywords'] != '':
            # Case of issues related to keywords
            # To: KEUI
            print "Case KEUI-keywords"

            params_issues_for_keywords = {
                'keywords': (query['keywords'], ),
                "offset": 0,
                "maxCount": 100,
                'resultData': 'itemData',
                "includeAttachments": 1,
                'sortBy': 'dateDesc',
                'itemDataSnipLen': 200,
                'snipMatchKeywords': 1,
                'keywordMatchOffset': 25,
                'includePeopleData': 0
            }

            response = ec.send_recv_keui(BUS_URL, params_issues_for_keywords)

            data = ec.deserial_keui('issuesForKeywords', StringIO(response))

        elif 'developer' in query and query['developer'] != '':
            # Case of suggest issues for a developer
            # To: Recommendation service
            print "Case Recommender.issuesRecommended"

            # Example developer UUID:
            # "ff9dc34d-774e-47ad-9eab-07c46ab3e765ff0df1c4-4c8d-4703-97ea-267d83b4ac08"
            params_issues_recommend = {"identities": (query['developer'], )}

            response = send_recv_recommender(BUS_URL, params_issues_recommend,
                                             'issues')

            data = ec.deserial_recommendation('issue.Recommendation',
                                              StringIO(response))

        else:
            # Error: there must be one option selected
            return HttpResponse("Unsupported query petition.</br>"+\
                "You must provide at least a commit_id, issue_id, "+\
                "list of keywords (separated by blank spaces) "+\
                "or developer name for searching.")

        return HttpResponse(json.dumps(data), mimetype="application/json")
Exemplo n.º 5
0
def query_test(request):
    """
    Test method for REST API
    http://127.0.0.1:8000/hound/search/query/?issue_id=1&project=kde
    &keywords=hola,adios,tururu&commit_id=123&component=solid
    &start_date=20100901&end_date=20110901
    """

    deserial_test = EventComposer()

    if request.method == 'GET':

        query = request.GET

        if 'commit_option' in query:

            if (query['commit_option'] == 'info'):
                if 'commit_uri' in query and query['commit_uri'] != '':
                    print "Case commit.getInfo"
                    data = deserial_test.deserial_metadata(
                        'commit.getInfo',
                        'templates/events/metadata-commit.getInfo.xml')

                else:
                    return HttpResponse("You must provide the commit URI")

            elif (query['commit_option'] == 'prod'):
                if 'product' in query and query['product'] != '':
                    # Case of retrieving all commits related to a method
                    # To: Metadata service
                    print "Case commit.getAllForProduct"
                    data = deserial_test.deserial_metadata(
                        'commit.getAllForProduct',
                        'templates/events/metadata-commit.getAllForProduct.xml'
                    )
                else:
                    return HttpResponse("You must provide a product name.")

        elif ('issue_id' in query and query['issue_id'] != ''):

            if ('issue_option' in query and query['issue_option'] != ''):
                if (query['issue_option'] == 'sug'):
                    # Case of suggesting developers for an issue
                    # To: Recommendation service
                    print "Case Recommender.identity.Recommendation"
                    data = deserial_test.deserial_recommendation(
                        'identity.Recommendation',
                        'templates/events/recommender-IdentityRecommendation.xml'
                    )

                elif (query['issue_option'] == 'sim'):
                    # Case of finding related issues
                    # To: KEUI
                    print "Case KEUI-similarThreads"
                    data = deserial_test.deserial_keui(
                        'similarThreads',
                        'templates/events/KEUI-similarThreads.xml')

                elif (query['issue_option'] == 'ext'):
                    # Case of presented extended info about issue
                    # To: Metadata service
                    print "Case issue.getInfo"
                    data = deserial_test.deserial_metadata(
                        'issue.getInfo',
                        'templates/events/metadata-issue.getInfo.xml')

            else:
                return HttpResponse(
                    "You must select an issue option for this particular ID.")

        elif 'product' in query and query['product'] != '':
            # Case of getting all issues for a product
            # To: Metadata service
            print "Case issue.getAllForProduct"
            data = deserial_test.deserial_metadata(
                'issue.getAllForProduct',
                'templates/events/metadata-issue.getAllForProduct.xml')

        elif 'method_uri' in query and query['method_uri'] != '':
            # Case of getting all issues for a method
            # To: Metadata service
            print "Case issue.getAllForMethod"
            data = deserial_test.deserial_metadata(
                'issue.getAllForMethod',
                'templates/events/metadata-issue.getAllForMethod.xml')

        elif 'keywords' in query and query['keywords'] != '':
            # Case of issues related to keywords
            # To: KEUI
            print "Case KEUI-keywords"
            data = deserial_test.deserial_keui(
                'issuesForKeywords', 'templates/events/KEUI-keywords.xml')

        elif 'developer' in query and query['developer'] != '':
            # Case of suggest issues for a developer
            # To: Recommendation service
            print "Case Recommender.issuesRecommended"
            data = deserial_test.deserial_recommendation(
                'issue.Recommendation',
                'templates/events/recommender-issuesRecommended.xml')

        else:
            # Error: there must be one option selected
            return HttpResponse("Unsupported query petition.</br>"+\
                "You must provide at least a commit_id, issue_id, "+\
                "list of keywords (separated by blank spaces) "+\
                "or developer name for searching.")

        return HttpResponse(json.dumps(data), mimetype="application/json")
Exemplo n.º 6
0
def query_handler(request):
    """
    Entry method to handle incoming search queries for hound service.
    Query fields come embedded in request search arguments.
    """
    
    if request.method == 'GET':
        
        query = request.GET
        print "kk"
        
        html = "The query items: </br>"

        json_project = ""
        json_issue_id = ""
        json_issue_option = ""
        json_keywords = ""
        json_data = ""
        json_suggested = ""
        json_happening = ""

        print "kk2"
	if 'project' in request.GET:
            json_project = str(query.get('project'))
        
        if 'issue_id' in request.GET:
            json_issue_id = str(query.get('issue_id'))

	if 'issue_option' in request.GET:
            json_issue_option = str(query.get('issue_option'))
            
        if 'keywords' in request.GET:
            json_keywords = str(query.get('keywords'))

        if 'suggested' in request.GET:
            json_suggested = str(query.get('suggested'))

        if 'happening' in request.GET:
            json_happening = str(query.get('hapenning'))

        print "kk3"

        data = []

        print("issue_id = %s" % (query['issue_id'],))
        print "kk4"

        if query['suggested'] == 'sug':
            print "** SUGGESTED USE CASE**"   # to be deleted
            #ALERT.Search.APICallRequest (issue.getOpen) Search service -> Metadata service
            #ALERT.Metadata.APICallResponse (issue.getOpen) Metadata service ->	Search service
            #ALERT.Search.Recommender.RecommendationRequest Search service -> Recommender
            #ALERT.Recommender.IdentityRecommendation Recommender -> Search service

            ec = EventComposer()

            params_issue_get_open = {"apiCall": "issue.getOpen",
                                     "name": "productID",
                                     "value": query['project']}
            get_open_msg = ec.serial_metadata(None,
                                              params_issue_get_open,
                                              False, True,
                                              EventComposer.topic_req_metadata)
            #print get_open_msg

            #bquery = BusQuery('tcp://www.cimcollege.rs:61616',
            
            ## bquery = BusQuery('tcp://laus.perimeter.fzi.de:61616',            
            ##                   EventComposer.topic_req_metadata,
            ##                   get_open_msg,
            ##                   'ALERT.Metadata.APICallResponse')
            ## try:
            ##     result = bquery.run()
            ##     print "Received: ALERT.Metadata.APICallResponse"
            ## except:
            ##     print "ERROR: ALERT.Metadata.APICallResponse is MIA"

            print "hola"

            ## print result
            ## aux = ec.deserial_metadata('issue.getOpen', StringIO(result))
            ## print aux
            ## aux_issues = ()
            ## cont = 0
            ### {'issue_id': '271749', 'issue_uri': 'http://www.alert-project.eu/ontologies/alert_its.owl#Bug870', 'issue_url': 'https://bugs.kde.org/show_bug.cgi?id=271749', 'desc': 'Malformed URL error dragging and dropping a file to a usb drive'}]}
            ## for i in aux['issues']:
            ##     aux_issues = aux_issues + ((i['issue_id'], i['issue_uri']),)
            ##     cont = cont + 1
            ##     if (cont == 10):
            ##         break

            ## print("%s opened issues" % (str(cont),))

            ## ### params_devs_recommend = {"issues": aux_issues}
            ## params_devs_recommend = {"issues": ( (291250,"owl#1"), 
            ##                                      (290735, "owl#2"),) }
                        
            ## to_reco_msg = ec.serial_recommendation(ec.header_devs_recomm,
            ##                                        params_devs_recommend,
            ##                                        False, True,
            ##                                        ec.topic_req_devs_recomm)

            ## # comment out as soon as Fotis starts its component
            ## print to_reco_msg
                
            ## # bquery = BusQuery('tcp://www.cimcollege.rs:61616',"""
            ## bquery = BusQuery('tcp://laus.perimeter.fzi.de:61616',
            ##                   ec.topic_req_issues_recomm,
            ##                   to_reco_msg,
            ##                   'ALERT.Recommender.IdentityRecommendation')
            ## try:
            ##     result = bquery.run()
            ##     print "Received: ALERT.Recommender.IdentityRecommendation"
            ## except:
            ##     print "ERROR: ALERT.Recommender.IdentityRecommendation is MIA"
            

            #print result

            # comment out this as soon as the metadata and recommendation components are started
            suggested_devs = ec.deserial_recommendation('identity.Recommendation',
                                                        'socrates-identity-recomm-test.xml')

            suggested_devs['devs']['2050'].append("Notify user on hardware changes")
            suggested_devs['devs']['2050'].append("https://bugs.kde.org/show_bug.cgi?id=184671")

            suggested_devs['devs']['274'].append("Cant open window Power Management")
            suggested_devs['devs']['274'].append("https://bugs.kde.org/show_bug.cgi?id=177772")

            print suggested_devs
            
            data = suggested_devs

            #print suggested_devs

        elif query['issue_id']:
            print "** EXTENDED VIEW USE CASE**"   # to be deleted
            #ALERT.Search.APICallRequest (issue.getInfo) Search service -> Metadata service
            #ALERT.Metadata.APICallResponse (issue.getInfo) Metadata service ->	Search service

            ec = EventComposer()

            ## params_issue_get_info = {"apiCall": "issue.getInfo",
            ##                          "name": "issueID",
            ##                          "value": query['issue_id']}    
            ## get_info_msg = ec.serial_metadata(None,
            ##                                   params_issue_get_info,
            ##                                   False, True,
            ##                                   EventComposer.topic_req_metadata)
            ## print get_info_msg
            ## #bquery = BusQuery('tcp://laus.perimeter.fzi.de:61616',
            ## bquery = BusQuery('tcp://www.cimcollege.rs:61616',
            ##                   ec.topic_req_metadata,
            ##                   get_info_msg,
            ##                   'ALERT.Metadata.APICallResponse')            

            ## result = bquery.run()

            ## print("Received: ALERT.Metadata.APICallResponse")

            ## print result

            ## aux = ec.deserial_metadata('issue.getInfo', StringIO(result))

            print "hola"
            aux = ec.deserial_metadata('issue.getInfo','metadata-issue.getInfo.xml')
            print "adios"
            print aux

            data = aux

        elif query['happening'] == 'happening':
            print("METHOD NOT IMPLEMENTED")
            # TO BE DONE

        elif query['issue_option'] == 'rel':
            print "** RELATED ISSUES USE CASE**"   # to be deleted
            #Alert.Search.KEUIRequest 	Search service -> KEUI
            #ALERT.KEUI.Response 	KEUI ->	Search service
            # to be done
        else:
            print "** KEYWORDS USE CASE**"
            # TO BE DONE


        try:
            resjson = json.dumps(data)
        except:
            print "Unexpected error:", sys.exc_info()[0]

        resjson = query.get('jsoncall') + "(" + resjson + ")"

        print("JSON to be sent back: %s" % (resjson,))


        return HttpResponse(resjson)