/**
   * Get an existing instance of TransfertReference
   *
   * @param entityId the id of the TransfertReferenceProxy to be fetched
   */
  private void fetchTransfertReference(String entityId) {

    TransfertReferenceRequest request = requestFactory.transfertReferenceRequest();

    /* get the TransfertReference instance from database */
    Request<TransfertReferenceProxy> fetchRequest = request.findById(entityId);
    fetchRequest.with("region");
    fetchRequest.with("region.nom");
    fetchRequest.with("districtSante");
    fetchRequest.with("districtSante.nom");
    fetchRequest.with("CDTDepart");
    fetchRequest.with("patient");
    fetchRequest.with("regionArrivee");
    fetchRequest.with("regionArrivee.nom");
    fetchRequest.with("districtSanteArrivee");
    fetchRequest.with("districtSanteArrivee.nom");
    fetchRequest.with("CDTArrivee");

    fetchRequest
        .to(
            new Receiver<TransfertReferenceProxy>() {
              @Override
              public void onSuccess(TransfertReferenceProxy entity) {
                viewTransfertReference(entity);
              }
            })
        .fire();
  }
  /**
   * Display the current instance of TransfertReference in editor
   *
   * @param entity the TransfertReferenceProxy to be displayed
   */
  private void viewTransfertReference(TransfertReferenceProxy entity) {

    /* display instance information */
    setTitle(
        NLS.constants().transfertReference_name()
            + ": "
            + EpicamRenderer.get().getDisplayValue(entity));
    setMetaData((ImogBeanProxy) entity);

    /* push the instance to the editor in view mode */
    request = requestFactory.transfertReferenceRequest();
    current = request.edit(entity);

    editor.setEditedValue(current);

    /* set request context for list editor operations */
    editor.setRequestContextForListEditors(request);

    editorDriver.edit(current, request);
    editor.setEdited(false);

    /* update field widgets in editor */
    editor.computeVisibility(null, true);

    /* display edit button */
    if (AccessManager.canEditTransfertReference()) setModifiable(true);

    showGlassPanel = false;
    EpicamEntryPoint.GP.hide();
  }
  /** Create a new instance of TransfertReference */
  private void createNewTransfertReference() {

    request = requestFactory.transfertReferenceRequest();

    /* create a new intance of TransfertReference */
    TransfertReferenceProxy newTransfertReference = request.create(TransfertReferenceProxy.class);
    newTransfertReference.setId(ImogKeyGenerator.generateKeyId("TRANS_REF"));

    /* push the instance to the editor */
    current = newTransfertReference;
    editorDriver.edit(current, request);

    /* set request context for list editor operations */
    editor.setRequestContextForListEditors(request);

    /* update field widgets in editor */
    editor.computeVisibility(null, true);
    // Field districtSante depends on the value of field region
    editor.getDistrictSanteFilteredByRegion(null);
    // Field cDTDepart depends on the value of field districtSante
    editor.getCDTDepartFilteredByDistrictSante(null);
    // Field districtSanteArrivee depends on the value of field regionArrivee
    editor.getDistrictSanteArriveeFilteredByRegionArrivee(null);
    // Field cDTArrivee depends on the value of field districtSanteArrivee
    editor.getCDTArriveeFilteredByDistrictSanteArrivee(null);
    editor.getPatientFilteredByCDTDepart(null);
    editor.setEdited(true);
  }