Examples of HibernateIdentityObject


Examples of org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject

      if (relationshipType == null)
      {
         throw new IllegalArgumentException("RelationshipType is null");
      }

      HibernateIdentityObject fromIO = safeGet(ctx, fromIdentity);
      HibernateIdentityObject toIO = safeGet(ctx, toIdentity);
      HibernateIdentityObjectRelationshipType type = getHibernateIdentityObjectRelationshipType(ctx, relationshipType);

      getSupportedFeatures().isRelationshipTypeSupported(fromIO.getIdentityType(), toIO.getIdentityType(), relationshipType);

      org.hibernate.Query query = null;

      if (name == null)
      {
         query = getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE)
            .setParameter("fromIO", fromIO)
            .setParameter("toIO", toIO)
            .setParameter("typeName", type.getName());
      }
      else
      {
         HibernateIdentityObjectRelationshipName relationshipName =
            (HibernateIdentityObjectRelationshipName)getHibernateSession(ctx)
               .createCriteria(HibernateIdentityObjectRelationshipName.class).add(Restrictions.eq("name", name))
               .uniqueResult();

         if (relationshipName == null)
         {
            throw new IdentityException("Relationship name not present in the store");
         }

         query = getHibernateSession(ctx).createQuery(QUERY_RELATIONSHIP_BY_FROM_TO_TYPE_NAME)
            .setParameter("fromIO", fromIO)
            .setParameter("toIO", toIO)
            .setParameter("typeName", type.getName())
            .setParameter("name", name);
      }


      List results = query.list();

      if (results == null)
      {
         throw new IdentityException("Relationship already present");
      }

      HibernateIdentityObjectRelationship relationship = (HibernateIdentityObjectRelationship)results.iterator().next();     

      fromIO.getFromRelationships().remove(relationship);
      toIO.getToRelationships().remove(relationship);
      getHibernateSession(ctx).delete(relationship);

   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.