forked from kitodo/kitodo-production
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt to the guidelines of the community board
- Loading branch information
1 parent
f4c192b
commit 87121c4
Showing
13 changed files
with
467 additions
and
872 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
200 changes: 78 additions & 122 deletions
200
Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/IndexingKeyworder.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
Kitodo/src/main/java/org/kitodo/production/services/data/DatabaseIdQueryPart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* (c) Kitodo. Key to digital objects e. V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo project. | ||
* | ||
* It is licensed under GNU General Public License version 3 or later. | ||
* | ||
* For the full copyright and license information, please read the | ||
* GPL3-License.txt file that was distributed with this source code. | ||
*/ | ||
|
||
package org.kitodo.production.services.data; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* A part of the filter searching on the database for an ID or ID range. | ||
*/ | ||
class DatabaseIdQueryPart extends DatabaseQueryPart { | ||
|
||
private static final String SECOND_PARAMETER_EXTENSION = "upTo"; | ||
|
||
private Integer firstId; | ||
private Integer upToId; | ||
|
||
/** | ||
* Constructor, creates a new DatabaseQueryPart. | ||
* | ||
* @param filterField | ||
* field to search on | ||
* @param firstId | ||
* first or only ID | ||
* @param upToId | ||
* {@code null} or last ID | ||
*/ | ||
DatabaseIdQueryPart(FilterField filterField, String firstId, String upToId, boolean operand) { | ||
super(filterField, operand); | ||
this.firstId = Integer.valueOf(firstId); | ||
this.upToId = Objects.nonNull(upToId) ? Integer.valueOf(upToId) : null; | ||
} | ||
|
||
/** | ||
* Returns the part HQL query. If the query contains the keyword "IN", it | ||
* must be queried using JOIN, otherwise using WHERE. | ||
* | ||
* @param className | ||
* "Task" for a query on the tasks table, else for a query on the | ||
* process table. | ||
* @param varName | ||
* variable name to use in the query | ||
* @param parameterName | ||
* parameter name to use in the query | ||
* @return the part HQL query | ||
*/ | ||
@Override | ||
String getDatabaseQuery(String className, String varName, String parameterName) { | ||
String query = Objects.equals(className, "Task") ? filterField.getTaskIdQuery() | ||
: filterField.getProcessIdQuery(); | ||
return varName + '.' + query + (upToId == null ? (operand ? " = :" : " != :") + parameterName | ||
: (operand ? " BETWEEN :" : " NOT BETWEEN :") + parameterName + " AND :" + parameterName | ||
+ SECOND_PARAMETER_EXTENSION); | ||
} | ||
|
||
/** | ||
* Puts the parameters necessary for the query. | ||
* | ||
* @param parameterName | ||
* parameter name used in the query | ||
* @param parameters | ||
* map to put the parameters into | ||
*/ | ||
@Override | ||
void addParameters(String parameterName, Map<String, Object> parameters) { | ||
if (Objects.nonNull(filterField.getQueryObject())) { | ||
parameters.put("queryObject", filterField.getQueryObject()); | ||
} | ||
parameters.put(parameterName, firstId); | ||
if (Objects.nonNull(upToId)) { | ||
parameters.put(parameterName.concat(SECOND_PARAMETER_EXTENSION), upToId); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return filterField + (upToId == null ? (operand ? " = " : " != ") + firstId | ||
: (operand ? " BETWEEN " : " NOT BETWEEN ") + firstId + " AND " + upToId); | ||
} | ||
} |
Oops, something went wrong.