diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/AbstractAssetModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractAssetModel.java
new file mode 100644
index 000000000..800cb5720
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractAssetModel.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+/**
+ * A simpli
+ *
+ * @author Jens Pelzetter
+ */
+public abstract class AbstractAssetModel {
+
+ private String uuid;
+
+ private String displayName;
+
+ private String title;
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(final String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ /**
+ * Returns the type of the assets. In most cases implementations
+ * should return the fully qualified name of the asset class here.
+ *
+ * @return The type of the asset.
+ */
+ public abstract String getType();
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/AbstractAssetModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractAssetModelBuilder.java
new file mode 100644
index 000000000..9d2bbaffb
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractAssetModelBuilder.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.contentsection.Asset;
+
+import javax.inject.Inject;
+
+/**
+ *
+ * @author Jens Pelzetter
+ * @param
+ * @param
+ */
+public abstract class AbstractAssetModelBuilder
+implements AssetModelBuilder {
+
+ @Inject
+ private GlobalizationHelper globalizationHelper;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public M buildAssetModel(final Asset asset) {
+ final M model = buildModel();
+ model.setDisplayName(asset.getDisplayName());
+ model.setTitle(
+ globalizationHelper.getValueFromLocalizedString(asset.getTitle())
+ );
+ model.setUuid(asset.getUuid());
+
+ addProperties((T) asset, model);
+
+ return model;
+ }
+
+ protected abstract M buildModel();
+
+ protected void addProperties(final T asset, final M model) {
+ // Nothing in the default implementation.
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/AbstractContentItemListItemModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractContentItemListItemModelBuilder.java
index e14ff553c..5a27c06e1 100644
--- a/ccm-cms/src/main/java/org/librecms/pages/models/AbstractContentItemListItemModelBuilder.java
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractContentItemListItemModelBuilder.java
@@ -53,6 +53,7 @@ public abstract class AbstractContentItemListItemModelBuilderJens Pelzetter
+ */
+public interface AssetModelBuilder {
+
+ M buildAssetModel(Asset asset);
+
+ Class buildsAssetModelFor();
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/AssetModelBuilders.java b/ccm-cms/src/main/java/org/librecms/pages/models/AssetModelBuilders.java
new file mode 100644
index 000000000..facb1437d
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/AssetModelBuilders.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.librecms.contentsection.Asset;
+
+import java.util.Optional;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+public class AssetModelBuilders {
+
+ @Inject
+ private Instance> modelBuilders;
+
+ public Optional> getModelBuilderFor(
+ final Class extends Asset> assetType
+ ) {
+ final Optional> exactMatch = findExactType(
+ assetType
+ );
+ if (exactMatch.isPresent()) {
+ return exactMatch;
+ } else {
+ return findForParentType(assetType);
+ }
+ }
+
+ private Optional> findExactType(
+ final Class extends Asset> assetType
+ ) {
+ return modelBuilders
+ .stream()
+ .filter(
+ modelBuilder -> modelBuilder.buildsAssetModelFor().equals(
+ assetType
+ )
+ )
+ .findAny();
+ }
+
+ private Optional> findForParentType(
+ final Class extends Asset> assetType
+ ) {
+ final Class> superClass = assetType.getSuperclass();
+ if (Asset.class.isAssignableFrom(superClass)) {
+ @SuppressWarnings("unchecked")
+ final Class extends Asset> superType
+ = (Class extends Asset>) superClass;
+ final Optional> builderForSuperType
+ = findExactType(superType);
+ if (builderForSuperType.isPresent()) {
+ return builderForSuperType;
+ } else {
+ return findForParentType(superType);
+ }
+ } else {
+ return Optional.empty();
+ }
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/ContentItemListItemModelBuilders.java b/ccm-cms/src/main/java/org/librecms/pages/models/ContentItemListItemModelBuilders.java
index 6beb7c131..d3226c7ba 100644
--- a/ccm-cms/src/main/java/org/librecms/pages/models/ContentItemListItemModelBuilders.java
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/ContentItemListItemModelBuilders.java
@@ -53,8 +53,11 @@ public class ContentItemListItemModelBuilders {
) {
return modelBuilders
.stream()
- .filter(modelBuilder -> modelBuilder.buildsListItemModelFor()
- .equals(itemType))
+ .filter(
+ modelBuilder -> modelBuilder.buildsListItemModelFor().equals(
+ itemType
+ )
+ )
.findAny();
}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/LegalMetadataModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/LegalMetadataModel.java
new file mode 100644
index 000000000..11ea6ff88
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/LegalMetadataModel.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.librecms.assets.LegalMetadata;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class LegalMetadataModel extends AbstractAssetModel{
+
+ private String rightsHolder;
+
+ private String rights;
+
+ private String publisher;
+
+ private String creator;
+
+ private List contributors;
+
+ @Override
+ public String getType() {
+ return LegalMetadata.class.getName();
+ }
+
+ public String getRightsHolder() {
+ return rightsHolder;
+ }
+
+ public void setRightsHolder(final String rightsHolder) {
+ this.rightsHolder = rightsHolder;
+ }
+
+ public String getRights() {
+ return rights;
+ }
+
+ public void setRights(final String rights) {
+ this.rights = rights;
+ }
+
+ public String getPublisher() {
+ return publisher;
+ }
+
+ public void setPublisher(final String publisher) {
+ this.publisher = publisher;
+ }
+
+ public String getCreator() {
+ return creator;
+ }
+
+ public void setCreator(String creator) {
+ this.creator = creator;
+ }
+
+ public List getContributors() {
+ return Collections.unmodifiableList(contributors);
+ }
+
+ public void setContributors(final List contributors) {
+ this.contributors = new ArrayList<>(contributors);
+ }
+
+
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/LegalMetadataModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/LegalMetadataModelBuilder.java
new file mode 100644
index 000000000..132e6013c
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/LegalMetadataModelBuilder.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.assets.LegalMetadata;
+
+import javax.inject.Inject;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class LegalMetadataModelBuilder
+ extends AbstractAssetModelBuilder {
+
+ @Inject
+ private GlobalizationHelper globalizationHelper;
+
+ @Override
+ public Class buildsAssetModelFor() {
+ return LegalMetadata.class;
+ }
+
+ @Override
+ protected LegalMetadataModel buildModel() {
+ return new LegalMetadataModel();
+ }
+
+ @Override
+ protected void addProperties(
+ final LegalMetadata legalMetadata, final LegalMetadataModel model
+ ) {
+ super.addProperties(legalMetadata, model);
+ model.setContributors(legalMetadata.getContributors());
+ model.setCreator(legalMetadata.getCreator());
+ model.setPublisher(legalMetadata.getPublisher());
+ model.setRights(
+ globalizationHelper.getValueFromLocalizedString(
+ legalMetadata.getRights()
+ )
+ );
+ model.setRightsHolder(legalMetadata.getRightsHolder());
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/PostalAddressModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/PostalAddressModel.java
new file mode 100644
index 000000000..a204a9ecb
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/PostalAddressModel.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.librecms.assets.PostalAddress;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class PostalAddressModel extends AbstractAssetModel {
+
+ private String address;
+
+ private String postalCode;
+
+ private String city;
+
+ private String state;
+
+ private String isoCountryCode;
+
+ @Override
+ public String getType() {
+ return PostalAddress.class.getName();
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(final String address) {
+ this.address = address;
+ }
+
+ public String getPostalCode() {
+ return postalCode;
+ }
+
+ public void setPostalCode(final String postalCode) {
+ this.postalCode = postalCode;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(final String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(final String state) {
+ this.state = state;
+ }
+
+ public String getIsoCountryCode() {
+ return isoCountryCode;
+ }
+
+ public void setIsoCountryCode(final String isoCountryCode) {
+ this.isoCountryCode = isoCountryCode;
+ }
+
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/PostalAddressModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/PostalAddressModelBuilder.java
new file mode 100644
index 000000000..7dfd44c11
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/PostalAddressModelBuilder.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.librecms.assets.PostalAddress;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class PostalAddressModelBuilder
+ extends AbstractAssetModelBuilder {
+
+ @Override
+ public Class buildsAssetModelFor() {
+ return PostalAddress.class;
+ }
+
+ @Override
+ protected PostalAddressModel buildModel() {
+ return new PostalAddressModel();
+ }
+
+ @Override
+ protected void addProperties(
+ final PostalAddress postalAddress, final PostalAddressModel model
+ ) {
+ super.addProperties(postalAddress, model);
+ model.setAddress(postalAddress.getAddress());
+ model.setCity(postalAddress.getCity());
+ model.setIsoCountryCode(postalAddress.getIsoCountryCode());
+ model.setPostalCode(postalAddress.getPostalCode());
+ model.setState(postalAddress.getState());
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/SideNoteModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/SideNoteModel.java
new file mode 100644
index 000000000..4814b1566
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/SideNoteModel.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.librecms.assets.SideNote;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SideNoteModel extends AbstractAssetModel {
+
+ private String text;
+
+ @Override
+ public String getType() {
+ return SideNote.class.getName();
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(final String text) {
+ this.text = text;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/SideNoteModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/SideNoteModelBuilder.java
new file mode 100644
index 000000000..dc4e82af7
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/pages/models/SideNoteModelBuilder.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 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 org.librecms.pages.models;
+
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.assets.SideNote;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+public class SideNoteModelBuilder
+ extends AbstractAssetModelBuilder {
+
+ @Inject
+ private GlobalizationHelper globalizationHelper;
+
+ @Override
+ public Class buildsAssetModelFor() {
+ return SideNote.class;
+ }
+
+ @Override
+ protected SideNoteModel buildModel() {
+ return new SideNoteModel();
+ }
+
+ @Override
+ protected void addProperties(
+ final SideNote sideNote, final SideNoteModel model
+ ) {
+ super.addProperties(sideNote, model);
+ model.setText(
+ globalizationHelper.getValueFromLocalizedString(sideNote.getText())
+ );
+ }
+
+}