예제 #1
0
  @Before
  public void setUp()
      throws DateException, AddressException, PhoneException, CPFException, RGException,
          StudentException, ServiceException, PersonException, CourseException {

    date = new Date(05, 06, 1996);
    address = new Address("Rua 3 ", "6B", "", "72323411", "Brasília");
    phone1 = new Phone("61", "83265622");
    phone2 = new Phone("61", "32551111");
    cpf = new CPF("51464638403");
    rg = new RG("8598298", "SSP", "DF");
    email = "*****@*****.**";

    student =
        new Student(
            "Jacó Mário Souza",
            cpf,
            rg,
            date,
            email,
            address,
            phone1,
            phone2,
            "Milene Souza Medeiros",
            "Mário Souza Filho",
            1);

    courses.add(0, "1");
    courses.add(1, "2");
    packages.add(0, "7");

    service = new Service(student);
    service.addItem(new Course("Instalação de porta", "Instalar portas.", 5, 100000));
  }
예제 #2
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;
  }
예제 #3
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;
  }