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