use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class HashMapStoreTransaction method loadObject.
@Override
public Object loadObject(EntityProjection projection, Serializable id, RequestScope scope) {
EntityDictionary dictionary = scope.getDictionary();
synchronized (dataStore) {
Map<String, Object> data = dataStore.get(projection.getType());
if (data == null) {
return null;
}
Serde serde = dictionary.getSerdeLookup().apply(id.getClass());
String idString = (serde == null) ? id.toString() : (String) serde.serialize(id);
return data.get(idString);
}
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class AggregationDataStore method populateEntityDictionary.
/**
* Populate an {@link EntityDictionary} and use this dictionary to construct a {@link QueryEngine}.
* @param dictionary the dictionary
*/
@Override
public void populateEntityDictionary(EntityDictionary dictionary) {
if (dynamicCompiledClasses != null && dynamicCompiledClasses.size() != 0) {
dynamicCompiledClasses.stream().filter((type) -> !IS_TYPE_HIDDEN.test(type)).forEach(dynamicLoadedClass -> {
dictionary.bindEntity(dynamicLoadedClass, IS_FIELD_HIDDEN);
validateModelExpressionChecks(dictionary, dynamicLoadedClass);
dictionary.bindPermissionExecutor(dynamicLoadedClass, aggPermissionExecutor);
});
}
dictionary.getScanner().getAnnotatedClasses(AGGREGATION_STORE_CLASSES).stream().filter((type) -> !IS_TYPE_HIDDEN.test(ClassType.of(type))).forEach(cls -> {
dictionary.bindEntity(cls, IS_FIELD_HIDDEN);
validateModelExpressionChecks(dictionary, ClassType.of(cls));
dictionary.bindPermissionExecutor(cls, aggPermissionExecutor);
});
for (Table table : queryEngine.getMetaDataStore().getMetaData(ClassType.of(Table.class))) {
/* Add 'grain' argument to each TimeDimensionColumn */
for (TimeDimension timeDim : table.getAllTimeDimensions()) {
dictionary.addArgumentToAttribute(dictionary.getEntityClass(table.getName(), table.getVersion()), timeDim.getName(), new ArgumentType("grain", ClassType.STRING_TYPE, timeDim.getDefaultGrain().getGrain()));
}
/* Add argument to each Column */
for (Column col : table.getAllColumns()) {
for (ArgumentDefinition arg : col.getArgumentDefinitions()) {
dictionary.addArgumentToAttribute(dictionary.getEntityClass(table.getName(), table.getVersion()), col.getName(), new ArgumentType(arg.getName(), ValueType.getType(arg.getType()), arg.getDefaultValue()));
}
}
/* Add argument to each Table */
for (ArgumentDefinition arg : table.getArgumentDefinitions()) {
dictionary.addArgumentToEntity(dictionary.getEntityClass(table.getName(), table.getVersion()), new ArgumentType(arg.getName(), ValueType.getType(arg.getType()), arg.getDefaultValue()));
}
}
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class MetaDataStore method addTable.
/**
* Add a table metadata object.
*
* @param table table metadata
*/
public void addTable(Table table) {
String version = table.getVersion();
EntityDictionary dictionary = hashMapDataStores.computeIfAbsent(version, SERVER_ERROR).getDictionary();
tables.put(dictionary.getEntityClass(table.getName(), version), table);
if (!table.isHidden()) {
addMetaData(table, version);
}
table.getAllColumns().stream().forEach(this::addColumn);
table.getArgumentDefinitions().forEach(arg -> addArgument(arg, version));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class MetaDataStore method addMetaData.
/**
* Add a meta data object into this data store, check for duplication.
*
* @param object a meta data object
*/
private void addMetaData(Object object, String version) {
HashMapDataStore hashMapDataStore = hashMapDataStores.computeIfAbsent(version, SERVER_ERROR);
EntityDictionary dictionary = hashMapDataStore.getDictionary();
Type<?> cls = dictionary.lookupBoundClass(EntityDictionary.getType(object));
String id = dictionary.getId(object);
if (hashMapDataStore.get(cls).containsKey(id)) {
if (!hashMapDataStore.get(cls).get(id).equals(object)) {
throw new DuplicateMappingException("Duplicated " + cls.getSimpleName() + " metadata " + id);
}
} else {
hashMapDataStore.get(cls).put(id, object);
}
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class StandardTestBinder method configure.
@Override
protected void configure() {
EntityDictionary dictionary = EntityDictionary.builder().injector(injector::inject).checks(TestCheckMappings.MAPPINGS).build();
bind(dictionary).to(EntityDictionary.class);
// Elide instance
bindFactory(new Factory<Elide>() {
@Override
public Elide provide() {
DefaultFilterDialect defaultFilterStrategy = new DefaultFilterDialect(dictionary);
RSQLFilterDialect rsqlFilterStrategy = RSQLFilterDialect.builder().dictionary(dictionary).build();
MultipleFilterDialect multipleFilterStrategy = new MultipleFilterDialect(Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy), Arrays.asList(rsqlFilterStrategy, defaultFilterStrategy));
Elide elide = new Elide(new ElideSettingsBuilder(IntegrationTest.getDataStore()).withAuditLogger(auditLogger).withJoinFilterDialect(multipleFilterStrategy).withSubqueryFilterDialect(multipleFilterStrategy).withEntityDictionary(dictionary).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", Calendar.getInstance().getTimeZone()).build());
elide.doScans();
return elide;
}
@Override
public void dispose(Elide elide) {
}
}).to(Elide.class).named("elide");
bind(BILLING_SERVICE).to(BillingService.class);
}
Aggregations