ResourceCreationData.java

  1. /*
  2.  * The coLAB project
  3.  * Copyright (C) 2021-2023 AlbaSim, MEI, HEIG-VD, HES-SO
  4.  *
  5.  * Licensed under the MIT License
  6.  */
  7. package ch.colabproject.colab.api.rest.document.bean;

  8. import ch.colabproject.colab.api.model.document.Document;
  9. import ch.colabproject.colab.api.model.document.TextDataBlock;
  10. import ch.colabproject.colab.generator.model.annotations.ExtractJavaDoc;
  11. import java.io.Serializable;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import org.apache.commons.lang3.builder.EqualsBuilder;
  15. import org.apache.commons.lang3.builder.HashCodeBuilder;

  16. /**
  17.  * Bean with everything needed to create a resource
  18.  *
  19.  * @author sandra
  20.  */
  21. @ExtractJavaDoc
  22. public class ResourceCreationData implements Serializable {

  23.     private static final long serialVersionUID = 1L;

  24.     // ---------------------------------------------------------------------------------------------
  25.     // fields
  26.     // ---------------------------------------------------------------------------------------------

  27.     /**
  28.      * The title of the resource
  29.      */
  30.     private String title;

  31.     /**
  32.      * The teaser of the resource
  33.      */
  34.     private TextDataBlock teaser;

  35.     /**
  36.      * The category of the resource
  37.      */
  38.     private String category;

  39.     /**
  40.      * The abstract card type id
  41.      */
  42.     private Long abstractCardTypeId;

  43.     /**
  44.      * The card id
  45.      */
  46.     private Long cardId;

  47.     /**
  48.      * The card content id
  49.      */
  50.     private Long cardContentId;

  51.     /**
  52.      * Is it at the disposal of the inheritors
  53.      */
  54.     private boolean published;

  55.     /**
  56.      * The document
  57.      */
  58.     private List<Document> documents = new ArrayList<>();

  59.     // ---------------------------------------------------------------------------------------------
  60.     // getters and setters
  61.     // ---------------------------------------------------------------------------------------------

  62.     /**
  63.      * @return the title
  64.      */
  65.     public String getTitle() {
  66.         return title;
  67.     }

  68.     /**
  69.      * @param title the title
  70.      */
  71.     public void setTitle(String title) {
  72.         this.title = title;
  73.     }

  74.     /**
  75.      * @return the teaser
  76.      */
  77.     public TextDataBlock getTeaser() {
  78.         return teaser;
  79.     }

  80.     /**
  81.      * @param teaser the teaser
  82.      */
  83.     public void setTeaser(TextDataBlock teaser) {
  84.         this.teaser = teaser;
  85.     }

  86.     /**
  87.      * @return the category
  88.      */
  89.     public String getCategory() {
  90.         return category;
  91.     }

  92.     /**
  93.      * @param category the category
  94.      */
  95.     public void setCategory(String category) {
  96.         this.category = category;
  97.     }

  98.     /**
  99.      * @return the abstractCardTypeId
  100.      */
  101.     public Long getAbstractCardTypeId() {
  102.         return abstractCardTypeId;
  103.     }

  104.     /**
  105.      * @param abstractCardTypeId the abstractCardTypeId
  106.      */
  107.     public void setAbstractCardTypeId(Long abstractCardTypeId) {
  108.         this.abstractCardTypeId = abstractCardTypeId;
  109.     }

  110.     /**
  111.      * @return the cardId
  112.      */
  113.     public Long getCardId() {
  114.         return cardId;
  115.     }

  116.     /**
  117.      * @param cardId the cardId
  118.      */
  119.     public void setCardId(Long cardId) {
  120.         this.cardId = cardId;
  121.     }

  122.     /**
  123.      * @return the cardContentId
  124.      */
  125.     public Long getCardContentId() {
  126.         return cardContentId;
  127.     }

  128.     /**
  129.      * @param cardContentId the cardContentId
  130.      */
  131.     public void setCardContentId(Long cardContentId) {
  132.         this.cardContentId = cardContentId;
  133.     }

  134.     /**
  135.      * @return if it is at the disposal of the inheritors
  136.      */
  137.     public boolean isPublished() {
  138.         return published;
  139.     }

  140.     /**
  141.      * @param published if it is at the disposal of the inheritors
  142.      */
  143.     public void setPublished(boolean published) {
  144.         this.published = published;
  145.     }

  146.     /**
  147.      * @return the documents
  148.      */
  149.     public List<Document> getDocuments() {
  150.         return documents;
  151.     }

  152.     /**
  153.      * @param documents the documents
  154.      */
  155.     public void setDocuments(List<Document> documents) {
  156.         this.documents = documents;
  157.     }

  158.     // ---------------------------------------------------------------------------------------------
  159.     // concerning the whole class
  160.     // ---------------------------------------------------------------------------------------------

  161.     @Override
  162.     public int hashCode() {
  163.         return new HashCodeBuilder()
  164.             .append(this.title)
  165.             .append(this.category)
  166.             .append(this.abstractCardTypeId)
  167.             .append(this.cardId)
  168.             .append(this.cardContentId)
  169.             .append(this.published)
  170.             .toHashCode();
  171.     }

  172.     @Override
  173.     public boolean equals(Object obj) {
  174.         if (this == obj) {
  175.             return true;
  176.         }
  177.         if (obj == null) {
  178.             return false;
  179.         }
  180.         if (getClass() != obj.getClass()) {
  181.             return false;
  182.         }
  183.         final ResourceCreationData other = (ResourceCreationData) obj;
  184.         return new EqualsBuilder()
  185.             .append(this.title, other.title)
  186.             .append(this.category, other.category)
  187.             .append(this.abstractCardTypeId, other.abstractCardTypeId)
  188.             .append(this.cardId, other.cardId)
  189.             .append(this.cardContentId, other.cardContentId)
  190.             .append(this.published, other.published)
  191.             .isEquals();
  192.     }

  193.     @Override
  194.     public String toString() {
  195.         return "ResourceCreationData{" + "title=" + title + ", category=" + category
  196.             + ", abstractCardTypeId=" + abstractCardTypeId + ", cardId=" + cardId
  197.             + ", cardContentId=" + cardContentId + ", published=" + published + "}";
  198.     }

  199. }