Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Aug 24, 2018
2 parents 59ddc5d + cc4f8ec commit 746e708
Show file tree
Hide file tree
Showing 57 changed files with 2,380 additions and 2,401 deletions.
Expand Up @@ -163,4 +163,9 @@ public class GuiStyleConstants {

public static final String CLASS_SYSTEM_CONFIGURATION_ICON = "fa fa-cog";
public static final String CLASS_SYSTEM_CONFIGURATION_ICON_COLORED = CLASS_SYSTEM_CONFIGURATION_ICON + " object-shadow-color";

public static final String CLASS_ASSIGN = "fa fa-link";
public static final String CLASS_UNASSIGN = "fa fa-unlink";
public static final String CLASS_RECONCILE = "fa fa-refresh";
public static final String CLASS_CREATE_FOCUS = "fa fa-user-plus";
}
Expand Up @@ -15,6 +15,7 @@
*/
package com.evolveum.midpoint.gui.api.component;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.model.api.RoleSelectionSpecification;
import com.evolveum.midpoint.prism.query.ObjectFilter;
Expand Down Expand Up @@ -62,7 +63,11 @@ protected void initParametersPanel(Fragment parametersPanel){
relationContainer.setOutputMarkupId(true);
parametersPanel.add(relationContainer);

relationContainer.add(new RelationDropDownChoicePanel(ID_RELATION, null, AreaCategoryType.ADMINISTRATION));
relationContainer.add(new RelationDropDownChoicePanel(ID_RELATION, null, getSupportedRelations(), false));
}

private List<QName> getSupportedRelations() {
return WebComponentUtil.getCategoryRelationChoices(AreaCategoryType.ADMINISTRATION, getPageBase());
}

@Override
Expand Down
Expand Up @@ -243,11 +243,6 @@ public boolean isVisible(){

}
}

protected PrismObject<O> getNewObjectListObject(){
return null;
}

private void adoptNewObject(PrismObject<O> object) throws SchemaException{
getPageBase().getMidpointApplication().getPrismContext().adopt(object);
}
Expand Down
Expand Up @@ -29,11 +29,6 @@
</div>
<div wicket:id="relationContainer" class="row">
<div class="form-group col-md-12">
<div class="col-md-1">
<div>
<wicket:message key="AssignmentEditorPanel.relation"/>
</div>
</div>
<div class="col-md-3">
<span wicket:id="relation"/>
</div>
Expand Down
Expand Up @@ -85,16 +85,7 @@ public boolean isEnabled(){
});
parametersPanel.add(relationContainer);

relationContainer.add(new RelationDropDownChoicePanel(ID_RELATION, null, AreaCategoryType.ADMINISTRATION){
private static final long serialVersionUID = 1L;

@Override
protected List<QName> getChoicesList(){
return supportedRelationList;
}


});
relationContainer.add(new RelationDropDownChoicePanel(ID_RELATION, null, supportedRelationList, false));
}

protected ObjectDelta prepareDelta(){
Expand Down
Expand Up @@ -27,7 +27,7 @@
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.page.admin.users.component.AbstractRoleMemberPanel;
import com.evolveum.midpoint.web.page.admin.roles.AbstractRoleMemberPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down
Expand Up @@ -633,12 +633,20 @@ public static List<QName> createObjectTypeList() {

// TODO: move to schema component
public static List<QName> createFocusTypeList() {
return createFocusTypeList(false);
}

public static List<QName> createFocusTypeList(boolean includeAbstractType) {
List<QName> focusTypeList = new ArrayList<>();

focusTypeList.add(UserType.COMPLEX_TYPE);
focusTypeList.add(OrgType.COMPLEX_TYPE);
focusTypeList.add(RoleType.COMPLEX_TYPE);
focusTypeList.add(ServiceType.COMPLEX_TYPE);

if (includeAbstractType) {
focusTypeList.add(FocusType.COMPLEX_TYPE);
}

return focusTypeList;
}
Expand Down Expand Up @@ -2421,9 +2429,9 @@ public static ItemVisibility checkShadowActivationAndPasswordVisibility(ItemWrap

}

public static List<QName> getCategoryRelationChoices(AreaCategoryType category, OperationResult result, ModelServiceLocator pageBase){
public static List<QName> getCategoryRelationChoices(AreaCategoryType category, ModelServiceLocator pageBase){
List<QName> relationsList = new ArrayList<>();
List<RelationDefinitionType> defList = getRelationDefinitions(result, pageBase);
List<RelationDefinitionType> defList = getRelationDefinitions(pageBase);
if (defList != null) {
defList.forEach(def -> {
if (def.getCategory() != null && def.getCategory().contains(category)) {
Expand All @@ -2435,14 +2443,14 @@ public static List<QName> getCategoryRelationChoices(AreaCategoryType category,
}

public static List<QName> getAllRelations(ModelServiceLocator pageBase) {
OperationResult result = new OperationResult("get all relations");
List<RelationDefinitionType> allRelationdefinitions = getRelationDefinitions(result, pageBase);
List<RelationDefinitionType> allRelationdefinitions = getRelationDefinitions(pageBase);
List<QName> allRelationsQName = new ArrayList<>(allRelationdefinitions.size());
allRelationdefinitions.stream().forEach(relation -> allRelationsQName.add(relation.getRef()));
return allRelationsQName;
}

public static List<RelationDefinitionType> getRelationDefinitions(OperationResult result, ModelServiceLocator pageBase){
public static List<RelationDefinitionType> getRelationDefinitions(ModelServiceLocator pageBase){
OperationResult result = new OperationResult("get relation definitions");
try {
return pageBase.getModelInteractionService().getRelationDefinitions(result);
} catch (ObjectNotFoundException | SchemaException ex){
Expand Down
Expand Up @@ -792,8 +792,7 @@ public void setDelegationOwner(UserType delegationOwner) {
}

public List<QName> getNotAssignedRelationsList(){
List<QName> availableRelations = WebComponentUtil.getCategoryRelationChoices(AreaCategoryType.ADMINISTRATION,
new OperationResult(OPERATION_LOAD_RELATION_DEFINITIONS), pageBase);
List<QName> availableRelations = WebComponentUtil.getCategoryRelationChoices(AreaCategoryType.ADMINISTRATION, pageBase);
List<QName> assignedRelationsList = getAssignedRelationsList();
if (assignedRelationsList == null || assignedRelationsList.size() == 0){
return availableRelations;
Expand Down Expand Up @@ -821,8 +820,7 @@ public boolean isAssignable() {
if (defualtAssignmentConstraints.isAllowSameTarget() && defualtAssignmentConstraints.isAllowSameRelation()){
return true;
}
List<QName> availableRelations = WebComponentUtil.getCategoryRelationChoices(AreaCategoryType.ADMINISTRATION,
new OperationResult(OPERATION_LOAD_RELATION_DEFINITIONS), pageBase);
List<QName> availableRelations = WebComponentUtil.getCategoryRelationChoices(AreaCategoryType.ADMINISTRATION, pageBase);
int relationsListSize = availableRelations == null ? 0 : availableRelations.size();
if (defualtAssignmentConstraints.isAllowSameTarget() && !defualtAssignmentConstraints.isAllowSameRelation()
&& getAssignedRelationsList().size() < relationsListSize){
Expand Down
Expand Up @@ -984,25 +984,13 @@ protected String load() {

private void addRelationDropDown(WebMarkupContainer relationContainer){
QName assignmentRelation = getModelObject().getTargetRef() != null ? getModelObject().getTargetRef().getRelation() : null;

RelationDropDownChoicePanel relationDropDown = new RelationDropDownChoicePanel(ID_RELATION,
Model.of(assignmentRelation != null ? assignmentRelation : SchemaConstants.ORG_DEFAULT), AreaCategoryType.SELF_SERVICE){
private static final long serialVersionUID = 1L;

@Override
protected List<QName> getChoicesList(){
AssignmentConstraintsType constraints = AssignmentEditorPanel.this.getModelObject().getDefaultAssignmentConstraints();
if (constraints == null ||
constraints.isAllowSameTarget() && constraints.isAllowSameRelation()){
return super.getChoicesList();
} else {
return AssignmentEditorPanel.this.getModelObject().getNotAssignedRelationsList();
}
}

};
relationDropDown.setEnabled(getModel().getObject().isEditable());
assignmentRelation != null ? assignmentRelation : SchemaConstants.ORG_DEFAULT, getSupportedRelations(), false); relationDropDown.setEnabled(getModel().getObject().isEditable());
relationDropDown.add(new VisibleEnableBehaviour() {

private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
return isCreatingNewAssignment();
Expand All @@ -1011,34 +999,16 @@ public boolean isVisible() {
relationContainer.add(relationDropDown);

}

private IModel<RelationTypes> getRelationModel(List<RelationTypes> availableRelations){
return new IModel<RelationTypes>() {
@Override
public RelationTypes getObject() {
RelationTypes defaultRelation = RelationTypes.MEMBER;
if (!getModelObject().isMultyAssignable() &&
getModelObject().getAssignedRelationsList().contains(defaultRelation)){
defaultRelation = availableRelations.get(0);
}
if (getModelObject().getTargetRef() == null){
return defaultRelation;
}
return RelationTypes.getRelationType(getModelObject().getTargetRef().getRelation());
}

@Override
public void setObject(RelationTypes relationTypes) {
if (getModelObject().getTargetRef() != null){
getModelObject().getTargetRef().setRelation(relationTypes.getRelation());
}
}

@Override
public void detach() {

}
};

private List<QName> getSupportedRelations() {
OperationResult result = new OperationResult("Relations for self service area");
AssignmentConstraintsType constraints = AssignmentEditorPanel.this.getModelObject().getDefaultAssignmentConstraints();
if (constraints == null ||
constraints.isAllowSameTarget() && constraints.isAllowSameRelation()){
return WebComponentUtil.getCategoryRelationChoices(AreaCategoryType.SELF_SERVICE, getPageBase());
} else {
return getModelObject().getNotAssignedRelationsList();
}
}


Expand Down
Expand Up @@ -300,7 +300,7 @@ private static void appendRelation(AssignmentType assignment, StringBuilder sb,
}

RelationDefinitionType relationDef = ObjectTypeUtil.findRelationDefinition(
WebComponentUtil.getRelationDefinitions(new OperationResult("AssignmentsUtil.loadRelationDefinitions"), pageBase),
WebComponentUtil.getRelationDefinitions(pageBase),
assignment.getTargetRef().getRelation());
if (relationDef != null && relationDef.getDisplay() != null &&
!relationDef.getDisplay().getLabel().isEmpty()) {
Expand Down
Expand Up @@ -221,8 +221,7 @@ private IModel<String> getAlreadyAssignedIconTitleModel(AssignmentEditorDto dto)
List<QName> assignedRelations = dto.getAssignedRelationsList();
StringBuilder relations = new StringBuilder();
if (assignedRelations != null && assignedRelations.size() > 0) {
List<RelationDefinitionType> defs = WebComponentUtil.getRelationDefinitions(new OperationResult(OPERATION_LOAD_RELATION_DEFINITION_LIST),
RoleCatalogItemButton.this.getPageBase());
List<RelationDefinitionType> defs = WebComponentUtil.getRelationDefinitions(RoleCatalogItemButton.this.getPageBase());
for (QName relation : assignedRelations) {
RelationDefinitionType def = ObjectTypeUtil.findRelationDefinition(defs, relation);
String relationLabel;
Expand Down
Expand Up @@ -16,11 +16,16 @@
-->

<wicket:panel xmlns:wicket="http://wicket.apache.org">
<div style="margin: 5px;">
<p align="center">
<select wicket:id="type" />
</p>

<div>

<div class="form-group">
<div class="col-md-12" wicket:id="type"/>
</div>
<div class="form-group col-md-12">
<label class="col-md-4"><wicket:message key="chooseFocusTypeAndRelationDialogPanel.relation"/></label>
<div class="col-md-8" wicket:id="relation" />
</div>

<p align="center">
<a class="btn btn-primary btn-sm" wicket:id="ok" />
</p>
Expand Down
@@ -0,0 +1,129 @@
package com.evolveum.midpoint.web.component.dialog;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.namespace.QName;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.model.util.ListModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.form.DropDownFormGroup;
import com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel;
import com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;

public class ChooseFocusTypeAndRelationDialogPanel extends BasePanel implements Popupable{

private static final String ID_OBJECT_TYPE = "type";
private static final String ID_RELATION = "relation";
private static final String ID_BUTTON_OK = "ok";

public ChooseFocusTypeAndRelationDialogPanel(String id) {
super(id);

}

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

private void initLayout(){

DropDownFormGroup<QName> type = new DropDownFormGroup<QName>(ID_OBJECT_TYPE, Model.of(FocusType.COMPLEX_TYPE), Model.ofList(getSupportedObjectTypes()),
new QNameObjectTypeChoiceRenderer(), createStringResource("chooseFocusTypeAndRelationDialogPanel.type"),
"chooseFocusTypeAndRelationDialogPanel.tooltip.type", true, "col-md-4", "col-md-8", false);
type.getInput().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
type.setOutputMarkupId(true);
add(type);

IModel<Map<String, String>> options = new Model(null);
Map<String, String> optionsMap = new HashMap<>();
// optionsMap.put("nonSelectedText", createStringResource("LoggingConfigPanel.appenders.Inherit").getString());
options.setObject(optionsMap);
ListMultipleChoicePanel<QName> relation = new ListMultipleChoicePanel<QName>(ID_RELATION, new ListModel<>(),
new ListModel<QName>(getSupportedRelations()), new QNameObjectTypeChoiceRenderer(), options);
relation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
relation.setOutputMarkupId(true);
add(relation);

AjaxButton confirmButton = new AjaxButton(ID_BUTTON_OK, createStringResource("Button.ok")) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
DropDownFormGroup<QName> type = (DropDownFormGroup<QName>) getParent().get(ID_OBJECT_TYPE);
QName typeChosen = type.getModelObject();

ListMultipleChoicePanel<QName> relation = (ListMultipleChoicePanel<QName>) getParent().get(ID_RELATION);
Collection<QName> relationChosen = relation.getModelObject();
ChooseFocusTypeAndRelationDialogPanel.this.okPerformed(typeChosen, relationChosen, target);
getPageBase().hideMainPopup(target);

}
};

add(confirmButton);



}

protected void okPerformed(QName type, Collection<QName> relation, AjaxRequestTarget target) {
// TODO Auto-generated method stub

}

protected List<QName> getSupportedObjectTypes() {
return WebComponentUtil.createFocusTypeList(true);
}

protected List<QName> getSupportedRelations() {
return WebComponentUtil.getAllRelations(getPageBase());
}

@Override
public int getWidth() {
return 400;
}

@Override
public int getHeight() {
return 300;
}

@Override
public String getWidthUnit(){
return "px";
}

@Override
public String getHeightUnit(){
return "px";
}

@Override
public StringResourceModel getTitle() {
return new StringResourceModel("ChooseFocusTypeDialogPanel.chooseType");
}

@Override
public Component getComponent() {
return this;
}


}

0 comments on commit 746e708

Please sign in to comment.