Skip to content

Commit

Permalink
Merge pull request #4522 from matthias-ronge/rename-physical_part-of-…
Browse files Browse the repository at this point in the history
…issue-3159

Rename “media unit” to “physical division”
  • Loading branch information
Kathrin-Huber authored Aug 30, 2021
2 parents dfcb2fd + 88a3c89 commit 7f3609c
Show file tree
Hide file tree
Showing 50 changed files with 858 additions and 831 deletions.
12 changes: 6 additions & 6 deletions Kitodo-API/src/main/java/org/kitodo/api/dataformat/Division.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @param <T>
* There are two versions of it, an {@link LogicalDivision}
* and a {@link MediaUnit}.
* and a {@link PhysicalDivision}.
*/
public abstract class Division<T extends Division<T>> {
/**
Expand All @@ -57,7 +57,7 @@ public abstract class Division<T extends Division<T>> {
* <i>For logical structures</i> meaningless, only used internally.
*
* <p>
* <i>For media units</i>, the display or playback order of several media
* <i>For physical divisions</i>, the display or playback order of several media
* units referenced from one logical division is determined by
* this attribute, not by the order of the references.
*/
Expand All @@ -72,8 +72,8 @@ public abstract class Division<T extends Division<T>> {
* mapped to a machine-readable value.
*
* <p>
* <i>For media units</i>, <b>a human readable label</b> for the
* <i>order</i> of this media unit. This need not be directly related to the
* <i>For physical divisions</i>, <b>a human readable label</b> for the
* <i>order</i> of this physical division. This need not be directly related to the
* order number. Examples of order labels could be “I, II, III, IV, V, - ,
* 1, 2, 3”, meanwhile the order would be “1, 2, 3, 4, 5, 6, 7, 8, 9”.
*/
Expand Down Expand Up @@ -191,7 +191,7 @@ public void setOrder(int order) {
}

/**
* Returns the order label for this media unit.
* Returns the order label for this physical division.
*
* @return the order label
*/
Expand All @@ -200,7 +200,7 @@ public String getOrderlabel() {
}

/**
* Sets the order label for this media unit.
* Sets the order label for this physical division.
*
* @param orderlabel
* order label to set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* representation of a digital medium. The logical division can be
* imagined as a table of contents and is used to display the table of contents
* in the viewer. It uses {@link View}s to refer to elements of the
* {@link MediaUnit} of the digital medium, or can {@link #link} to other
* {@link PhysicalDivision} of the digital medium, or can {@link #link} to other
* processes.
*/
public class LogicalDivision extends Division<LogicalDivision> {
Expand All @@ -31,7 +31,7 @@ public class LogicalDivision extends Division<LogicalDivision> {
private LinkedMetsResource link;

/**
* The views on {@link MediaUnit}s that this logical division
* The views on {@link PhysicalDivision}s that this logical division
* level comprises.
*/
private final LinkedList<View> views;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Objects;

/**
* A variant of the {@code MediaUnit}s for a particular use. By use is meant a
* A variant of the {@code PhysicalDivision}s for a particular use. By use is meant a
* technical form of use. Therefore, the variant has as technical property the
* Internet MIME type. Examples of variants include thumbnails, full resolution
* images, file ready to print, OCR results, etc. For Production, a variant is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import org.kitodo.api.dataformat.mets.KitodoUUID;

/**
* A tree-shaped description of the media unit of the digital representation of
* A tree-shaped description of the physical division of the digital representation of
* a digital medium. Each leaf of the physical structure tree represents a
* single medium, possibly in several forms of digital representation. For
* books, this is typically flat, meaning the {@link Workpiece#getMediaUnit()}
* books, this is typically flat, meaning the {@link Workpiece#getPhysicalStructure()}
* represents the book, and its immediate children represent the individual
* views (front cover, inside cover, first page, second page, third page, …) For
* other media, this may well be more complex, such as an archival box
Expand All @@ -35,18 +35,18 @@
*
* <p>
* Media files that represent different representations of the same medium can
* be attached to a media unit. This can be still images in different
* be attached to a physical division. This can be still images in different
* resolutions with equal image content, but also the photography of the side of
* a record along with its digitized soundtrack.
*/
public class MediaUnit extends Division<MediaUnit> {
// TODO: we probably need a way to configure MediaUnit types to be considered for renumbering/pagination!
public class PhysicalDivision extends Division<PhysicalDivision> {
// TODO: we probably need a way to configure PhysicalDivision types to be considered for renumbering/pagination!
public static final String TYPE_PAGE = "page";
public static final String TYPE_TRACK = "track";
public static final String TYPE_OTHER = "other";

/**
* Each media unit can be available in different variants, for each of which
* Each physical division can be available in different variants, for each of which
* a media file is available. This is in this map.
*/
private Map<MediaVariant, URI> mediaFiles = new HashMap<>();
Expand All @@ -62,9 +62,9 @@ public class MediaUnit extends Division<MediaUnit> {
private transient List<LogicalDivision> logicalDivisions;

/**
* Creates a new MediaUnit.
* Creates a new PhysicalDivision.
*/
public MediaUnit() {
public PhysicalDivision() {
logicalDivisions = new LinkedList<>();
}

Expand Down Expand Up @@ -103,7 +103,7 @@ public void setDivId(String divId) {

/**
* The list is available to assist to render the front-end by holding the
* elements of the logical structure that reference this media unit. It is
* elements of the logical structure that reference this physical division. It is
* transient, meaning that its content is not saved and is not restored when
* it is loaded.
*
Expand Down Expand Up @@ -135,11 +135,11 @@ public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (!(o instanceof MediaUnit)) {
if (!(o instanceof PhysicalDivision)) {
return false;
}
MediaUnit mediaUnit = (MediaUnit) o;
return Objects.equals(mediaFiles, mediaUnit.mediaFiles);
PhysicalDivision physicalDivision = (PhysicalDivision) o;
return Objects.equals(mediaFiles, physicalDivision.mediaFiles);
}

@Override
Expand Down
42 changes: 21 additions & 21 deletions Kitodo-API/src/main/java/org/kitodo/api/dataformat/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,48 @@
import java.util.Objects;

/**
* A view on a media unit. The individual levels of the
* A view on a physical division. The individual levels of the
* {@link LogicalDivision} refer to {@code View}s on
* {@link MediaUnit}s. At the moment, each {@code View} refers to exactly one
* {@code MediaUnit} as a whole.
* {@link PhysicalDivision}s. At the moment, each {@code View} refers to exactly one
* {@code PhysicalDivision} as a whole.
*/
public class View {

/**
* Creates a new view with a media unit.
* Creates a new view with a physical division.
*
* @param mediaUnit
* media unit to set in the view
* @return a new view with a media unit
* @param physicalDivision
* physical division to set in the view
* @return a new view with a physical division
*/
public static View of(MediaUnit mediaUnit) {
public static View of(PhysicalDivision physicalDivision) {
View view = new View();
view.setMediaUnit(mediaUnit);
view.setPhysicalDivision(physicalDivision);
return view;
}

/**
* Media unit in view.
*/
private MediaUnit mediaUnit;
private PhysicalDivision physicalDivision;

/**
* Returns the media unit in the view.
* Returns the physical division in the view.
*
* @return the media unit
* @return the physical division
*/
public MediaUnit getMediaUnit() {
return mediaUnit;
public PhysicalDivision getPhysicalDivision() {
return physicalDivision;
}

/**
* Inserts a media unit into the view.
* Inserts a physical division into the view.
*
* @param mediaUnit
* media unit to insert
* @param physicalDivision
* physical division to insert
*/
public void setMediaUnit(MediaUnit mediaUnit) {
this.mediaUnit = mediaUnit;
public void setPhysicalDivision(PhysicalDivision physicalDivision) {
this.physicalDivision = physicalDivision;
}

@Override
Expand All @@ -67,14 +67,14 @@ public boolean equals(Object o) {
return false;
}
View view = (View) o;
return Objects.equals(mediaUnit, view.mediaUnit);
return Objects.equals(physicalDivision, view.physicalDivision);
}

@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((mediaUnit == null) ? 0 : mediaUnit.hashCode());
hashCode = prime * hashCode + ((physicalDivision == null) ? 0 : physicalDivision.hashCode());
return hashCode;
}
}
59 changes: 30 additions & 29 deletions Kitodo-API/src/main/java/org/kitodo/api/dataformat/Workpiece.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class Workpiece {
private String id;

/**
* The media unit that belongs to this workpiece. The media unit can have
* The physical division that belongs to this workpiece. The physical division can have
* children, such as a bound book that can have pages.
*/
private MediaUnit mediaUnit = new MediaUnit();
private PhysicalDivision physicalStructure = new PhysicalDivision();

/**
* The logical logical division.
Expand Down Expand Up @@ -99,12 +99,12 @@ public void setId(String id) {
}

/**
* Returns the media unit of this workpiece.
* Returns the physical structure of this workpiece.
*
* @return the media units
* @return the physical structure
*/
public MediaUnit getMediaUnit() {
return mediaUnit;
public PhysicalDivision getPhysicalStructure() {
return physicalStructure;
}

/**
Expand All @@ -117,20 +117,20 @@ public LogicalDivision getLogicalStructure() {
}

/**
* Sets the media unit of the workpiece.
* Sets the physical structure of the workpiece.
*
* @param mediaUnit
* media unit to set
* @param physicalStructure
* physical structure to set
*/
public void setMediaUnit(MediaUnit mediaUnit) {
this.mediaUnit = mediaUnit;
public void setPhysicalStructure(PhysicalDivision physicalStructure) {
this.physicalStructure = physicalStructure;
}

/**
* Sets the logical division of the workpiece.
* Sets the logical structure of the workpiece.
*
* @param logicalStructure
* logical division to set
* logical structure to set
*/
public void setLogicalStructure(LogicalDivision logicalStructure) {
this.logicalStructure = logicalStructure;
Expand Down Expand Up @@ -161,7 +161,7 @@ public boolean equals(Object o) {
return Objects.equals(creationDate, workpiece.creationDate)
&& Objects.equals(editHistory, workpiece.editHistory)
&& Objects.equals(id, workpiece.id)
&& Objects.equals(mediaUnit, workpiece.mediaUnit)
&& Objects.equals(physicalStructure, workpiece.physicalStructure)
&& Objects.equals(logicalStructure, workpiece.logicalStructure);
}

Expand All @@ -179,31 +179,32 @@ public List<LogicalDivision> getAllLogicalDivisions() {
}

/**
* Returns all child media units of the media unit of the workpiece with
* Returns all child physical divisions of the physical division of the workpiece with
* type "page" sorted by their {@code order} as a flat list. The root media
* unit is not contained. The list isn’t backed by the media units, which
* unit is not contained. The list isn’t backed by the physical divisions, which
* means that insertions and deletions in the list would not change the
* media units. Therefore a list that cannot be modified is returned.
* physical divisions. Therefore a list that cannot be modified is returned.
*
* @return all media units with type "page", sorted by their {@code order}
* @return all physical divisions with type "page", sorted by their {@code order}
*/
public List<MediaUnit> getAllMediaUnitChildrenFilteredByTypePageAndSorted() {
List<MediaUnit> mediaUnits = mediaUnit.getChildren().stream().flatMap(Workpiece::treeStream)
.filter(mediaUnitToCheck -> Objects.equals(mediaUnitToCheck.getType(), MediaUnit.TYPE_PAGE))
.sorted(Comparator.comparing(MediaUnit::getOrder)).collect(Collectors.toList());
return Collections.unmodifiableList(mediaUnits);
public List<PhysicalDivision> getAllPhysicalDivisionChildrenFilteredByTypePageAndSorted() {
List<PhysicalDivision> physicalDivisions = physicalStructure.getChildren().stream()
.flatMap(Workpiece::treeStream)
.filter(physicalDivisionToCheck -> Objects.equals(physicalDivisionToCheck.getType(), PhysicalDivision.TYPE_PAGE))
.sorted(Comparator.comparing(PhysicalDivision::getOrder)).collect(Collectors.toList());
return Collections.unmodifiableList(physicalDivisions);
}

/**
* Returns all media units of the media unit of the workpiece as a flat
* list. The list isn’t backed by the media units, which means that
* insertions and deletions in the list would not change the media units.
* Returns all physical divisions of the physical division of the workpiece as a flat
* list. The list isn’t backed by the physical divisions, which means that
* insertions and deletions in the list would not change the physical divisions.
* Therefore a list that cannot be modified is returned.
*
* @return all media units as an unmodifiable list
* @return all physical divisions as an unmodifiable list
*/
public List<MediaUnit> getAllMediaUnits() {
return Collections.unmodifiableList(treeStream(mediaUnit).collect(Collectors.toList()));
public List<PhysicalDivision> getAllPhysicalDivisions() {
return Collections.unmodifiableList(treeStream(physicalStructure).collect(Collectors.toList()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.NoSuchElementException;
import java.util.Objects;

import org.kitodo.api.dataformat.MediaUnit;
import org.kitodo.api.dataformat.PhysicalDivision;
import org.kitodo.config.KitodoConfig;
import org.kitodo.config.enums.ParameterDataEditor;
import org.kitodo.dataeditor.MetsKitodoObjectFactory;
Expand Down Expand Up @@ -77,12 +77,12 @@ private List<DivType> getDivTypesByFileTypes(List<FileType> fileTypes) {

private String getPhysicalDivTypeByFileType(FileType file) {
if (file.getMIMETYPE().contains("image")) {
return MediaUnit.TYPE_PAGE;
return PhysicalDivision.TYPE_PAGE;
}
if (file.getMIMETYPE().contains("audio")) {
return MediaUnit.TYPE_TRACK;
return PhysicalDivision.TYPE_TRACK;
}
return MediaUnit.TYPE_OTHER;
return PhysicalDivision.TYPE_OTHER;
}

private DivType getDivById(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import org.kitodo.api.dataformat.View;

/**
* A view on a media unit. The individual levels of the {@link DivXmlElementAccess} refer
* A view on a physical division. The individual levels of the {@link DivXmlElementAccess} refer
* to {@code View}s on {@link FileXmlElementAccess}s. At the moment, each {@code View}
* refers to exactly one {@code MediaUnit} as a whole. This concept level has
* refers to exactly one {@code PhysicalDivision} as a whole. This concept level has
* been added here in order to be able to expand it in the future in order to be
* able to refer to individual parts of a {@code MediaUnit}.
* able to refer to individual parts of a {@code PhysicalDivision}.
*/
public class AreaXmlElementAccess {

Expand All @@ -39,10 +39,10 @@ public AreaXmlElementAccess() {
* called module-internally when loading a METS file.
*
* @param fileXmlElementAccess
* media unit in view
* physical division in view
*/
AreaXmlElementAccess(FileXmlElementAccess fileXmlElementAccess) {
view.setMediaUnit(fileXmlElementAccess.getMediaUnit());
view.setPhysicalDivision(fileXmlElementAccess.getPhysicalDivision());
}

View getView() {
Expand Down
Loading

0 comments on commit 7f3609c

Please sign in to comment.