Updated ImExporters for content items
parent
b3f66535a4
commit
69bcf4c8f6
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2022-12-24T130950",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-18T182914",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@librecms/ccm-cms",
|
||||
"version": "7.0.0-SNAPSHOT.2022-12-24T130950",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-18T182914",
|
||||
"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-12-24T130950",
|
||||
"version": "7.0.0-SNAPSHOT.2023-01-18T182914",
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.librecms.contenttypes;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -49,8 +48,10 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
@Entity
|
||||
@Audited
|
||||
@Table(name = "ARTICLES", schema = DB_SCHEMA)
|
||||
@ContentTypeDescription(labelBundle = "org.librecms.contenttypes.Article",
|
||||
descriptionBundle = "org.librecms.contenttypes.Article")
|
||||
@ContentTypeDescription(
|
||||
labelBundle = "org.librecms.contenttypes.Article",
|
||||
descriptionBundle = "org.librecms.contenttypes.Article"
|
||||
)
|
||||
@MvcAuthoringKit(
|
||||
createStep = MvcArticleCreateStep.class,
|
||||
authoringSteps = {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ package org.librecms.contenttypes;
|
|||
import org.libreccm.imexport.Processes;
|
||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
|
|
@ -41,4 +43,20 @@ public class ArticleImExporter extends AbstractContentItemImExporter<Article> {
|
|||
return Article.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateExistingContentItem(
|
||||
final Article existingContentItem,
|
||||
final Article importedContentItem
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getText(),
|
||||
importedContentItem.getText()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getText(),
|
||||
existingContentItem.getText()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ package org.librecms.contenttypes;
|
|||
import org.libreccm.imexport.Processes;
|
||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
|
|
@ -41,4 +43,93 @@ public class EventImExporter extends AbstractContentItemImExporter<Event> {
|
|||
return Event.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateExistingContentItem(
|
||||
final Event existingContentItem,
|
||||
final Event importedContentItem
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getText(),
|
||||
importedContentItem.getText()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getText(),
|
||||
existingContentItem.getText()
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getStartDate(),
|
||||
importedContentItem.getStartDate()
|
||||
)) {
|
||||
existingContentItem.setStartDate(
|
||||
importedContentItem.getStartDate()
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getEndDate(),
|
||||
importedContentItem.getEndDate()
|
||||
)) {
|
||||
existingContentItem.setEndDate(importedContentItem.getEndDate());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getEventDate(),
|
||||
importedContentItem.getEventDate()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getEventDate(),
|
||||
existingContentItem.getEventDate()
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getLocation(),
|
||||
importedContentItem.getLocation()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getLocation(),
|
||||
existingContentItem.getLocation()
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getMainContributor(),
|
||||
importedContentItem.getMainContributor()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getMainContributor(),
|
||||
existingContentItem.getMainContributor()
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getEventType(),
|
||||
importedContentItem.getEventType()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getEventType(),
|
||||
existingContentItem.getEventType()
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getMapLink(),
|
||||
importedContentItem.getMapLink()
|
||||
)) {
|
||||
existingContentItem.setMapLink(importedContentItem.getMapLink());
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getCost(),
|
||||
importedContentItem.getCost()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getCost(),
|
||||
existingContentItem.getCost()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ import org.libreccm.imexport.Processes;
|
|||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
import org.librecms.contentsection.ContentItemRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -43,6 +47,9 @@ public class MultiPartArticleImExporter
|
|||
@Inject
|
||||
private ContentItemRepository itemRepository;
|
||||
|
||||
@Inject
|
||||
private MultiPartArticleSectionManager sectionManager;
|
||||
|
||||
@Inject
|
||||
private MultiPartArticleSectionRepository sectionRepo;
|
||||
|
||||
|
|
@ -60,4 +67,47 @@ public class MultiPartArticleImExporter
|
|||
itemRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateExistingContentItem(
|
||||
final MultiPartArticle existingContentItem,
|
||||
final MultiPartArticle importedContentItem
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getSummary(),
|
||||
importedContentItem.getSummary()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getSummary(),
|
||||
existingContentItem.getSummary()
|
||||
);
|
||||
}
|
||||
|
||||
final List<MultiPartArticleSection> missingSections = importedContentItem
|
||||
.getSections()
|
||||
.stream()
|
||||
.filter(
|
||||
section -> existingContentItem.getSections().contains(section)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for(final MultiPartArticleSection missingSection : missingSections) {
|
||||
final MultiPartArticleSection newSection = new MultiPartArticleSection();
|
||||
newSection.setPageBreak(missingSection.isPageBreak());
|
||||
newSection.setRank(missingSection.getRank());
|
||||
syncLocalizedStrings(
|
||||
missingSection.getText(),
|
||||
newSection.getText()
|
||||
);
|
||||
syncLocalizedStrings(
|
||||
missingSection.getTitle(),
|
||||
newSection.getTitle()
|
||||
);
|
||||
|
||||
sectionManager.addSectionToMultiPartArticle(
|
||||
newSection,
|
||||
existingContentItem
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ package org.librecms.contenttypes;
|
|||
import org.libreccm.imexport.Processes;
|
||||
import org.librecms.contentsection.AbstractContentItemImExporter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
|
|
@ -41,4 +43,33 @@ public class NewsImExporter extends AbstractContentItemImExporter<News> {
|
|||
return News.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateExistingContentItem(
|
||||
final News existingContentItem,
|
||||
final News importedContentItem
|
||||
) {
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getText(),
|
||||
importedContentItem.getText()
|
||||
)) {
|
||||
syncLocalizedStrings(
|
||||
importedContentItem.getText(),
|
||||
existingContentItem.getText()
|
||||
);
|
||||
}
|
||||
|
||||
if (!Objects.equals(
|
||||
existingContentItem.getReleaseDate(),
|
||||
importedContentItem.getReleaseDate()
|
||||
)) {
|
||||
existingContentItem.setReleaseDate(
|
||||
importedContentItem.getReleaseDate()
|
||||
);
|
||||
}
|
||||
|
||||
if (existingContentItem.isHomepage() != importedContentItem.isHomepage()) {
|
||||
existingContentItem.setHomepage(importedContentItem.isHomepage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue