clearwing

changeset 233:2f3122efdcb9 tip

Fixing issues with region and SQL query tools
author Stelios <stv@roe.ac.uk>
date Tue Sep 04 03:30:04 2018 +0300 (2018-09-04)
parents 307ebe3e1bfe
children
files src/config-sample.py src/freeform_sql/misc.py src/static/static_vo_tool/js/freeformJS.js src/url_classes/data_tables_processing.py src/url_classes/dbaccess_region_form.py src/url_classes/helper_urls.py
line diff
     1.1 --- a/src/config-sample.py	Tue Sep 04 00:33:16 2018 +0300
     1.2 +++ b/src/config-sample.py	Tue Sep 04 03:30:04 2018 +0300
     1.3 @@ -117,6 +117,8 @@
     1.4  database_imageList = SURVEY_DB
     1.5  
     1.6  db_to_tap_map = {SURVEY_DB :SURVEY_TAP, '###' :'####'}
     1.7 +db_to_resource_map = {'###' :'####'}
     1.8 +
     1.9  taps_using_binary = ["http://dc.zah.uni-heidelberg.de"]
    1.10  
    1.11  firethorn_admin_username=""
     2.1 --- a/src/freeform_sql/misc.py	Tue Sep 04 00:33:16 2018 +0300
     2.2 +++ b/src/freeform_sql/misc.py	Tue Sep 04 03:30:04 2018 +0300
     2.3 @@ -692,8 +692,10 @@
     2.4          urlenc = { firethorn_config.query_name_param : query_name,  firethorn_config.query_param : query, firethorn_config.query_status_update : "COMPLETED"}
     2.5          data = urllib.urlencode(urlenc)
     2.6  
     2.7 -
     2.8 -        request = urllib2.Request(json.loads(read_json(query_space))["parent"] + firethorn_config.query_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
     2.9 +        if ("/schema/" in query_space):
    2.10 +            request = urllib2.Request(json.loads(read_json(query_space))["parent"] + firethorn_config.query_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})        
    2.11 +        else :
    2.12 +            request = urllib2.Request(query_space + firethorn_config.query_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    2.13  
    2.14          f = urllib2.urlopen(request)
    2.15          query_create_result = json.loads(f.read())
    2.16 @@ -795,6 +797,11 @@
    2.17  
    2.18      elif votable!='' and votable!= None:
    2.19          if len(votable)>0:
    2.20 +
    2.21 +            if (tap_endpoint.lower().startswith("http")):
    2.22 +                tap_endpoint=get_info(query_results_id)["results"]["table"]
    2.23 +                tap_endpoint=get_parent_workspace(get_parent_workspace(tap_endpoint))
    2.24 +
    2.25              if tap_endpoint!="" and query!="":
    2.26                  content = '<form class="launch_viewer" style="float:left;z-index:100;position: relative;" action="' + survey_prefix + '/viewer" method="post" target="_blank"><input type="hidden" name="query" value="'+ string_functions.encode(query) +'"/><input type="hidden" name="cols" value="'+ html_functions.escape(json.dumps(cols)) +'"/><input type="hidden" name="filepath" id="temp_file" value="'+ pathname +'"/><input type="hidden" name="tap_endpoint" value="'+ tap_endpoint +'"/>'
    2.27                  content += '<input type="hidden" name="adql_table" id="adql_table" value="'+ adql_table +'"/>'
    2.28 @@ -955,9 +962,7 @@
    2.29      
    2.30      @return: Return a votable with the results, the TAP job ID and a temporary file path with the results stored on the server
    2.31      """    
    2.32 -
    2.33      params = urllib.urlencode({'REQUEST': request, 'LANG': lang, 'FORMAT': result_format, 'QUERY' : q}) 
    2.34 -    full_url = url+mode_local
    2.35  
    2.36      votable = ''
    2.37      jobId= 'None'
    2.38 @@ -971,8 +976,6 @@
    2.39          return query_json   
    2.40  
    2.41      try:
    2.42 -        url="http://gillian:8080/firethorn/adql/schema/579/"
    2.43 -
    2.44          # Return results as a votable object
    2.45          votable, adql_table, query_loop_results = run_query(q,"",query_space=url)   
    2.46          jobId=adql_table
    2.47 @@ -1282,4 +1285,4 @@
    2.48      response = urllib2.urlopen(req)
    2.49      info = json.loads(response.read())
    2.50      response.close()
    2.51 -    return info
    2.52 \ No newline at end of file
    2.53 +    return info
     3.1 --- a/src/static/static_vo_tool/js/freeformJS.js	Tue Sep 04 00:33:16 2018 +0300
     3.2 +++ b/src/static/static_vo_tool/js/freeformJS.js	Tue Sep 04 03:30:04 2018 +0300
     3.3 @@ -102,6 +102,7 @@
     3.4         		jQuery(content_div ).on('click','#loadvotable', function(e){ 
     3.5         		
     3.6         				var temp_stored_url = fnSaveAsGetURL('vo', oTable, pathname_divId, base_url);
     3.7 +
     3.8         				var xhr = jQuery.ajax({
     3.9  	        	       type: "POST",
    3.10  	        	       data: {_broadcast_url : temp_stored_url, _action : "save_as_temp_file"},
     4.1 --- a/src/url_classes/data_tables_processing.py	Tue Sep 04 00:33:16 2018 +0300
     4.2 +++ b/src/url_classes/data_tables_processing.py	Tue Sep 04 03:30:04 2018 +0300
     4.3 @@ -1036,7 +1036,7 @@
     4.4                  queryvotable = query_json["results"]["formats"]["votable"]
     4.5  
     4.6                  web.header('Content-disposition', 'attachment; filename=download.xml')
     4.7 -                req = urllib2.Request( queryvotable, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password} )
     4.8 +                req = urllib2.Request( queryvotable)
     4.9                  response = urllib2.urlopen(req)
    4.10                  return_votable = response.read()  
    4.11                  response.close()
     5.1 --- a/src/url_classes/dbaccess_region_form.py	Tue Sep 04 00:33:16 2018 +0300
     5.2 +++ b/src/url_classes/dbaccess_region_form.py	Tue Sep 04 03:30:04 2018 +0300
     5.3 @@ -4,7 +4,7 @@
     5.4  @author: stelios
     5.5  '''
     5.6  from app import session
     5.7 -from config import render, SURVEY_TAP, mode_global, SURVEY_TAP_TITLE, survey_prefix, no_users,db_to_tap_map
     5.8 +from config import render, SURVEY_TAP, mode_global, SURVEY_TAP_TITLE, survey_prefix, no_users,db_to_resource_map
     5.9  import freeform_sql
    5.10  import survey_globals
    5.11  import web
    5.12 @@ -63,7 +63,7 @@
    5.13                  else:
    5.14                      from_table=data.database + ".atlasDetection"
    5.15  
    5.16 -            database = db_to_tap_map[data.database]
    5.17 +            database = db_to_resource_map[data.database]
    5.18              programmeID = data.programmeID
    5.19              co_sys = survey_globals.coord_systems[getattr(data,survey_globals.region_sys)]
    5.20              radius = data.radius
    5.21 @@ -191,3 +191,4 @@
    5.22          
    5.23              if error:
    5.24                  return "<div class='error'>" + error + "</div>"
    5.25 +
     6.1 --- a/src/url_classes/helper_urls.py	Tue Sep 04 00:33:16 2018 +0300
     6.2 +++ b/src/url_classes/helper_urls.py	Tue Sep 04 03:30:04 2018 +0300
     6.3 @@ -150,7 +150,7 @@
     6.4          """
     6.5          from helper_functions import MultipartPostHandler
     6.6          web.header('Content-Type', 'text/html')
     6.7 -        data = web.input(href="", params="", action="", uploadFile="", file1="")
     6.8 +        data = web.input(href="", params="", action="", uploadFile="", file1="", programmeID="170")
     6.9          return_str = ''
    6.10          f = ''
    6.11          temp_URL = ''