/** * Content type query. * @param contentType Content type to filter. * @return The requested query or {@code null} if the argument is {@code null}. */ public static NodeQuery contentType(ContentType contentType) { if (contentType == null) { return null; } return term(Schema.TYPE, contentType.getId()); }
@Override public String toString() { return String.format("CT[%s:%s]", getStringId(), getDefaultName().getDisplayName()); }
/** * Returns the built content type. * @return The built content type. * @throws IllegalStateException in case of an error. */ protected ContentType doGet() { return new ContentType(this); }
private CloudItem createItem(ContentType contentType, int hits, int totalHits) { final NavigationKey nk = NavigationKey.contentType(contentType); final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? contentType.getName().get(locale) : contentType.getDefaultName(); return new CloudItem(name.getDisplayName(), uri, Math.ceil(hits / totalHits)); } }
public boolean apply(ContentType input) { return input.isNavigable(); }; };
public ContentType apply(ContentTypeObject from) { return set(ContentType.builder(), from).setNavigable(from.isNavigable()).get(); } };
/** * Adds an item related to a content type. * * @param contentType * Content type to add. * @param navigation * Navigation to use. */ protected final void add(ContentType contentType, NavigationKey navigationKey) { if (contentType == null) { return; } final PageKey pk = PageKey.contentType(navigationKey, contentType); add(contentType.getName().get(locale).getDisplayName(), pk); }
protected MenuItem createItem(ContentType contentType) { final NavigationKey nk; if (config.navigation() && context.getNavigationKey() != null && context.getNavigationKey().isCategory()) { nk = NavigationKey.category(context.getNavigationKey().getCategory(), contentType); } else { nk = NavigationKey.contentType(contentType); } final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? contentType.getName().get(locale) : contentType.getDefaultName(); final MenuItem item = new MenuItem(name.getDisplayName(), uri); return item; }
/** Returns the node key. */ public NodeKey getNodeKey() { return NodeKey.of(contentType.getId(), contentId); }
/** * Reads content from content repository id by contentkey. * @see com.isotrol.impe3.api.component.Component#execute() */ public ComponentResponse execute() { if (contentKey == null) { throw new IllegalStateException(); } final NodeQuery query = NodeQueries.nodeKey(contentKey.getContentId(), contentKey.getContentType().getId()); final Item<Content> item = contentRepository.getFirst(query, null, true); content = item.getItem(); return ComponentResponse.OK; }
@Override NodeQuery and() { if (getNavigationKey() == null) { return null; } final ContentType contentType = getNavigationKey().getContentType(); if (contentType == null) { return null; } return NodeQueries.term(Schema.TYPE, contentType.getId()); }