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
KaterynaHonchar committed Apr 10, 2018
2 parents ad70ec5 + 56c2aa6 commit 35533da
Show file tree
Hide file tree
Showing 23 changed files with 144 additions and 85 deletions.
Expand Up @@ -713,8 +713,7 @@ public static void addIncludeOptionsForExportOrView(Collection<SelectorOptions<G
}
}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator pageBase) {
OperationResult result = task.getResult();

ModelInteractionService mInteractionService = pageBase.getModelInteractionService();
Expand All @@ -737,6 +736,12 @@ public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase)
return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
return isEnableExperimentalFeature(task, pageBase);

}

public static AccessCertificationConfigurationType getCertificationConfiguration(PageBase pageBase) {
OperationResult result = new OperationResult(WebModelServiceUtils.class.getName() + ".getCertificationConfiguration");
Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.column.IsolatedCheckBoxPanel;
Expand Down Expand Up @@ -171,13 +172,15 @@ private void onPolicyAddedOrRemoved(PrismObject<AbstractRoleType> assignmentTarg
assignmentsModel.getObject().getValues().remove(assignmentToRemove);
} else {
if (added){
//TODO: not sure if this is correct way of creating new value.. this value is added directly to the origin object... what about deltas??
PrismContainerValue<AssignmentType> newAssignment = assignmentsModel.getObject().getItem().createNewValue();
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(assignmentTargetObject);
AssignmentType assignmentType = newAssignment.asContainerable();
assignmentType.setTargetRef(ref);
Task task = getPageBase().createSimpleTask("Creating new applicable policy");
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(assignmentsModel.getObject(), newAssignment,
assignmentsModel.getObject().getObjectStatus(), ValueStatus.ADDED, assignmentsModel.getObject().getPath());
assignmentsModel.getObject().getObjectStatus(), ValueStatus.ADDED, assignmentsModel.getObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
assignmentsModel.getObject().getValues().add(valueWrapper);
}
Expand Down
Expand Up @@ -50,6 +50,7 @@
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
Expand Down Expand Up @@ -459,8 +460,9 @@ protected void deleteAssignmentPerformed(AjaxRequestTarget target, List<Containe

protected ContainerValueWrapper<AssignmentType> createNewAssignmentContainerValueWrapper(PrismContainerValue<AssignmentType> newAssignment) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
Task task = getPageBase().createSimpleTask("Creating new assignment");
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath());
getModelObject().getObjectStatus(), ValueStatus.ADDED, getModelObject().getPath(), task);
valueWrapper.setShowEmpty(true, false);
getModelObject().getValues().add(valueWrapper);
return valueWrapper;
Expand Down
Expand Up @@ -281,6 +281,7 @@ private List<ObjectReferenceType> getAssociationsShadowRefs(boolean compareName,
private void addNewShadowRefValuePerformed(AjaxRequestTarget target, RefinedAssociationDefinition def){
ObjectFilter filter = WebComponentUtil.createAssociationShadowRefFilter(def,
getPageBase().getPrismContext(), resourceModel.getObject().getOid());
Task task = getPageBase().createAnonymousTask("Adding new shadow");
ObjectBrowserPanel<ShadowType> objectBrowserPanel = new ObjectBrowserPanel<ShadowType>(
getPageBase().getMainPopupBodyId(), ShadowType.class, Arrays.asList(ShadowType.COMPLEX_TYPE),
false, getPageBase(),
Expand All @@ -304,7 +305,7 @@ protected void onSelectPerformed(AjaxRequestTarget target, ShadowType object) {
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
ContainerValueWrapper<ResourceObjectAssociationType> valueWrapper =
factory.createContainerValueWrapper(associationWrapper, newAssociation,
associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath());
associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath(), task);
// valueWrapper.setShowEmpty(true, false);
associationWrapper.getValues().add(valueWrapper);

Expand Down
Expand Up @@ -155,7 +155,7 @@ public void computeStripes() {
}
int visibleProperties = 0;

for (ItemWrapper item : properties) {
for (ItemWrapper item : properties) {
if (item.isVisible()) {
visibleProperties++;
}
Expand Down Expand Up @@ -599,26 +599,7 @@ 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;
}
PrismContainerValue<C> newContainerValue = childContainerWrapper.getItem().createNewValue();
ContainerWrapperFactory factory = new ContainerWrapperFactory(pageBase);
ContainerValueWrapper newValueWrapper = factory.createContainerValueWrapper(childContainerWrapper,
newContainerValue, objectStatus,
ValueStatus.ADDED, new ItemPath(path));
newValueWrapper.setShowEmpty(true, false);
newValueWrapper.computeStripes();
childContainerWrapper.getValues().add(newValueWrapper);

}


private Item createItem(PropertyOrReferenceWrapper itemWrapper, ItemDefinition propertyDef) {
List<PrismValue> prismValues = new ArrayList<>();
for (Object vWrapper : itemWrapper.getValues()) {
Expand Down
Expand Up @@ -32,6 +32,7 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.TunnelException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -85,13 +86,14 @@ public <C extends Containerable> ContainerWrapper createContainerWrapper(
PrismContainer<C> container,
ContainerStatus objectStatus,
ContainerStatus status,
ItemPath path) {
ItemPath path,
Task task) {

result = new OperationResult(CREATE_PROPERTIES);

ContainerWrapper<C> cWrapper = new ContainerWrapper(container, objectStatus, status, path);

List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path);
List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path, task);
cWrapper.setProperties(containerValues);
cWrapper.computeStripes();

Expand Down Expand Up @@ -217,45 +219,45 @@ private boolean isEmpty(ValueWrapper shadowAssociationRef) {

}

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

result = new OperationResult(CREATE_PROPERTIES);

ContainerWrapper<C> cWrapper = new ContainerWrapper<>(container, objectStatus, status, path, readonly);

List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path);
List<ContainerValueWrapper<C>> containerValues = createContainerValues(cWrapper, path, task);
cWrapper.setProperties(containerValues);
cWrapper.computeStripes();


return cWrapper;
}

private <C extends Containerable> List<ContainerValueWrapper<C>> createContainerValues(ContainerWrapper<C> cWrapper, ItemPath path) {
private <C extends Containerable> List<ContainerValueWrapper<C>> createContainerValues(ContainerWrapper<C> cWrapper, ItemPath path, Task task) {
List<ContainerValueWrapper<C>> containerValueWrappers = new ArrayList<>();
PrismContainer<C> container = cWrapper.getItem();

if (container.getValues().isEmpty() && container.isSingleValue()) {
PrismContainerValue<C> pcv = container.createNewValue();
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), ValueStatus.ADDED, cWrapper.getPath());
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), ValueStatus.ADDED, cWrapper.getPath(), task);

containerValueWrappers.add(containerValueWrapper);
return containerValueWrappers;
}

container.getValues().forEach(pcv -> {
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), cWrapper.getStatus() == ContainerStatus.ADDING ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, pcv.getPath());
ContainerValueWrapper<C> containerValueWrapper = createContainerValueWrapper(cWrapper, pcv, cWrapper.getObjectStatus(), cWrapper.getStatus() == ContainerStatus.ADDING ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, pcv.getPath(), task);
containerValueWrappers.add(containerValueWrapper);
});


return containerValueWrappers;
}

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

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

ReferenceWrapper shadowRefWrapper = (ReferenceWrapper) containerValueWrapper.findPropertyWrapper(ShadowAssociationType.F_SHADOW_REF);
Expand All @@ -266,7 +268,7 @@ public <C extends Containerable> ContainerValueWrapper<C> createContainerValueWr
return containerValueWrapper;
}

public <O extends ObjectType, C extends Containerable> List<ItemWrapper> createProperties(ContainerValueWrapper<C> cWrapper, boolean onlyEmpty) {
public <O extends ObjectType, C extends Containerable> List<ItemWrapper> createProperties(ContainerValueWrapper<C> cWrapper, boolean onlyEmpty, Task task) {

result = new OperationResult(CREATE_PROPERTIES);

Expand All @@ -291,14 +293,20 @@ public <O extends ObjectType, C extends Containerable> List<ItemWrapper> createP
return;
}

if (itemDef.isExperimental() && !WebModelServiceUtils.isEnableExperimentalFeature(modelServiceLocator)) {
if (itemDef.isExperimental() && !WebModelServiceUtils.isEnableExperimentalFeature(task, modelServiceLocator)) {
LOGGER.trace("Skipping creating wrapper for {} because it is experimental a experimental features are not enabled.", itemDef.getName());
return;
}

LOGGER.trace("Creating wrapper for {}", itemDef);
try {
createPropertyOrReferenceWrapper(itemDef, cWrapper, propertyOrReferenceWrappers, onlyEmpty, cWrapper.getPath());
createContainerWrapper(itemDef, cWrapper, containerWrappers, onlyEmpty);
createContainerWrapper(itemDef, cWrapper, containerWrappers, onlyEmpty, task);
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "something strange happenned: " + e.getMessage(), e);
System.out.println(e.getMessage());
throw new TunnelException(e);
}

});

Expand Down Expand Up @@ -330,7 +338,7 @@ private <C extends Containerable> void createPropertyOrReferenceWrapper(ItemDefi


private <C extends Containerable> void createContainerWrapper(ItemDefinition itemDef, ContainerValueWrapper<C> cWrapper,
List<ContainerWrapper<C>> properties, boolean onlyEmpty){
List<ContainerWrapper<C>> properties, boolean onlyEmpty, Task task){

if (itemDef instanceof PrismContainerDefinition) {

Expand Down Expand Up @@ -367,7 +375,7 @@ private <C extends Containerable> void createContainerWrapper(ItemDefinition ite
// }
//
// } else {
subContainerWrapper = createContainerWrapper((PrismContainerDefinition<C>) itemDef, cWrapper, onlyEmpty);
subContainerWrapper = createContainerWrapper((PrismContainerDefinition<C>) itemDef, cWrapper, onlyEmpty, task);
// }

if (subContainerWrapper == null) {
Expand Down Expand Up @@ -456,7 +464,7 @@ private <C extends Containerable> ReferenceWrapper createReferenceWrapper(PrismR
}

private <C extends Containerable> ContainerWrapper<C> createContainerWrapper(PrismContainerDefinition<C> def,
ContainerValueWrapper<C> cWrapper, boolean onlyEmpty) {
ContainerValueWrapper<C> cWrapper, boolean onlyEmpty, Task task) {

PrismContainerValue<C> containerValue = cWrapper.getContainerValue();

Expand Down Expand Up @@ -487,9 +495,9 @@ private <C extends Containerable> ContainerWrapper<C> createContainerWrapper(Pri
return null;
}
return createContainerWrapper(newContainer, cWrapper.getObjectStatus(), ContainerStatus.ADDING,
cWrapper.getPath().append(new ItemPath(newContainer.getElementName())));
cWrapper.getPath().append(new ItemPath(newContainer.getElementName())), task);
}
return createContainerWrapper(container, cWrapper.getObjectStatus(), cWrapper.getStatus() == ValueStatus.ADDED ? ContainerStatus.ADDING: ContainerStatus.MODIFYING, container.getPath());
return createContainerWrapper(container, cWrapper.getObjectStatus(), cWrapper.getStatus() == ValueStatus.ADDED ? ContainerStatus.ADDING: ContainerStatus.MODIFYING, container.getPath(), task);
}

private <C extends Containerable> boolean isItemReadOnly(ItemDefinition def, ContainerValueWrapper<C> cWrapper) {
Expand Down

0 comments on commit 35533da

Please sign in to comment.