diff --git a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Division.java b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Division.java index 51bf70abe07..6bb9b5128bd 100644 --- a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Division.java +++ b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Division.java @@ -29,7 +29,7 @@ * be described with metadata. * * @param - * There are two versions of it, an {@link IncludedStructuralElement} + * There are two versions of it, an {@link LogicalDivision} * and a {@link MediaUnit}. */ public abstract class Division> { @@ -58,7 +58,7 @@ public abstract class Division> { * *

* For media units, the display or playback order of several media - * units referenced from one included structural element is determined by + * units referenced from one logical division is determined by * this attribute, not by the order of the references. */ private int order; @@ -144,7 +144,7 @@ public List getContentIds() { } /** - * Returns the label of this included structural element. + * Returns the label of this logical division. * * @return the label */ @@ -153,7 +153,7 @@ public String getLabel() { } /** - * Sets the label of this included structural element. + * Sets the label of this logical division. * * @param label * label to set diff --git a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/IncludedStructuralElement.java b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/LogicalDivision.java similarity index 68% rename from Kitodo-API/src/main/java/org/kitodo/api/dataformat/IncludedStructuralElement.java rename to Kitodo-API/src/main/java/org/kitodo/api/dataformat/LogicalDivision.java index 00880ca85e9..c5a9d09ab33 100644 --- a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/IncludedStructuralElement.java +++ b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/LogicalDivision.java @@ -17,47 +17,47 @@ import org.kitodo.api.dataformat.mets.LinkedMetsResource; /** - * A tree-shaped description of the included structural element of the digital - * representation of a digital medium. The included structural element can be + * A tree-shaped description of the logical division of the digital + * 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 * processes. */ -public class IncludedStructuralElement extends Division { +public class LogicalDivision extends Division { /** * Specifies the link if there is one. */ private LinkedMetsResource link; /** - * The views on {@link MediaUnit}s that this included structural element + * The views on {@link MediaUnit}s that this logical division * level comprises. */ private final LinkedList views; /** - * Creates a new included structural element. + * Creates a new logical division. */ - public IncludedStructuralElement() { + public LogicalDivision() { views = new LinkedList<>(); } /** - * Creates a new subclass of included structural element from an existing - * included structural element. + * Creates a new subclass of logical division from an existing + * logical division. * * @param source - * included structural element that serves as data source + * logical division that serves as data source */ - protected IncludedStructuralElement(IncludedStructuralElement source) { + protected LogicalDivision(LogicalDivision source) { super(source); link = source.link; views = source.views; } /** - * Returns the link of this included structural element. + * Returns the link of this logical division. * * @return the link */ @@ -66,7 +66,7 @@ public LinkedMetsResource getLink() { } /** - * Sets the link of this included structural element. + * Sets the link of this logical division. * * @param link * link to set @@ -76,7 +76,7 @@ public void setLink(LinkedMetsResource link) { } /** - * Returns the views associated with this included structural element. + * Returns the views associated with this logical division. * * @return the views */ @@ -97,10 +97,10 @@ public boolean equals(Object o) { if (!super.equals(o)) { return false; } - if (!(o instanceof IncludedStructuralElement)) { + if (!(o instanceof LogicalDivision)) { return false; } - IncludedStructuralElement other = (IncludedStructuralElement) o; + LogicalDivision other = (LogicalDivision) o; return Objects.equals(link, other.link) && Objects.equals(views, other.views); } diff --git a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaUnit.java b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaUnit.java index 7ce181f3832..c7cce247068 100644 --- a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaUnit.java +++ b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/MediaUnit.java @@ -57,15 +57,15 @@ public class MediaUnit extends Division { private String metsDivReferrerId; /** - * List of IncludedStructuralElements this view is assigned to. + * List of LogicalDivisions this view is assigned to. */ - private transient List includedStructuralElements; + private transient List logicalDivisions; /** * Creates a new MediaUnit. */ public MediaUnit() { - includedStructuralElements = new LinkedList<>(); + logicalDivisions = new LinkedList<>(); } @@ -103,14 +103,14 @@ public void setDivId(String divId) { /** * The list is available to assist to render the front-end by holding the - * elements of the root element that reference this media unit. It is + * elements of the logical structure that reference this media unit. It is * transient, meaning that its content is not saved and is not restored when * it is loaded. * * @return a list that you can use */ - public List getIncludedStructuralElements() { - return includedStructuralElements; + public List getLogicalDivisions() { + return logicalDivisions; } @Override diff --git a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/View.java b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/View.java index cfb8a74d716..0ac27f28e5c 100644 --- a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/View.java +++ b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/View.java @@ -15,7 +15,7 @@ /** * A view on a media unit. The individual levels of the - * {@link IncludedStructuralElement} refer to {@code View}s on + * {@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. */ diff --git a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Workpiece.java b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Workpiece.java index 202b431f072..c89fec00bf8 100644 --- a/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Workpiece.java +++ b/Kitodo-API/src/main/java/org/kitodo/api/dataformat/Workpiece.java @@ -47,9 +47,9 @@ public class Workpiece { private MediaUnit mediaUnit = new MediaUnit(); /** - * The logical included structural element. + * The logical logical division. */ - private IncludedStructuralElement rootElement = new IncludedStructuralElement(); + private LogicalDivision logicalStructure = new LogicalDivision(); /** * Returns the creation date of the workpiece. @@ -108,12 +108,12 @@ public MediaUnit getMediaUnit() { } /** - * Returns the root element of the included structural element. + * Returns the root element of the logical division. * - * @return root element of the included structural element + * @return root element of the logical division */ - public IncludedStructuralElement getRootElement() { - return rootElement; + public LogicalDivision getLogicalStructure() { + return logicalStructure; } /** @@ -127,18 +127,18 @@ public void setMediaUnit(MediaUnit mediaUnit) { } /** - * Sets the included structural element of the workpiece. + * Sets the logical division of the workpiece. * - * @param rootElement - * included structural element to set + * @param logicalStructure + * logical division to set */ - public void setRootElement(IncludedStructuralElement rootElement) { - this.rootElement = rootElement; + public void setLogicalStructure(LogicalDivision logicalStructure) { + this.logicalStructure = logicalStructure; } @Override public String toString() { - return id + ", " + rootElement; + return id + ", " + logicalStructure; } @Override @@ -162,20 +162,20 @@ public boolean equals(Object o) { && Objects.equals(editHistory, workpiece.editHistory) && Objects.equals(id, workpiece.id) && Objects.equals(mediaUnit, workpiece.mediaUnit) - && Objects.equals(rootElement, workpiece.rootElement); + && Objects.equals(logicalStructure, workpiece.logicalStructure); } /** - * Returns all included structural elements of the root element of the + * Returns all logical divisions of the logical structure of the * workpiece as a flat list. The list isn’t backed by the included * structural elements, which means that insertions and deletions in the - * list would not change the included structural elements. Therefore a list + * list would not change the logical divisions. Therefore a list * that cannot be modified is returned. * - * @return all included structural elements as an unmodifiable list + * @return all logical divisions as an unmodifiable list */ - public List getAllIncludedStructuralElements() { - return Collections.unmodifiableList(treeStream(rootElement).collect(Collectors.toList())); + public List getAllLogicalDivisions() { + return Collections.unmodifiableList(treeStream(logicalStructure).collect(Collectors.toList())); } /** diff --git a/Kitodo-API/src/test/java/org/kitodo/api/dataformat/DivisionTest.java b/Kitodo-API/src/test/java/org/kitodo/api/dataformat/DivisionTest.java index c6a6ede300e..eb828c45b69 100644 --- a/Kitodo-API/src/test/java/org/kitodo/api/dataformat/DivisionTest.java +++ b/Kitodo-API/src/test/java/org/kitodo/api/dataformat/DivisionTest.java @@ -26,34 +26,34 @@ public class DivisionTest { */ @Test public void getAllChildrenTest() { - IncludedStructuralElement parent = new IncludedStructuralElement(); + LogicalDivision parent = new LogicalDivision(); parent.setLabel("Parent"); - IncludedStructuralElement childOne = new IncludedStructuralElement(); + LogicalDivision childOne = new LogicalDivision(); childOne.setLabel("Child 1"); parent.getChildren().add(childOne); - IncludedStructuralElement childOneOne = new IncludedStructuralElement(); + LogicalDivision childOneOne = new LogicalDivision(); childOneOne.setLabel("Child 1.1"); childOne.getChildren().add(childOneOne); - IncludedStructuralElement childOneTwo = new IncludedStructuralElement(); + LogicalDivision childOneTwo = new LogicalDivision(); childOneTwo.setLabel("Child 1.2"); childOne.getChildren().add(childOneTwo); - IncludedStructuralElement childTwo = new IncludedStructuralElement(); + LogicalDivision childTwo = new LogicalDivision(); childTwo.setLabel("Child 2"); parent.getChildren().add(childTwo); - IncludedStructuralElement childTwoOne = new IncludedStructuralElement(); + LogicalDivision childTwoOne = new LogicalDivision(); childTwoOne.setLabel("Child 2.1"); childTwo.getChildren().add(childTwoOne); - IncludedStructuralElement childTwoTwo = new IncludedStructuralElement(); + LogicalDivision childTwoTwo = new LogicalDivision(); childTwoTwo.setLabel("Child 2.2"); childTwo.getChildren().add(childTwoTwo); - List allChildren = parent.getAllChildren().stream().map(IncludedStructuralElement::getLabel) + List allChildren = parent.getAllChildren().stream().map(LogicalDivision::getLabel) .collect(Collectors.toList()); assertFalse(allChildren.contains("Parent")); diff --git a/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java b/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java index 1ae3adfb4a8..3d1b21abc1c 100644 --- a/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java +++ b/Kitodo-DataFormat/src/main/java/org/kitodo/dataformat/access/DivXmlElementAccess.java @@ -34,7 +34,7 @@ import org.kitodo.api.Metadata; import org.kitodo.api.MetadataEntry; import org.kitodo.api.MetadataGroup; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.api.dataformat.mets.KitodoUUID; @@ -52,7 +52,7 @@ * The tree-like outline structure for digital representation. This structuring * structure can be subdivided into arbitrary finely granular. */ -public class DivXmlElementAccess extends IncludedStructuralElement { +public class DivXmlElementAccess extends LogicalDivision { /** * The qualified name of the Kitodo metadata format, needed to assemble the * metadata entries in METS using JAXB. @@ -78,10 +78,10 @@ public DivXmlElementAccess() { /** * Creates a new DivXmlElementAccess for an existing structure. */ - DivXmlElementAccess(IncludedStructuralElement includedStructuralElement) { - super(includedStructuralElement); - metsReferrerId = includedStructuralElement instanceof DivXmlElementAccess - ? ((DivXmlElementAccess) includedStructuralElement).metsReferrerId + DivXmlElementAccess(LogicalDivision logicalDivision) { + super(logicalDivision); + metsReferrerId = logicalDivision instanceof DivXmlElementAccess + ? ((DivXmlElementAccess) logicalDivision).metsReferrerId : KitodoUUID.randomUUID(); } @@ -132,7 +132,7 @@ public DivXmlElementAccess() { if (Objects.nonNull(fileXmlElementAccess) && !fileXmlElementAccessIsLinkedToChildren(fileXmlElementAccess, div.getDiv(), mediaUnitsMap)) { super.getViews().add(new AreaXmlElementAccess(fileXmlElementAccess).getView()); - fileXmlElementAccess.getMediaUnit().getIncludedStructuralElements().add(this); + fileXmlElementAccess.getMediaUnit().getLogicalDivisions().add(this); } } } @@ -268,8 +268,8 @@ DivType toDiv(Map mediaUnitIDs, LinkedList - * The {@code IncludedStructuralElement} is a tree structure that can be finely + * The {@code LogicalDivision} is a tree structure that can be finely * subdivided, e.g. a book, in which the chapters, in it individual elements * such as tables or figures. Each outline level points to the * {@code MediaUnit}s that belong to it via {@link AreaXmlElementAccess}s. @@ -151,7 +151,7 @@ private MetsXmlElementAccess(Mets mets) { mediaUnitsMap.get(smLink.getFrom()).add(divIDsToMediaUnits.get(smLink.getTo())); } } - workpiece.setRootElement(getStructMapsStreamByType(mets, "LOGICAL") + workpiece.setLogicalStructure(getStructMapsStreamByType(mets, "LOGICAL") .map(structMap -> new DivXmlElementAccess(structMap.getDiv(), mets, mediaUnitsMap, 1)).collect(Collectors.toList()) .iterator().next()); } @@ -251,7 +251,7 @@ private Mets toMets() { LinkedList> smLinkData = new LinkedList<>(); StructMapType logical = new StructMapType(); logical.setTYPE("LOGICAL"); - logical.setDiv(new DivXmlElementAccess(workpiece.getRootElement()).toDiv(mediaUnitIDs, smLinkData, mets)); + logical.setDiv(new DivXmlElementAccess(workpiece.getLogicalStructure()).toDiv(mediaUnitIDs, smLinkData, mets)); mets.getStructMap().add(logical); mets.setStructLink(createStructLink(smLinkData)); diff --git a/Kitodo-DataFormat/src/test/java/org/kitodo/dataformat/access/MetsXmlElementAccessIT.java b/Kitodo-DataFormat/src/test/java/org/kitodo/dataformat/access/MetsXmlElementAccessIT.java index b20e8e9ee00..b75670d3c08 100644 --- a/Kitodo-DataFormat/src/test/java/org/kitodo/dataformat/access/MetsXmlElementAccessIT.java +++ b/Kitodo-DataFormat/src/test/java/org/kitodo/dataformat/access/MetsXmlElementAccessIT.java @@ -32,7 +32,7 @@ import org.kitodo.api.MdSec; import org.kitodo.api.MetadataEntry; import org.kitodo.api.MetadataGroup; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.MediaVariant; import org.kitodo.api.dataformat.ProcessingNote; @@ -59,13 +59,13 @@ public void testRead() throws Exception { assertEquals(183, workpiece.getMediaUnit().getChildren().size()); // METS file has 17 unstructured images - assertEquals(17, workpiece.getRootElement().getViews().size()); + assertEquals(17, workpiece.getLogicalStructure().getViews().size()); // root node has 16 children - assertEquals(16, workpiece.getRootElement().getChildren().size()); + assertEquals(16, workpiece.getLogicalStructure().getChildren().size()); // root node has 11 metadata entries - assertEquals(11, workpiece.getRootElement().getMetadata().size()); + assertEquals(11, workpiece.getLogicalStructure().getMetadata().size()); // file URIs can be read assertEquals(new URI("images/ThomPhar_644901748_media/00000001.tif"), @@ -124,45 +124,45 @@ public void testSave() throws Exception { } // create document structure - workpiece.getRootElement().setType("leaflet"); - workpiece.getRootElement().setLabel("The Leaflet"); + workpiece.getLogicalStructure().setType("leaflet"); + workpiece.getLogicalStructure().setLabel("The Leaflet"); for (MediaUnit page : pages) { View view = new View(); view.setMediaUnit(page); - workpiece.getRootElement().getViews().add(view); - page.getIncludedStructuralElements().add(workpiece.getRootElement()); + workpiece.getLogicalStructure().getViews().add(view); + page.getLogicalDivisions().add(workpiece.getLogicalStructure()); } - IncludedStructuralElement frontCover = new IncludedStructuralElement(); + LogicalDivision frontCover = new LogicalDivision(); frontCover.setType("frontCover"); frontCover.setLabel("Front cover"); View view = new View(); view.setMediaUnit(pages.get(0)); frontCover.getViews().add(view); - view.getMediaUnit().getIncludedStructuralElements().add(frontCover); - workpiece.getRootElement().getChildren().add(frontCover); + view.getMediaUnit().getLogicalDivisions().add(frontCover); + workpiece.getLogicalStructure().getChildren().add(frontCover); - IncludedStructuralElement inside = new IncludedStructuralElement(); + LogicalDivision inside = new LogicalDivision(); inside.setType("inside"); inside.setLabel("Inside"); view = new View(); view.setMediaUnit(pages.get(1)); inside.getViews().add(view); - view.getMediaUnit().getIncludedStructuralElements().add(inside); + view.getMediaUnit().getLogicalDivisions().add(inside); view = new View(); view.setMediaUnit(pages.get(2)); inside.getViews().add(view); - view.getMediaUnit().getIncludedStructuralElements().add(inside); - workpiece.getRootElement().getChildren().add(inside); + view.getMediaUnit().getLogicalDivisions().add(inside); + workpiece.getLogicalStructure().getChildren().add(inside); - IncludedStructuralElement backCover = new IncludedStructuralElement(); + LogicalDivision backCover = new LogicalDivision(); backCover.setType("backCover"); backCover.setLabel("Back cover"); view = new View(); view.setMediaUnit(pages.get(3)); backCover.getViews().add(view); - view.getMediaUnit().getIncludedStructuralElements().add(backCover); - workpiece.getRootElement().getChildren().add(backCover); + view.getMediaUnit().getLogicalDivisions().add(backCover); + workpiece.getLogicalStructure().getChildren().add(backCover); // add metadata MetadataEntry title = new MetadataEntry(); @@ -187,7 +187,7 @@ public void testSave() throws Exception { imagesConverted.setKey("imageConversionHint"); imagesConverted.setDomain(MdSec.DIGIPROV_MD); imagesConverted.setValue("Images have been converted from TIFF to JPEG."); - workpiece.getRootElement().getMetadata().add(imagesConverted); + workpiece.getLogicalStructure().getMetadata().add(imagesConverted); frontCover.getMetadata().add(imagesConverted); inside.getMetadata().add(imagesConverted); backCover.getMetadata().add(imagesConverted); @@ -239,12 +239,12 @@ public void testSave() throws Exception { MediaUnit mediaUnit = mediaUnits.get(i); assertEquals(2, mediaUnit.getMediaFiles().size()); } - IncludedStructuralElement includedStructuralElementRoot = reread.getRootElement(); - assertEquals(1, includedStructuralElementRoot.getChildren().get(0).getViews().size()); - assertEquals(2, includedStructuralElementRoot.getChildren().get(1).getViews().size()); - assertEquals(1, includedStructuralElementRoot.getChildren().get(2).getViews().size()); - assertEquals(3, includedStructuralElementRoot.getChildren().size()); - assertEquals(1, includedStructuralElementRoot.getMetadata().size()); + LogicalDivision logicalStructure = reread.getLogicalStructure(); + assertEquals(1, logicalStructure.getChildren().get(0).getViews().size()); + assertEquals(2, logicalStructure.getChildren().get(1).getViews().size()); + assertEquals(1, logicalStructure.getChildren().get(2).getViews().size()); + assertEquals(3, logicalStructure.getChildren().size()); + assertEquals(1, logicalStructure.getMetadata().size()); clean(); } diff --git a/Kitodo-Validation/src/main/java/org/kitodo/validation/metadata/MetadataValidation.java b/Kitodo-Validation/src/main/java/org/kitodo/validation/metadata/MetadataValidation.java index adebf102521..f9712f72a4e 100644 --- a/Kitodo-Validation/src/main/java/org/kitodo/validation/metadata/MetadataValidation.java +++ b/Kitodo-Validation/src/main/java/org/kitodo/validation/metadata/MetadataValidation.java @@ -43,7 +43,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; import org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.api.dataformat.Workpiece; @@ -119,9 +119,9 @@ public ValidationResult validate(Workpiece workpiece, RulesetManagementInterface results.add(checkForStructuresWithoutMedia(workpiece, translations)); results.add(checkForUnlinkedMedia(workpiece, translations)); - for (IncludedStructuralElement includedStructuralElement : workpiece.getAllIncludedStructuralElements()) { - results.addAll(checkMetadataRules(includedStructuralElement.toString(), includedStructuralElement.getType(), - getMetadata(includedStructuralElement), ruleset, metadataLanguage, translations)); + for (LogicalDivision logicalDivision : workpiece.getAllLogicalDivisions()) { + results.addAll(checkMetadataRules(logicalDivision.toString(), logicalDivision.getType(), + getMetadata(logicalDivision), ruleset, metadataLanguage, translations)); } for (MediaUnit mediaUnit : workpiece.getAllMediaUnits()) { @@ -132,18 +132,18 @@ public ValidationResult validate(Workpiece workpiece, RulesetManagementInterface return merge(results); } - private static Collection getMetadata(IncludedStructuralElement includedStructuralElement) { - Collection metadata = new ArrayList<>(includedStructuralElement.getMetadata()); - if (Objects.nonNull(includedStructuralElement.getLabel())) { + private static Collection getMetadata(LogicalDivision logicalDivision) { + Collection metadata = new ArrayList<>(logicalDivision.getMetadata()); + if (Objects.nonNull(logicalDivision.getLabel())) { MetadataEntry labelEntry = new MetadataEntry(); labelEntry.setKey("LABEL"); - labelEntry.setValue(includedStructuralElement.getLabel()); + labelEntry.setValue(logicalDivision.getLabel()); metadata.add(labelEntry); } - if (Objects.nonNull(includedStructuralElement.getOrderlabel())) { + if (Objects.nonNull(logicalDivision.getOrderlabel())) { MetadataEntry orderlabelEntry = new MetadataEntry(); orderlabelEntry.setKey("ORDERLABEL"); - orderlabelEntry.setValue(includedStructuralElement.getOrderlabel()); + orderlabelEntry.setValue(logicalDivision.getOrderlabel()); metadata.add(orderlabelEntry); } return metadata; @@ -191,7 +191,7 @@ private static ValidationResult checkForStructuresWithoutMedia(Workpiece workpie boolean warning = false; Collection messages = new HashSet<>(); - Collection structuresWithoutMedia = Workpiece.treeStream(workpiece.getRootElement()) + Collection structuresWithoutMedia = Workpiece.treeStream(workpiece.getLogicalStructure()) .filter(struc -> Objects.nonNull(struc.getType()) && struc.getViews().isEmpty() && struc.getChildren().isEmpty()) .map(structure -> translations.get(MESSAGE_STRUCTURE_WITHOUT_MEDIA) + ' ' + structure) .collect(Collectors.toSet()); @@ -200,7 +200,7 @@ private static ValidationResult checkForStructuresWithoutMedia(Workpiece workpie warning = true; } - if (!Workpiece.treeStream(workpiece.getRootElement()) + if (!Workpiece.treeStream(workpiece.getLogicalStructure()) .flatMap(structure -> structure.getViews().stream()).map(View::getMediaUnit) .allMatch(workpiece.getAllMediaUnits()::contains)) { messages.add(translations.get(MESSAGE_MEDIA_MISSING)); @@ -226,7 +226,7 @@ private static ValidationResult checkForUnlinkedMedia(Workpiece workpiece, KeySetView unassignedMediaUnits = ConcurrentHashMap.newKeySet(); unassignedMediaUnits.addAll(Workpiece.treeStream(workpiece.getMediaUnit()) .filter(mediaUnit -> !mediaUnit.getMediaFiles().isEmpty()).collect(Collectors.toList())); - Workpiece.treeStream(workpiece.getRootElement()).flatMap(structure -> structure.getViews().stream()) + Workpiece.treeStream(workpiece.getLogicalStructure()).flatMap(structure -> structure.getViews().stream()) .map(View::getMediaUnit) .forEach(unassignedMediaUnits::remove); if (!unassignedMediaUnits.isEmpty()) { diff --git a/Kitodo/rulesets/subhh.xml b/Kitodo/rulesets/subhh.xml index 26c6c59877d..1e13cbe7bfb 100644 --- a/Kitodo/rulesets/subhh.xml +++ b/Kitodo/rulesets/subhh.xml @@ -828,7 +828,7 @@ - + diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java index d41af9047f0..a33a5732263 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java @@ -129,7 +129,7 @@ public void showProcessMetadataStatistic() { int numberOfProcessImages = (int) Workpiece.treeStream(workpiece.getMediaUnit()) .filter(mediaUnit -> Objects.equals(mediaUnit.getType(), MediaUnit.TYPE_PAGE)).count(); this.numberOfGlobalImages += numberOfProcessImages; - int numberOfProcessStructuralElements = (int) Workpiece.treeStream(workpiece.getRootElement()).count(); + int numberOfProcessStructuralElements = (int) Workpiece.treeStream(workpiece.getLogicalStructure()).count(); this.numberOfGlobalStructuralElements += numberOfProcessStructuralElements; int numberOfProcessMetadata = Math .toIntExact(MetsService.countLogicalMetadata(workpiece)); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java index e14a2f88b8f..c3b85de2192 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java @@ -567,7 +567,7 @@ public void initializeProcesses() { processGenerator.generateProcess(template.getId(), project.getId()); this.processes = new LinkedList<>(Collections.singletonList( new TempProcess(processGenerator.getGeneratedProcess(), new Workpiece()))); - this.processMetadataTab.initializeProcessDetails(getProcesses().get(0).getWorkpiece().getRootElement()); + this.processMetadataTab.initializeProcessDetails(getProcesses().get(0).getWorkpiece().getLogicalStructure()); } catch (ProcessGenerationException e) { logger.error(e.getLocalizedMessage()); } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/InsertionPositionSelectionTreeNode.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/InsertionPositionSelectionTreeNode.java index 77f4162b22c..98f30c7cfaf 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/InsertionPositionSelectionTreeNode.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/InsertionPositionSelectionTreeNode.java @@ -47,7 +47,7 @@ public class InsertionPositionSelectionTreeNode extends DefaultTreeNode { * @param parent * parent node in the tree view * @param label - * label for the included structural element + * label for the logical division */ InsertionPositionSelectionTreeNode(TreeNode parent, String label, List tooltip) { super(null, parent); @@ -68,7 +68,7 @@ public int getItemIndex() { } /** - * Returns the label for an existing included structural element. + * Returns the label for an existing logical division. * * @return the label */ @@ -77,7 +77,7 @@ public String getLabel() { } /** - * Returns the tooltip for an existing included structural element. + * Returns the tooltip for an existing logical division. * * @return the tooltip */ diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/MetadataImportDialog.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/MetadataImportDialog.java index 33ae3bc9749..4afc5bab88c 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/MetadataImportDialog.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/MetadataImportDialog.java @@ -107,7 +107,7 @@ void fillCreateProcessForm(LinkedList processes) { if (!processes.isEmpty() && processes.getFirst().getMetadataNodes().getLength() > 0) { TempProcess firstProcess = processes.getFirst(); this.createProcessForm.getProcessDataTab() - .setDocType(firstProcess.getWorkpiece().getRootElement().getType()); + .setDocType(firstProcess.getWorkpiece().getLogicalStructure().getType()); Collection metadata = ImportService.importMetadata(firstProcess.getMetadataNodes(), MdSec.DMD_SEC); createProcessForm.getProcessMetadataTab().getProcessDetails().setMetadata(metadata); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java index fe1d34cf6b6..7d1cc00922f 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java @@ -60,12 +60,12 @@ public void setDocType(String docType) { Helper.setErrorMessage("docTypeNotFound", new Object[] {docType}); } if (!this.createProcessForm.getProcesses().isEmpty()) { - this.createProcessForm.getProcesses().get(0).getWorkpiece().getRootElement().setType(this.docType); + this.createProcessForm.getProcesses().get(0).getWorkpiece().getLogicalStructure().setType(this.docType); if (this.docType.isEmpty()) { this.createProcessForm.getProcessMetadataTab().setProcessDetails(ProcessFieldedMetadata.EMPTY); } else { ProcessFieldedMetadata metadata = this.createProcessForm.getProcessMetadataTab() - .initializeProcessDetails(this.createProcessForm.getProcesses().get(0).getWorkpiece().getRootElement()); + .initializeProcessDetails(this.createProcessForm.getProcesses().get(0).getWorkpiece().getLogicalStructure()); this.createProcessForm.getProcessMetadataTab().setProcessDetails(metadata); } } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDetail.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDetail.java index 1f80075212a..b4575fa1d1f 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDetail.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDetail.java @@ -27,7 +27,7 @@ import org.kitodo.api.Metadata; import org.kitodo.api.dataeditor.rulesetmanagement.Domain; import org.kitodo.api.dataformat.Division; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.exceptions.InvalidMetadataValueException; import org.kitodo.exceptions.NoSuchMetadataFieldException; @@ -115,7 +115,7 @@ public String getLabel() { /** * Returns the metadata from this row, as far as it has to be stored in the - * collection obtainable from {@link IncludedStructuralElement#getMetadata()}. + * collection obtainable from {@link LogicalDivision#getMetadata()}. * * @return the metadata from this row * @throws InvalidMetadataValueException @@ -129,7 +129,7 @@ public String getLabel() { * it to be called when saving the data. * * @return if data is to be written a pair of the setter of the - * {@link IncludedStructuralElement} and the value to set, else null + * {@link LogicalDivision} and the value to set, else null * @throws InvalidMetadataValueException * if the metadata form contains syntactically wrong input * @throws NoSuchMetadataFieldException diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessMetadataTab.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessMetadataTab.java index 01399e10ec8..99475bcf6a3 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessMetadataTab.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessMetadataTab.java @@ -15,7 +15,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.exceptions.InvalidMetadataValueException; import org.kitodo.exceptions.NoSuchMetadataFieldException; import org.kitodo.production.services.data.ImportService; @@ -37,7 +37,7 @@ public ProcessMetadataTab(CreateProcessForm createProcessForm) { * @param structure * which its Metadata are wanted to be shown */ - public ProcessFieldedMetadata initializeProcessDetails(IncludedStructuralElement structure) { + public ProcessFieldedMetadata initializeProcessDetails(LogicalDivision structure) { return ImportService.initializeProcessDetails(structure, this.createProcessForm.getRulesetManagement(), this.createProcessForm.getAcquisitionStage(), this.createProcessForm.getPriorityList()); } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessSimpleMetadata.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessSimpleMetadata.java index 586fa831ed7..c5c7600860a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessSimpleMetadata.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessSimpleMetadata.java @@ -21,13 +21,13 @@ import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface; import org.kitodo.api.dataformat.Division; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.exceptions.NoSuchMetadataFieldException; abstract class ProcessSimpleMetadata extends ProcessDetail implements Serializable { - static final List>> PARENT_CLASSES = Arrays.asList(IncludedStructuralElement.class, + static final List>> PARENT_CLASSES = Arrays.asList(LogicalDivision.class, MediaUnit.class); /** diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SearchTab.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SearchTab.java index 7e96bd8f599..aa3a5236832 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SearchTab.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SearchTab.java @@ -21,7 +21,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.beans.Project; @@ -85,7 +85,7 @@ public void copyMetadata() { try { URI metadataUri = ServiceManager.getProcessService().getMetadataFileUri(this.originalProcess); Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataUri); - IncludedStructuralElement root = workpiece.getRootElement(); + LogicalDivision root = workpiece.getLogicalStructure(); if (StringUtils.isNotBlank(root.getType())) { this.createProcessForm.getProcessDataTab().setDocType(root.getType()); } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java index 9e7e11645bb..066b5a1c339 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java @@ -31,7 +31,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.FunctionalMetadata; import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.exceptions.DAOException; @@ -79,10 +79,10 @@ public class TitleRecordLinkTab { private List possibleParentProcesses = Collections.emptyList(); /** - * Tree with the root element of the workpiece and elements indicating the + * Tree with the logical structure of the workpiece and elements indicating the * possible insertion positions. */ - private TreeNode rootElement = new DefaultTreeNode(); + private TreeNode logicalStructure = new DefaultTreeNode(); /** * The user’s search for parent processes. @@ -115,12 +115,12 @@ public TitleRecordLinkTab(CreateProcessForm createProcessForm) { } /** - * Selects a parent process and builds the tree with the root element of the + * Selects a parent process and builds the tree with the logical structure of the * selected process and the possible insertion positions. */ public void chooseParentProcess() { if (StringUtils.isBlank(chosenParentProcess)) { - rootElement = new DefaultTreeNode(); + logicalStructure = new DefaultTreeNode(); titleRecordProcess = null; } else { try { @@ -155,10 +155,10 @@ public void createInsertionPositionSelectionTree() throws DAOException, DataExce List priorityList = LanguageRange.parse(metadataLanguage.isEmpty() ? "en" : metadataLanguage); selectableInsertionPositions = new LinkedList<>(); - rootElement = new DefaultTreeNode(); - createInsertionPositionSelectionTreeRecursive("", workpiece.getRootElement(), rootElement, ruleset, + logicalStructure = new DefaultTreeNode(); + createInsertionPositionSelectionTreeRecursive("", workpiece.getLogicalStructure(), logicalStructure, ruleset, priorityList); - rootElement.setExpanded(true); + logicalStructure.setExpanded(true); if (selectableInsertionPositions.size() > 0) { selectedInsertionPosition = (String) ((LinkedList) selectableInsertionPositions).getLast() @@ -175,9 +175,9 @@ public void createInsertionPositionSelectionTree() throws DAOException, DataExce * @param positionPrefix * A string with comma-delimited specification of the levels that * have already been traversed. Initially empty. - * @param currentIncludedStructuralElement - * Included structural element for whom the tree is being - * created. Initially the root element of the workpiece. + * @param currentLogicalDivision + * Logical division for whom the tree is being created. Initially + * the logical structure of the workpiece. * @param parentNode * Parent node of the tree structure to add to. This is * initialized with a {@link DefaultTreeNode} which is not @@ -188,45 +188,45 @@ public void createInsertionPositionSelectionTree() throws DAOException, DataExce * the user’s metadata language priority list */ private void createInsertionPositionSelectionTreeRecursive(String positionPrefix, - IncludedStructuralElement currentIncludedStructuralElement, TreeNode parentNode, + LogicalDivision currentLogicalDivision, TreeNode parentNode, RulesetManagementInterface ruleset, List priorityList) throws IOException, DAOException, DataException { String type; List tooltip = Collections.emptyList(); - if (Objects.isNull(currentIncludedStructuralElement.getLink())) { - type = currentIncludedStructuralElement.getType(); + if (Objects.isNull(currentLogicalDivision.getLink())) { + type = currentLogicalDivision.getType(); } else { ProcessService processService = ServiceManager.getProcessService(); - int linkedProcessUri = processService.processIdFromUri(currentIncludedStructuralElement.getLink().getUri()); + int linkedProcessUri = processService.processIdFromUri(currentLogicalDivision.getLink().getUri()); Process linkedProcess = processService.getById(linkedProcessUri); type = processService.getBaseType(linkedProcessUri); tooltip = getToolTip(ruleset, linkedProcess); } - StructuralElementViewInterface currentIncludedStructuralElementView = ruleset.getStructuralElementView(type, + StructuralElementViewInterface currentStructuralElementView = ruleset.getStructuralElementView(type, createProcessForm.getAcquisitionStage(), priorityList); - TreeNode includedStructuralElementNode = new InsertionPositionSelectionTreeNode(parentNode, - currentIncludedStructuralElementView.getLabel(), tooltip); + TreeNode logicalDivisionNode = new InsertionPositionSelectionTreeNode(parentNode, + currentStructuralElementView.getLabel(), tooltip); - boolean linkingAllowedHere = Objects.isNull(currentIncludedStructuralElement.getLink()) - && currentIncludedStructuralElementView.getAllowedSubstructuralElements() + boolean linkingAllowedHere = Objects.isNull(currentLogicalDivision.getLink()) + && currentStructuralElementView.getAllowedSubstructuralElements() .containsKey(createProcessForm.getProcessDataTab().getDocType()); if (linkingAllowedHere) { - new InsertionPositionSelectionTreeNode(includedStructuralElementNode, selectableInsertionPositions.size()); + new InsertionPositionSelectionTreeNode(logicalDivisionNode, selectableInsertionPositions.size()); selectableInsertionPositions.add(new SelectItem(positionPrefix.concat("0"), null)); } - List children = currentIncludedStructuralElement.getChildren(); + List children = currentLogicalDivision.getChildren(); for (int index = 0; index < children.size(); index++) { createInsertionPositionSelectionTreeRecursive( positionPrefix + index + 1 + MetadataEditor.INSERTION_POSITION_SEPARATOR, children.get(index), - includedStructuralElementNode, ruleset, priorityList); + logicalDivisionNode, ruleset, priorityList); if (linkingAllowedHere) { - new InsertionPositionSelectionTreeNode(includedStructuralElementNode, + new InsertionPositionSelectionTreeNode(logicalDivisionNode, selectableInsertionPositions.size()); selectableInsertionPositions.add(new SelectItem(positionPrefix + (index + 1), null)); } @@ -251,13 +251,13 @@ private List getToolTip(RulesetManagementInterface ruleset, Process link if (!summaryKeys.isEmpty()) { Workpiece workpiece = metsService.loadWorkpiece(processService.getMetadataFileUri(linkedProcess)); - IncludedStructuralElement rootElement = workpiece.getRootElement(); + LogicalDivision logicalStructure = workpiece.getLogicalStructure(); final String metadataLanguage = ServiceManager.getUserService().getCurrentUser().getMetadataLanguage(); List priorityList = Locale.LanguageRange.parse(metadataLanguage); for (String key : summaryKeys) { - String value = MetadataEditor.getMetadataValue(rootElement, key); + String value = MetadataEditor.getMetadataValue(logicalStructure, key); if (Objects.nonNull(value)) { Optional label = ruleset.getTranslationForKey(key, priorityList); @@ -299,7 +299,7 @@ public void setChosenParentProcess(String chosenParentProcess) { * constant above, the corresponding message is displayed. */ public void searchForParentProcesses() { - rootElement = new DefaultTreeNode(); + logicalStructure = new DefaultTreeNode(); selectableInsertionPositions = Collections.emptyList(); selectedInsertionPosition = null; if (searchQuery.trim().isEmpty()) { @@ -391,13 +391,13 @@ public void setPossibleParentProcesses(List possibleParentProcesses) } /** - * Returns the tree containing the root element of the selected parent + * Returns the tree containing the logical structure of the selected parent * process and the possible insert positions. * * @return the tree structure for selecting the insertion position */ - public TreeNode getRootElement() { - return rootElement; + public TreeNode getLogicalStructure() { + return logicalStructure; } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java index caddd674cdf..fff50e4a6e3 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java @@ -38,7 +38,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.data.database.beans.Process; @@ -69,7 +69,7 @@ public class AddDocStrucTypeDialog { private InsertionPosition selectedDocStructPosition = LAST_CHILD_OF_CURRENT_ELEMENT; private int elementsToAddSpinnerValue; private String inputMetaDataValue = ""; - private LinkedList parents; + private LinkedList parents; private List addableMetadata; private String selectedMetadata = ""; private String selectFirstPageOnAddNode; @@ -142,7 +142,7 @@ public void addDocStruc(boolean preview) { * submit btn command button. */ private void addMultiDocStruc() { - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { MetadataEditor.addMultipleStructures(elementsToAddSpinnerValue, docStructAddTypeSelectionSelectedItem, dataEditor.getWorkpiece(), selectedStructure.get(), @@ -158,9 +158,9 @@ private void addMultiDocStruc() { * submit btn command button. */ private void addSingleDocStruc(boolean selectViews) { - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { - IncludedStructuralElement newStructure = MetadataEditor.addStructure(docStructAddTypeSelectionSelectedItem, + LogicalDivision newStructure = MetadataEditor.addStructure(docStructAddTypeSelectionSelectedItem, dataEditor.getWorkpiece(), selectedStructure.get(), selectedDocStructPosition, getViewsToAdd()); dataEditor.getSelectedMedia().clear(); @@ -176,7 +176,7 @@ private void addSingleDocStruc(boolean selectViews) { this.dataEditor.getStructurePanel().setSelectedLogicalNode(selectedLogicalTreeNode); this.dataEditor.getMetadataPanel().showLogical(this.dataEditor.getSelectedStructure()); } - List> selectedMedia = this.dataEditor.getSelectedMedia().stream() + List> selectedMedia = this.dataEditor.getSelectedMedia().stream() .sorted(Comparator.comparingInt(p -> p.getLeft().getOrder())) .collect(Collectors.toList()); Collections.reverse(selectedMedia); @@ -402,10 +402,10 @@ private void sortMetadataList(List itemList) { public void prepare() { elementsToAddSpinnerValue = 1; checkSelectedLogicalNode(); - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { this.parents = MetadataEditor.getAncestorsOfStructure(selectedStructure.get(), - dataEditor.getWorkpiece().getRootElement()); + dataEditor.getWorkpiece().getLogicalStructure()); prepareDocStructPositionSelectionItems(parents.isEmpty()); prepareAddableMetadataForStructure(true); } else { @@ -435,10 +435,10 @@ private void checkSelectedLogicalNode() { * currently selected position. */ public void prepareDocStructTypes() { - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { this.parents = MetadataEditor.getAncestorsOfStructure(selectedStructure.get(), - dataEditor.getWorkpiece().getRootElement()); + dataEditor.getWorkpiece().getLogicalStructure()); if (parents.isEmpty()) { docStructAddTypeSelectionItemsForParent = Collections.emptyList(); } else { @@ -557,8 +557,8 @@ private void prepareSelectPageOnAddNodeItems() { */ public void preparePreselectedViews() { preselectedViews = new ArrayList<>(); - List> selectedMedia = dataEditor.getSelectedMedia(); - for (Pair pair : selectedMedia) { + List> selectedMedia = dataEditor.getSelectedMedia(); + for (Pair pair : selectedMedia) { for (View view : pair.getValue().getViews()) { if (Objects.equals(view.getMediaUnit(), pair.getKey())) { preselectedViews.add(view); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/ChangeDocStrucTypeDialog.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/ChangeDocStrucTypeDialog.java index 3e3ac84e05d..126c8e89500 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/ChangeDocStrucTypeDialog.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/ChangeDocStrucTypeDialog.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.production.helper.Helper; import org.kitodo.production.metadata.MetadataEditor; import org.kitodo.production.services.ServiceManager; @@ -57,7 +57,7 @@ public class ChangeDocStrucTypeDialog { * Edit the doc struc. */ public void editDocStruc() { - IncludedStructuralElement selectedStructure = getSelectedIncludedStructuralElement(); + LogicalDivision selectedStructure = getSelectedLogicalStructure(); selectedStructure.setType(docStructType); dataEditor.refreshStructurePanel(); } @@ -97,7 +97,7 @@ public void setDocStructType(String docStructEditTypeSelectionSelectedItem) { */ public void prepare() { try { - IncludedStructuralElement selectedStructure = getSelectedIncludedStructuralElement(); + LogicalDivision selectedStructure = getSelectedLogicalStructure(); Map possibleTypes = findAllPossibleTypes(selectedStructure); docStructTypes.clear(); for (Entry typeOption : possibleTypes.entrySet()) { @@ -112,7 +112,7 @@ public void prepare() { } } - private IncludedStructuralElement getSelectedIncludedStructuralElement() { + private LogicalDivision getSelectedLogicalStructure() { if (dataEditor.getSelectedStructure().isPresent()) { return dataEditor.getSelectedStructure().get(); } else { @@ -121,27 +121,27 @@ private IncludedStructuralElement getSelectedIncludedStructuralElement() { } private Map findAllPossibleTypes( - IncludedStructuralElement includedStructuralElement) throws IOException { + LogicalDivision logicalDivision) throws IOException { Map possibleTypes = getAllowedChildTypesFromIncludedStructuralParentElement( - includedStructuralElement); - restrictTypesToChildElements(includedStructuralElement, possibleTypes); + logicalDivision); + restrictTypesToChildElements(logicalDivision, possibleTypes); return possibleTypes; } private Map getAllowedChildTypesFromIncludedStructuralParentElement( - IncludedStructuralElement includedStructuralElement) throws IOException { + LogicalDivision logicalDivision) throws IOException { - IncludedStructuralElement rootElement = dataEditor.getWorkpiece().getRootElement(); - if (rootElement.equals(includedStructuralElement)) { + LogicalDivision logicalStructure = dataEditor.getWorkpiece().getLogicalStructure(); + if (logicalStructure.equals(logicalDivision)) { if (Objects.isNull(dataEditor.getProcess().getParent())) { return dataEditor.getRulesetManagement().getStructuralElements(dataEditor.getPriorityList()); } else { return getAllowedChildTypesFromParentalProcess(); } } else { - LinkedList ancestors = MetadataEditor - .getAncestorsOfStructure(includedStructuralElement, rootElement); + LinkedList ancestors = MetadataEditor + .getAncestorsOfStructure(logicalDivision, logicalStructure); String parentType = ancestors.getLast().getType(); return getAllowedSubstructuralElements(parentType); } @@ -150,16 +150,16 @@ private Map getAllowedChildTypesFromIncludedStructuralParentElem private Map getAllowedChildTypesFromParentalProcess() throws IOException { URI parentMetadataUri = ServiceManager.getProcessService() .getMetadataFileUri(dataEditor.getProcess().getParent()); - IncludedStructuralElement parentRootElement = ServiceManager.getMetsService().loadWorkpiece(parentMetadataUri) - .getRootElement(); - List parentHierarchyPath = MetadataEditor - .determineIncludedStructuralElementPathToChild(parentRootElement, + LogicalDivision parentLogicalStructure = ServiceManager.getMetsService().loadWorkpiece(parentMetadataUri) + .getLogicalStructure(); + List parentHierarchyPath = MetadataEditor + .determineLogicalDivisionPathToChild(parentLogicalStructure, dataEditor.getProcess().getId()); if (parentHierarchyPath.isEmpty()) { throw new IllegalStateException("proces is not linked in parent process"); } return getAllowedSubstructuralElements( - ((LinkedList) parentHierarchyPath).getLast().getType()); + ((LinkedList) parentHierarchyPath).getLast().getType()); } private Map getAllowedSubstructuralElements(String parentType) { @@ -169,12 +169,12 @@ private Map getAllowedSubstructuralElements(String parentType) { } private void restrictTypesToChildElements( - IncludedStructuralElement includedStructuralElement, Map possibleTypes) { - if (includedStructuralElement.getChildren().isEmpty()) { + LogicalDivision logicalDivision, Map possibleTypes) { + if (logicalDivision.getChildren().isEmpty()) { return; } Set childTypes = new HashSet<>(); - for (IncludedStructuralElement child : includedStructuralElement.getChildren()) { + for (LogicalDivision child : logicalDivision.getChildren()) { childTypes.add(child.getType()); } for (Iterator> possibleTypesIterator = possibleTypes.entrySet() diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/DataEditorForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/DataEditorForm.java index 4b0e32041b3..77ee2762bb9 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/DataEditorForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/DataEditorForm.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.api.dataformat.Workpiece; @@ -165,7 +165,7 @@ public class DataEditorForm implements RulesetSetupInterface, Serializable { * This List of Pairs stores all selected physical elements and the logical elements in which the physical element was selected. * It is necessary to store the logical elements as well, because a physical element can be assigned to multiple logical elements. */ - private List> selectedMedia; + private List> selectedMedia; /** * The id of the template's task corresponding to the current task that is under edit. @@ -404,7 +404,7 @@ public String saveAndExit() { } private void initSeveralAssignments(MediaUnit mediaUnit, List severalAssignments) { - if (mediaUnit.getIncludedStructuralElements().size() > 1) { + if (mediaUnit.getLogicalDivisions().size() > 1) { severalAssignments.add(mediaUnit); } for (MediaUnit child : mediaUnit.getChildren()) { @@ -550,7 +550,7 @@ public RulesetManagementInterface getRulesetManagement() { return ruleset; } - public Optional getSelectedStructure() { + public Optional getSelectedStructure() { return structurePanel.getSelectedStructure(); } @@ -559,13 +559,13 @@ Optional getSelectedMediaUnit() { } /** - * Check if the passed IncludedStructuralElement is part of the selection. - * @param structure IncludedStructuralElement to be checked + * Check if the passed LogicalDivision is part of the selection. + * @param structure LogicalDivision to be checked * @return boolean representing selection status */ - public boolean isStripeSelected(IncludedStructuralElement structure) { - Optional selectedStructure = structurePanel.getSelectedStructure(); - return selectedStructure.filter(includedStructuralElement -> Objects.equals(structure, includedStructuralElement)).isPresent(); + public boolean isStripeSelected(LogicalDivision structure) { + Optional selectedStructure = structurePanel.getSelectedStructure(); + return selectedStructure.filter(logicalDivision -> Objects.equals(structure, logicalDivision)).isPresent(); } /** @@ -595,7 +595,7 @@ void setProcess(Process process) { * * @return value of selectedMedia */ - public List> getSelectedMedia() { + public List> getSelectedMedia() { return selectedMedia; } @@ -612,21 +612,21 @@ public boolean consecutivePagesSelected() { && selectedMedia.stream().map(Pair::getValue).distinct().count() == 1; } - void setSelectedMedia(List> media) { + void setSelectedMedia(List> media) { this.selectedMedia = media; } /** * Check if the passed MediaUnit is selected. * @param mediaUnit MediaUnit object to check for selection - * @param includedStructuralElement object to check whether the MediaUnit is selected as a child of this IncludedStructuralElement. - * A MediaUnit can be assigned to multiple IncludedStructuralElements but can be selected - * in one of these IncludedStructuralElements. + * @param logicalDivision object to check whether the MediaUnit is selected as a child of this LogicalDivision. + * A MediaUnit can be assigned to multiple logical divisionss but can be selected + * in one of these LogicalDivisions. * @return boolean whether the MediaUnit is selected at the specified position */ - public boolean isSelected(MediaUnit mediaUnit, IncludedStructuralElement includedStructuralElement) { - if (Objects.nonNull(mediaUnit) && Objects.nonNull(includedStructuralElement)) { - return selectedMedia.contains(new ImmutablePair<>(mediaUnit, includedStructuralElement)); + public boolean isSelected(MediaUnit mediaUnit, LogicalDivision logicalDivision) { + if (Objects.nonNull(mediaUnit) && Objects.nonNull(logicalDivision)) { + return selectedMedia.contains(new ImmutablePair<>(mediaUnit, logicalDivision)); } return false; } @@ -638,17 +638,17 @@ void switchStructure(Object treeNodeData, boolean updateGalleryAndPhysicalTree) logger.info(e.getLocalizedMessage(), e); } - Optional selectedStructure = structurePanel.getSelectedStructure(); + Optional selectedStructure = structurePanel.getSelectedStructure(); metadataPanel.showLogical(selectedStructure); if (treeNodeData instanceof StructureTreeNode) { StructureTreeNode structureTreeNode = (StructureTreeNode) treeNodeData; if (Objects.nonNull(structureTreeNode.getDataObject())) { - if (structureTreeNode.getDataObject() instanceof IncludedStructuralElement + if (structureTreeNode.getDataObject() instanceof LogicalDivision && selectedStructure.isPresent()) { // Logical structure element selected if (structurePanel.isSeparateMedia()) { - IncludedStructuralElement structuralElement = selectedStructure.get(); + LogicalDivision structuralElement = selectedStructure.get(); if (!structuralElement.getViews().isEmpty()) { ArrayList views = new ArrayList<>(structuralElement.getViews()); if (Objects.nonNull(views.get(0)) && updateGalleryAndPhysicalTree) { @@ -707,42 +707,42 @@ private void updatePhysicalStructureTree(View view) { private void updateGallery(View view) { MediaUnit mediaUnit = view.getMediaUnit(); if (Objects.nonNull(mediaUnit)) { - galleryPanel.updateSelection(mediaUnit, structurePanel.getPageStructure(view, workpiece.getRootElement())); + galleryPanel.updateSelection(mediaUnit, structurePanel.getPageStructure(view, workpiece.getLogicalStructure())); } } - void assignView(IncludedStructuralElement includedStructuralElement, View view, Integer index) { - if (Objects.nonNull(index) && index >= 0 && index < includedStructuralElement.getViews().size()) { - includedStructuralElement.getViews().add(index, view); + void assignView(LogicalDivision logicalDivision, View view, Integer index) { + if (Objects.nonNull(index) && index >= 0 && index < logicalDivision.getViews().size()) { + logicalDivision.getViews().add(index, view); } else { - includedStructuralElement.getViews().add(view); + logicalDivision.getViews().add(view); } - view.getMediaUnit().getIncludedStructuralElements().add(includedStructuralElement); + view.getMediaUnit().getLogicalDivisions().add(logicalDivision); } - void unassignView(IncludedStructuralElement includedStructuralElement, View view, boolean removeLast) { + void unassignView(LogicalDivision logicalDivision, View view, boolean removeLast) { // if View was moved within one element, we need to distinguish two possible directions it could have been moved if (removeLast) { - includedStructuralElement.getViews().removeLastOccurrence(view); + logicalDivision.getViews().removeLastOccurrence(view); } else { - includedStructuralElement.getViews().removeFirstOccurrence(view); + logicalDivision.getViews().removeFirstOccurrence(view); } - view.getMediaUnit().getIncludedStructuralElements().remove(includedStructuralElement); + view.getMediaUnit().getLogicalDivisions().remove(logicalDivision); } /** * Retrieve and return 'title' value of given Object 'dataObject' if Object is instance of - * 'IncludedStructuralElement' and if it does have a title. Uses a configurable list of metadata keys to determine + * 'LogicalDivision' and if it does have a title. Uses a configurable list of metadata keys to determine * which metadata keys should be considered. * Return empty string otherwise. * * @param dataObject - * StructureTreeNode containing the IncludedStructuralElement whose title is returned - * @return 'title' value of the IncludedStructuralElement contained in the given StructureTreeNode 'treeNode' + * StructureTreeNode containing the LogicalDivision whose title is returned + * @return 'title' value of the LogicalDivision contained in the given StructureTreeNode 'treeNode' */ public String getStructureElementTitle(Object dataObject) { - if (dataObject instanceof IncludedStructuralElement) { - return DataEditorService.getTitleValue((IncludedStructuralElement) dataObject); + if (dataObject instanceof LogicalDivision) { + return DataEditorService.getTitleValue((LogicalDivision) dataObject); } return ""; } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/EditPagesDialog.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/EditPagesDialog.java index 21afb1ae9ef..e5e3cdb134a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/EditPagesDialog.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/EditPagesDialog.java @@ -22,7 +22,7 @@ import javax.faces.model.SelectItem; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.production.metadata.MetadataEditor; @@ -83,7 +83,7 @@ public class EditPagesDialog { * button. */ public void addPage() { - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { for (View viewToAdd : getViewsToAdd(paginationSelectionSelectedItems)) { dataEditor.assignView(selectedStructure.get(), viewToAdd, -1); @@ -216,7 +216,7 @@ private List getViewsToAdd(List pages) { * btn command button. */ public void setPageStartAndEnd() { - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { for (View viewToAdd : getViewsToAdd(selectFirstPageSelectedItem, selectLastPageSelectedItem)) { dataEditor.assignView(selectedStructure.get(), viewToAdd, -1); @@ -244,7 +244,7 @@ void prepare() { Integer id = i; SelectItem selectItem = new SelectItem(id, label); selectPageItems.add(selectItem); - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); boolean assigned = selectedStructure.isPresent() && selectedStructure.get().getViews().contains(view); (assigned ? paginationSubSelectionItems : paginationSelectionItems).add(selectItem); @@ -267,7 +267,7 @@ void prepare() { * button. */ public void removePage() { - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { for (View viewToRemove : getViewsToAdd(paginationSubSelectionSelectedItems)) { dataEditor.unassignView(selectedStructure.get(), viewToRemove, false); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryMediaContent.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryMediaContent.java index 46b7733e514..896d2ef0312 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryMediaContent.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryMediaContent.java @@ -193,13 +193,13 @@ public View getView() { } /** - * Check if the GalleryMediaContent's MediaUnit is assigned to several IncludedStructuralElements. + * Check if the GalleryMediaContent's MediaUnit is assigned to several LogicalDivisions. * * @return {@code true} when the MediaUnit is assigned to more than one logical element */ public boolean isAssignedSeveralTimes() { if (Objects.nonNull(view) && Objects.nonNull(view.getMediaUnit())) { - return view.getMediaUnit().getIncludedStructuralElements().size() > 1; + return view.getMediaUnit().getLogicalDivisions().size() > 1; } return false; } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java index 1565975d30a..f194edaa612 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.MediaVariant; import org.kitodo.api.dataformat.View; @@ -124,7 +124,7 @@ public String getGalleryViewMode() { * * @return value of lastSelection */ - public Pair getLastSelection() { + public Pair getLastSelection() { if (dataEditor.getSelectedMedia().size() > 0) { return dataEditor.getSelectedMedia().get(dataEditor.getSelectedMedia().size() - 1); } else { @@ -217,8 +217,8 @@ public void onPageDrop(DragDropEvent event) { GalleryStripe toStripe = stripes.get(toStripeIndex); // move views - List> viewsToBeMoved = new ArrayList<>(); - for (Pair selectedElement : dataEditor.getSelectedMedia()) { + List> viewsToBeMoved = new ArrayList<>(); + for (Pair selectedElement : dataEditor.getSelectedMedia()) { for (View view : selectedElement.getValue().getViews()) { if (Objects.equals(view.getMediaUnit(), selectedElement.getKey())) { viewsToBeMoved.add(new ImmutablePair<>(view, selectedElement.getValue())); @@ -266,7 +266,7 @@ private int getDropStripeIndex(DragDropEvent event) { } else if (dropUnstructuredMediaStripeMatcher.matches() || dropUnstructuredMediaLastAreaMatcher.matches() || dropUnstructuredMediaAreaMatcher.matches()) { - // First (0) stripe represents logical root element (unstructured media) + // First (0) stripe represents logical structure (unstructured media) return 0; } else { return -1; @@ -291,15 +291,15 @@ private int getMediaIndex(DragDropEvent event) { } } - private void updateData(GalleryStripe toStripe, List> viewsToBeMoved, int toMediaIndex) { + private void updateData(GalleryStripe toStripe, List> viewsToBeMoved, int toMediaIndex) { dataEditor.getStructurePanel().changeLogicalOrderFields(toStripe.getStructure(), viewsToBeMoved, toMediaIndex); dataEditor.getStructurePanel().reorderMediaUnits(toStripe.getStructure(), viewsToBeMoved, toMediaIndex); dataEditor.getStructurePanel().moveViews(toStripe.getStructure(), viewsToBeMoved, toMediaIndex); dataEditor.getStructurePanel().changePhysicalOrderFields(toStripe.getStructure(), viewsToBeMoved); } - private void updateAffectedStripes(GalleryStripe toStripe, List> viewsToBeMoved) { - for (Pair viewToBeMoved : viewsToBeMoved) { + private void updateAffectedStripes(GalleryStripe toStripe, List> viewsToBeMoved) { + for (Pair viewToBeMoved : viewsToBeMoved) { GalleryStripe fromStripe = getGalleryStripe(viewToBeMoved.getValue()); if (Objects.nonNull(fromStripe)) { fromStripe.getMedias().clear(); @@ -322,7 +322,7 @@ private void updateAffectedStripes(GalleryStripe toStripe, List 0) { // Update structured view @@ -414,7 +414,7 @@ void show() { } } - addStripesRecursive(dataEditor.getWorkpiece().getRootElement()); + addStripesRecursive(dataEditor.getWorkpiece().getLogicalStructure()); int imagesInStructuredView = stripes.parallelStream().mapToInt(stripe -> stripe.getMedias().size()).sum(); if (imagesInStructuredView > 200) { logger.warn("Number of images in structured view: {}", imagesInStructuredView); @@ -423,7 +423,7 @@ void show() { void updateStripes() { stripes = new ArrayList<>(); - addStripesRecursive(dataEditor.getWorkpiece().getRootElement()); + addStripesRecursive(dataEditor.getWorkpiece().getLogicalStructure()); } private static MediaVariant getMediaVariant(Folder folderSettings, List mediaUnits) { @@ -441,7 +441,7 @@ private static MediaVariant getMediaVariant(Folder folderSettings, List> getMediaWithinRange(Pair first, - Pair last) { + private List> getMediaWithinRange(Pair first, + Pair last) { // Pairs of stripe index and media index Pair firstIndices = getIndices(first.getKey(), first.getValue()); Pair lastIndices = getIndices(last.getKey(), last.getValue()); @@ -551,7 +551,7 @@ private List> getMediaWithinRange(Pai List stripesWithinRange = new LinkedList<>(); /* Stripe with index 0 represents "unstructured media". - This stripe is displayed last, but is actually the root element (first stripe). */ + This stripe is displayed last, but is actually the logical structure (first stripe). */ if (Objects.equals(firstIndices.getKey(), lastIndices.getKey())) { stripesWithinRange.add(stripes.get(firstIndices.getKey())); } else if (lastIndices.getKey() == 0) { @@ -582,20 +582,20 @@ This stripe is displayed last, but is actually the root element (first stripe). } /** - * Get a List of all MediaUnits and the IncludedStructuralElements they are assigned to + * Get a List of all MediaUnits and the LogicalDivisions they are assigned to * which are displayed between two selected MediaUnits. This method selected the MediaUnits between and including the two indices. * @param firstIndices * First selected MediaUnit. - * A Pair of indices of the MediaUnit and the IncludedStructuralElement to which the MediaUnit is assigned. + * A Pair of indices of the MediaUnit and the LogicalDivision to which the MediaUnit is assigned. * @param lastIndices * Last selected MediaUnit. - * A Pair of indices of the MediaUnit and the Included StructuralElement to which the MediaUnit is assigned. + * A Pair of indices of the MediaUnit and the Logical Division to which the MediaUnit is assigned. * @param galleryStripes * A List of GalleryStripes which contain the two selected MediaUnits and all in between * @return * A List of all selected MediaUnits */ - private List> getMediaWithinRangeFromSelectedStripes( + private List> getMediaWithinRangeFromSelectedStripes( Pair firstIndices, Pair lastIndices, List galleryStripes) { boolean countDown = false; @@ -619,9 +619,9 @@ private List> getMediaWithinRangeFrom } } - private List> getMediaForwards(Integer firstIndex, Integer lastIndex, + private List> getMediaForwards(Integer firstIndex, Integer lastIndex, List galleryStripes) { - List> mediaWithinRange = new LinkedList<>(); + List> mediaWithinRange = new LinkedList<>(); GalleryStripe firstStripe = galleryStripes.get(0); if (galleryStripes.size() == 1) { @@ -652,9 +652,9 @@ private List> getMediaForwards(Intege return mediaWithinRange; } - private List> getMediaBackwards(Integer firstIndex, Integer lastIndex, + private List> getMediaBackwards(Integer firstIndex, Integer lastIndex, List galleryStripes) { - List> mediaWithinRange = new LinkedList<>(); + List> mediaWithinRange = new LinkedList<>(); GalleryStripe firstStripe = galleryStripes.get(0); if (galleryStripes.size() == 1) { @@ -685,7 +685,7 @@ private List> getMediaBackwards(Integ return mediaWithinRange; } - private Pair getIndices(MediaUnit mediaUnit, IncludedStructuralElement structuralElement) { + private Pair getIndices(MediaUnit mediaUnit, LogicalDivision structuralElement) { for (GalleryStripe galleryStripe : stripes) { if (Objects.equals(galleryStripe.getStructure(), structuralElement)) { for (GalleryMediaContent media : galleryStripe.getMedias()) { @@ -756,9 +756,9 @@ private void selectMedia(String mediaUnitOrder, String stripeIndex, String selec } private void selectStructure(String stripeIndex) { - IncludedStructuralElement includedStructuralElement = stripes.get(Integer.parseInt(stripeIndex)).getStructure(); + LogicalDivision logicalDivision = stripes.get(Integer.parseInt(stripeIndex)).getStructure(); dataEditor.getSelectedMedia().clear(); - dataEditor.getStructurePanel().updateLogicalNodeSelection(includedStructuralElement); + dataEditor.getStructurePanel().updateLogicalNodeSelection(logicalDivision); PrimeFaces.current().executeScript("scrollToSelectedTreeNode()"); } @@ -845,8 +845,8 @@ private void rangeSelect(GalleryMediaContent currentSelection, GalleryStripe par return; } - Pair firstSelectedMediaPair = dataEditor.getSelectedMedia().get(0); - Pair lastSelectedMediaPair = + Pair firstSelectedMediaPair = dataEditor.getSelectedMedia().get(0); + Pair lastSelectedMediaPair = new ImmutablePair<>(currentSelection.getView().getMediaUnit(), parentStripe.getStructure()); dataEditor.getSelectedMedia().clear(); @@ -854,7 +854,7 @@ private void rangeSelect(GalleryMediaContent currentSelection, GalleryStripe par } private void multiSelect(GalleryMediaContent currentSelection, GalleryStripe parentStripe) { - Pair selectedMediaPair = new ImmutablePair<>( + Pair selectedMediaPair = new ImmutablePair<>( currentSelection.getView().getMediaUnit(), parentStripe.getStructure()); if (dataEditor.getSelectedMedia().contains(selectedMediaPair)) { @@ -868,7 +868,7 @@ private void multiSelect(GalleryMediaContent currentSelection, GalleryStripe par /** * Get the index of this GalleryMediaContent's MediaUnit out of all MediaUnits - * which are assigned to more than one IncludedStructuralElement. + * which are assigned to more than one LogicalDivision. * * @param galleryMediaContent object to find the index for * @return index of the GalleryMediaContent's MediaUnit if present in the List of several assignments, or -1 if not present in the list. diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryStripe.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryStripe.java index 5eaba5a8236..c4073f020fd 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryStripe.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryStripe.java @@ -16,7 +16,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; /** * One media stripe in the structured gallery view. @@ -35,7 +35,7 @@ public class GalleryStripe { /** * Structure this gallery stripe is related to. */ - private final IncludedStructuralElement structure; + private final LogicalDivision structure; /** * Creates a new gallery stripe. @@ -45,7 +45,7 @@ public class GalleryStripe { * @param structure * structure this gallery stripe is related to */ - GalleryStripe(GalleryPanel panel, IncludedStructuralElement structure) { + GalleryStripe(GalleryPanel panel, LogicalDivision structure) { this.structure = structure; this.label = getLabel(panel, structure); } @@ -68,7 +68,7 @@ public String getLabel() { * structure whose label is to return * @return the label */ - private String getLabel(GalleryPanel panel, IncludedStructuralElement structure) { + private String getLabel(GalleryPanel panel, LogicalDivision structure) { RulesetManagementInterface ruleset = panel.getRuleset(); StructuralElementViewInterface divisionView = ruleset.getStructuralElementView(structure.getType(), panel.getAcquisitionStage(), panel.getPriorityList()); @@ -89,7 +89,7 @@ public List getMedias() { * * @return structure */ - public IncludedStructuralElement getStructure() { + public LogicalDivision getStructure() { return structure; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/MetadataPanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/MetadataPanel.java index 856c6bbc4d6..75b5f63f49a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/MetadataPanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/MetadataPanel.java @@ -21,7 +21,7 @@ import org.apache.logging.log4j.Logger; import org.kitodo.api.Metadata; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.exceptions.InvalidMetadataValueException; import org.kitodo.exceptions.NoSuchMetadataFieldException; @@ -143,7 +143,7 @@ public ProcessFieldedMetadata getPhysicalMetadataTable() { return physicalMetadataTable; } - void showLogical(Optional optionalStructure) { + void showLogical(Optional optionalStructure) { if (optionalStructure.isPresent()) { StructuralElementViewInterface divisionView = dataEditorForm.getRulesetManagement().getStructuralElementView( optionalStructure.get().getType(), dataEditorForm.getAcquisitionStage(), dataEditorForm.getPriorityList()); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java index 1eaad147faa..3c4963723b2 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java @@ -22,7 +22,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.config.ConfigCore; @@ -160,13 +160,13 @@ public void setPaginationSelectionSelectedItems(List paginationSelectio this.paginationSelectionSelectedItems.size() - 1 ), lastItemIndex)) { dataEditor.getStructurePanel().updateNodeSelection( dataEditor.getGalleryPanel().getGalleryMediaContent(mediaUnits.get(lastItemIndex)), - mediaUnits.get(lastItemIndex).getIncludedStructuralElements().get(0)); + mediaUnits.get(lastItemIndex).getLogicalDivisions().get(0)); updateMetadataPanel(); } dataEditor.getSelectedMedia().clear(); for (int i : paginationSelectionSelectedItems) { - for (IncludedStructuralElement includedStructuralElement : mediaUnits.get(i).getIncludedStructuralElements()) { - dataEditor.getSelectedMedia().add(new ImmutablePair<>(mediaUnits.get(i), includedStructuralElement)); + for (LogicalDivision logicalDivision : mediaUnits.get(i).getLogicalDivisions()) { + dataEditor.getSelectedMedia().add(new ImmutablePair<>(mediaUnits.get(i), logicalDivision)); } } this.paginationSelectionSelectedItems = paginationSelectionSelectedItems; @@ -321,7 +321,7 @@ private void preparePaginationSelectionItems() { public void preparePaginationSelectionSelectedItems() { paginationSelectionSelectedItems = new ArrayList<>(); List mediaUnits = dataEditor.getWorkpiece().getAllMediaUnitChildrenFilteredByTypePageAndSorted(); - for (Pair selectedElement : dataEditor.getSelectedMedia()) { + for (Pair selectedElement : dataEditor.getSelectedMedia()) { for (int i = 0; i < mediaUnits.size(); i++) { MediaUnit mediaUnit = mediaUnits.get(i); if (mediaUnit.equals(selectedElement.getKey())) { diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java index 9613482f5e9..c4ed2b49b17 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructurePanel.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.data.database.beans.Process; @@ -71,7 +71,7 @@ public class StructurePanel implements Serializable { private TreeNode selectedPhysicalNode; - private IncludedStructuralElement structure; + private LogicalDivision structure; /** * The logical structure tree of the edited document. @@ -86,7 +86,7 @@ public class StructurePanel implements Serializable { /** * HashMap containing the current expansion states of all TreeNodes in the logical structure tree. */ - private HashMap previousExpansionStatesLogicalTree; + private HashMap previousExpansionStatesLogicalTree; /** * HashMap containing the current expansion states of all TreeNodes in the physical structure tree. @@ -94,7 +94,7 @@ public class StructurePanel implements Serializable { private HashMap previousExpansionStatesPhysicalTree; /** - * List of all mediaUnits assigned to multiple IncludedStructuralElements. + * List of all mediaUnits assigned to multiple LogicalDivisions. */ private List severalAssignments = new LinkedList<>(); @@ -140,8 +140,8 @@ void deleteSelectedStructure() { */ return; } - IncludedStructuralElement selectedStructure = getSelectedStructure().get(); - LinkedList ancestors = MetadataEditor.getAncestorsOfStructure(selectedStructure, structure); + LogicalDivision selectedStructure = getSelectedStructure().get(); + LinkedList ancestors = MetadataEditor.getAncestorsOfStructure(selectedStructure, structure); if (ancestors.isEmpty()) { // The selected element is the root node of the tree. return; @@ -150,17 +150,17 @@ void deleteSelectedStructure() { Collection subViews = new ArrayList<>(); getAllSubViews(selectedStructure, subViews); - List multipleViews = subViews.stream().filter(v -> v.getMediaUnit().getIncludedStructuralElements().size() > 1) + List multipleViews = subViews.stream().filter(v -> v.getMediaUnit().getLogicalDivisions().size() > 1) .collect(Collectors.toList()); for (View view : multipleViews) { dataEditor.unassignView(selectedStructure, view, selectedStructure.getViews().getLast().equals(view)); - if (view.getMediaUnit().getIncludedStructuralElements().size() <= 1) { + if (view.getMediaUnit().getLogicalDivisions().size() <= 1) { severalAssignments.remove(view.getMediaUnit()); } } subViews.removeAll(multipleViews); - IncludedStructuralElement parent = ancestors.getLast(); + LogicalDivision parent = ancestors.getLast(); parent.getViews().addAll(subViews); parent.getViews().sort(Comparator.comparingInt(v -> v.getMediaUnit().getOrder())); @@ -170,11 +170,11 @@ void deleteSelectedStructure() { dataEditor.getGalleryPanel().updateStripes(); } - private void getAllSubViews(IncludedStructuralElement selectedStructure, Collection views) { + private void getAllSubViews(LogicalDivision selectedStructure, Collection views) { if (Objects.nonNull(selectedStructure.getViews())) { views.addAll(selectedStructure.getViews()); } - for (IncludedStructuralElement child : selectedStructure.getChildren()) { + for (LogicalDivision child : selectedStructure.getChildren()) { getAllSubViews(child, views); } } @@ -238,10 +238,10 @@ public void setSelectedPhysicalNode(TreeNode selectedPhysicalNode) { } } - Optional getSelectedStructure() { + Optional getSelectedStructure() { StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData(); Object dataObject = structureTreeNode.getDataObject(); - return Optional.ofNullable(dataObject instanceof IncludedStructuralElement ? (IncludedStructuralElement) dataObject : null); + return Optional.ofNullable(dataObject instanceof LogicalDivision ? (LogicalDivision) dataObject : null); } Optional getSelectedMediaUnit() { @@ -319,7 +319,7 @@ void preserve() throws UnknownTreeNodeDataException { /** * Updates the live structure of the workpiece with the current members of * the structure tree in their given order. The live structure of the - * workpiece which is stored in the root element of the structure tree. + * workpiece which is stored in the logical structure of the structure tree. */ private void preserveLogical() { if (!this.logicalTree.getChildren().isEmpty()) { @@ -334,17 +334,17 @@ private void preserveLogical() { * aren’t structures, {@code null} is returned to skip them on the level * above. */ - private static IncludedStructuralElement preserveLogicalRecursive(TreeNode treeNode) { + private static LogicalDivision preserveLogicalRecursive(TreeNode treeNode) { StructureTreeNode structureTreeNode = (StructureTreeNode) treeNode.getData(); - if (Objects.isNull(structureTreeNode) || !(structureTreeNode.getDataObject() instanceof IncludedStructuralElement)) { + if (Objects.isNull(structureTreeNode) || !(structureTreeNode.getDataObject() instanceof LogicalDivision)) { return null; } - IncludedStructuralElement structure = (IncludedStructuralElement) structureTreeNode.getDataObject(); + LogicalDivision structure = (LogicalDivision) structureTreeNode.getDataObject(); - List childrenLive = structure.getChildren(); + List childrenLive = structure.getChildren(); childrenLive.clear(); for (TreeNode child : treeNode.getChildren()) { - IncludedStructuralElement maybeChildStructure = preserveLogicalRecursive(child); + LogicalDivision maybeChildStructure = preserveLogicalRecursive(child); if (Objects.nonNull(maybeChildStructure)) { childrenLive.add(maybeChildStructure); } @@ -379,7 +379,7 @@ private static MediaUnit preservePhysicalRecursive(TreeNode treeNode) { /** * Loads the tree(s) into the panel and sets the selected element to the - * root element of the structure tree. + * logical structure of the structure tree. * * @param keepSelection * if true, keeps the currently selected node(s) @@ -412,10 +412,10 @@ public void show(boolean keepSelection) { /** * Loads the tree(s) into the panel and sets the selected element to the - * root element of the structure tree. + * logical structure of the structure tree. */ public void show() { - this.structure = dataEditor.getWorkpiece().getRootElement(); + this.structure = dataEditor.getWorkpiece().getLogicalStructure(); this.previousExpansionStatesLogicalTree = getLogicalTreeNodeExpansionStates(this.logicalTree); this.logicalTree = buildStructureTree(); @@ -459,7 +459,7 @@ private DefaultTreeNode buildStructureTree() { return invisibleRootNode; } - private Collection buildStructureTreeRecursively(IncludedStructuralElement structure, TreeNode result) { + private Collection buildStructureTreeRecursively(LogicalDivision structure, TreeNode result) { StructureTreeNode node; if (Objects.isNull(structure.getLink())) { StructuralElementViewInterface divisionView = dataEditor.getRulesetManagement().getStructuralElementView( @@ -495,7 +495,7 @@ private Collection buildStructureTreeRecursively(IncludedStructuralElement Set viewsShowingOnAChild = new HashSet<>(); if (this.isSeparateMedia()) { - for (IncludedStructuralElement child : structure.getChildren()) { + for (LogicalDivision child : structure.getChildren()) { viewsShowingOnAChild.addAll(buildStructureTreeRecursively(child, parent)); } } else { @@ -506,21 +506,21 @@ private Collection buildStructureTreeRecursively(IncludedStructuralElement } /** - * This method appends IncludedStructuralElement children and assigned views while considering the ORDER attribute to create the + * This method appends LogicalDivision children and assigned views while considering the ORDER attribute to create the * combined tree with the correct order of logical and physical elements. - * @param children List of IncludedStructuralElements which are children of the element represented by the DefaultTreeNode parent + * @param children List of LogicalDivisions which are children of the element represented by the DefaultTreeNode parent * @param views List of Views assigned to the element represented by the DefaultTreeNode parent * @param parent DefaultTreeNode representing the logical element where all new elements should be appended * @param viewsShowingOnAChild Collection of Views displayed in the combined tree */ - private void orderChildrenAndViews(List children, List views, DefaultTreeNode parent, + private void orderChildrenAndViews(List children, List views, DefaultTreeNode parent, Set viewsShowingOnAChild) { - List temporaryChildren = new ArrayList<>(children); + List temporaryChildren = new ArrayList<>(children); List temporaryViews = new ArrayList<>(views); temporaryChildren.removeAll(Collections.singletonList(null)); temporaryViews.removeAll(Collections.singletonList(null)); while (temporaryChildren.size() > 0 || temporaryViews.size() > 0) { - IncludedStructuralElement temporaryChild = null; + LogicalDivision temporaryChild = null; View temporaryView = null; if (temporaryChildren.size() > 0) { @@ -604,7 +604,7 @@ private DefaultTreeNode addTreeNode(String label, boolean undefined, boolean lin DefaultTreeNode node = new DefaultTreeNode(new StructureTreeNode(label, undefined, linked, dataObject), parent); if (dataObject instanceof MediaUnit && physicalNodeStateUnknown(this.previousExpansionStatesPhysicalTree, node) - || dataObject instanceof IncludedStructuralElement + || dataObject instanceof LogicalDivision && logicalNodeStateUnknown(this.previousExpansionStatesLogicalTree, node)) { node.setExpanded(true); } @@ -634,11 +634,11 @@ private void addParentLinksRecursive(Process child, DefaultTreeNode tree) { addParentLinksRecursive(parent, tree); URI uri = ServiceManager.getProcessService().getMetadataFileUri(parent); try { - IncludedStructuralElement rootElement = ServiceManager.getMetsService().loadWorkpiece(uri).getRootElement(); - List includedStructuralElementList - = MetadataEditor.determineIncludedStructuralElementPathToChild(rootElement, child.getId()); + LogicalDivision logicalStructure = ServiceManager.getMetsService().loadWorkpiece(uri).getLogicalStructure(); + List logicalDivisionList + = MetadataEditor.determineLogicalDivisionPathToChild(logicalStructure, child.getId()); DefaultTreeNode parentNode = tree; - if (includedStructuralElementList.isEmpty()) { + if (logicalDivisionList.isEmpty()) { /* * Error case: The child is not linked in the parent process. * Show the process title of the parent process and a warning @@ -650,11 +650,11 @@ private void addParentLinksRecursive(Process child, DefaultTreeNode tree) { * Default case: Show the path through the parent process to the * linked child */ - for (IncludedStructuralElement includedStructuralElement : includedStructuralElementList) { - if (Objects.isNull(includedStructuralElement.getType())) { + for (LogicalDivision logicalDivision : logicalDivisionList) { + if (Objects.isNull(logicalDivision.getType())) { break; } else { - parentNode = addTreeNode(includedStructuralElement.getType(), true, null, parentNode); + parentNode = addTreeNode(logicalDivision.getType(), true, null, parentNode); parentNode.setExpanded(true); } } @@ -742,7 +742,7 @@ public void treePhysicalSelect(NodeSelectEvent event) { } } - void updateNodeSelection(GalleryMediaContent galleryMediaContent, IncludedStructuralElement structure) { + void updateNodeSelection(GalleryMediaContent galleryMediaContent, LogicalDivision structure) { this.updateLogicalNodeSelection(galleryMediaContent, structure); this.updatePhysicalNodeSelection(galleryMediaContent); } @@ -769,7 +769,7 @@ void updatePhysicalNodeSelection(GalleryMediaContent galleryMediaContent) { } } - void updateLogicalNodeSelection(GalleryMediaContent galleryMediaContent, IncludedStructuralElement structure) { + void updateLogicalNodeSelection(GalleryMediaContent galleryMediaContent, LogicalDivision structure) { if (Objects.nonNull(previouslySelectedLogicalNode)) { previouslySelectedLogicalNode.setSelected(false); } @@ -800,7 +800,7 @@ void updateLogicalNodeSelection(GalleryMediaContent galleryMediaContent, Include } } - void updateLogicalNodeSelection(IncludedStructuralElement includedStructuralElement) { + void updateLogicalNodeSelection(LogicalDivision logicalDivision) { if (Objects.nonNull(previouslySelectedLogicalNode)) { previouslySelectedLogicalNode.setSelected(false); } @@ -808,7 +808,7 @@ void updateLogicalNodeSelection(IncludedStructuralElement includedStructuralElem selectedLogicalNode.setSelected(false); } if (Objects.nonNull(logicalTree)) { - TreeNode selectedTreeNode = updateLogicalNodeSelectionRecursive(includedStructuralElement, logicalTree); + TreeNode selectedTreeNode = updateLogicalNodeSelectionRecursive(logicalDivision, logicalTree); if (Objects.nonNull(selectedTreeNode)) { setSelectedLogicalNode(selectedTreeNode); try { @@ -824,11 +824,11 @@ void updateLogicalNodeSelection(IncludedStructuralElement includedStructuralElem /** * Update the node selection in logical tree. - * @param structure the IncludedStructuralElement to be selected as a TreeNode + * @param structure the LogicalDivision to be selected as a TreeNode * @param treeNode the logical structure tree * @return the TreeNode that will be selected */ - public TreeNode updateLogicalNodeSelectionRecursive(IncludedStructuralElement structure, TreeNode treeNode) { + public TreeNode updateLogicalNodeSelectionRecursive(LogicalDivision structure, TreeNode treeNode) { TreeNode matchingTreeNode = null; for (TreeNode currentTreeNode : treeNode.getChildren()) { if (treeNodeMatchesStructure(structure, currentTreeNode)) { @@ -864,7 +864,7 @@ private TreeNode updatePhysicalNodeSelectionRecursive(GalleryMediaContent galler return matchingTreeNode; } - private TreeNode updatePhysSelectionInLogTreeRecursive(MediaUnit selectedMediaUnit, IncludedStructuralElement parentElement, + private TreeNode updatePhysSelectionInLogTreeRecursive(MediaUnit selectedMediaUnit, LogicalDivision parentElement, TreeNode treeNode) { TreeNode matchingTreeNode = null; for (TreeNode currentTreeNode : treeNode.getChildren()) { @@ -904,10 +904,10 @@ private boolean treeNodeMatchesGalleryMediaContent(GalleryMediaContent galleryMe return false; } - private boolean treeNodeMatchesStructure(IncludedStructuralElement structure, TreeNode treeNode) { + private boolean treeNodeMatchesStructure(LogicalDivision structure, TreeNode treeNode) { if (Objects.nonNull(treeNode) && treeNode.getData() instanceof StructureTreeNode) { StructureTreeNode structureTreeNode = (StructureTreeNode) treeNode.getData(); - if (structureTreeNode.getDataObject() instanceof IncludedStructuralElement) { + if (structureTreeNode.getDataObject() instanceof LogicalDivision) { return Objects.equals(structureTreeNode.getDataObject(), structure); } } @@ -958,14 +958,14 @@ public void onDragDrop(TreeDragDropEvent event) { try { StructureTreeNode dropNode = (StructureTreeNode) dropNodeObject; StructureTreeNode dragNode = (StructureTreeNode) dragNodeObject; - if (dragNode.getDataObject() instanceof IncludedStructuralElement - && dropNode.getDataObject() instanceof IncludedStructuralElement) { + if (dragNode.getDataObject() instanceof LogicalDivision + && dropNode.getDataObject() instanceof LogicalDivision) { checkLogicalDragDrop(dragNode, dropNode); } else if (dragNode.getDataObject() instanceof MediaUnit && dropNode.getDataObject() instanceof MediaUnit) { checkPhysicalDragDrop(dragNode, dropNode); } else if (dragNode.getDataObject() instanceof View - && dropNode.getDataObject() instanceof IncludedStructuralElement) { + && dropNode.getDataObject() instanceof LogicalDivision) { movePageNode(event, dropNode, dragNode); } else { Helper.setErrorMessage(Helper.getTranslation("dataEditor.dragnDropError", Arrays.asList( @@ -978,15 +978,15 @@ public void onDragDrop(TreeDragDropEvent event) { } /** - * Determine the IncludedStructuralElement to which the given View is assigned. + * Determine the LogicalDivision to which the given View is assigned. * * @param view - * View for which the IncludedStructuralElement is determined - * @return the IncludedStructuralElement to which the given View is assigned + * View for which the LogicalDivision is determined + * @return the LogicalDivision to which the given View is assigned */ - IncludedStructuralElement getPageStructure(View view, IncludedStructuralElement parent) { - IncludedStructuralElement resultElement = null; - for (IncludedStructuralElement child : parent.getChildren()) { + LogicalDivision getPageStructure(View view, LogicalDivision parent) { + LogicalDivision resultElement = null; + for (LogicalDivision child : parent.getChildren()) { if (child.getViews().contains(view)) { resultElement = child; } else { @@ -1014,7 +1014,7 @@ private void movePageNode(TreeDragDropEvent event, StructureTreeNode dropNode, S TreeNode dragParent = event.getDragNode().getParent(); if (dragParent.getData() instanceof StructureTreeNode) { StructureTreeNode dragParentTreeNode = (StructureTreeNode) dragParent.getData(); - if (dragParentTreeNode.getDataObject() instanceof IncludedStructuralElement) { + if (dragParentTreeNode.getDataObject() instanceof LogicalDivision) { // FIXME waiting for PrimeFaces' tree drop index bug to be fixed. // Until fixed dropping nodes onto other nodes will produce random drop indices. preserveLogicalAndPhysical(); @@ -1041,8 +1041,8 @@ private void movePageNode(TreeDragDropEvent event, StructureTreeNode dropNode, S * @param insertionIndex index at which the MediaUnits are added to the existing List of MediaUnits. * The value -1 represents the end of the list. */ - void reorderMediaUnits(IncludedStructuralElement toElement, - List> elementsToBeMoved, + void reorderMediaUnits(LogicalDivision toElement, + List> elementsToBeMoved, int insertionIndex) { int physicalInsertionIndex; List mediaUnitsToBeMoved = elementsToBeMoved.stream() @@ -1096,7 +1096,7 @@ void reorderMediaUnits(IncludedStructuralElement toElement, * logical elements. * @param elementsToBeMoved List of physical elements to be moved */ - void changePhysicalOrderFields(IncludedStructuralElement toElement, List> elementsToBeMoved) { + void changePhysicalOrderFields(LogicalDivision toElement, List> elementsToBeMoved) { ServiceManager.getFileService().renumberMediaUnits(dataEditor.getWorkpiece(), false); } @@ -1105,10 +1105,10 @@ void changePhysicalOrderFields(IncludedStructuralElement toElement, List> elementsToBeMoved, + void changeLogicalOrderFields(LogicalDivision toElement, List> elementsToBeMoved, int insertionIndex) { - HashMap> logicalElementsByOrder = new HashMap<>(); - for (IncludedStructuralElement logicalElement : dataEditor.getWorkpiece().getAllIncludedStructuralElements()) { + HashMap> logicalElementsByOrder = new HashMap<>(); + for (LogicalDivision logicalElement : dataEditor.getWorkpiece().getAllLogicalDivisions()) { if (logicalElementsByOrder.containsKey(logicalElement.getOrder())) { logicalElementsByOrder.get(logicalElement.getOrder()).add(logicalElement); } else { @@ -1125,7 +1125,7 @@ void changeLogicalOrderFields(IncludedStructuralElement toElement, List> entry : logicalElementsByOrder.entrySet()) { + for (Map.Entry> entry : logicalElementsByOrder.entrySet()) { for (int i = 0; i < ordersAffectedByMove.size() - 1; i++) { if (ordersAffectedByMove.get(i) < entry.getKey() && entry.getKey() < ordersAffectedByMove.get(i + 1)) { if (ordersAffectedByMove.get(i) < toElement.getOrder()) { @@ -1137,8 +1137,8 @@ void changeLogicalOrderFields(IncludedStructuralElement toElement, List beforeToElement = entry.getValue().subList(0, entry.getValue().indexOf(toElement) + 1); - List afterToElement = entry.getValue().subList(entry.getValue().indexOf(toElement) + 1, + List beforeToElement = entry.getValue().subList(0, entry.getValue().indexOf(toElement) + 1); + List afterToElement = entry.getValue().subList(entry.getValue().indexOf(toElement) + 1, entry.getValue().size()); /* toElement at index 0 means we're in an edge case: toElement is the first order which is affected (no pages with smaller order affected) and its order will not change, nor will other elements with the same order before it. */ @@ -1154,7 +1154,7 @@ void changeLogicalOrderFields(IncludedStructuralElement toElement, List getOrdersAffectedByMove(List> views, IncludedStructuralElement toElement) { + private List getOrdersAffectedByMove(List> views, LogicalDivision toElement) { Set ordersAffectedByMove = views.stream() .map(e -> e.getLeft().getMediaUnit().getOrder()) .collect(Collectors.toSet()); @@ -1164,25 +1164,25 @@ private List getOrdersAffectedByMove(List elementsToBeUpdated, int delta) { - for (IncludedStructuralElement element : elementsToBeUpdated) { + private void updateOrder(List elementsToBeUpdated, int delta) { + for (LogicalDivision element : elementsToBeUpdated) { element.setOrder(element.getOrder() + delta); } } /** - * Move List of elements 'elementsToBeMoved' from IncludedStructuralElement in each Pair to IncludedStructuralElement + * Move List of elements 'elementsToBeMoved' from LogicalDivision in each Pair to LogicalDivision * 'toElement'. * * @param toElement - * IncludedStructuralElement to which View is moved + * LogicalDivision to which View is moved * @param elementsToBeMoved - * List of elements to be moved as Pairs of View and IncludedStructuralElement they are attached to + * List of elements to be moved as Pairs of View and LogicalDivision they are attached to * @param insertionIndex * Index where views will be inserted into toElement's views */ - void moveViews(IncludedStructuralElement toElement, - List> elementsToBeMoved, + void moveViews(LogicalDivision toElement, + List> elementsToBeMoved, int insertionIndex) { List views = elementsToBeMoved.stream() .map(Pair::getKey) @@ -1194,28 +1194,28 @@ void moveViews(IncludedStructuralElement toElement, toElement.getViews().addAll(insertionIndex, views); } - for (Pair elementToBeMoved : elementsToBeMoved) { + for (Pair elementToBeMoved : elementsToBeMoved) { boolean removeLastOccurrenceOfView = toElement.equals(elementToBeMoved.getValue()) && insertionIndex < elementToBeMoved.getValue().getViews().lastIndexOf(elementToBeMoved.getKey()); dataEditor.unassignView(elementToBeMoved.getValue(), elementToBeMoved.getKey(), removeLastOccurrenceOfView); - elementToBeMoved.getKey().getMediaUnit().getIncludedStructuralElements().add(toElement); + elementToBeMoved.getKey().getMediaUnit().getLogicalDivisions().add(toElement); } } private void checkLogicalDragDrop(StructureTreeNode dragNode, StructureTreeNode dropNode) throws Exception { - IncludedStructuralElement dragStructure = (IncludedStructuralElement) dragNode.getDataObject(); - IncludedStructuralElement dropStructure = (IncludedStructuralElement) dropNode.getDataObject(); + LogicalDivision dragStructure = (LogicalDivision) dragNode.getDataObject(); + LogicalDivision dropStructure = (LogicalDivision) dropNode.getDataObject(); StructuralElementViewInterface divisionView = dataEditor.getRulesetManagement().getStructuralElementView( dropStructure.getType(), dataEditor.getAcquisitionStage(), dataEditor.getPriorityList()); - LinkedList dragParents; + LinkedList dragParents; if (divisionView.getAllowedSubstructuralElements().containsKey(dragStructure.getType())) { dragParents = MetadataEditor.getAncestorsOfStructure(dragStructure, - dataEditor.getWorkpiece().getRootElement()); + dataEditor.getWorkpiece().getLogicalStructure()); if (!dragParents.isEmpty()) { - IncludedStructuralElement parentStructure = dragParents.get(dragParents.size() - 1); + LogicalDivision parentStructure = dragParents.get(dragParents.size() - 1); if (parentStructure.getChildren().contains(dragStructure)) { if (isSeparateMedia()) { preserveLogical(); @@ -1272,19 +1272,19 @@ private void preserveLogicalAndPhysical() throws UnknownTreeNodeDataException { if (!this.logicalTree.getChildren().isEmpty()) { order = 1; for (MediaUnit mediaUnit : dataEditor.getWorkpiece().getMediaUnit().getChildren()) { - mediaUnit.getIncludedStructuralElements().clear(); + mediaUnit.getLogicalDivisions().clear(); } dataEditor.getWorkpiece().getMediaUnit().getChildren().clear(); preserveLogicalAndPhysicalRecursive(this.logicalTree.getChildren().get(logicalTree.getChildCount() - 1)); } } - private IncludedStructuralElement preserveLogicalAndPhysicalRecursive(TreeNode treeNode) throws UnknownTreeNodeDataException { + private LogicalDivision preserveLogicalAndPhysicalRecursive(TreeNode treeNode) throws UnknownTreeNodeDataException { StructureTreeNode structureTreeNode = (StructureTreeNode) treeNode.getData(); - if (Objects.isNull(structureTreeNode) || !(structureTreeNode.getDataObject() instanceof IncludedStructuralElement)) { + if (Objects.isNull(structureTreeNode) || !(structureTreeNode.getDataObject() instanceof LogicalDivision)) { return null; } - IncludedStructuralElement structure = (IncludedStructuralElement) structureTreeNode.getDataObject(); + LogicalDivision structure = (LogicalDivision) structureTreeNode.getDataObject(); structure.setOrder(order); structure.getViews().clear(); structure.getChildren().clear(); @@ -1292,8 +1292,8 @@ private IncludedStructuralElement preserveLogicalAndPhysicalRecursive(TreeNode t if (!(child.getData() instanceof StructureTreeNode)) { throw new UnknownTreeNodeDataException(child.getData().getClass().getCanonicalName()); } - if (((StructureTreeNode) child.getData()).getDataObject() instanceof IncludedStructuralElement) { - IncludedStructuralElement possibleChildStructure = preserveLogicalAndPhysicalRecursive(child); + if (((StructureTreeNode) child.getData()).getDataObject() instanceof LogicalDivision) { + LogicalDivision possibleChildStructure = preserveLogicalAndPhysicalRecursive(child); if (Objects.nonNull(possibleChildStructure)) { structure.getChildren().add(possibleChildStructure); } @@ -1305,8 +1305,8 @@ private IncludedStructuralElement preserveLogicalAndPhysicalRecursive(TreeNode t dataEditor.getWorkpiece().getMediaUnit().getChildren().add(view.getMediaUnit()); order++; } - if (!view.getMediaUnit().getIncludedStructuralElements().contains(structure)) { - view.getMediaUnit().getIncludedStructuralElements().add(structure); + if (!view.getMediaUnit().getLogicalDivisions().contains(structure)) { + view.getMediaUnit().getLogicalDivisions().add(structure); } } } @@ -1331,10 +1331,10 @@ private void expandNode(TreeNode node) { } } - private HashMap getLogicalTreeNodeExpansionStates(DefaultTreeNode tree) { + private HashMap getLogicalTreeNodeExpansionStates(DefaultTreeNode tree) { if (Objects.nonNull(tree) && tree.getChildCount() == 1) { TreeNode treeRoot = tree.getChildren().get(0); - IncludedStructuralElement structuralElement = getTreeNodeStructuralElement(treeRoot); + LogicalDivision structuralElement = getTreeNodeStructuralElement(treeRoot); if (Objects.nonNull(structuralElement)) { return getLogicalTreeNodeExpansionStatesRecursively(treeRoot, new HashMap<>()); } @@ -1342,10 +1342,10 @@ private HashMap getLogicalTreeNodeExpansionS return new HashMap<>(); } - private HashMap getLogicalTreeNodeExpansionStatesRecursively(TreeNode treeNode, - HashMap expansionStates) { + private HashMap getLogicalTreeNodeExpansionStatesRecursively(TreeNode treeNode, + HashMap expansionStates) { if (Objects.nonNull(treeNode)) { - IncludedStructuralElement structureData = getTreeNodeStructuralElement(treeNode); + LogicalDivision structureData = getTreeNodeStructuralElement(treeNode); if (Objects.nonNull(structureData)) { expansionStates.put(structureData, treeNode.isExpanded()); for (TreeNode childNode : treeNode.getChildren()) { @@ -1381,14 +1381,14 @@ private HashMap getPhysicalTreeNodeExpansionStatesRecursivel return expansionStates; } - private void updateLogicalNodeExpansionStates(DefaultTreeNode tree, HashMap expansionStates) { + private void updateLogicalNodeExpansionStates(DefaultTreeNode tree, HashMap expansionStates) { if (Objects.nonNull(tree) && Objects.nonNull(expansionStates) && !expansionStates.isEmpty()) { updateNodeExpansionStatesRecursively(tree, expansionStates); } } - private void updateNodeExpansionStatesRecursively(TreeNode treeNode, HashMap expansionStates) { - IncludedStructuralElement element = getTreeNodeStructuralElement(treeNode); + private void updateNodeExpansionStatesRecursively(TreeNode treeNode, HashMap expansionStates) { + LogicalDivision element = getTreeNodeStructuralElement(treeNode); if (Objects.nonNull(element) && expansionStates.containsKey(element)) { treeNode.setExpanded(expansionStates.get(element)); } @@ -1413,8 +1413,8 @@ private void updatePhysicalNodeExpansionStatesRecursively(TreeNode treeNode, Has } } - private boolean logicalNodeStateUnknown(HashMap expansionStates, TreeNode treeNode) { - IncludedStructuralElement element = getTreeNodeStructuralElement(treeNode); + private boolean logicalNodeStateUnknown(HashMap expansionStates, TreeNode treeNode) { + LogicalDivision element = getTreeNodeStructuralElement(treeNode); return !Objects.nonNull(expansionStates) || (Objects.nonNull(element) && !expansionStates.containsKey(element)); } @@ -1423,11 +1423,11 @@ private boolean physicalNodeStateUnknown(HashMap expanionSta return Objects.isNull(expanionStates) || (Objects.nonNull(mediaUnit) && !expanionStates.containsKey(mediaUnit)); } - private IncludedStructuralElement getTreeNodeStructuralElement(TreeNode treeNode) { + private LogicalDivision getTreeNodeStructuralElement(TreeNode treeNode) { if (treeNode.getData() instanceof StructureTreeNode) { StructureTreeNode structureTreeNode = (StructureTreeNode) treeNode.getData(); - if (structureTreeNode.getDataObject() instanceof IncludedStructuralElement) { - return (IncludedStructuralElement) structureTreeNode.getDataObject(); + if (structureTreeNode.getDataObject() instanceof LogicalDivision) { + return (LogicalDivision) structureTreeNode.getDataObject(); } } return null; @@ -1444,7 +1444,7 @@ private MediaUnit getTreeNodeMediaUnit(TreeNode treeNode) { } /** - * Get List of MediaUnits assigned to multiple IncludedStructuralElements. + * Get List of MediaUnits assigned to multiple LogicalDivisions. * * @return value of severalAssignments */ @@ -1472,7 +1472,7 @@ public void setActiveTabs(String activeTabs) { /** * Get the index of this StructureTreeNode's MediaUnit out of all MediaUnits - * which are assigned to more than one IncludedStructuralElement. + * which are assigned to more than one LogicalDivision. * * @param treeNode object to find the index for * @return index of the StructureTreeNode's MediaUnit if present in the List of several assignments, or -1 if not present in the list. @@ -1486,7 +1486,7 @@ public int getMultipleAssignmentsIndex(StructureTreeNode treeNode) { } /** - * Check if the selected Node's MediaUnit is assigned to several IncludedStructuralElements. + * Check if the selected Node's MediaUnit is assigned to several LogicalDivisions. * * @return {@code true} when the MediaUnit is assigned to more than one logical element */ @@ -1495,7 +1495,7 @@ public boolean isAssignedSeveralTimes() { StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData(); if (structureTreeNode.getDataObject() instanceof View) { View view = (View) structureTreeNode.getDataObject(); - return view.getMediaUnit().getIncludedStructuralElements().size() > 1; + return view.getMediaUnit().getLogicalDivisions().size() > 1; } } return false; @@ -1503,7 +1503,7 @@ public boolean isAssignedSeveralTimes() { /** * Check if the selected Node's MediaUnit can be assigned to the next logical element in addition to the current assignment. - * @return {@code true} if the MediaUnit can be assigned to the next IncludedStructuralElement + * @return {@code true} if the MediaUnit can be assigned to the next LogicalDivision */ public boolean isAssignableSeveralTimes() { if (Objects.nonNull(selectedLogicalNode) && selectedLogicalNode.getData() instanceof StructureTreeNode) { @@ -1518,7 +1518,7 @@ public boolean isAssignableSeveralTimes() { TreeNode nextSibling = logicalNodeSiblings.get(logicalNodeIndex + 1); if (nextSibling.getData() instanceof StructureTreeNode) { StructureTreeNode structureTreeNodeSibling = (StructureTreeNode) nextSibling.getData(); - return structureTreeNodeSibling.getDataObject() instanceof IncludedStructuralElement; + return structureTreeNodeSibling.getDataObject() instanceof LogicalDivision; } } } @@ -1528,7 +1528,7 @@ public boolean isAssignableSeveralTimes() { } /** - * Assign selected Node's MediaUnit to the next IncludedStructuralElement. + * Assign selected Node's MediaUnit to the next LogicalDivision. */ public void assign() { if (isAssignableSeveralTimes()) { @@ -1539,8 +1539,8 @@ public void assign() { int logicalNodeIndex = logicalNodeSiblings.indexOf(selectedLogicalNode.getParent()); TreeNode nextSibling = logicalNodeSiblings.get(logicalNodeIndex + 1); StructureTreeNode structureTreeNodeSibling = (StructureTreeNode) nextSibling.getData(); - IncludedStructuralElement includedStructuralElement = (IncludedStructuralElement) structureTreeNodeSibling.getDataObject(); - dataEditor.assignView(includedStructuralElement, viewToAssign, 0); + LogicalDivision logicalDivision = (LogicalDivision) structureTreeNodeSibling.getDataObject(); + dataEditor.assignView(logicalDivision, viewToAssign, 0); severalAssignments.add(viewToAssign.getMediaUnit()); show(); dataEditor.getSelectedMedia().clear(); @@ -1549,8 +1549,8 @@ public void assign() { } /** - * Unassign the selected Node's MediaUnit from the IncludedStructuralElement parent at the selected position. - * This does not remove it from other IncludedStructuralElements. + * Unassign the selected Node's MediaUnit from the LogicalDivision parent at the selected position. + * This does not remove it from other LogicalDivisions. */ public void unassign() { if (isAssignedSeveralTimes()) { @@ -1558,11 +1558,11 @@ public void unassign() { View view = (View) structureTreeNode.getDataObject(); if (selectedLogicalNode.getParent().getData() instanceof StructureTreeNode) { StructureTreeNode structureTreeNodeParent = (StructureTreeNode) selectedLogicalNode.getParent().getData(); - if (structureTreeNodeParent.getDataObject() instanceof IncludedStructuralElement) { - IncludedStructuralElement includedStructuralElement = - (IncludedStructuralElement) structureTreeNodeParent.getDataObject(); - dataEditor.unassignView(includedStructuralElement, view, false); - if (view.getMediaUnit().getIncludedStructuralElements().size() <= 1) { + if (structureTreeNodeParent.getDataObject() instanceof LogicalDivision) { + LogicalDivision logicalDivision = + (LogicalDivision) structureTreeNodeParent.getDataObject(); + dataEditor.unassignView(logicalDivision, view, false); + if (view.getMediaUnit().getLogicalDivisions().size() <= 1) { severalAssignments.remove(view.getMediaUnit()); } show(); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructureTreeNode.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructureTreeNode.java index cebd906023d..a70baed1412 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructureTreeNode.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/StructureTreeNode.java @@ -14,7 +14,7 @@ import java.io.Serializable; import java.util.Objects; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; @@ -71,22 +71,22 @@ public boolean isUndefined() { } /** - * Return label of dataObject if dataObject is instance of MediaUnit or IncludedStructuralElement. + * Return label of dataObject if dataObject is instance of MediaUnit or LogicalDivision. * * @return label */ public String getOrderLabel() { if (this.dataObject instanceof MediaUnit) { return ((MediaUnit) this.dataObject).getOrderlabel(); - } else if (this.dataObject instanceof IncludedStructuralElement) { - return ((IncludedStructuralElement) this.dataObject).getOrderlabel(); + } else if (this.dataObject instanceof LogicalDivision) { + return ((LogicalDivision) this.dataObject).getOrderlabel(); } else { return ""; } } /** - * Check if the StructureTreeNode's MediaUnit is assigned to several IncludedStructuralElements. + * Check if the StructureTreeNode's MediaUnit is assigned to several LogicalDivisions. * * @return {@code true} when the MediaUnit is assigned to more than one logical element */ @@ -94,9 +94,9 @@ public boolean isAssignedSeveralTimes() { if (Objects.nonNull(this.dataObject)) { if (this.dataObject instanceof View) { View view = (View) this.dataObject; - return Objects.nonNull(view.getMediaUnit()) && view.getMediaUnit().getIncludedStructuralElements().size() > 1; + return Objects.nonNull(view.getMediaUnit()) && view.getMediaUnit().getLogicalDivisions().size() > 1; } else if (this.dataObject instanceof MediaUnit) { - return ((MediaUnit) this.dataObject).getIncludedStructuralElements().size() > 1; + return ((MediaUnit) this.dataObject).getLogicalDivisions().size() > 1; } } return false; diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java b/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java index 05f9244d772..8f82c17e0ad 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java @@ -173,7 +173,7 @@ private void prepareRow(int rowCounter, HSSFSheet sheet, ProcessDTO processDTO) Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFilePath); numberOfProcessImages = (int) Workpiece.treeStream(workpiece.getMediaUnit()) .filter(mediaUnit -> Objects.equals(mediaUnit.getType(), MediaUnit.TYPE_PAGE)).count(); - numberOfProcessStructuralElements = (int) Workpiece.treeStream(workpiece.getRootElement()).count(); + numberOfProcessStructuralElements = (int) Workpiece.treeStream(workpiece.getLogicalStructure()).count(); numberOfProcessMetadata = Math.toIntExact(MetsService.countLogicalMetadata(workpiece)); } catch (IOException e) { diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/TempProcess.java b/Kitodo/src/main/java/org/kitodo/production/helper/TempProcess.java index bdd8390477c..c4ba6c2d1fd 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/TempProcess.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/TempProcess.java @@ -50,7 +50,7 @@ public TempProcess(Process process, NodeList nodeList, String docType) { this.process = process; this.metadataNodes = nodeList; this.workpiece = new Workpiece(); - this.workpiece.getRootElement().setType(docType); + this.workpiece.getLogicalStructure().setType(docType); } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java b/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java index 487f22f03e7..4716618c416 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.config.ConfigCore; import org.kitodo.config.enums.ParameterCore; @@ -326,7 +326,7 @@ private String determineReplacementForMetadata(Matcher variableFinder) { switch (metadataLevel) { case ALL: - List allChildren = workpiece.getRootElement().getChildren(); + List allChildren = workpiece.getLogicalStructure().getChildren(); String allFirstchildValue = allChildren.isEmpty() ? null : MetadataEditor.getMetadataValue(allChildren.get(0), variableFinder.group(5)); if (Objects.nonNull(allFirstchildValue)) { @@ -346,7 +346,7 @@ private String determineReplacementForMetadata(Matcher variableFinder) { } private String determineReplacementForTopstruct(Matcher variableFinder, String failureResult) { - String value = MetadataEditor.getMetadataValue(workpiece.getRootElement(), variableFinder.group(5)); + String value = MetadataEditor.getMetadataValue(workpiece.getLogicalStructure(), variableFinder.group(5)); if (Objects.isNull(value)) { logger.warn("Cannot replace \"{}\": No such metadata entry in the root element", variableFinder.group()); return failureResult; @@ -355,7 +355,7 @@ private String determineReplacementForTopstruct(Matcher variableFinder, String f } private String determineReplacementForFirstchild(Matcher variableFinder, String failureResult) { - List firstchildChildren = workpiece.getRootElement().getChildren(); + List firstchildChildren = workpiece.getLogicalStructure().getChildren(); if (firstchildChildren.isEmpty()) { logger.warn("Cannot replace \"{}\": Workpiece doesn't have subordinate logical divisions", variableFinder.group()); diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyLogicalDocStructHelper.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyLogicalDocStructHelper.java index a612bfe0d3f..0c0226558c2 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyLogicalDocStructHelper.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyLogicalDocStructHelper.java @@ -32,7 +32,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewWithValuesInterface; import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.production.metadata.MetadataEditor; @@ -46,9 +46,9 @@ public class LegacyLogicalDocStructHelper implements LegacyDocStructHelperInterf private static final Logger logger = LogManager.getLogger(LegacyLogicalDocStructHelper.class); /** - * The included structural element accessed via this soldering class. + * The logical division accessed via this soldering class. */ - private IncludedStructuralElement includedStructuralElement; + private LogicalDivision logicalDivision; /** * The current ruleset. @@ -70,13 +70,13 @@ public class LegacyLogicalDocStructHelper implements LegacyDocStructHelperInterf */ private LegacyLogicalDocStructHelper parent; - LegacyLogicalDocStructHelper(IncludedStructuralElement includedStructuralElement, LegacyLogicalDocStructHelper parent, + LegacyLogicalDocStructHelper(LogicalDivision logicalDivision, LegacyLogicalDocStructHelper parent, RulesetManagementInterface ruleset, List priorityList) { - this.includedStructuralElement = includedStructuralElement; + this.logicalDivision = logicalDivision; this.ruleset = ruleset; this.priorityList = priorityList; this.parent = parent; - String type = includedStructuralElement.getType(); + String type = logicalDivision.getType(); this.divisionView = ruleset.getStructuralElementView(Objects.nonNull(type) ? type : "", "edit", priorityList); } @@ -84,7 +84,7 @@ public class LegacyLogicalDocStructHelper implements LegacyDocStructHelperInterf @Deprecated public void addMetadata(LegacyMetadataHelper metadata) { Optional optionalKeyView = divisionView - .getAddableMetadata(includedStructuralElement.getMetadata(), Collections.emptyList()).parallelStream() + .getAddableMetadata(logicalDivision.getMetadata(), Collections.emptyList()).parallelStream() .filter(keyView -> keyView.getId().equals(metadata.getMetadataType().getName())).findFirst(); Optional optionalDomain = optionalKeyView.isPresent() ? optionalKeyView.get().getDomain() : Optional.empty(); @@ -92,7 +92,7 @@ public void addMetadata(LegacyMetadataHelper metadata) { MetadataEntry metadataEntry = new MetadataEntry(); metadata.setBinding(this, metadataEntry, optionalDomain.orElse(Domain.DESCRIPTION)); metadata.saveToBinding(); - includedStructuralElement.getMetadata().add(metadataEntry); + logicalDivision.getMetadata().add(metadataEntry); } else { metadata.setBinding(this, null, Domain.METS_DIV); metadata.saveToBinding(); @@ -103,8 +103,8 @@ public void addMetadata(LegacyMetadataHelper metadata) { public void saveMetadata(LegacyMetadataHelper metadata) { if (Domain.METS_DIV.equals(metadata.getDomain())) { try { - includedStructuralElement.getClass().getMethod("set".concat(metadata.getMetadataType().getName()), String.class) - .invoke(includedStructuralElement, metadata.getValue()); + logicalDivision.getClass().getMethod("set".concat(metadata.getMetadataType().getName()), String.class) + .invoke(logicalDivision, metadata.getValue()); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new IllegalArgumentException(e.getMessage(), e); } @@ -121,8 +121,8 @@ public LegacyReferenceHelper addReferenceTo(LegacyDocStructHelperInterface docSt View view = new View(); LegacyInnerPhysicalDocStructHelper target = (LegacyInnerPhysicalDocStructHelper) docStruct; view.setMediaUnit(target.getMediaUnit()); - includedStructuralElement.getViews().add(view); - view.getMediaUnit().getIncludedStructuralElements().add(includedStructuralElement); + logicalDivision.getViews().add(view); + view.getMediaUnit().getLogicalDivisions().add(logicalDivision); return new LegacyReferenceHelper(target); } @@ -130,7 +130,7 @@ public LegacyReferenceHelper addReferenceTo(LegacyDocStructHelperInterface docSt @Deprecated public List getAddableMetadataTypes() { Collection addableKeys = divisionView.getAddableMetadata( - includedStructuralElement.getMetadata(), + logicalDivision.getMetadata(), Collections.emptyList()); ArrayList addableMetadataTypes = new ArrayList<>(addableKeys.size()); for (MetadataViewInterface key : addableKeys) { @@ -143,7 +143,7 @@ public List getAddableMetadataTypes() { @Deprecated public List getAllChildren() { List wrappedChildren = new ArrayList<>(); - for (IncludedStructuralElement child : includedStructuralElement.getChildren()) { + for (LogicalDivision child : logicalDivision.getChildren()) { wrappedChildren.add(new LegacyLogicalDocStructHelper(child, this, ruleset, priorityList)); } return wrappedChildren; @@ -154,7 +154,7 @@ public List getAllChildren() { public List getAllMetadata() { List allMetadata = new LinkedList<>(); List entryViews = divisionView - .getSortedVisibleMetadata(includedStructuralElement.getMetadata(), Collections.emptyList()); + .getSortedVisibleMetadata(logicalDivision.getMetadata(), Collections.emptyList()); for (MetadataViewWithValuesInterface entryView : entryViews) { Optional optionalMetadata = entryView.getMetadata(); if (optionalMetadata.isPresent()) { @@ -175,7 +175,7 @@ public List getAllMetadata() { public List getAllMetadataByType(LegacyMetadataTypeHelper metadataType) { List allMetadata = new LinkedList<>(); List entryViews = divisionView - .getSortedVisibleMetadata(includedStructuralElement.getMetadata(), Collections.emptyList()); + .getSortedVisibleMetadata(logicalDivision.getMetadata(), Collections.emptyList()); for (MetadataViewWithValuesInterface entryView : entryViews) { if (entryView.getMetadata().isPresent()) { Optional optionalMetadata = entryView.getMetadata(); @@ -198,7 +198,7 @@ public List getAllMetadataByType(LegacyMetadataTypeHelper public Collection getAllToReferences(String type) { switch (type) { case "logical_physical": - Collection views = includedStructuralElement.getViews(); + Collection views = logicalDivision.getViews(); ArrayList allReferences = new ArrayList<>(views.size()); for (View view : views) { MediaUnit mediaUnit = view.getMediaUnit(); @@ -266,7 +266,7 @@ public boolean isDocStructTypeAllowedAsChild(LegacyLogicalDocStructTypeHelper ty @Override @Deprecated public void removeMetadata(LegacyMetadataHelper metaDatum) { - Iterator entries = includedStructuralElement.getMetadata().iterator(); + Iterator entries = logicalDivision.getMetadata().iterator(); String metadataTypeName = metaDatum.getMetadataType().getName(); while (entries.hasNext()) { Metadata entry = entries.next(); diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyMetsModsDigitalDocumentHelper.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyMetsModsDigitalDocumentHelper.java index 181e679a47f..a62afa52e9f 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyMetsModsDigitalDocumentHelper.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/legacytypeimplementations/LegacyMetsModsDigitalDocumentHelper.java @@ -134,7 +134,7 @@ public LegacyFileSetDocStructHelper getFileSet() { @Deprecated public LegacyDocStructHelperInterface getLogicalDocStruct() { - return new LegacyLogicalDocStructHelper(workpiece.getRootElement(), null, ruleset, priorityList); + return new LegacyLogicalDocStructHelper(workpiece.getLogicalStructure(), null, ruleset, priorityList); } @Deprecated diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/tasks/HierarchyMigrationTask.java b/Kitodo/src/main/java/org/kitodo/production/helper/tasks/HierarchyMigrationTask.java index 88587e5cc3c..6fbb0db7f6d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/tasks/HierarchyMigrationTask.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/tasks/HierarchyMigrationTask.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.Logger; import org.kitodo.api.Metadata; import org.kitodo.api.MetadataEntry; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.api.dataformat.mets.LinkedMetsResource; import org.kitodo.data.database.beans.Process; @@ -209,7 +209,7 @@ private static Optional getParentRecordId(Process process) throws IOExce URI metadataFilePath = fileService.getMetadataFilePath(process); URI anchorFilePath = fileService.createAnchorFile(metadataFilePath); Workpiece anchorWorkpiece = metsService.loadWorkpiece(anchorFilePath); - Optional parentRecordId = anchorWorkpiece.getRootElement().getMetadata().parallelStream() + Optional parentRecordId = anchorWorkpiece.getLogicalStructure().getMetadata().parallelStream() .filter(metadata -> metadata.getKey().equals("CatalogIDDigital")) .filter(MetadataEntry.class::isInstance).map(MetadataEntry.class::cast).map(MetadataEntry::getValue) .findFirst(); @@ -249,8 +249,8 @@ private List createParentProcess(Process childProcess) private void checkTaskAndId(Process parentProcess) throws IOException { URI parentMetadataFilePath = fileService.getMetadataFilePath(parentProcess, true, true); Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(parentMetadataFilePath); - ProcessService.checkTasks(parentProcess, workpiece.getRootElement().getType()); - Collection metadata = workpiece.getRootElement().getMetadata(); + ProcessService.checkTasks(parentProcess, workpiece.getLogicalStructure().getType()); + Collection metadata = workpiece.getLogicalStructure().getMetadata(); String shortedTitle = ""; String catalogIdentifier = ""; for (Metadata metadatum : metadata) { @@ -305,7 +305,7 @@ private void createParentMetsFile(Process process) throws IOException { URI metadataFileUri = fileService.getMetadataFilePath(process); URI anchorFileUri = fileService.createAnchorFile(metadataFileUri); Workpiece workpiece = metsService.loadWorkpiece(anchorFileUri); - IncludedStructuralElement firstChild = workpiece.getRootElement().getChildren().get(0); + LogicalDivision firstChild = workpiece.getLogicalStructure().getChildren().get(0); firstChild.setType(null); LinkedMetsResource link = firstChild.getLink(); link.setLoctype("Kitodo.Production"); @@ -324,8 +324,8 @@ private void createParentMetsFile(Process process) throws IOException { */ private static Integer convertChildMetsFile(URI metadataFilePath) throws IOException { Workpiece workpiece = metsService.loadWorkpiece(metadataFilePath); - IncludedStructuralElement childStructureRoot = workpiece.getRootElement().getChildren().get(0); - workpiece.setRootElement(childStructureRoot); + LogicalDivision childStructureRoot = workpiece.getLogicalStructure().getChildren().get(0); + workpiece.setLogicalStructure(childStructureRoot); metsService.saveWorkpiece(workpiece, metadataFilePath); return getCurrentNo(childStructureRoot); } @@ -345,7 +345,7 @@ private static Integer convertChildMetsFile(URI metadataFilePath) throws IOExcep * outline element with metadata * @return the CurrentNo, or {@code null} */ - private static Integer getCurrentNo(IncludedStructuralElement includedStructualElement) { + private static Integer getCurrentNo(LogicalDivision includedStructualElement) { Integer currentNo = includedStructualElement.getMetadata().parallelStream() .filter(metadata -> metadata.getKey().equals("CurrentNo")).filter(MetadataEntry.class::isInstance) .map(MetadataEntry.class::cast).map(MetadataEntry::getValue).filter(value -> value.matches("\\d+")) diff --git a/Kitodo/src/main/java/org/kitodo/production/metadata/MetadataEditor.java b/Kitodo/src/main/java/org/kitodo/production/metadata/MetadataEditor.java index e11d865796d..e955f9de2f1 100644 --- a/Kitodo/src/main/java/org/kitodo/production/metadata/MetadataEditor.java +++ b/Kitodo/src/main/java/org/kitodo/production/metadata/MetadataEditor.java @@ -34,7 +34,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.Domain; import org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface; import org.kitodo.api.dataformat.Division; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.View; import org.kitodo.api.dataformat.Workpiece; @@ -61,7 +61,7 @@ public class MetadataEditor { /** * Connects two processes by means of a link. The link is sorted as a linked - * included structural element in a included structural element of the + * logical division in a logical division of the * parent process. The order is based on the order number specified by the * user. This method does not create a link between the two processes in the * database, this must and can only happen when saving. @@ -79,13 +79,13 @@ public static void addLink(Process process, String insertionPosition, int childP URI metadataFileUri = ServiceManager.getProcessService().getMetadataFileUri(process); Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFileUri); List indices = Arrays.asList(insertionPosition.split(Pattern.quote(INSERTION_POSITION_SEPARATOR))); - IncludedStructuralElement includedStructuralElement = workpiece.getRootElement(); + LogicalDivision logicalDivision = workpiece.getLogicalStructure(); for (int index = 0; index < indices.size(); index++) { if (index < indices.size() - 1) { - includedStructuralElement = includedStructuralElement.getChildren() + logicalDivision = logicalDivision.getChildren() .get(Integer.parseInt(indices.get(index))); } else { - addLink(includedStructuralElement, Integer.parseInt(indices.get(index)), childProcessId); + addLink(logicalDivision, Integer.parseInt(indices.get(index)), childProcessId); } } ServiceManager.getFileService().createBackupFile(process); @@ -94,35 +94,35 @@ public static void addLink(Process process, String insertionPosition, int childP /** * Connects two processes by means of a link. The link is sorted as a linked - * included structural element in a included structural element of the + * logical division in a logical division of the * parent process. The order is based on the order number specified by the * user. This method does not create a link between the two processes in the * database, this must and can only happen when saving. * - * @param parentIncludedStructuralElement - * document included structural element of the parent process in + * @param parentLogicalDivision + * document logical division of the parent process in * which the link is to be added * @param childProcessId * Database ID of the child process to be linked */ - public static void addLink(IncludedStructuralElement parentIncludedStructuralElement, int childProcessId) { - addLink(parentIncludedStructuralElement, -1, childProcessId); + public static void addLink(LogicalDivision parentLogicalDivision, int childProcessId) { + addLink(parentLogicalDivision, -1, childProcessId); } - private static void addLink(IncludedStructuralElement parentIncludedStructuralElement, int index, + private static void addLink(LogicalDivision parentLogicalDivision, int index, int childProcessId) { LinkedMetsResource link = new LinkedMetsResource(); link.setLoctype(INTERNAL_LOCTYPE); URI uri = ServiceManager.getProcessService().getProcessURI(childProcessId); link.setUri(uri); - IncludedStructuralElement includedStructuralElement = new IncludedStructuralElement(); - includedStructuralElement.setLink(link); - List children = parentIncludedStructuralElement.getChildren(); + LogicalDivision logicalDivision = new LogicalDivision(); + logicalDivision.setLink(link); + List children = parentLogicalDivision.getChildren(); if (index < 0) { - children.add(includedStructuralElement); + children.add(logicalDivision); } else { - children.add(index, includedStructuralElement); + children.add(index, logicalDivision); } } @@ -136,7 +136,7 @@ private static void addLink(IncludedStructuralElement parentIncludedStructuralEl public static void removeLink(Process parentProcess, int childProcessId) throws IOException { URI metadataFileUri = ServiceManager.getProcessService().getMetadataFileUri(parentProcess); Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFileUri); - if (removeLinkRecursive(workpiece.getRootElement(), childProcessId)) { + if (removeLinkRecursive(workpiece.getLogicalStructure(), childProcessId)) { ServiceManager.getFileService().createBackupFile(parentProcess); ServiceManager.getMetsService().saveWorkpiece(workpiece, metadataFileUri); } else { @@ -144,10 +144,10 @@ public static void removeLink(Process parentProcess, int childProcessId) throws } } - private static boolean removeLinkRecursive(IncludedStructuralElement element, int childId) { - IncludedStructuralElement parentElement = null; - IncludedStructuralElement linkElement = null; - for (IncludedStructuralElement structuralElement : element.getChildren()) { + private static boolean removeLinkRecursive(LogicalDivision element, int childId) { + LogicalDivision parentElement = null; + LogicalDivision linkElement = null; + for (LogicalDivision structuralElement : element.getChildren()) { if (Objects.nonNull(structuralElement.getLink()) && Objects.nonNull(structuralElement.getLink().getUri()) && structuralElement.getLink().getUri().toString().endsWith("process.id=" + childId)) { parentElement = element; @@ -189,11 +189,11 @@ private static boolean removeLinkRecursive(IncludedStructuralElement element, in * @param metadataValue * value of the first metadata entry */ - public static void addMultipleStructures(int number, String type, Workpiece workpiece, IncludedStructuralElement structure, + public static void addMultipleStructures(int number, String type, Workpiece workpiece, LogicalDivision structure, InsertionPosition position, String metadataKey, String metadataValue) { for (int i = 0; i < number; i++) { - IncludedStructuralElement newStructure = addStructure(type, workpiece, structure, position, Collections.emptyList()); + LogicalDivision newStructure = addStructure(type, workpiece, structure, position, Collections.emptyList()); if (Objects.isNull(newStructure)) { continue; } @@ -222,10 +222,10 @@ public static void addMultipleStructures(int number, String type, Workpiece work * views to be assigned to the structure * @return the newly created structure */ - public static IncludedStructuralElement addStructure(String type, Workpiece workpiece, IncludedStructuralElement structure, + public static LogicalDivision addStructure(String type, Workpiece workpiece, LogicalDivision structure, InsertionPosition position, List viewsToAdd) { - LinkedList parents = getAncestorsOfStructure(structure, workpiece.getRootElement()); - List siblings = new LinkedList<>(); + LinkedList parents = getAncestorsOfStructure(structure, workpiece.getLogicalStructure()); + List siblings = new LinkedList<>(); if (parents.isEmpty()) { if (position.equals(InsertionPosition.AFTER_CURRENT_ELEMENT) || position.equals(InsertionPosition.BEFORE_CURRENT_ELEMENT) @@ -236,7 +236,7 @@ public static IncludedStructuralElement addStructure(String type, Workpiece work } else { siblings = parents.getLast().getChildren(); } - IncludedStructuralElement newStructure = new IncludedStructuralElement(); + LogicalDivision newStructure = new LogicalDivision(); newStructure.setType(type); switch (position) { case AFTER_CURRENT_ELEMENT: @@ -267,7 +267,7 @@ public static IncludedStructuralElement addStructure(String type, Workpiece work case PARENT_OF_CURRENT_ELEMENT: newStructure.getChildren().add(structure); if (parents.isEmpty()) { - workpiece.setRootElement(newStructure); + workpiece.setLogicalStructure(newStructure); } else { siblings.set(siblings.indexOf(structure), newStructure); } @@ -277,12 +277,12 @@ public static IncludedStructuralElement addStructure(String type, Workpiece work } if (Objects.nonNull(viewsToAdd) && !viewsToAdd.isEmpty()) { for (View viewToAdd : viewsToAdd) { - List includedStructuralElements = viewToAdd.getMediaUnit().getIncludedStructuralElements(); - for (IncludedStructuralElement elementToUnassign : includedStructuralElements) { + List logicalDivisions = viewToAdd.getMediaUnit().getLogicalDivisions(); + for (LogicalDivision elementToUnassign : logicalDivisions) { elementToUnassign.getViews().remove(viewToAdd); } - includedStructuralElements.clear(); - includedStructuralElements.add(newStructure); + logicalDivisions.clear(); + logicalDivisions.add(newStructure); } newStructure.getViews().addAll(viewsToAdd); } @@ -336,16 +336,16 @@ public static MediaUnit addMediaUnit(String type, Workpiece workpiece, MediaUnit * @param structure * structure to add all views of all children to */ - public static void assignViewsFromChildren(IncludedStructuralElement structure) { + public static void assignViewsFromChildren(LogicalDivision structure) { Collection viewsToAdd = getViewsFromChildrenRecursive(structure); Collection assignedViews = structure.getViews(); viewsToAdd.removeAll(assignedViews); assignedViews.addAll(viewsToAdd); } - private static Collection getViewsFromChildrenRecursive(IncludedStructuralElement structure) { + private static Collection getViewsFromChildrenRecursive(LogicalDivision structure) { List viewsFromChildren = new ArrayList<>(structure.getViews()); - for (IncludedStructuralElement child : structure.getChildren()) { + for (LogicalDivision child : structure.getChildren()) { viewsFromChildren.addAll(getViewsFromChildrenRecursive(child)); } return viewsFromChildren; @@ -366,38 +366,38 @@ public static View createUnrestrictedViewOn(MediaUnit mediaUnit) { } /** - * Determines the path to the included structural element of the child. For - * each level of the root element, the recursion is run through once, that - * is for a newspaper year process tree times (year, month, day). + * Determines the path to the logical division of the child. For each level + * of the logical structure, the recursion is run through once, that is for + * a newspaper year process tree times (year, month, day). * - * @param includedStructuralElement - * included structural element of the level stage of recursion - * (starting from the top) + * @param logicalDivision + * logical division of the level stage of recursion (starting + * from the top) * @param number * number of the record of the process of the child * */ - public static List determineIncludedStructuralElementPathToChild( - IncludedStructuralElement includedStructuralElement, int number) { + public static List determineLogicalDivisionPathToChild( + LogicalDivision logicalDivision, int number) { - if (Objects.nonNull(includedStructuralElement.getLink())) { + if (Objects.nonNull(logicalDivision.getLink())) { try { if (ServiceManager.getProcessService() - .processIdFromUri(includedStructuralElement.getLink().getUri()) == number) { - LinkedList linkedIncludedStructuralElements = new LinkedList<>(); - linkedIncludedStructuralElements.add(includedStructuralElement); - return linkedIncludedStructuralElements; + .processIdFromUri(logicalDivision.getLink().getUri()) == number) { + LinkedList linkedLogicalDivisions = new LinkedList<>(); + linkedLogicalDivisions.add(logicalDivision); + return linkedLogicalDivisions; } } catch (IllegalArgumentException | ClassCastException | SecurityException e) { logger.catching(Level.TRACE, e); } } - for (IncludedStructuralElement includedStructuralElementChild : includedStructuralElement.getChildren()) { - List includedStructuralElementList = determineIncludedStructuralElementPathToChild( - includedStructuralElementChild, number); - if (!includedStructuralElementList.isEmpty()) { - includedStructuralElementList.add(0, includedStructuralElement); - return includedStructuralElementList; + for (LogicalDivision logicalDivisionChild : logicalDivision.getChildren()) { + List logicalDivisionList = determineLogicalDivisionPathToChild( + logicalDivisionChild, number); + if (!logicalDivisionList.isEmpty()) { + logicalDivisionList.add(0, logicalDivision); + return logicalDivisionList; } } return Collections.emptyList(); @@ -441,11 +441,11 @@ public static MdSec domainToMdSec(Domain domain) { * node to be searched recursively * @return the parent nodes (maybe empty) */ - public static LinkedList getAncestorsOfStructure(IncludedStructuralElement searched, - IncludedStructuralElement position) { + public static LinkedList getAncestorsOfStructure(LogicalDivision searched, + LogicalDivision position) { return getAncestorsRecursive(searched, position, null) .stream() - .map(parent -> (IncludedStructuralElement) parent) + .map(parent -> (LogicalDivision) parent) .collect(Collectors.toCollection(LinkedList::new)); } @@ -491,15 +491,15 @@ private static > LinkedList> getAncestorsRecur /** * Returns the value of the specified metadata entry. * - * @param includedStructuralElement - * included structural element from whose metadata the value is + * @param logicalDivision + * logical division from whose metadata the value is * to be retrieved * @param key * key of the metadata to be determined * @return the value of the metadata entry, otherwise {@code null} */ - public static String getMetadataValue(IncludedStructuralElement includedStructuralElement, String key) { - for (Metadata metadata : includedStructuralElement.getMetadata()) { + public static String getMetadataValue(LogicalDivision logicalDivision, String key) { + for (Metadata metadata : logicalDivision.getMetadata()) { if (metadata.getKey().equals(key) && metadata instanceof MetadataEntry) { return ((MetadataEntry) metadata).getValue(); } @@ -513,9 +513,9 @@ public static String getMetadataValue(IncludedStructuralElement includedStructur * @return View or null if no View was found */ public static View getFirstViewForMediaUnit(MediaUnit mediaUnit) { - List includedStructuralElements = mediaUnit.getIncludedStructuralElements(); - if (!includedStructuralElements.isEmpty() && Objects.nonNull(includedStructuralElements.get(0))) { - for (View view : includedStructuralElements.get(0).getViews()) { + List logicalDivisions = mediaUnit.getLogicalDivisions(); + if (!logicalDivisions.isEmpty() && Objects.nonNull(logicalDivisions.get(0))) { + for (View view : logicalDivisions.get(0).getViews()) { if (Objects.nonNull(view) && Objects.equals(view.getMediaUnit(), mediaUnit)) { return view; } @@ -525,18 +525,18 @@ public static View getFirstViewForMediaUnit(MediaUnit mediaUnit) { } /** - * Reads the simple metadata from an included structural element defined by + * Reads the simple metadata from a logical division defined by * the simple metadata view interface, including {@code mets:div} metadata. * * @param division - * included structural element from which the metadata should be + * logical division from which the metadata should be * read * @param simpleMetadataView * simple metadata view interface which formally describes the * methadata to be read * @return metadata which corresponds to the formal description */ - public static List readSimpleMetadataValues(IncludedStructuralElement division, + public static List readSimpleMetadataValues(LogicalDivision division, SimpleMetadataViewInterface simpleMetadataView) { Domain domain = simpleMetadataView.getDomain().orElse(Domain.DESCRIPTION); if (domain.equals(Domain.METS_DIV)) { @@ -563,13 +563,13 @@ public static List readSimpleMetadataValues(IncludedStructuralElement di * Removes all metadata of the given key from the given included structural * element. * - * @param includedStructuralElement - * included structural element to remove metadata from + * @param logicalDivision + * logical division to remove metadata from * @param key * key of metadata to remove */ - public static void removeAllMetadata(IncludedStructuralElement includedStructuralElement, String key) { - includedStructuralElement.getMetadata().removeIf(metadata -> key.equals(metadata.getKey())); + public static void removeAllMetadata(LogicalDivision logicalDivision, String key) { + logicalDivision.getMetadata().removeIf(metadata -> key.equals(metadata.getKey())); } /** @@ -579,7 +579,7 @@ public static void removeAllMetadata(IncludedStructuralElement includedStructura * model. Otherwise, however, a metadata entry is written in metadata area. * * @param division - * included structural element at which the metadata entry is to + * logical division at which the metadata entry is to * be written * @param simpleMetadataView * properties of the metadata entry as defined in the ruleset @@ -591,7 +591,7 @@ public static void removeAllMetadata(IncludedStructuralElement includedStructura * and the value is different from either {@code label} or * {@code orderlabel}. */ - public static void writeMetadataEntry(IncludedStructuralElement division, + public static void writeMetadataEntry(LogicalDivision division, SimpleMetadataViewInterface simpleMetadataView, String value) { Domain domain = simpleMetadataView.getDomain().orElse(Domain.DESCRIPTION); diff --git a/Kitodo/src/main/java/org/kitodo/production/metadata/copier/DataCopyrule.java b/Kitodo/src/main/java/org/kitodo/production/metadata/copier/DataCopyrule.java index a1f790abd27..798f7cd5dbd 100644 --- a/Kitodo/src/main/java/org/kitodo/production/metadata/copier/DataCopyrule.java +++ b/Kitodo/src/main/java/org/kitodo/production/metadata/copier/DataCopyrule.java @@ -13,14 +13,13 @@ import java.io.IOException; import java.io.OutputStream; -import java.util.Collection; import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.MdSec; import org.kitodo.api.MetadataEntry; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.data.elasticsearch.exceptions.CustomResponseException; import org.kitodo.data.exceptions.DataException; @@ -44,9 +43,9 @@ public DataCopyrule(List command) { */ public void apply(CopierData data) { Workpiece workpiece = data.getDigitalDocument().getWorkpiece(); - List allIncludedStructuralElements = workpiece.getAllIncludedStructuralElements(); + List allLogicalDivisions = workpiece.getAllLogicalDivisions(); - for (IncludedStructuralElement child : allIncludedStructuralElements) { + for (LogicalDivision child : allLogicalDivisions) { MdSec domain = null; MetadataEntry metadataEntry = new MetadataEntry(); metadataEntry.setKey(command.get(0)); diff --git a/Kitodo/src/main/java/org/kitodo/production/migration/NewspaperProcessesMigrator.java b/Kitodo/src/main/java/org/kitodo/production/migration/NewspaperProcessesMigrator.java index 49037e901fb..9a8b0f671bc 100644 --- a/Kitodo/src/main/java/org/kitodo/production/migration/NewspaperProcessesMigrator.java +++ b/Kitodo/src/main/java/org/kitodo/production/migration/NewspaperProcessesMigrator.java @@ -43,7 +43,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; import org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.config.ConfigCore; import org.kitodo.config.enums.ParameterCore; @@ -185,10 +185,10 @@ public class NewspaperProcessesMigrator { private DatesSimpleMetadataViewInterface yearSimpleMetadataView; /** - * The years of the course of appearance of the newspaper with their logical - * root elements. + * The years of the course of appearance of the newspaper with their + * logical structures. */ - private Map years = new TreeMap<>(); + private Map years = new TreeMap<>(); /** * Process IDs of children (issue processes) to be added to the years in @@ -199,7 +199,7 @@ public class NewspaperProcessesMigrator { /** * Years iterator during creation of year processes. */ - private PeekingIterator> yearsIterator; + private PeekingIterator> yearsIterator; /** * The ruleset. @@ -320,21 +320,20 @@ public void convertProcess(int index) throws DAOException, IOException, Configur Workpiece workpiece = metsService.loadWorkpiece(metadataFilePath); workpiece.setId(process.getId().toString()); - IncludedStructuralElement newspaperIncludedStructuralElement = workpiece.getRootElement(); + LogicalDivision newspaperLogicalDivision = workpiece.getLogicalStructure(); if (Objects.isNull(title)) { - initializeMigrator(process, newspaperIncludedStructuralElement.getType()); + initializeMigrator(process, newspaperLogicalDivision.getType()); } - IncludedStructuralElement yearIncludedStructuralElement = cutOffTopLevel(newspaperIncludedStructuralElement); - final String year = createLinkStructureAndCopyDates(process, yearFilePath, yearIncludedStructuralElement); + LogicalDivision yearLogicalDivision = cutOffTopLevel(newspaperLogicalDivision); + final String year = createLinkStructureAndCopyDates(process, yearFilePath, yearLogicalDivision); - workpiece.setRootElement(cutOffTopLevel(yearIncludedStructuralElement)); + workpiece.setLogicalStructure(cutOffTopLevel(yearLogicalDivision)); moveMetadataFromYearToIssue(process, processTitle, yearFilePath, workpiece); - metsService.saveWorkpiece(workpiece, metadataFilePath); - for (Metadata metadata : overallWorkpiece.getRootElement().getMetadata()) { + for (Metadata metadata : overallWorkpiece.getLogicalStructure().getMetadata()) { if (!overallMetadata.contains(metadata)) { logger.debug("Adding metadata to newspaper {}: {}", title, metadata); overallMetadata.add(metadata); @@ -357,8 +356,8 @@ private void moveMetadataFromYearToIssue(Process process, String processTitle, U Workpiece yearWorkpiece = metsService.loadWorkpiece(yearFilePath); // Copy metadata from year to issue Collection processMetadataFromYear = new ArrayList<>( - yearWorkpiece.getRootElement().getChildren().get(0).getMetadata()); - List issuesIncludedStructuralElements = workpiece.getRootElement().getChildren() + yearWorkpiece.getLogicalStructure().getChildren().get(0).getMetadata()); + List issuesIncludedStructuralElements = workpiece.getLogicalStructure().getChildren() .get(0).getChildren(); issuesIncludedStructuralElements.get(0).getMetadata().addAll(processMetadataFromYear); @@ -380,22 +379,22 @@ private void moveMetadataFromYearToIssue(Process process, String processTitle, U } /** - * Cuts the top level of a tree included structural element. + * Cuts the top level of a tree logical division. * - * @param includedStructuralElement - * tree included structural element to be cut + * @param logicalDivision + * tree logical division to be cut * @return the new top level */ - private static IncludedStructuralElement cutOffTopLevel(IncludedStructuralElement includedStructuralElement) { - List children = includedStructuralElement.getChildren(); + private static LogicalDivision cutOffTopLevel(LogicalDivision logicalDivision) { + List children = logicalDivision.getChildren(); int numberOfChildren = children.size(); if (numberOfChildren == 0) { return null; } - IncludedStructuralElement firstChild = children.get(0); + LogicalDivision firstChild = children.get(0); if (numberOfChildren > 1) { children.subList(1, numberOfChildren).stream() - .flatMap(theIncludedStructuralElement -> theIncludedStructuralElement.getChildren().stream()) + .flatMap(theLogicalDivision -> theLogicalDivision.getChildren().stream()) .forEachOrdered(firstChild.getChildren()::add); String firstOrderlabel = firstChild.getOrderlabel(); String lastOrderlabel = children.get(children.size() - 1).getOrderlabel(); @@ -413,43 +412,41 @@ private static IncludedStructuralElement cutOffTopLevel(IncludedStructuralElemen * process ID of the current process (on issue level) * @param yearMetadata * Production v. 2 year metadata file - * @param metaFileYearIncludedStructuralElement - * year included structural element of the processes’ metadata - * file + * @param metaFileYearLogicalDivision + * year logical division of the processes’ metadata file * @throws IOException * if an error occurs in the disk drive */ private String createLinkStructureAndCopyDates(Process process, URI yearMetadata, - IncludedStructuralElement metaFileYearIncludedStructuralElement) + LogicalDivision metaFileYearLogicalDivision) throws IOException, ConfigurationException { - IncludedStructuralElement yearFileYearIncludedStructuralElement = metsService.loadWorkpiece(yearMetadata) - .getRootElement().getChildren().get(0); - String year = MetadataEditor.getMetadataValue(yearFileYearIncludedStructuralElement, FIELD_TITLE_SORT); + LogicalDivision yearFileYearLogicalDivision = metsService.loadWorkpiece(yearMetadata) + .getLogicalStructure().getChildren().get(0); + String year = MetadataEditor.getMetadataValue(yearFileYearLogicalDivision, FIELD_TITLE_SORT); if (Objects.isNull(year) || !year.matches(YEAR_OR_DOUBLE_YEAR)) { logger.debug("\"{}\" is not a year number. Falling back to {}.", year, FIELD_TITLE); - year = MetadataEditor.getMetadataValue(yearFileYearIncludedStructuralElement, FIELD_TITLE); + year = MetadataEditor.getMetadataValue(yearFileYearLogicalDivision, FIELD_TITLE); } - IncludedStructuralElement processYearIncludedStructuralElement = years.computeIfAbsent(year, theYear -> { + LogicalDivision processYearLogicalDivision = years.computeIfAbsent(year, theYear -> { // remove existing layers in the year - yearFileYearIncludedStructuralElement.getChildren().get(0).getChildren().get(0).getChildren().clear(); - MetadataEditor.writeMetadataEntry(yearFileYearIncludedStructuralElement, yearSimpleMetadataView, theYear); - return yearFileYearIncludedStructuralElement; + yearFileYearLogicalDivision.getChildren().get(0).getChildren().get(0).getChildren().clear(); + MetadataEditor.writeMetadataEntry(yearFileYearLogicalDivision, yearSimpleMetadataView, theYear); + return yearFileYearLogicalDivision; }); - createLinkStructureAndCopyMonths(process, metaFileYearIncludedStructuralElement, - yearFileYearIncludedStructuralElement, year, processYearIncludedStructuralElement); + createLinkStructureAndCopyMonths(process, metaFileYearLogicalDivision, yearFileYearLogicalDivision, year, + processYearLogicalDivision); return year; } private void createLinkStructureAndCopyMonths(Process process, - IncludedStructuralElement metaFileYearIncludedStructuralElement, - IncludedStructuralElement yearFileYearIncludedStructuralElement, String year, - IncludedStructuralElement processYearIncludedStructuralElement) throws ConfigurationException { + LogicalDivision metaFileYearLogicalDivision, LogicalDivision yearFileYearLogicalDivision, String year, + LogicalDivision processYearLogicalDivision) throws ConfigurationException { // Add types to month and day StructuralElementViewInterface newspaperView = rulesetManagement.getStructuralElementView( - overallWorkpiece.getRootElement().getType(), acquisitionStage, Locale.LanguageRange.parse("en")); + overallWorkpiece.getLogicalStructure().getType(), acquisitionStage, Locale.LanguageRange.parse("en")); StructuralElementViewInterface yearDivisionView = nextSubView(rulesetManagement, newspaperView, acquisitionStage); yearSimpleMetadataView = yearDivisionView.getDatesSimpleMetadata().orElseThrow(ConfigurationException::new); @@ -462,22 +459,22 @@ private void createLinkStructureAndCopyMonths(Process process, daySimpleMetadataView = dayDivisionView.getDatesSimpleMetadata().orElseThrow(ConfigurationException::new); String dayType = dayDivisionView.getId(); - for (Iterator yearFileMonthIncludedStructuralElementsIterator = yearFileYearIncludedStructuralElement + for (Iterator yearFileMonthLogicalDivisionsIterator = yearFileYearLogicalDivision .getChildren() - .iterator(), metaFileMonthIncludedStructuralElementsIterator = metaFileYearIncludedStructuralElement - .getChildren().iterator(); yearFileMonthIncludedStructuralElementsIterator.hasNext() - && metaFileMonthIncludedStructuralElementsIterator.hasNext();) { - IncludedStructuralElement yearFileMonthIncludedStructuralElement = yearFileMonthIncludedStructuralElementsIterator + .iterator(), metaFileMonthLogicalDivisionsIterator = metaFileYearLogicalDivision + .getChildren().iterator(); yearFileMonthLogicalDivisionsIterator.hasNext() + && metaFileMonthLogicalDivisionsIterator.hasNext();) { + LogicalDivision yearFileMonthLogicalDivision = yearFileMonthLogicalDivisionsIterator .next(); - IncludedStructuralElement metaFileMonthIncludedStructuralElement = metaFileMonthIncludedStructuralElementsIterator + LogicalDivision metaFileMonthLogicalDivision = metaFileMonthLogicalDivisionsIterator .next(); - String month = getCompletedDate(yearFileMonthIncludedStructuralElement, year); - IncludedStructuralElement processMonthIncludedStructuralElement = computeIfAbsent( - processYearIncludedStructuralElement, monthSimpleMetadataView, month, monthType); - MetadataEditor.writeMetadataEntry(metaFileMonthIncludedStructuralElement, monthSimpleMetadataView, month); + String month = getCompletedDate(yearFileMonthLogicalDivision, year); + LogicalDivision processMonthLogicalDivision = computeIfAbsent( + processYearLogicalDivision, monthSimpleMetadataView, month, monthType); + MetadataEditor.writeMetadataEntry(metaFileMonthLogicalDivision, monthSimpleMetadataView, month); - createLinkStructureAndCopyDays(process, yearFileMonthIncludedStructuralElement, - metaFileMonthIncludedStructuralElement, month, dayType, processMonthIncludedStructuralElement); + createLinkStructureAndCopyDays(process, yearFileMonthLogicalDivision, + metaFileMonthLogicalDivision, month, dayType, processMonthLogicalDivision); } } @@ -490,53 +487,52 @@ private static StructuralElementViewInterface nextSubView(RulesetManagementInter } private void createLinkStructureAndCopyDays(Process process, - IncludedStructuralElement yearFileMonthIncludedStructuralElement, - IncludedStructuralElement metaFileMonthIncludedStructuralElement, String month, String dayType, - IncludedStructuralElement processMonthIncludedStructuralElement) { + LogicalDivision yearFileMonthLogicalDivision, + LogicalDivision metaFileMonthLogicalDivision, String month, String dayType, + LogicalDivision processMonthLogicalDivision) { - for (Iterator yearFileDayIncludedStructuralElementsIterator = yearFileMonthIncludedStructuralElement + for (Iterator yearFileDayLogicalDivisionsIterator = yearFileMonthLogicalDivision .getChildren() - .iterator(), metaFileDayIncludedStructuralElementsIterator = metaFileMonthIncludedStructuralElement - .getChildren().iterator(); yearFileDayIncludedStructuralElementsIterator.hasNext() - && metaFileDayIncludedStructuralElementsIterator.hasNext();) { - IncludedStructuralElement yearFileDayIncludedStructuralElement = yearFileDayIncludedStructuralElementsIterator + .iterator(), metaFileDayLogicalDivisionsIterator = metaFileMonthLogicalDivision + .getChildren().iterator(); yearFileDayLogicalDivisionsIterator.hasNext() + && metaFileDayLogicalDivisionsIterator.hasNext();) { + LogicalDivision yearFileDayLogicalDivision = yearFileDayLogicalDivisionsIterator .next(); - IncludedStructuralElement metaFileDayIncludedStructuralElement = metaFileDayIncludedStructuralElementsIterator + LogicalDivision metaFileDayLogicalDivision = metaFileDayLogicalDivisionsIterator .next(); - String day = getCompletedDate(yearFileDayIncludedStructuralElement, month); - IncludedStructuralElement processDayIncludedStructuralElement = computeIfAbsent( - processMonthIncludedStructuralElement, daySimpleMetadataView, day, dayType); - MetadataEditor.writeMetadataEntry(metaFileDayIncludedStructuralElement, daySimpleMetadataView, day); - - createLinkStructureOfIssues(process, yearFileDayIncludedStructuralElement, - processDayIncludedStructuralElement); + String day = getCompletedDate(yearFileDayLogicalDivision, month); + LogicalDivision processDayLogicalDivision = computeIfAbsent( + processMonthLogicalDivision, daySimpleMetadataView, day, dayType); + MetadataEditor.writeMetadataEntry(metaFileDayLogicalDivision, daySimpleMetadataView, day); + createLinkStructureOfIssues(process, yearFileDayLogicalDivision, + processDayLogicalDivision); } } private void createLinkStructureOfIssues(Process process, - IncludedStructuralElement yearFileDayIncludedStructuralElement, - IncludedStructuralElement processDayIncludedStructuralElement) { + LogicalDivision yearFileDayLogicalDivision, + LogicalDivision processDayLogicalDivision) { - MetadataEditor.addLink(processDayIncludedStructuralElement, process.getId()); + MetadataEditor.addLink(processDayLogicalDivision, process.getId()); } /** - * Finds the included structural element with the specified label, if it + * Finds the logical division with the specified label, if it * exists, otherwise it creates. * - * @param includedStructuralElement - * parent included structural element + * @param logicalDivision + * parent logical division * @param simpleMetadataView * indication which metadata value is used to store the value * @param value * the value * @return child with value */ - private static IncludedStructuralElement computeIfAbsent(IncludedStructuralElement includedStructuralElement, + private static LogicalDivision computeIfAbsent(LogicalDivision logicalDivision, SimpleMetadataViewInterface simpleMetadataView, String value, String type) { int index = 0; - for (IncludedStructuralElement child : includedStructuralElement.getChildren()) { + for (LogicalDivision child : logicalDivision.getChildren()) { String firstSimpleMetadataValue = MetadataEditor.readSimpleMetadataValues(child, simpleMetadataView).get(0); int comparison = firstSimpleMetadataValue.compareTo(value); if (comparison <= -1) { @@ -547,10 +543,10 @@ private static IncludedStructuralElement computeIfAbsent(IncludedStructuralEleme break; } } - IncludedStructuralElement computed = new IncludedStructuralElement(); + LogicalDivision computed = new LogicalDivision(); computed.setType(type); MetadataEditor.writeMetadataEntry(computed, simpleMetadataView, value); - includedStructuralElement.getChildren().add(index, computed); + logicalDivision.getChildren().add(index, computed); return computed; } @@ -559,14 +555,14 @@ private static IncludedStructuralElement computeIfAbsent(IncludedStructuralEleme * the date is stored incompletely (as an integer). This is supplemented to * ISO if found. Otherwise just returns the date. * - * @param includedStructuralElement - * the included structural element that contains the date + * @param logicalDivision + * the logical division that contains the date * @param previousLevel * previous part of date * @return ISO date */ - private static String getCompletedDate(IncludedStructuralElement includedStructuralElement, String previousLevel) { - String date = MetadataEditor.getMetadataValue(includedStructuralElement, FIELD_TITLE_SORT); + private static String getCompletedDate(LogicalDivision logicalDivision, String previousLevel) { + String date = MetadataEditor.getMetadataValue(logicalDivision, FIELD_TITLE_SORT); if (!date.matches("\\d{1,2}")) { return date; } @@ -594,17 +590,17 @@ public void createOverallProcess() throws ProcessGenerationException, IOExceptio CommandException { final long begin = System.nanoTime(); logger.info("Creating overall process {}...", title); - overallWorkpiece.getRootElement().getChildren().clear(); + overallWorkpiece.getLogicalStructure().getChildren().clear(); ProcessGenerator processGenerator = new ProcessGenerator(); processGenerator.generateProcess(templateId, projectId); overallProcess = processGenerator.getGeneratedProcess(); overallProcess.setTitle(getTitle()); - ProcessService.checkTasks(overallProcess, overallWorkpiece.getRootElement().getType()); + ProcessService.checkTasks(overallProcess, overallWorkpiece.getLogicalStructure().getType()); processService.saveToDatabase(overallProcess); ServiceManager.getFileService().createProcessLocation(overallProcess); overallWorkpiece.setId(overallProcess.getId().toString()); - overallWorkpiece.getRootElement().getMetadata().addAll(overallMetadata); + overallWorkpiece.getLogicalStructure().getMetadata().addAll(overallMetadata); addToBatch(overallProcess); logger.info("Process {} (ID {}) successfully created.", overallProcess.getTitle(), overallProcess.getId()); @@ -629,7 +625,7 @@ public void createOverallProcess() throws ProcessGenerationException, IOExceptio public void createNextYearProcess() throws ProcessGenerationException, IOException, DAOException, CommandException { final long begin = System.nanoTime(); - Entry yearToCreate = yearsIterator.next(); + Entry yearToCreate = yearsIterator.next(); String yearTitle = getYearTitle(yearToCreate.getKey()); logger.info("Creating process for year {}, {}...", yearToCreate.getKey(), yearTitle); ProcessGenerator processGenerator = new ProcessGenerator(); @@ -641,7 +637,7 @@ public void createNextYearProcess() throws ProcessGenerationException, IOExcepti yearToCreate.getValue().getMetadata().clear(); processService.saveToDatabase(yearProcess); - MetadataEditor.addLink(overallWorkpiece.getRootElement(), yearProcess.getId()); + MetadataEditor.addLink(overallWorkpiece.getLogicalStructure(), yearProcess.getId()); if (!yearsIterator.hasNext()) { metsService.saveWorkpiece(overallWorkpiece, fileService.getMetadataFilePath(overallProcess, false, false)); } @@ -674,18 +670,18 @@ public void createNextYearProcess() throws ProcessGenerationException, IOExcepti } } - private void createYearWorkpiece(Entry yearToCreate, String yearTitle, + private void createYearWorkpiece(Entry yearToCreate, String yearTitle, Process yearProcess) throws IOException { Workpiece yearWorkpiece = new Workpiece(); yearWorkpiece.setId(yearProcess.getId().toString()); - yearWorkpiece.setRootElement(yearToCreate.getValue()); + yearWorkpiece.setLogicalStructure(yearToCreate.getValue()); StructuralElementViewInterface newspaperView = rulesetManagement.getStructuralElementView( - yearWorkpiece.getRootElement().getType(), acquisitionStage, Locale.LanguageRange.parse("de")); + yearWorkpiece.getLogicalStructure().getType(), acquisitionStage, Locale.LanguageRange.parse("de")); final Collection processTitleKeys = rulesetManagement.getFunctionalKeys(FunctionalMetadata.PROCESS_TITLE); newspaperView.getAllowedMetadata().parallelStream().filter(SimpleMetadataViewInterface.class::isInstance) .map(SimpleMetadataViewInterface.class::cast) .filter(metadataView -> processTitleKeys.contains(metadataView.getId())).collect(Collectors.toList()) - .forEach(yearView -> MetadataEditor.writeMetadataEntry(yearWorkpiece.getRootElement(), yearView, yearTitle)); + .forEach(yearView -> MetadataEditor.writeMetadataEntry(yearWorkpiece.getLogicalStructure(), yearView, yearTitle)); metsService.saveWorkpiece(yearWorkpiece, fileService.getMetadataFilePath(yearProcess, false, false)); } diff --git a/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java b/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java index e895e3de6aa..f4d30762b58 100644 --- a/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java +++ b/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java @@ -45,7 +45,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; import org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.api.dataformat.mets.LinkedMetsResource; import org.kitodo.config.ConfigProject; @@ -148,7 +148,7 @@ public class NewspaperProcessesGenerator extends ProcessGenerator { private DatesSimpleMetadataViewInterface daySimpleMetadataView; /** - * Which included structural element type are the days. + * Which logical division type are the days. */ private String dayType; @@ -168,7 +168,7 @@ public class NewspaperProcessesGenerator extends ProcessGenerator { private DatesSimpleMetadataViewInterface monthSimpleMetadataView; /** - * Which included structural element type are the months. + * Which logical division type are the months. */ private String monthType; @@ -227,7 +227,7 @@ public class NewspaperProcessesGenerator extends ProcessGenerator { private DatesSimpleMetadataViewInterface yearSimpleMetadataView; /** - * Which included structural element type are the years. + * Which logical division type are the years. */ private String yearType; @@ -314,12 +314,12 @@ private void initialize() throws ConfigurationException, IOException, DoctypeMis overallMetadataFileUri = processService.getMetadataFileUri(overallProcess); overallWorkpiece = metsService.loadWorkpiece(overallMetadataFileUri); - initializeRulesetFields(overallWorkpiece.getRootElement().getType()); + initializeRulesetFields(overallWorkpiece.getLogicalStructure().getType()); ConfigProject configProject = new ConfigProject(overallProcess.getProject().getTitle()); Collection allowedMetadata = rulesetService.openRuleset(overallProcess.getRuleset()) - .getStructuralElementView(overallWorkpiece.getRootElement().getType(), acquisitionStage, ENGLISH) + .getStructuralElementView(overallWorkpiece.getLogicalStructure().getType(), acquisitionStage, ENGLISH) .getAllowedMetadata(); titleGenerator = initializeTitleGenerator(configProject, overallWorkpiece, allowedMetadata); @@ -404,18 +404,18 @@ private static TitleGenerator initializeTitleGenerator(ConfigProject configProje Collection allowedMetadata) throws DoctypeMissingException { - IncludedStructuralElement rootElement = workpiece.getRootElement(); + LogicalDivision logicalStructure = workpiece.getLogicalStructure(); Map> metadata = new HashMap<>(4); - Map topstruct = getMetadataEntries(rootElement.getMetadata()); + Map topstruct = getMetadataEntries(logicalStructure.getMetadata()); metadata.put("topstruct", topstruct); - List children = rootElement.getChildren(); + List children = logicalStructure.getChildren(); metadata.put("firstchild", children.isEmpty() ? Collections.emptyMap() : getMetadataEntries(children.get(0).getMetadata())); metadata.put("physSequence", getMetadataEntries(workpiece.getMediaUnit().getMetadata())); String docType = null; for (ConfigOpacDoctype configOpacDoctype : ConfigOpac.getAllDoctypes()) { - if (configOpacDoctype.getRulesetType().equals(rootElement.getType())) { + if (configOpacDoctype.getRulesetType().equals(logicalStructure.getType())) { docType = configOpacDoctype.getTitle(); break; } @@ -541,24 +541,24 @@ private String makeTitle(String definition, Map genericFields) t private void createMetadataFileForProcess(List individualIssues, String title) throws IOException, CommandException { - IncludedStructuralElement rootElement = new IncludedStructuralElement(); + LogicalDivision logicalStructure = new LogicalDivision(); MetadataEntry dateMetadataEntry = new MetadataEntry(); dateMetadataEntry.setKey(monthSimpleMetadataView.getId()); dateMetadataEntry.setValue(dateMark(monthSimpleMetadataView.getScheme(), individualIssues.get(0).getDate())); - rootElement.getMetadata().add(dateMetadataEntry); + logicalStructure.getMetadata().add(dateMetadataEntry); for (IndividualIssue individualIssue : individualIssues) { String monthMark = dateMark(monthSimpleMetadataView.getScheme(), individualIssue.getDate()); - IncludedStructuralElement yearMonth = getOrCreateIncludedStructuralElement(yearWorkpiece.getRootElement(), + LogicalDivision yearMonth = getOrCreateLogicalDivision(yearWorkpiece.getLogicalStructure(), monthType, monthSimpleMetadataView, monthMark); String dayMark = dateMark(daySimpleMetadataView.getScheme(), individualIssue.getDate()); - final IncludedStructuralElement processDay = getOrCreateIncludedStructuralElement(rootElement, null, + final LogicalDivision processDay = getOrCreateLogicalDivision(logicalStructure, null, daySimpleMetadataView, dayMark); - final IncludedStructuralElement yearDay = getOrCreateIncludedStructuralElement(yearMonth, dayType, + final LogicalDivision yearDay = getOrCreateLogicalDivision(yearMonth, dayType, daySimpleMetadataView, dayMark); - IncludedStructuralElement processIssue = new IncludedStructuralElement(); + LogicalDivision processIssue = new LogicalDivision(); processIssue.setType(issueDivisionView.getId()); for (SimpleMetadataViewInterface issueProcessTitleView : issueProcessTitleViews) { MetadataEditor.writeMetadataEntry(processIssue, issueProcessTitleView, title); @@ -566,7 +566,7 @@ private void createMetadataFileForProcess(List individualIssues addCustomMetadata(individualIssue, processIssue); processDay.getChildren().add(processIssue); - IncludedStructuralElement yearIssue = new IncludedStructuralElement(); + LogicalDivision yearIssue = new LogicalDivision(); LinkedMetsResource linkToProcess = new LinkedMetsResource(); linkToProcess.setLoctype("Kitodo.Production"); linkToProcess.setUri(processService.getProcessURI(getGeneratedProcess())); @@ -575,14 +575,14 @@ private void createMetadataFileForProcess(List individualIssues } Workpiece workpiece = new Workpiece(); - workpiece.setRootElement(rootElement); + workpiece.setLogicalStructure(logicalStructure); workpiece.setId(getGeneratedProcess().getId().toString()); fileService.createProcessLocation(getGeneratedProcess()); final URI metadataFileUri = processService.getMetadataFileUri(getGeneratedProcess()); metsService.saveWorkpiece(workpiece, metadataFileUri); } - private void addCustomMetadata(IndividualIssue definition, IncludedStructuralElement issue) { + private void addCustomMetadata(IndividualIssue definition, LogicalDivision issue) { Collection entered = new ArrayList<>(); MonthDay yearBegin = yearSimpleMetadataView.getYearBegin(); for (Metadata metadata : definition.getMetadata(yearBegin.getMonthValue(), @@ -656,7 +656,7 @@ private void saveAndCloseCurrentYearProcess() throws DataException, IOException final long begin = System.nanoTime(); metsService.saveWorkpiece(yearWorkpiece, yearMetadataFileUri); - ProcessService.checkTasks(yearProcess, yearWorkpiece.getRootElement().getType()); + ProcessService.checkTasks(yearProcess, yearWorkpiece.getLogicalStructure().getType()); processService.save(yearProcess, true); this.yearProcess = null; @@ -676,7 +676,7 @@ private boolean openExistingYearProcess(String yearMark) final long begin = System.nanoTime(); boolean couldOpenExistingProcess = false; - for (IncludedStructuralElement firstLevelChild : overallWorkpiece.getRootElement().getChildren()) { + for (LogicalDivision firstLevelChild : overallWorkpiece.getLogicalStructure().getChildren()) { LinkedMetsResource firstLevelChildLink = firstLevelChild.getLink(); if (Objects.isNull(firstLevelChildLink)) { continue; @@ -687,9 +687,9 @@ private boolean openExistingYearProcess(String yearMark) Workpiece workpiece = metsService.loadWorkpiece(metadataFileUri); String yearMetadataEntry = null; if (yearSimpleMetadataView.getId().equals("ORDERLABEL")) { - yearMetadataEntry = workpiece.getRootElement().getOrderlabel(); + yearMetadataEntry = workpiece.getLogicalStructure().getOrderlabel(); } - for (Metadata metadata : workpiece.getRootElement().getMetadata()) { + for (Metadata metadata : workpiece.getLogicalStructure().getMetadata()) { if (metadata.getKey().equals(yearSimpleMetadataView.getId()) && metadata instanceof MetadataEntry) { yearMetadataEntry = ((MetadataEntry) metadata).getValue(); break; @@ -732,21 +732,21 @@ private void createNewYearProcess(String yearMark, Map genericFi fileService.createProcessLocation(getGeneratedProcess()); final URI metadataFileUri = processService.getMetadataFileUri(getGeneratedProcess()); - IncludedStructuralElement newYearChild = new IncludedStructuralElement(); + LogicalDivision newYearChild = new LogicalDivision(); LinkedMetsResource link = new LinkedMetsResource(); link.setLoctype("Kitodo.Production"); link.setUri(processService.getProcessURI(getGeneratedProcess())); newYearChild.setLink(link); - overallWorkpiece.getRootElement().getChildren().add(newYearChild); + overallWorkpiece.getLogicalStructure().getChildren().add(newYearChild); - IncludedStructuralElement rootElement = new IncludedStructuralElement(); - rootElement.setType(yearType); - MetadataEditor.writeMetadataEntry(rootElement, yearSimpleMetadataView, yearMark); + LogicalDivision logicalStructure = new LogicalDivision(); + logicalStructure.setType(yearType); + MetadataEditor.writeMetadataEntry(logicalStructure, yearSimpleMetadataView, yearMark); for (SimpleMetadataViewInterface yearProcessTitleView : yearProcessTitleViews) { - MetadataEditor.writeMetadataEntry(rootElement, yearProcessTitleView, title); + MetadataEditor.writeMetadataEntry(logicalStructure, yearProcessTitleView, title); } Workpiece workpiece = new Workpiece(); - workpiece.setRootElement(rootElement); + workpiece.setLogicalStructure(logicalStructure); workpiece.setId(getGeneratedProcess().getId().toString()); this.yearProcess = getGeneratedProcess(); @@ -760,21 +760,21 @@ private void createNewYearProcess(String yearMark, Map genericFi } } - private IncludedStructuralElement getOrCreateIncludedStructuralElement( - IncludedStructuralElement includedStructuralElement, String childType, + private LogicalDivision getOrCreateLogicalDivision( + LogicalDivision logicalDivision, String childType, SimpleMetadataViewInterface identifierMetadata, String identifierMetadataValue) { - for (IncludedStructuralElement child : includedStructuralElement.getChildren()) { + for (LogicalDivision child : logicalDivision.getChildren()) { if (MetadataEditor.readSimpleMetadataValues(child, identifierMetadata).contains(identifierMetadataValue)) { return child; } } - IncludedStructuralElement createdChild = new IncludedStructuralElement(); + LogicalDivision createdChild = new LogicalDivision(); createdChild.setType(childType); MetadataEditor.writeMetadataEntry(createdChild, identifierMetadata, identifierMetadataValue); - includedStructuralElement.getChildren().add(createdChild); + logicalDivision.getChildren().add(createdChild); return createdChild; } @@ -783,11 +783,11 @@ private void finish() throws DataException, IOException { saveAndCloseCurrentYearProcess(); for (SimpleMetadataViewInterface newspaperProcessTitleView : newspaperProcessTitleViews) { - MetadataEditor.writeMetadataEntry(overallWorkpiece.getRootElement(), newspaperProcessTitleView, + MetadataEditor.writeMetadataEntry(overallWorkpiece.getLogicalStructure(), newspaperProcessTitleView, overallProcess.getTitle()); } metsService.saveWorkpiece(overallWorkpiece, overallMetadataFileUri); - ProcessService.checkTasks(overallProcess, overallWorkpiece.getRootElement().getType()); + ProcessService.checkTasks(overallProcess, overallWorkpiece.getLogicalStructure().getType()); processService.save(overallProcess,true); if (logger.isTraceEnabled()) { diff --git a/Kitodo/src/main/java/org/kitodo/production/services/command/EditDataScript.java b/Kitodo/src/main/java/org/kitodo/production/services/command/EditDataScript.java index cbbcb0cd9b9..6b1afea3cc6 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/command/EditDataScript.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/command/EditDataScript.java @@ -15,7 +15,6 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Objects; @@ -23,7 +22,7 @@ import org.apache.logging.log4j.Logger; import org.kitodo.api.Metadata; import org.kitodo.api.MetadataEntry; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.data.database.beans.Process; import org.kitodo.data.elasticsearch.exceptions.CustomResponseException; @@ -125,7 +124,7 @@ public void generateValueFromParent(MetadataScript metadataScript, Process paren .readMetadataFile(parentProcess); Workpiece workpiece = metadataFile.getWorkpiece(); - Collection metadataCollection = workpiece.getRootElement().getMetadata(); + Collection metadataCollection = workpiece.getLogicalStructure().getMetadata(); generateValueForMetadataScript(metadataScript, metadataCollection, parentProcess, metadataFile); } @@ -140,22 +139,21 @@ public Collection getMetadataCollection(MetadataScript metadataScript, Collection metadataCollection; if (Objects.nonNull(metadataScript.getTypeTarget())) { - IncludedStructuralElement structuralElement = getStructuralElementWithType(metadataScript.getTypeTarget(), - workpiece.getRootElement()); + LogicalDivision structuralElement = getLogicalDivisionWithType(metadataScript.getTypeTarget(), + workpiece.getLogicalStructure()); metadataCollection = Objects.isNull(structuralElement) ? null : structuralElement.getMetadata(); } else { - metadataCollection = workpiece.getRootElement().getMetadata(); + metadataCollection = workpiece.getLogicalStructure().getMetadata(); } return metadataCollection; } - private IncludedStructuralElement getStructuralElementWithType(String typeTarget, - IncludedStructuralElement structuralElement) { + private LogicalDivision getLogicalDivisionWithType(String typeTarget, LogicalDivision structuralElement) { if (typeTarget.equals(structuralElement.getType())) { return structuralElement; } else { - for (IncludedStructuralElement structuralElementChild : structuralElement.getChildren()) { - IncludedStructuralElement structuralElementWithType = getStructuralElementWithType(typeTarget, + for (LogicalDivision structuralElementChild : structuralElement.getChildren()) { + LogicalDivision structuralElementWithType = getLogicalDivisionWithType(typeTarget, structuralElementChild); if (Objects.nonNull(structuralElementWithType)) { return structuralElementWithType; diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java index 7ffc95c0a9a..39a6ec5eb60 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java @@ -48,7 +48,7 @@ import org.kitodo.api.MetadataGroup; import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.api.externaldatamanagement.ExternalDataImportInterface; import org.kitodo.api.externaldatamanagement.SearchInterfaceType; @@ -427,13 +427,13 @@ private String importProcessAndReturnParentID(String recordId, LinkedList transformToProcessDetails(TempProcess tempProc String acquisitionStage, List priorityList) throws InvalidMetadataValueException, NoSuchMetadataFieldException { - ProcessFieldedMetadata metadata = initializeProcessDetails(tempProcess.getWorkpiece().getRootElement(), + ProcessFieldedMetadata metadata = initializeProcessDetails(tempProcess.getWorkpiece().getLogicalStructure(), managementInterface, acquisitionStage, priorityList); metadata.setMetadata(ImportService.importMetadata(tempProcess.getMetadataNodes(), MdSec.DMD_SEC)); metadata.preserve(); @@ -975,7 +975,7 @@ public static void createProcessTitle(TempProcess tempProcess, String acquisitionStage, List priorityList, List processDetails) throws ProcessGenerationException { - String docType = tempProcess.getWorkpiece().getRootElement().getType(); + String docType = tempProcess.getWorkpiece().getLogicalStructure().getType(); StructuralElementViewInterface docTypeView = rulesetManagementInterface .getStructuralElementView(docType, acquisitionStage, priorityList); String processTitle = docTypeView.getProcessTitle().orElse(""); @@ -984,17 +984,17 @@ public static void createProcessTitle(TempProcess tempProcess, } /** - * Create and return an instance of 'ProcessFieldedMetadata' for the given IncludedStructuralElement 'structure', + * Create and return an instance of 'ProcessFieldedMetadata' for the given LogicalDivision 'structure', * RulesetManagementInterface 'managementInterface', acquisition stage String 'stage' and List of LanguageRange * 'priorityList'. * - * @param structure IncludedStructuralElement for which to create a ProcessFieldedMetadata + * @param structure LogicalDivision for which to create a ProcessFieldedMetadata * @param managementInterface RulesetManagementInterface used to create ProcessFieldedMetadata * @param stage String containing acquisition stage used to create ProcessFieldedMetadata * @param priorityList List of LanguageRange objects used to create ProcessFieldedMetadata * @return the created ProcessFieldedMetadata */ - public static ProcessFieldedMetadata initializeProcessDetails(IncludedStructuralElement structure, + public static ProcessFieldedMetadata initializeProcessDetails(LogicalDivision structure, RulesetManagementInterface managementInterface, String stage, List priorityList) { @@ -1020,7 +1020,7 @@ public static boolean ensureNonEmptyTitles(LinkedList tempProcesses // yet been saved to disk and contains the workpiece directly, instead! URI metadataFileUri = ServiceManager.getProcessService().getMetadataFileUri(process); Workpiece workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFileUri); - Collection metadata = workpiece.getRootElement().getMetadata(); + Collection metadata = workpiece.getLogicalStructure().getMetadata(); String processTitle = "[" + Helper.getTranslation("process") + " " + process.getId() + "]"; for (Metadata metadatum : metadata) { if (CATALOG_IDENTIFIER.equals(metadatum.getKey())) { @@ -1153,7 +1153,7 @@ public static void processTempProcess(TempProcess tempProcess, Template template IOException { List processDetails = transformToProcessDetails(tempProcess, managementInterface, acquisitionStage, priorityList); - String docType = tempProcess.getWorkpiece().getRootElement().getType(); + String docType = tempProcess.getWorkpiece().getLogicalStructure().getType(); createProcessTitle(tempProcess, managementInterface, acquisitionStage, priorityList, processDetails); Process process = tempProcess.getProcess(); addProperties(tempProcess.getProcess(), template, processDetails, docType, tempProcess.getProcess().getTitle()); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java index 9062701c520..8bd92520ae8 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java @@ -88,7 +88,7 @@ import org.json.JSONObject; import org.json.XML; import org.kitodo.api.dataeditor.rulesetmanagement.FunctionalDivision; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.docket.DocketData; import org.kitodo.api.docket.DocketInterface; import org.kitodo.api.filemanagement.ProcessSubType; @@ -1697,12 +1697,12 @@ public LegacyMetsModsDigitalDocumentHelper getDigitalDocument(Process process) t } /** - * Returns the type of the top element of the root element, and thus the + * Returns the type of the top element of the logical structure, and thus the * type of the workpiece of the process. * * @param process * process whose root type is to be determined - * @return the type of the root element of the workpiece, "" if unreadable + * @return the type of the logical structure of the workpiece, "" if unreadable */ public String getBaseType(Process process) { try { @@ -1715,12 +1715,12 @@ public String getBaseType(Process process) { } /** - * Returns the type of the top element of the root element, and thus the + * Returns the type of the top element of the logical structure, and thus the * type of the workpiece of the process. * * @param processId * id of the process whose root type is to be determined - * @return the type of root element of the root element of the workpiece + * @return the type of root element of the logical structure of the workpiece * @throws DataException * if the type cannot be found in the index (e.g. because the process * cannot be found in the index) @@ -2206,30 +2206,30 @@ public static String getProcessDuration(ProcessDTO process) { /** * Updates the linked child processes to the level specified in the root - * element. Processes linked in the root element are linked in the database. - * For processes that are not linked in the root element, the link in the + * element. Processes linked in the logical structure are linked in the database. + * For processes that are not linked in the logical structure, the link in the * database is removed. * * @param process * parent process - * @param rootElement - * the current state of the root element + * @param logicalStructure + * the current state of the logical structure * @throws DAOException * if a process is referenced with a URI whose ID does not * appear in the database * @throws DataException * if the process cannot be saved */ - public void updateChildrenFromRootElement(Process process, IncludedStructuralElement rootElement) + public void updateChildrenFromLogicalStructure(Process process, LogicalDivision logicalStructure) throws DAOException, DataException { - removeLinksFromNoLongerLinkedProcesses(process, rootElement); - addNewLinks(process, rootElement); + removeLinksFromNoLongerLinkedProcesses(process, logicalStructure); + addNewLinks(process, logicalStructure); } - private void removeLinksFromNoLongerLinkedProcesses(Process process, IncludedStructuralElement rootElement) + private void removeLinksFromNoLongerLinkedProcesses(Process process, LogicalDivision logicalStructure) throws DAOException, DataException { ArrayList childrenToRemove = new ArrayList<>(process.getChildren()); - childrenToRemove.removeAll(getProcessesLinkedInIncludedStructuralElement(rootElement)); + childrenToRemove.removeAll(getProcessesLinkedInLogicalDivision(logicalStructure)); for (Process childToRemove : childrenToRemove) { childToRemove.setParent(null); process.getChildren().remove(childToRemove); @@ -2240,9 +2240,9 @@ private void removeLinksFromNoLongerLinkedProcesses(Process process, IncludedStr } } - private void addNewLinks(Process process, IncludedStructuralElement rootElement) + private void addNewLinks(Process process, LogicalDivision logicalStructure) throws DAOException, DataException { - HashSet childrenToAdd = getProcessesLinkedInIncludedStructuralElement(rootElement); + HashSet childrenToAdd = getProcessesLinkedInLogicalDivision(logicalStructure); childrenToAdd.removeAll(process.getChildren()); for (Process childToAdd : childrenToAdd) { childToAdd.setParent(process); @@ -2254,17 +2254,17 @@ private void addNewLinks(Process process, IncludedStructuralElement rootElement) } } - private HashSet getProcessesLinkedInIncludedStructuralElement( - IncludedStructuralElement includedStructuralElement) throws DAOException { - HashSet processesLinkedInIncludedStructuralElement = new HashSet<>(); - if (Objects.nonNull(includedStructuralElement.getLink())) { - int processId = processIdFromUri(includedStructuralElement.getLink().getUri()); - processesLinkedInIncludedStructuralElement.add(getById(processId)); + private HashSet getProcessesLinkedInLogicalDivision( + LogicalDivision logicalDivision) throws DAOException { + HashSet processesLinkedInLogicalDivision = new HashSet<>(); + if (Objects.nonNull(logicalDivision.getLink())) { + int processId = processIdFromUri(logicalDivision.getLink().getUri()); + processesLinkedInLogicalDivision.add(getById(processId)); } - for (IncludedStructuralElement child : includedStructuralElement.getChildren()) { - processesLinkedInIncludedStructuralElement.addAll(getProcessesLinkedInIncludedStructuralElement(child)); + for (LogicalDivision child : logicalDivision.getChildren()) { + processesLinkedInLogicalDivision.addAll(getProcessesLinkedInLogicalDivision(child)); } - return processesLinkedInIncludedStructuralElement; + return processesLinkedInLogicalDivision; } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/services/dataeditor/DataEditorService.java b/Kitodo/src/main/java/org/kitodo/production/services/dataeditor/DataEditorService.java index aee9c57364d..ffd77d9fd2a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/dataeditor/DataEditorService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/dataeditor/DataEditorService.java @@ -36,7 +36,7 @@ import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.View; import org.kitodo.config.ConfigCore; import org.kitodo.config.enums.ParameterCore; @@ -99,7 +99,7 @@ public static List getTitleKeys() { * @param element IncludedStructuralElement for which the title value is returned. * @return title value of given element */ - public static String getTitleValue(IncludedStructuralElement element) { + public static String getTitleValue(LogicalDivision element) { for (final String titleKey : getTitleKeys()) { String[] metadataPath = titleKey.split("@"); int lastIndex = metadataPath.length - 1; @@ -225,7 +225,7 @@ public static List getAddableMetadataForMediaUnit(DataEditorForm dat * @return StructureElementViewInterface corresponding to structure element currently selected or to be added */ public static StructuralElementViewInterface getStructuralElementView(DataEditorForm dataEditor) { - Optional selectedStructure = dataEditor.getSelectedStructure(); + Optional selectedStructure = dataEditor.getSelectedStructure(); if (selectedStructure.isPresent()) { return dataEditor.getRulesetManagement() .getStructuralElementView( diff --git a/Kitodo/src/main/java/org/kitodo/production/services/dataformat/MetsService.java b/Kitodo/src/main/java/org/kitodo/production/services/dataformat/MetsService.java index e6ee3802da1..9bad929fe09 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/dataformat/MetsService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/dataformat/MetsService.java @@ -29,7 +29,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.MetadataEntry; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.api.dataformat.mets.MetsXmlElementAccessInterface; import org.kitodo.production.services.ServiceManager; @@ -67,22 +67,22 @@ private MetsService() { } /** - * Returns the type of the top element of the root element, and thus the + * Returns the type of the top element of the logical structure, and thus the * type of the workpiece. * * @param uri * Address of the METS file of the workpiece - * @return the type of root element of the root element of the workpiece + * @return the type of root element of the logical structure of the workpiece * @throws IOException * if the file cannot be read (for example, because the file was * not found) */ public String getBaseType(URI uri) throws IOException { - IncludedStructuralElement includedStructuralElement = loadWorkpiece(uri).getRootElement(); - String type = includedStructuralElement.getType(); - while (Objects.isNull(type) && !includedStructuralElement.getChildren().isEmpty()) { - includedStructuralElement = includedStructuralElement.getChildren().get(0); - type = includedStructuralElement.getType(); + LogicalDivision logicalDivision = loadWorkpiece(uri).getLogicalStructure(); + String type = logicalDivision.getType(); + while (Objects.isNull(type) && !logicalDivision.getChildren().isEmpty()) { + logicalDivision = logicalDivision.getChildren().get(0); + type = logicalDivision.getType(); } return type; } @@ -151,8 +151,8 @@ public void save(Workpiece workpiece, OutputStream outputStream) throws IOExcept * @return the number of tags */ public static long countLogicalMetadata(Workpiece workpiece) { - return Workpiece.treeStream(workpiece.getRootElement()) - .flatMap(includedStructuralElement -> includedStructuralElement.getMetadata().parallelStream()) + return Workpiece.treeStream(workpiece.getLogicalStructure()) + .flatMap(logicalDivision -> logicalDivision.getMetadata().parallelStream()) .filter(metadata -> !(metadata instanceof MetadataEntry) || Objects.nonNull(((MetadataEntry) metadata).getValue()) && !((MetadataEntry) metadata).getValue().isEmpty()) diff --git a/Kitodo/src/main/java/org/kitodo/production/services/file/FileService.java b/Kitodo/src/main/java/org/kitodo/production/services/file/FileService.java index da748098086..4e7ca56f371 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/file/FileService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/file/FileService.java @@ -37,7 +37,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.kitodo.api.command.CommandResult; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.MediaUnit; import org.kitodo.api.dataformat.MediaVariant; import org.kitodo.api.dataformat.View; @@ -1094,9 +1094,9 @@ public void searchForMedia(Process process, Workpiece workpiece) throws InvalidI if (ConfigCore.getBooleanParameter(ParameterCore.WITH_AUTOMATIC_PAGINATION)) { repaginateMediaUnits(workpiece); } - if (Workpiece.treeStream(workpiece.getRootElement()) - .allMatch(includedStructuralElement -> includedStructuralElement.getViews().isEmpty())) { - automaticallyAssignMediaUnitsToEffectiveRootRecursive(workpiece, workpiece.getRootElement()); + if (Workpiece.treeStream(workpiece.getLogicalStructure()) + .allMatch(logicalDivision -> logicalDivision.getViews().isEmpty())) { + automaticallyAssignMediaUnitsToEffectiveRootRecursive(workpiece, workpiece.getLogicalStructure()); } if (logger.isTraceEnabled()) { logger.trace("Searching for media took {} ms", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - begin)); @@ -1104,14 +1104,14 @@ public void searchForMedia(Process process, Workpiece workpiece) throws InvalidI } private void automaticallyAssignMediaUnitsToEffectiveRootRecursive(Workpiece workpiece, - IncludedStructuralElement includedStructuralElement) { + LogicalDivision logicalDivision) { - if (Objects.nonNull(includedStructuralElement.getType())) { + if (Objects.nonNull(logicalDivision.getType())) { Workpiece.treeStream(workpiece.getMediaUnit()).filter(mediaUnit -> !mediaUnit.getMediaFiles().isEmpty()) - .map(View::of).forEachOrdered(includedStructuralElement.getViews()::add); - } else if (includedStructuralElement.getChildren().size() == 1) { + .map(View::of).forEachOrdered(logicalDivision.getViews()::add); + } else if (logicalDivision.getChildren().size() == 1) { automaticallyAssignMediaUnitsToEffectiveRootRecursive(workpiece, - includedStructuralElement.getChildren().get(0)); + logicalDivision.getChildren().get(0)); } } @@ -1195,8 +1195,8 @@ private void addNewMediaToWorkpiece(List canonicals, Map children = includedStructuralElement.getChildren(); + private void assignViewsFromChildrenRecursive(LogicalDivision logicalDivision) { + List children = logicalDivision.getChildren(); if (!children.isEmpty()) { - for (IncludedStructuralElement child : children) { + for (LogicalDivision child : children) { assignViewsFromChildrenRecursive(child); } - if (Objects.nonNull(includedStructuralElement.getType())) { - MetadataEditor.assignViewsFromChildren(includedStructuralElement); + if (Objects.nonNull(logicalDivision.getType())) { + MetadataEditor.assignViewsFromChildren(logicalDivision); } } } @@ -123,7 +123,7 @@ private void set(Workpiece workpiece, MdSec domain, String key, String value) { entry.setKey(key); entry.setDomain(domain); entry.setValue(value); - workpiece.getRootElement().getMetadata().add(entry); + workpiece.getLogicalStructure().getMetadata().add(entry); } } @@ -228,7 +228,7 @@ private void addUse(Subfolder subfolder, String canonical, MediaUnit mediaUnit) * legacy ruleset wrapper * @return whether the current structure shall be deleted */ - private boolean convertChildrenLinksForExportRecursive(Workpiece workpiece, IncludedStructuralElement structure, + private boolean convertChildrenLinksForExportRecursive(Workpiece workpiece, LogicalDivision structure, LegacyPrefsHelper prefs) throws DAOException, IOException { LinkedMetsResource link = structure.getLink(); @@ -241,7 +241,7 @@ private boolean convertChildrenLinksForExportRecursive(Workpiece workpiece, Incl setLinkForExport(structure, process, prefs, workpiece); copyLabelAndOrderlabel(process, structure); } - for (Iterator iterator = structure.getChildren().iterator(); iterator.hasNext();) { + for (Iterator iterator = structure.getChildren().iterator(); iterator.hasNext();) { if (convertChildrenLinksForExportRecursive(workpiece, iterator.next(), prefs)) { iterator.remove(); } @@ -249,13 +249,13 @@ private boolean convertChildrenLinksForExportRecursive(Workpiece workpiece, Incl return false; } - private int enumerateLogicalDivisions(IncludedStructuralElement includedStructuralElement, int elementCount, + private int enumerateLogicalDivisions(LogicalDivision logicalDivision, int elementCount, int journalIssueCount, boolean journalIssue) { - boolean untyped = Objects.isNull(includedStructuralElement.getType()); - includedStructuralElement.setOrder(untyped ? 0 : (journalIssue ? journalIssueCount++ : elementCount)); - for (int i = 0; i < includedStructuralElement.getChildren().size(); i++) { - journalIssueCount = enumerateLogicalDivisions(includedStructuralElement.getChildren().get(i), i + 1, + boolean untyped = Objects.isNull(logicalDivision.getType()); + logicalDivision.setOrder(untyped ? 0 : (journalIssue ? journalIssueCount++ : elementCount)); + for (int i = 0; i < logicalDivision.getChildren().size(); i++) { + journalIssueCount = enumerateLogicalDivisions(logicalDivision.getChildren().get(i), i + 1, journalIssueCount, untyped); } return journalIssueCount; @@ -272,15 +272,15 @@ private void addLinksToParents(Process process, LegacyPrefsHelper prefs, Workpie private void addParentLinkForExport(LegacyPrefsHelper prefs, Workpiece workpiece, Process parent) throws IOException { - IncludedStructuralElement linkHolder = new IncludedStructuralElement(); + LogicalDivision linkHolder = new LogicalDivision(); linkHolder.setLink(new LinkedMetsResource()); setLinkForExport(linkHolder, parent, prefs, workpiece); - linkHolder.getChildren().add(workpiece.getRootElement()); + linkHolder.getChildren().add(workpiece.getLogicalStructure()); copyLabelAndOrderlabel(parent, linkHolder); - workpiece.setRootElement(linkHolder); + workpiece.setLogicalStructure(linkHolder); } - private void setLinkForExport(IncludedStructuralElement structure, Process process, LegacyPrefsHelper prefs, + private void setLinkForExport(LogicalDivision structure, Process process, LegacyPrefsHelper prefs, Workpiece workpiece) { LinkedMetsResource link = structure.getLink(); @@ -292,9 +292,9 @@ private void setLinkForExport(IncludedStructuralElement structure, Process proce structure.setType(ServiceManager.getProcessService().getBaseType(process)); } - private void copyLabelAndOrderlabel(Process source, IncludedStructuralElement destination) throws IOException { + private void copyLabelAndOrderlabel(Process source, LogicalDivision destination) throws IOException { URI sourceMetadataUri = processService.getMetadataFileUri(source); - IncludedStructuralElement sourceRoot = metsService.loadWorkpiece(sourceMetadataUri).getRootElement(); + LogicalDivision sourceRoot = metsService.loadWorkpiece(sourceMetadataUri).getLogicalStructure(); if (Objects.isNull(destination.getLabel())) { destination.setLabel(sourceRoot.getLabel()); } diff --git a/Kitodo/src/main/resources/log4j2.xml b/Kitodo/src/main/resources/log4j2.xml index c0488c2f1a6..a05150259e6 100644 --- a/Kitodo/src/main/resources/log4j2.xml +++ b/Kitodo/src/main/resources/log4j2.xml @@ -12,30 +12,17 @@ * --> - - /usr/local/kitodo/logs - - - - - - - - - - - - + + - diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 09f515f0a31..7ff3d555aa2 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -22,7 +22,7 @@ active=Aktiv ACTIVE=Aktiv activeUsers=Aktive Benutzer addElement=Element hinzuf\u00fcgen -addIncludedStructuralElement=Logisches Strukturelement hinzuf\u00fcgen +addLogicalDivision=Logisches Strukturelement hinzuf\u00fcgen addMediaUnit=Physisches Strukturelement hinzuf\u00fcgen addMessage=Nachricht hinzuf\u00FCgens addMessageForAll=Nachricht zu allen Prozessen hinzuf\u00FCgen @@ -827,7 +827,7 @@ removeElement=Element entfernen removeFilter=Filter entfernen removeFromAssociatedBatch=Selektierte Vorg\u00E4nge von ihren zugewiesenen Batches entfernen removeFromBatch=Die Zuordnungs des Vorgangs zu Batch {0} wurde aufgehoben. -removeIncludedStructuralElement=Logisches Strukturelement entfernen +removeLogicalDivision=Logisches Strukturelement entfernen removeMediaUnit=Physisches Strukturelement entfernen removeUser=Benutzer entfernen removeRole=Rolle entfernen diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index ae3cc3d8996..0e3ec10e558 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -22,7 +22,7 @@ active=Active ACTIVE=Active activeUsers=Current users addElement=Add element -addIncludedStructuralElement=Add logical structure element +addLogicalDivision=Add logical structure element addLdapGroup=Add LDAP group addLdapServer=Add LDAP server addMediaUnit=Add physical structure element @@ -841,7 +841,7 @@ removeElement=Remove element removeFilter=Remove filter from list removeFromAssociatedBatch=remove selected processes from assigned batches removeFromBatch=Removed process from batch {0}. -removeIncludedStructuralElement=Remove logical structure element +removeLogicalDivision=Remove logical structure element removeMediaUnit=Remove physical structure element removeUser=Remove user removeRole=Remove role diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/titleRecordLink.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/titleRecordLink.xhtml index 988161e57c1..830ae1ec6db 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/titleRecordLink.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/titleRecordLink.xhtml @@ -66,14 +66,14 @@ + rendered="#{CreateProcessForm.titleRecordLinkTab.logicalStructure.childCount ne 0}"> - - + result = (List) determineIncludedStructuralElementPathToChild - .invoke(null, includedStructuralElement, number); + List result = (List) determineLogicalDivisionPathToChild + .invoke(null, logicalDivision, number); - Assert.assertEquals(new LinkedList<>(Arrays.asList(includedStructuralElement, monthIncludedStructuralElement, - correctDayIncludedStructuralElement)), result); + Assert.assertEquals(new LinkedList<>(Arrays.asList(logicalDivision, monthLogicalDivision, + correctDayLogicalDivision)), result); } } diff --git a/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java b/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java index 5d76f201766..b4069f24c1e 100644 --- a/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/process/NewspaperProcessesGeneratorIT.java @@ -40,7 +40,7 @@ import org.kitodo.SecurityTestUtils; import org.kitodo.TreeDeleter; import org.kitodo.api.MetadataEntry; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.config.ConfigCore; import org.kitodo.config.enums.KitodoConfigFile; @@ -140,15 +140,15 @@ public void shouldGenerateNewspaperProcesses() throws Exception { * In the overall process and in the annual processes (both * {@code false}), the process title is saved in the root * element. In the issue process ({@code true}), it is in the - * issue, which is two levels below the root element. + * issue, which is two levels below the logical structure. */ private String readProcessTitleFromMetadata(int processId, boolean issue) throws DAOException, IOException { - IncludedStructuralElement rootElement = metsService - .loadWorkpiece(processService.getMetadataFileUri(processService.getById(processId))).getRootElement(); - IncludedStructuralElement includedStructuralElement = issue - ? rootElement.getChildren().get(0).getChildren().get(0) - : rootElement; - return includedStructuralElement.getMetadata().parallelStream() + LogicalDivision logicalStructure = metsService + .loadWorkpiece(processService.getMetadataFileUri(processService.getById(processId))).getLogicalStructure(); + LogicalDivision logicalDivision = issue + ? logicalStructure.getChildren().get(0).getChildren().get(0) + : logicalStructure; + return logicalDivision.getMetadata().parallelStream() .filter(metadata -> metadata.getKey().equals("ProcessTitle")).map(MetadataEntry.class::cast) .map(MetadataEntry::getValue).collect(Collectors.joining(" ; ")); } @@ -168,7 +168,7 @@ public void shouldGenerateSeasonProcesses() throws Exception { Process seasonProcess = ServiceManager.getProcessService().getById(10); URI seasonUri = processService.getMetadataFileUri(seasonProcess); Workpiece seasonMets = metsService.loadWorkpiece(seasonUri); - seasonMets.getRootElement().setType("Season"); + seasonMets.getLogicalStructure().setType("Season"); metsService.saveWorkpiece(seasonMets, seasonUri); Course course = NewspaperCourse.getCourse(); @@ -192,7 +192,7 @@ public void shouldGenerateSeasonProcesses() throws Exception { * Year identifier must be two consecutive integer years * separated by '/'. */ - String twoYears = workpiece.getRootElement().getOrderlabel(); + String twoYears = workpiece.getLogicalStructure().getOrderlabel(); List years = Arrays.asList(twoYears.split("/", 2)); Assert.assertTrue("Bad season-year in " + seasonProcess + ": " + twoYears, Integer.parseInt(years.get(0)) + 1 == Integer.parseInt(years.get(1))); @@ -211,12 +211,12 @@ public void shouldGenerateSeasonProcesses() throws Exception { private void dayChecksOfShouldGenerateSeasonProcesses(Process seasonProcess, Workpiece seasonYearWorkpiece) { // all days must be inside their month - for (IncludedStructuralElement monthIncludedStructuralElement : seasonYearWorkpiece.getRootElement() + for (LogicalDivision monthLogicalDivision : seasonYearWorkpiece.getLogicalStructure() .getChildren()) { - String monthValue = monthIncludedStructuralElement.getOrderlabel(); - for (IncludedStructuralElement dayIncludedStructuralElement : monthIncludedStructuralElement + String monthValue = monthLogicalDivision.getOrderlabel(); + for (LogicalDivision dayLogicalDivision : monthLogicalDivision .getChildren()) { - String dayValue = dayIncludedStructuralElement.getOrderlabel(); + String dayValue = dayLogicalDivision.getOrderlabel(); Assert.assertTrue( "Error in " + seasonProcess + ": " + dayValue + " misplaced in month " + monthValue + '!', dayValue.startsWith(monthValue)); @@ -224,12 +224,12 @@ private void dayChecksOfShouldGenerateSeasonProcesses(Process seasonProcess, Wor } // days must be ordered ascending - for (IncludedStructuralElement monthIncludedStructuralElement : seasonYearWorkpiece.getRootElement() + for (LogicalDivision monthLogicalDivision : seasonYearWorkpiece.getLogicalStructure() .getChildren()) { String previousDayValue = null; - for (IncludedStructuralElement dayIncludedStructuralElement : monthIncludedStructuralElement + for (LogicalDivision dayLogicalDivision : monthLogicalDivision .getChildren()) { - String dayValue = dayIncludedStructuralElement.getOrderlabel(); + String dayValue = dayLogicalDivision.getOrderlabel(); if (Objects.nonNull(previousDayValue)) { Assert.assertTrue("Bad order of days in " + seasonProcess + ": " + dayValue + " should be before " + previousDayValue + ", but isn’t!", @@ -243,9 +243,9 @@ private void dayChecksOfShouldGenerateSeasonProcesses(Process seasonProcess, Wor private void monthChecksOfShouldGenerateSeasonProcesses(Process seasonProcess, Workpiece seasonYearWorkpiece, String twoYears, List years) { // all months must be in the timespan - for (IncludedStructuralElement monthIncludedStructuralElement : seasonYearWorkpiece.getRootElement() + for (LogicalDivision monthLogicalDivision : seasonYearWorkpiece.getLogicalStructure() .getChildren()) { - String monthValue = monthIncludedStructuralElement.getOrderlabel(); + String monthValue = monthLogicalDivision.getOrderlabel(); List monthValueFields = Arrays.asList(monthValue.split("-", 2)); int monthNumberOfMonth = Integer.parseInt(monthValueFields.get(1)); if (monthValueFields.get(0).equals(years.get(0))) { @@ -264,9 +264,9 @@ private void monthChecksOfShouldGenerateSeasonProcesses(Process seasonProcess, W // months must be ordered ascending String previousMonthValue = null; - for (IncludedStructuralElement monthIncludedStructuralElement : seasonYearWorkpiece.getRootElement() + for (LogicalDivision monthLogicalDivision : seasonYearWorkpiece.getLogicalStructure() .getChildren()) { - String monthValue = monthIncludedStructuralElement.getOrderlabel(); + String monthValue = monthLogicalDivision.getOrderlabel(); if (Objects.nonNull(previousMonthValue)) { Assert.assertTrue("Bad order of months in " + seasonProcess + ": " + monthValue + " should be before " + previousMonthValue + ", but isn’t!", diff --git a/Kitodo/src/test/java/org/kitodo/production/process/ProcessValidatorIT.java b/Kitodo/src/test/java/org/kitodo/production/process/ProcessValidatorIT.java index 2f444446f44..147ec62d0c1 100644 --- a/Kitodo/src/test/java/org/kitodo/production/process/ProcessValidatorIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/process/ProcessValidatorIT.java @@ -109,12 +109,12 @@ public void propertyShouldNotExist() throws Exception { private List createProcessDetailsList() throws IOException { Workpiece workpiece = new Workpiece(); - workpiece.getRootElement().setType("Monograph"); + workpiece.getLogicalStructure().setType("Monograph"); RulesetManagementInterface rulesetManagementInterface = ServiceManager.getRulesetManagementService().getRulesetManagement(); rulesetManagementInterface.load(new File("src/test/resources/rulesets/monograph.xml")); StructuralElementViewInterface monograph = rulesetManagementInterface.getStructuralElementView( "Monograph", "", Locale.LanguageRange.parse("en")); - ProcessFieldedMetadata processDetails = new ProcessFieldedMetadata(workpiece.getRootElement(), monograph); + ProcessFieldedMetadata processDetails = new ProcessFieldedMetadata(workpiece.getLogicalStructure(), monograph); for (ProcessDetail detail : processDetails.getRows()) { switch (detail.getMetadataID()) { case "TitleDocMain": diff --git a/Kitodo/src/test/java/org/kitodo/production/process/TitleGeneratorTest.java b/Kitodo/src/test/java/org/kitodo/production/process/TitleGeneratorTest.java index 6141db8cea2..d5db365ed82 100644 --- a/Kitodo/src/test/java/org/kitodo/production/process/TitleGeneratorTest.java +++ b/Kitodo/src/test/java/org/kitodo/production/process/TitleGeneratorTest.java @@ -101,12 +101,12 @@ public void shouldGenerateTitle() throws Exception { static List createProcessDetailsList() throws IOException { Workpiece workpiece = new Workpiece(); - workpiece.getRootElement().setType("Monograph"); + workpiece.getLogicalStructure().setType("Monograph"); RulesetManagementInterface rulesetManagementInterface = ServiceManager.getRulesetManagementService().getRulesetManagement(); rulesetManagementInterface.load(new File("src/test/resources/rulesets/monograph.xml")); StructuralElementViewInterface monograph = rulesetManagementInterface.getStructuralElementView( "Monograph", "", Locale.LanguageRange.parse("en")); - ProcessFieldedMetadata processDetails = new ProcessFieldedMetadata(workpiece.getRootElement(), monograph); + ProcessFieldedMetadata processDetails = new ProcessFieldedMetadata(workpiece.getLogicalStructure(), monograph); for (ProcessDetail detail : processDetails.getRows()) { switch (detail.getMetadataID()) { case "TitleDocMain": diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java index 31c7c52184a..0df15a28ec5 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/ProcessServiceIT.java @@ -41,7 +41,7 @@ import org.kitodo.FileLoader; import org.kitodo.MockDatabase; import org.kitodo.SecurityTestUtils; -import org.kitodo.api.dataformat.IncludedStructuralElement; +import org.kitodo.api.dataformat.LogicalDivision; import org.kitodo.api.dataformat.Workpiece; import org.kitodo.api.dataformat.mets.LinkedMetsResource; import org.kitodo.config.ConfigCore; @@ -249,7 +249,7 @@ public void shouldFindByMetadataGroupContent() throws DataException { processService.findByTitle("Second Process"); assertEquals(processNotFound, 1, processService.findByAnything("August").size()); } - + @Test public void shouldFindByProperty() throws DataException { List processByProperty = processService.findByProperty("Process Property", "first value"); @@ -569,22 +569,22 @@ public void shouldNotBeProcessAssignedToOnlyOneBatch() throws Exception { } @Test - public void shouldUpdateChildrenFromRootElement() throws Exception { + public void shouldUpdateChildrenFromLogicalStructure() throws Exception { LinkedMetsResource childToKeepLink = new LinkedMetsResource(); childToKeepLink.setUri(processService.getProcessURI(processService.getById(5))); - IncludedStructuralElement childToKeepIncludedStructuralElement = new IncludedStructuralElement(); - childToKeepIncludedStructuralElement.setLink(childToKeepLink); - IncludedStructuralElement rootElement = new IncludedStructuralElement(); - rootElement.getChildren().add(childToKeepIncludedStructuralElement); + LogicalDivision childToKeepLogicalDivision = new LogicalDivision(); + childToKeepLogicalDivision.setLink(childToKeepLink); + LogicalDivision logicalStructure = new LogicalDivision(); + logicalStructure.getChildren().add(childToKeepLogicalDivision); LinkedMetsResource childToAddLink = new LinkedMetsResource(); childToAddLink.setUri(processService.getProcessURI(processService.getById(7))); - IncludedStructuralElement childToAddIncludedStructuralElement = new IncludedStructuralElement(); - childToAddIncludedStructuralElement.setLink(childToAddLink); - rootElement.getChildren().add(childToAddIncludedStructuralElement); + LogicalDivision childToAddLogicalDivision = new LogicalDivision(); + childToAddLogicalDivision.setLink(childToAddLink); + logicalStructure.getChildren().add(childToAddLogicalDivision); Process process = processService.getById(4); - processService.updateChildrenFromRootElement(process, rootElement); + processService.updateChildrenFromLogicalStructure(process, logicalStructure); for (Process child : process.getChildren()) { assertTrue("Process should have child to keep and child to add as only children", diff --git a/Kitodo/src/test/java/org/kitodo/production/services/dataformat/MetsServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/dataformat/MetsServiceIT.java index 6471f048767..7dc58fbea42 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/dataformat/MetsServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/dataformat/MetsServiceIT.java @@ -37,13 +37,13 @@ public void testReadXML() throws Exception { assertEquals(183, workpiece.getMediaUnit().getChildren().size()); // METS file has 17 unstructured images - assertEquals(17, workpiece.getRootElement().getViews().size()); + assertEquals(17, workpiece.getLogicalStructure().getViews().size()); // root node has 16 children - assertEquals(16, workpiece.getRootElement().getChildren().size()); + assertEquals(16, workpiece.getLogicalStructure().getChildren().size()); // root node has 11 metadata entries - assertEquals(11, workpiece.getRootElement().getMetadata().size()); + assertEquals(11, workpiece.getLogicalStructure().getMetadata().size()); // file URIs can be read assertEquals(new URI("images/ThomPhar_644901748_media/00000001.tif"), diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessFromTemplatePage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessFromTemplatePage.java index 1ac972957fb..f1d8c64782a 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessFromTemplatePage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessFromTemplatePage.java @@ -41,8 +41,8 @@ public class ProcessFromTemplatePage extends EditPage { private WebElement guessImagesInput; @SuppressWarnings("unused") - @FindBy(id = TAB_VIEW + ":rootElement") - private WebElement rootElementTree; + @FindBy(id = TAB_VIEW + ":logicalStructure") + private WebElement logicalStructureTree; @SuppressWarnings("unused") @FindBy(id = TAB_VIEW + ":docType") @@ -193,7 +193,7 @@ public String createProcessAsChild(String parentProcessTitle) throws Exception { clickElement(chooseParentSelect.findElement(By.cssSelector(CSS_SELECTOR_DROPDOWN_TRIGGER))); clickElement(Browser.getDriver().findElement(By.id(chooseParentSelect.getAttribute("id") + "_1"))); await("Wait for tree shows").pollDelay(500, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS) - .ignoreExceptions().until(() -> isDisplayed.test(rootElementTree)); + .ignoreExceptions().until(() -> isDisplayed.test(logicalStructureTree)); save(); return generatedTitle; }