-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- DTO mapping support with JpaModule.addMappedEntityClass - JpaMapper class to map entities to DTO and back - JpaMapper makes use of Tuple API to support computed attributes - virtual attributes renamed to computed attributes - JpaRepositoryFilter to intercept most stages within the jpa repository to allow further customization - JpaModule.addFilter(...) to register filters - test case showning use of computed attributes and dto mappers - subquery comparable fix/workaround for computed attrs - JpaModule constructors replaced by static create methods pending: - optimize reuse of computed attributes between select, filter and sort
- Loading branch information
Remo
authored
Oct 6, 2016
1 parent
817a67a
commit 27a7b0b
Showing
66 changed files
with
7,023 additions
and
5,630 deletions.
There are no files selected for viewing
474 changes: 255 additions & 219 deletions
474
katharsis-client/src/main/java/io/katharsis/client/internal/BaseResponseDeserializer.java
Large diffs are not rendered by default.
Oops, something went wrong.
543 changes: 273 additions & 270 deletions
543
katharsis-core/src/main/java/io/katharsis/dispatcher/controller/resource/ResourceUpsert.java
Large diffs are not rendered by default.
Oops, something went wrong.
196 changes: 98 additions & 98 deletions
196
katharsis-core/src/test/java/io/katharsis/resource/mock/models/Project.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,98 @@ | ||
package io.katharsis.resource.mock.models; | ||
|
||
import io.katharsis.resource.annotations.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@JsonApiResource(type = "projects") | ||
public class Project { | ||
|
||
@JsonApiId | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
private ProjectData data; | ||
|
||
@JsonApiToMany | ||
private List<Task> tasks = new ArrayList<>(); | ||
|
||
@JsonApiToOne | ||
private Task task; | ||
|
||
@JsonApiToOne | ||
@JsonApiIncludeByDefault | ||
private ProjectEager projectEager; | ||
|
||
@JsonApiToMany | ||
@JsonApiIncludeByDefault | ||
private List<ProjectEager> projectEagerList = new ArrayList<>(); | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Project setId(Long id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(@SuppressWarnings("SameParameterValue") String description) { | ||
this.description = description; | ||
} | ||
|
||
public ProjectData getData() { | ||
return data; | ||
} | ||
|
||
public void setData(ProjectData data) { | ||
this.data = data; | ||
} | ||
|
||
public List<Task> getTasks() { | ||
return tasks; | ||
} | ||
|
||
public void setTasks(List<Task> tasks) { | ||
this.tasks = tasks; | ||
} | ||
|
||
public Task getTask() { | ||
return task; | ||
} | ||
|
||
public void setTask(Task task) { | ||
this.task = task; | ||
} | ||
|
||
public ProjectEager getProjectEager() { | ||
return projectEager; | ||
} | ||
|
||
public void setProjectEager(ProjectEager projectEager) { | ||
this.projectEager = projectEager; | ||
} | ||
|
||
public List<ProjectEager> getProjectEagerList() { | ||
return projectEagerList; | ||
} | ||
|
||
public void setProjectEagerList(List<ProjectEager> projectEagerList) { | ||
this.projectEagerList = projectEagerList; | ||
} | ||
} | ||
package io.katharsis.resource.mock.models; | ||
|
||
import io.katharsis.resource.annotations.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@JsonApiResource(type = "projects") | ||
public class Project { | ||
|
||
@JsonApiId | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
private ProjectData data; | ||
|
||
@JsonApiToMany | ||
private List<Task> tasks = new ArrayList<>(); | ||
|
||
@JsonApiToOne | ||
private Task task; | ||
|
||
@JsonApiToOne | ||
@JsonApiIncludeByDefault | ||
private ProjectEager projectEager; | ||
|
||
@JsonApiToMany | ||
@JsonApiIncludeByDefault | ||
private List<ProjectEager> projectEagerList = new ArrayList<>(); | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Project setId(Long id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(@SuppressWarnings("SameParameterValue") String description) { | ||
this.description = description; | ||
} | ||
|
||
public ProjectData getData() { | ||
return data; | ||
} | ||
|
||
public void setData(ProjectData data) { | ||
this.data = data; | ||
} | ||
|
||
public List<Task> getTasks() { | ||
return tasks; | ||
} | ||
|
||
public void setTasks(List<Task> tasks) { | ||
this.tasks = tasks; | ||
} | ||
|
||
public Task getTask() { | ||
return task; | ||
} | ||
|
||
public void setTask(Task task) { | ||
this.task = task; | ||
} | ||
|
||
public ProjectEager getProjectEager() { | ||
return projectEager; | ||
} | ||
|
||
public void setProjectEager(ProjectEager projectEager) { | ||
this.projectEager = projectEager; | ||
} | ||
|
||
public List<ProjectEager> getProjectEagerList() { | ||
return projectEagerList; | ||
} | ||
|
||
public void setProjectEagerList(List<ProjectEager> projectEagerList) { | ||
this.projectEagerList = projectEagerList; | ||
} | ||
} |
53 changes: 34 additions & 19 deletions
53
katharsis-jpa/src/main/java/io/katharsis/jpa/DefaultJpaRepositoryFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
package io.katharsis.jpa; | ||
|
||
import java.io.Serializable; | ||
|
||
public class DefaultJpaRepositoryFactory implements JpaRepositoryFactory { | ||
|
||
@Override | ||
public <T, I extends Serializable> JpaEntityRepository<T, I> createEntityRepository(JpaModule module, | ||
Class<T> entityClass) { | ||
return new JpaEntityRepository<>(module, entityClass); | ||
} | ||
|
||
@Override | ||
public <T, I extends Serializable, D, J extends Serializable> JpaRelationshipRepository<T, I, D, J> createRelationshipRepository( | ||
JpaModule module, Class<T> entityClass, Class<D> relatedEntityClass) { | ||
return new JpaRelationshipRepository<>(module, entityClass, relatedEntityClass); | ||
} | ||
|
||
} | ||
package io.katharsis.jpa; | ||
|
||
import java.io.Serializable; | ||
|
||
import io.katharsis.jpa.mapping.JpaMapper; | ||
|
||
public class DefaultJpaRepositoryFactory implements JpaRepositoryFactory { | ||
|
||
@Override | ||
public <T, I extends Serializable> JpaEntityRepository<T, I> createEntityRepository(JpaModule module, Class<T> entityClass) { | ||
return new JpaEntityRepository<>(module, entityClass); | ||
} | ||
|
||
@Override | ||
public <T, I extends Serializable, D, J extends Serializable> JpaRelationshipRepository<T, I, D, J> createRelationshipRepository( | ||
JpaModule module, Class<T> entityClass, Class<D> relatedEntityClass) { | ||
return new JpaRelationshipRepository<>(module, entityClass, relatedEntityClass); | ||
} | ||
|
||
@Override | ||
public <E, D, I extends Serializable> JpaEntityRepository<D, I> createMappedEntityRepository(JpaModule module, | ||
Class<E> entityClass, Class<D> dtoClass, JpaMapper<E, D> mapper) { | ||
return new JpaEntityRepository<>(module, entityClass, dtoClass, mapper); | ||
} | ||
|
||
@Override | ||
public <S, I extends Serializable, T, J extends Serializable, E, F> JpaRelationshipRepository<S, I, T, J> createMappedRelationshipRepository( | ||
JpaModule module, Class<E> sourceEntityClass, Class<S> sourceResourceClass, Class<F> targetEntityClass, | ||
Class<T> targetResourceClass, JpaMapper<E, S> sourceMapper, JpaMapper<F, T> targetMapper) { | ||
return new JpaRelationshipRepository<>(module, sourceEntityClass, sourceResourceClass, targetEntityClass, | ||
targetResourceClass, sourceMapper, targetMapper); | ||
} | ||
|
||
} |
Oops, something went wrong.