Beispiel #1
0
def action_embed(request, guid):
    """
    Show an embed microsite view
    """
    account = request.account
    preferences = request.preferences
    base_uri = 'http://' + preferences['account_domain']

    try:
        visualizationrevision_id = VisualizationRevision.objects.get_last_published_by_guid(guid)
        visualization_revision = VisualizationDBDAO().get(
            preferences['account_language'],
            visualization_revision_id=visualizationrevision_id
        )

        datastream = DataStreamDBDAO().get(
            preferences['account_language'],
            datastream_revision_id=visualization_revision["datastream_revision_id"]
        )
    except:
        return render_to_response('viewChart/embed404.html',{'settings': settings, 'request' : request})

    # VisualizationHitsDAO(visualization_revision.visualization).add(ChannelTypes.WEB)
    width = request.REQUEST.get('width', False) # TODO get default value from somewhere
    height = request.REQUEST.get('height', False) # TODO get default value from somewhere

    visualization_revision_parameters = RequestProcessor(request).get_arguments(visualization_revision["parameters"])
    visualization_revision_parameters['pId'] = visualization_revision["datastream_revision_id"]
    json, type = invoke(visualization_revision_parameters)
    visualization_revision_parameters = urllib.urlencode(visualization_revision_parameters)

    return render_to_response('viewChart/embed.html', locals())
Beispiel #2
0
def mint_process(mint_request):
    """
    process a datastream revision through a RDF template and insert it on bigdata server
    end_point is the URL to the RDF template
    """
    logger = _get_logger()

    # nice (?) way to use dot notation for dictionaries
    request = type('lamdbaobject', (object,), mint_request)()

    datastream = get_object_or_404(DataStream, guid=request.guid)

    # Obtain the namespace preference for this account.
    namespace = request.namespace
    if not namespace:
        namespace = Account.objects.get(pk=request.account_id).get_preference('account.bigdata.namespace')

    # If namespace was not defined, raise an exception.
    if not namespace:
        raise BigdataNamespaceNotDefined()

    datastreamrevision_id = DataStreamRevision.objects.get_last_published_id(datastream.id)

    query = datastream.get_query(datastreamrevision_id, request, is_turtle=0)
    contents, mimetype = engine.invoke(query)

    # read the template
    template = None
    if request.end_point:
        try:
            # get the ttl file
            template_file = urllib2.urlopen(request.end_point)
            if template_file:
                status_code = template_file.getcode()
                if status_code == 200:
                    template = template_file.read()
                else:
                    template_file.close()
                    raise MintTemplateURLError("Error reading template %s" % str(status_code))

                template_file.close()

        except Exception, e:
            logger.error(e)
            raise MintTemplateURLError("Unexpected error reading template. %s" % str(e))


        DataStreamRevision.objects.filter(pk = datastreamrevision_id).update(rdf_template = template)
Beispiel #3
0
    def data(self, request, guid=None, pk=None, format='json'):
        datastream = self.get_object()
        mutable_get = request.GET.copy()
        mutable_get['datastream_revision_id'] = datastream['datastream_revision_id']
        form = forms.RequestForm(mutable_get)
        if form.is_valid():
            query = RequestProcessor(request).get_arguments_no_validation()
            query['pId'] = form.cleaned_data.get('datastream_revision_id')
            limit = form.cleaned_data.get('limit')
            query['pLimit'] = limit or 50

            ivk = invoke(query)
            if ivk:
                datastream['result'] = json.loads(ivk[0])
                serializer = self.get_serializer(datastream)
        return Response(serializer.data)
Beispiel #4
0
def action_embed(request, guid):

    account     = request.account
    preferences = request.preferences
    base_uri = 'http://' + preferences['account_domain']

    try:
        visualizationrevision_id = VisualizationRevision.objects.get_last_published_by_guid(guid)
        visualization_revision = VZ(visualizationrevision_id, preferences['account_language'])
    except:
        return render_to_response('chart_manager/embed404.html',{'settings': settings, 'request' : request})

    VisualizationHitsDAO(visualization_revision.visualization).add(ChannelTypes.WEB)
    width     = request.REQUEST.get('width', False)
    height    = request.REQUEST.get('height', False)

    visualization_revision_parameters = RequestProcessor(request).get_arguments(visualization_revision.parameters)
    visualization_revision_parameters['pId'] = visualization_revision.datastreamrevision_id
    json, type = invoke(visualization_revision_parameters)
    visualization_revision_parameters = urllib.urlencode(visualization_revision_parameters)

    return render_to_response('chart_manager/embed.html', locals())
Beispiel #5
0
        raise Http404
    else:
        can_download = True
        can_export = True
        can_share = False
        
        VisualizationHitsDAO(visualization_revision.visualization).add(ChannelTypes.WEB)

        visualization_revision_parameters = RequestProcessor(request).get_arguments(visualization_revision.parameters) 
        
        chart_type = json.loads(visualization_revision.impl_details).get('format').get('type') 
        
        try:
            if chart_type != "mapchart":
                visualization_revision_parameters['pId'] = visualization_revision.datastreamrevision_id
                result, content_type = invoke(visualization_revision_parameters)
            else:
                join_intersected_clusters = request.GET.get('joinIntersectedClusters',"1")
#                visualization_revision_parameters['pId'] = visualization_revision.visualizationrevision_id
#                visualization_revision_parameters['pLimit'] = 1000
#                visualization_revision_parameters['pPage'] = 0                   
#                result, content_type = invoke_chart(visualization_revision_parameters)
        except:
            result = '{fType="ERROR"}'
            

        visualization_revision_parameters = urllib.urlencode(visualization_revision_parameters)
        
        return render_to_response('chart_manager/viewForm.html', locals())

@xframe_options_exempt