Search in sources :

Example 1 with Relation

use of io.crnk.core.mock.repository.util.Relation in project crnk-framework by crnk-project.

the class ProjectToTaskRepository method findOneTarget.

@Override
public Task findOneTarget(Long sourceId, String fieldName, QueryParams queryParams) {
    Map<Relation<Project>, Integer> repo = getRepo();
    for (Relation<Project> relation : repo.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Task task = new Task();
            task.setId((Long) relation.getTargetId());
            return task;
        }
    }
    return null;
}
Also used : Project(io.crnk.core.mock.models.Project) Relation(io.crnk.core.mock.repository.util.Relation) Task(io.crnk.core.mock.models.Task)

Example 2 with Relation

use of io.crnk.core.mock.repository.util.Relation in project crnk-framework by crnk-project.

the class ProjectToProjectEagerRepository method findOneTarget.

@Override
public ProjectEager findOneTarget(Long sourceId, String fieldName, QueryParams queryParams) {
    Map<Relation<Project>, Integer> repo = getRepo();
    for (Relation<Project> relation : repo.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            ProjectEager task = new ProjectEager();
            task.setId((Long) relation.getTargetId());
            return task;
        }
    }
    return null;
}
Also used : Project(io.crnk.core.mock.models.Project) Relation(io.crnk.core.mock.repository.util.Relation) ProjectEager(io.crnk.core.mock.models.ProjectEager)

Example 3 with Relation

use of io.crnk.core.mock.repository.util.Relation in project crnk-framework by crnk-project.

the class TaskToProjectRepository method findOneTarget.

@Override
public Project findOneTarget(Long sourceId, String fieldName, QueryParams queryParams) {
    Map<Relation<Task>, Integer> repo = getRepo();
    for (Relation<Task> relation : repo.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Project project = new Project();
            if (relation.getTargetId().equals(ProjectRepository.FANCY_PROJECT_ID)) {
                project = new FancyProject();
            }
            project.setId((Long) relation.getTargetId());
            return project;
        }
    }
    return null;
}
Also used : FancyProject(io.crnk.core.mock.models.FancyProject) Project(io.crnk.core.mock.models.Project) Relation(io.crnk.core.mock.repository.util.Relation) Task(io.crnk.core.mock.models.Task) FancyProject(io.crnk.core.mock.models.FancyProject)

Aggregations

Project (io.crnk.core.mock.models.Project)3 Relation (io.crnk.core.mock.repository.util.Relation)3 Task (io.crnk.core.mock.models.Task)2 FancyProject (io.crnk.core.mock.models.FancyProject)1 ProjectEager (io.crnk.core.mock.models.ProjectEager)1