ImExporters for Article, News and Event

Former-commit-id: f9f1124a71
pull/2/head
Jens Pelzetter 2019-11-26 21:40:59 +01:00
parent 538881b6bb
commit 1511873311
6 changed files with 119 additions and 2 deletions

View File

@ -0,0 +1,45 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.librecms.contentsection;
import org.libreccm.categorization.Category;
import org.libreccm.imexport.AbstractEntityImExporter;
import org.libreccm.imexport.Exportable;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.transaction.Transactional;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T>
*/
public abstract class AbstractContentItemImExporter<T extends ContentItem>
extends AbstractEntityImExporter<T> {
@Inject
private ContentItemRepository itemRepository;
@Override
protected Set<Class<? extends Exportable>> getRequiredEntities() {
final Set<Class<? extends Exportable>> entities = new HashSet<>();
entities.add(Category.class);
entities.add(ContentSection.class);
return entities;
}
@Override
@Transactional(Transactional.TxType.REQUIRED)
public void saveImportedEntity(final T entity) {
itemRepository.save(entity);
}
}

View File

@ -56,6 +56,7 @@ import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import org.hibernate.envers.NotAudited; import org.hibernate.envers.NotAudited;
import org.libreccm.imexport.Exportable;
import org.librecms.contentsection.privileges.ItemPrivileges; import org.librecms.contentsection.privileges.ItemPrivileges;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
@ -594,7 +595,7 @@ import javax.persistence.OrderBy;
+ " )" + " )"
) )
}) })
public class ContentItem extends CcmObject implements Serializable { public class ContentItem extends CcmObject implements Serializable, Exportable {
private static final long serialVersionUID = 5897287630227129653L; private static final long serialVersionUID = 5897287630227129653L;

View File

@ -18,6 +18,7 @@
*/ */
package org.librecms.contentsection; package org.librecms.contentsection;
import org.libreccm.imexport.Exportable;
import org.libreccm.security.RecursivePermissions; import org.libreccm.security.RecursivePermissions;
import org.libreccm.security.Role; import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
@ -116,7 +117,9 @@ import static org.librecms.CmsConstants.*;
// creator = ContentSectionCreator.class, // creator = ContentSectionCreator.class,
// servlet = ContentSectionServlet.class, // servlet = ContentSectionServlet.class,
// instanceForm = ApplicationInstanceForm.class) // instanceForm = ApplicationInstanceForm.class)
public class ContentSection extends CcmApplication implements Serializable { public class ContentSection
extends CcmApplication
implements Serializable, Exportable {
private static final long serialVersionUID = -671718122153931727L; private static final long serialVersionUID = -671718122153931727L;

View File

@ -0,0 +1,26 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.librecms.contenttypes;
import org.libreccm.imexport.Processes;
import org.librecms.contentsection.AbstractContentItemImExporter;
import javax.enterprise.context.RequestScoped;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Processes(Article.class)
public class ArticleImExporter extends AbstractContentItemImExporter<Article> {
@Override
protected Class<Article> getEntityClass() {
return Article.class;
}
}

View File

@ -0,0 +1,21 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.librecms.contenttypes;
import org.librecms.contentsection.AbstractContentItemImExporter;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class EventImExporter extends AbstractContentItemImExporter<Event> {
@Override
protected Class<Event> getEntityClass() {
return Event.class;
}
}

View File

@ -0,0 +1,21 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.librecms.contenttypes;
import org.librecms.contentsection.AbstractContentItemImExporter;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class NewsImExporter extends AbstractContentItemImExporter<News> {
@Override
protected Class<News> getEntityClass() {
return News.class;
}
}