use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class OperationsModule method enrichTypeIdInformation.
private void enrichTypeIdInformation(List<Operation> operations) {
ResourceRegistry resourceRegistry = moduleContext.getResourceRegistry();
for (Operation operation : operations) {
if (operation.getOp().equalsIgnoreCase(HttpMethod.DELETE.toString())) {
String path = OperationParameterUtils.parsePath(operation.getPath());
JsonPath jsonPath = (new PathBuilder(resourceRegistry)).build(path);
Resource resource = new Resource();
resource.setType(jsonPath.getResourceType());
resource.setId(jsonPath.getIds().getIds().get(0));
operation.setValue(resource);
}
}
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class RepositoryRequestSpecImpl method getResponseResourceInformation.
@Override
public ResourceInformation getResponseResourceInformation() {
if (relationshipField != null) {
String oppositeResourceType = relationshipField.getOppositeResourceType();
ResourceRegistry resourceRegistry = moduleRegistry.getResourceRegistry();
RegistryEntry entry = resourceRegistry.getEntry(oppositeResourceType);
return entry.getResourceInformation();
}
return owningResourceInformation;
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class HttpRequestProcessorImpl method getRequestedResource.
private ResourceInformation getRequestedResource(JsonPath jsonPath) {
ResourceRegistry resourceRegistry = moduleRegistry.getResourceRegistry();
RegistryEntry registryEntry = resourceRegistry.getEntry(jsonPath.getResourceType());
PreconditionUtil.assertNotNull("repository not found, that should have been catched earlier", registryEntry);
String elementName = jsonPath.getElementName();
if (elementName != null && !elementName.equals(jsonPath.getResourceType())) {
ResourceField relationshipField = registryEntry.getResourceInformation().findRelationshipFieldByName(elementName);
if (relationshipField == null) {
throw new ResourceFieldNotFoundException(elementName);
}
String oppositeResourceType = relationshipField.getOppositeResourceType();
return resourceRegistry.getEntry(oppositeResourceType).getResourceInformation();
} else {
return registryEntry.getResourceInformation();
}
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class MetaModule method initRefreshListener.
private void initRefreshListener() {
ResourceRegistry resourceRegistry = context.getResourceRegistry();
resourceRegistry.addListener(new ResourceRegistryPartAdapter() {
@Override
public void onChanged(ResourceRegistryPartEvent event) {
currentLookup = null;
}
});
}
use of io.crnk.core.engine.registry.ResourceRegistry in project crnk-framework by crnk-project.
the class DecoratorTest method testRelationshipRegistryAwareDecoration.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testRelationshipRegistryAwareDecoration() {
RegistryAwareRelationshipRepository repository = Mockito.mock(RegistryAwareRelationshipRepository.class);
RelationshipRepositoryDecoratorBase<Schedule, Long, Task, Long> decorator = new RelationshipRepositoryDecoratorBase() {
};
decorator.setDecoratedObject(repository);
ResourceRegistry resourceRegistry = Mockito.mock(ResourceRegistry.class);
decorator.setResourceRegistry(resourceRegistry);
Mockito.verify(repository, Mockito.times(1)).setResourceRegistry(Mockito.eq(resourceRegistry));
}
Aggregations