Skip to content

Commit

Permalink
fix(jpa): fix in/not in operations only taking first value
Browse files Browse the repository at this point in the history
  • Loading branch information
Idane committed Mar 5, 2023
1 parent 97da4e5 commit b99f28f
Show file tree
Hide file tree
Showing 38 changed files with 324 additions and 156 deletions.
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ object Versions {
// KRUD
val SHAPESHIFT = "0.7.0"
val SPRING_COMPONENTMAP = "0.1.0"

// Others
val GSON = "2.10"
val CHALK = "1.0.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.krud.crudframework.crud.cache.adapter.ehcache

import dev.krud.crudframework.crud.cache.CrudCache
import net.sf.ehcache.Ehcache
import net.sf.ehcache.Element
import dev.krud.crudframework.crud.cache.CrudCache

class CrudEhCacheImpl(private val vendorCache: Ehcache) : CrudCache {
override fun get(key: Any): Any? {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package dev.krud.crudframework.crud.cache.adapter.ehcache

import dev.krud.crudframework.crud.cache.CacheManagerAdapter
import dev.krud.crudframework.crud.cache.CrudCache
import dev.krud.crudframework.crud.cache.CrudCacheOptions
import net.sf.ehcache.Cache
import net.sf.ehcache.CacheManager
import net.sf.ehcache.config.CacheConfiguration
import org.slf4j.LoggerFactory
import dev.krud.crudframework.crud.cache.CacheManagerAdapter
import dev.krud.crudframework.crud.cache.CrudCache
import dev.krud.crudframework.crud.cache.CrudCacheOptions

class EhCacheManagerAdapter(
private val cacheManager: CacheManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.krud.crudframework.crud.cache.adapter.inmemory

import org.slf4j.LoggerFactory
import dev.krud.crudframework.crud.cache.CacheManagerAdapter
import dev.krud.crudframework.crud.cache.CrudCache
import dev.krud.crudframework.crud.cache.CrudCacheOptions
import org.slf4j.LoggerFactory

class InMemoryCacheManagerAdapter : CacheManagerAdapter {
private val caches = mutableMapOf<String, CrudCache>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package dev.krud.crudframework.crud.configuration

import dev.krud.crudframework.crud.cache.CacheManagerAdapter
import dev.krud.crudframework.crud.cache.adapter.inmemory.InMemoryCacheManagerAdapter
import org.slf4j.LoggerFactory
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Import
import dev.krud.crudframework.crud.cache.CacheManagerAdapter
import dev.krud.crudframework.crud.cache.adapter.inmemory.InMemoryCacheManagerAdapter

@Configuration
@Import(CrudEhCacheConfiguration::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.krud.crudframework.crud.configuration

import dev.krud.crudframework.crud.cache.CacheManagerAdapter
import dev.krud.crudframework.crud.cache.adapter.ehcache.EhCacheManagerAdapter
import net.sf.ehcache.CacheManager
import org.slf4j.LoggerFactory
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import dev.krud.crudframework.crud.cache.CacheManagerAdapter
import dev.krud.crudframework.crud.cache.adapter.ehcache.EhCacheManagerAdapter

@Configuration
@ConditionalOnClass(CacheManager::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ internal class CrudSecurityHandlerImpl(
private val principalProvider: ObjectProvider<PrincipalProvider>
) : CrudSecurityHandler, InitializingBean {
private val policyMap = ConcurrentHashMap<Class<*>, MutableList<Policy<PersistentEntity>>>()

@Autowired
private lateinit var applicationContext: ApplicationContext

override fun afterPropertiesSet() {
for (policy in policies.orderedStream()) {
policyMap.computeIfAbsent(policy.clazz) { mutableListOf() }
.add(policy)
.add(policy)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.krud.crudframework.crud.model

import org.springframework.core.annotation.AnnotatedElementUtils
import org.springframework.core.annotation.AnnotationUtils
import dev.krud.crudframework.crud.annotation.CachedBy
import dev.krud.crudframework.crud.annotation.CrudEntity
import dev.krud.crudframework.crud.annotation.DeleteColumn
Expand All @@ -12,10 +10,12 @@ import dev.krud.crudframework.crud.annotation.WithHooks
import dev.krud.crudframework.crud.cache.CrudCacheOptions
import dev.krud.crudframework.crud.handler.CrudDao
import dev.krud.crudframework.crud.hooks.interfaces.CRUDHooks
import dev.krud.crudframework.getGenericClass
import dev.krud.crudframework.model.BaseCrudEntity
import dev.krud.crudframework.model.PersistentEntity
import dev.krud.crudframework.util.ReflectionUtils
import dev.krud.crudframework.getGenericClass
import org.springframework.core.annotation.AnnotatedElementUtils
import org.springframework.core.annotation.AnnotationUtils
import java.lang.reflect.Field
import kotlin.reflect.KClass
import kotlin.reflect.full.allSuperclasses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Policy<RootType : PersistentEntity>(
)
}


fun evaluatePreCanAccess(principal: Principal?): Result<RootType> {
val result = canAccessRules.map { it.evaluatePreConditions(principal) }
return Result(
Expand Down Expand Up @@ -99,7 +98,7 @@ class Policy<RootType : PersistentEntity>(
}

private fun appendSuccess(success: Boolean): String {
return if(success) {
return if (success) {
Chalk.on("PASSED").bold().green().toString()
} else {
Chalk.on("FAILED").bold().red().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ class PolicyBuilder<RootType : PersistentEntity>(

fun build(): Policy<RootType> {
return Policy(
name ?: DEFAULT_POLICY_NAME, location, clazz, filterFields, rules
name ?: DEFAULT_POLICY_NAME,
location,
clazz,
filterFields,
rules
)
}

companion object {
const val DEFAULT_POLICY_NAME = "unnamed policy"
const val DEFAULT_FILTER_NAME = "unnamed filter"
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dev.krud.crudframework.crud.policy
data class PolicyElementLocation(
val fileName: String?,
val lineNumber: Int,
val declaringClass : String,
val methodName: String,
val declaringClass: String,
val methodName: String
) {
override fun toString(): String {
return "$declaringClass.$methodName($fileName:$lineNumber)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dev.krud.crudframework.crud.policy

import dev.krud.crudframework.crud.policy.PolicyElementLocation.Companion.toPolicyElementLocation
import dev.krud.crudframework.model.PersistentEntity
import dev.krud.crudframework.modelfilter.dsl.FilterFieldsBuilder
import java.security.Principal

class PolicyRuleBuilder<RootType : PersistentEntity>(private val name: String?, private val type: PolicyRuleType, private val location: PolicyElementLocation) {
private val preConditions = mutableListOf<PolicyPreCondition>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ fun <RootType : PersistentEntity> not(setup: FilterFieldsBuilder<RootType>.() ->

fun <RootType : PersistentEntity> emptyFilter(): DynamicModelFilter {
return DynamicModelFilter()
}

}
Loading

0 comments on commit b99f28f

Please sign in to comment.