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 01b20a4bc94..b6c2f371bdf 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 @@ -147,7 +147,7 @@ public ProcessFieldedMetadata getPhysicalMetadataTable() { } void showLogical(Optional optionalStructure) { - if (optionalStructure.isPresent()) { + if (optionalStructure.isPresent() && Objects.isNull(optionalStructure.get().getLink())) { logicalMetadataTable = createProcessFieldedMetadata(optionalStructure.get()); dataEditorForm.getAddMetadataDialog().prepareAddableMetadataForStructure( getLogicalMetadataRows().getChildren()); 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 c116800b786..7a3d9619688 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 @@ -1363,16 +1363,17 @@ private void checkLogicalDragDrop(StructureTreeNode dragNode, StructureTreeNode dropStructure.getType(), dataEditor.getAcquisitionStage(), dataEditor.getPriorityList()); LinkedList dragParents; - if (divisionView.getAllowedSubstructuralElements().containsKey(dragStructure.getType())) { + if (divisionView.getAllowedSubstructuralElements().containsKey(dragStructure.getType()) + || Objects.nonNull(dragStructure.getLink())) { dragParents = MetadataEditor.getAncestorsOfLogicalDivision(dragStructure, dataEditor.getWorkpiece().getLogicalStructure()); if (!dragParents.isEmpty()) { LogicalDivision parentStructure = dragParents.get(dragParents.size() - 1); if (parentStructure.getChildren().contains(dragStructure)) { - if (!this.logicalStructureTreeContainsMedia()) { - preserveLogical(); - } else { + if (logicalStructureTreeContainsMedia()) { preserveLogicalAndPhysical(); + } else { + preserveLogical(); } this.dataEditor.getGalleryPanel().updateStripes(); this.dataEditor.getPaginationPanel().show(); 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 2248fc3cd6e..4e91ff68e09 100644 --- a/Kitodo/src/main/java/org/kitodo/production/metadata/MetadataEditor.java +++ b/Kitodo/src/main/java/org/kitodo/production/metadata/MetadataEditor.java @@ -131,7 +131,7 @@ private static void addLink(LogicalDivision parentLogicalDivision, int index, * Remove link to process with ID 'childProcessId' from workpiece of Process 'parentProcess'. * * @param parentProcess Process from which link is removed - * @param childProcessId ID of process whose link will be remove from workpiece of parent process + * @param childProcessId ID of process whose link will be removed from workpiece of parent process * @throws IOException thrown if meta.xml could not be loaded */ public static void removeLink(Process parentProcess, int childProcessId) throws IOException { 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 b0e82820260..38d5a17cba2 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 @@ -177,8 +177,10 @@ public static List getAddableMetadataForStructureElement(DataEditorF Collection additionalFields = isLogicalStructure ? dataEditor.getMetadataPanel() .getLogicalMetadataTable().getAdditionallySelectedFields() : dataEditor.getMetadataPanel() .getPhysicalMetadataTable().getAdditionallySelectedFields(); - addableMetadata = getAddableMetadataForStructureElement(structureView, existingMetadata, - additionalFields, dataEditor.getProcess().getRuleset()); + if (Objects.nonNull(structureView)) { + addableMetadata = getAddableMetadataForStructureElement(structureView, existingMetadata, + additionalFields, dataEditor.getProcess().getRuleset()); + } } catch (InvalidMetadataValueException e) { Helper.setErrorMessage(e); } @@ -245,22 +247,46 @@ public static StructuralElementViewInterface getStructuralElementView(DataEditor .getStructuralElementView( selectedStructure.get().getType(), dataEditor.getAcquisitionStage(), dataEditor.getPriorityList()); - } else { - TreeNode selectedLogicalNode = dataEditor.getStructurePanel().getSelectedLogicalNode(); - if (Objects.nonNull(selectedLogicalNode) - && selectedLogicalNode.getData() instanceof StructureTreeNode) { - StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData(); - if (structureTreeNode.getDataObject() instanceof View) { - View view = (View) structureTreeNode.getDataObject(); - if (Objects.nonNull(view.getPhysicalDivision())) { - return dataEditor.getRulesetManagement().getStructuralElementView( - view.getPhysicalDivision().getType(), - dataEditor.getAcquisitionStage(), dataEditor.getPriorityList()); - } - } + } + + TreeNode selectedLogicalNode = dataEditor.getStructurePanel().getSelectedLogicalNode(); + + if (Objects.isNull(selectedLogicalNode)) { + throw new IllegalStateException("No logical node selected!"); + } + + if (!(selectedLogicalNode.getData() instanceof StructureTreeNode)) { + String nodeClass = "unknown"; + if (Objects.nonNull(selectedLogicalNode.getData())) { + nodeClass = selectedLogicalNode.getData().getClass().getName(); } + throw new IllegalStateException("Selected logical node data has wrong type '" + nodeClass + + "'! ('StructureTreeNode' expected)"); + } + StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData(); + + Object dataObject = structureTreeNode.getDataObject(); + + // data object is null for structures inside parent processes + if (Objects.isNull(dataObject)) { + return null; + } + + if (dataObject instanceof View) { + View view = (View) dataObject; + if (Objects.isNull(view.getPhysicalDivision())) { + throw new IllegalStateException("View has no physical division assigned!"); + } + return dataEditor.getRulesetManagement().getStructuralElementView( + view.getPhysicalDivision().getType(), + dataEditor.getAcquisitionStage(), dataEditor.getPriorityList()); + } + + // data object is a sibling process + if (dataObject instanceof Process) { + return null; } - throw new IllegalStateException(); + throw new IllegalStateException("Data object has unknown type '" + dataObject.getClass().getName() + "'!"); } /** diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 81868e158ed..e94fc4e8aa0 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -1102,6 +1102,7 @@ unassignTasks=Aufgaben zur\u00FCcksetzen unit=Einheit uncounted=unnummeriert unknown=Unbekannt +unlinkProcess=Prozessverkn\u00FCpfung aufheben unlocked=Entsperrt up=hoch updateFileReferences=Aktualisierung der Dateireferenzen diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 95ba7f0217b..1f44d972924 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -1102,6 +1102,7 @@ unassignTasks=Unassign Tasks unit=unit uncounted=uncounted unknown=Unknown +unlinkProcess=Unlink process unlocked=Unlocked up=up updateFileReferences=Update file references diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index db2d86986bf..c0990147ecf 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -2545,11 +2545,6 @@ Column content .ui-tree .ui-treenode.linked { background: transparent; - cursor: not-allowed; -} - -.ui-tree .ui-treenode.linked span { - pointer-events: none; } .ui-tree .ui-treenode.undefined .ui-treenode-label span { diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalMetadata.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalMetadata.xhtml index 2a47efd9d03..07ec768e9eb 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalMetadata.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/logicalMetadata.xhtml @@ -35,6 +35,7 @@ rendered="#{not readOnly}"> - dummyProcessIds = new LinkedList<>(); + private static final String PARENT_PROCESS_TITLE = "Parent process"; + private static final String FIRST_CHILD_PROCESS_TITLE = "First child process"; + private static final String SECOND_CHILD_PROCESS_TITLE = "Second child process"; + private static final String TEST_PARENT_PROCESS_METADATA_FILE = "testParentProcessMeta.xml"; + private static final String FIRST_CHILD_ID = "FIRST_CHILD_ID"; + private static final String SECOND_CHILD_ID = "SECOND_CHILD_ID"; + private static final String META_XML = "/meta.xml"; + private static List processHierarchyTestProcessIds = new LinkedList<>(); + private static final int TEST_PROJECT_ID = 1; + private static final int TEST_TEMPLATE_ID = 1; - /** - * Prepare file system, database and search index for tests. - * @throws DAOException when inserting processes into database fails - * @throws DataException when inserting processes into index fails - * @throws IOException when copying test files fails - */ - private static void prepareMediaReferenceProcesses() throws DAOException, DataException, IOException { + private static void prepareMediaReferenceProcess() throws DAOException, DataException, IOException { + insertDummyProcesses(); insertTestProcessForMediaReferencesTest(); copyTestFilesForMediaReferences(); } private static void prepareMetadataLockProcess() throws DAOException, DataException, IOException { + insertDummyProcesses(); insertTestProcessForMetadataLockTest(); copyTestMetadataFile(metadataLockProcessId, TEST_METADATA_LOCK_FILE); } + private static void prepareProcessHierarchyProcesses() throws DAOException, IOException, DataException { + insertDummyProcesses(); + processHierarchyTestProcessIds = linkProcesses(); + copyTestParentProcessMetadataFile(); + updateChildProcessIdsInParentProcessMetadataFile(); + } + /** * Prepare tests by inserting dummy processes into database and index for sub-folders of test metadata resources. * @throws DAOException when saving of dummy or test processes fails. @@ -75,10 +95,9 @@ private static void prepareMetadataLockProcess() throws DAOException, DataExcept @BeforeClass public static void prepare() throws DAOException, DataException, IOException { MockDatabase.insertFoldersForSecondProject(); - insertDummyProcesses(); prepareMetadataLockProcess(); - insertDummyProcesses(); - prepareMediaReferenceProcesses(); + prepareMediaReferenceProcess(); + prepareProcessHierarchyProcesses(); } /** @@ -113,6 +132,27 @@ public void removeMetadataLockTest() throws Exception { Browser.getCurrentUrl().contains("metadataEditor.jsf")); } + /** + * Verifies that linked child processes can be reordered via drag'n'drop in the metadata editor. + * @throws Exception if processes cannot be saved or loaded + */ + @Test + public void changeProcessLinkOrderTest() throws Exception { + login("kowal"); + Pages.getProcessesPage().goTo().editParentProcessMetadata(); + Assert.assertTrue("Wrong initial order of linked child processes", + Pages.getMetadataEditorPage().getNameOfFirstLinkedChildProcess().endsWith(FIRST_CHILD_PROCESS_TITLE)); + Assert.assertTrue("Wrong initial order of linked child processes", + Pages.getMetadataEditorPage().getNameOfSecondLinkedChildProcess().endsWith(SECOND_CHILD_PROCESS_TITLE)); + Pages.getMetadataEditorPage().changeOrderOfLinkedChildProcesses(); + Pages.getMetadataEditorPage().saveAndExit(); + Pages.getProcessesPage().goTo().editParentProcessMetadata(); + Assert.assertTrue("Wrong resulting order of linked child processes", + Pages.getMetadataEditorPage().getNameOfFirstLinkedChildProcess().endsWith(SECOND_CHILD_PROCESS_TITLE)); + Assert.assertTrue("Wrong resulting order of linked child processes", + Pages.getMetadataEditorPage().getNameOfSecondLinkedChildProcess().endsWith(FIRST_CHILD_PROCESS_TITLE)); + } + /** * Tests total number of scans. */ @@ -171,6 +211,9 @@ public void closeEditorAndLogout() throws Exception { */ @AfterClass public static void cleanup() throws DAOException, CustomResponseException, DataException, IOException { + for (int processId : processHierarchyTestProcessIds) { + ProcessService.deleteProcess(processId); + } for (int dummyProcessId : dummyProcessIds) { ServiceManager.getProcessService().removeFromDatabase(dummyProcessId); ServiceManager.getProcessService().removeFromIndex(dummyProcessId, false); @@ -192,6 +235,34 @@ private static void insertTestProcessForMetadataLockTest() throws DAOException, metadataLockProcessId = MockDatabase.insertTestProcessForMetadataLockTestIntoSecondProject(); } + /** + * Creates dummy parent process and links first two test processes as child processes to parent process. + * @throws DAOException if loading of processes fails + * @throws DataException if saving of processes fails + */ + private static List linkProcesses() throws DAOException, DataException { + List processIds = new LinkedList<>(); + List childProcesses = new LinkedList<>(); + childProcesses.add(addProcess(FIRST_CHILD_PROCESS_TITLE)); + childProcesses.add(addProcess(SECOND_CHILD_PROCESS_TITLE)); + Process parentProcess = addProcess(PARENT_PROCESS_TITLE); + parentProcess.getChildren().addAll(childProcesses); + ServiceManager.getProcessService().save(parentProcess); + parentProcessId = parentProcess.getId(); + for (Process childProcess : childProcesses) { + childProcess.setParent(parentProcess); + ServiceManager.getProcessService().save(childProcess); + processIds.add(childProcess.getId()); + } + processIds.add(parentProcess.getId()); + return processIds; + } + + private static Process addProcess(String processTitle) throws DAOException, DataException { + insertDummyProcesses(); + return MockDatabase.addProcess(processTitle, TEST_PROJECT_ID, TEST_TEMPLATE_ID); + } + private static void insertDummyProcesses() throws DAOException, DataException { dummyProcessIds = new LinkedList<>(); List processIds = ServiceManager.getProcessService().getAll().stream().map(Process::getId) @@ -219,7 +290,7 @@ private static void copyTestFilesForMediaReferences() throws IOException { + "/images/").toUri(); try { if (!ServiceManager.getFileService().isDirectory(targetImages)) { - ServiceManager.getFileService().createDirectory(processDir, "images"); + ServiceManager.getFileService().createDirectory(processDir, TEST_IMAGES_DIR); } ServiceManager.getFileService().copyDirectory(testImagesUri, targetImages); } catch (IOException e) { @@ -232,7 +303,7 @@ private static void copyTestMetadataFile(int processId, String filename) throws URI processDir = Paths.get(ConfigCore.getKitodoDataDirectory(), String.valueOf(processId)) .toUri(); URI processDirTargetFile = Paths.get(ConfigCore.getKitodoDataDirectory(), processId - + "/meta.xml").toUri(); + + META_XML).toUri(); URI metaFileUri = Paths.get(ConfigCore.getKitodoDataDirectory(), filename).toUri(); if (!ServiceManager.getFileService().isDirectory(processDir)) { ServiceManager.getFileService().createDirectory(Paths.get(ConfigCore.getKitodoDataDirectory()).toUri(), @@ -240,4 +311,19 @@ private static void copyTestMetadataFile(int processId, String filename) throws } ServiceManager.getFileService().copyFile(metaFileUri, processDirTargetFile); } + + private static void copyTestParentProcessMetadataFile() throws IOException { + copyTestMetadataFile(parentProcessId, TEST_PARENT_PROCESS_METADATA_FILE); + } + + private static void updateChildProcessIdsInParentProcessMetadataFile() throws IOException, DAOException { + Process parentProcess = ServiceManager.getProcessService().getById(parentProcessId); + Path metaXml = Paths.get(ConfigCore.getKitodoDataDirectory(), parentProcessId + META_XML); + String xmlContent = Files.readString(metaXml); + String firstChildId = String.valueOf(parentProcess.getChildren().get(0).getId()); + String secondChildId = String.valueOf(parentProcess.getChildren().get(1).getId()); + xmlContent = xmlContent.replaceAll(FIRST_CHILD_ID, String.valueOf(firstChildId)); + xmlContent = xmlContent.replaceAll(SECOND_CHILD_ID, String.valueOf(secondChildId)); + Files.write(metaXml, xmlContent.getBytes()); + } } diff --git a/Kitodo/src/test/java/org/kitodo/selenium/WorkingST.java b/Kitodo/src/test/java/org/kitodo/selenium/WorkingST.java index 96eea717ad9..a5c8778748f 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/WorkingST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/WorkingST.java @@ -156,7 +156,7 @@ public void downloadLogTest() throws Exception { @Test public void editMetadataTest() throws Exception { - processesPage.goTo().editMetadata(); + processesPage.goTo().editSecondProcessMetadata(); assertTrue("Redirection after click edit metadata was not successful", Pages.getMetadataEditorPage().isAt()); } diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java index 929bd3862d1..0ba56fedb0b 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java @@ -11,7 +11,12 @@ package org.kitodo.selenium.testframework.pages; +import org.kitodo.selenium.testframework.Browser; +import org.kitodo.selenium.testframework.Pages; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; public class MetadataEditorPage extends Page { @@ -42,6 +47,18 @@ public class MetadataEditorPage extends Page { @FindBy(id = "buttonForm:save") private WebElement saveButton; + @FindBy(id = "buttonForm:saveExit") + private WebElement saveAndExitButton; + + @FindBy(id = "logicalTree:0") + private WebElement logicalTree; + + @FindBy(id = "logicalTree:0_0") + private WebElement firstChildProcess; + + @FindBy(id = "logicalTree:0_1") + private WebElement secondChildProcess; + public MetadataEditorPage() { super("metadataEditor.jsf"); } @@ -107,4 +124,29 @@ public void closeEditor() { public void save() { saveButton.click(); } + + /** + * Change order of child processes in metadata editor by moving the second child process before + * the first child process via drag and drop. + */ + public void changeOrderOfLinkedChildProcesses() { + secondChildProcess.click(); + WebDriver webDriver = Browser.getDriver(); + Actions moveAction = new Actions(webDriver); + WebElement dropArea = logicalTree.findElement(By.className("ui-tree-droppoint")); + moveAction.dragAndDrop(secondChildProcess, dropArea).build().perform(); + } + + public ProcessesPage saveAndExit() throws InstantiationException, IllegalAccessException { + clickButtonAndWaitForRedirect(saveAndExitButton, Pages.getProcessesPage().getUrl()); + return Pages.getProcessesPage(); + } + + public String getNameOfFirstLinkedChildProcess() { + return firstChildProcess.getText(); + } + + public String getNameOfSecondLinkedChildProcess() { + return secondChildProcess.getText(); + } } diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java index 2dba9aba2df..75c86cb5102 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProcessesPage.java @@ -26,6 +26,7 @@ import org.kitodo.selenium.testframework.Pages; import org.kitodo.selenium.testframework.enums.TabIndex; import org.openqa.selenium.By; +import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.Select; @@ -39,7 +40,8 @@ public class ProcessesPage extends Page { private static final String PROCESSES_TABLE_HEADER = PROCESSES_TABLE + "_head"; private static final String FILTER_FORM = "filterMenu"; private static final String FILTER_INPUT = "filterMenu:filterfield"; - private static final String PROCESS_TITLE = "Second process"; + private static final String SECOND_PROCESS_TITLE = "Second process"; + private static final String PARENT_PROCESS_TITLE = "Parent process"; private static final String WAIT_FOR_ACTIONS_BUTTON = "Wait for actions menu button"; private static final String WAIT_FOR_ACTIONS_MENU = "Wait for actions menu to open"; private static final String WAIT_FOR_COLUMN_SORT = "Wait for column sorting"; @@ -271,7 +273,7 @@ public void downloadDocketForBatch() throws Exception { await("Wait for docket file download").pollDelay(700, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS) .ignoreExceptions() - .until(() -> isFileDownloaded.test(new File(Browser.DOWNLOAD_DIR + PROCESS_TITLE + ".pdf"))); + .until(() -> isFileDownloaded.test(new File(Browser.DOWNLOAD_DIR + SECOND_PROCESS_TITLE + ".pdf"))); } public void downloadDocket() { @@ -280,7 +282,7 @@ public void downloadDocket() { await("Wait for docket file download").pollDelay(700, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS) .ignoreExceptions().until(() -> isFileDownloaded.test( - new File(Browser.DOWNLOAD_DIR + Helper.getNormalizedTitle(PROCESS_TITLE) + ".pdf"))); + new File(Browser.DOWNLOAD_DIR + Helper.getNormalizedTitle(SECOND_PROCESS_TITLE) + ".pdf"))); } public void downloadLog() { @@ -290,7 +292,7 @@ public void downloadLog() { await("Wait for log file download").pollDelay(700, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS) .ignoreExceptions() .until(() -> isFileDownloaded.test(new File(KitodoConfig.getParameter(ParameterCore.DIR_USERS) - + "kowal/" + Helper.getNormalizedTitle(PROCESS_TITLE) + "_log.xml"))); + + "kowal/" + Helper.getNormalizedTitle(SECOND_PROCESS_TITLE) + "_log.xml"))); } /** @@ -299,7 +301,7 @@ public void downloadLog() { * @throws InstantiationException when retrieving metadata editor page fails */ public void editMetadata() throws IllegalAccessException, InstantiationException { - setEditMetadataLink(PROCESS_TITLE); + setEditMetadataLink(SECOND_PROCESS_TITLE); clickButtonAndWaitForRedirect(editMetadataLink, Pages.getMetadataEditorPage().getUrl()); } @@ -314,6 +316,34 @@ public void editMetadata(String processTitle) throws InstantiationException, Ill clickButtonAndWaitForRedirect(editMetadataLink, Pages.getMetadataEditorPage().getUrl()); } + /** + * Open second process in metadata editor. + * @throws IllegalAccessException when navigating to metadata editor page fails + * @throws InstantiationException when navigating to metadata editor page fails + */ + public void editSecondProcessMetadata() throws IllegalAccessException, InstantiationException { + try { + setEditMetadataLink(SECOND_PROCESS_TITLE); + clickButtonAndWaitForRedirect(editMetadataLink, Pages.getMetadataEditorPage().getUrl()); + } catch (StaleElementReferenceException e) { + e.printStackTrace(); + } + } + + /** + * Open parent process in metadata editor. + * @throws IllegalAccessException when navigating to metadata editor page fails + * @throws InstantiationException when navigating to metadata editor page fails + */ + public void editParentProcessMetadata() throws InstantiationException, IllegalAccessException { + try { + setEditMetadataLink(PARENT_PROCESS_TITLE); + clickButtonAndWaitForRedirect(editMetadataLink, Pages.getMetadataEditorPage().getUrl()); + } catch (StaleElementReferenceException e) { + e.printStackTrace(); + } + } + public void downloadSearchResultAsExcel() { actionsButton.click(); await(WAIT_FOR_ACTIONS_MENU).pollDelay(700, TimeUnit.MILLISECONDS) @@ -340,7 +370,7 @@ public void downloadSearchResultAsPdf() { } private void setDownloadDocketLink() { - int index = getRowIndex(processesTable, PROCESS_TITLE, 3); + int index = getRowIndex(processesTable, SECOND_PROCESS_TITLE, 3); downloadDocketLink = Browser.getDriver().findElementById(PROCESSES_TABLE + ":" + index + ":downloadDocket"); } @@ -354,7 +384,7 @@ private void setEditMetadataLink(String processTitle) { } private void setDownloadLogLink() { - int index = getRowIndex(processesTable, PROCESS_TITLE, 3); + int index = getRowIndex(processesTable, SECOND_PROCESS_TITLE, 3); downloadLogLink = Browser.getDriver().findElementById(PROCESSES_TABLE + ":" + index + ":exportLogXml"); } diff --git a/Kitodo/src/test/resources/metadata/testParentProcessMeta.xml b/Kitodo/src/test/resources/metadata/testParentProcessMeta.xml new file mode 100644 index 00000000000..8b266343d36 --- /dev/null +++ b/Kitodo/src/test/resources/metadata/testParentProcessMeta.xml @@ -0,0 +1,38 @@ + + + + + + + + + Test parent process + + + + + + + + + + + + + + + + + + + +