use of com.manydesigns.elements.options.SelectionProvider in project Portofino by ManyDesigns.
the class AbstractCrudAction method getAllSelectionProviders.
// **************************************************************************
// Configuration
// **************************************************************************
@GET
@Path(":allSelectionProviders")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "The list of selection providers configured on this crud action.")
public CrudSelectionProviderEdit[] getAllSelectionProviders() {
Map<List<String>, Collection<String>> availableSelectionProviders = selectionProviderSupport.getAvailableSelectionProviderNames();
CrudSelectionProviderEdit[] selectionProviderEdits = new CrudSelectionProviderEdit[availableSelectionProviders.size()];
int i = 0;
for (Map.Entry<List<String>, Collection<String>> entry : availableSelectionProviders.entrySet()) {
CrudSelectionProviderEdit selectionProviderEdit = new CrudSelectionProviderEdit();
selectionProviderEdits[i] = selectionProviderEdit;
String[] fieldNames = entry.getKey().toArray(new String[0]);
selectionProviderEdit.fieldNames = fieldNames;
selectionProviderEdit.availableSelectionProviders = entry.getValue();
selectionProviderEdit.displayModeName = DisplayMode.DROPDOWN.name();
selectionProviderEdit.searchDisplayModeName = SearchDisplayMode.DROPDOWN.name();
for (CrudSelectionProvider cp : selectionProviderSupport.getCrudSelectionProviders()) {
if (Arrays.equals(cp.fieldNames, fieldNames)) {
SelectionProvider selectionProvider = cp.getSelectionProvider();
if (selectionProvider != null) {
selectionProviderEdit.selectionProviderName = selectionProvider.getName();
DisplayMode displayMode = selectionProvider.getDisplayMode();
if (displayMode != null) {
selectionProviderEdit.displayModeName = displayMode.name();
}
SearchDisplayMode searchDisplayMode = selectionProvider.getSearchDisplayMode();
if (searchDisplayMode != null) {
selectionProviderEdit.searchDisplayModeName = searchDisplayMode.name();
}
}
}
}
i++;
}
return selectionProviderEdits;
}
use of com.manydesigns.elements.options.SelectionProvider in project Portofino by ManyDesigns.
the class AbstractCrudAction method selectionProviders.
@GET
@Path(":selectionProvider")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
@Operation(summary = "The list of selection providers supported by this resource")
public List selectionProviders() {
List<Map<?, ?>> result = new ArrayList<>();
// setup option providers
for (CrudSelectionProvider current : selectionProviderSupport.getCrudSelectionProviders()) {
SelectionProvider selectionProvider = current.getSelectionProvider();
if (selectionProvider == null) {
continue;
}
String[] fieldNames = current.getFieldNames();
Map description = new HashMap();
description.put("name", selectionProvider.getName());
description.put("fieldNames", Arrays.asList(fieldNames));
description.put("displayMode", selectionProvider.getDisplayMode());
description.put("searchDisplayMode", selectionProvider.getSearchDisplayMode());
result.add(description);
}
return result;
}
Aggregations