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; }
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; }
@Override public DocumentModel createEntry(DocumentModel entry) { Map<String, Object> fieldMap = entry.getProperties(schemaName); return createEntry(fieldMap); }