@Override public void setup(JPAIdentityStoreConfiguration config) { super.setup(config); if (config.getContextInitializers().isEmpty()) { JPA_STORE_LOGGER.jpaContextInitializerNotProvided(); } for (Class<?> entityType : config.getEntityTypes()) { configureEntityMapper(entityType); } logEntityMappers(); validateConfiguration(); }
private void validateConfiguration() { Set<Class<? extends AttributedType>> supportedTypes = getConfig().getSupportedTypes().keySet(); validateTypeMapping(supportedTypes); validateAttributeMapping(); validateCredentialMapping(); }
private boolean isPartitionSupported(Class<?> type) { return Partition.class.isAssignableFrom(type) && this.store.getConfig().supportsPartition(); }
@Override protected JPAStoreConfigurationBuilder readFrom(JPAIdentityStoreConfiguration configuration) { super.readFrom(configuration); for (Class<?> entityType: configuration.getEntityTypes()) { mappedEntity(entityType); } return this; }
@Override public void removeAttribute(IdentityContext context, AttributedType attributedType, String attributeName) { EntityMapper attributeMapper = getAttributeMapper(attributedType.getClass()); EntityManager entityManager = getEntityManager(context); CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<?> cq = cb.createQuery(attributeMapper.getEntityType()); Root<?> from = cq.from(attributeMapper.getEntityType()); List<Predicate> predicates = new ArrayList<Predicate>(); Property attributeNameProperty = attributeMapper.getProperty(Attribute.class, AttributeName.class).getValue(); predicates.add(cb.equal(from.get(attributeNameProperty.getName()), attributeName)); Property ownerProperty = attributeMapper.getProperty(Attribute.class, OwnerReference.class).getValue(); if (getConfig().supportsType(attributedType.getClass(), IdentityOperation.create) && !String.class.equals(ownerProperty.getJavaClass())) { predicates.add(cb.equal(from.get(ownerProperty.getName()), getOwnerEntity(attributedType, ownerProperty, entityManager))); } else { predicates.add(cb.equal(from.get(ownerProperty.getName()), attributedType.getId())); } cq.where(predicates.toArray(new Predicate[predicates.size()])); for (Object entity : entityManager.createQuery(cq).getResultList()) { entityManager.remove(entity); } }
if (partitionProperty != null && getConfig().supportsPartition()) { Join<Object, Object> join = rootEntity.join(partitionProperty.getValue().getName()); predicates.add(cb.equal(join, entityManager.find(partitionProperty.getValue().getJavaClass(), partition.getId()))); } else if (getConfig().supportsAttribute()) { addAttributeQueryPredicates(type, entityManager, cb, cq, rootEntity, predicates, attributeParameter, condition, null);
private void validateAttributeMapping() { if (getConfig().supportsAttribute()) { for (EntityMapper entityMapper : getEntityMappers()) { if (entityMapper.getProperty(AttributeClass.class) != null) { checkIfAnnotationIsDefinedForAttribute(entityMapper, AttributeName.class); checkIfAnnotationIsDefinedForAttribute(entityMapper, AttributeValue.class); checkIfAnnotationIsDefinedForAttribute(entityMapper, OwnerReference.class); return; } } throw MESSAGES.configJpaStoreMappedNoAttributeMappingFound(); } }
@Override protected JPAIdentityStoreConfiguration create() { return new JPAIdentityStoreConfiguration( this.mappedEntities, getSupportedTypes(), getUnsupportedTypes(), getContextInitializers(), getCredentialHandlerProperties(), getCredentialHandlers(), isSupportAttributes(), isSupportCredentials(), isSupportPermissions()); }
private void validateCredentialMapping() { if (getConfig().supportsCredential()) { for (EntityMapper entityMapper : getEntityMappers()) { ManagedCredential managedCredential = entityMapper.getEntityType().getAnnotation(ManagedCredential.class); if (managedCredential != null) { checkIfAnnotationIsDefinedForCredential(entityMapper, CredentialClass.class); checkIfAnnotationIsDefinedForCredential(entityMapper, EffectiveDate.class); checkIfAnnotationIsDefinedForCredential(entityMapper, ExpiryDate.class); return; } } throw MESSAGES.configJpaStoreMappedNoCredentialStorageMappingFound(); } }
@Override protected JPAStoreConfigurationBuilder readFrom(JPAIdentityStoreConfiguration configuration) { super.readFrom(configuration); for (Class<?> entityType: configuration.getEntityTypes()) { mappedEntity(entityType); } return this; }
@Override public void removeAttribute(IdentityContext context, AttributedType attributedType, String attributeName) { EntityMapper attributeMapper = getAttributeMapper(attributedType.getClass()); EntityManager entityManager = getEntityManager(context); CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<?> cq = cb.createQuery(attributeMapper.getEntityType()); Root<?> from = cq.from(attributeMapper.getEntityType()); List<Predicate> predicates = new ArrayList<Predicate>(); Property attributeNameProperty = attributeMapper.getProperty(Attribute.class, AttributeName.class).getValue(); predicates.add(cb.equal(from.get(attributeNameProperty.getName()), attributeName)); Property ownerProperty = attributeMapper.getProperty(Attribute.class, OwnerReference.class).getValue(); if (getConfig().supportsType(attributedType.getClass(), IdentityOperation.create) && !String.class.equals(ownerProperty.getJavaClass())) { predicates.add(cb.equal(from.get(ownerProperty.getName()), getOwnerEntity(attributedType, ownerProperty, entityManager))); } else { predicates.add(cb.equal(from.get(ownerProperty.getName()), attributedType.getId())); } cq.where(predicates.toArray(new Predicate[predicates.size()])); for (Object entity : entityManager.createQuery(cq).getResultList()) { entityManager.remove(entity); } }
if (partitionProperty != null && getConfig().supportsPartition()) { Join<Object, Object> join = rootEntity.join(partitionProperty.getValue().getName()); predicates.add(cb.equal(join, entityManager.find(partitionProperty.getValue().getJavaClass(), partition.getId()))); } else if (getConfig().supportsAttribute()) { addAttributeQueryPredicates(type, entityManager, cb, cq, rootEntity, predicates, attributeParameter, condition, null);
private void validateAttributeMapping() { if (getConfig().supportsAttribute()) { for (EntityMapper entityMapper : getEntityMappers()) { if (entityMapper.getProperty(AttributeClass.class) != null) { checkIfAnnotationIsDefinedForAttribute(entityMapper, AttributeName.class); checkIfAnnotationIsDefinedForAttribute(entityMapper, AttributeValue.class); checkIfAnnotationIsDefinedForAttribute(entityMapper, OwnerReference.class); return; } } throw MESSAGES.configJpaStoreMappedNoAttributeMappingFound(); } }
@Override protected JPAIdentityStoreConfiguration create() { return new JPAIdentityStoreConfiguration( this.mappedEntities, getSupportedTypes(), getUnsupportedTypes(), getContextInitializers(), getCredentialHandlerProperties(), getCredentialHandlers(), isSupportAttributes(), isSupportCredentials(), isSupportPermissions()); }
private void validateCredentialMapping() { if (getConfig().supportsCredential()) { for (EntityMapper entityMapper : getEntityMappers()) { ManagedCredential managedCredential = entityMapper.getEntityType().getAnnotation(ManagedCredential.class); if (managedCredential != null) { checkIfAnnotationIsDefinedForCredential(entityMapper, CredentialClass.class); checkIfAnnotationIsDefinedForCredential(entityMapper, EffectiveDate.class); checkIfAnnotationIsDefinedForCredential(entityMapper, ExpiryDate.class); return; } } throw MESSAGES.configJpaStoreMappedNoCredentialStorageMappingFound(); } }
@Override public void setup(JPAIdentityStoreConfiguration config) { super.setup(config); if (config.getContextInitializers().isEmpty()) { JPA_STORE_LOGGER.jpaContextInitializerNotProvided(); } for (Class<?> entityType : config.getEntityTypes()) { configureEntityMapper(entityType); } logEntityMappers(); validateConfiguration(); }
if (getConfig().getEntityTypes().contains(ownerClass)) { configureEntityMapper(ownerClass);
if (getConfig().supportsType(attributedType.getClass(), IdentityOperation.create) && !String.class.equals(ownerProperty.getJavaClass())) { predicates.add(cb.equal(from.get(ownerProperty.getName()),
private boolean isPartitionSupported(Class<?> type) { return Partition.class.isAssignableFrom(type) && this.store.getConfig().supportsPartition(); }
private void validateConfiguration() { Set<Class<? extends AttributedType>> supportedTypes = getConfig().getSupportedTypes().keySet(); validateTypeMapping(supportedTypes); validateAttributeMapping(); validateCredentialMapping(); }