@Override protected void doPopulateIdentityInstance(Object toIdentity, Relationship fromRelationship, JPAIdentityStore store) { store.setModelProperty(toIdentity, PROPERTY_IDENTITY_NAME, fromRelationship.getName(), true); Object relatedFromIdentity = store.lookupIdentityObjectById(fromRelationship.from()); store.setModelProperty(toIdentity, JPAIdentityStoreConfiguration.PROPERTY_IDENTITY_RELATED_TO, relatedFromIdentity, true); Object relatesToIdentity = store.lookupIdentityObjectById(fromRelationship.to()); store.setModelProperty(toIdentity, JPAIdentityStoreConfiguration.PROPERTY_IDENTITY_RELATES_TO, relatesToIdentity, true); }
@Override public String getId() { return getRelationship().getId(); }
authorized.setFrom(robert); authorized.setTo(myOauthApp); authorized.setAttribute(new Attribute<String>("authorizationCode", authorizationCode)); authorized.setAttribute(new Attribute<String>("accessToken", accessToken)); authorized.setAttribute(new Attribute<String>("refreshToken", refreshToken)); query.setParameter(Relationship.NAME, authorized.getName()); assertEquals(authorized.getName(), result.get(0).getName()); assertNotNull(authorized.to()); assertNotNull(authorized.from()); assertNotNull(authorized.getAttribute("authorizationCode")); assertEquals(authorized.getName(), result.get(0).getName()); assertNotNull(authorized.to()); assertNotNull(authorized.from()); assertEquals(authorized.getName(), result.get(0).getName()); assertNotNull(authorized.to()); assertNotNull(authorized.from());
/** * <p> * Resolves the value of the identifier for the given {@link IdentityType}. * </p> * * @param identityType * @return */ private String getIdentifierValue(IdentityType identityType) { String value = null; if (IDMUtil.isUserType(identityType.getClass())) { value = ((User) identityType).getId(); } else if (IDMUtil.isAgentType(identityType.getClass())) { value = ((Agent) identityType).getId(); } else if (IDMUtil.isRoleType(identityType.getClass())) { value = ((Role) identityType).getName(); } else if (IDMUtil.isGroupType(identityType.getClass())) { value = ((Group) identityType).getName(); } else if (IDMUtil.isRelationshipType(identityType.getClass())) { value = ((Relationship) identityType).getName(); } return value; }
@Override public String getId() { return getRelationship().getId(); }
private void storeRelationshipType(Relationship relationship) { String type = relationship.getClass().getName(); Map<String, FileRelationship> storedRelationships = this.fileDataSource.getRelationships().get(type); if (storedRelationships == null) { storedRelationships = new ConcurrentHashMap<String, FileRelationship>(); this.fileDataSource.getRelationships().put(type, storedRelationships); } storedRelationships.put(relationship.getId(), new FileRelationship(relationship)); this.fileDataSource.flushRelationships(); }
private void storeRelationshipType(Relationship relationship) { String type = relationship.getClass().getName(); Map<String, FileRelationship> storedRelationships = this.fileDataSource.getRelationships().get(type); if (storedRelationships == null) { storedRelationships = new ConcurrentHashMap<String, FileRelationship>(); this.fileDataSource.getRelationships().put(type, storedRelationships); } storedRelationships.put(relationship.getId(), new FileRelationship(relationship)); this.fileDataSource.flushRelationships(); }
private List<?> findChildRelationships(IdentityContext context, Relationship relationship) { EntityManager em = getEntityManager(context); EntityMapper relationshipMemberMapper = getEntityMapperForProperty(relationship.getClass(), RelationshipMember.class); CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<?> criteria = builder.createQuery(relationshipMemberMapper.getEntityType()); Root<?> root = criteria.from(relationshipMemberMapper.getEntityType()); List<Predicate> predicates = new ArrayList<Predicate>(); Property ownerProperty = relationshipMemberMapper.getProperty(OwnerReference.class).getValue(); Join<?, ?> join = root.join(ownerProperty.getName()); EntityMapper relationshipMapper = getRootMapper(relationship.getClass()); Property identifierProperty = relationshipMapper.getProperty(Identifier.class).getValue(); predicates.add(builder.equal(join.get(identifierProperty.getName()), relationship.getId())); criteria.where(predicates.toArray(new Predicate[predicates.size()])); return em.createQuery(criteria).getResultList(); }
private List<?> findChildRelationships(IdentityContext context, Relationship relationship) { EntityManager em = getEntityManager(context); EntityMapper relationshipMemberMapper = getEntityMapperForProperty(relationship.getClass(), RelationshipMember.class); CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<?> criteria = builder.createQuery(relationshipMemberMapper.getEntityType()); Root<?> root = criteria.from(relationshipMemberMapper.getEntityType()); List<Predicate> predicates = new ArrayList<Predicate>(); Property ownerProperty = relationshipMemberMapper.getProperty(OwnerReference.class).getValue(); Join<?, ?> join = root.join(ownerProperty.getName()); EntityMapper relationshipMapper = getRootMapper(relationship.getClass()); Property identifierProperty = relationshipMapper.getProperty(Identifier.class).getValue(); predicates.add(builder.equal(join.get(identifierProperty.getName()), relationship.getId())); criteria.where(predicates.toArray(new Predicate[predicates.size()])); return em.createQuery(criteria).getResultList(); }