@Override List<CloudItem> generateCloud(GroupResult result, int totalHits) { final Group rootGroup = result.getGroup(); List<CloudItem> cloud = new LinkedList<CloudItem>(); for (String groupName : rootGroup.getGroupNames()) { final Group group = rootGroup.getGroup(groupName); final UUID uuid = UUID.fromString(groupName); final ContentType contentType = contentTypes.get(uuid); cloud.add(createItem(contentType, group.getHits(), totalHits)); } return cloud; }
public void edit() { cloud = new LinkedList<CloudItem>(); final ContentTypes contentTypes = getContentTypes(); for (ContentType contentType : contentTypes.values()) { cloud.add(createItem(contentType, (int) Math.ceil(Math.random() * 10), 10)); } }
public ComponentResponse execute() { final Set<UUID> uuids = contentTypes.keySet(); final List<MenuItem> list = Lists.newArrayList(); final Predicate<ContentType> filter = getFilter(); for (UUID key : uuids) { final ContentType ct = contentTypes.get(key); if (filter.apply(ct)) { final MenuItem item = createItem(ct); list.add(item); } } setItems(createListing(list)); return ComponentResponse.OK; }
private ContentType getParameterContentType() { if (requestParam != null && requestParams != null && requestParams.contains(requestParam)) { String value = requestParams.getFirst(requestParam); if (value == null) { return null; } final UUID id; try { id = UUID.fromString(value); } catch (IllegalArgumentException e) { return null; } return getContentTypes().get(id); } return null; } }
private static ContentType getContentType(final ComponentRequestContext context, List<String> args, int i) { final UUID id = getUUID(args, i); if (id == null) { return null; } return context.getPortal().getContentTypes().get(id); }
ContentTypeMapping toMapping(BaseModel model) { ContentType ct = model.getContentTypes().get(getId()); if (ct == null) { return null; } return new ContentTypeMapping(ct, getMapping()); }
Configuration get(ImpeIAModel model) { checkState(!isError(), "Invalid configuration state"); final ConfigurationBuilder<?> cb = definition.builder(); final ImmutableMap<String, Item> parameters = definition.getParameters(); for (Entry<String, Object> ecv : values.entrySet()) { final String name = ecv.getKey(); final Class<?> type = parameters.get(name).getType(); final Object value = ecv.getValue(); try { if (Category.class == type) { cb.set(name, checkNotNull(model.getCategories().get((UUID) value))); } else if (ContentType.class == type) { cb.set(name, checkNotNull(model.getContentTypes().get((UUID) value))); } else { cb.set(name, value); } } catch (RuntimeException e) { Loggers.pms().error(LOG_PREFIX + "Error setting parameter [{}]", logArgs(name)); throw e; } } try { return cb.get(); } catch (RuntimeException e) { Loggers.pms().error(LOG_PREFIX + "Unable to build configuration", logArgs(null)); throw e; } }
PortalConfiguration get(ImpeIAModel model) { checkState(!isError(), "Invalid configuration state"); final PortalConfigurationBuilder<?> cb = definition.builder(); final ImmutableMap<String, Item> parameters = definition.getParameters(); for (Entry<String, Object> ecv : values.entrySet()) { final String name = ecv.getKey(); final Class<?> type = parameters.get(name).getType(); final Object value = ecv.getValue(); try { if (Category.class == type) { cb.set(name, checkNotNull(model.getCategories().get((UUID) value))); } else if (ContentType.class == type) { cb.set(name, checkNotNull(model.getContentTypes().get((UUID) value))); } else { cb.set(name, value); } } catch (RuntimeException e) { Loggers.pms().error(LOG_PREFIX + "Error setting parameter [{}]", logArgs(name)); throw e; } } try { return cb.get(); } catch (RuntimeException e) { Loggers.pms().error(LOG_PREFIX + "Unable to build configuration", logArgs(null)); throw e; } }