diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/VideoAssetModel.java b/ccm-cms/src/main/java/org/librecms/pages/models/VideoAssetModel.java new file mode 100644 index 000000000..cab14aac4 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/pages/models/VideoAssetModel.java @@ -0,0 +1,64 @@ +/* + * 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.VideoAsset; + +/** + * + * @author Jens Pelzetter + */ +public class VideoAssetModel extends BinaryAssetModel { + + private long width; + + private long height; + + private LegalMetadataModel legalMetadata; + + @Override + public String getType() { + return VideoAsset.class.getName(); + } + + 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 LegalMetadataModel getLegalMetadata() { + return legalMetadata; + } + + public void setLegalMetadata(final LegalMetadataModel legalMetadata) { + this.legalMetadata = legalMetadata; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/pages/models/VideoModelBuilder.java b/ccm-cms/src/main/java/org/librecms/pages/models/VideoModelBuilder.java new file mode 100644 index 000000000..eb8e140f7 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/pages/models/VideoModelBuilder.java @@ -0,0 +1,64 @@ +/* + * 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.Image; +import org.librecms.assets.VideoAsset; + +import javax.inject.Inject; +import javax.transaction.Transactional; + +/** + * + * @author Jens Pelzetter + */ +public class VideoModelBuilder + extends AbstractAssetModelBuilder { + + @Inject + private BinaryAssetModelBuilder binaryAssetModelBuilder; + + @Inject + private LegalMetadataModelBuilder legalMetadataModelBuilder; + + @Override + public Class buildsAssetModelFor() { + return VideoAsset.class; + } + + @Override + protected VideoAssetModel buildModel() { + return new VideoAssetModel(); + } + + @Transactional(Transactional.TxType.REQUIRED) + @Override + protected void addProperties( + final VideoAsset video, final VideoAssetModel model + ) { + super.addProperties(video, model); + binaryAssetModelBuilder.addProperties(video, model); + model.setHeight(video.getHeight()); + model.setLegalMetadata( + legalMetadataModelBuilder.buildAssetModel(video.getLegalMetadata()) + ); + model.setWidth(video.getWidth()); + } + +}