-
Notifications
You must be signed in to change notification settings - Fork 63
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
Process parent link #5869
Process parent link #5869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the (SLUB Dresden) users' perspective it works fine, in general.
It is possible to import volumes of multivolume works and link them with the superordinate process, even if the superordinate process is located in a project to which a person does not have permissions.
The user is informed that the process is linked, but that the user cannot access the superordinate process via metadata editor, ...
This is the main use in the SLUB Dresden and it works very fine - thanks a lot!
I have tried to apply to periodical volumes, but this does not work as expected.
If i enter the identifier of a superordinate process, only one process of a volume is shown.
I would expect the superordinate process, like:
As we do not apply the functionality in this way for periodicals, it does not bother us. I just want to give a hint, that this might need some examination. Maybe, that is the expected behavior?
I have assigned "Request change" because i am not certain, if the functionality with the periodicals works as expected.
I cannot give any precise requirements, but you can contact me, if there are further questions.
753b0cf
to
a9ea218
Compare
@solth Thanks a lot for working on that again. I am again trying to work myself through the code. The general functionality seems to work good. But the way the code is written right now leads to a behavior where always only one possible parent is shown to the user. So the user does not even see all possible parents (independent of the fact wether he is able to actually select a specific process) Imagine a situation where you have one possible parent process in the same project (as the to be created child record), and another possible parent process in a different project. Right now, only one of those is available for selection by the user. Scenario a) Using the search button in the title record link tab: We search for multiple possible parent processes, but after we set one of them as the parent process using Lines 319 to 332 in a9ea218
This could mean, that a parent process in the same project gets skipped because a possible parent process in the other project is chosen. (Given the case that the user has the ability to link to processes in other projects). This could happen also because the found processes are not sorted in that case of a manual search as done in the case of the automatic search for a parent record after the catalog import ( kitodo-production/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java Line 986 in a9ea218
We should always show all possible parents when a user uses the search functionality. Scenario b) Automatic search for parent after catalog import. During a search for a title using catalog import Kitodo triggers an automatic search for parent records in the Kitodo database using the method kitodo-production/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java Lines 967 to 970 in a9ea218
So when calling So the question would be, wether we want to show the user all possible parents in all projects or wether we want to automatically select one, as it is implicitly done with the current implementation. |
@andre-hohmann The problem is that the search implemented in the Title Record Link tab is not actually a search for a parent, but a search for every process whose ID or title matches the given input. Since every volume of the peridocial has the same base value as part of the identifier Kitodo just finds randomly one of those entries that match. (So in the example a single volume of that periodical) kitodo-production/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java Line 819 in a9ea218
You would have to specify the precise ID of the parent in order to find only the parent process. |
@BartChris : Thanks a lot for the investigation and explanation! This could become more obvious, if all processes are shown, which contain the search criteria. |
The comment of the
We could use kitodo-production/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java Line 1431 in a9ea218
and extend the check with that condition: public ArrayList<SelectItem> getPotentialParentProcesses(List<ProcessDTO> parentCandidates, int maxNumber)
throws DAOException, IOException {
ArrayList<SelectItem> possibleParentProcesses = new ArrayList<>();
for (ProcessDTO process : parentCandidates.subList(0, Math.min(parentCandidates.size(), maxNumber))) {
if (ProcessService.canCreateChildProcess(process)) {
SelectItem selectItem = new SelectItem(process.getId().toString(), process.getTitle());
selectItem.setDisabled(!userMayLinkToParent(process.getId()));
if (!processInAssignedProject(process.getId())) {
String problem = Helper.getTranslation("projectNotAssignedToCurrentUser", process.getProject().getTitle());
selectItem.setDescription(problem);
selectItem.setLabel(selectItem.getLabel() + " (" + problem + ")");
}
possibleParentProcesses.add(selectItem);
}
}
return possibleParentProcesses;
} or filter the records directly in the search service public List<ProcessDTO> findLinkableParentProcesses(String searchInput, int rulesetId)
throws DataException, DAOException, IOException {
BoolQueryBuilder processQuery = new BoolQueryBuilder()
.should(createSimpleWildcardQuery(ProcessTypeField.TITLE.getKey(), searchInput));
if (searchInput.matches("\\d*")) {
processQuery.should(new MatchQueryBuilder(ProcessTypeField.ID.getKey(), searchInput));
}
BoolQueryBuilder query = new BoolQueryBuilder().must(processQuery)
.must(new MatchQueryBuilder(ProcessTypeField.RULESET.getKey(), rulesetId));
List<ProcessDTO> filteredProcesses = new ArrayList<>();
for (ProcessDTO process : findByQueryInAllProjects(query, false)) {
if (ProcessService.canCreateChildProcess(process)) {
filteredProcesses.add(process);
}
}
return filteredProcesses;
} |
a9ea218
to
bc2bb03
Compare
bc2bb03
to
9ff57f2
Compare
@solth and @BartChris : On the one hand, i think there is no need to solve the problem for periodical-processes. Maybe, this is only a problem of the SLUB Dresden due to the the local configuration to create the process title - and we have no disadvantage with the current workflows. As i do not see a use case which affects the SLUB Dresden (or other institutions) and i cannot estimate the resources and effects of the last proposal to improve the functionality, i would approve the current version of the PR. Then it can be merged. Is this procedure OK for you? If yes, @henning-gerhardt could review the technical aspects of this PR. |
@andre-hohmann
So the main suggested change to this PR would be that we should display multiple results in the search in the Title Record Link tab since there is no real reason why that worked in Kitodo 3.6 but does not work in 3.7 anymore. (And it is also required to enable the user tho choose between multiple possible parents). |
Is this issue introduced by this pull request or is this issue not related to this pull request and is existing already in 3.7 / master branch? If this issue is not related to this pull request then it should be solved by a separate pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Map can be simplified regarding it used types from class types to primitive types as there is no real need for classes to be used here.
* @return whether the process with the provided ID belongs to a project assigned to the current user or not | ||
* @throws DAOException when retrieving the process with the ID "processId" from the database fails | ||
*/ | ||
public static Boolean processInAssignedProject(int processId) throws DAOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return value is false
or true
but never null
so return type of method can be changed to primitive boolean
.
Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java
Show resolved
Hide resolved
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described in the discussions, i approve this pull requests because the main aspect has been solved:
A new problem is described in a separate issue and should be solved by an own pull request:
This is introduced by the current pull request. In master you get multiple hits. |
9ff57f2
to
9992f3e
Compare
selectedInsertionPosition = null; | ||
Helper.setErrorMessage("createProcessForm.titleRecordLinkTab.noInsertionPosition"); | ||
} else { | ||
selectedInsertionPosition = (String) ((LinkedList<SelectItem>) selectableInsertionPositions).getLast() |
Check warning
Code scanning / CodeQL
Cast from abstract to concrete collection Warning
List
LinkedList
Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java
Fixed
Show fixed
Hide fixed
Then this must be fixed in current pull request. |
9992f3e
to
a3e272a
Compare
@andre-hohmann , @BartChris , @henning-gerhardt sorry for not responding earlier, I didn't find the time to work on this pull request in the last few weeks. I will try to incorporate the changes in the functionality (show multiple potential parent processes in the pulldown menu as options, maybe check/filter for "canCreateChildren") and implement the change requests from the code review. |
I think we need to do the check in |
Also, wouldn't it be necessary to also check for |
b4a4b47
to
d40c2fd
Compare
@BartChris can you formally approve this PR or make change requests if you see something that should be adjusted before merging? |
import org.kitodo.production.dto.ProcessDTO; | ||
import org.kitodo.production.dto.ProjectDTO; | ||
|
||
public class ImportServiceTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this new test class written with Junit5 usage instead of Junit4? Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@solth We probably need to document the behavior (in the current or in an adapted form) before releasing 3.7. Outstanding issues which can be adressed later:
|
@BartChris : maybe by opening two issues with references to this issue? Both issues can be solved independent of each other (or maybe even together) so maybe one of the issues could be solved earlier than the other. Especially the second sound for me more important then the first one but maybe only as we did not use the mass import feature. |
I will add those issues, when the current PR gets merged and will also inspect wether there are more potential features to consider and to be adressed in issues. (e.g. topics outlined in this comment #5869 (comment), section on automatic import) |
@BartChris Sorry, I thought you had the "Approve" button as in other pull requests when reviewing the changes in the "Files" tab, but apparently that was not the case. |
786ae8e
to
cdbfded
Compare
Fixes #5626
Builds upon #5663 by @BartChris
As discussed in that pull request, processes in projects that are not assigned to the current user cannot be chosen as parent process in the
TitleRecordLinkTab
by default. Instead the corresponding option will be deactivated and a note will be displayed to inform the user why he cannot link to that specific parent process:This PR adds a new permission, though, that allows a user to link processes to parent processes in other projects which are not assigned to the current user. The option in the
TitleRecordLinkTab
will still contain the hint about the parent process belonging to a project to which the current user does not have regular access, but the option to select said parent process will now be activated:@andre-hohmann & @BartChris does this pull request meet your requirements for the discussed functionality?