Example #1
0
 def removeSample(self, id):
     sample = Sample.findSampleById(id)
     if sample:
         sample.delete()
         return {
             "message": "The sample with id '{}' is deleted!".format(id)
         }
     else:
         return "The sample does not exist!"
Example #2
0
    def addSample(self, id):
        data = SampleService.parser.parse_args()
        sample = Sample.findSampleById(id)

        if sample:
            return "Sample already exists!"
        else:
            sample = Sample(data["id"], data["date"], data["quality"],
                            data["x_coor"], data["y_coor"], data["date_added"],
                            data["location_id"], data["owner_id"],
                            data["taxon_values"])
            sample.save()
            return sample.json()
Example #3
0
    def updateSample(self, id):
        data = SampleService.parser.parse_args()
        sample = Sample.findSampleById(id)

        if sample:
            sample.date = data["date"]
            sample.quality = data["quality"]
            sample.x_coor = data["x_coor"]
            sample.y_coor = data["y_coor"]
            sample.date_added = data["date_added"]
            sample.location_id = data["location_id"]
            sample.owner_id = data["owner_id"]
            sample.taxon_values = data["taxon_values"]
        else:
            sample = Sample(data["id"], data["date"], data["quality"],
                            data["x_coor"], data["y_coor"], data["date_added"],
                            data["location_id"], data["owner_id"],
                            data["taxon_values"])

        sample.save()
        return sample.json()
Example #4
0
 def getSample(self, id):
     sample = Sample.findSampleById(id)
     if sample:
         return sample.json(), 201
     return {"message": "The sample is not found!"}, 404