diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java index fb71a2623..52011aa41 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachment.java @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/conversion/NgCmsFileAssetCollection.java similarity index 90% rename from ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java rename to ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/conversion/NgCmsFileAssetCollection.java index dbdfd5260..dfdd7dccc 100644 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/conversion/NgCmsFileAssetCollection.java @@ -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 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 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); + } +} diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/modules/assets/FileAsset.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/modules/assets/FileAsset.java index 8de84701a..5a69ccf3c 100644 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/modules/assets/FileAsset.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/modules/assets/FileAsset.java @@ -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); } } diff --git a/ccm-cms-assets-imagestep/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java b/ccm-cms-assets-imagestep/src/com/arsdigita/cms/portation/conversion/NgCmsImageCollection.java similarity index 86% rename from ccm-cms-assets-imagestep/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java rename to ccm-cms-assets-imagestep/src/com/arsdigita/cms/portation/conversion/NgCmsImageCollection.java index 8a57323b3..40f709c8e 100644 --- a/ccm-cms-assets-imagestep/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java +++ b/ccm-cms-assets-imagestep/src/com/arsdigita/cms/portation/conversion/NgCmsImageCollection.java @@ -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 Tobias Osmers<\a> * @version created the 4/3/18 */ -public class NgCmsCollection { +public class NgCmsSideNoteCollection { public static Map sideNotes = new HashMap<>(); /** * Private constructor to prevent the instantiation of this class. */ - private NgCmsCollection() {} + private NgCmsSideNoteCollection() {} } diff --git a/ccm-cms-assets-notes/src/com/arsdigita/cms/portation/modules/assets/SideNote.java b/ccm-cms-assets-notes/src/com/arsdigita/cms/portation/modules/assets/SideNote.java index 9e1cbd7a9..9883608fc 100644 --- a/ccm-cms-assets-notes/src/com/arsdigita/cms/portation/modules/assets/SideNote.java +++ b/ccm-cms-assets-notes/src/com/arsdigita/cms/portation/modules/assets/SideNote.java @@ -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() { diff --git a/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/Article.java b/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/Article.java index 4c3301694..49d607a3a 100755 --- a/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/Article.java +++ b/ccm-cms-types-article/src/com/arsdigita/cms/contenttypes/Article.java @@ -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
getAllObjects() { + List
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; + } } diff --git a/ccm-cms-types-article/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java b/ccm-cms-types-article/src/com/arsdigita/cms/portation/conversion/NgCmsArticleCollection.java similarity index 93% rename from ccm-cms-types-article/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java rename to ccm-cms-types-article/src/com/arsdigita/cms/portation/conversion/NgCmsArticleCollection.java index 9a766344c..e382dcaca 100644 --- a/ccm-cms-types-article/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java +++ b/ccm-cms-types-article/src/com/arsdigita/cms/portation/conversion/NgCmsArticleCollection.java @@ -27,11 +27,11 @@ import java.util.Map; * @author 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 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 trunkArticles) { + int processed = 0; + for (com.arsdigita.cms.contenttypes.Article trunkArticle : + trunkArticles) { + + // create article + Article article = new Article(trunkArticle); + + processed++; + } + ExportLogger.created("articles", processed); + } +} diff --git a/ccm-cms-types-article/src/com/arsdigita/cms/portation/modules/contenttypes/Article.java b/ccm-cms-types-article/src/com/arsdigita/cms/portation/modules/contenttypes/Article.java index 8925b49d0..09d277cfe 100644 --- a/ccm-cms-types-article/src/com/arsdigita/cms/portation/modules/contenttypes/Article.java +++ b/ccm-cms-types-article/src/com/arsdigita/cms/portation/modules/contenttypes/Article.java @@ -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 DomainObject class to represent Event ContentType @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java b/ccm-cms-types-event/src/com/arsdigita/cms/portation/conversion/NgCmsEventCollection.java similarity index 94% rename from ccm-cms-types-event/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java rename to ccm-cms-types-event/src/com/arsdigita/cms/portation/conversion/NgCmsEventCollection.java index 529dbe566..57ad109f0 100644 --- a/ccm-cms-types-event/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java +++ b/ccm-cms-types-event/src/com/arsdigita/cms/portation/conversion/NgCmsEventCollection.java @@ -27,11 +27,11 @@ import java.util.Map; * @author 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 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 trunkEvents) { + int processed = 0; + for (com.arsdigita.cms.contenttypes.Event trunkEvent : trunkEvents) { + + // create event + Event event = new Event(trunkEvent); + + processed++; + } + ExportLogger.created("events", processed); + } +} diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/portation/modules/contenttypes/Event.java b/ccm-cms-types-event/src/com/arsdigita/cms/portation/modules/contenttypes/Event.java index 1d646835b..26cb68add 100644 --- a/ccm-cms-types-event/src/com/arsdigita/cms/portation/modules/contenttypes/Event.java +++ b/ccm-cms-types-event/src/com/arsdigita/cms/portation/modules/contenttypes/Event.java @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java index 57fe4bc60..03325657e 100755 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/contenttypes/MultiPartArticle.java @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/NgCmsMPArticleCollection.java similarity index 93% rename from ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java rename to ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/NgCmsMPArticleCollection.java index b92d40866..cf13cc167 100644 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/NgCmsMPArticleCollection.java @@ -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 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 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 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); + } +} diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/contenttypes/MultiPartArticleSectionConversion.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/contenttypes/MultiPartArticleSectionConversion.java new file mode 100644 index 000000000..15f1ce1ae --- /dev/null +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/conversion/contenttypes/MultiPartArticleSectionConversion.java @@ -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 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); + } +} diff --git a/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/modules/contenttypes/MultiPartArticle.java b/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/modules/contenttypes/MultiPartArticle.java index 25fb2e40d..42dadd855 100644 --- a/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/modules/contenttypes/MultiPartArticle.java +++ b/ccm-cms-types-mparticle/src/com/arsdigita/cms/portation/modules/contenttypes/MultiPartArticle.java @@ -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 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() { diff --git a/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java b/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java index 6f2b18a1b..dc0276833 100755 --- a/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java +++ b/ccm-cms-types-newsitem/src/com/arsdigita/cms/contenttypes/NewsItem.java @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java b/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/conversion/NgCmsNewsCollection.java similarity index 94% rename from ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java rename to ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/conversion/NgCmsNewsCollection.java index 61ad63691..61a5171ef 100644 --- a/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/conversion/NgCmsCollection.java +++ b/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/conversion/NgCmsNewsCollection.java @@ -27,11 +27,11 @@ import java.util.Map; * @author 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 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 allTrunkNews) { + int processed = 0; + for (NewsItem trunkNews : allTrunkNews) { + + // create news + News news = new News(trunkNews); + + processed++; + } + ExportLogger.created("news", processed); + } +} diff --git a/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/modules/contenttypes/News.java b/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/modules/contenttypes/News.java index 7aefa2dfe..44829b9dd 100644 --- a/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/modules/contenttypes/News.java +++ b/ccm-cms-types-newsitem/src/com/arsdigita/cms/portation/modules/contenttypes/News.java @@ -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() { diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSection.java b/ccm-cms/src/com/arsdigita/cms/ContentSection.java index 78eca25d1..34c029f24 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSection.java @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms/src/com/arsdigita/cms/ContentType.java b/ccm-cms/src/com/arsdigita/cms/ContentType.java index 14827ef38..fd406e9cf 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentType.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentType.java @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms/src/com/arsdigita/cms/Folder.java b/ccm-cms/src/com/arsdigita/cms/Folder.java index d050c4cc6..455607fad 100755 --- a/ccm-cms/src/com/arsdigita/cms/Folder.java +++ b/ccm-cms/src/com/arsdigita/cms/Folder.java @@ -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 getAllObjects() { + List 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; + } } diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/CmsConverter.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/CmsConverter.java index a61a5a132..53e41b671 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/conversion/CmsConverter.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/CmsConverter.java @@ -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 assets = new HashMap<>(); - public static Map binaryAssets = new HashMap<>(); - public static Map legalMetadatas = new HashMap<>(); - public static Map itemAttachments = new HashMap<>(); - public static Map attachmentLists = new HashMap<>(); - public static Map contentItems = new HashMap<>(); - - public static Map contentTypes = new HashMap<>(); - public static Map contentSections = new HashMap<>(); - public static Map phases = new HashMap<>(); - public static Map lifecycles = new HashMap<>(); - public static Map lifecycleDefinitions = new - HashMap<>(); + public static Map lifecycleDefinitions = new HashMap<>(); public static Map phaseDefinitions = new HashMap<>(); + public static Map folders = new HashMap<>(); + public static Map contentSections = new HashMap<>(); + public static Map contentTypes = new HashMap<>(); + + public static Map contentItems = new HashMap<>(); + + public static Map legalMetadatas = new HashMap<>(); + public static Map binaryAssets = new HashMap<>(); + public static Map assets = new HashMap<>(); + + public static Map attachmentLists = new HashMap<>(); + public static Map itemAttachments = new HashMap<>(); /** * Private constructor to prevent the instantiation of this class. diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/ContentSectionConversion.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/ContentSectionConversion.java new file mode 100644 index 000000000..fab7cd9ab --- /dev/null +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/ContentSectionConversion.java @@ -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 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 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; + } +} diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/ContentTypeConversion.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/ContentTypeConversion.java new file mode 100644 index 000000000..5b3ef811d --- /dev/null +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/ContentTypeConversion.java @@ -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 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 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; + } +} diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/FolderConversion.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/FolderConversion.java new file mode 100644 index 000000000..a3360abf9 --- /dev/null +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/contentsection/FolderConversion.java @@ -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 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 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; + } +} diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleConversion.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleConversion.java index 30bfdafce..f27dcd9f9 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleConversion.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleConversion.java @@ -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 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); } diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleDefinitionConversion.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleDefinitionConversion.java index b85d7a92e..2ecee0226 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleDefinitionConversion.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/LifecycleDefinitionConversion.java @@ -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 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); } diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseConversion.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseConversion.java index ac62dfa2e..1d21fde5e 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseConversion.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseConversion.java @@ -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 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); } diff --git a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseDefinitionConversion.java b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseDefinitionConversion.java index 9e7f4b8f6..290e35f5e 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseDefinitionConversion.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/conversion/lifecycle/PhaseDefinitionConversion.java @@ -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 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(); } /** diff --git a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Asset.java b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Asset.java index 42eb06a9e..24f095a00 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Asset.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Asset.java @@ -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); } diff --git a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentItem.java b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentItem.java index 54cc4750b..a76aca94a 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentItem.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentItem.java @@ -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); } diff --git a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentSection.java b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentSection.java index 380e822f9..f39c1f6c2 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentSection.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentSection.java @@ -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 roles; private Locale defaultLocale; @JsonIdentityReference(alwaysAsId = true) + private List roles; + @JsonIgnore private List contentTypes; @JsonIdentityReference(alwaysAsId = true) private List 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<>(); diff --git a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentType.java b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentType.java index 19b368bf4..1180f2065 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentType.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/ContentType.java @@ -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() { diff --git a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Folder.java b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Folder.java index f8e41701f..2e57f0f9f 100644 --- a/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Folder.java +++ b/ccm-cms/src/com/arsdigita/cms/portation/modules/contentsection/Folder.java @@ -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() { diff --git a/ccm-core/src/com/arsdigita/portation/AbstractConverter.java b/ccm-core/src/com/arsdigita/portation/AbstractConverter.java index 7dcc295f9..722ce9624 100644 --- a/ccm-core/src/com/arsdigita/portation/AbstractConverter.java +++ b/ccm-core/src/com/arsdigita/portation/AbstractConverter.java @@ -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; } diff --git a/ccm-core/src/com/arsdigita/portation/cmd/RootConverter.java b/ccm-core/src/com/arsdigita/portation/cmd/RootConverter.java index ed152ae96..d9647ea1c 100644 --- a/ccm-core/src/com/arsdigita/portation/cmd/RootConverter.java +++ b/ccm-core/src/com/arsdigita/portation/cmd/RootConverter.java @@ -18,8 +18,6 @@ */ package com.arsdigita.portation.cmd; -import com.arsdigita.portation.conversion.CoreConverter; - import java.lang.reflect.Method; /** diff --git a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java index c07fd2101..a24b5eccf 100644 --- a/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java +++ b/ccm-core/src/com/arsdigita/portation/conversion/core/workflow/WorkflowConversion.java @@ -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 diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java index 507643985..8740e03ca 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Category.java @@ -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(); diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/util/CategoryInformation.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/util/CategoryInformation.java index 4a8349c8b..8aa429b6c 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/util/CategoryInformation.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/util/CategoryInformation.java @@ -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() { diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java b/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java index ca0d10253..0c4c67cd0 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/core/CcmObject.java @@ -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;