Exemple #1
0
    def get_queryset(self):

        queryset = Program.objects.all()

        return search_get_qparams(self, queryset,
                                  [('programName', 'programName'),
                                   ('abbreviation', 'abbreviation')])
Exemple #2
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = StudyObsUnit.objects.all()
        queryset = search_get_qparams(
            self, queryset,
            [('observationVariableDbIds', 'observationVariableDbIds')])

        return paginate(queryset, request, StudyObsUnitSerializer)
Exemple #3
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = Location.objects.all()

        queryset = search_get_qparams(self, queryset,
                                      [('locationType', 'locationType')])

        return paginate(queryset, request, LocationSerializer)
Exemple #4
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = Marker.objects.all()

        # name, matchMethod, include
        # possible values are 'case_insensitive', 'exact' (case sensitive), 'wildcard' (which is case insensitive). Wildcard uses both '*' and '%' for any number of characters and '?' for one character matching. Default is exact.
        # Whether to include synonyms in the output.
        name = self.request.query_params.get('name', None)
        match_method = self.request.query_params.get('matchMethod', None)
        include = self.request.query_params.get('include', None)

        synonyms = include is not None and include == 'synonyms'

        logger = logging.getLogger(__name__)
        logger.warn("FILTERING: %s, method=%s, synonyms=%s" %
                    (name, match_method, synonyms))

        if name is not None:
            if match_method is not None:
                if match_method == 'case_insensitive':
                    if synonyms:
                        queryset = queryset.filter(
                            Q(defaultDisplaydefaultDisplayName__iexact=name)
                            | Q(synonyms__iexact=name))
                    else:
                        queryset = queryset.filter(
                            defaultDisplayName__iexact=name)
                    # end if
                elif match_method == 'wildcard':
                    # TODO: add prefixes and suffixes
                    name = name.replace('*', '')
                    name = name.replace('%', '')
                    if synonyms:
                        queryset = queryset.filter(
                            Q(defaultDisplayName__icontains=name)
                            | Q(synonyms__contains=name))
                    else:
                        queryset = queryset.filter(
                            defaultDisplayName__icontains=name)
                    # end if
                # end if
            else:  # exact
                if synonyms:
                    queryset = queryset.filter(
                        Q(defaultDisplayName=name) | Q(synonyms=name))
                else:
                    queryset = queryset.filter(defaultDisplayName=name)
                # end if
            # end if
        # end if

        queryset = search_get_qparams(self, queryset, [('type', 'type')])

        return paginate(queryset, request, MarkerSerializer)
Exemple #5
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = AlleleMSearch.objects.all()

        # TODO: it is not clear to which data the query parameters apply!
        # unknownString=&sepPhased=&sepUnphased=&expandHomozygotes=
        queryset = search_get_qparams(
            self, queryset, [('markerprofileDbId', 'markerprofileDbId'),
                             ('markerDbId', 'markerDbId')])

        return paginate(queryset, request, AlleleMSearchSerializer,
                        BrAPIListPagination)
Exemple #6
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = Germplasm.objects.all()

        logger = logging.getLogger(__name__)
        logger.warn("Searching with parameters %s" % self.request.query_params)

        queryset = search_get_qparams(self, queryset,
                                      [('germplasmName', 'germplasmName'),
                                       ('germplasmDbId', 'germplasmDbId'),
                                       ('germplasmPUI', 'germplasmPUI')])

        return paginate(queryset, request, GermplasmSerializer)
Exemple #7
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = Study.objects.all()

        queryset = search_get_qparams(
            self, queryset,
            [('studyType', 'studyType'), ('seasonDbId', 'seasonDbId'),
             ('locationDbId', 'locationDbId'), ('programDbId', 'programDbId'),
             ('germplasmDbId', 'germplasmDbIds'),
             ('observationVariableDbId', 'observationVariableDbIds'),
             ('active', 'active')])

        return paginate(queryset, request, StudySerializer)
Exemple #8
0
    def get(self, request, format=None, *args, **kwargs):

        logger = logging.getLogger(__name__)

        mapDbId = self.kwargs['mapDbId']
        queryset = MapLinkage.objects.all()

        linkageGroupId = self.request.query_params.get('linkageGroupId', None)
        logger.warn("Linkages: (%s, %s)" % (mapDbId, linkageGroupId))

        queryset = search_get_qparams(self, queryset, [('mapDbId', 'mapDbId'), ('linkageGroupId', 'linkageGroupId')])

        return paginate(queryset, request, MapLinkageSerializer)
Exemple #9
0
    def get(self, request, format=None, *args, **kwargs):

        logger = logging.getLogger(__name__)
        logger.warn("Searching with parameters %s" % self.request.query_params)

        queryset = MarkerProfile.objects.all()

        queryset = search_get_qparams(self, queryset,
                                      [('germplasmDbId', 'germplasm'),
                                       ('studyDbId', 'studyDbId'),
                                       ('sampleDbId', 'sample'),
                                       ('extractDbId', 'extract'),
                                       ('analysisMethod', 'method')])

        return paginate(queryset, request, MarkerProfileSerializer)
Exemple #10
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = Trial.objects.all()
        queryset = search_get_qparams(self, queryset,
                                      [('programDbId', 'programDbId'),
                                       ('locationDbId', 'locationDbId'),
                                       ('active', 'active')])

        sortBy = self.request.query_params.get('sortBy', None)
        sortOrder = self.request.query_params.get('sortOrder', None)

        if sortBy is not None:
            if sortOrder is not None and sortOrder == 'Ascending':
                queryset = queryset.order_by(sortBy)
            elif sortOrder is not None and sortOrder == 'Descending':
                queryset = queryset.order_by('-' + sortBy)
            # end if
        # end if

        return paginate(queryset, request, TrialSerializer)
Exemple #11
0
    def get_queryset(self):

        queryset = StudySeason.objects.all()

        return search_get_qparams(self, queryset, [('year', 'year')])
Exemple #12
0
    def get_queryset(self):

        queryset = AlleleMatrix.objects.all()

        return search_get_qparams(self, queryset, [('studyDbId', 'studyDbId')])
Exemple #13
0
    def get(self, request, format=None, *args, **kwargs):

        queryset = Map.objects.all()
        queryset = search_get_qparams(self, queryset, [('type', 'type'), ('species', 'species')])

        return paginate(queryset, request, MapSerializer)