diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/AbstractBookmarkModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractBookmarkModelBuilder.java new file mode 100644 index 000000000..2393eb8b0 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/pages/models/AbstractBookmarkModelBuilder.java @@ -0,0 +1,51 @@ +/* + * 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.Bookmark; + +import javax.inject.Inject; +import javax.transaction.Transactional; + + +/** + * + * @author Jens Pelzetter + * @param + * @param + */ +public abstract class AbstractBookmarkModelBuilder + extends AbstractAssetModelBuilder { + + @Inject + private GlobalizationHelper globalizationHelper; + + @Transactional(Transactional.TxType.REQUIRED) + @Override + protected void addProperties(final T asset, final M model) { + super.addProperties(asset, model); + model.setDescription( + globalizationHelper.getValueFromLocalizedString( + asset.getDescription() + ) + ); + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/BookmarkModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/BookmarkModel.java new file mode 100644 index 000000000..d1e9a3cdf --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/pages/models/BookmarkModel.java @@ -0,0 +1,54 @@ +/* + * 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.Bookmark; + +/** + * + * @author Jens Pelzetter + */ +public class BookmarkModel extends AbstractAssetModel { + + private String description; + + private String url; + + @Override + public String getType() { + return Bookmark.class.getName(); + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public String getUrl() { + return url; + } + + public void setUrl(final String url) { + this.url = url; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/BookmarkModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/BookmarkModelBuilder.java new file mode 100644 index 000000000..1da3dff90 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/pages/models/BookmarkModelBuilder.java @@ -0,0 +1,39 @@ +/* + * 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.Bookmark; + +/** + * + * @author Jens Pelzetter + */ +public class BookmarkModelBuilder extends AbstractBookmarkModelBuilder { + + @Override + public Class buildsAssetModelFor() { + return Bookmark.class; + } + + @Override + protected BookmarkModel buildModel() { + return new BookmarkModel(); + } + +}