Skip to content

Commit

Permalink
kitodo#3747 implementation of all processes selection
Browse files Browse the repository at this point in the history
  • Loading branch information
markusweigelt committed Nov 22, 2021
1 parent 6c996c3 commit c8e6292
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 38 deletions.
20 changes: 6 additions & 14 deletions Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@ public void init() {
ServiceManager.getListColumnService().getSelectedListColumnsForListAndClient("process");
}

/**
* Set selectedProcesses.
*
* @param selectedProcesses as java.util.List of {@link org.kitodo.data.database.beans.Process}
*/
public void setSelectedProcesses(List<Process> selectedProcesses) {
this.selectedProcesses = selectedProcesses;
}

/**
* Return list of process properties configured as custom list columns in kitodo
* configuration.
Expand Down Expand Up @@ -483,7 +474,7 @@ public void exportPdf() {
*/
public void downloadToHomeForSelection() {
try {
ProcessService.downloadToHome(this.selectedProcesses);
ProcessService.downloadToHome(getSelectedProcesses());
// TODO: fix message
Helper.setMessage("createdInUserHomeAll");
} catch (DAOException e) {
Expand All @@ -507,7 +498,7 @@ public void downloadToHomeForAll() {
* Set up processing status selection.
*/
public void setTaskStatusUpForSelection() {
workflowControllerService.setTaskStatusUpForProcesses(this.selectedProcesses);
workflowControllerService.setTaskStatusUpForProcesses(getSelectedProcesses());
}

/**
Expand All @@ -521,7 +512,7 @@ public void setTaskStatusUpForAll() {
* Set down processing status selection.
*/
public void setTaskStatusDownForSelection() {
workflowControllerService.setTaskStatusDownForProcesses(this.selectedProcesses);
workflowControllerService.setTaskStatusDownForProcesses(getSelectedProcesses());
}

/**
Expand Down Expand Up @@ -645,7 +636,7 @@ public void executeKitodoScriptAll() {
* Execute Kitodo script for selected processes.
*/
public void executeKitodoScriptSelection() {
executeKitodoScriptForProcesses(this.selectedProcesses, this.kitodoScriptSelection);
executeKitodoScriptForProcesses(getSelectedProcesses(), this.kitodoScriptSelection);
}

private void executeKitodoScriptForProcesses(List<Process> processes, String kitodoScript) {
Expand Down Expand Up @@ -1024,7 +1015,7 @@ public String changeFilter(String filter) {
}

private String filterList() {
this.selectedProcesses.clear();
this.selectedProcessesOrProcessDTOs.clear();
return processesPage;
}

Expand Down Expand Up @@ -1172,4 +1163,5 @@ public String getAmount() {
return "";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.primefaces.model.charts.hbar.HorizontalBarChartModel;
import org.primefaces.model.charts.pie.PieChartModel;

public class ProcessListBaseView extends BaseForm {
public class ProcessListBaseView<T> extends BaseForm {

private static final Logger logger = LogManager.getLogger(ProcessListBaseView.class);
private ChartMode chartMode;
Expand All @@ -56,7 +56,7 @@ public class ProcessListBaseView extends BaseForm {
private int numberOfGlobalImages;
private int numberOfGlobalStructuralElements;
private int numberOfGlobalMetadata;
List<Process> selectedProcesses = new ArrayList<>();
List<T> selectedProcessesOrProcessDTOs = new ArrayList<>();
private final String doneDirectoryName = ConfigCore.getParameterOrDefaultValue(ParameterCore.DONE_DIRECTORY_NAME);
DeleteProcessDialog deleteProcessDialog = new DeleteProcessDialog();

Expand All @@ -76,7 +76,19 @@ public ProcessListBaseView() {
* @return value of selectedProcesses
*/
public List<Process> getSelectedProcesses() {
return selectedProcesses;
if (selectedProcessesOrProcessDTOs.size() > 0) {
if (selectedProcessesOrProcessDTOs.get(0) instanceof ProcessDTO) {
try {
selectedProcessesOrProcessDTOs = (List<T>) ServiceManager.getProcessService()
.convertDtosToBeans((List<ProcessDTO>) selectedProcessesOrProcessDTOs);
} catch (DAOException e) {
Helper.setErrorMessage(ERROR_LOADING_MANY,
new Object[] {ObjectType.PROCESS.getTranslationPlural() }, logger, e);
}
}
return (List<Process>) selectedProcessesOrProcessDTOs;
}
return new ArrayList<>();
}

/**
Expand All @@ -93,7 +105,7 @@ public HorizontalBarChartModel getStackedBarModel() {
*/
public void showDurationOfTasks() {
chartMode = ChartMode.BAR;
stackedBarModel = ServiceManager.getProcessService().getBarChartModel(selectedProcesses);
stackedBarModel = ServiceManager.getProcessService().getBarChartModel(getSelectedProcesses());
PrimeFaces.current().executeScript("PF('statisticsDialog').show();");
PrimeFaces.current().ajax().update("statisticsDialog");
}
Expand All @@ -103,7 +115,7 @@ public void showDurationOfTasks() {
*/
public void showStateOfVolume() {
chartMode = ChartMode.PIE;
statisticResult = ServiceManager.getProcessService().getProcessTaskStates(selectedProcesses);
statisticResult = ServiceManager.getProcessService().getProcessTaskStates(getSelectedProcesses());
pieModel = ServiceManager.getProcessService().getPieChardModel(statisticResult);
PrimeFaces.current().executeScript("PF('statisticsDialog').show();");
PrimeFaces.current().ajax().update("statisticsDialog");
Expand All @@ -117,7 +129,7 @@ public void showProcessMetadataStatistic() {
processMetadataStatistics = new ArrayList<>();
resetGlobalStatisticValues();
Workpiece workpiece;
for (Process selectedProcess : selectedProcesses) {
for (Process selectedProcess : getSelectedProcesses()) {
try {
URI metadataFilePath = ServiceManager.getFileService().getMetadataFilePath(selectedProcess);
workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFilePath);
Expand Down Expand Up @@ -282,7 +294,7 @@ public boolean isShowInactiveProjects() {
* Export DMS for selected processes.
*/
public void exportDMSForSelection() {
exportDMSForProcesses(this.selectedProcesses);
exportDMSForProcesses(getSelectedProcesses());
}

/**
Expand Down Expand Up @@ -329,6 +341,7 @@ private void exportDMSForProcesses(List<Process> processes) {
ExportDms export = new ExportDms();
for (Process processToExport : processes) {
try {

export.startExport(processToExport);
Helper.setMessage(EXPORT_FINISHED);
} catch (DataException e) {
Expand Down Expand Up @@ -505,4 +518,12 @@ public boolean canBeExported(int processId) {
}
}

public List<T> getSelectedProcessesOrProcessDTOs() {
return selectedProcessesOrProcessDTOs;
}

public void setSelectedProcessesOrProcessDTOs(List<T> selectedProcessesOrProcessDTOs) {
this.selectedProcessesOrProcessDTOs = selectedProcessesOrProcessDTOs;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,6 @@ public class SearchResultForm extends ProcessListBaseView {
private final String searchResultListPath = MessageFormat.format(REDIRECT_PATH, "searchResult");
private final WorkflowControllerService workflowControllerService = new WorkflowControllerService();

/**
* Set selectedProcesses.
*
* @param selectedProcesses as java.util.List of {@link org.kitodo.production.dto.ProcessDTO}
*/
public void setSelectedProcesses(List<ProcessDTO> selectedProcesses) {
try {
this.selectedProcesses = ServiceManager.getProcessService().convertDtosToBeans(selectedProcesses);
} catch (DAOException e) {
Helper.setErrorMessage(ERROR_LOADING_MANY, new Object[] {ObjectType.PROCESS.getTranslationPlural() },
logger, e);
}
}

/**
* Searches for processes with the entered searchQuery.
*
Expand Down Expand Up @@ -324,4 +310,5 @@ public Integer getCurrentProjectFilter() {
public void setCurrentProjectFilter(Integer currentProjectFilter) {
this.currentProjectFilter = currentProjectFilter;
}

}
2 changes: 2 additions & 0 deletions Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,8 @@ surname=Nachname
save=Speichern
saveExit=Speichern \u0026 Schlie\u00DFen
search=Suche
selectAllRows=Alle Treffer
selectAllRowsOnPage=Alle Treffer dieser Seite
start=Start
startDate=Startdatum
startIndexing=Indexierung starten
Expand Down
2 changes: 2 additions & 0 deletions Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,8 @@ surname=Surname
save=Save
saveExit=Save \u0026 exit
search=Search
selectAllRows=Select all rows
selectAllRowsOnPage=Select all rows on page
start=Start
startDate=Start date
startIndexing=Start indexing
Expand Down
17 changes: 17 additions & 0 deletions Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,23 @@ h3#headerText {
vertical-align: middle;
}

.allSelectableOverlayPanel {
top: 36px;
left: 16px;
}

.allSelectableOverlayPanel ul {
list-style: none;
}

.allSelectableOverlayPanel ul li {
margin-top: 5px;
}

.allSelectableOverlayPanel ul li:first-child {
margin-top: 0px;
}

#processesTabView\:processesForm\:processesTable .ui-row-toggler {
margin-right: 8px;
}
Expand Down
8 changes: 8 additions & 0 deletions Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ function registerRowToggleEvents(event) {
}
);
}

$( document ).on( "click", ".allSelectable .ui-chkbox-all .ui-chkbox-box", function() {
if( $(this).hasClass( "ui-state-active" ) ) {
PF('allSelectableOverlayPanel').show();
} else {
PF('processesTable').unselectAllRows();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<!--@elvariable id="process" type="org.kitodo.production.dto.ProcessDTO"-->
<p:dataTable id="processesTable"
widgetVar="processesTable"
styleClass="default-layout"
styleClass="default-layout allSelectable"
var="process"
value="#{ProcessForm.lazyDTOModel}"
first="#{ProcessForm.firstRow}"
selection="#{ProcessForm.selectedProcesses}"
selection="#{ProcessForm.selectedProcessesOrProcessDTOs}"
lazy="true"
paginator="true"
resizableColumns="true"
Expand All @@ -37,12 +37,14 @@
currentPageReportTemplate="#{msgs.currentPageReportTemplate}"
paginatorPosition="bottom">


<p:ajax event="page"
listener="#{ProcessForm.onPageChange}"/>
<p:ajax event="rowToggle"
oncomplete="registerRowToggleEvents();" />

<p:column styleClass="checkboxListColumn" selectionMode="multiple" resizable="false"/>

<p:column styleClass="hierarchy-info">
<p:rowToggler rendered="#{process.getParentID() ne 0 or process.hasChildren() or ProcessForm.getCurrentTasksForUser(process).size() gt 0}"/>
<h:outputText rendered="#{process.getParentID() ne 0 and not process.hasChildren()}"><i class="fa fa-long-arrow-left" title="#{msgs.hierarchicalParents}"/></h:outputText>
Expand Down Expand Up @@ -218,6 +220,14 @@
</p:rowExpansion>

</p:dataTable>

<p:overlayPanel widgetVar="allSelectableOverlayPanel" dismissable="true" styleClass="allSelectableOverlayPanel" >
<ul>
<li><p:commandLink value="#{msgs.selectAllRowsOnPage}" onclick="PF('processesTable').unselectAllRows();PF('processesTable').selectAllRowsOnPage();PF('allSelectableOverlayPanel').hide();"/></li>
<li><p:commandLink value="#{msgs.selectAllRows}" onclick="PF('processesTable').selectAllRows();PF('allSelectableOverlayPanel').hide();"/></li>
</ul>
</p:overlayPanel>

<div id="dropDownMenus">
<p:commandButton id="actionsButton" value="#{msgs.possibleActions}" styleClass="secondary"
icon="fa fa-sort" iconPos="right" process="@this"/>
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/webapp/pages/searchResult.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
styleClass="default-layout"
var="process"
value="#{SearchResultForm.filteredList}"
selection="#{SearchResultForm.selectedProcesses}"
selection="#{SearchResultForm.selectedProcessesOrProcessDTOs}"
rowKey="#{process.id}"
paginator="true"
rows="#{LoginForm.loggedUser.tableSize}"
Expand Down

0 comments on commit c8e6292

Please sign in to comment.