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.mods.merger;
20  
21  import org.jdom2.Element;
22  
23  /**
24   * Compares and merges mods:relatedItem elements.
25   * Two related items are only probably same
26   * if they are of type "host", since there can only be one host per publication.
27   *
28   * @author Frank L\u00FCtzenkirchen
29   */
30  public class MCRRelatedItemMerger extends MCRMerger {
31  
32      public void setElement(Element element) {
33          super.setElement(element);
34      }
35  
36      @Override
37      public boolean isProbablySameAs(MCRMerger other) {
38          if (!(other instanceof MCRRelatedItemMerger)) {
39              return false;
40          } else {
41              return isRelatedItemTypeHost() && ((MCRRelatedItemMerger) other).isRelatedItemTypeHost();
42          }
43      }
44  
45      private boolean isRelatedItemTypeHost() {
46          return "host".equals(element.getAttributeValue("type"));
47      }
48  }