Example #1
0
    def verifyStrainExistanceDesignationFkSpecie(designation: str,
                                                 fk_specie: int):
        """
        Verify if a strain already exists given its designation and fk_specie

        :param designation: designation of the strain
        :param fk_specie: fk of the specie

        :type designation: string
        :type fk_specie: integer

        :return: None or a strain if exists
        :rtype: StrainJ
        """

        designation = urllib.parse.quote(designation)
        strain_obj = StrainAPI().getByDesignationFkSpecie(
            designation, fk_specie)
        print(strain_obj['strain_exists'])
        if strain_obj['strain_exists'] == True:
            schema = StrainSchema(only=['designation', 'specie', 'id'])
            results = schema.load(strain_obj, many=False)
            return results[0]
        else:
            return None
Example #2
0
    def getAllAPI():
        """
        get all the strains on the database

        :return: list of Strain
        :rtype: vector[StrainJ]
        """
        list_strain = StrainAPI().get_all()
        schema = StrainSchema()
        results = schema.load(list_strain, many=True)
        return results
Example #3
0
    def setStrain(self):
        """
        set new strain

        :return: new strain completed with the id
        :rtype: StrainJ
        """
        schema = StrainSchema(only=['designation', 'specie'])
        jsonFam = schema.dump(self)
        resultsCreation = StrainAPI().set_strain(jsonData=jsonFam.data)
        schema = StrainSchema()
        results = schema.load(resultsCreation)
        return results[0]
Example #4
0
    def getByID(id_strain: int):
        """
        get a strain given its id

        :param id_strain: id of the strain that it will be returned

        :type id_strain: int

        :return: a json of the strain 
        :rtype: StrainJson
        """
        strain = StrainAPI().get_by_id(id_strain)
        schema = StrainSchema()
        results = schema.load(strain, many=False)
        return results