Search in sources :

Example 31 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class SecurityModuleIntTest method getPostOnly.

@Test
public void getPostOnly() {
    identityManager.addUser("doe", "doePass", "getRole", "postRole");
    Project project = new Project();
    project.setId(1L);
    project.setName("test");
    projectRepo.create(project);
    project = projectRepo.findOne(project.getId(), new QuerySpec(Project.class));
    Assert.assertNotNull(project);
}
Also used : Project(io.crnk.security.model.Project) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 32 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class SecurityModuleIntTest method permitAllMatchAnyType.

@Test
public void permitAllMatchAnyType() {
    identityManager.addUser("doe", "doePass");
    projectRepo.findAll(new QuerySpec(Project.class));
}
Also used : Project(io.crnk.security.model.Project) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 33 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class QuerySpecAdapter method getIncludedRelations.

@Override
public TypedParams<IncludedRelationsParams> getIncludedRelations() {
    Map<String, IncludedRelationsParams> params = new HashMap<>();
    addRelations(params, querySpec);
    for (QuerySpec relatedSpec : querySpec.getNestedSpecs()) {
        addRelations(params, relatedSpec);
    }
    return new TypedParams<>(params);
}
Also used : HashMap(java.util.HashMap) TypedParams(io.crnk.legacy.queryParams.params.TypedParams) IncludedRelationsParams(io.crnk.legacy.queryParams.params.IncludedRelationsParams) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 34 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class RelationshipRepositoryBase method getTargets.

@SuppressWarnings("unchecked")
protected Iterable<D> getTargets(RegistryEntry entry, Iterable<J> targetIds) {
    ResourceRepositoryAdapter<D, J> targetAdapter = entry.getResourceRepository();
    QueryAdapter queryAdapter = new QuerySpecAdapter(new QuerySpec(entry.getResourceInformation()), resourceRegistry);
    return (Iterable<D>) targetAdapter.findAll(targetIds, queryAdapter).getEntity();
}
Also used : QueryAdapter(io.crnk.core.engine.query.QueryAdapter) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 35 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class RelationshipRepositoryBase method getSaveQueryAdapter.

protected QueryAdapter getSaveQueryAdapter(String fieldName) {
    QuerySpec querySpec = newSourceQuerySpec();
    querySpec.includeRelation(Arrays.asList(fieldName));
    return new QuerySpecAdapter(querySpec, resourceRegistry);
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter)

Aggregations

QuerySpec (io.crnk.core.queryspec.QuerySpec)306 Test (org.junit.Test)233 FilterSpec (io.crnk.core.queryspec.FilterSpec)51 Document (io.crnk.core.engine.document.Document)45 Resource (io.crnk.core.engine.document.Resource)43 Set (java.util.Set)39 HashMap (java.util.HashMap)37 HashSet (java.util.HashSet)36 AbstractQuerySpecTest (io.crnk.core.queryspec.AbstractQuerySpecTest)34 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)32 AbstractJpaJerseyTest (io.crnk.jpa.AbstractJpaJerseyTest)32 Task (io.crnk.test.mock.models.Task)32 Project (io.crnk.core.mock.models.Project)28 Relationship (io.crnk.core.engine.document.Relationship)26 Task (io.crnk.core.mock.models.Task)26 TestEntity (io.crnk.jpa.model.TestEntity)26 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)25 Serializable (java.io.Serializable)24 RelatedEntity (io.crnk.jpa.model.RelatedEntity)21 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)20