Skip to content

Commit

Permalink
UBO-244 Publication status restriction in solr query in rsc/export/li…
Browse files Browse the repository at this point in the history
…nk/{format}/{pids:.+} should be configurable (#286)

* UBO-244 Added property UBO.Export.Status.Restriction
* UBO-244 Code format of UBOExportResource
  • Loading branch information
Possommi committed Jun 2, 2023
1 parent 88515e8 commit b32140f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.mycore.common.xml.MCRURIResolver;
import org.mycore.frontend.MCRFrontendUtil;


@Path("export")
public class UBOExportResource {

Expand All @@ -62,21 +61,24 @@ private static String encode(String s) {
return URLEncoder.encode(s, StandardCharsets.UTF_8);
}

protected static final String STATUS_RESTRICTION = MCRConfiguration2.getString("UBO.Export.Status.Restriction")
.orElse("+status:confirmed");

@GET
@Path("styles")
@Produces(MediaType.APPLICATION_JSON)
public Response listStyles(){
public Response listStyles() {
String[] styles = MCRConfiguration2.getStringOrThrow("MCR.Export.CSL.Styles").split(",");

List<CSLEntry> result = new ArrayList<>(styles.length);
for (String style : styles) {
Element element = MCRURIResolver.instance().resolve("resource:" + style + ".csl");

String title = Optional.ofNullable(element.getChild("info", CSL_NAMESPACE))
.map(el -> Optional.ofNullable(el.getChild("title", CSL_NAMESPACE)))
.filter(Optional::isPresent)
.map(Optional::get)
.map(Element::getTextNormalize).orElse(style);
.map(el -> Optional.ofNullable(el.getChild("title", CSL_NAMESPACE)))
.filter(Optional::isPresent)
.map(Optional::get)
.map(Element::getTextNormalize).orElse(style);

CSLEntry cslEntry = new CSLEntry(style, title);
result.add(cslEntry);
Expand Down Expand Up @@ -118,7 +120,7 @@ public Response link(
yearPart = "";
}

if(yearNew != null) {
if (yearNew != null) {
yearPart = "+year:" + yearNew + " ";
}

Expand All @@ -133,7 +135,7 @@ public Response link(
childFilterQuery += " +role:(" + String.join(" OR ", ROLES) + ")";
}

String solrQuery = "+status:confirmed " + yearPart + partOfPart
String solrQuery = UBOExportResource.STATUS_RESTRICTION + " " + yearPart + partOfPart
+ "+{!parent which=\"objectType:mods\" filters=$childfq}objectKind:name";

StringBuilder solrRequest = new StringBuilder()
Expand Down Expand Up @@ -175,6 +177,7 @@ public CSLEntry(String id, String title) {
}

public String id;

public String title;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ MCR.ContentTransformer.mods2csv2.Class=org.mycore.common.content.transformer.MCR
MCR.ContentTransformer.mods2csv2.Steps=solr2csv

UBO.Export.Fields=id,subject,oa,genre,host_genre,person_aut,person_edt,title,id_doi,id_scopus,id_pubmed,id_isi,id_urn,id_duepublico,id_duepublico2,host_title,series,id_issn,id_isbn,shelfmark,year,volume,issue,pages,place,publisher
# Set allowed status of publications appearing personal publication list
UBO.Export.Status.Restriction=+status:confirmed
######################################################################
# #
# Classbrowser #
Expand Down

0 comments on commit b32140f

Please sign in to comment.