Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Apr 26, 2017
2 parents 28ca89f + 98ac4e0 commit 5b45811
Show file tree
Hide file tree
Showing 76 changed files with 2,909 additions and 1,058 deletions.
Expand Up @@ -492,19 +492,6 @@ public List<T> getObject() {
};
}

public static List<OpResult> getTestConnectionResults(OperationResult result, PageBase component) {
List<OpResult> resultsDto = new ArrayList<>();
for (ConnectorTestOperation connectorOperation : ConnectorTestOperation.values()) {
for (OperationResult testResult : result.getSubresults()) {
if (connectorOperation.getOperation().equals(testResult.getOperation())) {
OpResult resultDto = OpResult.getOpResult(component, testResult);
resultsDto.add(resultDto);
}
}
}
return resultsDto;
}

public static List<String> createTaskCategoryList() {
List<String> categories = new ArrayList<>();

Expand Down
Expand Up @@ -101,7 +101,7 @@ private void initLayout(PageAdminObjectDetails<O> parentPage) {
mainForm = new Form<>(ID_MAIN_FORM, true);
add(mainForm);
initLayoutTabs(parentPage);
initLayoutOptions(parentPage);
initLayoutOptions();
initLayoutButtons(parentPage);
}

Expand All @@ -114,7 +114,7 @@ protected void initLayoutTabs(final PageAdminObjectDetails<O> parentPage) {

protected abstract List<ITab> createTabs(PageAdminObjectDetails<O> parentPage);

protected void initLayoutOptions(PageAdminObjectDetails<O> parentPage) {
protected void initLayoutOptions() {
ExecuteChangeOptionsPanel optionsPanel = new ExecuteChangeOptionsPanel(ID_EXECUTE_OPTIONS,
executeOptionsModel, true, false);
optionsPanel.setVisible(getOptionsPanelVisibility());
Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.component.DateLabelComponent;
Expand All @@ -41,6 +42,7 @@
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -204,6 +206,12 @@ public List<WorkItemDto> getSelectedWorkItems() {

IColumn<WorkItemDto, String> createObjectNameColumn(final String headerKey) {
return new LinkColumn<WorkItemDto>(createStringResource(headerKey), WorkItemDto.F_OBJECT_NAME) {
private static final long serialVersionUID = 1L;

@Override
protected IModel<String> createLinkModel(IModel<WorkItemDto> rowModel) {
return Model.of(WebModelServiceUtils.resolveReferenceName(rowModel.getObject().getObjectRef(), getPageBase()));
}

@Override
public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
Expand All @@ -216,6 +224,11 @@ public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
IColumn<WorkItemDto, String> createTargetNameColumn(final String headerKey) {
return new LinkColumn<WorkItemDto>(createStringResource(headerKey), WorkItemDto.F_TARGET_NAME) {

@Override
protected IModel<String> createLinkModel(IModel<WorkItemDto> rowModel) {
return Model.of(WebModelServiceUtils.resolveReferenceName(rowModel.getObject().getTargetRef(), getPageBase()));
}

@Override
public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
WorkItemDto dto = rowModel.getObject();
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016 Evolveum
~ Copyright (c) 2016-2017 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<div class="row">
<div class="row" wicket:id="connectorList">
<div class="col-md-12">
<div class="container-fluid prism-object">
<div class="row prism-header">
Expand All @@ -28,6 +28,15 @@
<div class="container-fluid prism-container">
<div class="prism-properties">

<div class="row prism-property">
<div class="col-xs-2 prism-property-label">
<span><wicket:message key="ConnectorOperationalStatus.connectorName">Connector name</wicket:message></span>
</div>
<div class="col-md-10 prism-property-value">
<span wicket:id="connectorName"/>
</div>
</div>

<div class="row prism-property">
<div class="col-xs-2 prism-property-label">
<span><wicket:message key="ConnectorOperationalStatus.connectorClassName">Connector class</wicket:message></span>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Evolveum
* Copyright (c) 2016-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,11 @@
*/
package com.evolveum.midpoint.web.page.admin.resources;

import java.util.List;

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.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -45,6 +49,8 @@ public class ResourceConnectorPanel extends Panel {
private static final String DOT_CLASS = ResourceConnectorPanel.class.getName() + ".";
private static final String OPERATION_GET_CONNECTOR_OPERATIONAL_STATUS = DOT_CLASS + "getConnectorOperationalStatus";

private static final String ID_CONNECTOR_LIST = "connectorList";
private static final String ID_CONNECTOR_NAME = "connectorName";
private static final String ID_CONNECOTR_CLASS = "connectorClass";
private static final String ID_POOL_CONFIG_MIN_SIZE = "poolConfigMinSize";
private static final String ID_POOL_CONFIG_MAX_SIZE = "poolConfigMaxSize";
Expand All @@ -69,14 +75,14 @@ public ResourceConnectorPanel(String id, ShadowKindType kind,
private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
setOutputMarkupId(true);

IModel<ConnectorOperationalStatus> statsModel = new AbstractReadOnlyModel<ConnectorOperationalStatus>() {
IModel<List<ConnectorOperationalStatus>> statsModel = new AbstractReadOnlyModel<List<ConnectorOperationalStatus>>() {
private static final long serialVersionUID = 1L;

@Override
public ConnectorOperationalStatus getObject() {
public List<ConnectorOperationalStatus> getObject() {
PrismObject<ResourceType> resource = model.getObject();
OperationResult result = new OperationResult(OPERATION_GET_CONNECTOR_OPERATIONAL_STATUS);
ConnectorOperationalStatus status = null;
List<ConnectorOperationalStatus> status = null;
try {
status = parentPage.getModelInteractionService().getConnectorOperationalStatus(resource.getOid(), result);
} catch (SchemaException | ObjectNotFoundException | CommunicationException
Expand All @@ -87,16 +93,28 @@ public ConnectorOperationalStatus getObject() {
return status;
}
};

ListView<ConnectorOperationalStatus> listview = new ListView<ConnectorOperationalStatus>(ID_CONNECTOR_LIST, statsModel) {
private static final long serialVersionUID = 1L;

protected void populateItem(ListItem<ConnectorOperationalStatus> item) {
item.add(new Label("label", item.getModel()));
IModel<ConnectorOperationalStatus> statModel = item.getModel();
item.add(createLabel(statModel, ID_CONNECTOR_NAME, ConnectorOperationalStatus.F_CONNECTOR_NAME));
item.add(createLabel(statModel, ID_CONNECOTR_CLASS, ConnectorOperationalStatus.F_CONNECTOR_CLASS_NAME));
item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_SIZE));
item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_SIZE));
item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_IDLE));
item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_IDLE));
item.add(createLabel(statModel, ID_POOL_CONFIG_WAIT_TIMEOUT, ConnectorOperationalStatus.F_POOL_CONFIG_WAIT_TIMEOUT));
item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME));
item.add(createLabel(statModel, ID_POOL_STATUS_NUM_IDLE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_IDLE));
item.add(createLabel(statModel, ID_POOL_STATUS_NUM_ACTIVE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_ACTIVE));

}
};
add(listview);

add(createLabel(statsModel, ID_CONNECOTR_CLASS, ConnectorOperationalStatus.F_CONNECTOR_CLASS_NAME));
add(createLabel(statsModel, ID_POOL_CONFIG_MIN_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_SIZE));
add(createLabel(statsModel, ID_POOL_CONFIG_MAX_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_SIZE));
add(createLabel(statsModel, ID_POOL_CONFIG_MIN_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_IDLE));
add(createLabel(statsModel, ID_POOL_CONFIG_MAX_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_IDLE));
add(createLabel(statsModel, ID_POOL_CONFIG_WAIT_TIMEOUT, ConnectorOperationalStatus.F_POOL_CONFIG_WAIT_TIMEOUT));
add(createLabel(statsModel, ID_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME));
add(createLabel(statsModel, ID_POOL_STATUS_NUM_IDLE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_IDLE));
add(createLabel(statsModel, ID_POOL_STATUS_NUM_ACTIVE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_ACTIVE));
}

private Label createLabel(IModel<ConnectorOperationalStatus> statsModel, String id, String fieldName) {
Expand Down
@@ -1,5 +1,5 @@
<!--
~ Copyright (c) 2010-2016 Evolveum
~ 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.
Expand All @@ -19,10 +19,15 @@
<wicket:panel>
<div class="box-body">
<div wicket:id="messagesPanel">
<div wicket:id="messages"/>

<div wicket:id="connectorMessagesPanel">
<h4><span><wicket:message key="ObjectTypeGuiDescriptor.connector">Connector</wicket:message></span> <span wicket:id="connectorName"/></h4>
<div wicket:id="connectorMessages"/>
</div>
<div> <!-- Resource messages -->
<h4><wicket:message key="ObjectTypeGuiDescriptor.resource">Resource</wicket:message></h4>
<div wicket:id="resourceMessages"/>
</div>
</div>

</div>
</wicket:panel>
</html>
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* 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.
Expand All @@ -21,33 +21,45 @@
import com.evolveum.midpoint.gui.api.component.result.OperationResultPanel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.constants.ConnectorTestOperation;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Page;
import org.apache.wicket.markup.html.WebMarkupContainer;
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.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.util.ListModel;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* Created by honchar.
*/
public class TestConnectionMessagesPanel extends BasePanel {
private static final String DOT_CLASS = TestConnectionMessagesPanel.class.getName() + ".";
private static final long serialVersionUID = 1L;

private static final String DOT_CLASS = TestConnectionMessagesPanel.class.getName() + ".";

private static final String OPERATION_TEST_CONNECTION = DOT_CLASS + "testConnection";

private static final String ID_MESSAGES_PANEL = "messagesPanel";
private static final String ID_MESSAGES = "messages";
private static final String ID_CONNECTOR_MESSAGES_PANEL = "connectorMessagesPanel";
private static final String ID_CONNECTOR_NAME = "connectorName";
private static final String ID_CONNECTOR_MESSAGES = "connectorMessages";
private static final String ID_RESOURCE_MESSAGES = "resourceMessages";

private PageBase parentPage;
private ListModel<OpResult> model;
private ListModel<OpResult> modelResourceResults;
private ListModel<ConnectorStruct> connectorResourceResults;

public TestConnectionMessagesPanel(String id, String resourceOid, PageBase parentPage) {
super(id);
Expand All @@ -58,45 +70,101 @@ public TestConnectionMessagesPanel(String id, String resourceOid, PageBase paren

private void initResultsModel(String resourceOid) {
OperationResult result = new OperationResult(OPERATION_TEST_CONNECTION);
List<OpResult> resultsDto = new ArrayList<>();
List<OpResult> resourceResultsDto = new ArrayList<>();
List<ConnectorStruct> connectorStructs = new ArrayList<>();
if (StringUtils.isNotEmpty(resourceOid)) {
Task task = parentPage.createSimpleTask(OPERATION_TEST_CONNECTION);
try {
Task task = parentPage.createSimpleTask(OPERATION_TEST_CONNECTION);
result = parentPage.getModelService().testResource(resourceOid, task);
resultsDto = WebComponentUtil.getTestConnectionResults(result, parentPage);
} catch (ObjectNotFoundException e) {
result.recordFatalError("Failed to test resource connection", e);
}

for (OperationResult subresult: result.getSubresults()) {
if (isConnectorResult(subresult)) {
ConnectorStruct connectorStruct = new ConnectorStruct();
connectorStruct.connectorName = (String) subresult.getParams().get(OperationResult.PARAM_NAME);
if (connectorStruct.connectorName == null) {
connectorStruct.connectorName = "";
}
connectorStruct.connectorResultsDto = new ArrayList<>();
for (OperationResult subsubresult: subresult.getSubresults()) {
if (isKnownResult(subsubresult)) {
connectorStruct.connectorResultsDto.add(OpResult.getOpResult(parentPage, subsubresult));
}
}
connectorStructs.add(connectorStruct);
} else if (isKnownResult(subresult)) {
// resource operation
resourceResultsDto.add(OpResult.getOpResult(parentPage, subresult));
}

}

if (result.isSuccess()) {
result.recomputeStatus();
}
}
model = new ListModel<OpResult>(resultsDto);
modelResourceResults = new ListModel<>(resourceResultsDto);
connectorResourceResults = new ListModel<>(connectorStructs);
}

private void initLayout() {
private boolean isConnectorResult(OperationResult subresult) {
return subresult.getOperation().equals(ConnectorTestOperation.CONNECTOR_TEST.getOperation());
}

private boolean isKnownResult(OperationResult subresult) {
for (ConnectorTestOperation connectorOperation : ConnectorTestOperation.values()) {
if (connectorOperation.getOperation().equals(subresult.getOperation())) {
return true;
}
}
return false;
}


private void initLayout() {
setOutputMarkupId(true);

WebMarkupContainer messagesPanel = new WebMarkupContainer(ID_MESSAGES_PANEL);
messagesPanel.setOutputMarkupId(true);
add(messagesPanel);

ListView<ConnectorStruct> connectorView = new ListView<ConnectorStruct>(ID_CONNECTOR_MESSAGES_PANEL, connectorResourceResults) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<ConnectorStruct> item) {
Label connectorNameLabel = new Label(ID_CONNECTOR_NAME, item.getModelObject().connectorName);
item.add(connectorNameLabel);
RepeatingView connectorResultView = new RepeatingView(ID_CONNECTOR_MESSAGES);
List<OpResult> resultsDto = item.getModelObject().connectorResultsDto;
if (resultsDto != null) {
initResultsPanel(connectorResultView, resultsDto, parentPage);
}
item.add(connectorResultView);
}

};
messagesPanel.add(connectorView);

RepeatingView resultView = new RepeatingView(ID_MESSAGES);
if (model.getObject() != null && model.getObject().size() > 0) {
initResultsPanel(resultView, parentPage);
RepeatingView resultView = new RepeatingView(ID_RESOURCE_MESSAGES);
if (modelResourceResults.getObject() != null) {
initResultsPanel(resultView, modelResourceResults.getObject(), parentPage);
}
resultView.setOutputMarkupId(true);
messagesPanel.add(resultView);
}

public void initResultsPanel(RepeatingView resultView, Page parentPage) {
for (OpResult result : model.getObject()) {
public void initResultsPanel(RepeatingView resultView, List<OpResult> opresults, Page parentPage) {
for (OpResult result : opresults) {
OperationResultPanel resultPanel = new OperationResultPanel(resultView.newChildId(), new Model<>(result), parentPage);
resultPanel.setOutputMarkupId(true);
resultView.add(resultPanel);
}
}


private class ConnectorStruct implements Serializable {
private String connectorName;
private List<OpResult> connectorResultsDto;
}
}

0 comments on commit 5b45811

Please sign in to comment.