Search in sources :

Example 1 with RegistryEntryBuilder

use of io.crnk.core.engine.registry.RegistryEntryBuilder in project crnk-framework by crnk-project.

the class ModuleRegistry method applyRepositoryRegistration.

private void applyRepositoryRegistration(Object repository) {
    RegistryEntryBuilder entryBuilder = getContext().newRegistryEntryBuilder();
    entryBuilder.fromImplementation(repository);
    RegistryEntry entry = entryBuilder.build();
    resourceRegistry.addEntry(entry);
}
Also used : DefaultRegistryEntryBuilder(io.crnk.core.engine.internal.registry.DefaultRegistryEntryBuilder) RegistryEntryBuilder(io.crnk.core.engine.registry.RegistryEntryBuilder) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry)

Example 2 with RegistryEntryBuilder

use of io.crnk.core.engine.registry.RegistryEntryBuilder in project crnk-framework by crnk-project.

the class DynamicModule method init.

@Override
public void init() {
    for (int i = 0; i < 2; i++) {
        RegistryEntryBuilder builder = context.newRegistryEntryBuilder();
        String resourceType = "dynamic" + i;
        RegistryEntryBuilder.ResourceRepository resourceRepository = builder.resourceRepository();
        resourceRepository.instance(new DynamicResourceRepository(resourceType));
        RegistryEntryBuilder.RelationshipRepository parentRepository = builder.relationshipRepositoryForField("parent");
        parentRepository.instance(new DynamicRelationshipRepository(resourceType));
        RegistryEntryBuilder.RelationshipRepository childrenRepository = builder.relationshipRepositoryForField("children");
        childrenRepository.instance(new DynamicRelationshipRepository(resourceType));
        InformationBuilder.Resource resource = builder.resource();
        resource.resourceType(resourceType);
        resource.resourceClass(Resource.class);
        resource.addField("id", ResourceFieldType.ID, String.class);
        resource.addField("value", ResourceFieldType.ATTRIBUTE, String.class);
        resource.addField("parent", ResourceFieldType.RELATIONSHIP, Resource.class).oppositeResourceType(resourceType).oppositeName("children");
        resource.addField("children", ResourceFieldType.RELATIONSHIP, List.class).oppositeResourceType(resourceType).oppositeName("parent");
        context.addRegistryEntry(builder.build());
    }
}
Also used : InformationBuilder(io.crnk.core.engine.information.InformationBuilder) RegistryEntryBuilder(io.crnk.core.engine.registry.RegistryEntryBuilder)

Example 3 with RegistryEntryBuilder

use of io.crnk.core.engine.registry.RegistryEntryBuilder in project crnk-framework by crnk-project.

the class MetaModuleTest method createRegistryEntry.

private RegistryEntry createRegistryEntry() {
    ModuleRegistry moduleRegistry = boot.getModuleRegistry();
    RegistryEntryBuilder entryBuilder = moduleRegistry.getContext().newRegistryEntryBuilder();
    entryBuilder.resource().resourceClass(Task.class).resourceType("someNewTask");
    entryBuilder.resourceRepository().instance(new TaskRepository());
    return entryBuilder.build();
}
Also used : Task(io.crnk.test.mock.models.Task) RegistryEntryBuilder(io.crnk.core.engine.registry.RegistryEntryBuilder) TaskRepository(io.crnk.test.mock.repository.TaskRepository) ModuleRegistry(io.crnk.core.module.ModuleRegistry)

Aggregations

RegistryEntryBuilder (io.crnk.core.engine.registry.RegistryEntryBuilder)3 InformationBuilder (io.crnk.core.engine.information.InformationBuilder)1 DefaultRegistryEntryBuilder (io.crnk.core.engine.internal.registry.DefaultRegistryEntryBuilder)1 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1 Task (io.crnk.test.mock.models.Task)1 TaskRepository (io.crnk.test.mock.repository.TaskRepository)1