use of io.crnk.core.engine.internal.information.DefaultInformationBuilder in project crnk-framework by crnk-project.
the class ModuleRegistry method getResourceInformationBuilder.
/**
* Returns a {@link ResourceInformationProvider} instance that combines all
* instances registered by modules.
*
* @return resource information builder
*/
public ResourceInformationProvider getResourceInformationBuilder() {
if (resourceInformationProvider == null) {
resourceInformationProvider = new CombinedResourceInformationProvider(aggregatedModule.getResourceInformationProviders());
InformationBuilder informationBuilder = new DefaultInformationBuilder(typeParser);
DefaultResourceInformationProviderContext context = new DefaultResourceInformationProviderContext(resourceInformationProvider, informationBuilder, typeParser, objectMapper);
resourceInformationProvider.init(context);
}
return resourceInformationProvider;
}
use of io.crnk.core.engine.internal.information.DefaultInformationBuilder in project crnk-framework by crnk-project.
the class MetaModule method registerInformationBuilder.
protected DefaultResourceInformationProvider registerInformationBuilder(PropertiesProvider propertiesProvider) {
InformationBuilder informationBuilder = new DefaultInformationBuilder(context.getTypeParser());
DefaultResourceInformationProvider informationProvider = new DefaultResourceInformationProvider(propertiesProvider, new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
informationProvider.init(new DefaultResourceInformationProviderContext(informationProvider, informationBuilder, context.getTypeParser(), null) {
@Override
public ObjectMapper getObjectMapper() {
return context.getObjectMapper();
}
});
return informationProvider;
}
use of io.crnk.core.engine.internal.information.DefaultInformationBuilder in project crnk-framework by crnk-project.
the class DefaultRegistryEntryBuilder method contributeFields.
private void contributeFields(ResourceInformation resourceInformation) {
// TODO make service discovery the primary target to resolve all objects => wrapped it with module
List<ResourceFieldContributor> contributors = new ArrayList<>();
contributors.addAll(moduleRegistry.getServiceDiscovery().getInstancesByType(ResourceFieldContributor.class));
for (Object repo : moduleRegistry.getRepositories()) {
if (repo instanceof ResourceFieldContributor && !contributors.contains(repo)) {
contributors.add((ResourceFieldContributor) repo);
}
}
for (ResourceFieldContributor contributor : contributors) {
List<ResourceField> contributedFields = contributor.getResourceFields(new ResourceFieldContributorContext() {
@Override
public ResourceInformation getResourceInformation() {
return resourceInformation;
}
@Override
public InformationBuilder getInformationBuilder() {
return new DefaultInformationBuilder(moduleRegistry.getTypeParser());
}
});
List<ResourceField> fields = new ArrayList<>();
fields.addAll(resourceInformation.getFields());
fields.addAll(contributedFields);
resourceInformation.setFields(fields);
}
}
use of io.crnk.core.engine.internal.information.DefaultInformationBuilder in project crnk-framework by crnk-project.
the class QueryParamsAdapterTest method test.
@Test
public void test() {
ModuleRegistry moduleRegistry = new ModuleRegistry();
moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
ResourceRegistry resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
QueryParams params = new QueryParams();
DefaultResourceInformationProvider builder = new DefaultResourceInformationProvider(new NullPropertiesProvider(), new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
builder.init(new DefaultResourceInformationProviderContext(builder, new DefaultInformationBuilder(moduleRegistry.getTypeParser()), moduleRegistry.getTypeParser(), new ObjectMapper()));
ResourceInformation info = builder.build(Task.class);
QueryParamsAdapter adapter = new QueryParamsAdapter(info, params, moduleRegistry);
Assert.assertEquals(Task.class, adapter.getResourceInformation().getResourceClass());
Assert.assertEquals(resourceRegistry, adapter.getResourceRegistry());
}
use of io.crnk.core.engine.internal.information.DefaultInformationBuilder in project crnk-framework by crnk-project.
the class JpaResourceInformationProviderTest method setup.
@Before
public void setup() {
jpaMetaProvider = new JpaMetaProvider(Collections.<Class>emptySet());
lookup = new MetaLookup();
lookup.addProvider(jpaMetaProvider);
builder = new JpaResourceInformationProvider(new NullPropertiesProvider());
builder.init(new DefaultResourceInformationProviderContext(builder, new DefaultInformationBuilder(new TypeParser()), new TypeParser(), new ObjectMapper()));
}
Aggregations