Model for image assets.
parent
13479343aa
commit
478cda35b6
|
|
@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ImageModel extends BinaryAssetModel {
|
||||||
|
|
||||||
|
private long width;
|
||||||
|
|
||||||
|
private long height;
|
||||||
|
|
||||||
|
private LegalMetadataModel legalMetadata;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return Image.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* 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 javax.inject.Inject;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ImageModelBuilder
|
||||||
|
extends AbstractAssetModelBuilder<Image, ImageModel> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BinaryAssetModelBuilder binaryAssetModelBuilder;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private LegalMetadataModelBuilder legalMetadataModelBuilder;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Image> buildsAssetModelFor() {
|
||||||
|
return Image.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ImageModel buildModel() {
|
||||||
|
return new ImageModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
|
protected void addProperties(final Image image, final ImageModel model) {
|
||||||
|
super.addProperties(image, model);
|
||||||
|
binaryAssetModelBuilder.addProperties(image, model);
|
||||||
|
model.setHeight(image.getHeight());
|
||||||
|
model.setLegalMetadata(
|
||||||
|
legalMetadataModelBuilder.buildAssetModel(image.getLegalMetadata())
|
||||||
|
);
|
||||||
|
model.setWidth(image.getWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue