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 Nov 29, 2017
2 parents 6024104 + c20f306 commit 3340a50
Show file tree
Hide file tree
Showing 61 changed files with 1,404 additions and 699 deletions.
Expand Up @@ -37,6 +37,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
Expand Down Expand Up @@ -1881,7 +1882,13 @@ public static void dispatchToObjectDetailsPage(PrismObject obj, Component compon
throw new SystemException("Error instantiating " + newObjectPageClass + ": " + e.getMessage(), e);
}

component.setResponsePage(page);
if (component.getPage() instanceof PageBase) {
// this way we have correct breadcrumbs
PageBase pb = (PageBase) component.getPage();
pb.navigateToNext(page);
} else {
component.setResponsePage(page);
}
}

public static void dispatchToObjectDetailsPage(Class<? extends ObjectType> objectClass, String oid, Component component, boolean failIfUnsupported) {
Expand Down Expand Up @@ -2270,6 +2277,10 @@ protected CharSequence getDefaultChoice(String selectedValue) {
return dropDown;
}

public static boolean isAllNulls(Iterable<?> array) {
return StreamSupport.stream(array.spliterator(), true).allMatch(o -> o == null);
}

private static IModel<List<Boolean>> createChoices() {
return new AbstractReadOnlyModel<List<Boolean>>() {

Expand Down
Expand Up @@ -25,6 +25,8 @@
import javax.xml.validation.Schema;

import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit;
import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.web.component.prism.*;
Expand Down Expand Up @@ -235,16 +237,29 @@ protected int getItemsPerPage() {
}

protected ObjectQuery createObjectQuery() {
return QueryBuilder.queryFor(AssignmentType.class, getParentPage().getPrismContext())
.block()
.not()
.item(new ItemPath(AssignmentType.F_CONSTRUCTION, ConstructionType.F_RESOURCE_REF))
.isNull()
.endBlock()
.or()
.item(new ItemPath(AssignmentType.F_TARGET_REF))
.ref(getRelation())
.build();
QName relation = getRelation();
S_AtomicFilterExit tempFilter = QueryBuilder.queryFor(AssignmentType.class, getParentPage().getPrismContext())
.block()
.not()
.item(new ItemPath(AssignmentType.F_CONSTRUCTION, ConstructionType.F_RESOURCE_REF))
.isNull()
.endBlock();
if (PrismConstants.Q_ANY.equals(relation)){
return tempFilter
.or()
.block()
.not()
.item(new ItemPath(AssignmentType.F_TARGET_REF))
.ref(SchemaConstants.ORG_DEPUTY)
.endBlock()
.build();
} else {
return tempFilter
.or()
.item(new ItemPath(AssignmentType.F_TARGET_REF))
.ref(relation)
.build();
}
};

private QName getRelation() {
Expand Down
Expand Up @@ -740,7 +740,7 @@ public List<AssignmentsPreviewDto> getPrivilegeLimitationList() {
}

public void setPrivilegeLimitationList(List<AssignmentsPreviewDto> privilegeLimitationList) {
if (newAssignment.getLimitTargetContent() == null){
if (newAssignment.getLimitTargetContent() == null) {
newAssignment.setLimitTargetContent(new AssignmentSelectorType());
}
List<ObjectReferenceType> referencesList = newAssignment.getLimitTargetContent().getTargetRef();
Expand All @@ -758,6 +758,30 @@ public void setPrivilegeLimitationList(List<AssignmentsPreviewDto> privilegeLimi
}
this.privilegeLimitationList = privilegeLimitationList;
}

public boolean isLimitTargetAllowTransitive() {
AssignmentSelectorType limitTargetContent = newAssignment.getLimitTargetContent();
if (limitTargetContent == null) {
return false;
}
Boolean allowTransitive = limitTargetContent.isAllowTransitive();
if (allowTransitive == null) {
return false;
}
return allowTransitive;
}

public void setLimitTargetAllowTransitive(Boolean newValue) {
AssignmentSelectorType limitTargetContent = newAssignment.getLimitTargetContent();
if (limitTargetContent == null) {
if (newValue == null) {
return;
}
limitTargetContent = new AssignmentSelectorType();
newAssignment.setLimitTargetContent(limitTargetContent);
}
limitTargetContent.setAllowTransitive(newValue);
}

public UserType getDelegationOwner() {
return delegationOwner;
Expand Down Expand Up @@ -837,11 +861,11 @@ public void setDefaultRelation(){
}
}

public OtherPrivilegesLimitationType getPrivilegesLimitation(){
public OtherPrivilegesLimitationType getPrivilegesLimitation() {
return newAssignment.getLimitOtherPrivileges();
}

public void setPrivilegesLimitation(OtherPrivilegesLimitationType limitations){
public void setPrivilegesLimitation(OtherPrivilegesLimitationType limitations) {
newAssignment.setLimitOtherPrivileges(limitations);

}
Expand Down
Expand Up @@ -99,6 +99,17 @@
</div>
</div>
</div>
<div>
<div class="row prism-property">
<div class="col-xs-4">
<span><wicket:message key="DelegationEditorPanel.assignmentLimitations"/></span>
</div>
<div class="col-xs-8">
<input class="pull-left" type="checkbox" wicket:id="allowTransitive"/>
<wicket:message key="DelegationEditorPanel.allowTransitive"/>
</div>
</div>
</div>
<div>
<div class="row prism-property">
<div class="col-xs-4">
Expand Down
Expand Up @@ -57,7 +57,9 @@
* Created by honchar.
*/
public class DelegationEditorPanel extends AssignmentEditorPanel {
private static final String ID_DELEGATION_VALID_FROM = "delegationValidFrom";
private static final long serialVersionUID = 1L;

private static final String ID_DELEGATION_VALID_FROM = "delegationValidFrom";
private static final String ID_DELEGATION_VALID_TO = "delegationValidTo";
private static final String ID_DESCRIPTION = "delegationDescription";
private static final String ID_ARROW_ICON = "arrowIcon";
Expand All @@ -77,6 +79,7 @@ public class DelegationEditorPanel extends AssignmentEditorPanel {
private static final String ID_DELEGATE_APPROVAL_WI = "approvalWorkItems";
private static final String ID_DELEGATE_CERTIFICATION_WI = "certificationWorkItems";
private static final String ID_DELEGATE_MANAGEMENT_WI = "managementWorkItems";
private static final String ID_ALLOW_TRANSITIVE = "allowTransitive";
private static final String ID_ASSIGNMENT_PRIVILEGES_CHECKBOX = "assignmentPrivilegesCheckbox";
private static final String ID_ASSIGNMENT_PRIVILEGES_LABEL = "assignmentPrivilegesLabel";
private static final String ID_ASSIGNMENT_PRIVILEGES_CONTAINER = "assignmentPrivilegesContainer";
Expand Down Expand Up @@ -327,7 +330,8 @@ protected void addButtonClicked(AjaxRequestTarget target, List<AssignmentsPrevie
pageBase.showMainPopup(assignmentPreviewDialog, target);
}
};
limitPrivilegesButton.add(new VisibleEnableBehaviour(){
limitPrivilegesButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible(){
return UserDtoStatus.ADD.equals(getModelObject().getStatus()) &&
Expand Down Expand Up @@ -377,10 +381,12 @@ protected void onUpdate(AjaxRequestTarget target) {
};
approvalRights.setOutputMarkupId(true);
approvalRights.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {}
});
approvalRights.add(new VisibleEnableBehaviour(){
approvalRights.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled(){
return getModel().getObject().isEditable();
Expand Down Expand Up @@ -428,10 +434,12 @@ protected void onUpdate(AjaxRequestTarget target) {
}
};
certificationRights.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {}
});
certificationRights.add(new VisibleEnableBehaviour(){
certificationRights.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled(){
return getModel().getObject().isEditable();
Expand Down Expand Up @@ -459,6 +467,45 @@ public boolean isVisible(){
}
});
body.add(managementWorkItems);

AjaxCheckBox allowTransitive = new AjaxCheckBox(ID_ALLOW_TRANSITIVE,
new IModel<Boolean>(){
private static final long serialVersionUID = 1L;

@Override
public Boolean getObject() {
return getModelObject().isLimitTargetAllowTransitive();
}

@Override
public void setObject(Boolean value){
getModelObject().setLimitTargetAllowTransitive(value);
}

@Override
public void detach(){
}
}) {
private static final long serialVersionUID = 1L;

@Override
protected void onUpdate(AjaxRequestTarget target) {
}
};
allowTransitive.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {}
});
allowTransitive.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled(){
return getModel().getObject().isEditable();
}
});
allowTransitive.setOutputMarkupId(true);
body.add(allowTransitive);

addAjaxOnUpdateBehavior(body);
};
Expand Down
Expand Up @@ -15,14 +15,11 @@
*/
package com.evolveum.midpoint.web.component.assignment;

import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.PrismContainerPanel;
import com.evolveum.midpoint.web.component.prism.PrismPanel;
import com.evolveum.midpoint.web.model.ContainerWrapperFromObjectWrapperModel;
import com.evolveum.midpoint.web.model.ContainerWrapperListFromObjectWrapperModel;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand All @@ -33,56 +30,34 @@
/**
* Created by honchar.
*/
public class InducementDetailsPanel<R extends AbstractRoleType> extends AbstractRoleAssignmentDetailsPanel<R> {
public class InducementDetailsPanel<R extends AbstractRoleType, C extends Containerable> extends AbstractRoleAssignmentDetailsPanel<R> {
private static final long serialVersionUID = 1L;

public InducementDetailsPanel(String id, Form<?> form, IModel<ContainerValueWrapper<AssignmentType>> assignmentModel) {
super(id, form, assignmentModel);
}

// @Override
// protected void initContainersPanel(Form form, PageAdminObjectDetails<R> pageBase){
// ContainerWrapperListFromObjectWrapperModel<ConstructionType, R> containerModel =
// new ContainerWrapperListFromObjectWrapperModel<ConstructionType, R>(pageBase.getObjectModel(), collectContainersToShow());
// if (containerModel != null){
// containerModel.getObject().forEach(container -> {
// if (container.getName().equals(AssignmentType.F_CONSTRUCTION) &&
// container.getValues().size() > 0){
// container.getValues().get(0).getItems().forEach(constructionContainerItem -> {
// if (constructionContainerItem instanceof PrismContainer &&
// ((PrismContainer) constructionContainerItem).getElementName().equals(ConstructionType.F_ASSOCIATION)){
// PrismContainer<ResourceObjectAssociationType> associationCont =
// (PrismContainer<ResourceObjectAssociationType>)constructionContainerItem;
// ((PrismContainer) constructionContainerItem).getValue().
// }
// });
//
//
//
// List<ResourceObjectAssociationType> associations = construction.getAssociation();
// if (associations != null){
// associations.forEach(association -> {
//
// });
// }
// ContainerValueWrapper associationContainer =
// container.findContainerValueWrapper(container.getPath().append(ConstructionType.F_ASSOCIATION));
// if (associationContainer != null && associationContainer.getItems() != null) {
// associationContainer.getItems().forEach(itemWrapper -> {
// if (itemWrapper instanceof ContainerWrapper && ((ContainerWrapper) itemWrapper).getPath().last().toString()
// .equals(ResourceObjectAssociationType.F_OUTBOUND.getLocalPart())) {
// ((ContainerWrapper) itemWrapper).setAddContainAssignmentTypeerButtonVisible(true);
// ((ContainerWrapper) itemWrapper).setShowEmpty(true, false);
// }
// });
// }
// }
// });
// }
@Override
protected void initContainersPanel(Form form, PageAdminObjectDetails<R> pageBase){
ContainerWrapperListFromObjectWrapperModel<C, R> containerModel =
new ContainerWrapperListFromObjectWrapperModel<C, R>(pageBase.getObjectModel(), collectContainersToShow());
if (containerModel != null && containerModel.getObject() != null){
containerModel.getObject().forEach(container -> {
if (container.getName().equals(AssignmentType.F_CONSTRUCTION)) {
container.setAddContainerButtonVisible(true);
container.setShowEmpty(true, false);

// PrismPanel<AssignmentType> containers = new PrismPanel<>(ID_SPECIFIC_CONTAINERS, containerModel,
// null, form, null, pageBase) ;
// add(containers);
// }
ContainerWrapper associationWrapper = container.findContainerWrapper(container.getPath().append(ConstructionType.F_ASSOCIATION));
if (associationWrapper != null) {
associationWrapper.setRemoveContainerButtonVisible(true);
}
}
});
}

PrismPanel<C> containers = new PrismPanel<C>(ID_SPECIFIC_CONTAINERS, containerModel,
null, form, null, pageBase) ;
add(containers);
}

}
Expand Up @@ -569,6 +569,9 @@ private void addItemDelta(PropertyOrReferenceWrapper itemWrapper, ItemDelta pDel

public void addNewChildContainerValue(QName path, PageBase pageBase){
ContainerWrapper<C> childContainerWrapper = getContainer().findContainerWrapper(new ItemPath(getPath(), path));
if (childContainerWrapper == null){
return;
}
boolean isSingleValue = childContainerWrapper.getItemDefinition().isSingleValue();
if (isSingleValue){
return;
Expand Down
Expand Up @@ -405,12 +405,14 @@ private <C extends Containerable> ContainerWrapper<C> createContainerWrapper(Pri
PrismContainer<C> newContainer;
try {
newContainer = (PrismContainer) def.instantiate();
newContainer.setParent(containerValue);
// containerValue.add(newContainer);
} catch (SchemaException e) {
LoggingUtils.logException(LOGGER, "Cannot create container " + def.getName(), e);
return null;
}
return createContainerWrapper(newContainer, cWrapper.getObjectStatus(), ContainerStatus.ADDING, cWrapper.getPath().append(newContainer.getPath()));
return createContainerWrapper(newContainer, cWrapper.getObjectStatus(), ContainerStatus.ADDING,
cWrapper.getPath().append(new ItemPath(newContainer.getElementName())));
}
return createContainerWrapper(container, cWrapper.getObjectStatus(), cWrapper.getStatus() == ValueStatus.ADDED ? ContainerStatus.ADDING: ContainerStatus.MODIFYING, container.getPath());
}
Expand Down

0 comments on commit 3340a50

Please sign in to comment.