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 May 21, 2018
2 parents 591bbeb + c2ac2a7 commit 093e374
Show file tree
Hide file tree
Showing 30 changed files with 527 additions and 224 deletions.
Expand Up @@ -294,7 +294,7 @@ public void updateScopeDefinition(PrismContext prismContext) {
if (parsedSearchFilter != null) {
// check if everything is OK
try {
QueryConvertor.parseFilterPreliminarily(parsedSearchFilter.getFilterClauseXNode(), prismContext);
QueryConvertor.parseFilterPreliminarily(parsedSearchFilter.getFilterClauseXNode(), null, prismContext);
} catch (SchemaException e) {
throw new SystemException("Couldn't parse search filter: " + e.getMessage(), e);
}
Expand Down
Expand Up @@ -23,6 +23,7 @@

import javax.xml.namespace.QName;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand All @@ -37,6 +38,7 @@
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;

Expand All @@ -47,6 +49,7 @@
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
Expand All @@ -64,6 +67,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyConstraintType;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;


/**
Expand Down Expand Up @@ -182,12 +186,23 @@ public String getObject() {
}));
item.add(textWrapper);

TextField<String> property = new TextField<>(ID_PROPERTY,
new PropertyModel<>(item.getModel(), PropertyConstraintType.F_PATH.getLocalPart()));

ItemPathType itemPathType = (item.getModelObject() != null ) ? item.getModelObject().getPath() : null;
String pathToShow = itemPathType != null ? itemPathType.getItemPath().toString() : null;

TextField<String> property = new TextField<>(ID_PROPERTY, Model.of(pathToShow));

property.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
Component component = this.getComponent();
String newValue = (String) component.getDefaultModelObject();
ItemPathType itemPathType = null;
if (StringUtils.isNotBlank(newValue)) {
itemPathType = new ItemPathType(newValue);
}
item.getModelObject().setPath(itemPathType);
}
});
property.add(AttributeAppender.replace("placeholder",
Expand Down Expand Up @@ -247,6 +262,7 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
//TODO: show error?
target.add(form);
}
};
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.web.page.admin.configuration.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.xml.namespace.QName;
Expand All @@ -31,6 +32,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyConstraintType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

Expand Down Expand Up @@ -61,6 +63,10 @@ public ObjectPolicyDialogDto(ObjectPolicyConfigurationType config, PageBase page
type = config.getType();
subtype = config.getSubtype();

// for (PropertyConstraintType constraint : config.getPropertyConstraint()) {
// propertyConstraintsList.add(new PropertyConstraintTypeDto(constraint));
// }

propertyConstraintsList = config.getPropertyConstraint();

if (propertyConstraintsList.isEmpty()) {
Expand All @@ -78,7 +84,7 @@ public ObjectPolicyConfigurationType preparePolicyConfig(){

for (PropertyConstraintType constraintType : propertyConstraintsList) {
PrismContainerValue<PropertyConstraintType> constraint = constraintType.asPrismContainerValue();
if (!constraint.isEmpty()) {
if (!constraint.isEmpty() && constraintType.getPath() != null) {
newConfig.getPropertyConstraint().add(constraint.clone().asContainerable());
}
}
Expand Down
Expand Up @@ -59,22 +59,8 @@ public interface Definition extends Serializable, DebugDumpable, Revivable {
QName getTypeName();

/**
* This means that the entities described by this schema (items, complex types) or their content
* is not defined by fixed (compile-time) schema. I.e. it is known only at run time.
*
* Some examples for "false" value:
* - c:user, c:UserType - statically defined type with statically defined content.
*
* Some examples for "true" value:
* - c:extension, c:ExtensionType - although the entity itself (item, type) are defined in
* the static schema, their content is not known at compile time;
* - c:attributes, c:ShadowAttributeType - the same as extension/ExtensionType;
* - ext:weapon (of type xsd:string) - even if the content is statically defined,
* the definition of the item itself is not known at compile time;
* - ri:inetOrgPerson, ext:LocationsType, ext:locations - both the entity
* and their content are known at run time only.
*
* TODO clarify the third point; provide some tests for the 3rd and 4th point
* This means that this particular definition (of an item or of a type) is part of the runtime schema, e.g.
* extension schema, resource schema or connector schema or something like that. I.e. it is not defined statically.
*/
boolean isRuntimeSchema();

Expand Down
Expand Up @@ -68,9 +68,8 @@ public abstract class DefinitionImpl implements Definition {
protected boolean inherited = false;

/**
* This means that the item container is not defined by fixed (compile-time) schema.
* This in fact means that we need to use getAny in a JAXB types. It does not influence the
* processing of DOM that much, as that does not really depend on compile-time/run-time distinction.
* This means that this particular definition (of an item or of a type) is part of the runtime schema, e.g.
* extension schema, resource schema or connector schema or something like that. I.e. it is not defined statically.
*/
protected boolean isRuntimeSchema;

Expand Down
Expand Up @@ -91,40 +91,40 @@ public PrismContainerDefinition<?> getExtensionDefinition() {
return findContainerDefinition(getExtensionQName());
}

public void setExtensionDefinition(ComplexTypeDefinition extensionComplexTypeDefinition) {
QName extensionQName = getExtensionQName();

PrismContainerDefinition<Containerable> oldExtensionDef = findContainerDefinition(extensionQName);

PrismContainerDefinitionImpl<?> newExtensionDef = new PrismContainerDefinitionImpl<>(extensionQName,
extensionComplexTypeDefinition, prismContext);
newExtensionDef.setRuntimeSchema(true);
if (oldExtensionDef != null) {
if (newExtensionDef.getDisplayName() == null) {
newExtensionDef.setDisplayName(oldExtensionDef.getDisplayName());
}
if (newExtensionDef.getDisplayOrder() == null) {
newExtensionDef.setDisplayOrder(oldExtensionDef.getDisplayOrder());
}
if (newExtensionDef.getHelp() == null) {
newExtensionDef.setHelp(oldExtensionDef.getHelp());
}
}

ComplexTypeDefinitionImpl newCtd = (ComplexTypeDefinitionImpl) this.complexTypeDefinition.clone();
newCtd.replaceDefinition(extensionQName, newExtensionDef);
if (newCtd.getDisplayName() == null) {
newCtd.setDisplayName(this.complexTypeDefinition.getDisplayName());
}
if (newCtd.getDisplayOrder() == null) {
newCtd.setDisplayOrder(this.complexTypeDefinition.getDisplayOrder());
}
if (newCtd.getHelp() == null) {
newCtd.setHelp(this.complexTypeDefinition.getHelp());
}

this.complexTypeDefinition = newCtd;
}
// public void setExtensionDefinition(ComplexTypeDefinition extensionComplexTypeDefinition) {
// QName extensionQName = getExtensionQName();
//
// PrismContainerDefinition<Containerable> oldExtensionDef = findContainerDefinition(extensionQName);
//
// PrismContainerDefinitionImpl<?> newExtensionDef = new PrismContainerDefinitionImpl<>(extensionQName,
// extensionComplexTypeDefinition, prismContext);
// newExtensionDef.setRuntimeSchema(true);
// if (oldExtensionDef != null) {
// if (newExtensionDef.getDisplayName() == null) {
// newExtensionDef.setDisplayName(oldExtensionDef.getDisplayName());
// }
// if (newExtensionDef.getDisplayOrder() == null) {
// newExtensionDef.setDisplayOrder(oldExtensionDef.getDisplayOrder());
// }
// if (newExtensionDef.getHelp() == null) {
// newExtensionDef.setHelp(oldExtensionDef.getHelp());
// }
// }
//
// ComplexTypeDefinitionImpl newCtd = (ComplexTypeDefinitionImpl) this.complexTypeDefinition.clone();
// newCtd.replaceDefinition(extensionQName, newExtensionDef);
// if (newCtd.getDisplayName() == null) {
// newCtd.setDisplayName(this.complexTypeDefinition.getDisplayName());
// }
// if (newCtd.getDisplayOrder() == null) {
// newCtd.setDisplayOrder(this.complexTypeDefinition.getDisplayOrder());
// }
// if (newCtd.getHelp() == null) {
// newCtd.setHelp(this.complexTypeDefinition.getHelp());
// }
//
// this.complexTypeDefinition = newCtd;
// }

@Override
public PrismObjectValue<O> createValue() {
Expand Down
Expand Up @@ -1127,7 +1127,7 @@ private <T extends SearchFilterType> T unmarshalSearchFilterType(MapXNode xmap,
return null;
}
T filterType = instantiate(beanClass);
filterType.parseFromXNode(xmap, prismContext);
filterType.parseFromXNode(xmap, pc, prismContext);
return filterType;
}

Expand Down
Expand Up @@ -515,7 +515,7 @@ private PrismReferenceValue parseReferenceValueAsReference(@NotNull XNode xnode,

refVal.setDescription(map.getParsedPrimitiveValue(XNode.KEY_REFERENCE_DESCRIPTION, DOMUtil.XSD_STRING));

refVal.setFilter(parseFilter(map.get(XNode.KEY_REFERENCE_FILTER)));
refVal.setFilter(parseFilter(map.get(XNode.KEY_REFERENCE_FILTER), pc));

String resolutionTimeString = map.getParsedPrimitiveValue(XNode.KEY_REFERENCE_RESOLUTION_TIME, DOMUtil.XSD_STRING);
if (resolutionTimeString != null) {
Expand Down Expand Up @@ -598,14 +598,14 @@ private PrismReferenceValue parseReferenceValueAsCompositeObject(XNode node,
return refVal;
}

private SearchFilterType parseFilter(XNode xnode) throws SchemaException {
private SearchFilterType parseFilter(XNode xnode, ParsingContext pc) throws SchemaException {
if (xnode == null) {
return null;
}
if (xnode.isEmpty()) {
return null;
}
return SearchFilterType.createFromXNode(xnode, prismContext);
return SearchFilterType.createFromParsedXNode(xnode, pc, prismContext);
}

private ItemDefinition locateItemDefinition(@NotNull QName itemName,
Expand Down

0 comments on commit 093e374

Please sign in to comment.