Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 5, 2017
2 parents 8861ff8 + 14e349b commit 63b2e4e
Show file tree
Hide file tree
Showing 38 changed files with 1,315 additions and 342 deletions.
Expand Up @@ -151,28 +151,24 @@ protected <T extends ObjectType> void addSelectedAssignmentsPerformed(AjaxReques
target.add(getPageBase().getFeedbackPanel());
return;
}
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());

for (T object : assignmentsList){
// ContainerWrapper<AssignmentType> newAssignmentContainer = factory.createContainerWrapper(object.asPrismContainerValue().getContainer(),
// ContainerStatus.ADDING, new ItemPath(FocusType.F_ASSIGNMENT));

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(object.getOid());
ort.setRelation(SchemaConstants.ORG_DEFAULT);
ort.setType(WebComponentUtil.classToQName(getPageBase().getPrismContext(), object.getClass()));


PrismContainerValue<AssignmentType> newAssignment = getModelObject().getItem().createNewValue();
newAssignment.asContainerable().setTargetRef(ort);


// AssignmentType assignment = new AssignmentType();
// assignment.setTargetRef(ort);
// assignment.asPrismContainerValue().setParent(getModelObject().getItem());

ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
ValueStatus.ADDED, new ItemPath(FocusType.F_ASSIGNMENT));
getModelObject().getValues().add(valueWrapper);
PrismContainerValue<AssignmentType> newAssignment = getModelObject().getItem().createNewValue();
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(object, relation);
AssignmentType assignmentType = newAssignment.asContainerable();
if (ResourceType.class.equals(object.getClass())) {
ConstructionType constructionType = new ConstructionType();
constructionType.setResourceRef(ref);
assignmentType.setConstruction(constructionType);
} else {
assignmentType.setTargetRef(ref);
}
ContainerValueWrapper<AssignmentType> newAssignmentValueWrapper = createNewAssignmentContainerValueWrapper(newAssignment);
// getModelObject().getValues().add(newAssignmentValueWrapper);

// ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment.asPrismContainerValue(),
// ValueStatus.ADDED, new ItemPath(FocusType.F_ASSIGNMENT));
// getModelObject().getValues().add(valueWrapper);
}

refreshTable(target);
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand All @@ -47,6 +48,7 @@
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxIconButton;
Expand All @@ -66,6 +68,7 @@
import com.evolveum.midpoint.web.session.UserProfileStorage.TableId;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;

import javax.xml.datatype.XMLGregorianCalendar;

Expand Down Expand Up @@ -275,6 +278,7 @@ public void onClick(AjaxRequestTarget target, IModel<ContainerValueWrapper<Assig
@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {

List<ItemWrapper> assignmentItems = rowModel.getObject().getItems();//ContainerValue().findContainer(AssignmentType.F_ACTIVATION);
ItemWrapper activationItem = null;
for (ItemWrapper wrapper : assignmentItems){
Expand Down Expand Up @@ -323,7 +327,7 @@ public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentTyp
protected abstract List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initColumns();

protected abstract void newAssignmentClickPerformed(AjaxRequestTarget target);

protected void initCustomLayout(WebMarkupContainer assignmentsContainer) {

}
Expand All @@ -349,7 +353,7 @@ public boolean isVisible() {

@Override
public List<ContainerValueWrapper<AssignmentType>> getObject() {
return getAssignmentListProvider().getSelectedData();
return getModelObject().getValues().stream().filter(v -> v.isSelected()).collect(Collectors.toList());
}
};

Expand Down Expand Up @@ -377,10 +381,11 @@ protected void populateItem(ListItem<ContainerValueWrapper<AssignmentType>> item
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
public void onClick(AjaxRequestTarget target) {
assignmentDetailsVisible = false;
getSelectedAssignments().stream().forEach(a -> a.setSelected(false));
ajaxRequestTarget.add(AssignmentPanel.this);
refreshTable(target);
target.add(AssignmentPanel.this);
}
};
details.add(doneButton);
Expand Down Expand Up @@ -485,13 +490,23 @@ protected void deleteAssignmentPerformed(AjaxRequestTarget target, List<Containe
if (toDelete == null){
return;
}
for (ContainerValueWrapper<AssignmentType> assignmentContainerWrapper : getModelObject().getValues()){
if (toDelete.contains(assignmentContainerWrapper)){
assignmentContainerWrapper.setStatus(ValueStatus.DELETED);
}
}
toDelete.forEach(value -> value.setStatus(ValueStatus.DELETED));
// for (ContainerValueWrapper<AssignmentType> assignmentContainerWrapper : getModelObject().getValues()){
// if (toDelete.contains(assignmentContainerWrapper)){
// assignmentContainerWrapper.setStatus(ValueStatus.DELETED);
// }
// }
refreshTable(target);
}

protected ContainerValueWrapper<AssignmentType> createNewAssignmentContainerValueWrapper(PrismContainerValue<AssignmentType> newAssignment) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
ValueStatus.ADDED, new ItemPath(FocusType.F_ASSIGNMENT));
valueWrapper.setShowEmpty(true, false);
getModelObject().getValues().add(valueWrapper);
return valueWrapper;
}

protected WebMarkupContainer getAssignmentContainer() {
return (WebMarkupContainer) get(ID_ASSIGNMENTS);
Expand Down
Expand Up @@ -16,12 +16,17 @@
package com.evolveum.midpoint.web.component.assignment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapperFactory;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -143,29 +148,17 @@ private AssignmentsTabStorage getPolicyRulesTabStorage(){

@Override
protected void newAssignmentClickPerformed(AjaxRequestTarget target) {
// TODO Auto-generated method stub

AssignmentType assignment = new AssignmentType();

PolicyRuleType policyRule = new PolicyRuleType(getPageBase().getPrismContext());
policyRule.setDescription("");
assignment.setPolicyRule(policyRule);

// ContainerValueWrapper<AssignmentType> newAssignmentContainerWrapper = assignmentContainerWrapper.createItem(false);
// newAssignmentContainerWrapper.setStatus(ValueStatus.ADDED);
// newAssignmentContainerWrapper.getContainerValue().getValue().setupContainerValue(assignment.asPrismContainerValue());
// getModelObject().add(newAssignmentContainerWrapper);
target.add(getAssignmentContainer());
PrismContainerValue<AssignmentType> newAssignment = getModelObject().getItem().createNewValue();
ContainerValueWrapper<AssignmentType> newAssignmentWrapper = createNewAssignmentContainerValueWrapper(newAssignment);
assignmentDetailsPerformed(target, Arrays.asList(newAssignmentWrapper));
// refreshTable(target);

}

@Override
protected ObjectQuery createObjectQuery() {
return QueryBuilder.queryFor(AssignmentType.class, getParentPage().getPrismContext())
.block()
.not()
.item(getModelObject().getItemDefinition(), new ItemPath(AssignmentType.F_POLICY_RULE))
.isNull()
.endBlock()
.exists(AssignmentType.F_POLICY_RULE)
.build();
}

Expand Down
Expand Up @@ -147,14 +147,30 @@ protected ObjectQuery createChooseQuery(List<PrismReferenceValue> values) {
// }

if (oidList.isEmpty()) {
ObjectFilter customFilter = createCustomFilter();
if (customFilter != null) {
query.addFilter(customFilter);
return query;
}

return null;

}

ObjectFilter oidFilter = InOidFilter.createInOid(oidList);
query.setFilter(NotFilter.createNot(oidFilter));

ObjectFilter customFilter = createCustomFilter();
if (customFilter != null) {
query.addFilter(customFilter);
}

return query;
}

protected ObjectFilter createCustomFilter() {
return null;
}

/**
* @return css class for off-setting other values (not first, left to the
Expand Down
Expand Up @@ -81,6 +81,7 @@ public void onClick(AjaxRequestTarget ajaxRequestTarget) {
}
};
menuItemButton.setOutputMarkupId(true);
menuItemButton.setOutputMarkupPlaceholderTag(true);
menuItemButton.add(new AttributeAppender("class", "dropdown-toggle " + getAdditionalButtonClass()));
menuItemButton.add(new AttributeAppender("style", getMenuItemButtonStyle()));
menuItemContainer.add(menuItemButton);
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.evolveum.midpoint.web.component.assignment.AssignmentsUtil;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.web.model.ContainerWrapperFromObjectWrapperModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.Component;
Expand Down Expand Up @@ -66,6 +67,7 @@ private void initLayout() {
assignments.setOutputMarkupId(true);
add(assignments);

new ContainerWrapperFromObjectWrapperModel<>(getObjectWrapperModel(), new ItemPath(FocusType.F_ASSIGNMENT));
AbstractRoleAssignmentPanel panel = new AbstractRoleAssignmentPanel(ID_ASSIGNMENTS_PANEL, Model.of(assignmentsContainerWrapper));

// new AbstractReadOnlyModel<ContainerWrapper<AssignmentType>>() {
Expand Down
Expand Up @@ -130,7 +130,10 @@ protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item)
packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);

shadowPanel = new PrismPanel<F>(ID_SHADOW,
new ContainerWrapperListFromObjectWrapperModel(objectWrapperModel, Arrays.asList(new ItemPath(ShadowType.F_ATTRIBUTES), SchemaConstants.PATH_ACTIVATION, SchemaConstants.PATH_PASSWORD)), packageRef,
new ContainerWrapperListFromObjectWrapperModel(objectWrapperModel,
Arrays.asList(new ItemPath(ShadowType.F_ATTRIBUTES),
SchemaConstants.PATH_ACTIVATION, SchemaConstants.PATH_PASSWORD
/*,new ItemPath(ShadowType.F_ASSOCIATION ) */)), packageRef,
getMainForm(), null, getPageBase());
} else {
shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {
Expand Down
Expand Up @@ -34,6 +34,8 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

/**
Expand Down Expand Up @@ -115,6 +117,7 @@ private <IW extends ItemWrapper> void addOrReplaceProperties(IModel<ContainerVal

@Override
protected void populateItem(final ListItem<IW> item) {

if (item.getModel().getObject() instanceof ContainerWrapper) {
PrismContainerPanel<C> containerPanel = new PrismContainerPanel("property", (IModel<ContainerWrapper<C>>) item.getModel(), true, form, isPanaleVisible, pageBase);
containerPanel.setOutputMarkupId(true);
Expand Down
Expand Up @@ -195,12 +195,22 @@ static String getDisplayNameFromItem(Item item) {
}

public boolean hasChanged() {
for (ItemWrapper item : getItems()) {
if (item.hasChanged()) {

switch (getStatus()) {
case DELETED :
return true;
}
case ADDED:
case NOT_CHANGED:
for (ItemWrapper item : getItems()) {
if (item.hasChanged()) {
return true;
}
}
}




return false;
}

Expand Down Expand Up @@ -372,7 +382,7 @@ public PrismContainerValue<C> createContainerValueAddDelta() throws SchemaExcept
try {
newValue.addAllReplaceExisting((Collection) getUpdatedContainerValueItems(containerValue.getPrismContext()));
} catch (TunnelException e) {
throw new SchemaException();
throw new SchemaException(e.getMessage(), e);
}

return newValue;
Expand Down Expand Up @@ -413,7 +423,7 @@ public Collection<Item> getUpdatedContainerValueItems(PrismContext prismContext)

}
} catch (SchemaException ex) {
throw new TunnelException("Cannot create add delta for container value: " + containerValue);
throw new TunnelException("Cannot create add delta for container value: " + containerValue, ex);
}
});
return updatedItems;
Expand Down

0 comments on commit 63b2e4e

Please sign in to comment.