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
1azyman committed May 4, 2016
2 parents 221f93b + 5afa9fd commit 17babcf
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 124 deletions.
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015 Evolveum
* Copyright (c) 2015-2016 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,9 +15,9 @@
*/
package com.evolveum.midpoint.web.component.prism;

import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand All @@ -27,23 +27,43 @@
* @author semancik
*
*/
public class AssociationWrapper extends PropertyWrapper {

public class AssociationWrapper extends PropertyWrapper<PrismContainer<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> {
private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(AssociationWrapper.class);

private RefinedAssociationDefinition assocRDef;

public AssociationWrapper(ContainerWrapper container, PrismContainer<ShadowAssociationType> property, boolean readonly, ValueStatus status) {
public AssociationWrapper(ContainerWrapper<ShadowAssociationType> container, PrismContainer<ShadowAssociationType> property,
boolean readonly, ValueStatus status, RefinedAssociationDefinition assocRDef) {
super(container, property, readonly, status);
this.assocRDef = assocRDef;
}

@Override
public ValueWrapper createAddedValue() {
public ValueWrapper<ShadowAssociationType> createAddedValue() {
PrismContainer<ShadowAssociationType> container = (PrismContainer<ShadowAssociationType>)getItem();
PrismContainerValue<ShadowAssociationType> cval = container.createNewValue();
ValueWrapper wrapper = new ValueWrapper(this, cval, ValueStatus.ADDED);
ValueWrapper<ShadowAssociationType> wrapper = new ValueWrapper<>(this, cval, ValueStatus.ADDED);

return wrapper;
}

@Override
public String getDisplayName() {
if (assocRDef != null) {
String displayName = assocRDef.getDisplayName();
if (displayName != null) {
return displayName;
}
}
return super.getDisplayName();
}

public RefinedAssociationDefinition getRefinedAssociationDefinition() {
return assocRDef;
}

@Override
protected String getDebugName() {
return "AssociationWrapper";
Expand Down
Expand Up @@ -276,8 +276,9 @@ private List<ItemWrapper> createProperties(ContainerWrapper cWrapper, OperationR
}

for (Map.Entry<QName, PrismContainer<ShadowAssociationType>> assocEntry : assocMap.entrySet()) {
// HACK HACK HACK, the container wrapper should not parse itself. This code should not be here.
AssociationWrapper assocWrapper = new AssociationWrapper(cWrapper, assocEntry.getValue(), cWrapper.isReadonly(), ValueStatus.NOT_CHANGED);
RefinedAssociationDefinition assocRDef = rOcDef.findAssociation(assocEntry.getKey());
AssociationWrapper assocWrapper = new AssociationWrapper(cWrapper, assocEntry.getValue(),
cWrapper.isReadonly(), ValueStatus.NOT_CHANGED, assocRDef);
properties.add(assocWrapper);
}

Expand Down
Expand Up @@ -212,9 +212,7 @@ private <O extends ObjectType> List<ContainerWrapper<? extends Containerable>> c
ContainerWrapper wrapper = cwf.createContainerWrapper(oWrapper, container, status, new ItemPath(name));
result.addSubresult(cwf.getResult());
list.add(wrapper);
// list.addAll(createContainerWrapper(container, null, pageBase));
if (!ShadowType.F_ASSOCIATION.equals(name)) {
// [pm] is this OK? "name" is the name of the container itself; originally here was an empty path - that seems more logical
addContainerWrappers(list, oWrapper, container, new ItemPath(name), result);
}

Expand Down Expand Up @@ -371,8 +369,7 @@ private <O extends ObjectType> void addShadowContainers(
.addAll(createCustomContainerWrapper(oWrapper, object, objectDefinitionForEditing, ShadowType.F_CREDENTIALS, result));
}

PrismContainer<ShadowAssociationType> associationContainer = object
.findOrCreateContainer(ShadowType.F_ASSOCIATION);
PrismContainer<ShadowAssociationType> associationContainer = object.findOrCreateContainer(ShadowType.F_ASSOCIATION);
attributesContainerWrapper = cwf.createContainerWrapper(oWrapper, associationContainer, ContainerStatus.MODIFYING,
new ItemPath(ShadowType.F_ASSOCIATION));
result.addSubresult(cwf.getResult());
Expand Down
Expand Up @@ -55,6 +55,7 @@ public class PrismPropertyPanel<IW extends ItemWrapper> extends Panel {
private static final Trace LOGGER = TraceManager.getTrace(PrismPropertyPanel.class);
private static final String ID_HAS_PENDING_MODIFICATION = "hasPendingModification";
private static final String ID_HELP = "help";
private static final String ID_LABEL = "label";
private static final String ID_LABEL_CONTAINER = "labelContainer";

private PageBase pageBase;
Expand Down Expand Up @@ -99,7 +100,7 @@ private void initLayout(final IModel<IW> model, final Form form) {
add(labelContainer);

final IModel<String> label = createDisplayName(model);
labelContainer.add(new Label("label", label));
labelContainer.add(new Label(ID_LABEL, label));

final IModel<String> helpText = new LoadableModel<String>(false) {

Expand Down

0 comments on commit 17babcf

Please sign in to comment.