/** * <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 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); }
query.setParameter(Relationship.NAME, authorized.getName()); 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()); assertEquals(authorized.getName(), result.get(0).getName()); assertNotNull(authorized.to()); assertNotNull(authorized.from());