Exemplo n.º 1
0
  /*To remove an rcm under a particular rmos*/
  public Message removeRcm(int id) {
    RcmService rcmService = new RcmService();
    Rcm rcm;

    Message msg = new Message();
    msg.setSuccessful(true);

    rcm = rcmService.getRcmById(id);
    if (rcm == null) {
      msg.setSuccessful(false);
      msg.setMessage("Rcm Does not exist");
      return msg;
    }

    RmosRcmMapping mapping = repository.getMappingForRcm(this.rmos, rcm);
    if (mapping == null) {
      msg.setSuccessful(false);
      msg.setMessage("Rcm is Not Mapped to this Rmos");
      return msg;
    }

    mapping.setValid(false);
    mapping.getRcm().setStatus(RcmStatus.REMOVED);

    msg.setSuccessful(repository.updateRmos(this.rmos));
    if (!msg.isSuccessful()) msg.setMessage("Internal Error");
    else {
      this.rmos = repository.getRmosById(this.rmos.getId());
    }
    setChanged();
    notifyObservers();

    return msg;
  }
Exemplo n.º 2
0
  /*To add a rcm to a particular rmos*/
  public Message addRcm(String name, String location, double capacity, double cashValue) {
    LocationService locationService = new LocationService();
    RcmService rcmService = new RcmService();

    Message msg = new Message();
    msg.setSuccessful(true);

    Rcm rcm = rcmService.getRcmByName(name);
    if (rcm != null) {
      msg.setSuccessful(false);
      msg.setMessage("Rcm Already exists");
      return msg;
    }

    rcm = new Rcm();
    rcm.setName(name);
    rcm.setLocation(locationService.getLocationByCity(location));
    rcm.setTotalCapacity(capacity);
    rcm.setTotalCashValue(cashValue);
    rcm.setStatus(RcmStatus.ACTIVE);
    rcm.setReason("Admin Change");

    RmosRcmMapping mapping = new RmosRcmMapping();
    mapping.setRcm(rcm);
    mapping.setRmos(this.rmos);
    mapping.setValid(true);

    this.rmos.addRmosRcmMapping(mapping);

    msg.setSuccessful(repository.updateRmos(this.rmos));
    if (!msg.isSuccessful()) msg.setMessage("Internal Error");
    else {
      this.rmos = repository.getRmosById(this.rmos.getId());
    }
    setChanged();
    notifyObservers();

    return msg;
  }