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
4421de89
Commit
4421de89
authored
3 years ago
by
Stefan E. Funk
Browse files
Options
Downloads
Patches
Plain Diff
mc
parent
327f675d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java
+76
-66
76 additions, 66 deletions
.../java/info/textgrid/middleware/RecordListDelivererDC.java
with
76 additions
and
66 deletions
oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java
+
76
−
66
View file @
4421de89
...
...
@@ -23,7 +23,6 @@ import org.elasticsearch.search.SearchHit;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.fetch.subphase.FetchSourceContext
;
import
org.json.JSONObject
;
import
org.springframework.util.SystemPropertyUtils
;
import
info.textgrid.middleware.oaipmh.HeaderType
;
import
info.textgrid.middleware.oaipmh.ListRecordsType
;
import
info.textgrid.middleware.oaipmh.MetadataType
;
...
...
@@ -157,8 +156,10 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
DublinCoreBuilder
dublinCoreBuilder
=
new
DublinCoreBuilder
();
if
(
this
.
dariah
==
true
)
{
// All objects!
recordFilter
=
query
;
}
else
{
// All editions only!
recordFilter
=
QueryBuilders
.
boolQuery
().
must
(
query
)
.
must
(
QueryBuilders
.
matchPhraseQuery
(
this
.
formatField
,
this
.
formatToFilter
));
}
...
...
@@ -171,7 +172,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
searchSourceBuilder
.
query
(
recordFilter
);
searchSourceBuilder
.
size
(
100
);
searchRequest
.
source
(
searchSourceBuilder
);
if
(
resumptionToken
!=
null
)
{
SearchScrollRequest
scrollRequest
=
new
SearchScrollRequest
(
resumptionToken
);
scrollRequest
.
scroll
(
TimeValue
.
timeValueSeconds
(
LIFETIME_RES_TOKEN
));
...
...
@@ -220,76 +221,84 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
}
catch
(
DatatypeConfigurationException
e
)
{
log
.
debug
(
e
);
}
// ES6
JSONObject
json
=
new
JSONObject
(
hit
.
getSourceAsMap
());
this
.
modifiedValue
=
OAIPMHUtilities
.
fieldLoader
(
json
,
this
.
modifiedField
);
// OLD
//this.modifiedValue = hit.getSourceAsMap().get(this.modifiedField).toString();
//
this.modifiedValue = hit.getSourceAsMap().get(this.modifiedField).toString();
// TextGrid search!
String
workUri
=
""
;
String
[]
blaFields
=
new
String
[]
{
this
.
relationToFurtherMetadataObject
};
if
(
this
.
textgrid
==
true
&&
hit
.
getSourceAsMap
().
get
(
this
.
formatField
)
.
toString
().
equals
(
this
.
formatToFilter
))
{
String
setSpec
=
"project:"
+
DublinCoreFieldLoader
.
fillList
(
hit
,
TGConstants
.
RELATIONS_LIST
).
get
(
0
);
if
(
DublinCoreFieldLoader
.
fillList
(
hit
,
blaFields
).
get
(
0
)
!=
null
)
{
workUri
=
DublinCoreFieldLoader
.
fillList
(
hit
,
blaFields
).
get
(
0
)
.
substring
(
this
.
repositoryObjectURIPrefix
.
length
());
if
(!
workUri
.
endsWith
(
".0"
))
{
workUri
=
workUri
.
concat
(
".0"
);
if
(
this
.
textgrid
)
{
String
workUri
=
""
;
String
[]
blaFields
=
new
String
[]
{
this
.
relationToFurtherMetadataObject
};
if
(
hit
.
getSourceAsMap
().
get
(
this
.
formatField
).
toString
().
equals
(
this
.
formatToFilter
))
{
String
setSpec
=
"project:"
+
DublinCoreFieldLoader
.
fillList
(
hit
,
TGConstants
.
RELATIONS_LIST
).
get
(
0
);
if
(
DublinCoreFieldLoader
.
fillList
(
hit
,
blaFields
).
get
(
0
)
!=
null
)
{
workUri
=
DublinCoreFieldLoader
.
fillList
(
hit
,
blaFields
).
get
(
0
)
.
substring
(
this
.
repositoryObjectURIPrefix
.
length
());
if
(!
workUri
.
endsWith
(
".0"
))
{
workUri
=
workUri
.
concat
(
".0"
);
}
}
try
{
dublinCoreBuilder
=
putContentIntoDCFieldLists
(
hit
,
furtherDCElements
(
workUri
,
OAI_ESClient
.
getEsClient
()));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
DatatypeConfigurationException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
buildRecord
(
recordList
,
set
,
hit
.
getSourceAsMap
().
get
(
this
.
identifierField
).
toString
(),
dublinCoreBuilder
,
setSpec
);
}
}
// DARIAH search!
else
if
(
this
.
dariah
==
true
)
{
System
.
out
.
println
(
" ## kramsblablaZWO --> "
+
DublinCoreFieldLoader
.
fillList
(
hit
,
DARIAHConstants
.
IDENTIFIER_LIST
));
String
setSpec
=
"hdl:"
+
DublinCoreFieldLoader
.
fillList
(
hit
,
DARIAHConstants
.
IDENTIFIER_LIST
).
get
(
0
);
System
.
out
.
println
(
" ## setSpec --> "
+
setSpec
);
try
{
dublinCoreBuilder
=
putContentIntoDCFieldLists
(
hit
,
furtherDCElements
(
workUri
,
OAI_ESClient
.
getEsClient
()));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
DatatypeConfigurationException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
dublinCoreBuilder
=
putContentIntoDCFieldLists
2
(
hit
,
furtherDCElements
(
hit
.
getId
()
,
OAI_ESClient
.
getEsClient
()));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
DatatypeConfigurationException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
buildRecord
(
recordList
,
set
,
hit
.
getSourceAsMap
().
get
(
this
.
identifierField
).
toString
(),
dublinCoreBuilder
,
setSpec
);
}
if
(
this
.
dariah
==
true
)
{
String
setSpec
=
"hdl:"
+
DublinCoreFieldLoader
.
fillList
(
hit
,
DARIAHConstants
.
IDENTIFIER_LIST
).
get
(
0
);
System
.
out
.
println
(
" ## setSpec --> "
+
setSpec
);
try
{
dublinCoreBuilder
=
putContentIntoDCFieldLists2
(
hit
,
furtherDCElements
(
hit
.
getId
(),
OAI_ESClient
.
getEsClient
()));
}
catch
(
ParseException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
DatatypeConfigurationException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
buildRecord
(
recordList
,
set
,
hit
.
getSourceAsMap
().
get
(
this
.
identifierField
).
toString
(),
dublinCoreBuilder
,
setSpec
);
}
}
}
// Check the need for a resumption token!
ResumptionTokenType
resTokenForResponse
=
OAIPMHUtilities
.
getResumptionToken
(
completeListSize
,
resumptionToken
,
cursorCollector
,
scrollID
,
this
.
searchResponseSize
,
i
);
//if (resTokenForResponse != null) {
recordList
.
setResumptionToken
(
resTokenForResponse
);
System
.
out
.
println
(
"RESTOKEN: "
);
System
.
out
.
println
(
recordList
.
getResumptionToken
());
//}
//
if (resTokenForResponse != null) {
recordList
.
setResumptionToken
(
resTokenForResponse
);
System
.
out
.
println
(
"RESTOKEN: "
);
System
.
out
.
println
(
recordList
.
getResumptionToken
());
//
}
}
else
{
setFoundItems
(
false
);
...
...
@@ -300,8 +309,8 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
* @param hit
* @param responseWorkValues
* @return
* @throws DatatypeConfigurationException
* @throws ParseException
* @throws DatatypeConfigurationException
* @throws ParseException
*/
public
DublinCoreBuilder
putContentIntoDCFieldLists
(
SearchHit
hit
,
GetResponse
responseWorkValues
)
throws
ParseException
,
DatatypeConfigurationException
{
...
...
@@ -335,8 +344,8 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
* @param hit
* @param responseWorkValues
* @return
* @throws DatatypeConfigurationException
* @throws ParseException
* @throws DatatypeConfigurationException
* @throws ParseException
*/
public
DublinCoreBuilder
putContentIntoDCFieldLists2
(
SearchHit
hit
,
GetResponse
responseWorkValues
)
throws
ParseException
,
DatatypeConfigurationException
{
...
...
@@ -410,7 +419,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
if
(
this
.
textgrid
==
true
)
{
String
[]
setParts
=
set
.
split
(
":"
);
if
(
setParts
[
0
].
equals
(
"project"
))
{
queryField
=
"project.id"
;
queryField
=
"project.id"
;
valueField
=
setParts
[
1
];
}
}
...
...
@@ -419,19 +428,20 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
QueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
().
must
(
rangeQuery
).
must
(
matchQuery
);
System
.
out
.
println
(
boolQuery
);
query
=
boolQuery
;
}
else
{
query
=
rangeQuery
;
}
try
{
System
.
out
.
println
(
" ## getRecords() --> "
+
(
query
!=
null
?
query
.
getName
():
"query=NULL"
)
+
" - "
+
(
recordList
!=
null
?
recordList:
"recordList=NULL"
)
+
" - "
+
(
resumptionToken
!=
null
?
resumptionToken:
"resumptionToken=NULL"
)
+
" - "
+
(
set
!=
null
?
set:
"set:NULL"
));
System
.
out
.
println
(
" ## getRecords() --> "
+
(
query
!=
null
?
"queryName="
+
query
.
getName
()
:
"query=NULL"
)
+
" - "
+
(
recordList
!=
null
?
recordList
:
"recordList=NULL"
)
+
" - "
+
(
resumptionToken
!=
null
?
resumptionToken
:
"resumptionToken=NULL"
)
+
" - "
+
(
set
!=
null
?
set
:
"set=NULL"
));
fetchFields
(
query
,
recordList
,
resumptionToken
,
set
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
...
...
@@ -467,7 +477,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
}
header
.
setIdentifier
(
identifierForHeader
);
// Set set :-)
if
(
set
!=
null
)
{
header
.
getSetSpec
().
add
(
setSpec
);
...
...
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