use of io.crnk.core.engine.information.contributor.ResourceFieldContributorContext 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);
}
}
Aggregations