Ejemplo n.º 1
0
 def searchResources(self, args):
     resourcename = args.get("resourcename")
     supplierid = args.get("supplierid")
     attributename = args.get("attributename")
     dao = ResourcesDAO()
     resources_list = []
     if (len(args) == 2) and resourcename and supplierid:
         resources_list = dao.getResourcesByNameAndSupplier(resourcename, supplierid)
     elif (len(args) == 1) and resourcename:
         resources_list = dao.getResourcesByName(resourcename)
     elif (len(args) == 1) and supplierid:
         resources_list = dao.getResourcesBySupplier(supplierid)
     elif (len(args) == 1) and attributename:
         resources_list = dao.getResourcesByAttributeName(attributename)
     else:
         return jsonify(Error="Malformed query string"), 400
     result_list = []
     for row in resources_list:
         result = self.build_resource_dict(row)
         result_list.append(result)
     return jsonify(Resources=result_list)
Ejemplo n.º 2
0
 def searchResources(self, args):
     rid = args.get('rid')
     rname = args.get('rname')
     rtype = args.get('rtype')
     rprice = args.get('rprice')
     rlocation = args.get('rlocation')
     rstock = args.get('rstock')
     dao = ResourcesDAO()
     resources_list = []
     if (len(args)
             == 5) and rname and rtype and rprice and rstock and rlocation:
         resources_list = dao.getResourcesByNameandTypeandPriceandStockandLocation(
             rname, rtype, rprice, rstock, rlocation)
     if (len(args) == 4) and rname and rtype and rprice and rstock:
         resources_list = dao.getResourcesByNameandTypeandPriceandStock(
             rname, rtype, rprice, rstock)
     if (len(args) == 4) and rname and rtype and rprice and rlocation:
         resources_list = dao.getResourcesByNameandTypeandPriceandLocation(
             rname, rtype, rprice, rlocation)
     if (len(args) == 4) and rname and rtype and rstock and rlocation:
         resources_list = dao.getResourcesByNameandTypeandStockandLocation(
             rname, rtype, rstock, rlocation)
     if (len(args) == 4) and rname and rprice and rstock and rlocation:
         resources_list = dao.getResourcesByNameandPriceandStockandLocation(
             rname, rprice, rstock, rlocation)
     if (len(args) == 4) and rtype and rprice and rstock and rlocation:
         resources_list = dao.getResourcesByTypeandPriceandStockandLocation(
             rtype, rprice, rstock, rlocation)
     if (len(args) == 3) and rname and rtype and rprice:
         resources_list = dao.getResourcesByNameandTypeandPrice(
             rname, rtype, rprice)
     if (len(args) == 3) and rname and rtype and rstock:
         resources_list = dao.getResourcesByNameandTypeandStock(
             rname, rtype, rstock)
     if (len(args) == 3) and rname and rtype and rlocation:
         resources_list = dao.getResourcesByNameandTypeandLocation(
             rname, rtype, rlocation)
     if (len(args) == 3) and rname and rprice and rstock:
         resources_list = dao.getResourcesByNameandPriceandStock(
             rname, rprice, rstock)
     if (len(args) == 3) and rname and rprice and rlocation:
         resources_list = dao.getResourcesByNameandPriceandLocation(
             rname, rprice, rlocation)
     if (len(args) == 3) and rname and rstock and rlocation:
         resources_list = dao.getResourcesByNameandStockandLocation(
             rname, rstock, rlocation)
     if (len(args) == 3) and rtype and rprice and rstock:
         resources_list = dao.getResourcesByTypeandPriceandStock(
             rtype, rprice, rstock)
     if (len(args) == 3) and rtype and rprice and rlocation:
         resources_list = dao.getResourcesByTypeandPriceandLocation(
             rtype, rprice, rlocation)
     if (len(args) == 3) and rtype and rstock and rlocation:
         resources_list = dao.getResourcesByTypeandStockandLocation(
             rtype, rstock, rlocation)
     if (len(args) == 3) and rprice and rstock and rlocation:
         resources_list = dao.getResourcesByPriceandStockandLocation(
             rprice, rstock, rlocation)
     if (len(args) == 2) and rname and rtype:
         resources_list = dao.getResourcesByNameandType(rname, rtype)
     if (len(args) == 2) and rname and rprice:
         resources_list = dao.getResourcesByNameandPrice(rname, rprice)
     if (len(args) == 2) and rname and rstock:
         resources_list = dao.getResourcesByNameandStock(rname, rstock)
     if (len(args) == 2) and rname and rlocation:
         resources_list = dao.getResourcesByNameandLocation(
             rname, rlocation)
     if (len(args) == 2) and rtype and rprice:
         resources_list = dao.getResourcesByTypeandPrice(rtype, rprice)
     if (len(args) == 2) and rtype and rstock:
         resources_list = dao.getResourcesByTypeandStock(rtype, rstock)
     if (len(args) == 2) and rtype and rlocation:
         resources_list = dao.getResourcesByTypeandLocation(
             rtype, rlocation)
     if (len(args) == 2) and rprice and rstock:
         resources_list = dao.getResourcesByPriceandStock(rprice, rstock)
     if (len(args) == 2) and rprice and rlocation:
         resources_list = dao.getResourcesByPriceandLocation(
             rprice, rlocation)
     if (len(args) == 2) and rstock and rlocation:
         resources_list = dao.getResourcesByStockandLocation(
             rstock, rlocation)
     if (len(args) == 1) and rname:
         resources_list = dao.getResourcesByName(rname)
     if (len(args) == 1) and rtype:
         resources_list = dao.getResourcesByType(rtype)
     if (len(args) == 1) and rprice:
         resources_list = dao.getResourcesByPrice(rprice)
     if (len(args) == 1) and rstock:
         resources_list = dao.getResourcesByStock(rstock)
     if (len(args) == 1) and rlocation:
         resources_list = dao.getResourcesByLocation(rlocation)
     else:
         return jsonify(Error="Malformed query string"), 400
     result_list = []
     for row in resources_list:
         result = self.build_resource_dict(row)
         result_list.append(result)
     return jsonify(Resources=result_list)