forked from kitodo/kitodo-production
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e906c52
commit 5b8ed80
Showing
5 changed files
with
60 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ain/java/org/kitodo/production/helper/metadata/MediaPartialLogicalDivisionComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* 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.production.helper.metadata; | ||
|
||
import org.kitodo.api.dataformat.LogicalDivision; | ||
import org.kitodo.api.dataformat.PhysicalDivision; | ||
import org.kitodo.api.dataformat.View; | ||
|
||
import java.util.Comparator; | ||
import java.util.Objects; | ||
|
||
public class MediaPartialLogicalDivisionComparator implements Comparator<LogicalDivision> { | ||
|
||
@Override | ||
public int compare(LogicalDivision logicalDivisionA, LogicalDivision logicalDivisionB) { | ||
View viewA = logicalDivisionA.getViews().getFirst(); | ||
View viewB = logicalDivisionB.getViews().getFirst(); | ||
if (Objects.nonNull(viewA) && Objects.nonNull(viewB)) { | ||
PhysicalDivision physicalDivisionA = viewA.getPhysicalDivision(); | ||
PhysicalDivision physicalDivisionB = viewB.getPhysicalDivision(); | ||
if (physicalDivisionA.hasMediaPartialView() && physicalDivisionB.hasMediaPartialView()) { | ||
return physicalDivisionA.getMediaPartialView().getBegin() | ||
.compareTo(physicalDivisionB.getMediaPartialView().getBegin()); | ||
} | ||
} | ||
return Integer.compare(logicalDivisionA.getOrder(), logicalDivisionB.getOrder()); | ||
} | ||
|
||
} |