// Build an FL_Link result from a list of SolrDocuments returned from a group command in a query protected FL_Link buildResultFromGroupedDocuments(SolrDocumentList dl) { // Build the initial result from the first document FL_Link link = buildResultFromDocument(dl.get(0)); // Get the nodetype String targetField = PropertyDescriptorHelper.mapKey( FL_RequiredPropertyKey.TO.name(), _applicationConfiguration.getLinkDescriptors().getProperties(), link.getType()); // Add the remaining document properties to the entity // Currently only the TO field is aggregated from grouping of one-to-many links for (int i = 1; i < dl.size(); i++) { SolrDocument sd = dl.get(i); String target = (String) sd.getFieldValue(targetField); FL_Property property = null; List<FL_Property> properties = link.getProperties(); for (FL_Property prop : link.getProperties()) { if (prop.getKey().equals(FL_RequiredPropertyKey.TO.name())) { property = prop; } } if (property != null) { Object range = property.getRange(); if (range instanceof FL_ListRange) { List<Object> values = ((FL_ListRange) range).getValues(); values.add(target); } else if (range instanceof FL_SingletonRange) { List<Object> values = new ArrayList<Object>(); values.add(((FL_SingletonRange) range).getValue()); values.add(target); property.setRange( FL_ListRange.newBuilder().setType(FL_PropertyType.STRING).setValues(values).build()); } link.setProperties(properties); } link.setTarget(link.getTarget() + "," + getTarget(sd)); } return link; }