Search in sources :

Example 1 with RepositoryAction

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;
}
Also used : ResourceRepositoryV2(io.crnk.core.repository.ResourceRepositoryV2) MetaDataObject(io.crnk.meta.model.MetaDataObject) RepositoryAction(io.crnk.core.engine.information.repository.RepositoryAction)

Example 2 with RepositoryAction

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());
}
Also used : ResourceRepositoryInformation(io.crnk.core.engine.information.repository.ResourceRepositoryInformation) RepositoryAction(io.crnk.core.engine.information.repository.RepositoryAction) Test(org.junit.Test)

Aggregations

RepositoryAction (io.crnk.core.engine.information.repository.RepositoryAction)2 ResourceRepositoryInformation (io.crnk.core.engine.information.repository.ResourceRepositoryInformation)1 ResourceRepositoryV2 (io.crnk.core.repository.ResourceRepositoryV2)1 MetaDataObject (io.crnk.meta.model.MetaDataObject)1 Test (org.junit.Test)1