protected Long retrieveOrderingFromEntry(DocumentModel docEntry) { Long ordering = getItemOrdering(); if (ordering != null) { return ordering; } // fallback on default ordering key if (docEntry == null) { return null; } String schema = docEntry.getSchemas()[0]; try { ordering = (Long) docEntry.getProperties(schema).get("ordering"); } catch (ClassCastException e) { // nevermind } return ordering; }
public static void applyPropertyValues(DocumentModel src, DocumentModel dst) { for (String schema : src.getSchemas()) { DataModelImpl dataModel = (DataModelImpl) dst.getDataModel(schema); DataModelImpl fromDataModel = (DataModelImpl) src.getDataModel(schema); for (String field : fromDataModel.getDirtyFields()) { Serializable data = (Serializable) fromDataModel.getData(field); try { if (!(dataModel.getDocumentPart().get(field) instanceof BlobProperty)) { dataModel.setData(field, data); } else { dataModel.setData(field, decodeBlob(data)); } } catch (PropertyNotFoundException e) { continue; } } } }
protected String retrieveLabelFromEntry(DocumentModel docEntry) { if (docEntry == null) { return null; } String schema = docEntry.getSchemas()[0]; // compute label Object labelObject = getItemLabel(); String label = labelObject != null ? labelObject.toString() : null; FacesContext ctx = FacesContext.getCurrentInstance(); Locale locale = ctx.getViewRoot().getLocale(); if (StringUtils.isBlank(label)) { if (isLocalize() && isdbl10n()) { // lookup label property, hardcode the "label_" prefix for // now String defaultPattern = "label_en"; String pattern = "label_" + locale.getLanguage(); label = (String) docEntry.getProperty(schema, pattern); if (StringUtils.isBlank(label)) { label = (String) docEntry.getProperty(schema, defaultPattern); } if (StringUtils.isBlank(label)) { label = docEntry.getId(); log.warn( "Could not find label column for entry " + label + " (falling back on entry id)"); } } else { label = (String) docEntry.getProperties(schema).get("label"); if (isLocalize()) { label = translate(ctx, locale, label); } } } else if (isLocalize()) { label = translate(ctx, locale, label); } return label; }