use of org.mycore.datamodel.ifs2.MCRMetadataVersion in project mycore by MyCoRe-Org.
the class MCRMetadataHistoryCommands method buildObjectHistory.
private static Stream<MCRMetaHistoryItem> buildObjectHistory(MCRObjectID objId) {
try {
List<MCRMetadataVersion> versions = Collections.emptyList();
MCRMetadataStore store = MCRXMLMetadataManager.instance().getStore(objId);
if (store instanceof MCRVersioningMetadataStore) {
MCRVersionedMetadata versionedMetadata = ((MCRVersioningMetadataStore) store).retrieve(objId.getNumberAsInteger());
versions = versionedMetadata.listVersions();
}
if (versions.isEmpty()) {
return buildSimpleObjectHistory(objId);
} else {
return buildObjectHistory(objId, versions);
}
} catch (IOException e) {
LogManager.getLogger().error("Error while getting history of {}", objId);
return Stream.empty();
}
}
use of org.mycore.datamodel.ifs2.MCRMetadataVersion in project mycore by MyCoRe-Org.
the class MCRObjectCommands method listRevisions.
/**
* List revisions of an MyCoRe Object.
*
* @param id
* id of MyCoRe Object
*/
@MCRCommand(syntax = "list revisions of {0}", help = "List revisions of MCRObject.", order = 260)
public static void listRevisions(String id) {
MCRObjectID mcrId = MCRObjectID.getInstance(id);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT);
try {
StringBuilder log = new StringBuilder("Revisions:\n");
List<MCRMetadataVersion> revisions = MCRXMLMetadataManager.instance().listRevisions(mcrId);
for (MCRMetadataVersion revision : revisions) {
log.append(revision.getRevision()).append(" ");
log.append(revision.getType()).append(" ");
log.append(sdf.format(revision.getDate())).append(" ");
log.append(revision.getUser());
log.append("\n");
}
LOGGER.info(log.toString());
} catch (Exception exc) {
LOGGER.error("While print revisions.", exc);
}
}
Aggregations