use of org.mycore.oai.set.MCRSet in project mycore by MyCoRe-Org.
the class MCROAISetManager method createSetList.
protected OAIDataList<MCRSet> createSetList() {
OAIDataList<MCRSet> setList = new OAIDataList<>();
synchronized (this.setConfigurationMap) {
for (MCROAISetConfiguration<?, ?, ?> conf : this.setConfigurationMap.values()) {
MCROAISetHandler<?, ?, ?> handler = conf.getHandler();
Map<String, MCRSet> setMap = handler.getSetMap();
synchronized (setMap) {
setMap.clear();
Element resolved = MCRURIResolver.instance().resolve(conf.getURI());
if (resolved == null) {
throw new MCRException("Could not resolve set URI " + conf.getURI() + " for set " + conf.getId() + ".");
}
for (Element setElement : resolved.getChildren("set", OAIConstants.NS_OAI)) {
MCRSet set = createSet(conf.getId(), setElement);
setMap.put(set.getSpec(), set);
if (!contains(set.getSpec(), setList)) {
if (!handler.filter(set)) {
setList.add(set);
}
}
}
}
}
}
return setList;
}
use of org.mycore.oai.set.MCRSet in project mycore by MyCoRe-Org.
the class MCROAISetManager method createSet.
private MCRSet createSet(String setId, Element setElement) {
String setSpec = setElement.getChildText("setSpec", NS_OAI);
String setName = setElement.getChildText("setName", NS_OAI);
MCRSet set = new MCRSet(setId, getSetSpec(setSpec), setName);
set.getDescription().addAll(setElement.getChildren("setDescription", NS_OAI).stream().flatMap(// first childElement of setDescription
e -> e.getChildren().stream().limit(1)).peek(Element::detach).map(d -> (Description) new Description() {
@Override
public Element toXML() {
return d;
}
@Override
public void fromXML(Element descriptionElement) {
throw new UnsupportedOperationException();
}
}).collect(Collectors.toList()));
return set;
}
use of org.mycore.oai.set.MCRSet in project mycore by MyCoRe-Org.
the class MCROAIAdapter method getSet.
/*
* (non-Javadoc)
* @see org.mycore.oai.pmh.dataprovider.OAIAdapter#getSet(java.lang.String)
*/
@Override
public MCRSet getSet(String setSpec) throws NoSetHierarchyException, NoRecordsMatchException {
MCROAISetManager setManager = getSetManager();
OAIDataList<MCRSet> setList = setManager.get();
if (setList.isEmpty()) {
throw new NoSetHierarchyException();
}
MCRSet set = MCROAISetManager.get(setSpec, setList);
if (set == null) {
throw new NoRecordsMatchException();
}
return set;
}
Aggregations