Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DARIAH-DE OAI-PMH Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DARIAH-DE
DARIAH-DE OAI-PMH Services
Commits
9a9257c0
Commit
9a9257c0
authored
2 years ago
by
Stefan E. Funk
Browse files
Options
Downloads
Patches
Plain Diff
fix: add reducing singleField again.... had to understand it first
parent
e39331e1
No related branches found
No related tags found
No related merge requests found
Pipeline
#340705
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
oaipmh-core/src/main/java/info/textgrid/middleware/OaipmhUtilities.java
+69
-15
69 additions, 15 deletions
...c/main/java/info/textgrid/middleware/OaipmhUtilities.java
with
69 additions
and
15 deletions
oaipmh-core/src/main/java/info/textgrid/middleware/OaipmhUtilities.java
+
69
−
15
View file @
9a9257c0
...
...
@@ -396,8 +396,11 @@ public class OaipmhUtilities {
* @param resultFromGetRequestInES
* @param fields
* @return Returns ONE or MORE params as a list!
* @deprecated
*/
public
static
List
<
String
>
fieldLoader
(
JSONObject
resultFromGetRequestInES
,
String
[]
fields
)
{
@Deprecated
public
static
List
<
String
>
fieldLoader
(
final
JSONObject
resultFromGetRequestInES
,
final
String
[]
fields
)
{
log
.
fine
(
"JSON: "
+
(
resultFromGetRequestInES
==
null
?
"NULL"
:
resultFromGetRequestInES
));
log
.
fine
(
"FIELDS: "
+
fields
);
...
...
@@ -418,32 +421,63 @@ public class OaipmhUtilities {
try
{
// Loop the splitted field components, such as "edition", "source", etcpp.
for
(
int
i
=
0
;
i
<
fieldPathForESIndex
.
length
;
i
++)
{
// Case 1: We have only one field component.
String
fieldComponent
=
fieldPathForESIndex
[
i
];
log
.
fine
(
"i="
+
i
);
log
.
fine
(
"fieldPathLength="
+
fieldPathForESIndex
.
length
);
// Case 1: Reduce JSON object.
if
(
i
<
fieldPathForESIndex
.
length
-
1
)
{
String
singleFieldComponent
=
fieldPathForESIndex
[
i
];
log
.
fine
(
"case 1: we have only one field component: "
+
singleFieldComponent
);
log
.
fine
(
"case 1: "
+
i
+
"<"
+
(
fieldPathForESIndex
.
length
-
1
)
+
" : reduce singlePath"
);
singlePath
=
singlePath
.
getJSONObject
(
fieldPathForESIndex
[
i
]);
fieldResults
.
add
(
singlePath
.
toString
());
}
// Case 2: We have
only
one field component
??
// Case 2: We have one field component
.
else
if
(
fieldPathForESIndex
.
length
==
1
)
{
String
singleFieldComponent
=
fieldPathForESIndex
[
i
];
log
.
fine
(
"case 2: we have only one field component: "
+
singleFieldComponent
);
log
.
fine
(
"case 2: we have only one field component in field "
+
field
);
// Examine JSONArray, take String if not applicable.
try
{
JSONArray
singlePathArray
=
singlePath
.
getJSONArray
(
fieldComponent
);
log
.
fine
(
"get json array: "
+
singlePathArray
.
toString
(
2
));
for
(
int
j
=
0
;
j
<
singlePathArray
.
length
();
j
++)
{
fieldResults
.
add
(
singlePathArray
.
getString
(
j
));
}
}
catch
(
JSONException
e
)
{
String
singlePathValue
=
singlePath
.
getString
(
fieldComponent
);
log
.
fine
(
"get string: "
+
singlePathValue
);
JSONObject
resultiDingsda
=
resultFromGetRequestInES
.
getJSONObject
(
singleFieldComponent
);
fieldResults
.
add
(
resultiDingsda
.
toString
());
fieldResults
.
add
(
singlePathValue
);
}
}
// Case 3: We have got more field components.
// // Case 2: We have only one field component??
// else if (fieldPathForESIndex.length == 1) {
// String singleFieldComponent = fieldPathForESIndex[i];
//
// log.fine("case 2: we have only one field component: " + singleFieldComponent);
//
// JSONObject resultiDingsda =
// resultFromGetRequestInES.getJSONObject(singleFieldComponent);
// fieldResults.add(resultiDingsda.toString());
// }
// Case 2: We have got more field components.
else
{
String
res
=
singlePath
.
get
(
fieldPathForESIndex
[
i
]).
toString
();
log
.
fine
(
"case 3: we have "
+
fieldPathForESIndex
.
length
+
" components in "
+
field
);
log
.
fine
(
"case 2: we have "
+
fieldPathForESIndex
.
length
+
" components in "
+
field
);
// JSONArray pathArray = resultFromGetRequestInES.getJSONArray(fieldComponent);
String
res
=
singlePath
.
get
(
fieldPathForESIndex
[
i
]).
toString
();
// Examine JSONArray.
// Examine JSONArray
, take String if not applicable
.
if
(
res
.
startsWith
(
"["
))
{
log
.
fine
(
"json array found: "
+
res
);
...
...
@@ -489,19 +523,39 @@ public class OaipmhUtilities {
String
[]
fieldPathForESIndex
=
field
.
split
(
ES_DIVIDER_REGEXP
);
JSONObject
singlePath
=
resultFromGetRequestInES
;
try
{
log
.
fine
(
"kakki 1"
);
for
(
int
i
=
0
;
i
<
fieldPathForESIndex
.
length
;
i
++)
{
log
.
fine
(
"kakki 2"
);
if
(
i
<
fieldPathForESIndex
.
length
-
1
)
{
log
.
fine
(
i
+
"<"
+
(
fieldPathForESIndex
.
length
-
1
)
+
" : reduce singlePath"
);
singlePath
=
singlePath
.
getJSONObject
(
fieldPathForESIndex
[
i
]);
log
.
fine
(
"kakki 3"
);
}
else
if
(
fieldPathForESIndex
.
length
==
1
)
{
fieldResults
=
resultFromGetRequestInES
.
get
(
fieldPathForESIndex
[
i
]).
toString
();
log
.
fine
(
"kakki 4"
);
}
else
{
fieldResults
=
singlePath
.
get
(
fieldPathForESIndex
[
i
]).
toString
();
log
.
fine
(
"kakki 5"
);
}
}
}
catch
(
JSONException
e
)
{
log
.
fine
(
"IGNORING JSON ERROR: "
+
e
.
getMessage
());
}
log
.
fine
(
"kakki 6"
);
return
fieldResults
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment