Beispiel #1
0
  public MediaartDto mediaartFindByPrimaryKey(String cNr, TheClientDto theClientDto)
      throws EJBExceptionLP {
    myLogger.logData(cNr);

    if (cNr == null) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER, new Exception("cNr == null"));
    }

    MediaartDto mediaartDtoO = null;

    // try {
    Mediaart mediaart = em.find(Mediaart.class, cNr);
    if (mediaart == null) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY, "");
    }
    mediaartDtoO = assembleMediaartDto(mediaart);

    try {
      Mediaartspr mediaartspr =
          em.find(
              Mediaartspr.class,
              new MediaartsprPK(mediaartDtoO.getCNr(), theClientDto.getLocUiAsString()));
      mediaartDtoO.setMediaartsprDto(assembleMediaartsprDto(mediaartspr));
    } catch (Throwable t) {
      // nothing here.
    }
    // }
    // catch (FinderException ex) {
    // throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY,
    // ex);
    // }

    return mediaartDtoO;
  }
Beispiel #2
0
  public void removeMediaart(MediaartDto mediaartDto, TheClientDto theClientDto)
      throws EJBExceptionLP {
    checkMediaartDto(mediaartDto);

    try {
      Query query = em.createNamedQuery("MediaartsprfindByMediaartCNr");
      query.setParameter(1, mediaartDto.getCNr());
      Collection<?> cl = query.getResultList();
      Mediaart mediaart = em.find(Mediaart.class, mediaartDto.getCNr());
      if (mediaart == null) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY, "");
      }
      // Erst alle SPRs dazu loeschen.
      for (Iterator<?> iter = cl.iterator(); iter.hasNext(); ) {
        Mediaartspr item = (Mediaartspr) iter.next();
        em.remove(item);
      }

      em.remove(mediaart);
      em.flush();
      // }
      // catch (FinderException ex) {
      // throw new
      // EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY, ex);
    } catch (EntityExistsException ex) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEIM_LOESCHEN, ex);
    }
  }
Beispiel #3
0
  public void updateMediaart(MediaartDto mediaartDto, TheClientDto theClientDto)
      throws EJBExceptionLP, RemoteException {
    checkMediaartDto(mediaartDto);

    String cNr = mediaartDto.getCNr();

    // try {
    Mediaart mediaart = em.find(Mediaart.class, cNr);
    if (mediaart == null) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY, "");
    }

    if (mediaartDto.getMediaartsprDto() != null) {
      mediaartDto.getMediaartsprDto().setLocaleCNr(theClientDto.getLocUiAsString());

      // create
      if (mediaartDto.getMediaartsprDto().getMediaartCNr() == null) {
        // zuerst Key setzen
        mediaartDto.getMediaartsprDto().setMediaartCNr(mediaartDto.getCNr());

        createMediaartspr(mediaartDto.getMediaartsprDto(), theClientDto);
      }

      // update
      else {
        updateMediaartspr(mediaartDto.getMediaartsprDto(), theClientDto);
      }
    }
    // }
    // catch (FinderException ex) {
    // throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEI_FINDBYPRIMARYKEY,
    // ex);
    // }

  }
Beispiel #4
0
  public String createMediaart(MediaartDto oMediaartDtoI, TheClientDto theClientDto)
      throws EJBExceptionLP {
    checkMediaartDto(oMediaartDtoI);

    Mediaart mediaart = null;

    try {
      mediaart = new Mediaart(oMediaartDtoI.getCNr());
      em.persist(mediaart);
      em.flush();

      if (oMediaartDtoI.getMediaartsprDto() != null) {
        oMediaartDtoI.getMediaartsprDto().setMediaartCNr(oMediaartDtoI.getCNr());
        createMediaartspr(oMediaartDtoI.getMediaartsprDto(), theClientDto);
      }
    } catch (EntityExistsException ex) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEIM_ANLEGEN, ex);
    }

    return mediaart.getCNr();
  }