Several bugfixes
parent
9f6937352c
commit
e150bd2509
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2023-02-06T182349",
|
||||
"version": "7.0.0-SNAPSHOT.2023-02-16T191702",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2023-02-06T182349",
|
||||
"version": "7.0.0-SNAPSHOT.2023-02-16T191702",
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^2.0.0-beta.127",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2023-02-06T182349",
|
||||
"version": "7.0.0-SNAPSHOT.2023-02-16T191702",
|
||||
"description": "JavaScript stuff for ccm-cms",
|
||||
"main": "target/generated-resources/assets/@content-sections/cms-admin.js",
|
||||
"types": "target/generated-resources/assets/@content-sections/cms-admin.d.ts",
|
||||
|
|
|
|||
|
|
@ -143,8 +143,7 @@ public class BinaryAssetRepository
|
|||
public void initNewEntity(final BinaryAsset asset) {
|
||||
super.initNewEntity(asset);
|
||||
if (asset.getUuid() == null) {
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
asset.setUuid(uuid);
|
||||
asset.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,8 +137,7 @@ public class AssetRepository
|
|||
public void initNewEntity(final Asset asset) {
|
||||
super.initNewEntity(asset);
|
||||
if (asset.getUuid() == null) {
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
asset.setUuid(uuid);
|
||||
asset.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,9 @@ public class AttachmentListRepository
|
|||
@Override
|
||||
protected void initNewEntity(final AttachmentList entity) {
|
||||
super.initNewEntity(entity);
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,10 +138,11 @@ public class ContentItemRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final ContentItem item) {
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
item.setUuid(uuid);
|
||||
if (item.getUuid() == null) {
|
||||
item.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
if (item.getItemUuid() == null || item.getItemUuid().isEmpty()) {
|
||||
item.setItemUuid(uuid);
|
||||
item.setItemUuid(item.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,16 +95,19 @@ public class ContentSectionRepository
|
|||
return section.getObjectId() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initNewEntity(final ContentSection section) {
|
||||
if (section.getUuid() == null) {
|
||||
section.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
section.setApplicationType(ContentSection.class.getName());
|
||||
}
|
||||
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public void save(final ContentSection section) {
|
||||
if (isNew(section)) {
|
||||
section.setUuid(UUID.randomUUID().toString());
|
||||
section.setApplicationType(ContentSection.class.getName());
|
||||
}
|
||||
|
||||
super.save(section);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,10 @@ public class FolderRepository extends AbstractEntityRepository<Long, Folder> {
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Folder folder) {
|
||||
if (folder.getUuid() == null) {
|
||||
folder.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<Folder> getRootDocumentFolders() {
|
||||
|
|
@ -108,7 +110,7 @@ public class FolderRepository extends AbstractEntityRepository<Long, Folder> {
|
|||
.setParameter("uuid", uuid)
|
||||
.getSingleResult()
|
||||
);
|
||||
} catch(NoResultException ex) {
|
||||
} catch (NoResultException ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,10 @@ public class ItemAttachmentRepository
|
|||
|
||||
@Override
|
||||
protected void initNewEntity(final ItemAttachment entity) {
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<ItemAttachment> findByUuid(final String uuid) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class LifecycleDefinitionRepository
|
|||
.setParameter("uuid", uuid)
|
||||
.getSingleResult()
|
||||
);
|
||||
} catch(NoResultException ex) {
|
||||
} catch (NoResultException ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -74,9 +74,9 @@ public class LifecycleDefinitionRepository
|
|||
@Override
|
||||
protected void initNewEntity(final LifecycleDefinition entity) {
|
||||
super.initNewEntity(entity);
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,10 @@ public class LifecycleRepository
|
|||
@Override
|
||||
protected void initNewEntity(final Lifecycle entity) {
|
||||
super.initNewEntity(entity);
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<Lifecycle> findByUuid(final String uuid) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,10 @@ public class PhaseDefinititionRepository
|
|||
@Override
|
||||
public void initNewEntity(final PhaseDefinition phaseDefinition) {
|
||||
super.initNewEntity(phaseDefinition);
|
||||
if (phaseDefinition.getUuid() == null) {
|
||||
phaseDefinition.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<PhaseDefinition> findByUuid(final String uuid) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -58,8 +58,10 @@ public class PhaseRepository extends AbstractEntityRepository<Long, Phase> {
|
|||
@Override
|
||||
public void initNewEntity(final Phase phase) {
|
||||
super.initNewEntity(phase);
|
||||
if (phase.getUuid() == null) {
|
||||
phase.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<Phase> findByUuid(final String uuid) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -64,10 +64,8 @@ public class PageRepository extends AbstractEntityRepository<Long, Page> {
|
|||
|
||||
@Override
|
||||
protected void initNewEntity(final Page entity) {
|
||||
|
||||
super.initNewEntity(entity);
|
||||
|
||||
if (isNew(entity)) {
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,10 +99,11 @@ public class PagesRepository extends AbstractEntityRepository<Long, Pages> {
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Pages pages) {
|
||||
|
||||
super.initNewEntity(pages);
|
||||
|
||||
if (pages.getUuid() == null) {
|
||||
pages.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
pages.setApplicationType(Pages.class.getName());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,10 @@ public class CategoryRepository extends AbstractEntityRepository<Long, Category>
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Category category) {
|
||||
if (category.getUuid() == null) {
|
||||
category.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of all top level categories (Categories without a parent
|
||||
|
|
|
|||
|
|
@ -68,8 +68,10 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Domain domain) {
|
||||
if (domain.getUuid() == null) {
|
||||
domain.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -78,8 +78,10 @@ public class CcmObjectRepository extends AbstractEntityRepository<Long, CcmObjec
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final CcmObject entity) {
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link CcmObject} by its id.
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ import java.util.UUID;
|
|||
* @version created the 8/10/17
|
||||
*/
|
||||
@RequestScoped
|
||||
public class ResourceRepository extends AbstractEntityRepository<Long,
|
||||
Resource> {
|
||||
public class ResourceRepository extends AbstractEntityRepository<Long, Resource> {
|
||||
|
||||
private static final long serialVersionUID = 4593206445936878071L;
|
||||
|
||||
|
|
@ -62,8 +61,10 @@ public class ResourceRepository extends AbstractEntityRepository<Long,
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Resource resource) {
|
||||
if (resource.getUuid() == null) {
|
||||
resource.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link Resource} by its uuid.
|
||||
|
|
@ -83,4 +84,5 @@ public class ResourceRepository extends AbstractEntityRepository<Long,
|
|||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,16 @@
|
|||
*/
|
||||
package org.libreccm.core;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -35,6 +40,10 @@ import javax.inject.Inject;
|
|||
public class ResourceTypeImExporter
|
||||
extends AbstractEntityImExporter<ResourceType> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
ResourceTypeImExporter.class
|
||||
);
|
||||
|
||||
@Inject
|
||||
private ResourceTypeRepository repository;
|
||||
|
||||
|
|
@ -56,7 +65,22 @@ public class ResourceTypeImExporter
|
|||
|
||||
@Override
|
||||
protected void saveImportedEntity(final ResourceType entity) {
|
||||
final List<ResourceType> types = repository
|
||||
.findAll()
|
||||
.stream()
|
||||
.sorted(
|
||||
Comparator.comparing(ResourceType::getResourceTypeId)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
final long lastId;
|
||||
if (types.isEmpty()) {
|
||||
lastId = 0;
|
||||
} else {
|
||||
lastId = types.get(types.size() - 1).getResourceTypeId();
|
||||
}
|
||||
entity.setResourceTypeId(lastId + 1);
|
||||
repository.save(entity);
|
||||
LOGGER.debug("Saved {}", entity.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -58,20 +58,15 @@ public class ResourceTypeRepository
|
|||
|
||||
@Override
|
||||
public boolean isNew(final ResourceType entity) {
|
||||
return entity.getTitle() == null;
|
||||
return entity.getResourceTypeId() == 0;
|
||||
// return entity.getTitle() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initNewEntity(final ResourceType entity) {
|
||||
|
||||
if (entity.getResourceTypeId() == 0) {
|
||||
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Optional<ResourceType> findByUuid(final String uuid) {
|
||||
|
|
|
|||
|
|
@ -137,9 +137,10 @@ public class GroupRepository extends AbstractEntityRepository<Long, Group> {
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Group group) {
|
||||
|
||||
if (group.getUuid() == null) {
|
||||
group.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ public class PartyRepository extends AbstractEntityRepository<Long, Party> {
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Party party) {
|
||||
if (party.getUuid() == null) {
|
||||
party.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Optional<Party> findByUuid(final String uuid) {
|
||||
final TypedQuery<Party> query = getEntityManager().createNamedQuery(
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ public class PermissionRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Permission permission) {
|
||||
|
||||
if (permission.getUuid() == null) {
|
||||
permission.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<Permission> findByUuid(final String uuid) {
|
||||
final TypedQuery<Permission> query = getEntityManager()
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ public class RoleRepository extends AbstractEntityRepository<Long, Role> {
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Role role) {
|
||||
|
||||
if (role.getUuid() == null) {
|
||||
role.setUuid(UUID.randomUUID().toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public long count() {
|
||||
|
|
|
|||
|
|
@ -206,11 +206,10 @@ public class UserRepository extends AbstractEntityRepository<Long, User> {
|
|||
|
||||
@Override
|
||||
protected void initNewEntity(final User entity) {
|
||||
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
|
|
|
|||
|
|
@ -162,7 +162,9 @@ public class SiteRepository extends AbstractEntityRepository<Long, Site> {
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final Site site) {
|
||||
if (site.getUuid() == null) {
|
||||
site.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class ApplicationIdResolver implements Serializable, ObjectIdResolver {
|
|||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No ccmApplications with UUID %s in the database.",
|
||||
"No CcmApplication with UUID %s in the database.",
|
||||
id.key.toString()
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -65,11 +65,14 @@ public class ApplicationRepository
|
|||
|
||||
@Override
|
||||
public void initNewEntity(final CcmApplication application) {
|
||||
|
||||
super.initNewEntity(application);
|
||||
if (application.getUuid() == null) {
|
||||
application.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
if (application.getApplicationType() == null) {
|
||||
application.setApplicationType(application.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the application mounted at the provided {@code path}.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.libreccm.workflow;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.libreccm.imexport.AbstractEntityImExporter;
|
||||
import org.libreccm.imexport.Processes;
|
||||
|
||||
|
|
@ -28,6 +30,7 @@ import java.util.Set;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
/**
|
||||
* Exporter/Importer for {@link AssignableTask}s.
|
||||
|
|
@ -41,9 +44,16 @@ import javax.inject.Inject;
|
|||
public class AssignableTaskImExporter
|
||||
extends AbstractEntityImExporter<AssignableTask> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
AssignableTaskImExporter.class
|
||||
);
|
||||
|
||||
@Inject
|
||||
private AssignableTaskRepository assignableTaskRepository;
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private TaskManager taskManager;
|
||||
|
||||
|
|
@ -74,6 +84,11 @@ public class AssignableTaskImExporter
|
|||
@Override
|
||||
protected void saveImportedEntity(final AssignableTask entity) {
|
||||
assignableTaskRepository.save(entity);
|
||||
LOGGER.warn(
|
||||
"Saved imported assignable task with UUID {} and ID {}.",
|
||||
entity.getUuid(),
|
||||
entity.getTaskId()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import java.util.Optional;
|
|||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Repository for assignable tasks.
|
||||
*
|
||||
|
|
@ -65,7 +67,7 @@ public class AssignableTaskRepository
|
|||
|
||||
@Override
|
||||
protected void initNewEntity(final AssignableTask entity) {
|
||||
if (isNew(entity)) {
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -77,6 +79,7 @@ public class AssignableTaskRepository
|
|||
*
|
||||
* @return An optional either with the found item or empty
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Optional<AssignableTask> findByUuid(final String uuid) {
|
||||
final TypedQuery<AssignableTask> query = getEntityManager()
|
||||
.createNamedQuery(
|
||||
|
|
@ -90,6 +93,7 @@ public class AssignableTaskRepository
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<AssignableTask> findEnabledTasksForWorkflow(
|
||||
final User user, final Workflow workflow) {
|
||||
final TypedQuery<AssignableTask> query = getEntityManager()
|
||||
|
|
@ -102,6 +106,7 @@ public class AssignableTaskRepository
|
|||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<AssignableTask> getAssignedTasks(final User user,
|
||||
final Workflow workflow) {
|
||||
final TypedQuery<AssignableTask> query = getEntityManager()
|
||||
|
|
@ -119,6 +124,4 @@ public class AssignableTaskRepository
|
|||
return query.getResultList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ import java.util.Objects;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
|
|
@ -119,10 +121,11 @@ import javax.xml.bind.annotation.XmlElementWrapper;
|
|||
@JsonIdentityInfo(
|
||||
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
resolver = TaskIdResolver.class,
|
||||
property = "uuid",
|
||||
scope = Task.class
|
||||
property = "uuid"
|
||||
// ,
|
||||
// scope = Task.class
|
||||
)
|
||||
public class Task implements Identifiable, Serializable {
|
||||
public class Task implements Exportable, Identifiable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8161343036908150426L;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@ package org.libreccm.workflow;
|
|||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Used to resolve {@link Task}s based on the UUIDs for export or import.
|
||||
|
|
@ -31,9 +33,11 @@ import java.io.Serializable;
|
|||
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class TaskIdResolver implements Serializable, ObjectIdResolver {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
TaskIdResolver.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
|
|
@ -48,6 +52,31 @@ public class TaskIdResolver implements Serializable, ObjectIdResolver {
|
|||
|
||||
@Override
|
||||
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||
// final Optional<Task> result = CdiUtil
|
||||
// .createCdiUtil()
|
||||
// .findBean(TaskRepository.class)
|
||||
// .findByUuid(id.key.toString());
|
||||
//
|
||||
// if (result.isPresent()) {
|
||||
// return result.get();
|
||||
// }
|
||||
//
|
||||
// return Optional.ofNullable(
|
||||
// CdiUtil
|
||||
// .createCdiUtil()
|
||||
// .findBean(AssignableTaskImExporter.class)
|
||||
// .getImportedTask(id.key.toString())
|
||||
// )
|
||||
// .orElseThrow(
|
||||
// () -> new IllegalArgumentException(
|
||||
// String.format(
|
||||
// "No task with UUID %s found.",
|
||||
// id.key.toString()
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
//
|
||||
|
||||
return CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(TaskRepository.class)
|
||||
|
|
|
|||
|
|
@ -60,8 +60,10 @@ public class TaskRepository extends AbstractEntityRepository<Long, Task> {
|
|||
@Override
|
||||
protected void initNewEntity(final Task task) {
|
||||
super.initNewEntity(task);
|
||||
if (task.getUuid() == null) {
|
||||
task.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a {@link Task} by its uuid.
|
||||
|
|
@ -73,7 +75,9 @@ 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 {
|
||||
|
|
|
|||
|
|
@ -63,10 +63,10 @@ public class WorkflowRepository extends AbstractEntityRepository<Long, Workflow>
|
|||
@Override
|
||||
protected void initNewEntity(final Workflow workflow) {
|
||||
super.initNewEntity(workflow);
|
||||
if (workflow.getUuid() == null) {
|
||||
workflow.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a {@link Workflow} by its UUID.
|
||||
|
|
|
|||
|
|
@ -203,6 +203,8 @@ public abstract class AbstractResourceRepository<T extends AbstractResource>
|
|||
//Todo
|
||||
@Override
|
||||
public void initNewEntity(final T entity) {
|
||||
if (entity.getUuid() == null) {
|
||||
entity.setUuid(UUID.randomUUID().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue