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/convertion/NgCmsCollection.java new file mode 100644 index 000000000..dbdfd5260 --- /dev/null +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java @@ -0,0 +1,37 @@ +/* + * 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.convertion; + +import com.arsdigita.cms.portation.modules.assets.FileAsset; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Tobias Osmers<\a> + * @version created the 4/6/18 + */ +public class FileAsset extends BinaryAsset implements Portable { + + /** + * Constructor for the ng-object. + * + * @param trunkFileAsset the trunk object + */ + public FileAsset(final FileAttachment trunkFileAsset) { + super(trunkFileAsset); + + NgCmsCollection.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/convertion/NgCmsCollection.java new file mode 100644 index 000000000..8a57323b3 --- /dev/null +++ b/ccm-cms-assets-imagestep/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java @@ -0,0 +1,38 @@ +/* + * 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.convertion; + +import com.arsdigita.cms.portation.modules.assets.Image; +import com.arsdigita.cms.portation.modules.assets.LegalMetadata; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Tobias Osmers<\a> + * @version created the 4/6/18 + */ +public class Image extends BinaryAsset implements Portable { + private long width; + private long height; + @JsonIdentityReference(alwaysAsId = true) + private LegalMetadata legalMetadata; + + /** + * Constructor for the ng-object. + * + * @param trunkImage the trunk object + */ + public Image(final ImageAsset trunkImage) { + super(trunkImage); + + this.width = trunkImage.getWidth().longValue(); + this.height = trunkImage.getHeight().longValue(); + + //this.legalMetaData + + NgCmsCollection.images.put(this.getObjectId(), this); + } + + public long getWidth() { + return width; + } + + public void setWidth(final long width) { + this.width = width; + } + + public long getHeight() { + return height; + } + + public void setHeight(final long height) { + this.height = height; + } + + public LegalMetadata getLegalMetadata() { + return legalMetadata; + } + + public void setLegalMetadata(final LegalMetadata legalMetadata) { + this.legalMetadata = legalMetadata; + } +} diff --git a/ccm-cms-assets-notes/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java b/ccm-cms-assets-notes/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java new file mode 100644 index 000000000..f566e733d --- /dev/null +++ b/ccm-cms-assets-notes/src/com/arsdigita/cms/portation/convertion/NgCmsCollection.java @@ -0,0 +1,37 @@ +/* + * 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.convertion; + +import com.arsdigita.cms.portation.modules.assets.SideNote; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Tobias Osmers<\a> + * @version created the 4/6/18 + */ +public class SideNote extends Asset implements Portable { + private LocalizedString text; + + /** + * Constructor for the ng-object. + * + * @param trunkNote the trunk object + */ + public SideNote(final Note trunkNote) { + super("Title_" + trunkNote.getDisplayName(), + trunkNote.getDisplayName()); + + this.text = new LocalizedString(); + final Locale language = Locale.getDefault(); + this.text.addValue(language, trunkNote.getContent()); + + NgCmsCollection.sideNotes.put(this.getObjectId(), this); + } + + public LocalizedString getText() { + return text; + } + + public void setText(final LocalizedString text) { + this.text = text; + } +} 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 61bf45845..8925b49d0 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,12 +18,14 @@ */ package com.arsdigita.cms.portation.modules.contenttypes; +import com.arsdigita.cms.ItemCollection; import com.arsdigita.cms.portation.conversion.NgCmsCollection; 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 Tobias Osmers<\a> @@ -49,29 +51,39 @@ public class Event extends ContentItem implements Portable { public Event(final com.arsdigita.cms.contenttypes.Event trunkEvent) { super(trunkEvent); - final Locale locale = Locale.getDefault(); this.text = new LocalizedString(); - this.text.addValue(locale, trunkEvent.getTextAsset().getText()); - this.startDate = trunkEvent.getStartDate(); this.endDate = trunkEvent.getEndDate(); - this.eventDate = new LocalizedString(); - this.eventDate.addValue(locale, trunkEvent.getEventDate()); - this.location = new LocalizedString(); - this.location.addValue(locale, trunkEvent.getLocation()); - this.mainContributor = new LocalizedString(); - this.mainContributor.addValue(locale, trunkEvent.getMainContributor()); - this.eventType = new LocalizedString(); - this.eventType.addValue(locale, trunkEvent.getEventType()); - this.mapLink = trunkEvent.getMapLink(); - this.cost = new LocalizedString(); - this.cost.addValue(locale, trunkEvent.getCost()); + + 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()); + + addName(language, languageItem.getName()); + addTitle(language, languageItem.getTitle()); + addDescription(language, languageItem.getDescription()); + + this.text.addValue(language, languageItem.getTextAsset().getText()); + + 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()); + } NgCmsCollection.events.put(this.getObjectId(), this); } 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 4f076a18c..25fb2e40d 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,6 +18,7 @@ */ package com.arsdigita.cms.portation.modules.contenttypes; +import com.arsdigita.cms.ItemCollection; import com.arsdigita.cms.portation.conversion.NgCmsCollection; import com.arsdigita.cms.portation.modules.contentsection.ContentItem; import com.arsdigita.portation.Portable; @@ -27,6 +28,7 @@ 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> @@ -36,21 +38,26 @@ public class MultiPartArticleSection implements Portable { private boolean pageBreak; private LocalizedString text; - public MultiPartArticleSection(final com.arsdigita.cms.contenttypes - .ArticleSection trunkMultiPartArticleSection) { + public MultiPartArticleSection(final ArticleSection + trunkMultiPartArticleSection) { this.sectionId = trunkMultiPartArticleSection.getID().longValue(); - final Locale locale = Locale.getDefault(); this.title = new LocalizedString(); - this.title.addValue(locale, trunkMultiPartArticleSection - .getPageTitle()); - this.rank = trunkMultiPartArticleSection.getRank(); this.pageBreak = trunkMultiPartArticleSection.isPageBreak(); - this.text = new LocalizedString(); - this.text.addValue(locale, trunkMultiPartArticleSection.getText() - .getText()); + + final ItemCollection languageSets = Objects.requireNonNull( + trunkMultiPartArticleSection.getContentBundle()) + .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()); + } NgCmsCollection.multiPartArticleSections.put(this.sectionId, this); } 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 039a82be5..7aefa2dfe 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,6 +18,8 @@ */ package com.arsdigita.cms.portation.modules.contenttypes; +import com.arsdigita.cms.ItemCollection; +import com.arsdigita.cms.contenttypes.NewsItem; import com.arsdigita.cms.portation.conversion.NgCmsCollection; import com.arsdigita.cms.portation.modules.contentsection.ContentItem; import com.arsdigita.portation.Portable; @@ -25,6 +27,7 @@ import com.arsdigita.portation.modules.core.l10n.LocalizedString; import java.util.Date; import java.util.Locale; +import java.util.Objects; /** * @author Tobias Osmers<\a> + * @version created the 4/6/18 + */ +public class BinaryAsset extends Asset { + private LocalizedString description; + private String fileName; + private MimeType mimeType; + private byte[] data; + private long size; + + /** + * Constructor for the ng-object. + * + * @param trunkBinaryAsset the old trunk object + */ + public BinaryAsset(final com.arsdigita.cms.BinaryAsset trunkBinaryAsset) { + super(trunkBinaryAsset); + + this.description = new LocalizedString(); + final Locale language = new Locale(trunkBinaryAsset.getLanguage()); + this.description.addValue(language, trunkBinaryAsset.getDescription()); + + this.fileName = trunkBinaryAsset.getName(); + try { + this.mimeType = new MimeType(trunkBinaryAsset.getMimeType() + .getMimeType()); + } catch (MimeTypeParseException e) { + e.printStackTrace(); + } + + this.data = trunkBinaryAsset.getContent(); + this.size = trunkBinaryAsset.getSize(); + + NgCmsCollection.binaryAssets.put(this.getObjectId(), this); + } + + public LocalizedString getDescription() { + return description; + } + + public void setDescription(final LocalizedString description) { + this.description = description; + } + + public void addDescription(final Locale language, final String description) { + this.description.addValue(language, description); + } + + public String getFileName() { + return fileName; + } + + public void setFileName(final String fileName) { + this.fileName = fileName; + } + + public MimeType getMimeType() { + return mimeType; + } + + public void setMimeType(final MimeType mimeType) { + this.mimeType = mimeType; + } + + public byte[] getData() { + return data; + } + + public void setData(final byte[] data) { + this.data = data; + } + + public long getSize() { + return size; + } + + public void setSize(final long size) { + this.size = size; + } +} diff --git a/ccm-cms/src/com/arsdigita/cms/portation/modules/assets/LegalMetadata.java b/ccm-cms/src/com/arsdigita/cms/portation/modules/assets/LegalMetadata.java new file mode 100644 index 000000000..72f543854 --- /dev/null +++ b/ccm-cms/src/com/arsdigita/cms/portation/modules/assets/LegalMetadata.java @@ -0,0 +1,44 @@ +/* + * 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.modules.assets; + +import com.arsdigita.cms.portation.conversion.NgCmsCollection; +import com.arsdigita.cms.portation.modules.contentsection.Asset; +import com.arsdigita.portation.Portable; +import com.arsdigita.portation.modules.core.l10n.LocalizedString; + +import java.util.List; + +/** + * @author (); + + this.title = new LocalizedString(); + final Locale language = Locale.getDefault(); + this.title.addValue(language, title); + + NgCmsCollection.assets.put(this.getObjectId(), this); + } public List> getItemAttachments() { return itemAttachments; @@ -83,4 +100,8 @@ public class Asset extends CcmObject { public void setTitle(final LocalizedString title) { this.title = title; } + + public void addTitle(final Locale language, final String title) { + this.title.addValue(language, title); + } } 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 094131108..54cc4750b 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 @@ -21,7 +21,6 @@ package com.arsdigita.cms.portation.modules.contentsection; import com.arsdigita.cms.portation.conversion.NgCmsCollection; import com.arsdigita.cms.portation.modules.contentsection.util.ContentItemVersionMapper; import com.arsdigita.cms.portation.modules.lifecycle.Lifecycle; -import com.arsdigita.portation.Portable; import com.arsdigita.portation.modules.core.core.CcmObject; import com.arsdigita.portation.modules.core.l10n.LocalizedString; import com.arsdigita.portation.modules.core.workflow.Workflow; @@ -72,10 +71,7 @@ public class ContentItem extends CcmObject { this.name = new LocalizedString(); this.title = new LocalizedString(); this.description = new LocalizedString(); - final Locale locale = trunkContentItem.getLocale().toJavaLocale(); - name.addValue(locale, trunkContentItem.getDisplayName()); - title.addValue(locale, trunkContentItem.getName()); - description.addValue(locale, trunkContentItem.getAdditionalInfo()); + // localized string-entries will be set in subclasses e.g. Article, News //this.contentType this.version = ContentItemVersionMapper @@ -113,12 +109,8 @@ public class ContentItem extends CcmObject { this.name = name; } - public ContentType getContentType() { - return contentType; - } - - public void setContentType(final ContentType contentType) { - this.contentType = contentType; + public void addName(final Locale language, final String name) { + this.name.addValue(language, name); } public LocalizedString getTitle() { @@ -129,6 +121,10 @@ public class ContentItem extends CcmObject { this.title = title; } + public void addTitle(final Locale language, final String title) { + this.title.addValue(language, title); + } + public LocalizedString getDescription() { return description; } @@ -137,6 +133,18 @@ public class ContentItem extends CcmObject { this.description = description; } + public void addDescription(final Locale language, final String description) { + this.name.addValue(language, description); + } + + public ContentType getContentType() { + return contentType; + } + + public void setContentType(final ContentType contentType) { + this.contentType = contentType; + } + public ContentItemVersion getVersion() { return version; } 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 3efcb0c64..507643985 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 @@ -66,7 +66,11 @@ public class Category extends CcmObject implements Portable { private Category parentCategory; private long categoryOrder; - + /** + * Constructor for the ng-object. + * + * @param trunkCategory the trunk object + */ public Category(final com.arsdigita.categorization.Category trunkCategory) { super(trunkCategory); @@ -109,8 +113,11 @@ public class Category extends CcmObject implements Portable { NgCoreCollection.categories.put(this.getObjectId(), this); } - // specific constructor for subclasses of category - // e.g. Folder + /** + * Specific constructor for subclasses of category e.g. Folder + * + * @param categoryInformation the trunk object + */ public Category(final CategoryInformation categoryInformation) { super(categoryInformation.getDisplayName()); diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Domain.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Domain.java index f2ea3d73a..12eb157f3 100644 --- a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Domain.java +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/Domain.java @@ -64,7 +64,11 @@ public class Domain extends CcmObject implements Portable { @JsonIgnore private List owners; - + /** + * Constructor for the ng object. + * + * @param trunkDomain the trunk object + */ public Domain(final DataObject trunkDomain) { super((String) trunkDomain.get("key") + "_DName"); 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 d7c3d740a..ca0d10253 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 @@ -75,7 +75,7 @@ public class CcmObject { NgCoreCollection.ccmObjects.put(this.objectId, this); } - // specific constructor for ldn-terms' domain + // specific constructor for ldn-terms' domain and Asset SideNote public CcmObject(final String displayName) { this.objectId = ACSObject.generateID().longValue();