Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
digibib
ls.ext
Commits
21f81266
Commit
21f81266
authored
Sep 26, 2018
by
Petter Goksøyr Åsen
Browse files
services: remove remaining traces of keeping track of publication items
parent
ae059876
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
redef/services/src/main/java/no/deichman/services/entity/EntityService.java
View file @
21f81266
...
...
@@ -25,8 +25,6 @@ public interface EntityService {
Model
retrieveCorporationWithLinkedResources
(
XURI
xuri
);
XURI
updateAvailabilityData
(
String
recordId
,
String
homeBranches
,
String
availableBranches
,
int
numItems
,
boolean
deleted
)
throws
Exception
;
Model
retrieveWorkItemsByURI
(
XURI
xuri
);
String
create
(
EntityType
type
,
Model
inputModel
)
throws
Exception
;
...
...
redef/services/src/main/java/no/deichman/services/entity/EntityServiceImpl.java
View file @
21f81266
...
...
@@ -236,21 +236,6 @@ public final class EntityServiceImpl implements EntityService {
return
repository
.
retrieveAuthorizedValuesFor
(
type
);
}
@Override
public
XURI
updateAvailabilityData
(
String
recordId
,
String
homeBranches
,
String
availableBranches
,
int
numItems
,
boolean
deleted
)
throws
Exception
{
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
if
(
deleted
)
{
XURI
pub
=
repository
.
retrievePublicationXURIByRecordId
(
recordId
);
String
query
=
sqb
.
deleteBiblioReferences
(
recordId
);
repository
.
updateResource
(
query
);
return
pub
;
}
String
query
=
sqb
.
updateAvailabilityData
(
recordId
,
homeBranches
,
availableBranches
,
numItems
);
repository
.
updateResource
(
query
);
return
repository
.
retrievePublicationXURIByRecordId
(
recordId
);
}
@Override
public
void
updateWork
(
String
work
)
{
repository
.
updateWork
(
work
);
...
...
redef/services/src/main/java/no/deichman/services/entity/repository/RDFRepositoryBase.java
View file @
21f81266
...
...
@@ -79,10 +79,7 @@ public abstract class RDFRepositoryBase implements RDFRepository {
createProperty
(
BaseURI
.
ontology
(
"modified"
)),
createProperty
(
BaseURI
.
ontology
(
"hasPrimaryCataloguingSource"
)),
createProperty
(
BaseURI
.
ontology
(
"hasIdentifierInPrimaryCataloguingSource"
)),
createProperty
(
BaseURI
.
ontology
(
"hasImage"
)),
createProperty
(
BaseURI
.
ontology
(
"hasHomeBranch"
)),
createProperty
(
BaseURI
.
ontology
(
"hasAvailableBranch"
)),
createProperty
(
BaseURI
.
ontology
(
"hasNumItems"
))
createProperty
(
BaseURI
.
ontology
(
"hasImage"
))
);
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
RDFRepositoryBase
.
class
);
...
...
redef/services/src/main/java/no/deichman/services/entity/repository/SPARQLQueryBuilder.java
View file @
21f81266
...
...
@@ -374,35 +374,8 @@ public final class SPARQLQueryBuilder {
public
String
deleteBiblioReferences
(
String
recordId
)
{
String
q
=
format
(
""
+
"PREFIX : <%s>\n"
+
"DELETE { ?pub :recordId \"%s\" ; :hasHomeBranch ?homeBranch ; :hasAvailableBranch ?availBranch ; :hasNumItems ?numItems }\n"
+
"WHERE { ?pub :recordId \"%s\" .\n"
+
" OPTIONAL { ?pub :hasNumItems ?numItems }\n"
+
" OPTIONAL { ?pub :hasHomeBranch ?homeBranch }\n"
+
" OPTIONAL { ?pub :hasAvailableBranch ?availBranch }\n"
+
"}\n"
,
BaseURI
.
ontology
(),
recordId
,
recordId
);
return
q
;
}
public
String
updateAvailabilityData
(
String
recordId
,
String
homeBranches
,
String
availableBranches
,
int
numItems
)
{
List
<
String
>
inserts
=
newArrayList
();
if
(
homeBranches
!=
null
&&
!
homeBranches
.
equals
(
""
))
{
inserts
.
add
(
"?pub :hasHomeBranch \""
+
StringUtils
.
join
(
homeBranches
.
split
(
","
),
"\",\""
)
+
"\""
);
}
if
(
availableBranches
!=
null
&&
!
availableBranches
.
equals
(
""
))
{
inserts
.
add
(
"?pub :hasAvailableBranch \""
+
StringUtils
.
join
(
availableBranches
.
split
(
","
),
"\",\""
)
+
"\""
);
}
inserts
.
add
(
"?pub :hasNumItems "
+
numItems
);
String
q
=
format
(
""
+
"PREFIX : <%s>\n"
+
"DELETE { ?pub :hasHomeBranch ?homeBranch ; :hasAvailableBranch ?availBranch ; :hasNumItems ?numItems }\n"
+
"INSERT { %s }\n"
+
"WHERE { ?pub :recordId \"%s\" .\n"
+
" OPTIONAL { ?pub :hasNumItems ?numItems }\n"
+
" OPTIONAL { ?pub :hasHomeBranch ?homeBranch }\n"
+
" OPTIONAL { ?pub :hasAvailableBranch ?availBranch }\n"
+
"}\n"
,
BaseURI
.
ontology
(),
StringUtils
.
join
(
inserts
,
" .\n"
),
recordId
);
+
"DELETE WHERE { ?pub :recordId \"%s\" }\n"
,
BaseURI
.
ontology
(),
recordId
);
return
q
;
}
...
...
redef/services/src/main/java/no/deichman/services/search/SearchResource.java
View file @
21f81266
...
...
@@ -160,32 +160,6 @@ public class SearchResource extends ResourceBase {
return
Response
.
accepted
().
build
();
}
@POST
@Path
(
"publication/reindex"
)
public
final
Response
reIndexPublicationByRecordId
(
@FormParam
(
"recordId"
)
final
String
recordId
,
@FormParam
(
"homeBranches"
)
final
String
homeBranches
,
@FormParam
(
"availableBranches"
)
final
String
availableBranches
,
@FormParam
(
"numItems"
)
final
int
numItems
,
@FormParam
(
"deleted"
)
boolean
deleted
)
throws
Exception
{
if
(
recordId
==
null
)
{
throw
new
BadRequestException
(
"missing required queryparameter: recordId"
);
}
XURI
pubUri
=
getEntityService
().
updateAvailabilityData
(
recordId
,
homeBranches
,
availableBranches
,
numItems
,
deleted
);
try
{
getSearchService
().
indexOnly
(
pubUri
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
Response
.
accepted
().
build
();
}
@Override
protected
final
ServletConfig
getConfig
()
{
return
servletConfig
;
...
...
redef/services/src/main/resources/massage_work_query.sparql
View file @
21f81266
...
...
@@ -32,7 +32,6 @@ CONSTRUCT {
deich:contentAdaptation ?contentAdaptationNorwegianName ;
deich:adaptation ?contentAdaptationNorwegianName ;
deich:series ?seriesTitle ;
deich:totalNumItems ?totalNumItems ;
deich:literaryForm ?litform ;
deich:created ?created ;
deich:untranscribedTitle ?untranscribedTitle ;
...
...
@@ -240,20 +239,4 @@ WHERE {
VALUES ?seriesPred { deich:mainTitle deich:subtitle deich:partNumber deich:partTitle }
}
UNION { <__WORKURI__> deich:hasTag ?hasTag }
UNION {
select ?totalNumItems
where {
{
select (sum(?items) as ?totalNumItems)
where {
?publication deich:publicationOf <__WORKURI__> ;
deich:hasNumItems ?items .
optional {?publication deich:hasMediaType ?mediatype }
FILTER(!bound(?mediatype) || (bound(?mediatype) && ?mediatype != mediaType:Periodical))
}
having(sum(?items) > 0)
}
filter(?totalNumItems > 0)
}
}
}
redef/services/src/test/java/no/deichman/services/entity/repository/SPARQLQueryBuilderTest.java
View file @
21f81266
...
...
@@ -362,27 +362,6 @@ public class SPARQLQueryBuilderTest {
assertEquals
(
expected
,
query
);
}
@Test
public
void
test_update_branches_query
()
throws
Exception
{
String
recordId
=
"378"
;
String
homeBranches
=
"hutl,fmaj,fgry"
;
String
availableBranches
=
"fgry,fmaj"
;
int
numItems
=
8
;
String
expected
=
"PREFIX : <"
+
BaseURI
.
ontology
()
+
">\n"
+
"DELETE { ?pub :hasHomeBranch ?homeBranch ; :hasAvailableBranch ?availBranch ; :hasNumItems ?numItems }\n"
+
"INSERT { ?pub :hasHomeBranch \""
+
StringUtils
.
join
(
homeBranches
.
split
(
","
),
"\",\""
)
+
"\" .\n"
+
"?pub :hasAvailableBranch \""
+
StringUtils
.
join
(
availableBranches
.
split
(
","
),
"\",\""
)
+
"\" .\n"
+
"?pub :hasNumItems "
+
numItems
+
" }\n"
+
"WHERE { ?pub :recordId \""
+
recordId
+
"\" .\n"
+
" OPTIONAL { ?pub :hasNumItems ?numItems }\n"
+
" OPTIONAL { ?pub :hasHomeBranch ?homeBranch }\n"
+
" OPTIONAL { ?pub :hasAvailableBranch ?availBranch }\n"
+
"}\n"
;
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
String
query
=
sqb
.
updateAvailabilityData
(
recordId
,
homeBranches
,
availableBranches
,
numItems
);
assertEquals
(
expected
,
query
);
}
@Test
public
void
test_retrieve_record_ids_by_work_query
()
throws
Exception
{
XURI
xuri
=
new
XURI
(
"http://data.deichman.no/work/w234123"
);
...
...
redef/services/src/test/java/no/deichman/services/search/WorkModelToIndexMapperTest.java
View file @
21f81266
...
...
@@ -43,7 +43,6 @@ public class WorkModelToIndexMapperTest {
+
" \"litform\": \"Roman\","
+
" \"bio\": \"Biografisk innhold\",\n"
+
" \"country\": \"Norge\",\n"
+
" \"totalNumItems\": 3,\n"
+
" \"created\": \"2016-11-17T07:03:10.239Z\",\n"
+
" \"nationality\": \"Norge\",\n"
+
" \"displayLine1\": \"Ragde, Anne B.. Berlinerpoplene : Hvit uke i Trondheim. 3. Tredje del\",\n"
...
...
@@ -148,7 +147,6 @@ public class WorkModelToIndexMapperTest {
+
" ns2:language <http://lexvo.org/id/iso639-3/ita> ;\n"
+
" ns2:mainTitle \"La casa delle bugie\" ;\n"
+
" ns2:partTitle \"abc\" ;\n"
+
" ns2:hasNumItems 2 ;\n"
+
" ns2:subtitle \"xyz2\" ;\n"
+
" ns2:publicationOf <http://data.deichman.no/work/w4e5db3a95caa282e5968f68866774e20> ;\n"
+
" ns2:publicationYear \"2016\"^^xsd:gYear ;\n"
...
...
@@ -168,7 +166,6 @@ public class WorkModelToIndexMapperTest {
+
" ns2:publicationOf <http://data.deichman.no/work/w4e5db3a95caa282e5968f68866774e20> ;\n"
+
" ns2:publicationYear \"2004\"^^xsd:gYear ;\n"
+
" ns2:recordId \"11\" ;\n"
+
" ns2:hasNumItems 1 ;\n"
+
" ns2:hasImage \"http://static.deichman.no/626460/kr/1_thumb.jpg\" ;\n"
+
" ns2:subtitle \"roman\" ;\n"
+
" ns4:locationSignature \"Rag\" ;\n"
...
...
@@ -183,8 +180,7 @@ public class WorkModelToIndexMapperTest {
+
" ns2:mainTitle \"Berlinerpoplene Magazine\" ; ns2:partTitle \"deltittel\" ; ns2:partNumber \"1\" ;\n"
+
" ns2:publicationOf <http://data.deichman.no/work/w4e5db3a95caa282e5968f68866774e20> ;\n"
+
" ns2:publicationYear \"2004\"^^xsd:gYear ;\n"
+
" ns2:recordId \"11\" ;\n"
+
" ns2:hasNumItems 100 . \n"
+
" ns2:recordId \"11\" .\n"
+
"\n"
+
"<http://data.deichman.no/person/h10834700> rdf:type ns2:Person ;\n"
+
" ns2:birthYear \"1957\" ;\n"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment