parent
94704d9e4a
commit
9ceb480c23
|
|
@ -25,20 +25,23 @@ import org.libreccm.l10n.LocalizedString;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class SubCategoryId extends CategoryId {
|
||||
public class AssociatedCategoryData extends CategoryId {
|
||||
|
||||
private String name;
|
||||
|
||||
private LocalizedString title;
|
||||
|
||||
private LocalizedString description;
|
||||
|
||||
public SubCategoryId() {
|
||||
public AssociatedCategoryData() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SubCategoryId(final Category category) {
|
||||
public AssociatedCategoryData(final Category category) {
|
||||
super(category);
|
||||
name = category.getName();
|
||||
title = category.getTitle();
|
||||
description = category.getDescription();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
@ -57,5 +60,15 @@ public class SubCategoryId extends CategoryId {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public LocalizedString getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final LocalizedString description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright (C) 2020 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.libreccm.api.admin.categorization.dto;
|
||||
|
||||
import org.libreccm.api.core.dto.CcmObjectId;
|
||||
import org.libreccm.categorization.Categorization;
|
||||
import org.libreccm.categorization.Category;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class CategorizationData {
|
||||
|
||||
private long categorizationId;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private CcmObjectId categorizedObject;
|
||||
|
||||
private boolean indexObject;
|
||||
|
||||
private long categoryOrder;
|
||||
|
||||
private long objectOrder;
|
||||
|
||||
private String type;
|
||||
|
||||
public CategorizationData() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public CategorizationData(final Categorization fromCategorization) {
|
||||
Objects.requireNonNull(
|
||||
fromCategorization,
|
||||
"Can't create a CategorizationData DTO from null."
|
||||
);
|
||||
|
||||
categorizationId = fromCategorization.getCategorizationId();
|
||||
uuid = fromCategorization.getUuid();
|
||||
categorizedObject = new CcmObjectId(
|
||||
fromCategorization.getCategorizedObject()
|
||||
);
|
||||
indexObject = fromCategorization.isIndexObject();
|
||||
categoryOrder = fromCategorization.getCategoryOrder();
|
||||
objectOrder = fromCategorization.getObjectOrder();
|
||||
type = fromCategorization.getType();
|
||||
}
|
||||
|
||||
public long getCategorizationId() {
|
||||
return categorizationId;
|
||||
}
|
||||
|
||||
public void setCategorizationId(final long categorizationId) {
|
||||
this.categorizationId = categorizationId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public CcmObjectId getCategorizedObject() {
|
||||
return categorizedObject;
|
||||
}
|
||||
|
||||
public void setCategorizedObject(final CcmObjectId categorizedObject) {
|
||||
this.categorizedObject = categorizedObject;
|
||||
}
|
||||
|
||||
public boolean isIndexObject() {
|
||||
return indexObject;
|
||||
}
|
||||
|
||||
public void setIndexObject(final boolean indexObject) {
|
||||
this.indexObject = indexObject;
|
||||
}
|
||||
|
||||
public long getCategoryOrder() {
|
||||
return categoryOrder;
|
||||
}
|
||||
|
||||
public void setCategoryOrder(final long categoryOrder) {
|
||||
this.categoryOrder = categoryOrder;
|
||||
}
|
||||
|
||||
public long getObjectOrder() {
|
||||
return objectOrder;
|
||||
}
|
||||
|
||||
public void setObjectOrder(final long objectOrder) {
|
||||
this.objectOrder = objectOrder;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
* Copyright (C) 2020 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.libreccm.api.admin.categorization.dto;
|
||||
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class CategoryData {
|
||||
|
||||
private long categoryId;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private String uniqueId;
|
||||
|
||||
private String name;
|
||||
|
||||
private LocalizedString title;
|
||||
|
||||
private LocalizedString description;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private boolean visible;
|
||||
|
||||
private boolean abstractCategory;
|
||||
|
||||
private List<CategorizationData> objects;
|
||||
|
||||
private List<AssociatedCategoryData> subCategories;
|
||||
|
||||
private AssociatedCategoryData parentCategory;
|
||||
|
||||
private long categoryOrder;
|
||||
|
||||
public CategoryData() {
|
||||
objects = new ArrayList<>();
|
||||
subCategories = new ArrayList<>();
|
||||
}
|
||||
|
||||
public CategoryData(final Category fromCategory) {
|
||||
Objects.requireNonNull(
|
||||
fromCategory, "Can't create a CategoryData DTO from null."
|
||||
);
|
||||
|
||||
categoryId = fromCategory.getObjectId();
|
||||
uuid = fromCategory.getUuid();
|
||||
uniqueId = fromCategory.getUniqueId();
|
||||
name = fromCategory.getName();
|
||||
title = fromCategory.getTitle();
|
||||
description = fromCategory.getDescription();
|
||||
enabled = fromCategory.isEnabled();
|
||||
visible = fromCategory.isVisible();
|
||||
abstractCategory = fromCategory.isAbstractCategory();
|
||||
objects = fromCategory
|
||||
.getObjects()
|
||||
.stream()
|
||||
.map(CategorizationData::new)
|
||||
.collect(Collectors.toList());
|
||||
subCategories = fromCategory
|
||||
.getSubCategories()
|
||||
.stream()
|
||||
.map(AssociatedCategoryData::new)
|
||||
.collect(Collectors.toList());
|
||||
parentCategory = new AssociatedCategoryData(
|
||||
fromCategory.getParentCategory()
|
||||
);
|
||||
}
|
||||
|
||||
public long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(final long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUniqueId() {
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
public void setUniqueId(final String uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LocalizedString getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final LocalizedString title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public LocalizedString getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final LocalizedString description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(final boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public boolean isAbstractCategory() {
|
||||
return abstractCategory;
|
||||
}
|
||||
|
||||
public void setAbstractCategory(final boolean abstractCategory) {
|
||||
this.abstractCategory = abstractCategory;
|
||||
}
|
||||
|
||||
public List<CategorizationData> getObjects() {
|
||||
return new ArrayList<>(objects);
|
||||
}
|
||||
|
||||
public void setObjects(final List<CategorizationData> objects) {
|
||||
this.objects = new ArrayList<>(objects);
|
||||
}
|
||||
|
||||
public List<AssociatedCategoryData> getSubCategories() {
|
||||
return new ArrayList<>(subCategories);
|
||||
}
|
||||
|
||||
public void setSubCategories(
|
||||
final List<AssociatedCategoryData> subCategories) {
|
||||
this.subCategories = new ArrayList<>(subCategories);
|
||||
}
|
||||
|
||||
public AssociatedCategoryData getParentCategory() {
|
||||
return parentCategory;
|
||||
}
|
||||
|
||||
public void setParentCategory(final AssociatedCategoryData parentCategory) {
|
||||
this.parentCategory = parentCategory;
|
||||
}
|
||||
|
||||
public long getCategoryOrder() {
|
||||
return categoryOrder;
|
||||
}
|
||||
|
||||
public void setCategoryOrder(final long categoryOrder) {
|
||||
this.categoryOrder = categoryOrder;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ public class Categorization implements Serializable, Relation, Exportable {
|
|||
private boolean indexObject;
|
||||
|
||||
/**
|
||||
* Defines the order in which the categories assigned the the categorised
|
||||
* Defines the order in which the categories assigned to the categorized
|
||||
* object are shown.
|
||||
*/
|
||||
@Column(name = "CATEGORY_ORDER")
|
||||
|
|
|
|||
Loading…
Reference in New Issue