Fixed dependency problem for RelatedLinkImExporter
parent
e066ac358f
commit
f7ce45621f
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2022-11-07T181703",
|
||||
"version": "7.0.0-SNAPSHOT.2022-11-26T105237",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2022-11-07T181703",
|
||||
"version": "7.0.0-SNAPSHOT.2022-11-26T105237",
|
||||
"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.2022-11-07T181703",
|
||||
"version": "7.0.0-SNAPSHOT.2022-11-26T105237",
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.util.Set;
|
|||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
* @param <T> Type of {@link ContactableEntity}.
|
||||
*/
|
||||
public abstract class AbstractContactableEntityImExporter<T extends ContactableEntity>
|
||||
extends AbstractAssetImExporter<T> {
|
||||
|
|
@ -31,7 +32,7 @@ public abstract class AbstractContactableEntityImExporter<T extends ContactableE
|
|||
protected final void init() {
|
||||
addRequiredEntities(Set.of(PostalAddress.class));
|
||||
}
|
||||
|
||||
|
||||
protected abstract void initContactableEntityImExporter();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class RelatedLink extends Asset implements Serializable {
|
|||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "TARGET_ITEM")
|
||||
@JsonIgnore
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
private ContentItem targetItem;
|
||||
|
||||
@OneToOne
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import org.libreccm.imexport.AbstractEntityImExporter;
|
|||
import org.libreccm.imexport.Processes;
|
||||
import org.libreccm.security.Permission;
|
||||
import org.libreccm.security.PermissionImExporter;
|
||||
import org.librecms.assets.RelatedLink;
|
||||
import org.librecms.assets.RelatedLinkImExporter;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
|
@ -44,20 +46,25 @@ public abstract class AbstractContentItemImExporter<T extends ContentItem>
|
|||
|
||||
@Inject
|
||||
private ContentItemRepository itemRepository;
|
||||
|
||||
|
||||
@Inject
|
||||
@Any
|
||||
@Processes(Categorization.class)
|
||||
private CategorizationImExporter categorizationImExporter;
|
||||
|
||||
|
||||
@Inject
|
||||
@Any
|
||||
@Processes(Permission.class)
|
||||
private PermissionImExporter permissionImExporter;
|
||||
|
||||
|
||||
@Inject
|
||||
@Any
|
||||
@Processes(RelatedLink.class)
|
||||
private RelatedLinkImExporter relatedLinkImExporter;
|
||||
|
||||
@PostConstruct
|
||||
@Override
|
||||
protected void init() {
|
||||
protected final void init() {
|
||||
addRequiredEntities(
|
||||
Set.of(
|
||||
Category.class,
|
||||
|
|
@ -67,9 +74,15 @@ public abstract class AbstractContentItemImExporter<T extends ContentItem>
|
|||
);
|
||||
categorizationImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
||||
permissionImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
||||
|
||||
// Related link import requires all content items to be imported to
|
||||
// get the target item.
|
||||
relatedLinkImExporter.addRequiredEntities(Set.of(getEntityClass()));
|
||||
|
||||
initContentItemImExporter();
|
||||
}
|
||||
|
||||
|
||||
protected abstract void initContentItemImExporter();
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
|
|||
|
|
@ -18,8 +18,10 @@
|
|||
*/
|
||||
package org.librecms.contentsection;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
|
|
@ -575,6 +577,11 @@ import javax.xml.bind.annotation.XmlElementWrapper;
|
|||
+ " )"
|
||||
)
|
||||
})
|
||||
@JsonIdentityInfo(
|
||||
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
resolver = ContentItemIdResolver.class,
|
||||
property = "uuid"
|
||||
)
|
||||
public class ContentItem extends CcmObject implements Serializable, Exportable {
|
||||
|
||||
private static final long serialVersionUID = 5897287630227129653L;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (C) 2022 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.librecms.contentsection;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdResolver;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ContentItemIdResolver implements Serializable, ObjectIdResolver {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void bindItem(
|
||||
final ObjectIdGenerator.IdKey id,
|
||||
final Object object
|
||||
) {
|
||||
// According to the Jackson JavaDoc, this method can be used to keep
|
||||
// track of objects directly in a resolver implementation. We don't need
|
||||
// this here therefore this method is empty.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveId(final ObjectIdGenerator.IdKey id) {
|
||||
return CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(ContentItemRepository.class)
|
||||
.findByUuid(id.key.toString())
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No ContentItem with UUID %s found in the database.",
|
||||
id.key.toString()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIdResolver newForDeserialization(final Object context) {
|
||||
return new ContentItemIdResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseFor(final ObjectIdResolver resolverType) {
|
||||
return resolverType instanceof ContentItemIdResolver;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ package org.librecms.contenttypes;
|
|||
import org.libreccm.imexport.Processes;
|
||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +32,12 @@ import javax.enterprise.context.RequestScoped;
|
|||
@Processes(Article.class)
|
||||
public class ArticleImExporter extends AbstractContentItemImExporter<Article> {
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void initContentItemImExporter() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Article> getEntityClass() {
|
||||
return Article.class;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.librecms.contenttypes;
|
|||
import org.libreccm.imexport.Processes;
|
||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +32,12 @@ import javax.enterprise.context.RequestScoped;
|
|||
@Processes(Event.class)
|
||||
public class EventImExporter extends AbstractContentItemImExporter<Event> {
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void initContentItemImExporter() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Event> getEntityClass() {
|
||||
return Event.class;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.libreccm.imexport.Processes;
|
|||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
import org.librecms.contentsection.ContentItemRepository;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -32,12 +33,18 @@ import javax.transaction.Transactional;
|
|||
*/
|
||||
@RequestScoped
|
||||
@Processes(MultiPartArticle.class)
|
||||
public class MultiPartArticleImExporter
|
||||
public class MultiPartArticleImExporter
|
||||
extends AbstractContentItemImExporter<MultiPartArticle> {
|
||||
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void initContentItemImExporter() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Inject
|
||||
private ContentItemRepository itemRepository;
|
||||
|
||||
|
||||
@Inject
|
||||
private MultiPartArticleSectionRepository sectionRepo;
|
||||
|
||||
|
|
@ -45,8 +52,8 @@ public class MultiPartArticleImExporter
|
|||
public Class<MultiPartArticle> getEntityClass() {
|
||||
return MultiPartArticle.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void saveImportedEntity(final MultiPartArticle entity) {
|
||||
for (final MultiPartArticleSection section : entity.getSections()) {
|
||||
|
|
@ -54,5 +61,5 @@ public class MultiPartArticleImExporter
|
|||
}
|
||||
itemRepository.save(entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.librecms.contenttypes;
|
|||
import org.libreccm.imexport.Processes;
|
||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +32,12 @@ import javax.enterprise.context.RequestScoped;
|
|||
@Processes(News.class)
|
||||
public class NewsImExporter extends AbstractContentItemImExporter<News> {
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void initContentItemImExporter() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<News> getEntityClass() {
|
||||
return News.class;
|
||||
|
|
|
|||
Loading…
Reference in New Issue