use of com.lyncode.xoai.dataprovider.model.Set in project dataverse by IQSS.
the class XlistRecordsHandler method createRecord.
private Record createRecord(OAICompiledRequest parameters, Item item) throws BadArgumentException, CannotDisseminateRecordException, OAIException, NoMetadataFormatsException, CannotDisseminateFormatException {
MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
Header header = new Header();
Dataset dataset = ((Xitem) item).getDataset();
Xrecord xrecord = new Xrecord().withFormatName(parameters.getMetadataPrefix()).withDataset(dataset);
header.withIdentifier(item.getIdentifier());
ItemHelper itemHelperWrap = new ItemHelper(item);
header.withDatestamp(item.getDatestamp());
for (Set set : itemHelperWrap.getSets(getContext(), getRepository().getFilterResolver())) header.withSetSpec(set.getSpec());
if (item.isDeleted())
header.withStatus(Header.Status.DELETED);
xrecord.withHeader(header);
xrecord.withMetadata(item.getMetadata());
return xrecord;
}
use of com.lyncode.xoai.dataprovider.model.Set in project dataverse by IQSS.
the class XgetRecordHandler method createRecord.
private Xrecord createRecord(OAICompiledRequest parameters, Item item) throws BadArgumentException, CannotDisseminateRecordException, OAIException, NoMetadataFormatsException, CannotDisseminateFormatException {
MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
Header header = new Header();
Dataset dataset = ((Xitem) item).getDataset();
Xrecord xrecord = new Xrecord().withFormatName(parameters.getMetadataPrefix()).withDataset(dataset);
header.withIdentifier(item.getIdentifier());
ItemHelper itemHelperWrap = new ItemHelper(item);
header.withDatestamp(item.getDatestamp());
for (Set set : itemHelperWrap.getSets(getContext(), getRepository().getFilterResolver())) header.withSetSpec(set.getSpec());
if (item.isDeleted())
header.withStatus(Header.Status.DELETED);
xrecord.withHeader(header);
xrecord.withMetadata(item.getMetadata());
return xrecord;
}
use of com.lyncode.xoai.dataprovider.model.Set in project dataverse by IQSS.
the class XitemRepository method getItem.
@Override
public Item getItem(String identifier) throws IdDoesNotExistException, OAIException {
logger.fine("getItem; calling findOaiRecordsByGlobalId, identifier " + identifier);
List<OAIRecord> oaiRecords = recordService.findOaiRecordsByGlobalId(identifier);
if (oaiRecords != null && !oaiRecords.isEmpty()) {
Xitem xoaiItem = null;
for (OAIRecord record : oaiRecords) {
if (xoaiItem == null) {
Dataset dataset = datasetService.findByGlobalId(record.getGlobalId());
if (dataset != null) {
xoaiItem = new Xitem(record).withDataset(dataset);
}
} else {
// is part of multiple sets:
if (!StringUtil.isEmpty(record.getSetName())) {
xoaiItem.getSets().add(new Set(record.getSetName()));
}
}
}
if (xoaiItem != null) {
return xoaiItem;
}
}
throw new IdDoesNotExistException();
}
use of com.lyncode.xoai.dataprovider.model.Set in project dataverse by IQSS.
the class XitemRepository method addExtraSets.
private void addExtraSets(Object xoaiItemsList, String setSpec, Date from, Date until) {
List<Xitem> xoaiItems = (List<Xitem>) xoaiItemsList;
List<OAIRecord> oaiRecords = recordService.findOaiRecordsNotInThisSet(setSpec, from, until);
if (oaiRecords == null || oaiRecords.isEmpty()) {
return;
}
// Make a second pass through the list of xoaiItems already found for this set,
// and add any other sets in which this item occurs:
int j = 0;
for (int i = 0; i < xoaiItems.size(); i++) {
// fast-forward the second list, until we find a record with this identifier,
// or until we are past this record (both lists are sorted alphabetically by
// the identifier:
Xitem xitem = xoaiItems.get(i);
while (j < oaiRecords.size() && xitem.getIdentifier().compareTo(oaiRecords.get(j).getGlobalId()) > 0) {
j++;
}
while (j < oaiRecords.size() && xitem.getIdentifier().equals(oaiRecords.get(j).getGlobalId())) {
xoaiItems.get(i).getSets().add(new Set(oaiRecords.get(j).getSetName()));
j++;
}
}
}
use of com.lyncode.xoai.dataprovider.model.Set in project dataverse by IQSS.
the class XsetRepository method retrieveSets.
@Override
public ListSetsResult retrieveSets(int offset, int length) {
logger.fine("calling retrieveSets()");
List<OAISet> dataverseOAISets = setService.findAll();
List<Set> XOAISets = new ArrayList<Set>();
if (dataverseOAISets != null) {
for (int i = 0; i < dataverseOAISets.size(); i++) {
OAISet dataverseSet = dataverseOAISets.get(i);
Set xoaiSet = new Set(dataverseSet.getSpec());
xoaiSet.withName(dataverseSet.getName());
XOAIMetadata xMetadata = new XOAIMetadata();
Element element = new Element("description");
element.withField("description", dataverseSet.getDescription());
xMetadata.getElements().add(element);
xoaiSet.withDescription(xMetadata);
XOAISets.add(xoaiSet);
}
}
return new ListSetsResult(offset + length < XOAISets.size(), XOAISets.subList(offset, Math.min(offset + length, XOAISets.size())));
}
Aggregations