use of org.alfresco.web.bean.ml.SingleEditionBean in project acs-community-packaging by Alfresco.
the class DocumentDetailsDialog method initEditionHistory.
/**
* Constructs a list of objects representing the editions of the
* logical document
*
* @return List of editions
*/
@SuppressWarnings("unused")
private List<SingleEditionBean> initEditionHistory() {
// get the mlContainer
NodeRef mlContainer = getDocumentMlContainer().getNodeRef();
// get all editions (in descending order - ie. most recent first)
List<Version> orderedEditionList = new ArrayList<Version>(getEditionService().getEditions(mlContainer).getAllVersions());
// the list of Single Edition Bean to return
editionHistory = new ArrayList<SingleEditionBean>(orderedEditionList.size());
boolean firstEdition = true;
// for each edition, init a SingleEditionBean
for (Version edition : orderedEditionList) {
SingleEditionBean editionBean = new SingleEditionBean();
MapNode clientEdition = new MapNode(edition.getFrozenStateNodeRef());
String editionLabel = edition.getVersionLabel();
if (firstEdition) {
editionLabel += " (" + Application.getMessage(FacesContext.getCurrentInstance(), MSG_CURRENT) + ")";
}
clientEdition.put("editionLabel", editionLabel);
clientEdition.put("editionNotes", edition.getDescription());
clientEdition.put("editionAuthor", edition.getCreator());
clientEdition.put("editionDate", edition.getCreatedDate());
// Set the edition of the edition bean
editionBean.setEdition(clientEdition);
// get translations
List<VersionHistory> translationHistories = null;
if (firstEdition) {
// Get the translations because the current edition doesn't content link with its
// translation in the version store.
Map<Locale, NodeRef> translations = getMultilingualContentService().getTranslations(mlContainer);
translationHistories = new ArrayList<VersionHistory>(translations.size());
for (NodeRef translation : translations.values()) {
translationHistories.add(getVersionService().getVersionHistory(translation));
}
} else {
translationHistories = getEditionService().getVersionedTranslations(edition);
}
// add each translation in the SingleEditionBean
for (VersionHistory versionHistory : translationHistories) {
// get the list of versions (in descending order - ie. most recent first)
List<Version> orderedVersions = new ArrayList<Version>(versionHistory.getAllVersions());
// the last version (ie. most recent) is the first version of the list
Version lastVersion = orderedVersions.get(0);
// get the properties of the lastVersion
Map<QName, Serializable> lastVersionProperties = getEditionService().getVersionedMetadatas(lastVersion);
Locale language = (Locale) lastVersionProperties.get(ContentModel.PROP_LOCALE);
// create a map node representation of the last version
MapNode clientLastVersion = new MapNode(lastVersion.getFrozenStateNodeRef());
clientLastVersion.put("versionName", lastVersionProperties.get(ContentModel.PROP_NAME));
// use the node service for the description to ensure that the returned value is a text and not a MLText
clientLastVersion.put("versionDescription", getNodeService().getProperty(lastVersion.getFrozenStateNodeRef(), ContentModel.PROP_DESCRIPTION));
clientLastVersion.put("versionAuthor", lastVersionProperties.get(ContentModel.PROP_AUTHOR));
clientLastVersion.put("versionCreatedDate", lastVersionProperties.get(ContentModel.PROP_CREATED));
clientLastVersion.put("versionModifiedDate", lastVersionProperties.get(ContentModel.PROP_MODIFIED));
clientLastVersion.put("versionLanguage", this.getContentFilterLanguagesService().convertToNewISOCode(language.getLanguage()).toUpperCase());
if (getNodeService().hasAspect(lastVersion.getFrozenStateNodeRef(), ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) {
clientLastVersion.put("versionUrl", null);
} else {
clientLastVersion.put("versionUrl", DownloadContentServlet.generateBrowserURL(lastVersion.getFrozenStateNodeRef(), clientLastVersion.getName()));
}
// add a translation of the editionBean
editionBean.addTranslations(clientLastVersion);
}
editionHistory.add(editionBean);
firstEdition = false;
}
return editionHistory;
}
Aggregations