Model for Bookmark assets.

pull/10/head
Jens Pelzetter 2021-11-06 15:53:28 +01:00
parent 9f515339e5
commit 9ba0610308
3 changed files with 144 additions and 0 deletions

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T>
* @param <M>
*/
public abstract class AbstractBookmarkModelBuilder<T extends Bookmark, M extends BookmarkModel>
extends AbstractAssetModelBuilder<T, M> {
@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()
)
);
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
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;
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class BookmarkModelBuilder extends AbstractBookmarkModelBuilder<Bookmark, BookmarkModel> {
@Override
public Class<Bookmark> buildsAssetModelFor() {
return Bookmark.class;
}
@Override
protected BookmarkModel buildModel() {
return new BookmarkModel();
}
}