Skip to content

Commit

Permalink
Made GetRecord behave the same way as ListIdentifiers and ListRecords…
Browse files Browse the repository at this point in the history
…, as requested in #3687,

with multiple sets showing in the record headers.
  • Loading branch information
landreev committed May 2, 2017
1 parent a908321 commit 1e32ab0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public OAIRecord findOAIRecordBySetNameandGlobalId(String setName, String global
}

public List<OAIRecord> findOaiRecordsByGlobalId(String globalId) {
String query="SELECT h from OAIRecord as h where h.globalId = :globalId";
String query="SELECT object(h) from OAIRecord h where h.globalId = :globalId";
List<OAIRecord> oaiRecords = null;
try {
oaiRecords = em.createQuery(query).setParameter("globalId",globalId).getResultList();
Expand Down Expand Up @@ -319,6 +319,8 @@ public List<OAIRecord> findOaiRecordsBySetName(String setName, Date from, Date u
} else {
queryString += " and h.setName = :setName";
}
} else {
queryString += " and h.setName is null";
}
queryString += from != null ? " and h.lastUpdateTime >= :from" : "";
queryString += until != null ? " and h.lastUpdateTime<=:until" : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,26 @@ public XitemRepository (OAIRecordServiceBean recordService, DatasetServiceBean d

@Override
public Item getItem(String identifier) throws IdDoesNotExistException, OAIException {
logger.fine("getItem; calling findOAIRecordBySetNameandGlobalId, identifier " + identifier);
OAIRecord oaiRecord = recordService.findOAIRecordBySetNameandGlobalId(null, identifier);
if (oaiRecord != null) {
Dataset dataset = datasetService.findByGlobalId(oaiRecord.getGlobalId());
if (dataset != null) {
return new Xitem(oaiRecord).withDataset(dataset);
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 {
// Adding extra set specs to the XOAI Item, if this record
// is part of multiple sets:
if (!StringUtil.isEmpty(record.getSetName())) {
xoaiItem.getSets().add(new Set(record.getSetName()));
}
}
}
if (xoaiItem != null) {
return xoaiItem;
}
}

Expand Down

0 comments on commit 1e32ab0

Please sign in to comment.