[TRUNK][FEATURE]

- adds conversions for ContentItems Article, Event, MultiPartArticle and -Section, News
- renames ContentItems and Assets NgCmsCollection

git-svn-id: https://svn.libreccm.org/ccm/trunk@5380 8810af33-2d31-482b-a856-94f89814c4df
master
tosmers 2018-04-30 14:30:16 +00:00
parent de858421c4
commit 984a21b93f
50 changed files with 1412 additions and 205 deletions

View File

@ -16,6 +16,7 @@ package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.FileAsset;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.persistence.DataCollection;
@ -26,9 +27,12 @@ import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
import org.apache.log4j.Logger;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a FileAsset uploaded as one of N files attached to a content item
*
@ -289,4 +293,28 @@ public class FileAttachment extends FileAsset {
return s_config;
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<FileAttachment> getAllObjects() {
List<FileAttachment> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
FileAttachment.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
FileAttachment object = (FileAttachment) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.cms.portation.convertion;
package com.arsdigita.cms.portation.conversion;
import com.arsdigita.cms.portation.modules.assets.FileAsset;
@ -27,11 +27,11 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/3/18
*/
public class NgCmsCollection {
public class NgCmsFileAssetCollection {
public static Map<Long, FileAsset> fileAssets = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCmsCollection() {}
private NgCmsFileAssetCollection() {}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.assets;
import com.arsdigita.cms.contentassets.FileAttachment;
import com.arsdigita.cms.portation.modules.assets.FileAsset;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class FileAssetConversion extends AbstractConversion {
/**
* Retrieves all
* trunk-{@link com.arsdigita.cms.contentassets.FileAttachment}s from the
* persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link FileAsset}s focusing on keeping all the
* associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("file assets");
List<FileAttachment> trunkFileAssets = FileAttachment.getAllObjects();
ExportLogger.converting("file assets");
createFileAssetsAndSetAssociations(trunkFileAssets);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code FileAsset} and restores the
* associations to other classes.
*
* @param trunkFileAssets List of all
* {@link com.arsdigita.cms.contentassets.FileAttachment}s
* from this old trunk-system.
*/
private void createFileAssetsAndSetAssociations(final List<
FileAttachment> trunkFileAssets) {
int processed = 0;
for (FileAttachment trunkFileAsset : trunkFileAssets) {
// create file asset
FileAsset fileAsset = new FileAsset(trunkFileAsset);
processed++;
}
ExportLogger.created("file assets", processed);
}
}

View File

@ -19,7 +19,7 @@
package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.contentassets.FileAttachment;
import com.arsdigita.cms.portation.convertion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsFileAssetCollection;
import com.arsdigita.portation.Portable;
/**
@ -36,6 +36,6 @@ public class FileAsset extends BinaryAsset implements Portable {
public FileAsset(final FileAttachment trunkFileAsset) {
super(trunkFileAsset);
NgCmsCollection.fileAssets.put(this.getObjectId(), this);
NgCmsFileAssetCollection.fileAssets.put(this.getObjectId(), this);
}
}

View File

@ -16,10 +16,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.cms.portation.convertion;
package com.arsdigita.cms.portation.conversion;
import com.arsdigita.cms.portation.modules.assets.Image;
import com.arsdigita.cms.portation.modules.assets.LegalMetadata;
import java.util.HashMap;
import java.util.Map;
@ -28,11 +27,11 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/3/18
*/
public class NgCmsCollection {
public class NgCmsImageCollection {
public static Map<Long, Image> images = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCmsCollection() {}
private NgCmsImageCollection() {}
}

View File

@ -19,7 +19,7 @@
package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.portation.convertion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsImageCollection;
import com.arsdigita.portation.Portable;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
@ -46,7 +46,7 @@ public class Image extends BinaryAsset implements Portable {
//this.legalMetaData
NgCmsCollection.images.put(this.getObjectId(), this);
NgCmsImageCollection.images.put(this.getObjectId(), this);
}
public long getWidth() {

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.cms.portation.convertion;
package com.arsdigita.cms.portation.conversion;
import com.arsdigita.cms.portation.modules.assets.SideNote;
@ -27,11 +27,11 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/3/18
*/
public class NgCmsCollection {
public class NgCmsSideNoteCollection {
public static Map<Long, SideNote> sideNotes = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCmsCollection() {}
private NgCmsSideNoteCollection() {}
}

View File

@ -19,7 +19,7 @@
package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.contentassets.Note;
import com.arsdigita.cms.portation.convertion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsSideNoteCollection;
import com.arsdigita.cms.portation.modules.contentsection.Asset;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
@ -39,14 +39,13 @@ public class SideNote extends Asset implements Portable {
* @param trunkNote the trunk object
*/
public SideNote(final Note trunkNote) {
super("Title_" + trunkNote.getDisplayName(),
trunkNote.getDisplayName());
super(trunkNote.getID(), trunkNote.getDisplayName());
this.text = new LocalizedString();
final Locale language = Locale.getDefault();
this.text.addValue(language, trunkNote.getContent());
NgCmsCollection.sideNotes.put(this.getObjectId(), this);
NgCmsSideNoteCollection.sideNotes.put(this.getObjectId(), this);
}
public LocalizedString getText() {

View File

@ -21,11 +21,16 @@ package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentType;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* This content type represents an article.
@ -90,4 +95,28 @@ public class Article extends GenericArticle {
true);
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<Article> getAllObjects() {
List<Article> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
Article.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
Article object = (Article) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -27,11 +27,11 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/3/18
*/
public class NgCmsCollection {
public class NgCmsArticleCollection {
public static Map<Long, Article> articles = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCmsCollection() {}
private NgCmsArticleCollection() {}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.portation.modules.contenttypes.Article;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/19/18
*/
public class ArticleConversion extends AbstractConversion {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.contenttypes.Article}s
* from the persistent storage and collects them in a list. Then calls
* for creating the equivalent ng-{@link Article}s focusing on keeping
* all the associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("articles");
List<com.arsdigita.cms.contenttypes.Article> trunkArticles = com
.arsdigita.cms.contenttypes.Article.getAllObjects();
ExportLogger.converting("articles");
createArticlesAndSetAssociations(trunkArticles);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code Article} and restores
* the associations to other classes.
*
* @param trunkArticles List of all
* {@link com.arsdigita.cms.contenttypes.Article}s from
* this old trunk-system.
*/
private void createArticlesAndSetAssociations(final List<com.arsdigita
.cms.contenttypes.Article> trunkArticles) {
int processed = 0;
for (com.arsdigita.cms.contenttypes.Article trunkArticle :
trunkArticles) {
// create article
Article article = new Article(trunkArticle);
processed++;
}
ExportLogger.created("articles", processed);
}
}

View File

@ -18,14 +18,14 @@
*/
package com.arsdigita.cms.portation.modules.contenttypes;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsArticleCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import java.util.Locale;
import java.util.Objects;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -43,23 +43,29 @@ public class Article extends ContentItem implements Portable {
super(trunkArticle);
this.text = new LocalizedString();
final ItemCollection languageSets = Objects.requireNonNull(trunkArticle
.getContentBundle())
.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final com.arsdigita.cms.contenttypes.Article languageItem =
(com.arsdigita.cms.contenttypes.Article) languageSets
.getContentItem();
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
final ContentBundle languageBundle = trunkArticle.getContentBundle();
if (languageBundle != null) {
final ItemCollection languageSets = languageBundle.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final com.arsdigita.cms.contenttypes.Article languageItem =
(com.arsdigita.cms.contenttypes.Article) languageSets
.getContentItem();
this.text.addValue(language, languageItem.getTextAsset().getText());
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
final String text = languageItem.getTextAsset() != null
? languageItem.getTextAsset().getText()
: "";
this.text.addValue(language, text);
}
languageSets.close();
}
NgCmsCollection.articles.put(this.getObjectId(), this);
NgCmsArticleCollection.articles.put(this.getObjectId(), this);
}
public LocalizedString getText() {

View File

@ -20,15 +20,19 @@ package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentType;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p><code>DomainObject</code> class to represent Event <code>ContentType</code>
@ -325,4 +329,29 @@ public class Event extends GenericArticle {
return event;
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<Event> getAllObjects() {
List<Event> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
Event.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
Event object = (Event) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -27,11 +27,11 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/3/18
*/
public class NgCmsCollection {
public class NgCmsEventCollection {
public static Map<Long, Event> events = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCmsCollection() {}
private NgCmsEventCollection() {}
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.portation.modules.contenttypes.Event;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/19/18
*/
public class EventConversion extends AbstractConversion {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.contenttypes.Event}s from
* the persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link Event}s focusing on keeping all the
* associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("events");
List<com.arsdigita.cms.contenttypes.Event> trunkEvents = com
.arsdigita.cms.contenttypes.Event.getAllObjects();
ExportLogger.converting("events");
createEventsAndSetAssociations(trunkEvents);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code Event} and restores the
* associations to other classes.
*
* @param trunkEvents List of all
* {@link com.arsdigita.cms.contenttypes.Event}s from
* this old trunk-system.
*/
private void createEventsAndSetAssociations(final List<com.arsdigita.cms
.contenttypes.Event> trunkEvents) {
int processed = 0;
for (com.arsdigita.cms.contenttypes.Event trunkEvent : trunkEvents) {
// create event
Event event = new Event(trunkEvent);
processed++;
}
ExportLogger.created("events", processed);
}
}

View File

@ -18,15 +18,15 @@
*/
package com.arsdigita.cms.portation.modules.contenttypes;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsEventCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -61,31 +61,34 @@ public class Event extends ContentItem implements Portable {
this.mapLink = trunkEvent.getMapLink();
this.cost = new LocalizedString();
final ItemCollection languageSets = Objects.requireNonNull(trunkEvent
.getContentBundle())
.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final com.arsdigita.cms.contenttypes.Event languageItem =
((com.arsdigita.cms.contenttypes.Event) languageSets
.getContentItem());
final ContentBundle languageBundle = trunkEvent.getContentBundle();
if (languageBundle != null) {
final ItemCollection languageSets = languageBundle.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final com.arsdigita.cms.contenttypes.Event languageItem =
((com.arsdigita.cms.contenttypes.Event) languageSets
.getContentItem());
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
this.text.addValue(language, languageItem.getTextAsset().getText());
final String text = languageItem.getTextAsset() != null
? languageItem.getTextAsset().getText() : "";
this.text.addValue(language, text);
this.eventDate.addValue(language, languageItem.getEventDate());
this.location.addValue(language, languageItem.getLocation());
this.mainContributor.addValue(language, languageItem
.getMainContributor());
this.eventType.addValue(language, languageItem.getEventType());
this.cost.addValue(language, languageItem.getCost());
this.eventDate.addValue(language, languageItem.getEventDate());
this.location.addValue(language, languageItem.getLocation());
this.mainContributor.addValue(language, languageItem
.getMainContributor());
this.eventType.addValue(language, languageItem.getEventType());
this.cost.addValue(language, languageItem.getCost());
}
languageSets.close();
}
NgCmsCollection.events.put(this.getObjectId(), this);
NgCmsEventCollection.events.put(this.getObjectId(), this);
}
public LocalizedString getText() {

View File

@ -20,12 +20,18 @@ package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.*;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import org.apache.log4j.Logger;
/**
@ -287,4 +293,29 @@ public class ArticleSection extends ContentPage {
// where upon setDefaultContentSection will be called..
return null;
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<ArticleSection> getAllObjects() {
List<ArticleSection> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
ArticleSection.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
ArticleSection object = (ArticleSection) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -22,15 +22,19 @@ import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ExtraXMLGenerator;
import com.arsdigita.cms.contenttypes.ui.mparticle.ArticleSectionPanel;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataAssociation;
import com.arsdigita.persistence.DataAssociationCursor;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import org.apache.log4j.Logger;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
@ -293,4 +297,28 @@ public class MultiPartArticle extends ContentPage {
return generators;
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<MultiPartArticle> getAllObjects() {
List<MultiPartArticle> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
MultiPartArticle.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
MultiPartArticle object = (MultiPartArticle) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.cms.portation.conversion;
import com.arsdigita.bebop.FormData;
import com.arsdigita.cms.portation.modules.contenttypes.MultiPartArticle;
import com.arsdigita.cms.portation.modules.contenttypes.MultiPartArticleSection;
@ -29,7 +28,7 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/3/18
*/
public class NgCmsCollection {
public class NgCmsMPArticleCollection {
public static Map<Long, MultiPartArticle> multiPartArticles
= new HashMap<>();
public static Map<Long, MultiPartArticleSection> multiPartArticleSections
@ -38,5 +37,5 @@ public class NgCmsCollection {
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCmsCollection() {}
private NgCmsMPArticleCollection() {}
}

View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.contenttypes.ArticleSectionCollection;
import com.arsdigita.cms.portation.conversion.NgCmsMPArticleCollection;
import com.arsdigita.cms.portation.modules.contenttypes.MultiPartArticle;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class MultiPartArticleConversion extends AbstractConversion {
/**
* Retrieves all
* trunk-{@link com.arsdigita.cms.contenttypes.MultiPartArticle}s from the
* persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link MultiPartArticle}s focusing on
* keeping all the associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("mp articles");
List<com.arsdigita.cms.contenttypes.MultiPartArticle> trunkMPArticles
= com.arsdigita.cms.contenttypes.MultiPartArticle
.getAllObjects();
ExportLogger.converting("mp articles");
createMPArticlesAntSetAssociations(trunkMPArticles);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code MultiPartArticle} and
* restores the associations to other classes.
*
* @param trunkMPArticles List of all
* {@link com.arsdigita.cms.contenttypes.MultiPartArticle}s
* from this old trunk-system.
*/
private void createMPArticlesAntSetAssociations(final List<com.arsdigita
.cms.contenttypes.MultiPartArticle> trunkMPArticles) {
int processed = 0;
for (com.arsdigita.cms.contenttypes.MultiPartArticle trunkMPArticle :
trunkMPArticles) {
// create mp articles
MultiPartArticle multiPartArticle = new MultiPartArticle
(trunkMPArticle);
// set mp article sections
ArticleSectionCollection sectionCollection = trunkMPArticle
.getSections();
while (sectionCollection.next()) {
multiPartArticle.addSection(NgCmsMPArticleCollection
.multiPartArticleSections
.get(sectionCollection
.getArticleSection()
.getID()
.longValue()));
}
processed++;
}
ExportLogger.created("mp articles", processed);
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.contenttypes.ArticleSection;
import com.arsdigita.cms.portation.modules.contenttypes.MultiPartArticleSection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class MultiPartArticleSectionConversion extends AbstractConversion {
/**
* Retrieves all
* trunk-{@link ArticleSection}s from the
* persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link MultiPartArticleSection}s focusing on
* keeping all the associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("mp article sections");
List<ArticleSection> trunkMPArticleSections = ArticleSection
.getAllObjects();
ExportLogger.converting("mp article sections");
createMPArticleSectionsAndSetAssociations(trunkMPArticleSections);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code MultiPartArticleSection}
* and restores the associations to other classes.
*
* @param trunkMPArticleSections List of all
* {@link com.arsdigita.cms.contenttypes.ArticleSection}s
* from this old trunk-system.
*/
private void createMPArticleSectionsAndSetAssociations(final List<
ArticleSection> trunkMPArticleSections) {
int processed = 0;
for (ArticleSection trunkMPArticleSection : trunkMPArticleSections) {
// create mp article section
MultiPartArticleSection multiPartArticleSection = new
MultiPartArticleSection(trunkMPArticleSection);
processed++;
}
ExportLogger.created("mp article sections", processed);
}
}

View File

@ -18,8 +18,9 @@
*/
package com.arsdigita.cms.portation.modules.contenttypes;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsMPArticleCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
@ -28,7 +29,6 @@ import com.fasterxml.jackson.annotation.JsonIdentityReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -49,25 +49,29 @@ public class MultiPartArticle extends ContentItem implements Portable {
super(trunkMultiPartArticle);
this.summary = new LocalizedString();
this.sections = new ArrayList<>();
final ItemCollection languageSets = Objects.requireNonNull(
trunkMultiPartArticle.getContentBundle())
.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final com.arsdigita.cms.contenttypes.MultiPartArticle
languageItem = (com.arsdigita.cms.contenttypes
.MultiPartArticle) languageSets.getContentItem();
final ContentBundle languageBundle = trunkMultiPartArticle
.getContentBundle();
if (languageBundle != null) {
final ItemCollection languageSets = languageBundle.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final com.arsdigita.cms.contenttypes.MultiPartArticle
languageItem = (com.arsdigita.cms.contenttypes
.MultiPartArticle) languageSets.getContentItem();
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
this.summary.addValue(language, languageItem.getSummary());
this.summary.addValue(language, languageItem.getSummary());
}
languageSets.close();
}
NgCmsCollection.multiPartArticles.put(this.getObjectId(), this);
NgCmsMPArticleCollection.multiPartArticles.put(this.getObjectId(), this);
}
public LocalizedString getSummary() {

View File

@ -18,14 +18,14 @@
*/
package com.arsdigita.cms.portation.modules.contenttypes;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.contenttypes.ArticleSection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsMPArticleCollection;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import java.util.Locale;
import java.util.Objects;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -47,19 +47,22 @@ public class MultiPartArticleSection implements Portable {
this.pageBreak = trunkMultiPartArticleSection.isPageBreak();
this.text = new LocalizedString();
final ItemCollection languageSets = Objects.requireNonNull(
trunkMultiPartArticleSection.getContentBundle())
.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final ArticleSection languageItem = (ArticleSection) languageSets
.getContentItem();
final ContentBundle languageBundle = trunkMultiPartArticleSection
.getContentBundle();
if (languageBundle != null) {
final ItemCollection languageSets = languageBundle.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final ArticleSection languageItem = (ArticleSection) languageSets
.getContentItem();
this.title.addValue(language, languageItem.getTitle());
this.text.addValue(language, languageItem.getText().getText());
this.title.addValue(language, languageItem.getTitle());
this.text.addValue(language, languageItem.getText().getText());
}
languageSets.close();
}
NgCmsCollection.multiPartArticleSections.put(this.sectionId, this);
NgCmsMPArticleCollection.multiPartArticleSections.put(this.sectionId, this);
}
public long getSectionId() {

View File

@ -20,14 +20,19 @@ package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentType;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
/**
@ -174,4 +179,29 @@ public class NewsItem extends GenericArticle {
return newsItem;
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<NewsItem> getAllObjects() {
List<NewsItem> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
NewsItem.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
NewsItem object = (NewsItem) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -27,11 +27,11 @@ import java.util.Map;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/3/18
*/
public class NgCmsCollection {
public class NgCmsNewsCollection {
public static Map<Long, News> news = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCmsCollection() {}
private NgCmsNewsCollection() {}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.contenttypes.NewsItem;
import com.arsdigita.cms.portation.modules.contenttypes.News;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class NewsConversion extends AbstractConversion {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.contenttypes.NewsItem}s
* from the persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link News}s focusing on keeping all the
* associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("news");
List<NewsItem> allTrunkNews = NewsItem.getAllObjects();
ExportLogger.converting("news");
createNewsAndSetAssociations(allTrunkNews);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code News} and restores the
* associations to other classes.
*
* @param allTrunkNews List of all
* {@link com.arsdigita.cms.contenttypes.NewsItem}s
* from this old trunk-system.
*/
private void createNewsAndSetAssociations(final List<NewsItem> allTrunkNews) {
int processed = 0;
for (NewsItem trunkNews : allTrunkNews) {
// create news
News news = new News(trunkNews);
processed++;
}
ExportLogger.created("news", processed);
}
}

View File

@ -18,9 +18,10 @@
*/
package com.arsdigita.cms.portation.modules.contenttypes;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.contenttypes.NewsItem;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.conversion.NgCmsNewsCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
@ -50,22 +51,27 @@ public class News extends ContentItem implements Portable {
this.releaseDate = trunkNews.getLaunchDate();
this.homepage = trunkNews.isHomepage();
final ItemCollection languageSets = Objects.requireNonNull(trunkNews
.getContentBundle())
.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final NewsItem languageItem = (NewsItem) languageSets
.getContentItem();
final ContentBundle languageBundle = trunkNews
.getContentBundle();
if (languageBundle != null) {
final ItemCollection languageSets = languageBundle.getInstances();
while (languageSets.next()) {
final Locale language = new Locale(languageSets.getLanguage());
final NewsItem languageItem = (NewsItem) languageSets
.getContentItem();
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
addName(language, languageItem.getName());
addTitle(language, languageItem.getTitle());
addDescription(language, languageItem.getDescription());
this.text.addValue(language, languageItem.getTextAsset().getText());
final String text = languageItem.getTextAsset() != null
? languageItem.getTextAsset().getText() : "";
this.text.addValue(language, text);
}
languageSets.close();
}
NgCmsCollection.news.put(this.getObjectId(), this);
NgCmsNewsCollection.news.put(this.getObjectId(), this);
}
public LocalizedString getText() {

View File

@ -31,6 +31,7 @@ import com.arsdigita.cms.lifecycle.LifecycleDefinition;
import com.arsdigita.cms.lifecycle.LifecycleDefinitionCollection;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.globalization.Locale;
import com.arsdigita.kernel.Group;
import com.arsdigita.kernel.permissions.PermissionService;
@ -42,6 +43,7 @@ import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.FilterFactory;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import com.arsdigita.util.UncheckedWrapperException;
@ -53,6 +55,8 @@ import com.arsdigita.workflow.simple.WorkflowTemplate;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
// import org.apache.log4j.Level;
@ -1337,4 +1341,28 @@ public class ContentSection extends Application {
return URL.SERVLET_DIR + "/content-section";
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<ContentSection> getAllObjects() {
List<ContentSection> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
ContentSection.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
ContentSection object = (ContentSection) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -18,7 +18,9 @@
*/
package com.arsdigita.cms;
import com.arsdigita.cms.lifecycle.Lifecycle;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.formbuilder.PersistentForm;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.ACSObject;
@ -29,6 +31,7 @@ import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.DataQueryDataCollectionAdapter;
import com.arsdigita.persistence.FilterFactory;
import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.Web;
@ -889,4 +892,28 @@ public class ContentType extends ACSObject {
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<ContentType> getAllObjects() {
List<ContentType> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
ContentType.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
ContentType object = (ContentType) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -23,6 +23,7 @@ import com.arsdigita.cms.lifecycle.Lifecycle;
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
import com.arsdigita.cms.util.SecurityConstants;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.domain.DomainCollectionIterator;
import com.arsdigita.kernel.ACSObject;
@ -44,8 +45,10 @@ import com.arsdigita.util.UncheckedWrapperException;
import org.apache.log4j.Logger;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
/**
* This class represents folders for which to organize items in a tree hierarchy.
@ -856,4 +859,29 @@ public class Folder extends ContentItem {
+ "[contentsection:]/path/to/folder'");
}
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
*
* @return List of all objects
*/
public static List<Folder> getAllObjects() {
List<Folder> objectList = new ArrayList<>();
final Session session = SessionManager.getSession();
DomainCollection collection = new DomainCollection(session.retrieve(
Folder.BASE_DATA_OBJECT_TYPE));
while (collection.next()) {
Folder object = (Folder) collection
.getDomainObject();
if (object != null) {
objectList.add(object);
}
}
collection.close();
return objectList;
}
}

View File

@ -18,12 +18,17 @@
*/
package com.arsdigita.cms.portation.conversion;
import com.arsdigita.cms.portation.conversion.contentsection.ContentSectionConversion;
import com.arsdigita.cms.portation.conversion.contentsection.ContentTypeConversion;
import com.arsdigita.cms.portation.conversion.contentsection.FolderConversion;
import com.arsdigita.cms.portation.conversion.lifecycle.LifecycleConversion;
import com.arsdigita.cms.portation.conversion.lifecycle.LifecycleDefinitionConversion;
import com.arsdigita.cms.portation.conversion.lifecycle.PhaseConversion;
import com.arsdigita.cms.portation.conversion.lifecycle.PhaseDefinitionConversion;
import com.arsdigita.portation.AbstractConverter;
import java.lang.reflect.Method;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 2/12/18
@ -49,12 +54,58 @@ public class CmsConverter extends AbstractConverter {
* order, so that dependencies can only be set, where the objects have
* already been created.
*/
@SuppressWarnings("unchecked")
@Override
public void startConversions() {
public void startConversions() throws Exception {
PhaseDefinitionConversion.getInstance().convertAll();
LifecycleDefinitionConversion.getInstance().convertAll();
LifecycleConversion.getInstance().convertAll();
PhaseConversion.getInstance().convertAll();
FolderConversion.getInstance().convertAll();
ContentTypeConversion.getInstance().convertAll();
ContentSectionConversion.getInstance().convertAll();
final Class c = Class.forName("com.arsdigita.cms.portation" +
".conversion.contenttypes.ArticleConversion");
if (c != null) {
Method startConversionToNg = c.getDeclaredMethod("convertAll");
startConversionToNg.invoke(c.newInstance());
}
final Class c1 = Class.forName("com.arsdigita.cms.portation" +
".conversion.contenttypes.EventConversion");
if (c1 != null) {
Method startConversionToNg = c1.getDeclaredMethod("convertAll");
startConversionToNg.invoke(c1.newInstance());
}
final Class c2 = Class.forName("com.arsdigita.cms.portation" +
".conversion.contenttypes.MultiPartArticleSectionConversion");
if (c2 != null) {
Method startConversionToNg = c2.getDeclaredMethod("convertAll");
startConversionToNg.invoke(c2.newInstance());
}
final Class c3 = Class.forName("com.arsdigita.cms.portation" +
".conversion.contenttypes.MultiPartArticleConversion");
if (c3 != null) {
Method startConversionToNg = c3.getDeclaredMethod("convertAll");
startConversionToNg.invoke(c3.newInstance());
}
final Class c4 = Class.forName("com.arsdigita.cms.portation" +
".conversion.contenttypes.NewsConversion");
if (c4 != null) {
Method startConversionToNg = c4.getDeclaredMethod("convertAll");
startConversionToNg.invoke(c4.newInstance());
}
final Class c5 = Class.forName("com.arsdigita.cms.portation" +
".conversion.assets.FileAssetConversion");
if (c5 != null) {
Method startConversionToNg = c5.getDeclaredMethod("convertAll");
startConversionToNg.invoke(c5.newInstance());
}
}
}

View File

@ -25,6 +25,7 @@ import com.arsdigita.cms.portation.modules.contentsection.AttachmentList;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.cms.portation.modules.contentsection.ContentSection;
import com.arsdigita.cms.portation.modules.contentsection.ContentType;
import com.arsdigita.cms.portation.modules.contentsection.Folder;
import com.arsdigita.cms.portation.modules.contentsection.ItemAttachment;
import com.arsdigita.cms.portation.modules.lifecycle.Lifecycle;
import com.arsdigita.cms.portation.modules.lifecycle.LifecycleDefinition;
@ -39,23 +40,23 @@ import java.util.Map;
* @version created the 2/12/18
*/
public class NgCmsCollection {
public static Map<Long, Asset> assets = new HashMap<>();
public static Map<Long, BinaryAsset> binaryAssets = new HashMap<>();
public static Map<Long, LegalMetadata> legalMetadatas = new HashMap<>();
public static Map<Long, ItemAttachment> itemAttachments = new HashMap<>();
public static Map<Long, AttachmentList> attachmentLists = new HashMap<>();
public static Map<Long, ContentItem> contentItems = new HashMap<>();
public static Map<Long, ContentType> contentTypes = new HashMap<>();
public static Map<Long, ContentSection> contentSections = new HashMap<>();
public static Map<Long, Phase> phases = new HashMap<>();
public static Map<Long, Lifecycle> lifecycles = new HashMap<>();
public static Map<Long, LifecycleDefinition> lifecycleDefinitions = new
HashMap<>();
public static Map<Long, LifecycleDefinition> lifecycleDefinitions = new HashMap<>();
public static Map<Long, PhaseDefinition> phaseDefinitions = new HashMap<>();
public static Map<Long, Folder> folders = new HashMap<>();
public static Map<Long, ContentSection> contentSections = new HashMap<>();
public static Map<Long, ContentType> contentTypes = new HashMap<>();
public static Map<Long, ContentItem> contentItems = new HashMap<>();
public static Map<Long, LegalMetadata> legalMetadatas = new HashMap<>();
public static Map<Long, BinaryAsset> binaryAssets = new HashMap<>();
public static Map<Long, Asset> assets = new HashMap<>();
public static Map<Long, AttachmentList> attachmentLists = new HashMap<>();
public static Map<Long, ItemAttachment> itemAttachments = new HashMap<>();
/**
* Private constructor to prevent the instantiation of this class.

View File

@ -0,0 +1,223 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contentsection;
import com.arsdigita.cms.ContentTypeCollection;
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
import com.arsdigita.cms.ContentTypeWorkflowTemplate;
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
import com.arsdigita.cms.lifecycle.LifecycleDefinitionCollection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentSection;
import com.arsdigita.cms.portation.modules.contentsection.ContentType;
import com.arsdigita.cms.portation.modules.contentsection.Folder;
import com.arsdigita.cms.portation.modules.contentsection.FolderType;
import com.arsdigita.kernel.RoleCollection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import com.arsdigita.workflow.simple.TaskCollection;
import com.arsdigita.workflow.simple.WorkflowTemplate;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/16/18
*/
public class ContentSectionConversion extends AbstractConversion {
private static ContentSectionConversion instance;
static {
instance = new ContentSectionConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.cms.ContentSection}s from the
* persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link ContentSection}s focusing on keeping
* all the associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("content sections");
List<com.arsdigita.cms.ContentSection> trunkContentSections = com
.arsdigita.cms.ContentSection.getAllObjects();
ExportLogger.converting("content sections");
createContentSectionsAndSetAssociations(trunkContentSections);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code ContentSection} and
* restores the associations to other classes.
*
* @param trunkContentSections List of all
* {@link com.arsdigita.cms.ContentSection}s
* from this old trunk-system.
*/
private void createContentSectionsAndSetAssociations(final List<com
.arsdigita.cms.ContentSection> trunkContentSections) {
int processed = 0, pDocFolders = 0, pAssetFolders = 0;
for (com.arsdigita.cms.ContentSection trunkContentSection :
trunkContentSections) {
// create content section
ContentSection contentSection =
new ContentSection(trunkContentSection);
// set root documents folders and opposed association
Folder rootDocumentsFolder = NgCmsCollection
.folders
.get(trunkContentSection
.getRootFolder()
.getID()
.longValue());
if (rootDocumentsFolder == null) {
rootDocumentsFolder = new Folder(FolderType.DOCUMENTS_FOLDER,
contentSection.getDisplayName());
pDocFolders++;
}
contentSection.setRootDocumentsFolder(rootDocumentsFolder);
rootDocumentsFolder.setSection(contentSection);
// set root assets folder and opposed association
Folder rootAssetsFolder = new Folder(FolderType.ASSETS_FOLDER,
contentSection.getDisplayName());
pAssetFolders++;
contentSection.setRootAssetsFolder(rootAssetsFolder);
rootAssetsFolder.setSection(contentSection);
// set roles
RoleCollection roleCollection = trunkContentSection
.getStaffGroup().getRoles();
while (roleCollection.next()) {
contentSection.addRole(NgCoreCollection
.roles
.get(roleCollection
.getRole()
.getID()
.longValue()));
}
// set content types and opposed association
ContentTypeCollection contentTypeCollection = trunkContentSection
.getContentTypes();
while (contentTypeCollection.next()) {
final com.arsdigita.cms.ContentType trunkContentType =
contentTypeCollection.getContentType();
ContentType contentType = NgCmsCollection
.contentTypes
.get(trunkContentType
.getID()
.longValue());
contentSection.addContentType(contentType);
contentType.setContentSection(contentSection);
// set content type's missing associations
setContentTypesMissingAssociations(trunkContentSection,
trunkContentType);
}
// set lifecycle definitions
LifecycleDefinitionCollection lifecycleDefinitionCollection =
trunkContentSection.getLifecycleDefinitions();
while (lifecycleDefinitionCollection.next()) {
contentSection.addLifecycleDefinition(NgCmsCollection
.lifecycleDefinitions
.get(lifecycleDefinitionCollection
.getLifecycleDefinition()
.getID()
.longValue()));
}
// set workflow templates
TaskCollection workflowTemplateCollection = trunkContentSection
.getWorkflowTemplates();
while (workflowTemplateCollection.next()) {
final Workflow template = NgCoreCollection
.workflows
.get(workflowTemplateCollection
.getTask()
.getID()
.longValue());
if (template != null && template.isAbstractWorkflow())
contentSection.addWorkflowTemplate(template);
}
processed++;
}
ExportLogger.created("content sections", processed);
ExportLogger.created("folders (root document)", pDocFolders);
ExportLogger.created("folders (root asset)", pAssetFolders);
}
/**
* Sets the missing associations {@code defaultLifecycle} and
* {@code defaultWorkflow} for the given content type in that given
* content section. This wasn't possible in {@link ContentTypeConversion}
* because the content sections had still been unknown.
*
* @param trunkContentSection The content section
* @param trunkContentType The content type
*/
private void setContentTypesMissingAssociations(
final com.arsdigita.cms.ContentSection trunkContentSection,
final com.arsdigita.cms.ContentType trunkContentType) {
ContentType contentType = NgCmsCollection
.contentTypes
.get(trunkContentType
.getID()
.longValue());
// set content type's default lifecycle
final LifecycleDefinition trunkLifecycleDefinition =
ContentTypeLifecycleDefinition.getLifecycleDefinition(
trunkContentSection, trunkContentType);
if (trunkLifecycleDefinition != null)
contentType.setDefaultLifecycle(NgCmsCollection
.lifecycleDefinitions
.get(trunkLifecycleDefinition
.getID()
.longValue()));
// set content type's default workflow (template)
final WorkflowTemplate trunkWorkflowTemplate =
ContentTypeWorkflowTemplate.getWorkflowTemplate(
trunkContentSection, trunkContentType);
if (trunkWorkflowTemplate != null) {
final Workflow defaultWorkflow = NgCoreCollection
.workflows
.get(trunkWorkflowTemplate
.getID()
.longValue());
if (defaultWorkflow != null && defaultWorkflow.isAbstractWorkflow())
contentType.setDefaultWorkflow(defaultWorkflow);
}
}
public static ContentSectionConversion getInstance() {
return instance;
}
}

View File

@ -0,0 +1,88 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contentsection;
import com.arsdigita.cms.portation.modules.contentsection.ContentType;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/16/18
*/
public class ContentTypeConversion extends AbstractConversion {
private static ContentTypeConversion instance;
static {
instance = new ContentTypeConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.cms.ContentType}s from the
* persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link ContentType}s focusing on keeping
* all the associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("content types");
List<com.arsdigita.cms.ContentType> trunkContentTypes = com.arsdigita
.cms.ContentType.getAllObjects();
ExportLogger.converting("content types");
createContentTypesAndSetAssociations(trunkContentTypes);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code ContentType} and restores
* the associations to other classes.
*
* @param trunkContentTypes List of all
* {@link com.arsdigita.cms.ContentType}s from
* this old trunk-system.
*/
private void createContentTypesAndSetAssociations(final List<com
.arsdigita.cms.ContentType> trunkContentTypes) {
int processed = 0;
for (com.arsdigita.cms.ContentType trunkContentType :
trunkContentTypes) {
// create content type
ContentType contentType = new ContentType(trunkContentType);
// set default lifecycle
// -> will be done in ContentSectionConversion
// set default workflow
// -> will be done in ContentSectionConversion
processed++;
}
ExportLogger.created("content types", processed);
}
public static ContentTypeConversion getInstance() {
return instance;
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2015 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 com.arsdigita.cms.portation.conversion.contentsection;
import com.arsdigita.cms.portation.modules.contentsection.Folder;
import com.arsdigita.cms.portation.modules.contentsection.FolderType;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import java.util.List;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/16/18
*/
public class FolderConversion extends AbstractConversion {
private static FolderConversion instance;
static {
instance = new FolderConversion();
}
/**
* Retrieves all trunk-{@link com.arsdigita.cms.Folder}s from the
* persistent storage and collects them in a list. Then calls for
* creating the equivalent ng-{@link Folder}s focusing on keeping all the
* associations in tact.
*/
@Override
public void convertAll() {
ExportLogger.fetching("folders");
List<com.arsdigita.cms.Folder> trunkFolders = com.arsdigita.cms
.Folder.getAllObjects();
ExportLogger.converting("folders");
createFoldersAndSetAssociations(trunkFolders);
ExportLogger.newLine();
}
/**
* Creates the equivalent ng-class of the {@code Folder} and restores
* the associations to other classes.
*
* @param trunkFolders List of all {@link com.arsdigita.cms.Folder}s from
* this old trunk-system.
*/
private void createFoldersAndSetAssociations(final List<com.arsdigita.cms
.Folder> trunkFolders) {
int processed = 0;
for (com.arsdigita.cms.Folder trunkFolder : trunkFolders) {
// create folder
Folder folder = new Folder(trunkFolder);
// set section
// -> will be done somewhere else
// set type -> to DOCUMENT_FOLDER
folder.setType(FolderType.DOCUMENTS_FOLDER);
processed++;
}
ExportLogger.created("folders", processed);
}
public static FolderConversion getInstance() {
return instance;
}
}

View File

@ -20,7 +20,6 @@ package com.arsdigita.cms.portation.conversion.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.Lifecycle;
import com.arsdigita.cms.portation.modules.lifecycle.LifecycleDefinition;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
@ -60,30 +59,29 @@ public class LifecycleConversion extends AbstractConversion {
* Creates the equivalent ng-class of the {@code Lifecycle} and restores
* the associations to other classes.
*
* @param trunkLifecycles List of all {@link com.arsdigita.cms.lifecycle.Lifecycle}s
* @param trunkLifecycles List of all
* {@link com.arsdigita.cms.lifecycle.Lifecycle}s
* from this old trunk-system.
*/
private void createLifecyclesAndSetAssociations(final List<com.arsdigita
.cms.lifecycle.Lifecycle> trunkLifecycles) {
int processed = 0;
for (com.arsdigita.cms.lifecycle.Lifecycle trunkLifecycle :
trunkLifecycles) {
// create lifecycle
Lifecycle lifecycle = new Lifecycle(trunkLifecycle);
// set lifecycle definition
long lifecycleDefinitionId = trunkLifecycle
.getLifecycleDefinition()
.getID()
.longValue();
lifecycle.setLifecycleDefinition(NgCmsCollection
.lifecycleDefinitions
.get(lifecycleDefinitionId));
.get(trunkLifecycle
.getLifecycleDefinition()
.getID()
.longValue()));
processed++;
}
ExportLogger.created("lifecycles", processed);
}

View File

@ -21,7 +21,6 @@ package com.arsdigita.cms.portation.conversion.lifecycle;
import com.arsdigita.cms.lifecycle.PhaseDefinitionCollection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.LifecycleDefinition;
import com.arsdigita.cms.portation.modules.lifecycle.PhaseDefinition;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
@ -69,9 +68,9 @@ public class LifecycleDefinitionConversion extends AbstractConversion {
private void createLifecycleDefinitionsAndSetAssociations(final List<com
.arsdigita.cms.lifecycle.LifecycleDefinition> trunkLifecycleDefinitions) {
int processed = 0;
for (com.arsdigita.cms.lifecycle.LifecycleDefinition
trunkLifecycleDefinition : trunkLifecycleDefinitions) {
// create lifecycle definition
LifecycleDefinition lifecycleDefinition = new LifecycleDefinition
(trunkLifecycleDefinition);
@ -79,23 +78,18 @@ public class LifecycleDefinitionConversion extends AbstractConversion {
// set phase definitions
PhaseDefinitionCollection phaseDefinitionCollection =
trunkLifecycleDefinition.getPhaseDefinitions();
while (phaseDefinitionCollection.next()) {
long phaseDefinitionId = phaseDefinitionCollection
.getPhaseDefinition()
.getID()
.longValue();
PhaseDefinition phaseDefinition = NgCmsCollection
lifecycleDefinition.addPhaseDefinition(NgCmsCollection
.phaseDefinitions
.get(phaseDefinitionId);
lifecycleDefinition.addPhaseDefinition(phaseDefinition);
.get(phaseDefinitionCollection
.getPhaseDefinition()
.getID()
.longValue()));
}
phaseDefinitionCollection.close();
processed++;
}
ExportLogger.created("lifecycle definitions", processed);
}

View File

@ -21,7 +21,6 @@ package com.arsdigita.cms.portation.conversion.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.Lifecycle;
import com.arsdigita.cms.portation.modules.lifecycle.Phase;
import com.arsdigita.cms.portation.modules.lifecycle.PhaseDefinition;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
@ -66,34 +65,30 @@ public class PhaseConversion extends AbstractConversion {
private void createPhasesAndSetAssociations(final List<com.arsdigita.cms
.lifecycle.Phase> trunkPhases) {
int processed = 0;
for (com.arsdigita.cms.lifecycle.Phase trunkPhase : trunkPhases) {
// create phase
Phase phase = new Phase(trunkPhase);
// set phase definition
long phaseDefinitionId = trunkPhase
.getPhaseDefinition()
.getID()
.longValue();
phase.setPhaseDefinition(NgCmsCollection
.phaseDefinitions
.get(phaseDefinitionId));
.get(trunkPhase
.getPhaseDefinition()
.getID()
.longValue()));
// set lifecycle and opposed association
long lifecycleId = trunkPhase
.getLifecycle()
.getID()
.longValue();
Lifecycle lifecycle = NgCmsCollection
.lifecycles
.get(lifecycleId);
.get(trunkPhase
.getLifecycle()
.getID()
.longValue());
phase.setLifecycle(lifecycle);
lifecycle.addPhase(phase);
processed++;
}
ExportLogger.created("phases", processed);
}

View File

@ -49,17 +49,23 @@ public class PhaseDefinitionConversion extends AbstractConversion {
= com.arsdigita.cms.lifecycle.PhaseDefinition.getAllObjects();
ExportLogger.converting("phase definitions");
createPhaseDefinitionsAndSetAssociations(trunkPhaseDefinitions);
ExportLogger.newLine();
}
private void createPhaseDefinitionsAndSetAssociations(final List<com
.arsdigita.cms.lifecycle.PhaseDefinition> trunkPhaseDefinitions) {
int processed = 0;
for (com.arsdigita.cms.lifecycle.PhaseDefinition
trunkPhaseDefinition : trunkPhaseDefinitions) {
// create phase definitions
new PhaseDefinition(trunkPhaseDefinition);
processed++;
}
ExportLogger.created("phase definitions", processed);
ExportLogger.newLine();
}
/**

View File

@ -19,11 +19,11 @@
package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@ -61,17 +61,17 @@ public class Asset extends CcmObject {
/**
* Specific constructor for subclass SideNews.
*
* @param title The title of this asset
* @param objectId The id of this asset
* @param displayName The display name as the {@link CcmObject}
*/
public Asset(final String title, final String displayName) {
super(displayName);
public Asset(final BigDecimal objectId, final String displayName) {
super(objectId, displayName);
this.itemAttachments = new ArrayList<>();
this.title = new LocalizedString();
final Locale language = Locale.getDefault();
this.title.addValue(language, title);
this.title.addValue(language, displayName + "_title");
NgCmsCollection.assets.put(this.getObjectId(), this);
}

View File

@ -71,7 +71,8 @@ public class ContentItem extends CcmObject {
this.name = new LocalizedString();
this.title = new LocalizedString();
this.description = new LocalizedString();
// localized string-entries will be set in subclasses e.g. Article, News
// values for localized string-entries will be added in subclasses
// e.g. Article, News
//this.contentType
this.version = ContentItemVersionMapper
@ -86,9 +87,12 @@ public class ContentItem extends CcmObject {
this.creationDate = trunkContentItem.getCreationDate();
this.lastModified = trunkContentItem.getLastModifiedDate();
this.creationUserName = trunkContentItem.getCreationUser().getName();
this.creationUserName = trunkContentItem.getCreationUser() != null
? trunkContentItem.getCreationUser().getName()
: "";
this.lastModifyingUserName = trunkContentItem.getLastModifiedUser()
.getName();
!= null ? trunkContentItem.getLastModifiedUser().getName()
: "";
NgCmsCollection.contentItems.put(this.getObjectId(), this);
}

View File

@ -20,8 +20,8 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.LifecycleDefinition;
import com.arsdigita.portation.modules.core.web.CcmApplication;
import com.arsdigita.portation.modules.core.security.Role;
import com.arsdigita.portation.modules.core.web.CcmApplication;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -44,10 +44,10 @@ public class ContentSection extends CcmApplication {
private String itemResolverClass;
private String templateResolverClass;
private String xmlGeneratorClass;
@JsonIdentityReference(alwaysAsId = true)
private List<Role> roles;
private Locale defaultLocale;
@JsonIdentityReference(alwaysAsId = true)
private List<Role> roles;
@JsonIgnore
private List<ContentType> contentTypes;
@JsonIdentityReference(alwaysAsId = true)
private List<LifecycleDefinition> lifecycleDefinitions;
@ -74,11 +74,11 @@ public class ContentSection extends CcmApplication {
.getTemplateResolverClassName();
this.xmlGeneratorClass = trunkContentSection.getXMLGeneratorClassName();
this.defaultLocale = (trunkContentSection.getDefaultLocale() != null)
? trunkContentSection.getDefaultLocale().toJavaLocale()
: Locale.getDefault();
this.roles = new ArrayList<>();
this.defaultLocale = trunkContentSection
.getDefaultLocale().toJavaLocale();
this.contentTypes = new ArrayList<>();
this.lifecycleDefinitions = new ArrayList<>();
this.workflowTemplates = new ArrayList<>();

View File

@ -26,7 +26,6 @@ import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Locale;
@ -36,12 +35,12 @@ import java.util.Locale;
*/
public class ContentType extends CcmObject implements Portable {
private String contentItemClass;
@JsonIgnore
@JsonIdentityReference(alwaysAsId = true)
private ContentSection contentSection;
private LocalizedString label;
private LocalizedString description;
private String ancestors;
private String descendents;
private String descendants;
private ContentTypeMode mode;
@JsonIdentityReference(alwaysAsId = true)
private LifecycleDefinition defaultLifecycle;
@ -67,10 +66,11 @@ public class ContentType extends CcmObject implements Portable {
description.addValue(locale, trunkContentType.getDescription());
this.ancestors = trunkContentType.getAncestors();
this.descendents = trunkContentType.getDescendants();
this.descendants = trunkContentType.getDescendants();
this.mode = ContentTypeModeMapper
.mapContentTypeMode(trunkContentType.getMode());
//this.defaultLifecycle
//this.defaultWorkflow
@ -117,12 +117,12 @@ public class ContentType extends CcmObject implements Portable {
this.ancestors = ancestors;
}
public String getDescendents() {
return descendents;
public String getDescendants() {
return descendants;
}
public void setDescendents(final String descendents) {
this.descendents = descendents;
public void setDescendants(final String descendants) {
this.descendants = descendants;
}
public ContentTypeMode getMode() {

View File

@ -18,6 +18,8 @@
*/
package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.modules.core.categorization.Category;
import com.arsdigita.portation.modules.core.categorization.util.CategoryInformation;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -32,26 +34,59 @@ public class Folder extends Category {
private FolderType type;
/**
* Constructor for the ng-object.
* Constructor for the ng-object, if old trunk object was retrieved from
* systems database storage.
*
* => use to convert folders
*
* @param trunkFolder the trunk object
*/
public Folder(final com.arsdigita.cms.Folder trunkFolder) {
super(new CategoryInformation(
trunkFolder.getID(),
trunkFolder.getDisplayName(),
trunkFolder.getID().toString(),
trunkFolder.getName(),
trunkFolder.getLabel(),
trunkFolder.getAdditionalInfo(),
true,
true,
false,
0)
);
this.type = FolderType.DOCUMENTS_FOLDER;
0));
//this.section
//this.type
NgCmsCollection.folders.put(this.getObjectId(), this);
}
/**
* Constructor for the ng-object, if old trunk object did not exist and a
* NEW one needed to be created. e.g. a new root folder for a content
* section.
*
* => use to create new folders for a content section with selected a
* {@link FolderType}
*
* @param folderType The type of the new folder
* @param sectionName The name of the section
*/
public Folder(final FolderType folderType, final String sectionName) {
super(new CategoryInformation(
ACSObject.generateID(),
folderType + "-" + sectionName,
folderType + "-" + sectionName,
folderType + "-" + sectionName,
"This is the " + folderType + " for the content "
+ "section: " + sectionName,
true,
true,
false,
0));
//this.section
this.type = folderType;
NgCmsCollection.folders.put(this.getObjectId(), this);
}
public ContentSection getSection() {

View File

@ -32,5 +32,5 @@ public abstract class AbstractConverter {
* order, so that dependencies can only be set, where the objects have
* already been created.
*/
public abstract void startConversions();
public abstract void startConversions() throws Exception;
}

View File

@ -18,8 +18,6 @@
*/
package com.arsdigita.portation.cmd;
import com.arsdigita.portation.conversion.CoreConverter;
import java.lang.reflect.Method;
/**

View File

@ -111,17 +111,18 @@ public class WorkflowConversion extends AbstractConversion {
for (com.arsdigita.workflow.simple.Workflow trunkWorkflow :
trunkWorkflows) {
Workflow workflow = NgCoreCollection
.workflows
.get(trunkWorkflow.getID().longValue());
// set template associations
WorkflowTemplate trunkWorkflowTemplate = trunkWorkflow
.getWorkflowTemplate();
if (trunkWorkflowTemplate != null) {
Workflow workflow = NgCoreCollection
.workflows
.get(trunkWorkflow.getID().longValue());
Workflow template = NgCoreCollection
.workflows
.get(trunkWorkflowTemplate.getID().longValue());
.workflows
.get(trunkWorkflowTemplate.getID().longValue());
workflow.setTemplate(template);
template.setAbstractWorkflow(true);
} else

View File

@ -119,9 +119,10 @@ public class Category extends CcmObject implements Portable {
* @param categoryInformation the trunk object
*/
public Category(final CategoryInformation categoryInformation) {
super(categoryInformation.getDisplayName());
super(categoryInformation.getObjectId(),
categoryInformation.getDisplayName());
this.uniqueId = categoryInformation.getUniqueId();
this.uniqueId = categoryInformation.getObjectId().toString();
this.name = categoryInformation.getName();
this.title = categoryInformation.getTitle();

View File

@ -20,6 +20,7 @@ package com.arsdigita.portation.modules.core.categorization.util;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import java.math.BigDecimal;
import java.util.Locale;
/**
@ -29,8 +30,8 @@ import java.util.Locale;
* @version created the 3/2/18
*/
public class CategoryInformation {
private BigDecimal objectId;
private String displayName;
private String uniqueId;
private String name;
private LocalizedString title;
private LocalizedString description;
@ -39,8 +40,8 @@ public class CategoryInformation {
private boolean abstractCategory;
private long categoryOrder;
public CategoryInformation(final String displayName,
final String uniqueId,
public CategoryInformation(final BigDecimal objectId,
final String displayName,
final String name,
final String title,
final String description,
@ -48,9 +49,9 @@ public class CategoryInformation {
final boolean visible,
final boolean abstractCategory,
final long categoryOrder) {
this.displayName = displayName;
this.objectId = objectId;
this.uniqueId = uniqueId;
this.displayName = displayName;
this.name = name;
this.title = new LocalizedString();
@ -66,12 +67,12 @@ public class CategoryInformation {
this.categoryOrder = categoryOrder;
}
public String getDisplayName() {
return displayName;
public BigDecimal getObjectId() {
return objectId;
}
public String getUniqueId() {
return uniqueId;
public String getDisplayName() {
return displayName;
}
public String getName() {

View File

@ -28,6 +28,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@ -75,9 +76,14 @@ public class CcmObject {
NgCoreCollection.ccmObjects.put(this.objectId, this);
}
// specific constructor for ldn-terms' domain and Asset SideNote
// specific constructor for ldn-terms' domain
public CcmObject(final String displayName) {
this.objectId = ACSObject.generateID().longValue();
this(ACSObject.generateID(), displayName);
}
// specific constructor for sideNote asset and folders
public CcmObject(final BigDecimal objectId, final String displayName) {
this.objectId = objectId.longValue();
this.uuid = UUID.randomUUID().toString();
this.displayName = displayName;