Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deactivate export buttons when process does not contain images #4224

Merged
merged 2 commits into from
Apr 13, 2021

Conversation

solth
Copy link
Member

@solth solth commented Mar 2, 2021

Fixes #3292

@solth solth requested a review from matthias-ronge March 2, 2021 11:34
Copy link
Collaborator

@matthias-ronge matthias-ronge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First issue: Each time the user interacts with the user interface, for each process that is displayed in the list, it is checked eight times on the file system to determine whether the process contains images.

In the Restore View phase:

  • to determine the style for the commandLink exportMets
  • to determine the disabled status for the commandLink exportMets
  • to determine the style for the commandLink exportDms
  • to determine the disabled status for the commandLink exportDms

Four more times in the Render Response phase. Caching should be implemented here.

Second issue: The way checking for images is error-prone, as it doesn’t handle all special cases. I would suggest the following.

public boolean hasImages(int processId) throws DAOException {
    Process process = ServiceManager.getProcessService().getById(processId);
    Folder generatorSource = process.getProject().getGeneratorSource();
    if(Objects.isNull(generatorSource)) {
        return false;
    }
    Subfolder sourceFolder = new Subfolder(process, generatorSource);
    return !sourceFolder.listContents().isEmpty();
}

BTW, I am unsure if this method should be in FileService or ProcessService.

*/
public boolean hasImages(int processId) {
try {
return FileService.hasImages(processId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, we do access File Service using the Service Loader. However, I prefer static access where possible. See #3327.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I take it you agree with hasImages remaining static?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kathrin-Huber should decide

@solth solth marked this pull request as draft March 10, 2021 10:03
@solth solth marked this pull request as ready for review April 6, 2021 09:11
@solth solth requested a review from matthias-ronge April 6, 2021 09:11
Copy link
Collaborator

@matthias-ronge matthias-ronge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to cover all requirements.

@Kathrin-Huber Kathrin-Huber merged commit 84af2df into kitodo:master Apr 13, 2021
@solth solth deleted the images-check branch April 14, 2021 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show existence of images in process list
3 participants