Skip to content

Commit

Permalink
Generating default "additional information" information for exclusion…
Browse files Browse the repository at this point in the history
… and generic triggers.
  • Loading branch information
mederly committed Jan 28, 2017
1 parent dc85cda commit 4860118
Show file tree
Hide file tree
Showing 23 changed files with 503 additions and 145 deletions.
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<div wicket:id="informationList">
<div wicket:id="information"/>
</div>

</wicket:panel>
</html>
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.web.page.admin.workflow;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.InformationType;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import java.util.List;

/**
* @author mederly
*/
public class InformationListPanel extends BasePanel<List<InformationType>> {

private static final String ID_INFORMATION_LIST = "informationList";
private static final String ID_INFORMATION = "information";

public InformationListPanel(String id, IModel<List<InformationType>> model) {
super(id, model);
initLayout();
}

private void initLayout() {
ListView<InformationType> list = new ListView<InformationType>(ID_INFORMATION_LIST, getModel()) {
@Override
protected void populateItem(ListItem<InformationType> item) {
item.add(new InformationPanel(ID_INFORMATION, item.getModel()));
}
};
add(list);
}
}
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<h3 wicket:id="title"/>
<div wicket:id="parts">
<div wicket:id="part" class="well well-sm"></div>
</div>

</wicket:panel>
</html>
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.web.page.admin.workflow;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.InformationPartType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.InformationType;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

/**
* @author mederly
*/
public class InformationPanel extends BasePanel<InformationType> {

private static final String ID_TITLE = "title";
private static final String ID_PARTS = "parts";
private static final String ID_PART = "part";

public InformationPanel(String id, IModel<InformationType> model) {
super(id, model);
initLayout();
}

private void initLayout() {
Label titleLabel = new Label(ID_TITLE, new PropertyModel<>(getModel(), InformationType.F_TITLE.getLocalPart()));
titleLabel.add(new VisibleBehaviour(() -> getModelObject().getTitle() != null));
add(titleLabel);

ListView<InformationPartType> list = new ListView<InformationPartType>(ID_PARTS,
new PropertyModel<>(getModel(), InformationType.F_PART.getLocalPart())) {
@Override
protected void populateItem(ListItem<InformationPartType> item) {
InformationPartType part = item.getModelObject();
Label label = new Label(ID_PART, part.getText());
if (Boolean.TRUE.equals(part.isHasMarkup())) {
label.setEscapeModelStrings(false);
}
item.add(label);
}
};
add(list);
}
}
Expand Up @@ -94,12 +94,7 @@ <h3 class="box-title"><wicket:message key="workItemPanel.relatedRequests"/></h3>
<p/>
<a href="#" wicket:id="showRequest"><wicket:message key="WorkItemPanel.showRequest"/></a> <i wicket:id="showRequestHelp" wicket:message="title:workItemPanel.showRequestHelp"/>

<div wicket:id="approverInstructionContainer">
<h3><wicket:message key="workItemPanel.approverInstruction"/></h3>
<div wicket:id="approverInstructionLines">
<label wicket:id="approverInstructionLine" class="well"></label>
</div>
</div>
<div style="margin-top:20px" wicket:id="additionalInformation"/>

<h3><wicket:message key="workItemPanel.approverComment"/></h3>
<textarea wicket:id="approverComment" class="form-control input-sm" rows="2"></textarea>
Expand Down
Expand Up @@ -31,24 +31,18 @@
import com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApproverInstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PlainApproverInstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -79,9 +73,7 @@ public class WorkItemPanel extends BasePanel<WorkItemDto> {
private static final String ID_RELATED_REQUESTS_CONTAINER = "relatedRequestsContainer";
private static final String ID_RELATED_REQUESTS = "relatedRequests";
private static final String ID_RELATED_REQUESTS_HELP = "relatedRequestsHelp";
private static final String ID_APPROVER_INSTRUCTION_CONTAINER = "approverInstructionContainer";
private static final String ID_APPROVER_INSTRUCTION_LINES = "approverInstructionLines";
private static final String ID_APPROVER_INSTRUCTION_LINE = "approverInstructionLine";
private static final String ID_ADDITIONAL_INFORMATION = "additionalInformation";
private static final String ID_APPROVER_COMMENT = "approverComment";
private static final String ID_SHOW_REQUEST = "showRequest";
private static final String ID_SHOW_REQUEST_HELP = "showRequestHelp";
Expand All @@ -95,7 +87,8 @@ protected void initLayout(PageBase pageBase) {
WebMarkupContainer additionalInfoColumn = new WebMarkupContainer(ID_ADDITIONAL_INFO_COLUMN);

WebMarkupContainer historyContainer = new WebMarkupContainer(ID_HISTORY_CONTAINER);
historyContainer.add(new ItemApprovalHistoryPanel(ID_HISTORY, new PropertyModel<WfContextType>(getModel(), WorkItemDto.F_WORKFLOW_CONTEXT),
historyContainer.add(new ItemApprovalHistoryPanel(ID_HISTORY,
new PropertyModel<>(getModel(), WorkItemDto.F_WORKFLOW_CONTEXT),
UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL, (int) pageBase.getItemsPerPage(UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL)));
final VisibleEnableBehaviour historyContainerVisible = new VisibleEnableBehaviour() {
@Override
Expand Down Expand Up @@ -126,7 +119,8 @@ public boolean isVisible() {
final ISortableDataProvider<ProcessInstanceDto, String> relatedWorkflowRequestsProvider = new ListDataProvider<>(this, relatedWorkflowRequestsModel);
relatedWorkflowRequestsContainer.add(
new ProcessInstancesPanel(ID_RELATED_REQUESTS, relatedWorkflowRequestsProvider, null, 10,
ProcessInstancesPanel.View.TASKS_FOR_PROCESS, new PropertyModel<String>(getModel(), WorkItemDto.F_PROCESS_INSTANCE_ID)));
ProcessInstancesPanel.View.TASKS_FOR_PROCESS,
new PropertyModel<>(getModel(), WorkItemDto.F_PROCESS_INSTANCE_ID)));
final VisibleEnableBehaviour relatedWorkflowRequestsContainerVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
Expand Down Expand Up @@ -183,36 +177,9 @@ public void onClick(AjaxRequestTarget target) {
});
add(WebComponentUtil.createHelp(ID_SHOW_REQUEST_HELP));

IModel<List<String>> instructionsModel = new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
ApproverInstructionType instruction = getModelObject().getApproverInstruction();
if (instruction == null) {
return Collections.emptyList();
} else if (instruction instanceof PlainApproverInstructionType) {
return ((PlainApproverInstructionType) instruction).getText();
} else {
// TODO
return Collections.singletonList(instruction.toString());
}
}
};

WebMarkupContainer approverInstructionContainer = new WebMarkupContainer(ID_APPROVER_INSTRUCTION_CONTAINER);
ListView<String> approverInstructionList = new ListView<String>(ID_APPROVER_INSTRUCTION_LINES, instructionsModel) {
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Label(ID_APPROVER_INSTRUCTION_LINE, item.getModelObject()));
}
};
approverInstructionContainer.add(approverInstructionList);
add(approverInstructionContainer);
approverInstructionContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().getApproverInstruction() != null;
}
});
WebMarkupContainer additionalInformation = new InformationListPanel(ID_ADDITIONAL_INFORMATION,
new PropertyModel<>(getModel(), WorkItemDto.F_ADDITIONAL_INFORMATION));
add(additionalInformation);

add(new TextArea<>(ID_APPROVER_COMMENT, new PropertyModel<String>(getModel(), WorkItemDto.F_APPROVER_COMMENT)));
}
Expand Down
Expand Up @@ -58,7 +58,7 @@ public class WorkItemDto extends Selectable {
public static final String F_ASSIGNEE = "assignee";
public static final String F_CANDIDATES = "candidates";
public static final String F_STAGE_INFO = "stageInfo";
public static final String F_APPROVER_INSTRUCTION = "approverInstruction";
public static final String F_ADDITIONAL_INFORMATION = "additionalInformation";

public static final String F_OTHER_WORK_ITEMS = "otherWorkItems";
public static final String F_RELATED_WORKFLOW_REQUESTS = "relatedWorkflowRequests";
Expand Down Expand Up @@ -318,7 +318,7 @@ public String getStageInfo() {
return wfc != null ? WfContextUtil.getStageInfo(wfc) : WfContextUtil.getStageInfo(workItem);
}

public ApproverInstructionType getApproverInstruction() {
return workItem.getApproverInstruction();
public List<InformationType> getAdditionalInformation() {
return workItem.getAdditionalInformation();
}
}
Expand Up @@ -20,10 +20,13 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.Nullable;

import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;

/**
* @author lazyman
Expand Down Expand Up @@ -303,5 +306,21 @@ public static List<Class<? extends ObjectType>> getAllObjectTypes() {

return list;
}

// TODO move somewhere else?
public static String getDisplayNameForTypeName(@Nullable QName name, @Nullable Locale locale) {
if (name == null) {
return null;
}
ResourceBundle bundle = ResourceBundle.getBundle(
SchemaConstants.SCHEMA_LOCALIZATION_PROPERTIES_RESOURCE_BASE_PATH,
locale != null ? locale : Locale.getDefault());
String key = "ObjectType." + name.getLocalPart();
if (bundle.containsKey(key)) {
return bundle.getString(key);
} else {
return null;
}
}
}

Expand Up @@ -8689,10 +8689,10 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="approverInstruction" type="c:ExpressionType" minOccurs="0">
<xsd:element name="additionalInformation" type="c:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Instruction to reviewer. Will be displayed when work item will be worked on.
Additional information for approver. Will be displayed when work item will be worked on.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down

0 comments on commit 4860118

Please sign in to comment.