View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.frontend.classeditor.json;
20  
21  import java.util.ArrayList;
22  
23  import org.mycore.datamodel.classifications2.MCRCategory;
24  import org.mycore.datamodel.classifications2.MCRCategoryID;
25  
26  import jakarta.ws.rs.WebApplicationException;
27  
28  public class MCRJSONCategoriesSaveList {
29      ArrayList<CategorySaveElement> updateList = new ArrayList<>();
30  
31      ArrayList<CategorySaveElement> deleteList = new ArrayList<>();
32  
33      public void add(MCRCategory categ, MCRCategoryID parentID, int index, String status)
34          throws WebApplicationException {
35          if ("updated".equals(status)) {
36              updateList.add(new CategorySaveElement(categ, parentID, index));
37          } else if ("deleted".equals(status)) {
38              deleteList.add(new CategorySaveElement(categ, parentID, index));
39          } else {
40              throw new WebApplicationException("Unknown status.");
41          }
42      }
43  
44      private class CategorySaveElement {
45          private MCRCategory categ;
46  
47          private MCRCategoryID parentID;
48  
49          private int index;
50  
51          CategorySaveElement(MCRCategory categ, MCRCategoryID parentID, int index) {
52              this.categ = categ;
53              this.parentID = parentID;
54              this.index = index;
55          }
56      }
57  
58  }