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
katkav committed Nov 2, 2016
2 parents cee07df + fb0276d commit 18aee30
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 113 deletions.
Expand Up @@ -33,8 +33,6 @@ public interface PrismContainerDefinition<C extends Containerable> extends ItemD

ComplexTypeDefinition getComplexTypeDefinition();

boolean isWildcard();

@Override
void revive(PrismContext prismContext);

Expand Down
Expand Up @@ -137,21 +137,6 @@ public boolean isAbstract() {
return complexTypeDefinition != null && complexTypeDefinition.isAbstract();
}

/**
* Returns true if the definition does not define specific items but it is just
* a "wildcard" for any kind of item (usually represented as xsd:any type).
*/
@Override
public boolean isWildcard() {
if (getTypeName().equals(DOMUtil.XSD_ANY)) {
return true;
}
// if (complexTypeDefinition != null && complexTypeDefinition.isXsdAnyMarker()) {
// return true;
// }
return false;
}

@Override
public void revive(PrismContext prismContext) {
if (this.prismContext != null) {
Expand Down
Expand Up @@ -1091,10 +1091,7 @@ public void applyDefinition(@NotNull PrismContainerDefinition<C> containerDef, b
return; // there's a definition already
}
replaceComplexTypeDefinition(containerDef.getComplexTypeDefinition());
if (complexTypeDefinition == null || complexTypeDefinition.isXsdAnyMarker()) {
// No point in applying this. Nothing will change and there may be phantom errors.
return;
}
// we need to continue even if CTD is null or 'any' - e.g. to resolve definitions within object extension
if (items != null) {
for (Item item : items) {
if (item.getDefinition() != null && !force) {
Expand Down
Expand Up @@ -272,7 +272,7 @@ private PrismObjectDefinition<UserType> getUserDefinition(){
public void testTypeFilterQuery() throws Exception {
displayTestTitle("testConnectorQuery");
SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE);
ObjectQuery query = null;
ObjectQuery query;
try {
query = QueryJaxbConvertor.createObjectQuery(ConnectorType.class, filterType, getPrismContext());
displayQuery(query);
Expand All @@ -294,12 +294,6 @@ public void testTypeFilterQuery() throws Exception {

QueryType convertedQueryType = toQueryType(query);
displayQueryType(convertedQueryType);
} catch (SchemaException ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
} catch (RuntimeException ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
} catch (Exception ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
Expand All @@ -319,15 +313,13 @@ private void assertRefFilterValue(RefFilter filter, String oid) {
}

private ObjectQuery toObjectQuery(Class type, QueryType queryType) throws Exception {
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(type, queryType,
return QueryJaxbConvertor.createObjectQuery(type, queryType,
getPrismContext());
return query;
}

private ObjectQuery toObjectQuery(Class type, SearchFilterType filterType) throws Exception {
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(type, filterType,
return QueryJaxbConvertor.createObjectQuery(type, filterType,
getPrismContext());
return query;
}

private QueryType toQueryType(ObjectQuery query) throws Exception {
Expand Down Expand Up @@ -386,7 +378,7 @@ public void testUserQuery() throws Exception {
for (File file : userQueriesToTest) {
SearchFilterType filterType = PrismTestUtil.parseAtomicValue(file, SearchFilterType.COMPLEX_TYPE);
LOGGER.info("===[ query type parsed ]===");
ObjectQuery query = null;
ObjectQuery query;
try {
query = QueryJaxbConvertor.createObjectQuery(UserType.class, filterType, getPrismContext());
LOGGER.info("query converted: ");
Expand All @@ -397,12 +389,6 @@ public void testUserQuery() throws Exception {

QueryType convertedQueryType = QueryJaxbConvertor.createQueryType(query, getPrismContext());
LOGGER.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement()));
} catch (SchemaException ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
} catch (RuntimeException ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
} catch (Exception ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
Expand Down Expand Up @@ -504,7 +490,6 @@ public void test210EqualMultiple() throws Exception {
public void test220EqualRightHandItem() throws Exception {
final String TEST_NAME = "test220EqualRightHandItem";
displayTestTitle(TEST_NAME);
PrismObjectDefinition<UserType> userDef = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
ObjectQuery q = QueryBuilder.queryFor(UserType.class, getPrismContext())
.item(UserType.F_EMPLOYEE_NUMBER).eq().item(UserType.F_COST_CENTER)
.build();
Expand Down
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.security.api.SecurityEnforcer;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.Holder;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
Expand All @@ -67,6 +68,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.QueryInterpretationOfNoValueType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import org.jetbrains.annotations.Nullable;

/**
* @author semancik
Expand Down Expand Up @@ -470,6 +472,22 @@ public static ObjectFilter evaluateFilterExpressions(ObjectFilter origFilter,
shortDesc, task, result);
}

public static boolean hasExpressions(@Nullable ObjectFilter filter) {
if (filter == null) {
return false;
}
Holder<Boolean> result = new Holder<>(false);
filter.accept(f -> {
if (f instanceof ValueFilter) {
ValueFilter<?, ?> vf = (ValueFilter<?, ?>) f;
if (vf.getExpression() != null) {
result.setValue(true);
}
}
});
return result.getValue();
}

private static ObjectFilter evaluateFilterExpressionsInternal(ObjectFilter filter,
ExpressionVariables variables, ExpressionFactory expressionFactory, PrismContext prismContext,
String shortDesc, Task task, OperationResult result)
Expand Down

0 comments on commit 18aee30

Please sign in to comment.