Startseite
jump to top

Startseite / Plugin-Entwicklung / ContentCreator-Erweiterungen / Interaktive Features / Elementstatus- und Arbeitsablaufanzeigen / Codebeispiel

Element Status and Workflow Display: Code Example

This code example illustrates a very simple Element Status Provider that will use a single page reference element to determine whether the web page displayed in the preview should be shown as released, modified or in a workflow. To maintain the simplicity of this example, a list of three workflow groups will be returned: one that contains only the page reference, one that contains the page element, and a third that includes all media elements reference by input components of the page element itself (but not of its child elements, such as sections).

The Element Status Provider Plug-In

All methods required to implement an Element Status Provider plug-in reside in a single class that implements the interface WebeditElementStatusProviderPlugin.

public class ExampleWebeditElementStatusProviderPlugin implements WebeditElementStatusProviderPlugin {

private BaseContext _context;

@Override
public void setUp(@NotNull final BaseContext context) {
_context = context;
}

@Override
public void tearDown() {
}

@Override
@NotNull
public State getReleaseState (@NotNull final IDProvider element) {
State releaseState = State.RELEASED;
if (element.hasTask()) {
releaseState = State.IN_WORKFLOW;
}
if (element.isReleaseSupported() && element.getReleaseStatus() != IDProvider.RELEASED) {
releaseState = State.CHANGED;
}
return releaseState;
}

@Override
@NotNull
public List<WorkflowGroup> getWorkflowGroups (@NotNull final IDProvider element) {
final List<WorkflowGroup> collectedWorkflowGroups = new ArrayList<WorkflowGroup>();

if (element instanceof PageRef) {
final WorkflowGroup pageRefGroup = Factory.create("Page Reference only", Collections.singletonList(element));
collectedWorkflowGroups.add(pageRefGroup);

final Page pageElement = ((PageRef) element).getPage();
if (pageElement != null) {
final WorkflowGroup pageGroup = Factory.create("Page only", Collections.singletonList(pageElement));
collectedWorkflowGroups.add(pageGroup);

final Set<ReferenceEntry> referenceEntries = pageElement.getReferences();
if (!referenceEntries.isEmpty()) {
final List<IDProvider> mediaElements = new ArrayList<IDProvider>();
for (final ReferenceEntry referenceEntry : referenceEntries) {
final IDProvider referencedElement = referenceEntry.getReferencedElement();
if (referencedElement instanceof Media &&
referencedElement.getProject().getId() == element.getProject().getId()) {
mediaElements.add(referencedElement);
}
}
final WorkflowGroup mediaGroup = Factory.create("Media only", mediaElements);
collectedWorkflowGroups.add(mediaGroup);
}
}
}
return collectedWorkflowGroups;
}
}

State getReleaseState()

ContentCreator calls this method any time a navigation or reload event takes place in the preview to determine what status indicator to display in the toolbar's page status display. Three states are available, provided by the enum object State in the interface WebeditElementStatusProviderPlugin:

  • RELEASED
    indicates that the whole of the web page's preview should be considered equal to the latest generated (i.e. published) version. No important parts of the page and its contents have been modified, and all of the shown contents will be visible in the published, generated version of the page.
  • CHANGED
    implies that enough content (e.g. page and section contents as well as referenced media elements) have been modified, such that another release request over several objects is required to make these changes available in the published, generated version of the web page.
  • IN_WORKFLOW
    indicates that one or several of the elements associated with the web page preview have been placed in a workflow.

This method should use store elements associated with the current web page (starting with a page reference or dataset element) to return one of the State values. The recommended priority list (from highest to lowest priority) in determining page status is: in workflow, changed, released.

List<WorkflowGroup> getWorkflowGroups()

This method is polled by the ContentCreator as navigation or reload events take place in the preview. The return value of getWorkflowGroups() is used to generate a list of available workflows and, more specifically, workflow transitions that are available on all elements in each workflow group. Each WorkflowGroup object in the returned List consists of a display name (a String) and a List of IDProvider objects.

For each WorkflowGroup object, ContentCreator inspects all IDProvider objects in its listing and determines which workflow transitions configured in the project are available to all of these IDProvider objects, based on availability criteria such as display logic (configured on each single workflow) and user permissions (configured in FirstSpirit stores). If such workflow transitions are identified, that workflow group will be displayed with a group header in the page status and workflow menu, and each valid workflow transition is displayed as a menu entry under that group's header. If ContentCreator cannot identify any workflow transitions available to all IDProvider objects in a workflow group's listing, this group is silently ignored and will not be displayed in the workflow menu for the current preview.

© 2005 - 2020 e-Spirit AG | Alle Rechte vorbehalten. | FirstSpirit 2020-09 | Datenschutz | Impressum | Kontakt