use of io.crnk.core.engine.information.repository.RepositoryAction in project crnk-framework by crnk-project.
the class ResourceMetaParitition method discoverRepository.
private MetaResourceRepository discoverRepository(ResourceRepositoryInformation repositoryInformation, MetaResource metaResource, ResourceRepositoryAdapter<?, Serializable> resourceRepository) {
MetaResourceRepository meta = new MetaResourceRepository();
meta.setResourceType(metaResource);
meta.setName(metaResource.getName() + "$repository");
meta.setId(metaResource.getId() + "$repository");
for (RepositoryAction action : repositoryInformation.getActions().values()) {
MetaResourceAction metaAction = new MetaResourceAction();
metaAction.setName(action.getName());
metaAction.setActionType(MetaResourceAction.MetaRepositoryActionType.valueOf(action.getActionType().toString()));
metaAction.setParent(meta, true);
}
// TODO avoid use of ResourceRepositoryAdapter by enriching ResourceRepositoryInformation
Object repository = resourceRepository.getResourceRepository();
if (repository instanceof ResourceRepositoryV2) {
setListInformationTypes(repository, meta);
}
return meta;
}
use of io.crnk.core.engine.information.repository.RepositoryAction in project crnk-framework by crnk-project.
the class JaxrsModuleTest method testActionDetection.
@Test
public void testActionDetection() {
ResourceRepositoryInformation information = (ResourceRepositoryInformation) builder.build(TaskRepository.class, context);
Map<String, RepositoryAction> actions = information.getActions();
Assert.assertEquals(5, actions.size());
RepositoryAction action = actions.get("repositoryAction");
Assert.assertNotNull(actions.get("repositoryPostAction"));
Assert.assertNotNull(actions.get("repositoryDeleteAction"));
Assert.assertNotNull(actions.get("repositoryPutAction"));
Assert.assertNull(actions.get("notAnAction"));
Assert.assertNotNull(action);
Assert.assertEquals("repositoryAction", action.getName());
Assert.assertEquals(RepositoryActionType.REPOSITORY, action.getActionType());
Assert.assertEquals(RepositoryActionType.RESOURCE, actions.get("resourceAction").getActionType());
}
Aggregations