Coverage Summary for Class: MetsKitodoHeaderHandler (org.kitodo.dataeditor.handlers)
Class |
Class, %
|
Method, %
|
Line, %
|
MetsKitodoHeaderHandler |
100%
(1/1)
|
100%
(1/1)
|
100%
(7/7)
|
/*
* (c) Kitodo. Key to digital objects e. V. <contact@kitodo.org>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/
package org.kitodo.dataeditor.handlers;
import java.util.List;
import java.util.Objects;
import org.kitodo.dataformat.metskitodo.Mets;
import org.kitodo.dataformat.metskitodo.MetsType;
/**
* General utilities for handling of generated mets-kitodo class content.
*/
public class MetsKitodoHeaderHandler {
/**
* Private constructor to hide the implicit public one.
*/
private MetsKitodoHeaderHandler() {
}
/**
* Adds a note to the first {@code agent} element in mets header. Does nothing
* if no {@code agent} element exists.
*
* @param noteMessage
* The note message.
* @param mets
* The Mets object.
* @return The Mets object with added note.
*/
public static Mets addNoteToMetsHeader(String noteMessage, Mets mets) {
MetsType.MetsHdr metsHdr = mets.getMetsHdr();
if (Objects.isNull(metsHdr)) {
return mets;
}
List<MetsType.MetsHdr.Agent> agents = metsHdr.getAgent();
if (!agents.isEmpty()) {
agents.get(0).getNote().add(noteMessage);
}
return mets;
}
}