Skip to content

Commit

Permalink
Changes regarding review
Browse files Browse the repository at this point in the history
  • Loading branch information
markusweigelt committed Jan 24, 2024
1 parent da54202 commit d978e67
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void getAllSubViews(LogicalDivision selectedStructure, Collection<View>
}

void deleteSelectedPhysicalDivision() {
if (Objects.nonNull(selectedLogicalNode) && StructurePanel.MEDIA_PARTIAL_NODE_TYPE.equals(
if (Objects.nonNull(selectedLogicalNode) && MEDIA_PARTIAL_NODE_TYPE.equals(
selectedLogicalNode.getType()) && selectedLogicalNode.getData() instanceof StructureTreeNode) {
StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData();
PhysicalDivision physicalDivision = ((View) structureTreeNode.getDataObject()).getPhysicalDivision();
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ jumpBackwardTenMilliseconds=10 Millisekunden zur\u00FCckspringen
jumpBackwardOneMillisecond=1 Millisekunde zur\u00FCckspringen
jumpForwardOneMillisecond=1 Millisekunde vorspringen
jumpForwardTenMilliseconds=10 Millisekunden vorspringen
jumpForwardOnHundredMilliseconds=100 Millisekunden vorspringen
jumpForwardOneHundredMilliseconds=100 Millisekunden vorspringen
jumpForwardOneSecond=1 Sekunde vorspringen
kitodoScript.generateImages.error.noSourceFiles=Bilder f\u00FCr Vorgang {0} k\u00F6nnen nicht erzeugt werden: Quellordner {1} hat keinen Inhalt.
kitodoScript.generateImages.error.noSourceFolder=Bilder f\u00FCr Vorgang {0} k\u00F6nnen nicht erzeugt werden: Im Projekt {1} wurde kein Quellordner festgelegt.
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ jumpBackwardTenMilliseconds=Jump backward 10 milliseconds
jumpBackwardOneMillisecond=Jump backward 1 millisecond
jumpForwardOneMillisecond=Jump forward 1 millisecond
jumpForwardTenMilliseconds=Jump forward 10 milliseconds
jumpForwardOnHundredMilliseconds=Jump forward 100 milliseconds
jumpForwardOneHundredMilliseconds=Jump forward 100 milliseconds
jumpForwardOneSecond=Jump forward 1 second
kitodoScript.generateImages.error.noSourceFiles=Cannot generate images for process {0}: No contents found in source folder {1}
kitodoScript.generateImages.error.noSourceFolder=Cannot generate images for process {0}: Project {1} has no source folder defined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
rendered="#{logicalNode.assignedSeveralTimes}"
styleClass="assigned-several-times"/>
</p:treeNode>
<p:treeNode type="#{StructurePanel.MEDIA_PARTIAL_NODE_TYPE}"
<p:treeNode type="#{DataEditorForm.structurePanel.MEDIA_PARTIAL_NODE_TYPE}"
icon="ui-icon-media-partial">
<h:outputText value="#{empty logicalNode.label ? msgs['dataEditor.withoutType'] : logicalNode.label}"
title="#{logicalNode.undefined ? msgs['dataEditor.undefinedStructure'] : ''}"
Expand Down Expand Up @@ -214,7 +214,7 @@
disabled="#{readOnly}"
process="@this"/>
<p:menuitem value="#{DataEditorForm.structurePanel.selectedLogicalNode.data.linked ? msgs.unlinkProcess : msgs.removeElement}"
rendered="#{DataEditorForm.structurePanel.selectedLogicalNode.data.dataObject ne null and DataEditorForm.structurePanel.selectedLogicalNode.type ne StructurePanel.VIEW_NODE_TYPE and DataEditorForm.structurePanel.selectedLogicalNode.type ne StructurePanel.MEDIA_PARTIAL_NODE_TYPE}"
rendered="#{DataEditorForm.structurePanel.selectedLogicalNode.data.dataObject ne null and DataEditorForm.structurePanel.selectedLogicalNode.type ne DataEditorForm.structurePanel.VIEW_NODE_TYPE and DataEditorForm.structurePanel.selectedLogicalNode.type ne DataEditorForm.structurePanel.MEDIA_PARTIAL_NODE_TYPE}"
icon="fa fa-trash fa-sm"
styleClass="plain"
disabled="#{readOnly}"
Expand All @@ -241,7 +241,7 @@
metadataAccordion:logicalMetadataWrapperPanel
galleryWrapperPanel"/>
<p:menuitem value="#{msgs.deleteMediaPartial}"
rendered="#{SecurityAccessController.hasAuthorityToDeleteMedia() and DataEditorForm.structurePanel.selectedLogicalNode.type eq StructurePanel.MEDIA_PARTIAL_NODE_TYPE}"
rendered="#{SecurityAccessController.hasAuthorityToDeleteMedia() and DataEditorForm.structurePanel.selectedLogicalNode.type eq DataEditorForm.structurePanel.MEDIA_PARTIAL_NODE_TYPE}"
icon="fa fa-trash fa-sm"
styleClass="plain"
disabled="#{readOnly}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
icon="fa fa-angle-double-right"
styleClass="media-formatted-time-jump-button secondary"
a:data-media-formatted-time-jump-milliseconds="10"/>
<p:commandButton title="#{msgs.jumpForwardOnHundredMilliseconds}"
<p:commandButton title="#{msgs.jumpForwardOneHundredMilliseconds}"
type="button"
icon="fa fa-chevron-right"
styleClass="media-formatted-time-jump-button secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
a:data-order="#{physicalNode.order}"/>
<h:outputText value=" 🔗" rendered="#{physicalNode.linked}"/>
</p:treeNode>
<p:treeNode type="#{StructurePanel.MEDIA_PARTIAL_NODE_TYPE}"
<p:treeNode type="#{DataEditorForm.structurePanel.MEDIA_PARTIAL_NODE_TYPE}"
icon="ui-icon-media-partial">
<h:outputText
value="#{physicalNode.label}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

package org.kitodo.production.forms.dataeditor;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -103,9 +103,10 @@ public void testSave() {
// overwrite to test save function
LinkedList<PhysicalDivision> ancestorsOfPhysicalDivision = new LinkedList<>();
ancestorsOfPhysicalDivision.add(new PhysicalDivision());
MockedStatic<MetadataEditor> metadataEditorMockedStatic = Mockito.mockStatic(MetadataEditor.class);
metadataEditorMockedStatic.when(() -> MetadataEditor.getAncestorsOfPhysicalDivision(physicalDivision, physicalStructure))
.thenReturn(ancestorsOfPhysicalDivision);
try (MockedStatic<MetadataEditor> metadataEditorMockedStatic = Mockito.mockStatic(MetadataEditor.class)) {
metadataEditorMockedStatic.when(() -> MetadataEditor.getAncestorsOfPhysicalDivision(physicalDivision, physicalStructure))
.thenReturn(ancestorsOfPhysicalDivision);
}

// add media partial

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

package org.kitodo.production.forms.dataeditor;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.List;

import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.kitodo.api.dataformat.LogicalDivision;
Expand Down Expand Up @@ -47,22 +47,22 @@ public void initTest() {
@Test
public void testGenerateExtentAndSortMediaPartials() {
List<LogicalDivision> logicalDivisions = new ArrayList<>();
logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:45.001"));
logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:00.002"));
logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:55.894"));
logicalDivisions.add(getLogicalDivisionWithMediaPartial("Lorem ipsum", "00:00:35.123"));
logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:45.001"));
logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:00.002"));
logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:55.894"));
logicalDivisions.add(getLogicalDivisionWithMediaPartial("00:00:35.123"));

// one minute media duration
MediaPartialHelper.calculateExtentAndSortMediaPartials(logicalDivisions, 60000L);

Assert.assertEquals("00:00:00.002", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getBegin());
Assert.assertEquals("00:00:35.121", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getExtent());
Assert.assertEquals("00:00:35.123", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getBegin());
Assert.assertEquals("00:00:09.878", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getExtent());
Assert.assertEquals("00:00:45.001", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getBegin());
Assert.assertEquals("00:00:10.893", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getExtent());
Assert.assertEquals("00:00:55.894", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getBegin());
Assert.assertEquals("00:00:04.106", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getExtent());
assertEquals("00:00:00.002", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getBegin());
assertEquals("00:00:35.121", getMediaPartialOfLogicalDivision(logicalDivisions, 0).getExtent());
assertEquals("00:00:35.123", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getBegin());
assertEquals("00:00:09.878", getMediaPartialOfLogicalDivision(logicalDivisions, 1).getExtent());
assertEquals("00:00:45.001", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getBegin());
assertEquals("00:00:10.893", getMediaPartialOfLogicalDivision(logicalDivisions, 2).getExtent());
assertEquals("00:00:55.894", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getBegin());
assertEquals("00:00:04.106", getMediaPartialOfLogicalDivision(logicalDivisions, 3).getExtent());
}

private static MediaPartial getMediaPartialOfLogicalDivision(List<LogicalDivision> logicalDivisions, int index) {
Expand All @@ -78,7 +78,7 @@ public void testMediaDurationValidation() {
when(mediaPartialsPanel.getMediaDuration()).thenReturn("123456");
assertEquals("mediaPartialFormMediaDurationWrongTimeFormat", mediaPartialsPanel.validateMediaDuration());
when(mediaPartialsPanel.getMediaDuration()).thenReturn("00:01:00.000");
Assert.assertNull(mediaPartialsPanel.validateMediaDuration());
assertNull(mediaPartialsPanel.validateMediaDuration());
}

/**
Expand All @@ -90,9 +90,9 @@ public void testConverting() {
assertEquals("01:01:01.120", MediaPartialHelper.convertMillisecondsToFormattedTime(3661120L));
}

private static LogicalDivision getLogicalDivisionWithMediaPartial(String label, String begin) {
private static LogicalDivision getLogicalDivisionWithMediaPartial(String begin) {
LogicalDivision logicalDivision = new LogicalDivision();
logicalDivision.setLabel(label);
logicalDivision.setLabel("Lorem ipsum");
PhysicalDivision physicalDivision = new PhysicalDivision();
MediaPartial mediaPartial = new MediaPartial(begin);
physicalDivision.setMediaPartial(mediaPartial);
Expand Down

0 comments on commit d978e67

Please sign in to comment.