예제 #1
0
  public static RequestClaim entity2domain(ApplicationClaimEntity entity) {
    Claim claim = ClaimDAOJPAImpl.entity2domain(entity.getClaim());
    RequestClaim reqClaim = new RequestClaim(claim);
    reqClaim.setId(entity.getId());
    reqClaim.setOptional(entity.isOptional());

    return reqClaim;
  }
예제 #2
0
  @Override
  public void removeClaimFromApplication(Application application, RequestClaim claim) {
    ApplicationEntity applicationEntity = null;
    if (application.getId() != 0) {
      applicationEntity = em.find(ApplicationEntity.class, application.getId());
    } else {
      Query query = null;
      query = em.createQuery("select a from Application a where a.realm=:realm");
      query.setParameter("realm", application.getRealm());

      applicationEntity = (ApplicationEntity) query.getSingleResult();
    }

    ApplicationClaimEntity foundEntity = null;
    for (ApplicationClaimEntity acm : applicationEntity.getRequestedClaims()) {
      if (claim.getClaimType().toString().equals(acm.getClaim().getClaimType())) {
        foundEntity = acm;
        break;
      }
    }
    if (foundEntity == null) {
      throw new EntityNotFoundException("ApplicationClaimEntity not found");
    }

    applicationEntity.getRequestedClaims().remove(foundEntity);
  }
예제 #3
0
  public static void domain2entity(
      ApplicationEntity application, RequestClaim reqClaim, ApplicationClaimEntity entity) {
    // The ID must not be updated if the entity has got an id already (update case)
    ClaimEntity claim = new ClaimEntity();
    ClaimDAOJPAImpl.domain2entity(reqClaim, claim);

    entity.setApplication(application);
    entity.setClaim(claim);
    entity.setOptional(reqClaim.isOptional());
  }
예제 #4
0
  @Override
  public void addClaimToApplication(Application application, RequestClaim claim) {
    ApplicationEntity applicationEntity = null;
    if (application.getId() != 0) {
      applicationEntity = em.find(ApplicationEntity.class, application.getId());
    } else {
      Query query = null;
      query = em.createQuery("select a from Application a where a.realm=:realm");
      query.setParameter("realm", application.getRealm());

      applicationEntity = (ApplicationEntity) query.getSingleResult();
    }

    Claim c = claimDAO.getClaim(claim.getClaimType().toString());
    ClaimEntity claimEntity = em.find(ClaimEntity.class, c.getId());

    ApplicationClaimEntity appClaimEntity = new ApplicationClaimEntity();
    appClaimEntity.setClaim(claimEntity);
    appClaimEntity.setApplication(applicationEntity);
    appClaimEntity.setOptional(claim.isOptional());

    applicationEntity.getRequestedClaims().add(appClaimEntity);
  }