Esempio n. 1
0
def get_results(**kwargs):
    ids = None
    uuids = None
    if kwargs.get('resultID'):
        ids = [int(i) for i in kwargs.get('resultID').split(',')]
    if kwargs.get('resultUUID'):
        uuids = kwargs.get('resultUUID').split(',')
    result_type = kwargs.get('resultType')
    act_id = kwargs.get('actionID')
    sf_id = kwargs.get('samplingFeatureID')
    site_id = kwargs.get('siteID')
    var_id = kwargs.get('variableID')
    sim_id = kwargs.get('simulationID')

    Results = READ.getResults(ids=ids,
                              type=result_type,
                              uuids=uuids,
                              actionid=act_id,
                              simulationid=sim_id,
                              sfid=sf_id,
                              variableid=var_id,
                              siteid=site_id)

    Results_list = []
    for res in Results:
        Serializer = ResultSerializer(result_creator(res))
        if res.FeatureActionObj.SamplingFeatureObj.SamplingFeatureTypeCV == 'Specimen':
            Serializer.fields['FeatureAction'].fields[
                'SamplingFeature'] = SpecimensSerializer()
        if res.FeatureActionObj.SamplingFeatureObj.SamplingFeatureTypeCV == 'Site':
            Serializer.fields['FeatureAction'].fields[
                'SamplingFeature'] = SitesSerializer()
        Results_list.append(Serializer.data)

    return Results_list
Esempio n. 2
0
def get_samplingfeaturedatasets(**kwargs):
    ids = None
    codes = None
    uuids = None
    if kwargs.get('samplingFeatureID'):
        ids = [int(i) for i in kwargs.get('samplingFeatureID').split(',')]
    if kwargs.get('samplingFeatureUUID'):
        uuids = kwargs.get('samplingFeatureUUID').split(',')
    if kwargs.get('samplingFeatureCode'):
        codes = kwargs.get('samplingFeatureCode').split(',')

    sf_type = kwargs.get('samplingFeatureType')

    ds_type = kwargs.get('dataSetType')

    dataSetResults = READ.getSamplingFeatureDatasets(ids=ids,
                                                     codes=codes,
                                                     uuids=uuids,
                                                     dstype=ds_type,
                                                     sftype=sf_type)

    dsr_list = []
    for dsr in dataSetResults:
        SFDSerializer = SamplingFeatureDatasetSerializer(
            samplingfeaturedatasets_creator(dsr))
        if dsr.SamplingFeatureTypeCV == 'Specimen':
            SFDSerializer = SpecimensDatasetSerializer(
                samplingfeaturedatasets_creator(dsr))
            SFDSerializer.fields['Datasets'].child.fields[
                'Results'].child.fields['FeatureAction'].fields[
                    'SamplingFeature'] = SpecimensSerializer()  # noqa
            if dsr.related_features.SamplingFeatureTypeCV == 'Site':
                SFDSerializer.fields['related_features'] = SitesSerializer()
        if dsr.SamplingFeatureTypeCV == 'Site':
            SFDSerializer = SitesDatasetSerializer(
                samplingfeaturedatasets_creator(dsr))
            SFDSerializer.fields['Datasets'].child.fields[
                'Results'].child.fields['FeatureAction'].fields[
                    'SamplingFeature'] = SitesSerializer()  # noqa
        dsr_list.append(SFDSerializer.data)

    return dsr_list
Esempio n. 3
0
def get_datasetresults(**kwargs):
    db_check()
    ids = kwargs.get('datasetID')
    codes = kwargs.get('datasetCode')
    uuids = kwargs.get('datasetUUID')
    if ids:
        ids = [int(i) for i in kwargs.get('datasetID').split(',')]
    if uuids:
        uuids = kwargs.get('datasetUUID').split(',')
    if codes:
        codes = kwargs.get('datasetCode').split(',')

    ds_type = kwargs.get('datasetType')

    dataSetResults = READ.getDataSetsResults(ids=ids,
                                             codes=codes,
                                             uuids=uuids,
                                             dstype=ds_type)

    dsr_list = []
    for dsr in dataSetResults:
        dsr_dct = get_vals(dsr)

        ds_dct = get_vals(dsr.DataSetObj)

        res_dct = result_creator(dsr.ResultObj)

        dsr_dct.update({'Result': res_dct, 'DataSet': ds_dct})

        Serializer = DataSetsResultsSerializer(dsr_dct)
        if dsr.ResultObj.FeatureActionObj.SamplingFeatureObj.SamplingFeatureTypeCV == 'Specimen':
            Serializer.fields['Result'].fields['FeatureAction'].fields[
                'SamplingFeature'] = SpecimensSerializer()
        if dsr.ResultObj.FeatureActionObj.SamplingFeatureObj.SamplingFeatureTypeCV == 'Site':
            Serializer.fields['Result'].fields['FeatureAction'].fields[
                'SamplingFeature'] = SitesSerializer()

        dsr_list.append(Serializer.data)

    return dsr_list
Esempio n. 4
0
def get_samplingfeatures(**kwargs):
    db_check()
    ids = None
    codes = None
    uuids = None
    if kwargs.get('samplingFeatureID'):
        ids = [int(i) for i in kwargs.get('samplingFeatureID').split(',')]
    if kwargs.get('samplingFeatureUUID'):
        uuids = kwargs.get('samplingFeatureUUID').split(',')
    if kwargs.get('samplingFeatureCode'):
        codes = kwargs.get('samplingFeatureCode').split(',')

    sf_type = kwargs.get('samplingFeatureType')
    res = kwargs.get('results')

    if type(res) in [str, unicode]:
        if res.upper() == 'TRUE':
            res = True
        else:
            res = False

    sampling_features = READ.getSamplingFeatures(ids=ids,
                                                 codes=codes,
                                                 uuids=uuids,
                                                 type=sf_type,
                                                 wkt=None,
                                                 results=res)

    sf_list = []
    for sf in sampling_features:
        sf_dct = get_vals(sf)
        serialized = SamplingFeatureSerializer(sf_dct).data
        if sf.SamplingFeatureTypeCV == 'Site':
            serialized = SitesSerializer(sf_dct).data
        if sf.SamplingFeatureTypeCV == 'Specimen':
            serialized = SpecimensSerializer(sf_dct).data

        sf_list.append(serialized)

    return sf_list