CCM NG: Several bugfixes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5151 8810af33-2d31-482b-a856-94f89814c4df
parent
9b3329756e
commit
15459112c7
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.contentsection;
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -27,6 +29,7 @@ import org.libreccm.categorization.Categorization;
|
||||||
import org.libreccm.categorization.Category;
|
import org.libreccm.categorization.Category;
|
||||||
import org.libreccm.categorization.CategoryManager;
|
import org.libreccm.categorization.CategoryManager;
|
||||||
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
|
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
|
||||||
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
import org.libreccm.core.CcmObject;
|
import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.core.CcmObjectRepository;
|
import org.libreccm.core.CcmObjectRepository;
|
||||||
import org.libreccm.core.UnexpectedErrorException;
|
import org.libreccm.core.UnexpectedErrorException;
|
||||||
|
|
@ -65,9 +68,17 @@ import javax.transaction.Transactional;
|
||||||
public class ContentItemRepository
|
public class ContentItemRepository
|
||||||
extends AbstractAuditedEntityRepository<Long, ContentItem> {
|
extends AbstractAuditedEntityRepository<Long, ContentItem> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -145167586339461600L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CategoryManager categoryManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CcmObjectRepository ccmObjectRepo;
|
private CcmObjectRepository ccmObjectRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ConfigurationManager confManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private FolderRepository folderRepo;
|
private FolderRepository folderRepo;
|
||||||
|
|
||||||
|
|
@ -75,28 +86,25 @@ public class ContentItemRepository
|
||||||
private ContentItemManager itemManager;
|
private ContentItemManager itemManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CategoryManager categoryManager;
|
private PermissionChecker permissionChecker;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Shiro shiro;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private UserRepository userRepository;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RoleManager roleManager;
|
private RoleManager roleManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private WorkflowRepository workflowRepo;
|
private Shiro shiro;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private TaskRepository taskRepo;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private TaskManager taskManager;
|
private TaskManager taskManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PermissionChecker permissionChecker;
|
private TaskRepository taskRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private WorkflowRepository workflowRepo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getEntityId(final ContentItem item) {
|
public Long getEntityId(final ContentItem item) {
|
||||||
|
|
@ -440,7 +448,6 @@ public class ContentItemRepository
|
||||||
final Class<? extends ContentItem> type,
|
final Class<? extends ContentItem> type,
|
||||||
final String name) {
|
final String name) {
|
||||||
|
|
||||||
|
|
||||||
final TypedQuery<ContentItem> query = getEntityManager()
|
final TypedQuery<ContentItem> query = getEntityManager()
|
||||||
.createNamedQuery("ContentItem.filterByFolderAndTypeAndName",
|
.createNamedQuery("ContentItem.filterByFolderAndTypeAndName",
|
||||||
ContentItem.class);
|
ContentItem.class);
|
||||||
|
|
@ -637,7 +644,24 @@ public class ContentItemRepository
|
||||||
roles = roleManager.findAllRolesForUser(theUser);
|
roles = roleManager.findAllRolesForUser(theUser);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
roles = Collections.emptyList();
|
final Optional<User> publicUser;
|
||||||
|
|
||||||
|
final KernelConfig kernelConfig = confManager
|
||||||
|
.findConfiguration(KernelConfig.class);
|
||||||
|
final String principal = (String) shiro
|
||||||
|
.getPublicUser()
|
||||||
|
.getPrincipal();
|
||||||
|
if (kernelConfig.emailIsPrimaryIdentifier()) {
|
||||||
|
publicUser = userRepository.findByEmailAddress(principal);
|
||||||
|
} else {
|
||||||
|
publicUser = userRepository.findByName(principal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publicUser.isPresent()) {
|
||||||
|
roles = roleManager.findAllRolesForUser(publicUser.get());
|
||||||
|
} else {
|
||||||
|
roles = Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isSystemUser = shiro.isSystemUser();
|
final boolean isSystemUser = shiro.isSystemUser();
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import java.util.Optional;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.ws.rs.NotFoundException;
|
|
||||||
|
|
||||||
import static org.librecms.pages.PagesConstants.*;
|
import static org.librecms.pages.PagesConstants.*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import static org.librecms.pages.PagesConstants.*;
|
import static org.librecms.pages.PagesConstants.*;
|
||||||
|
|
||||||
import org.libreccm.pagemodel.RendersComponent;
|
import org.libreccm.pagemodel.RendersComponent;
|
||||||
|
import org.librecms.contentsection.ContentItemVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer for the {@link ItemListComponent}.
|
* Renderer for the {@link ItemListComponent}.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
|
|
@ -166,7 +167,12 @@ public class ItemListComponentRenderer
|
||||||
final Join<? extends ContentItem, Categorization> catJoin = from
|
final Join<? extends ContentItem, Categorization> catJoin = from
|
||||||
.join("categories");
|
.join("categories");
|
||||||
|
|
||||||
criteriaQuery.where(catJoin.get("category").in(categories));
|
criteriaQuery.where(criteriaBuilder
|
||||||
|
.and(catJoin.get("category").in(categories),
|
||||||
|
criteriaBuilder.equal(catJoin.get("indexObject"), false),
|
||||||
|
criteriaBuilder.equal(catJoin.get("type"), ""),
|
||||||
|
criteriaBuilder.equal(from.get("version"),
|
||||||
|
ContentItemVersion.LIVE)));
|
||||||
// criteriaQuery
|
// criteriaQuery
|
||||||
// .where(criteriaBuilder
|
// .where(criteriaBuilder
|
||||||
// .and(catJoin.get("category").in(categories),
|
// .and(catJoin.get("category").in(categories),
|
||||||
|
|
|
||||||
|
|
@ -28,22 +28,26 @@ import org.librecms.contentsection.ItemAttachment;
|
||||||
import org.librecms.contentsection.rs.ContentItems;
|
import org.librecms.contentsection.rs.ContentItems;
|
||||||
import org.librecms.pagemodel.assets.AssetRenderers;
|
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for the renderers for {@link ContentItems}.
|
* Base class for the renderers for {@link ContentItems}.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractContentItemRenderer {
|
public abstract class AbstractContentItemRenderer implements Serializable {
|
||||||
|
|
||||||
@Inject
|
private static final long serialVersionUID = 1290408390406469580L;
|
||||||
private AssetRenderers assetRenderers;
|
|
||||||
|
private final AssetRenderers assetRenderers;
|
||||||
|
|
||||||
|
public AbstractContentItemRenderer(final AssetRenderers assetRenderers) {
|
||||||
|
this.assetRenderers = assetRenderers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be called to render a {@link ContentItem}. The method
|
* This method should be called to render a {@link ContentItem}. The method
|
||||||
|
|
@ -97,6 +101,7 @@ public abstract class AbstractContentItemRenderer {
|
||||||
result.put("contentType", renderContentType(item.getContentType(),
|
result.put("contentType", renderContentType(item.getContentType(),
|
||||||
language));
|
language));
|
||||||
result.put("description", item.getDescription().getValue(language));
|
result.put("description", item.getDescription().getValue(language));
|
||||||
|
result.put("version", item.getVersion().toString());
|
||||||
result.put("creationDate", item.getCreationDate());
|
result.put("creationDate", item.getCreationDate());
|
||||||
result.put("lastModified", item.getLastModified());
|
result.put("lastModified", item.getLastModified());
|
||||||
result.put("creationUserName", item.getCreationUserName());
|
result.put("creationUserName", item.getCreationUserName());
|
||||||
|
|
|
||||||
|
|
@ -20,34 +20,43 @@ package org.librecms.pagemodel.contentitems;
|
||||||
|
|
||||||
import org.librecms.contentsection.ContentItem;
|
import org.librecms.contentsection.ContentItem;
|
||||||
import org.librecms.contenttypes.Article;
|
import org.librecms.contenttypes.Article;
|
||||||
|
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer for {@link Article} items.
|
* Renderer for {@link Article} items.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@ContentItemRenderer(renders = Article.class)
|
@ContentItemRenderer(renders = Article.class)
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class ArticleRenderer extends AbstractContentItemRenderer {
|
public class ArticleRenderer extends AbstractContentItemRenderer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 8355183377902033759L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ArticleRenderer(final AssetRenderers assetRenderers) {
|
||||||
|
super(assetRenderers);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the provided {@link Article}. The following values are put into
|
* Render the provided {@link Article}. The following values are put into
|
||||||
* the map:
|
* the map:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {
|
* {
|
||||||
* "text": {@link Article#getText()}
|
* "text": {@link Article#getText()}
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param item The item to render.
|
* @param item The item to render.
|
||||||
* @param language The current language.
|
* @param language The current language.
|
||||||
* @param result The map into which the result is placed.
|
* @param result The map into which the result is placed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void renderItem(final ContentItem item,
|
public void renderItem(final ContentItem item,
|
||||||
|
|
@ -60,7 +69,7 @@ public class ArticleRenderer extends AbstractContentItemRenderer {
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.put("text", article.getText().getValue(language));
|
result.put("text", article.getText().getValue(language));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.librecms.pagemodel.contentitems;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.librecms.contentsection.ContentItem;
|
import org.librecms.contentsection.ContentItem;
|
||||||
|
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -43,6 +44,9 @@ public class ContentItemRenderers {
|
||||||
private static final Logger LOGGER = LogManager
|
private static final Logger LOGGER = LogManager
|
||||||
.getLogger(ContentItemRenderers.class);
|
.getLogger(ContentItemRenderers.class);
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRenderers assetRenderers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Instance<AbstractContentItemRenderer> renderers;
|
private Instance<AbstractContentItemRenderer> renderers;
|
||||||
|
|
||||||
|
|
@ -69,7 +73,7 @@ public class ContentItemRenderers {
|
||||||
* is returned.
|
* is returned.
|
||||||
*
|
*
|
||||||
* @param itemType The type for which the renderer is retrieved.
|
* @param itemType The type for which the renderer is retrieved.
|
||||||
* @param mode The render mode.
|
* @param mode The render mode.
|
||||||
*
|
*
|
||||||
* @return The renderer for the provided type.
|
* @return The renderer for the provided type.
|
||||||
*/
|
*/
|
||||||
|
|
@ -94,7 +98,10 @@ public class ContentItemRenderers {
|
||||||
LOGGER.warn("No renderer for item type \"{}\" and mode "
|
LOGGER.warn("No renderer for item type \"{}\" and mode "
|
||||||
+ "\"--DEFAULT--\". Returning default renderer.",
|
+ "\"--DEFAULT--\". Returning default renderer.",
|
||||||
itemType.getName());
|
itemType.getName());
|
||||||
return new AbstractContentItemRenderer() {
|
return new AbstractContentItemRenderer(assetRenderers) {
|
||||||
|
|
||||||
|
private static final long serialVersionUID
|
||||||
|
= -4679445070846896396L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderItem(final ContentItem item,
|
public void renderItem(final ContentItem item,
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,13 @@ package org.librecms.pagemodel.contentitems;
|
||||||
|
|
||||||
import org.librecms.contentsection.ContentItem;
|
import org.librecms.contentsection.ContentItem;
|
||||||
import org.librecms.contenttypes.Event;
|
import org.librecms.contenttypes.Event;
|
||||||
|
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer for {@link Event} items.
|
* Renderer for {@link Event} items.
|
||||||
*
|
*
|
||||||
|
|
@ -32,10 +35,17 @@ import java.util.Map;
|
||||||
@ContentItemRenderer(renders = Event.class)
|
@ContentItemRenderer(renders = Event.class)
|
||||||
public class EventRenderer extends AbstractContentItemRenderer {
|
public class EventRenderer extends AbstractContentItemRenderer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3517404651544429745L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public EventRenderer(final AssetRenderers assetRenderers) {
|
||||||
|
super(assetRenderers);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the provided {@link Event}. The following values are put into
|
* Render the provided {@link Event}. The following values are put into
|
||||||
* {@code result}:
|
* {@code result}:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {
|
* {
|
||||||
* "text": {@link Event#getText()}
|
* "text": {@link Event#getText()}
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,15 @@ package org.librecms.pagemodel.contentitems;
|
||||||
import org.librecms.contentsection.ContentItem;
|
import org.librecms.contentsection.ContentItem;
|
||||||
import org.librecms.contenttypes.MultiPartArticle;
|
import org.librecms.contenttypes.MultiPartArticle;
|
||||||
import org.librecms.contenttypes.MultiPartArticleSection;
|
import org.librecms.contenttypes.MultiPartArticleSection;
|
||||||
|
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer for {@link MultiPartArticle} items.
|
* Renderer for {@link MultiPartArticle} items.
|
||||||
*
|
*
|
||||||
|
|
@ -35,6 +38,13 @@ import java.util.stream.Collectors;
|
||||||
@ContentItemRenderer(renders = MultiPartArticle.class)
|
@ContentItemRenderer(renders = MultiPartArticle.class)
|
||||||
public class MultiPartArticleRenderer extends AbstractContentItemRenderer {
|
public class MultiPartArticleRenderer extends AbstractContentItemRenderer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -4298383182795585868L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public MultiPartArticleRenderer(final AssetRenderers assetRenderers) {
|
||||||
|
super(assetRenderers);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the provided {@link MultiPartArticle}. The following values are
|
* Renders the provided {@link MultiPartArticle}. The following values are
|
||||||
* put into {@code result}:
|
* put into {@code result}:
|
||||||
|
|
|
||||||
|
|
@ -20,31 +20,41 @@ package org.librecms.pagemodel.contentitems;
|
||||||
|
|
||||||
import org.librecms.contentsection.ContentItem;
|
import org.librecms.contentsection.ContentItem;
|
||||||
import org.librecms.contenttypes.News;
|
import org.librecms.contenttypes.News;
|
||||||
|
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderer for {@link News} items.
|
* Renderer for {@link News} items.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@ContentItemRenderer(renders = News.class)
|
@ContentItemRenderer(renders = News.class)
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class NewsRenderer extends AbstractContentItemRenderer {
|
public class NewsRenderer extends AbstractContentItemRenderer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -493301428054148505L;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public NewsRenderer(final AssetRenderers assetRenderers) {
|
||||||
|
super(assetRenderers);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the provided {@link News} item. The following values are put into {@code result}:
|
* Renders the provided {@link News} item. The following values are put into
|
||||||
*
|
* {@code result}:
|
||||||
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {
|
* {
|
||||||
* "text": {@link News#getText()}
|
* "text": {@link News#getText()}
|
||||||
* "releaseDate": {@link News#getReleaseDate()}
|
* "releaseDate": {@link News#getReleaseDate()}
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param item The item to render.
|
* @param item The item to render.
|
||||||
* @param language The current language.
|
* @param language The current language.
|
||||||
* @param result The map into which the result is placed.
|
* @param result The map into which the result is placed.
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import java.util.Objects;
|
||||||
|
|
||||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||||
|
|
||||||
|
import javax.persistence.Access;
|
||||||
|
import javax.persistence.AccessType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
|
|
@ -36,6 +38,7 @@ import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
@ -77,13 +80,13 @@ import javax.persistence.Table;
|
||||||
name = "Categorization.findIndexObject",
|
name = "Categorization.findIndexObject",
|
||||||
query = "SELECT c.categorizedObject FROM Categorization c "
|
query = "SELECT c.categorizedObject FROM Categorization c "
|
||||||
+ "WHERE c.category = :category "
|
+ "WHERE c.category = :category "
|
||||||
+ "AND c.index = TRUE")
|
+ "AND c.indexObject = TRUE")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Categorization.findIndexObjectCategorization",
|
name = "Categorization.findIndexObjectCategorization",
|
||||||
query = "SELECT c FROM Categorization c "
|
query = "SELECT c FROM Categorization c "
|
||||||
+ "WHERE c.category = :category "
|
+ "WHERE c.category = :category "
|
||||||
+ "AND c.index = TRUE"
|
+ "AND c.indexObject = TRUE"
|
||||||
)
|
)
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
|
|
@ -92,7 +95,7 @@ import javax.persistence.Table;
|
||||||
+ "ELSE false END) "
|
+ "ELSE false END) "
|
||||||
+ "FROM Categorization c "
|
+ "FROM Categorization c "
|
||||||
+ "WHERE c.category = :category "
|
+ "WHERE c.category = :category "
|
||||||
+ "AND c.index = TRUE")
|
+ "AND c.indexObject = TRUE")
|
||||||
})
|
})
|
||||||
@JsonIdentityInfo(generator = CategorizationIdGenerator.class,
|
@JsonIdentityInfo(generator = CategorizationIdGenerator.class,
|
||||||
property = "customCatId")
|
property = "customCatId")
|
||||||
|
|
@ -125,11 +128,11 @@ public class Categorization implements Serializable, Relation, Portable {
|
||||||
private CcmObject categorizedObject;
|
private CcmObject categorizedObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the categorised object is the index object of the category this
|
* If the categorised object is the indexObject object of the category this
|
||||||
* property is set to {@code true}.
|
property is set to {@code true}.
|
||||||
*/
|
*/
|
||||||
@Column(name = "CATEGORY_INDEX")
|
@Column(name = "CATEGORY_INDEX")
|
||||||
private boolean index;
|
private boolean indexObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the order in which the categories assigned the the categorised
|
* Defines the order in which the categories assigned the the categorised
|
||||||
|
|
@ -153,7 +156,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
public Categorization() {
|
public Categorization() {
|
||||||
index = false;
|
indexObject = false;
|
||||||
categoryOrder = 0;
|
categoryOrder = 0;
|
||||||
objectOrder = 0;
|
objectOrder = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -192,12 +195,16 @@ public class Categorization implements Serializable, Relation, Portable {
|
||||||
this.categorizedObject = categorizedObject;
|
this.categorizedObject = categorizedObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIndex() {
|
// public boolean getIndex() {
|
||||||
return index;
|
// return indexObject;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public boolean isIndexObject() {
|
||||||
|
return indexObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndex(final boolean index) {
|
public void setIndexObject(final boolean indexObject) {
|
||||||
this.index = index;
|
this.indexObject = indexObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCategoryOrder() {
|
public long getCategoryOrder() {
|
||||||
|
|
@ -231,7 +238,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
||||||
= 89 * hash + (int) (categorizationId ^ (categorizationId >>> 32));
|
= 89 * hash + (int) (categorizationId ^ (categorizationId >>> 32));
|
||||||
hash = 89 * hash + Objects.hashCode(category);
|
hash = 89 * hash + Objects.hashCode(category);
|
||||||
hash = 89 * hash + Objects.hashCode(categorizedObject);
|
hash = 89 * hash + Objects.hashCode(categorizedObject);
|
||||||
hash = 89 * hash + (index ? 1 : 0);
|
hash = 89 * hash + (indexObject ? 1 : 0);
|
||||||
hash = 89 * hash + (int) (categoryOrder ^ (categoryOrder >>> 32));
|
hash = 89 * hash + (int) (categoryOrder ^ (categoryOrder >>> 32));
|
||||||
hash = 89 * hash + (int) (objectOrder ^ (objectOrder >>> 32));
|
hash = 89 * hash + (int) (objectOrder ^ (objectOrder >>> 32));
|
||||||
hash = 89 * hash + Objects.hashCode(type);
|
hash = 89 * hash + Objects.hashCode(type);
|
||||||
|
|
@ -263,7 +270,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != other.isIndex()) {
|
if (indexObject != other.isIndexObject()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,7 +308,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
||||||
categorizationId,
|
categorizationId,
|
||||||
Objects.toString(category),
|
Objects.toString(category),
|
||||||
Objects.toString(categorizedObject),
|
Objects.toString(categorizedObject),
|
||||||
index,
|
indexObject,
|
||||||
categoryOrder,
|
categoryOrder,
|
||||||
objectOrder,
|
objectOrder,
|
||||||
type,
|
type,
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public class CategoryManager {
|
||||||
final long objectCount = countObjects(assignedCategory);
|
final long objectCount = countObjects(assignedCategory);
|
||||||
categorization.setObjectOrder(objectCount + 1);
|
categorization.setObjectOrder(objectCount + 1);
|
||||||
categorization.setType(type);
|
categorization.setType(type);
|
||||||
categorization.setIndex(false);
|
categorization.setIndexObject(false);
|
||||||
|
|
||||||
object.addCategory(categorization);
|
object.addCategory(categorization);
|
||||||
assignedCategory.addObject(categorization);
|
assignedCategory.addObject(categorization);
|
||||||
|
|
@ -992,7 +992,7 @@ public class CategoryManager {
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
categorization.setIndex(true);
|
categorization.setIndexObject(true);
|
||||||
entityManager.merge(categorization);
|
entityManager.merge(categorization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1013,7 +1013,7 @@ public class CategoryManager {
|
||||||
query.setParameter("category", category);
|
query.setParameter("category", category);
|
||||||
|
|
||||||
final List<Categorization> result = query.getResultList();
|
final List<Categorization> result = query.getResultList();
|
||||||
result.forEach(categorization -> categorization.setIndex(false));
|
result.forEach(categorization -> categorization.setIndexObject(false));
|
||||||
result.forEach(categorization -> entityManager.merge(categorization));
|
result.forEach(categorization -> entityManager.merge(categorization));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Unable to read objects "
|
LOGGER.error("Unable to read objects "
|
||||||
+ "from XML line:\n \"{}\"", line);
|
+ "from XML line:\n \"{}\"", line);
|
||||||
LOGGER.error(e);
|
LOGGER.error("Exception: ", e);
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ import java.util.Optional;
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class UserRepository extends AbstractEntityRepository<Long, User> {
|
public class UserRepository extends AbstractEntityRepository<Long, User> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 5787091134411376455L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<User> getEntityClass() {
|
public Class<User> getEntityClass() {
|
||||||
return User.class;
|
return User.class;
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,8 @@ public class CoreDataImportTest {
|
||||||
|
|
||||||
Assert.assertFalse(importHelper.importWorkflows());
|
Assert.assertFalse(importHelper.importWorkflows());
|
||||||
Assert.assertFalse(importHelper.importTaskComments());
|
Assert.assertFalse(importHelper.importTaskComments());
|
||||||
//Assert.assertFalse(importHelper.importAssignableTasks());
|
Assert.assertFalse(importHelper.importAssignableTasks());
|
||||||
//Assert.assertFalse(importHelper.importTaskAssignments());
|
// Assert.assertFalse(importHelper.importTaskAssignments());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue