Exemplo n.º 1
0
  @Override
  public boolean createOrUpdateService(
      String electronicShopID, String serviceID, String description) {

    // check if we know that shop
    if (!ConfigurationProperties.getElectronicShopID().equals(electronicShopID)) {
      logger.warning("electronicShopID \"" + electronicShopID + "\" not known!");
      return false;
    }

    List<Service> sl = Service.queryGetByForeignID(serviceID, 0, 1);
    Service s;
    if (sl.size() == 0) {
      s = new Service();
    } else {
      s = sl.get(0);
    }
    try {
      s.setForeignID(serviceID);
      s.setDescription(description);
      s.setPriceHour(0); // <--- отначало цената е 0 което означава, че не се извършва засега !!!
      s.writeToDB();
    } catch (RuntimeException e) {
      logger.log(Level.WARNING, "Can't write to DB!", e);
      return false;
    }

    return true;
  }
Exemplo n.º 2
0
  @Override
  public boolean createOrUpdateVehicleModelService(
      String electronicShopID,
      String vehicleModelID,
      String serviceID,
      double durationHour,
      long monthsToNext,
      long milageToNext) {

    // check if we know that shop
    if (!ConfigurationProperties.getElectronicShopID().equals(electronicShopID)) {
      logger.warning("electronicShopID \"" + electronicShopID + "\" not known!");
      return false;
    }

    VehicleModelService vms = new VehicleModelService();
    try {
      List<VehicleModel> vehicleModel = VehicleModel.queryGetByForeignID(vehicleModelID, 0, 1);
      if (vehicleModel.size() == 0) {
        logger.warning("vehicleModelID \"" + vehicleModelID + "\" not known!");
        return false;
      }

      List<Service> service = Service.queryGetByForeignID(serviceID, 0, 1);
      if (service.size() == 0) {
        logger.warning("serviceID \"" + serviceID + "\" not known!");
        return false;
      }

      List<VehicleModelService> vmsl =
          VehicleModelService.queryGetByService(
              service.get(0).getID(), 0, 1, vehicleModel.get(0).getID());
      if (vmsl.size() == 1) {
        vms = vmsl.get(0);
      }

      vms.setVehicleModelID(vehicleModel.get(0).getID());
      vms.setServiceID(service.get(0).getID());
      vms.setDurationHour(durationHour);
      vms.setMonthsToNext(monthsToNext);
      vms.setMilageToNext(milageToNext);
      vms.writeToDB();
    } catch (RuntimeException e) {
      logger.log(Level.WARNING, "Can't write to DB!", e);
      return false;
    }

    return true;
  }