Skip to content

Commit

Permalink
association container - object wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Oct 2, 2017
1 parent 4836936 commit e96144e
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 71 deletions.
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 @@ -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 @@ -35,6 +35,7 @@
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
Expand Down Expand Up @@ -67,6 +68,9 @@ public class ContainerWrapper<C extends Containerable> extends PrismWrapper impl
private List<ContainerValueWrapper<C>> values;

private boolean readonly;

//TODO: HACK to have custom filter for association contianer here becasue of creating new association:
private ObjectFilter filter;

ContainerWrapper(PrismContainer<C> container, ContainerStatus status, ItemPath path) {
Validate.notNull(container, "container must not be null.");
Expand Down Expand Up @@ -97,13 +101,21 @@ public void revive(PrismContext prismContext) throws SchemaException {
}
}
}

public ObjectFilter getFilter() {
return filter;
}

public void setFilter(ObjectFilter filter) {
this.filter = filter;
}

@Override
public PrismContainerDefinition<C> getItemDefinition() {
return container.getDefinition();
}

public ContainerStatus getStatus() {
public ContainerStatus getStatus() {
return status;
}

Expand Down Expand Up @@ -287,16 +299,16 @@ public boolean isEmpty() {
return getItem().isEmpty();
}

public void addValue(boolean showEmpty) {
getValues().add(createItem(showEmpty));
public void addValue(ContainerValueWrapper<C> newValue) {
getValues().add(newValue);
}

public ContainerValueWrapper<C> createItem(boolean showEmpty) {
PrismContainerValue<C> pcv = container.createNewValue();
ContainerValueWrapper<C> wrapper = new ContainerValueWrapper<C>(this, pcv, ValueStatus.ADDED, pcv.getPath());
wrapper.setShowEmpty(showEmpty, true);
return wrapper;
}
// public ContainerValueWrapper<C> createItem(boolean showEmpty) {
// PrismContainerValue<C> pcv = container.createNewValue();
// ContainerValueWrapper<C> wrapper = new ContainerValueWrapper<C>(this, pcv, ValueStatus.ADDED, pcv.getPath());
// wrapper.setShowEmpty(showEmpty, true);
// return wrapper;
// }

public void sort(final PageBase pageBase) {
for (ContainerValueWrapper<C> valueWrapper : getValues()) {
Expand Down Expand Up @@ -468,4 +480,10 @@ private boolean emphasizedAndCanAdd(PrismContainerDefinition<C> def) {
return def.canAdd() && def.isEmphasized();
}

@Override
public void addValue(boolean showEmpty) {
// TODO Auto-generated method stub

}

}
Expand Up @@ -23,7 +23,11 @@
import com.evolveum.midpoint.gui.api.util.ModelServiceLocator;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.CapabilityUtil;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.util.DOMUtil;
Expand Down Expand Up @@ -90,12 +94,11 @@ public <C extends Containerable> ContainerWrapper createContainerWrapper(
List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path);
cWrapper.setProperties(containerValues);
cWrapper.computeStripes();

return cWrapper;
return cWrapper;
}


public <C extends Containerable> ContainerWrapper<C> createContainerWrapper(PrismContainer<C> container, ContainerStatus status, ItemPath path, boolean readonly) {
public <C extends Containerable> ContainerWrapper<C> createContainerWrapper(PrismContainer<C> container, ContainerStatus status, ItemPath path, boolean readonly) {

result = new OperationResult(CREATE_PROPERTIES);

Expand Down Expand Up @@ -130,12 +133,17 @@ private <C extends Containerable> List<ContainerValueWrapper<C>> createContainer
return containerValueWrappers;
}

private <C extends Containerable> ContainerValueWrapper<C> createContainerValueWrapper(ContainerWrapper cWrapper, PrismContainerValue<C> value, ValueStatus status, ItemPath path){
public <C extends Containerable> ContainerValueWrapper<C> createContainerValueWrapper(ContainerWrapper cWrapper, PrismContainerValue<C> value, ValueStatus status, ItemPath path){
ContainerValueWrapper<C> containerValueWrapper = new ContainerValueWrapper<C>(cWrapper, value, status, path);

List<ItemWrapper> properties = createProperties(containerValueWrapper, false);
containerValueWrapper.setProperties(properties);

ReferenceWrapper shadowRefWrapper = (ReferenceWrapper) containerValueWrapper.findPropertyWrapper(ShadowAssociationType.F_SHADOW_REF);
if (shadowRefWrapper != null && cWrapper.getFilter() != null) {
shadowRefWrapper.setFilter(cWrapper.getFilter());
}

return containerValueWrapper;
}

Expand Down

0 comments on commit e96144e

Please sign in to comment.