CCM NG: Abstrakte Methode getIdAttributeName in AbstractEntityRepository erstellen (#2804)

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5253 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2018-02-07 13:52:57 +00:00
parent a0ba7d3d33
commit 2d37c5b2cb
37 changed files with 271 additions and 68 deletions

View File

@ -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);
}

View File

@ -115,6 +115,11 @@ public class ContentItemRepository
public Class<ContentItem> getEntityClass() {
return ContentItem.class;
}
@Override
public String getIdAttributeName() {
return "objectId";
}
@Override
public boolean isNew(final ContentItem item) {

View File

@ -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(
@ -61,6 +63,11 @@ public class ContentSectionRepository
public Class<ContentSection> getEntityClass() {
return ContentSection.class;
}
@Override
public String getIdAttributeName() {
return "objectId";
}
@Override
public boolean isNew(final ContentSection section) {

View File

@ -54,6 +54,11 @@ public class ContentTypeRepository
public Class<ContentType> getEntityClass() {
return ContentType.class;
}
@Override
public String getIdAttributeName() {
return "objectId";
}
@Override
public boolean isNew(final ContentType type) {

View File

@ -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;
@ -200,14 +207,14 @@ public class FolderRepository extends AbstractEntityRepository<Long, Folder> {
}
public List<Folder> findSubFolders(final Folder parent) {
final TypedQuery<Folder> query = getEntityManager()
.createNamedQuery("Folder.findSubFolders", Folder.class);
query.setParameter("parent", parent);
return query.getResultList();
}
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@Override

View File

@ -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;

View File

@ -27,19 +27,24 @@ import javax.enterprise.context.RequestScoped;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class LifecycleDefinitionRepository
extends AbstractEntityRepository<Long, LifecycleDefinition>{
public class LifecycleDefinitionRepository
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;
}
}

View File

@ -33,6 +33,11 @@ public class LifecycleRepository extends AbstractEntityRepository<Long, Lifecycl
public Class<Lifecycle> getEntityClass() {
return Lifecycle.class;
}
@Override
public String getIdAttributeName() {
return "lifecycleId";
}
@Override
public boolean isNew(final Lifecycle lifecycle) {

View File

@ -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;

View File

@ -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,9 +36,14 @@ 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;
}
}

View File

@ -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;

View File

@ -82,16 +82,21 @@ 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;
}
@Override
public void initNewEntity(final Pages pages) {
super.initNewEntity(pages);
pages.setUuid(UUID.randomUUID().toString());
pages.setApplicationType(Pages.class.getName());
}

View File

@ -65,6 +65,11 @@ public class CategoryRepository extends AbstractEntityRepository<Long, Category>
public Class<Category> getEntityClass() {
return Category.class;
}
@Override
public String getIdAttributeName() {
return "objectId";
}
@Override
public boolean isNew(final Category entity) {

View File

@ -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();

View File

@ -123,6 +123,14 @@ public abstract class AbstractEntityRepository<K, E> implements Serializable {
* repository.
*/
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.

View File

@ -50,6 +50,11 @@ public class CcmObjectRepository extends AbstractEntityRepository<Long, CcmObjec
public Class<CcmObject> getEntityClass() {
return CcmObject.class;
}
@Override
public String getIdAttributeName() {
return "objectId";
}
@Override
public boolean isNew(final CcmObject entity) {

View File

@ -44,6 +44,11 @@ public class ResourceRepository extends AbstractEntityRepository<Long,
public Class<Resource> getEntityClass() {
return Resource.class;
}
@Override
public String getIdAttributeName() {
return "objectId";
}
@Override
public boolean isNew(final Resource entity) {

View File

@ -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();
}
}
}

View File

@ -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;

View File

@ -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) {

View File

@ -41,6 +41,11 @@ public class GroupRepository extends AbstractEntityRepository<Long, Group> {
public Class<Group> getEntityClass() {
return Group.class;
}
@Override
public String getIdAttributeName() {
return "partyId";
}
@Override
public boolean isNew(final Group entity) {

View File

@ -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) {

View File

@ -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();
}
}
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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;

View File

@ -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;
@ -54,12 +59,12 @@ public class ApplicationRepository
@Override
public void initNewEntity(final CcmApplication application) {
super.initNewEntity(application);
application.setUuid(UUID.randomUUID().toString());
application.setApplicationType(application.getClass().getName());
}
/**
* Retrieve the application mounted at the provided {@code path}.
*
@ -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 {
@ -118,7 +123,7 @@ public class ApplicationRepository
return Optional.empty();
}
}
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -126,7 +131,7 @@ public class ApplicationRepository
public void save(final CcmApplication application) {
super.save(application);
}
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)

View File

@ -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;

View File

@ -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();
}
}
}

View File

@ -29,11 +29,12 @@ import java.util.UUID;
/**
* Repository for {@link Task}s.
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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();
}
}
}

View File

@ -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;
@ -65,14 +71,14 @@ public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow>
throw new IllegalArgumentException(
"The UUID of the Workflow to retrieve can't be null or empty.");
}
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();
}
}

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -34,7 +34,7 @@ import javax.transaction.Transactional;
/**
* Repository class for {@link Shortcut} entities.
*
*
* @author <a href="konerman@tzi.de">Alexander Konermann</a>
*/
@RequestScoped
@ -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;