Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
…into post-3.7-fixes
  • Loading branch information
katkav committed Feb 16, 2018
2 parents d2cd74a + 1e22a1f commit 545955a
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 131 deletions.
Expand Up @@ -53,9 +53,7 @@
import com.evolveum.midpoint.schema.util.LocalizationUtil;
import com.evolveum.midpoint.util.*;
import com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider;
import com.evolveum.midpoint.web.component.prism.InputPanel;
import com.evolveum.midpoint.web.component.prism.ItemWrapper;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.collections4.CollectionUtils;
Expand Down Expand Up @@ -873,6 +871,22 @@ public List<DisplayableValue> getObject() {
}


public static <IW extends ItemWrapper, C extends Containerable> PropertyModel createPrismPropertySingleValueModel(IModel<ContainerValueWrapper<C>> containerModel,
QName attributeName){
//todo should be refactored: wrap with some new model
PropertyModel<List<IW>> propertiesModel = new PropertyModel<>(containerModel, "properties");
List<IW> propertiesList = propertiesModel.getObject();
for (final IW property : propertiesList){
if (property.getName().equals(attributeName)){
List<ValueWrapper> valuesList = property.getValues();
if (valuesList.size() == 1) {
return new PropertyModel<>(valuesList.get(0).getValue(), "value");
}

}
}
return null;
}

private static List<DisplayableValue> getDisplayableValues(PrismPropertyDefinition def) {
List<DisplayableValue> values = null;
Expand Down
@@ -0,0 +1,61 @@
<!--
~ Copyright (c) 2010-2018 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 class="box-body">
<div class="container-fluid prism-object">

<div class="row">
<label class="col-md-1 pull-left"><h4>
<wicket:message key="AssociationDetailsPanel.AssociationHeader" />
</h4></label>
<button wicket:id="removeAssociation" wicket:message="title:PrismObjectPanel.deleteContainer"
class="btn btn-box-tool" trigger="hover"><i class="fa fa-minus-circle"></i></button>
</div>
<div class="row">
<div class="container-fluid prism-container">
<div class="prism-properties">

<div>
<div class="row prism-property">
<div class="col-xs-3">
<span><wicket:message key="ResourceObjectAssociationType.ref"/></span>
</div>
<div class="col-xs-8">
<div wicket:id="refField"/>
</div>
</div>
</div>
<div class="stripe">
<div class="row prism-property">
<div class="col-xs-3">
<span><wicket:message key="AssociationDetailsPanel.expressionPanel"/></span>
</div>
<div class="col-xs-8">
<div wicket:id="expressionPanel"/>
</div>
</div>
</div>

</div>
</div>
</div>
</div>
</div>
</wicket:panel>
</html>
@@ -0,0 +1,102 @@
/**
* Copyright (c) 2015-2018 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.component.assignment;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.input.ExpressionValuePanel;
import com.evolveum.midpoint.web.component.input.QNameEditorPanel;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.PrismContainerValueHeaderPanel;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

import javax.xml.namespace.QName;
import java.util.List;

/**
* Created by honchar
*/
public class AssociationDetailsPanel extends BasePanel<ContainerValueWrapper<ResourceObjectAssociationType>>{
private static final long serialVersionUID = 1L;

private static final String ID_REF_FIELD = "refField";
private static final String ID_EXPRESSION_PANEL = "expressionPanel";
private static final String ID_REMOVE_ASSOCIATION = "removeAssociation";

private ConstructionType construction;

public AssociationDetailsPanel(String id, IModel<ContainerValueWrapper<ResourceObjectAssociationType>> associationWrapperModel,
ConstructionType construction){
super(id, associationWrapperModel);
this.construction = construction;
}

@Override
protected void onInitialize(){
super.onInitialize();
initLayout();
}

private void initLayout(){
QNameEditorPanel refField = new QNameEditorPanel(ID_REF_FIELD, WebComponentUtil.createPrismPropertySingleValueModel(getModel(), ResourceObjectAssociationType.F_REF),
null, null, false, false){
private static final long serialVersionUID = 1L;
@Override
protected AttributeAppender getSpecificLabelStyleAppender() {
return AttributeAppender.append("style", "font-weight: normal !important;");
}
};
refField.setOutputMarkupId(true);
add(refField);

ResourceObjectAssociationType resourceObjectAssociationType = getModelObject().getContainerValue().asContainerable();
MappingType outbound = resourceObjectAssociationType.getOutbound();
ExpressionValuePanel expressionValuePanel = new ExpressionValuePanel(ID_EXPRESSION_PANEL,
new PropertyModel<ExpressionType>(outbound, MappingType.F_EXPRESSION.getLocalPart()),
construction, getPageBase());
expressionValuePanel.setOutputMarkupId(true);
add(expressionValuePanel);

ToggleIconButton removeAssociationButton = new ToggleIconButton(ID_REMOVE_ASSOCIATION,
GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER, GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER) {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
// isChildContainersSelectorPanelVisible = true;
// target.add(PrismContainerValueHeaderPanel.this);
}

@Override
public boolean isOn() {
return true;
}
};
add(removeAssociationButton);


}
}
Expand Up @@ -26,7 +26,7 @@

<div>
<div class="row prism-property">
<div class="col-xs-4">
<div class="col-xs-3">
<span><wicket:message key="ConstructionType.kind"/></span>
</div>
<div class="col-xs-8">
Expand All @@ -36,7 +36,7 @@
</div>
<div class="stripe">
<div class="row prism-property">
<div class="col-xs-4">
<div class="col-xs-3">
<span><wicket:message key="ConstructionType.intent"/></span>
</div>
<div class="col-xs-8">
Expand All @@ -50,6 +50,8 @@
</div>
</div>
</div>
<!--<div wicket:id="associationContainer" />-->
<div wicket:id="associationContainer" >
<div wicket:id="association" />
</div>
</wicket:panel>
</html>
Expand Up @@ -32,14 +32,13 @@
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ItemWrapper;
import com.evolveum.midpoint.web.component.prism.ValueWrapper;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.WebMarkupContainer;
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.LoadableDetachableModel;
import org.apache.wicket.model.Model;
Expand All @@ -58,6 +57,8 @@ public class ConstructionDetailsPanel<C extends Containerable, IW extends ItemWr

private static final String ID_KIND_FIELD = "kindField";
private static final String ID_INTENT_FIELD = "intentField";
private static final String ID_ASSOCIATION_CONTAINER = "associationContainer";
private static final String ID_ASSOCIATION = "association";

private static final Trace LOGGER = TraceManager.getTrace(ConstructionDetailsPanel.class);
private static final String DOT_CLASS = ConstructionDetailsPanel.class.getName() + ".";
Expand Down Expand Up @@ -98,7 +99,7 @@ protected PrismObject<ResourceType> load() {

private void initLayout(){
DropDownChoicePanel kindDropDown = WebComponentUtil.createEnumPanel(ShadowKindType.class, ID_KIND_FIELD,
getPropertyModelForConstructionAttribute(ConstructionType.F_KIND), ConstructionDetailsPanel.this);
WebComponentUtil.createPrismPropertySingleValueModel(getModel(), ConstructionType.F_KIND), ConstructionDetailsPanel.this);
kindDropDown.setOutputMarkupId(true);
kindDropDown.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

Expand All @@ -111,9 +112,32 @@ protected void onUpdate(AjaxRequestTarget target) {
add(kindDropDown);

DropDownChoicePanel intentDropDown = new DropDownChoicePanel(ID_INTENT_FIELD,
getPropertyModelForConstructionAttribute(ConstructionType.F_INTENT), getIntentAvailableValuesModel());
WebComponentUtil.createPrismPropertySingleValueModel(getModel(), ConstructionType.F_INTENT), getIntentAvailableValuesModel());
intentDropDown.setOutputMarkupId(true);
add(intentDropDown);


ListView<ContainerValueWrapper<ResourceObjectAssociationType>> associationDetailsPanel =
new ListView<ContainerValueWrapper<ResourceObjectAssociationType>>(ID_ASSOCIATION_CONTAINER, getAssociationsModel()){
@Override
protected void populateItem(ListItem<ContainerValueWrapper<ResourceObjectAssociationType>> item) {
item.add(new AssociationDetailsPanel(ID_ASSOCIATION, item.getModel(),
(ConstructionType)ConstructionDetailsPanel.this.getModelObject().getContainerValue().asContainerable()));
}
};
associationDetailsPanel.setOutputMarkupId(true);
add(associationDetailsPanel);
}

private PropertyModel<List<ContainerValueWrapper<ResourceObjectAssociationType>>> getAssociationsModel(){
// PropertyModel<List<IW>> propertiesModel = new PropertyModel<>(get, "properties");
List<ItemWrapper> propertiesList = getModelObject().getItems();
for (ItemWrapper property : propertiesList){
if (property.getName().equals(ConstructionType.F_ASSOCIATION)){
return new PropertyModel<List<ContainerValueWrapper<ResourceObjectAssociationType>>>(property, "values");
}
}
return null;
}

private IModel<List<String>> getIntentAvailableValuesModel(){
Expand Down Expand Up @@ -144,55 +168,6 @@ protected List<String> load(){
};
}

private PropertyModel getPropertyModelForConstructionAttribute(QName attributeName){
//todo should be refactored. 1) relocate 2) wrap by some new kind of model
PropertyModel<List<IW>> propertiesModel = new PropertyModel<>(getModel(), "properties");
List<IW> propertiesList = propertiesModel.getObject();
for (final IW property : propertiesList){
if (property.getName().equals(attributeName)){
IModel<IW> itemWrapperModel = new IModel<IW>() {
@Override
public IW getObject() {
return property;
}

@Override
public void setObject(IW iw) {
propertiesList.set(propertiesList.indexOf(property), iw);
}

@Override
public void detach() {

}
};
PropertyModel<List<ValueWrapper>> valuesModel = new PropertyModel<>(itemWrapperModel, "values");
List<ValueWrapper> valuesList = valuesModel.getObject();
if (valuesList.size() > 0) {
IModel<ValueWrapper> valueWrapperModel = new IModel<ValueWrapper>() {
@Override
public ValueWrapper getObject() {
return valuesList.get(0);
}

@Override
public void setObject(ValueWrapper valueWrapper) {
valuesList.set(0, valueWrapper);
}

@Override
public void detach() {

}
};
return new PropertyModel<>(valueWrapperModel, "value.value");
}

}
}
return null;
}

private DropDownChoicePanel getKindDropdownComponent(){
return (DropDownChoicePanel) get(ID_KIND_FIELD);
}
Expand Down
Expand Up @@ -126,15 +126,16 @@ private void addOrReplaceProperties(IModel<ContainerWrapper<C>> model, final For

@Override
protected void populateItem(ListItem<ContainerValueWrapper<C>> item) {
if (model.getObject().getName().equals(AssignmentType.F_CONSTRUCTION)){
ConstructionDetailsPanel panel = new ConstructionDetailsPanel("value", item.getModel());
panel.setOutputMarkupId(true);
item.add(panel);
} else {
//todo simplified construction panel will be in the gui starting from 3.8
// if (model.getObject().getName().equals(AssignmentType.F_CONSTRUCTION)){
// ConstructionDetailsPanel panel = new ConstructionDetailsPanel("value", item.getModel());
// panel.setOutputMarkupId(true);
// item.add(panel);
// } else {
ContainerValuePanel<C> containerPanel = new ContainerValuePanel<C>("value", item.getModel(), true, form, isPanelVisible, pageBase);
containerPanel.setOutputMarkupId(true);
item.add(containerPanel);
}
// }

}

Expand Down
Expand Up @@ -3917,6 +3917,8 @@ TreeTablePanel.menu.unassignApproversSelected=Unassign selected approvers
TreeTablePanel.menu.unassignOwnersSelected=Unassign selected owners
TreeTablePanel.menu.unassignManagersSelected=Unassign selected managers
Button.cancel=Cancel
AssociationDetailsPanel.expressionPanel=Outbound expression
AssociationDetailsPanel.AssociationHeader=Association
RoleRelationSelectionPanel.select.relation=Select relations to process
operation.com.evolveum.midpoint.web.page.admin.workflow.PageWorkItem.delegateWorkItem=Delegate work item
AbstractRoleAssignmentPanel.relationLabel=Relation
Expand Down
Expand Up @@ -346,6 +346,11 @@ public S_AtomicFilterEntry not() {
public S_ConditionEntry item(QName... names) {
return item(new ItemPath(names));
}

@Override
public S_ConditionEntry item(String... names) {
return item(new ItemPath(names));
}

@Override
public S_ConditionEntry item(ItemPath itemPath) {
Expand Down

0 comments on commit 545955a

Please sign in to comment.