use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class ObjectSolrReferenceResolver method getReferences.
@Override
public List<EntityReference> getReferences(EntityReference objectReference) throws SolrIndexerException {
List<EntityReference> result = new ArrayList<>();
// Object itself
result.add(objectReference);
// Object properties
DocumentReference documentReference = new DocumentReference(objectReference.getParent());
XWikiDocument document;
try {
document = getDocument(documentReference);
} catch (Exception e) {
throw new SolrIndexerException("Failed to get document for object [" + objectReference + "]", e);
}
BaseObject object = document.getXObject(objectReference);
if (object != null) {
for (Object field : object.getFieldList()) {
BaseProperty<ObjectPropertyReference> objectProperty = (BaseProperty<ObjectPropertyReference>) field;
ObjectPropertyReference objectPropertyReference = objectProperty.getReference();
try {
Iterables.addAll(result, this.objectPropertyResolverProvider.get().getReferences(objectPropertyReference));
} catch (Exception e) {
this.logger.error("Failed to resolve references for object property [" + objectPropertyReference + "]", e);
}
}
}
return result;
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class DBListClass method displayView.
@Override
public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
List<String> selectlist;
String separator = getSeparator();
BaseProperty prop = (BaseProperty) object.safeget(name);
Map<String, ListItem> map = getMap(context);
// Skip unset values.
if (prop == null) {
return;
}
if (prop instanceof ListProperty) {
selectlist = ((ListProperty) prop).getList();
List<String> newlist = new ArrayList<>();
for (String entry : selectlist) {
newlist.add(getDisplayValue(entry, name, map, context));
}
buffer.append(StringUtils.join(newlist, separator));
} else {
buffer.append(getDisplayValue(prop.getValue(), name, map, context));
}
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class DBTreeListClass method displayTreeSelectEdit.
protected void displayTreeSelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
select select = new select(prefix + name, 1);
select.setAttributeFilter(new XMLAttributeValueFilter());
select.setMultiple(isMultiSelect());
select.setSize(getSize());
select.setName(prefix + name);
select.setID(prefix + name);
select.setDisabled(isDisabled());
Map<String, ListItem> map = getMap(context);
Map<String, List<ListItem>> treemap = getTreeMap(context);
List<String> selectlist;
BaseProperty prop = (BaseProperty) object.safeget(name);
if (prop == null) {
selectlist = new ArrayList<String>();
} else if (prop instanceof ListProperty) {
selectlist = ((ListProperty) prop).getList();
} else {
selectlist = new ArrayList<String>();
selectlist.add(String.valueOf(prop.getValue()));
}
// Add options from Set
addToSelect(select, selectlist, map, treemap, "", "", context);
buffer.append(select.toString());
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class DBTreeListClass method displayView.
@Override
public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
List<String> selectlist;
BaseProperty prop = (BaseProperty) object.safeget(name);
if (prop == null) {
selectlist = new ArrayList<String>();
} else if (prop instanceof ListProperty) {
selectlist = ((ListProperty) prop).getList();
} else {
selectlist = new ArrayList<String>();
selectlist.add(String.valueOf(prop.getValue()));
}
String result = displayFlatView(selectlist, context);
if (result.equals("")) {
super.displayView(buffer, name, prefix, object, context);
} else {
buffer.append(result);
}
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class DBTreeListClass method displayEdit.
@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
BaseProperty prop = (BaseProperty) object.safeget(name);
List<String> selectlist = toList(prop);
if (isPicker()) {
String result = displayTree(name, prefix, selectlist, "edit", context);
if (result.equals("")) {
displayTreeSelectEdit(buffer, name, prefix, object, context);
} else {
displayHidden(buffer, name, prefix, object, context);
buffer.append(result);
}
} else {
displayTreeSelectEdit(buffer, name, prefix, object, context);
}
}
Aggregations