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);
}
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());
}
}
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();
}
Aggregations