use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class ElideAutoConfiguration method getRefreshableElide.
/**
* Creates the Elide instance with standard settings.
* @param dictionary Stores the static metadata about Elide models.
* @param dataStore The persistence store.
* @param transactionRegistry Global transaction registry.
* @param settings Elide settings.
* @return A new elide instance.
*/
@Bean
@RefreshScope
@ConditionalOnMissingBean
public RefreshableElide getRefreshableElide(EntityDictionary dictionary, DataStore dataStore, TransactionRegistry transactionRegistry, ElideConfigProperties settings, JsonApiMapper mapper, ErrorMapper errorMapper) {
ElideSettingsBuilder builder = new ElideSettingsBuilder(dataStore).withEntityDictionary(dictionary).withErrorMapper(errorMapper).withJsonApiMapper(mapper).withDefaultMaxPageSize(settings.getMaxPageSize()).withDefaultPageSize(settings.getPageSize()).withJoinFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withSubqueryFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withAuditLogger(new Slf4jLogger()).withBaseUrl(settings.getBaseUrl()).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).withJsonApiPath(settings.getJsonApi().getPath()).withGraphQLApiPath(settings.getGraphql().getPath());
if (settings.isVerboseErrors()) {
builder.withVerboseErrors();
}
if (settings.getAsync() != null && settings.getAsync().getExport() != null && settings.getAsync().getExport().isEnabled()) {
builder.withExportApiPath(settings.getAsync().getExport().getPath());
}
if (settings.getJsonApi() != null && settings.getJsonApi().isEnabled() && settings.getJsonApi().isEnableLinks()) {
String baseUrl = settings.getBaseUrl();
if (StringUtils.isEmpty(baseUrl)) {
builder.withJSONApiLinks(new DefaultJSONApiLinks());
} else {
String jsonApiBaseUrl = baseUrl + settings.getJsonApi().getPath() + "/";
builder.withJSONApiLinks(new DefaultJSONApiLinks(jsonApiBaseUrl));
}
}
Elide elide = new Elide(builder.build(), transactionRegistry, dictionary.getScanner(), true);
return new RefreshableElide(elide);
}
use of com.yahoo.elide.ElideSettingsBuilder in project faf-java-api by FAForever.
the class ElideConfig method elide.
@Bean
public Elide elide(SpringHibernateDataStore springHibernateDataStore, ObjectMapper objectMapper, EntityDictionary entityDictionary, ExtendedAuditLogger extendedAuditLogger) {
RSQLFilterDialect rsqlFilterDialect = new RSQLFilterDialect(entityDictionary);
registerAdditionalConverters();
return new Elide(new ElideSettingsBuilder(springHibernateDataStore).withJsonApiMapper(new JsonApiMapper(entityDictionary, objectMapper)).withAuditLogger(extendedAuditLogger).withEntityDictionary(entityDictionary).withJoinFilterDialect(rsqlFilterDialect).withSubqueryFilterDialect(rsqlFilterDialect).build());
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class RequestScopeTest method testNewObjectsForInheritedTypes.
@Test
public void testNewObjectsForInheritedTypes() throws Exception {
@Entity
@Include(rootLevel = false)
class MyBaseClass {
@Id
public long id;
}
@Entity
@Include(rootLevel = false)
class MyInheritedClass extends MyBaseClass {
public String myField;
}
EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(MyBaseClass.class);
dictionary.bindEntity(MyInheritedClass.class);
RequestScope requestScope = new RequestScope(null, "/", NO_VERSION, null, null, null, null, null, UUID.randomUUID(), new ElideSettingsBuilder(null).withEntityDictionary(dictionary).build());
String myId = "myId";
// Test that a new inherited class is counted for base type
requestScope.setUUIDForObject(ClassType.of(MyInheritedClass.class), myId, new MyInheritedClass());
assertNotNull(requestScope.getObjectById(ClassType.of(MyBaseClass.class), myId));
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class LogMessageImplTest method init.
@BeforeAll
public static void init() {
final EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(Child.class);
dictionary.bindEntity(Parent.class);
final Child child = new Child();
child.setId(5);
final Parent parent = new Parent();
parent.setId(7);
final Child friend = new Child();
friend.setId(9);
child.setFriends(Sets.newHashSet(friend));
final RequestScope requestScope = new RequestScope(null, null, NO_VERSION, null, null, new TestUser("aaron"), null, null, UUID.randomUUID(), new ElideSettingsBuilder(null).withAuditLogger(new TestAuditLogger()).withEntityDictionary(dictionary).build());
final PersistentResource<Parent> parentRecord = new PersistentResource<>(parent, requestScope.getUUIDFor(parent), requestScope);
childRecord = new PersistentResource<>(child, parentRecord, "children", requestScope.getUUIDFor(child), requestScope);
friendRecord = new PersistentResource<>(friend, childRecord, "friends", requestScope.getUUIDFor(friend), requestScope);
}
use of com.yahoo.elide.ElideSettingsBuilder in project elide by yahoo.
the class PermissionToFilterExpressionVisitorTest method setupEntityDictionary.
@BeforeEach
public void setupEntityDictionary() {
Map<String, Class<? extends Check>> checks = new HashMap<>();
checks.put(AT_OP_ALLOW, Permissions.Succeeds.class);
checks.put(AT_OP_DENY, Permissions.Fails.class);
checks.put(USER_ALLOW, Role.ALL.class);
checks.put(USER_DENY, Role.NONE.class);
checks.put(IN_FILTER, Permissions.InFilterExpression.class);
checks.put(NOT_IN_FILTER, Permissions.NotInFilterExpression.class);
checks.put(LT_FILTER, Permissions.LessThanFilterExpression.class);
checks.put(GE_FILTER, Permissions.GreaterThanOrEqualFilterExpression.class);
dictionary = TestDictionary.getTestDictionary(checks);
elideSettings = new ElideSettingsBuilder(null).withEntityDictionary(dictionary).build();
requestScope = newRequestScope();
cache = new ExpressionResultCache();
}
Aggregations