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.mets.model;
20  
21  import java.util.HashSet;
22  import java.util.Optional;
23  import java.util.Set;
24  
25  import org.mycore.datamodel.niofs.MCRPath;
26  
27  /**
28   * Base implementation for a METS generator.
29   *
30   * @author Matthias Eichner
31   */
32  public abstract class MCRMETSAbstractGenerator implements MCRMETSGenerator {
33  
34      private MCRPath derivatePath;
35  
36      private Set<MCRPath> ignorePaths;
37  
38      private Mets oldMets;
39  
40      public MCRMETSAbstractGenerator() {
41          this.ignorePaths = new HashSet<>();
42      }
43  
44      /**
45       * Returns the path to the derivate.
46       *
47       * @return path to the derivate
48       */
49      public MCRPath getDerivatePath() {
50          return derivatePath;
51      }
52  
53      /**
54       * Returns an optional of the old mets. Sometimes a generator needs to copy informations of the previous state
55       * of the mets.xml.
56       *
57       * @return optional of the previous mets.xml
58       */
59      public Optional<Mets> getOldMets() {
60          return oldMets != null ? Optional.of(this.oldMets) : Optional.empty();
61      }
62  
63      /**
64       * Returns a set of paths which should be ignore while creating the mets.xml.
65       *
66       * @return set of paths which should be ignored
67       */
68      public Set<MCRPath> getIgnorePaths() {
69          return ignorePaths;
70      }
71  
72      /**
73       * Returns the owner of the derivate path, so the derivate id as string.
74       *
75       * @return the derivate id
76       */
77      protected String getOwner() {
78          return this.derivatePath.getOwner();
79      }
80  
81      public void setDerivatePath(MCRPath derivatePath) {
82          this.derivatePath = derivatePath;
83      }
84  
85      public void setIgnorePaths(Set<MCRPath> ignorePaths) {
86          this.ignorePaths = ignorePaths;
87      }
88  
89      public void setOldMets(Mets oldMets) {
90          this.oldMets = oldMets;
91      }
92  
93  }