CCM NG: Abstrakte Methode getIdAttributeName in AbstractEntityRepository erstellen (#2804)
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5253 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
6e3e2fb8f3
commit
9dd1f85014
|
|
@ -60,6 +60,8 @@ import javax.transaction.Transactional;
|
|||
public class AssetRepository
|
||||
extends AbstractAuditedEntityRepository<Long, Asset> {
|
||||
|
||||
private static final long serialVersionUID = 7190032071018013125L;
|
||||
|
||||
private static final Logger LOGGER = LogManager
|
||||
.getLogger(AssetRepository.class);
|
||||
|
||||
|
|
@ -97,6 +99,11 @@ public class AssetRepository
|
|||
return Asset.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Asset asset) {
|
||||
return asset.getObjectId() == 0;
|
||||
|
|
@ -200,7 +207,8 @@ public class AssetRepository
|
|||
|
||||
final List<Permission> permissions = asset.getPermissions();
|
||||
for (final Permission permission : permissions) {
|
||||
permissionManager.revokePrivilege(permission.getGrantedPrivilege(),
|
||||
permissionManager.revokePrivilege(permission
|
||||
.getGrantedPrivilege(),
|
||||
permission.getGrantee(),
|
||||
asset);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,11 @@ public class ContentItemRepository
|
|||
return ContentItem.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final ContentItem item) {
|
||||
return ccmObjectRepo.isNew(item);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ import javax.transaction.Transactional;
|
|||
public class ContentSectionRepository
|
||||
extends AbstractEntityRepository<Long, ContentSection> {
|
||||
|
||||
private static final long serialVersionUID = 4616599498399330865L;
|
||||
|
||||
public Optional<ContentSection> findByLabel(final String label) {
|
||||
if (label == null || label.isEmpty()) {
|
||||
throw new IllegalArgumentException(
|
||||
|
|
@ -62,6 +64,11 @@ public class ContentSectionRepository
|
|||
return ContentSection.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final ContentSection section) {
|
||||
return section.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,11 @@ public class ContentTypeRepository
|
|||
return ContentType.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final ContentType type) {
|
||||
return type.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ import javax.transaction.Transactional;
|
|||
@RequestScoped
|
||||
public class FolderRepository extends AbstractEntityRepository<Long, Folder> {
|
||||
|
||||
private static final long serialVersionUID = -2588848483908283604L;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
FolderRepository.class);
|
||||
|
||||
|
|
@ -54,6 +56,11 @@ public class FolderRepository extends AbstractEntityRepository<Long, Folder> {
|
|||
return Folder.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Folder folder) {
|
||||
return folder.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -35,11 +35,18 @@ import javax.transaction.Transactional;
|
|||
public class MultiPartArticleSectionRepository
|
||||
extends AbstractAuditedEntityRepository<Long, MultiPartArticleSection> {
|
||||
|
||||
private static final long serialVersionUID = -3392120236224057234L;
|
||||
|
||||
@Override
|
||||
public Long getEntityId(final MultiPartArticleSection entity) {
|
||||
return entity.getSectionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "sectionId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<MultiPartArticleSection> getEntityClass() {
|
||||
return MultiPartArticleSection.class;
|
||||
|
|
|
|||
|
|
@ -28,18 +28,23 @@ import javax.enterprise.context.RequestScoped;
|
|||
*/
|
||||
@RequestScoped
|
||||
public class LifecycleDefinitionRepository
|
||||
extends AbstractEntityRepository<Long, LifecycleDefinition>{
|
||||
extends AbstractEntityRepository<Long, LifecycleDefinition> {
|
||||
|
||||
private static final long serialVersionUID = -6388883975391235155L;
|
||||
|
||||
@Override
|
||||
public Class<LifecycleDefinition> getEntityClass() {
|
||||
return LifecycleDefinition.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "definitionId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final LifecycleDefinition lifecycleDefinition) {
|
||||
return lifecycleDefinition.getDefinitionId() == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ public class LifecycleRepository extends AbstractEntityRepository<Long, Lifecycl
|
|||
return Lifecycle.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "lifecycleId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Lifecycle lifecycle) {
|
||||
return lifecycle.getLifecycleId() == 0;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ public class PhaseDefinititionRepository
|
|||
return PhaseDefinition.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "definitionId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final PhaseDefinition phaseDefinition) {
|
||||
return phaseDefinition.getDefinitionId() == 0;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import javax.enterprise.context.RequestScoped;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class PhaseRepository extends AbstractEntityRepository<Long, Phase>{
|
||||
public class PhaseRepository extends AbstractEntityRepository<Long, Phase> {
|
||||
|
||||
private static final long serialVersionUID = 1010039772043186415L;
|
||||
|
||||
|
|
@ -36,6 +36,11 @@ public class PhaseRepository extends AbstractEntityRepository<Long, Phase>{
|
|||
return Phase.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "phaseId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Phase phase) {
|
||||
return phase.getPhaseId() == 0;
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@ public class PageRepository extends AbstractEntityRepository<Long, Page> {
|
|||
return Page.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Page page) {
|
||||
return page.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,11 @@ public class PagesRepository extends AbstractEntityRepository<Long, Pages> {
|
|||
return Pages.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Pages pages) {
|
||||
return pages.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@ public class CategoryRepository extends AbstractEntityRepository<Long, Category>
|
|||
return Category.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Category entity) {
|
||||
return entity.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
|||
return Domain.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Domain entity) {
|
||||
return entity.getObjectId() == 0;
|
||||
|
|
@ -79,11 +84,11 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
|||
*/
|
||||
public Optional<Domain> findByDomainKey(final String domainKey) {
|
||||
final TypedQuery<Domain> query = getEntityManager()
|
||||
.createNamedQuery("Domain.findByKey", Domain.class);
|
||||
.createNamedQuery("Domain.findByKey", Domain.class);
|
||||
query.setParameter("key", domainKey);
|
||||
|
||||
final EntityGraph<?> graph = getEntityManager()
|
||||
.getEntityGraph( "Domain.allCategories");
|
||||
.getEntityGraph("Domain.allCategories");
|
||||
query.setHint("javax.persistence.fetchgraph", graph);
|
||||
|
||||
try {
|
||||
|
|
@ -103,7 +108,7 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
|||
*/
|
||||
public Domain findByUri(final URI uri) {
|
||||
final TypedQuery<Domain> query = getEntityManager()
|
||||
.createNamedQuery("Domain.findByUri", Domain.class);
|
||||
.createNamedQuery("Domain.findByUri", Domain.class);
|
||||
query.setParameter("uri", uri);
|
||||
|
||||
return query.getSingleResult();
|
||||
|
|
@ -118,7 +123,7 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
|||
*/
|
||||
public Optional<Domain> findByUuid(final String uuid) {
|
||||
final TypedQuery<Domain> query = getEntityManager()
|
||||
.createNamedQuery("Domain.findByUuid", Domain.class);
|
||||
.createNamedQuery("Domain.findByUuid", Domain.class);
|
||||
query.setParameter("uuid", uuid);
|
||||
|
||||
try {
|
||||
|
|
@ -130,10 +135,10 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
|||
|
||||
public List<Domain> search(final String term) {
|
||||
final TypedQuery<Domain> query = getEntityManager()
|
||||
.createNamedQuery("Domain.search", Domain.class);
|
||||
.createNamedQuery("Domain.search", Domain.class);
|
||||
query.setParameter("term", term);
|
||||
final EntityGraph<?> graph = getEntityManager()
|
||||
.getEntityGraph("Domain.withOwners");
|
||||
.getEntityGraph("Domain.withOwners");
|
||||
query.setHint("javax.persistence.fetchgraph", graph);
|
||||
|
||||
return query.getResultList();
|
||||
|
|
|
|||
|
|
@ -124,6 +124,14 @@ public abstract class AbstractEntityRepository<K, E> implements Serializable {
|
|||
*/
|
||||
public abstract Class<E> getEntityClass();
|
||||
|
||||
/**
|
||||
* Used by some methods to create queries using the JPA Criteria API.
|
||||
*
|
||||
* @return The name of the ID attribute/property for entities managed by
|
||||
* a repository.
|
||||
*/
|
||||
public abstract String getIdAttributeName();
|
||||
|
||||
/**
|
||||
* Finds an entity by it ID.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ public class CcmObjectRepository extends AbstractEntityRepository<Long, CcmObjec
|
|||
return CcmObject.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final CcmObject entity) {
|
||||
if (entity == null) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ public class ResourceRepository extends AbstractEntityRepository<Long,
|
|||
return Resource.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Resource entity) {
|
||||
return entity.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ import java.util.Optional;
|
|||
* {@link ResourceType}s from the database. This is the responsibility of the
|
||||
* application using the {@link ResourceType}.
|
||||
*
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 8/10/17
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
*
|
||||
*/
|
||||
@RequestScoped
|
||||
public class ResourceTypeRepository extends AbstractEntityRepository<Long,
|
||||
ResourceType> {
|
||||
public class ResourceTypeRepository
|
||||
extends AbstractEntityRepository<Long, ResourceType> {
|
||||
|
||||
private static final long serialVersionUID = -6313169146990554867L;
|
||||
|
||||
|
|
@ -44,6 +44,11 @@ public class ResourceTypeRepository extends AbstractEntityRepository<Long,
|
|||
return ResourceType.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "resourceTypeId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final ResourceType entity) {
|
||||
return entity.getTitle() == null;
|
||||
|
|
@ -58,7 +63,7 @@ public class ResourceTypeRepository extends AbstractEntityRepository<Long,
|
|||
*/
|
||||
public Optional<ResourceType> findByTitle(final String title) {
|
||||
final TypedQuery<ResourceType> query = getEntityManager()
|
||||
.createNamedQuery("ResourceType.findByTitle", ResourceType.class);
|
||||
.createNamedQuery("ResourceType.findByTitle", ResourceType.class);
|
||||
query.setParameter("title", title);
|
||||
|
||||
try {
|
||||
|
|
@ -67,4 +72,5 @@ public class ResourceTypeRepository extends AbstractEntityRepository<Long,
|
|||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import java.util.UUID;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class ComponentModelRepository extends AbstractEntityRepository<Long, ComponentModel> {
|
||||
public class ComponentModelRepository
|
||||
extends AbstractEntityRepository<Long, ComponentModel> {
|
||||
|
||||
private static final long serialVersionUID = -6358512316472857971L;
|
||||
|
||||
|
|
@ -42,6 +43,11 @@ public class ComponentModelRepository extends AbstractEntityRepository<Long, Com
|
|||
return ComponentModel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "componentModelId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final ComponentModel componentModel) {
|
||||
return componentModel.getComponentModelId() == 0;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
|||
return PageModel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "pageModelId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final PageModel pageModel) {
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ public class GroupRepository extends AbstractEntityRepository<Long, Group> {
|
|||
return Group.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "partyId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Group entity) {
|
||||
if (entity == null) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ public class PartyRepository extends AbstractEntityRepository<Long, Party> {
|
|||
return Party.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "partyId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Party entity) {
|
||||
if (entity == null) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import java.util.Optional;
|
|||
*/
|
||||
@RequestScoped
|
||||
public class PermissionRepository
|
||||
extends AbstractEntityRepository<Long, Permission> {
|
||||
extends AbstractEntityRepository<Long, Permission> {
|
||||
|
||||
private static final long serialVersionUID = -4240674229117593486L;
|
||||
|
||||
|
|
@ -42,6 +42,11 @@ public class PermissionRepository
|
|||
return Permission.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "permissionId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(Permission entity) {
|
||||
if (entity == null) {
|
||||
|
|
@ -51,25 +56,27 @@ public class PermissionRepository
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link Permission} by the privilege, the grantee and the
|
||||
* object. Where the grantee has been granted the given privilege on the
|
||||
* given object.
|
||||
* Finds a {@link Permission} by the privilege, the grantee and the object.
|
||||
* Where the grantee has been granted the given privilege on the given
|
||||
* object.
|
||||
*
|
||||
* @param privilege The privilege, beeing granted
|
||||
* @param grantee The grantee, having the privilege
|
||||
* @param object The object, the privilege has been granted on
|
||||
* @param grantee The grantee, having the privilege
|
||||
* @param object The object, the privilege has been granted on
|
||||
*
|
||||
* @return An optional either with the found item or empty
|
||||
*/
|
||||
public Optional<Permission> findByCustomPermId(final String privilege,
|
||||
final Role grantee,
|
||||
final Object object) {
|
||||
final TypedQuery<Permission> query = getEntityManager().createNamedQuery(
|
||||
final TypedQuery<Permission> query = getEntityManager()
|
||||
.createNamedQuery(
|
||||
"Permission.findByCustomPermId", Permission.class);
|
||||
query.setParameter("privilege", privilege);
|
||||
query.setParameter("grantee", grantee);
|
||||
if (object != null)
|
||||
if (object != null) {
|
||||
query.setParameter("object", object);
|
||||
}
|
||||
|
||||
try {
|
||||
return Optional.of(query.getSingleResult());
|
||||
|
|
@ -77,4 +84,5 @@ public class PermissionRepository
|
|||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ public class RoleRepository extends AbstractEntityRepository<Long, Role> {
|
|||
return Role.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "roleId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Role entity) {
|
||||
if (entity == null) {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,11 @@ public class UserRepository extends AbstractEntityRepository<Long, User> {
|
|||
return User.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "partyId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final User user) {
|
||||
if (user == null) {
|
||||
|
|
|
|||
|
|
@ -123,6 +123,11 @@ public class SiteRepository extends AbstractEntityRepository<Long, Site> {
|
|||
return Site.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Site site) {
|
||||
return site.getObjectId() == 0;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ public class ApplicationRepository
|
|||
return CcmApplication.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final CcmApplication application) {
|
||||
return application.getObjectId() == 0;
|
||||
|
|
@ -108,8 +113,8 @@ public class ApplicationRepository
|
|||
*/
|
||||
public Optional<CcmApplication> findByUuid(final String uuid) {
|
||||
final TypedQuery<CcmApplication> query = getEntityManager()
|
||||
.createNamedQuery("CcmApplication.findByUuid",
|
||||
CcmApplication.class);
|
||||
.createNamedQuery("CcmApplication.findByUuid",
|
||||
CcmApplication.class);
|
||||
query.setParameter("uuid", uuid);
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -36,8 +36,9 @@ import java.util.stream.Collectors;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class AssignableTaskRepository extends AbstractEntityRepository<Long,
|
||||
AssignableTask> {
|
||||
public class AssignableTaskRepository
|
||||
extends AbstractEntityRepository<Long, AssignableTask> {
|
||||
|
||||
private static final long serialVersionUID = 2657793145163510103L;
|
||||
|
||||
@Override
|
||||
|
|
@ -45,6 +46,11 @@ public class AssignableTaskRepository extends AbstractEntityRepository<Long,
|
|||
return AssignableTask.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "taskId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final AssignableTask task) {
|
||||
return task.getTaskId() == 0;
|
||||
|
|
|
|||
|
|
@ -27,11 +27,12 @@ import java.util.Optional;
|
|||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
|
||||
* @version created the 9/27/17
|
||||
*
|
||||
*/
|
||||
@RequestScoped
|
||||
public class TaskCommentRepository extends AbstractEntityRepository<Long,
|
||||
TaskComment> {
|
||||
public class TaskCommentRepository
|
||||
extends AbstractEntityRepository<Long, TaskComment> {
|
||||
|
||||
private static final long serialVersionUID = -420902242220205847L;
|
||||
|
||||
@Override
|
||||
|
|
@ -39,6 +40,11 @@ public class TaskCommentRepository extends AbstractEntityRepository<Long,
|
|||
return TaskComment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "commentId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(TaskComment entity) {
|
||||
return entity.getCommentId() == 0;
|
||||
|
|
@ -62,4 +68,5 @@ public class TaskCommentRepository extends AbstractEntityRepository<Long,
|
|||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import java.util.UUID;
|
|||
*/
|
||||
@RequestScoped
|
||||
public class TaskRepository extends AbstractEntityRepository<Long, Task> {
|
||||
|
||||
private static final long serialVersionUID = -8366096936911158514L;
|
||||
|
||||
@Override
|
||||
|
|
@ -41,6 +42,11 @@ public class TaskRepository extends AbstractEntityRepository<Long, Task> {
|
|||
return Task.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "taskId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Task task) {
|
||||
return task.getTaskId() == 0;
|
||||
|
|
@ -62,7 +68,7 @@ public class TaskRepository extends AbstractEntityRepository<Long, Task> {
|
|||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Optional<Task> findByUuid(final String uuid) {
|
||||
final TypedQuery<Task> query = getEntityManager().createNamedQuery(
|
||||
"Task.findByUuid", Task.class);
|
||||
"Task.findByUuid", Task.class);
|
||||
query.setParameter("uuid", uuid);
|
||||
|
||||
try {
|
||||
|
|
@ -71,4 +77,5 @@ public class TaskRepository extends AbstractEntityRepository<Long, Task> {
|
|||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import java.util.UUID;
|
|||
*/
|
||||
@RequestScoped
|
||||
public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow> {
|
||||
|
||||
private static final long serialVersionUID = -8811728904958517569L;
|
||||
|
||||
@Override
|
||||
|
|
@ -41,6 +42,11 @@ public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow>
|
|||
return Workflow.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "workflowId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Workflow workflow) {
|
||||
return workflow.getWorkflowId() == 0;
|
||||
|
|
@ -67,12 +73,12 @@ public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow>
|
|||
}
|
||||
|
||||
final TypedQuery<Workflow> query = getEntityManager()
|
||||
.createNamedQuery("Workflow.findByUuid", Workflow.class);
|
||||
.createNamedQuery("Workflow.findByUuid", Workflow.class);
|
||||
query.setParameter("uuid", uuid);
|
||||
|
||||
try {
|
||||
return Optional.of(query.getSingleResult());
|
||||
} catch(NoResultException ex) {
|
||||
} catch (NoResultException ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@ import javax.persistence.Lob;
|
|||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Blob;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.libreccm.docrepo;
|
||||
|
||||
|
||||
import org.libreccm.auditing.AbstractAuditedEntityRepository;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
|
@ -33,7 +32,7 @@ import javax.persistence.EntityManager;
|
|||
*/
|
||||
@RequestScoped
|
||||
public class BlobObjectRepository extends
|
||||
AbstractAuditedEntityRepository<Long, BlobObject> {
|
||||
AbstractAuditedEntityRepository<Long, BlobObject> {
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
|
@ -43,6 +42,11 @@ public class BlobObjectRepository extends
|
|||
return entity.getBlobObjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "blobObjectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BlobObject> getEntityClass() {
|
||||
return BlobObject.class;
|
||||
|
|
@ -55,4 +59,5 @@ public class BlobObjectRepository extends
|
|||
}
|
||||
return entity.getBlobObjectId() == 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,27 +34,33 @@ public class FileRepository extends AbstractResourceRepository<File> {
|
|||
classOfT = File.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<File> getFindByNameQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findFileByName", File.class);
|
||||
"DocRepo.findFileByName", File.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<File> getFindByPathNameQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findFileByPath", File.class);
|
||||
"DocRepo.findFileByPath", File.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<File> getFindForCreatorQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findCreatedFileFromUser", File.class);
|
||||
"DocRepo.findCreatedFileFromUser", File.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<File> getFindForModifierQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findModifiedFileFromUser", File.class);
|
||||
"DocRepo.findModifiedFileFromUser", File.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,27 +34,33 @@ public class FolderRepository extends AbstractResourceRepository<Folder> {
|
|||
classOfT = Folder.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<Folder> getFindByNameQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findFolderByName", Folder.class);
|
||||
"DocRepo.findFolderByName", Folder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<Folder> getFindByPathNameQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findFolderByPath", Folder.class);
|
||||
"DocRepo.findFolderByPath", Folder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<Folder> getFindForCreatorQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findCreatedFolderFromUser", Folder.class);
|
||||
"DocRepo.findCreatedFolderFromUser", Folder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedQuery<Folder> getFindForModifierQuery() {
|
||||
return entityManager.createNamedQuery(
|
||||
"DocRepo.findModifiedFolderFromUser", Folder.class);
|
||||
"DocRepo.findModifiedFolderFromUser", Folder.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,11 +34,10 @@ import java.util.stream.Collectors;
|
|||
* Repository class for retrieving, storing and deleting {@code Repository}s.
|
||||
*
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
|
||||
* @version 25/11/2015
|
||||
*/
|
||||
@RequestScoped
|
||||
public class RepositoryRepository extends
|
||||
AbstractAuditedEntityRepository<Long, Repository> {
|
||||
public class RepositoryRepository
|
||||
extends AbstractAuditedEntityRepository<Long, Repository> {
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
|
@ -48,6 +47,11 @@ public class RepositoryRepository extends
|
|||
return entity.getObjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "objectId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Repository> getEntityClass() {
|
||||
return Repository.class;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@ public class ShortcutRepository extends AbstractEntityRepository<Long, Shortcut>
|
|||
return Shortcut.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAttributeName() {
|
||||
return "shortcutId";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew(final Shortcut entity) {
|
||||
return entity.getShortcutId() == 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue