use of com.yahoo.elide.core.utils.coerce.CoerceUtil in project elide by yahoo.
the class ElideStandaloneSettings method getEntityDictionary.
/**
* Gets the EntityDictionary for elide.
* @param injector Service locator for web service for dependency injection.
* @param dynamicConfiguration optional dynamic config object.
* @param entitiesToExclude set of Entities to exclude from binding.
* @return EntityDictionary object initialized.
*/
default EntityDictionary getEntityDictionary(ServiceLocator injector, ClassScanner scanner, Optional<DynamicConfiguration> dynamicConfiguration, Set<Type<?>> entitiesToExclude) {
Map<String, Class<? extends Check>> checks = new HashMap<>();
if (getAnalyticProperties().enableDynamicModelConfigAPI()) {
checks.put(ConfigChecks.CAN_CREATE_CONFIG, ConfigChecks.CanNotCreate.class);
checks.put(ConfigChecks.CAN_READ_CONFIG, ConfigChecks.CanNotRead.class);
checks.put(ConfigChecks.CAN_DELETE_CONFIG, ConfigChecks.CanNotDelete.class);
checks.put(ConfigChecks.CAN_UPDATE_CONFIG, ConfigChecks.CanNotUpdate.class);
}
EntityDictionary dictionary = new EntityDictionary(// Checks
new HashMap<>(), // Role Checks
new HashMap<>(), new Injector() {
@Override
public void inject(Object entity) {
injector.inject(entity);
}
@Override
public <T> T instantiate(Class<T> cls) {
return injector.create(cls);
}
}, // Serde Lookup
CoerceUtil::lookup, entitiesToExclude, scanner);
dynamicConfiguration.map(DynamicConfiguration::getRoles).orElseGet(Collections::emptySet).forEach(role -> dictionary.addRoleCheck(role, new Role.RoleMemberCheck(role)));
return dictionary;
}
use of com.yahoo.elide.core.utils.coerce.CoerceUtil in project elide by yahoo.
the class ElideAutoConfiguration method buildDictionary.
/**
* Creates the entity dictionary for Elide which contains static metadata about Elide models.
* Override to load check classes or life cycle hooks.
* @param beanFactory Injector to inject Elide models.
* @param dynamicConfig An instance of DynamicConfiguration.
* @param settings Elide configuration settings.
* @param entitiesToExclude set of Entities to exclude from binding.
* @return a newly configured EntityDictionary.
*/
@Bean
@ConditionalOnMissingBean
@Scope(SCOPE_PROTOTYPE)
public EntityDictionary buildDictionary(AutowireCapableBeanFactory beanFactory, ClassScanner scanner, @Autowired(required = false) DynamicConfiguration dynamicConfig, ElideConfigProperties settings, @Qualifier("entitiesToExclude") Set<Type<?>> entitiesToExclude) {
Map<String, Class<? extends Check>> checks = new HashMap<>();
if (settings.getDynamicConfig().isConfigApiEnabled()) {
checks.put(ConfigChecks.CAN_CREATE_CONFIG, ConfigChecks.CanNotCreate.class);
checks.put(ConfigChecks.CAN_READ_CONFIG, ConfigChecks.CanNotRead.class);
checks.put(ConfigChecks.CAN_DELETE_CONFIG, ConfigChecks.CanNotDelete.class);
checks.put(ConfigChecks.CAN_UPDATE_CONFIG, ConfigChecks.CanNotUpdate.class);
}
EntityDictionary dictionary = new EntityDictionary(// Checks
checks, // Role Checks
new HashMap<>(), new Injector() {
@Override
public void inject(Object entity) {
beanFactory.autowireBean(entity);
}
@Override
public <T> T instantiate(Class<T> cls) {
return beanFactory.createBean(cls);
}
}, // Serde Lookup
CoerceUtil::lookup, entitiesToExclude, scanner);
if (isAggregationStoreEnabled(settings) && isDynamicConfigEnabled(settings)) {
dynamicConfig.getRoles().forEach(role -> {
dictionary.addRoleCheck(role, new Role.RoleMemberCheck(role));
});
}
return dictionary;
}
use of com.yahoo.elide.core.utils.coerce.CoerceUtil in project elide by yahoo.
the class ElideStandaloneConfigStoreTest method init.
@BeforeAll
public void init() throws Exception {
configRoot = Files.createTempDirectory("test");
settings = new ElideStandaloneTestSettings() {
@Override
public EntityDictionary getEntityDictionary(ServiceLocator injector, ClassScanner scanner, Optional<DynamicConfiguration> dynamicConfiguration, Set<Type<?>> entitiesToExclude) {
Map<String, Class<? extends Check>> checks = new HashMap<>();
if (getAnalyticProperties().enableDynamicModelConfigAPI()) {
checks.put(ConfigChecks.CAN_CREATE_CONFIG, ConfigChecks.CanCreate.class);
checks.put(ConfigChecks.CAN_READ_CONFIG, ConfigChecks.CanRead.class);
checks.put(ConfigChecks.CAN_DELETE_CONFIG, ConfigChecks.CanDelete.class);
checks.put(ConfigChecks.CAN_UPDATE_CONFIG, ConfigChecks.CanNotUpdate.class);
}
EntityDictionary dictionary = new EntityDictionary(// Checks
checks, // Role Checks
new HashMap<>(), new Injector() {
@Override
public void inject(Object entity) {
injector.inject(entity);
}
@Override
public <T> T instantiate(Class<T> cls) {
return injector.create(cls);
}
}, // Serde Lookup
CoerceUtil::lookup, entitiesToExclude, scanner);
dynamicConfiguration.map(DynamicConfiguration::getRoles).orElseGet(Collections::emptySet).forEach(role -> dictionary.addRoleCheck(role, new Role.RoleMemberCheck(role)));
return dictionary;
}
@Override
public ElideStandaloneAnalyticSettings getAnalyticProperties() {
return new ElideStandaloneAnalyticSettings() {
@Override
public boolean enableDynamicModelConfig() {
return true;
}
@Override
public boolean enableDynamicModelConfigAPI() {
return true;
}
@Override
public String getDynamicConfigPath() {
return configRoot.toFile().getAbsolutePath();
}
@Override
public boolean enableAggregationDataStore() {
return true;
}
@Override
public boolean enableMetaDataStore() {
return true;
}
};
}
};
elide = new ElideStandalone(settings);
elide.start(false);
}
use of com.yahoo.elide.core.utils.coerce.CoerceUtil in project elide by yahoo.
the class ConfigStoreIntegrationTestSetup method buildDictionary.
@Bean
public EntityDictionary buildDictionary(AutowireCapableBeanFactory beanFactory, ClassScanner scanner, @Autowired(required = false) DynamicConfiguration dynamicConfig, ElideConfigProperties settings, @Qualifier("entitiesToExclude") Set<Type<?>> entitiesToExclude) {
Map<String, Class<? extends Check>> checks = new HashMap<>();
if (settings.getDynamicConfig().isConfigApiEnabled()) {
checks.put(ConfigChecks.CAN_CREATE_CONFIG, ConfigChecks.CanCreate.class);
checks.put(ConfigChecks.CAN_READ_CONFIG, ConfigChecks.CanRead.class);
checks.put(ConfigChecks.CAN_DELETE_CONFIG, ConfigChecks.CanDelete.class);
checks.put(ConfigChecks.CAN_UPDATE_CONFIG, ConfigChecks.CanNotUpdate.class);
}
EntityDictionary dictionary = new EntityDictionary(// Checks
checks, // Role Checks
new HashMap<>(), new Injector() {
@Override
public void inject(Object entity) {
beanFactory.autowireBean(entity);
}
@Override
public <T> T instantiate(Class<T> cls) {
return beanFactory.createBean(cls);
}
}, // Serde Lookup
CoerceUtil::lookup, entitiesToExclude, scanner);
return dictionary;
}
use of com.yahoo.elide.core.utils.coerce.CoerceUtil in project elide by yahoo.
the class PersistentResourceFetcherTest method initializeQueryRunner.
@BeforeAll
public void initializeQueryRunner() {
RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).build();
hashMapDataStore = new HashMapDataStore(DefaultClassScanner.getInstance(), Author.class.getPackage());
settings = new ElideSettingsBuilder(hashMapDataStore).withEntityDictionary(dictionary).withJoinFilterDialect(filterDialect).withSubqueryFilterDialect(filterDialect).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).build();
settings.getSerdes().forEach(CoerceUtil::register);
initializeMocks();
Elide elide = new Elide(settings);
elide.doScans();
runner = new QueryRunner(elide, NO_VERSION);
}
Aggregations