Tabnine Logo
MatchingRuleRegistry.getMatchingRule
Code IndexAdd Tabnine to your IDE (free)

How to use
getMatchingRule
method
in
com.evolveum.midpoint.prism.match.MatchingRuleRegistry

Best Java code snippets using com.evolveum.midpoint.prism.match.MatchingRuleRegistry.getMatchingRule (Showing top 20 results out of 315)

origin: Evolveum/midpoint

public static <T> ValueMatcher<T> createDefaultMatcher(QName type, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException {
  MatchingRule<Object> matchingRule = matchingRuleRegistry.getMatchingRule(null, type);
  return new ValueMatcher<>((MatchingRule<T>) matchingRule);
}
origin: Evolveum/midpoint

@NotNull
MatchingRule getMatchingRuleFromRegistry(MatchingRuleRegistry matchingRuleRegistry, Item filterItem) {
  try {
    return matchingRuleRegistry.getMatchingRule(matchingRule, filterItem.getDefinition().getTypeName());
  } catch (SchemaException ex){
    throw new IllegalArgumentException(ex.getMessage(), ex);
  }
}
origin: Evolveum/midpoint

@NotNull
private MatchingRule<Object> getMatchingRuleForTargetNamingIdentifier(RefinedAssociationDefinition associationDefinition) throws SchemaException {
  RefinedAttributeDefinition<Object> targetNamingAttributeDef = associationDefinition.getAssociationTarget().getNamingAttribute();
  if (targetNamingAttributeDef != null) {
    QName matchingRuleName = targetNamingAttributeDef.getMatchingRuleQName();
    return matchingRuleRegistry.getMatchingRule(matchingRuleName, null);
  } else {
    throw new IllegalStateException(
        "Couldn't evaluate tolerant/intolerant value patterns, because naming attribute is not known for "
            + associationDefinition.getAssociationTarget());
  }
}
origin: Evolveum/midpoint

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
  super.initSystem(initTask, initResult);
  uidMatchingRule = matchingRuleRegistry.getMatchingRule(PrismConstants.STRING_IGNORE_CASE_MATCHING_RULE_NAME, DOMUtil.XSD_STRING);
}
origin: Evolveum/midpoint

private <T> Collection<T> getNormalizedAttributeValues(ResourceAttribute<T> attribute, RefinedAttributeDefinition rAttrDef) throws SchemaException {
  MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName());
  if (matchingRule == null) {
    return attribute.getRealValues();
  } else {
    Collection<T> normalizedValues = new ArrayList<>();
    for (PrismPropertyValue<T> pval: attribute.getValues()) {
      T normalizedRealValue = matchingRule.normalize(pval.getValue());
      normalizedValues.add(normalizedRealValue);
    }
    return normalizedValues;
  }
}
origin: Evolveum/midpoint

<T> T getNormalizedAttributeValue(PrismPropertyValue<T> pval, RefinedAttributeDefinition rAttrDef) throws SchemaException {
  MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName());
  if (matchingRule != null) {
    T normalizedRealValue = matchingRule.normalize(pval.getValue());
    return normalizedRealValue;
  } else {
    return pval.getValue();
  }
}
 
origin: Evolveum/midpoint

private <T> List<PrismPropertyValue<T>> getNormalizedValue(PrismProperty<T> attr, RefinedObjectClassDefinition rObjClassDef) throws SchemaException {
  RefinedAttributeDefinition<T> refinedAttributeDefinition = rObjClassDef.findAttributeDefinition(attr.getElementName());
  QName matchingRuleQName = refinedAttributeDefinition.getMatchingRuleQName();
  MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, refinedAttributeDefinition.getTypeName());
  List<PrismPropertyValue<T>> normalized = new ArrayList<>();
  for (PrismPropertyValue<T> origPValue : attr.getValues()){
    T normalizedValue = matchingRule.normalize(origPValue.getValue());
    PrismPropertyValue<T> normalizedPValue = origPValue.clone();
    normalizedPValue.setValue(normalizedValue);
    normalized.add(normalizedPValue);
  }
  return normalized;
  
}
origin: Evolveum/midpoint

private void checkMatchingRule(ResourceValidationContext ctx, ItemPath path,
    ResourceObjectTypeDefinitionType objectType, ResourceAttributeDefinitionType attributeDef, QName ref, ResourceAttributeDefinition<?> rad) {
  QName matchingRule = attributeDef.getMatchingRule();
  if (matchingRule == null) {
    return;
  }
  try {
    matchingRuleRegistry.getMatchingRule(matchingRule, rad != null ? rad.getTypeName() : null);
  } catch (Throwable t) {
    ctx.validationResult.add(Issue.Severity.WARNING,
        CAT_SCHEMA_HANDLING, C_WRONG_MATCHING_RULE,
        getString(CLASS_DOT + C_WRONG_MATCHING_RULE, getName(objectType), prettyPrintUsingStandardPrefix(ref), t.getMessage()),
        ctx.resourceRef, path.append(ResourceItemDefinitionType.F_MATCHING_RULE));
  }
}
origin: Evolveum/midpoint

private <T> void normalizeAttribute(ResourceAttribute<T> attribute, RefinedAttributeDefinition rAttrDef) throws SchemaException {
  MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName());
  if (matchingRule != null) {
    for (PrismPropertyValue<T> pval: attribute.getValues()) {
      T normalizedRealValue = matchingRule.normalize(pval.getValue());
      pval.setValue(normalizedRealValue);
    }
  }
}
 
origin: Evolveum/midpoint

public static <T> ValueMatcher<T> createMatcher(RefinedAttributeDefinition rAttrDef, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException {
  QName matchingRuleQName = rAttrDef.getMatchingRuleQName();
  MatchingRule<T> matchingRule;
  try {
    matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, rAttrDef.getTypeName());
  } catch (SchemaException e) {
    throw new SchemaException(e.getMessage()+", defined for attribute "+rAttrDef.getName(), e);
  }
  return new ValueMatcher<>(matchingRule);
}
origin: Evolveum/midpoint

public static <T> PropertyDelta<T> narrowPropertyDelta(PropertyDelta<T> propertyDelta,
    PrismObject<ShadowType> currentShadow, QName overridingMatchingRuleQName, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException {
  QName matchingRuleQName = overridingMatchingRuleQName;
  ItemDefinition propertyDef = propertyDelta.getDefinition();
  if (matchingRuleQName == null && propertyDef instanceof RefinedAttributeDefinition) {
    matchingRuleQName = ((RefinedAttributeDefinition)propertyDef).getMatchingRuleQName();
  }
  MatchingRule<T> matchingRule = null;
  if (matchingRuleQName != null && propertyDef != null) {
    matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, propertyDef.getTypeName());
  }
  LOGGER.trace("Narrowing attr def={}, matchingRule={} ({})", propertyDef, matchingRule, matchingRuleQName);
  PropertyDelta<T> filteredDelta = propertyDelta.narrow(currentShadow, matchingRule);
  if (LOGGER.isTraceEnabled() && (filteredDelta == null || !filteredDelta.equals(propertyDelta))) {
    LOGGER.trace("Narrowed delta: {}", filteredDelta==null?null:filteredDelta.debugDump());
  }
  return filteredDelta;
}
 
origin: Evolveum/midpoint

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
  // We need to switch off the encryption checks. Some values cannot be encrypted as we do
  // not have a definition here
  InternalsConfig.encryptionChecks = false;
  provisioningService.postInit(initResult);
  resource = addResourceFromFile(getResourceOpenDjFile(), IntegrationTestTools.CONNECTOR_LDAP_TYPE, initResult);
  repoAddShadowFromFile(ACCOUNT_BAD_FILE, initResult);
  dnMatchingRule = matchingRuleRegistry.getMatchingRule(PrismConstants.DISTINGUISHED_NAME_MATCHING_RULE_NAME, DOMUtil.XSD_STRING);
}
origin: Evolveum/midpoint

@Test
public void testStringDefault() throws Exception {
  // GIVEN
  MatchingRule<String> rule = matchingRuleRegistry.getMatchingRule(null, DOMUtil.XSD_STRING);
  // WHEN, THEN
  assertMatch(rule, "foo", "foo");
  assertNoMatch(rule, "foo", "bar");
  assertNoMatch(rule, "foo", "Foo");
  assertNoMatch(rule, "FOO", "Foo");
  assertNormalized(rule, "Foo", "Foo");
  assertNormalized(rule, "baR", "baR");
}
origin: Evolveum/midpoint

private boolean matches(ResourceAttribute<?> identifier, ResourceAttribute<?> attributeToMatch, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException {
  if (!identifier.getElementName().equals(attributeToMatch.getElementName())) {
    return false;
  }
  RefinedAttributeDefinition rAttrDef = rOcDef.findAttributeDefinition(identifier.getElementName());
  QName matchingRuleQName = rAttrDef.getMatchingRuleQName();
  if (matchingRuleQName == null || matchingRuleRegistry == null) {
    return identifier.equals(attributeToMatch, EquivalenceStrategy.REAL_VALUE);
  }
  MatchingRule<Object> matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, rAttrDef.getTypeName());
  return matchingRule.match(identifier.getRealValue(), attributeToMatch.getRealValue());
}
origin: Evolveum/midpoint

private <T> void normalizeDelta(ItemDelta<PrismPropertyValue<T>,PrismPropertyDefinition<T>> delta, RefinedAttributeDefinition rAttrDef) throws SchemaException{
  MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName());
  if (matchingRule != null) {
    if (delta.getValuesToReplace() != null){
      normalizeValues(delta.getValuesToReplace(), matchingRule);
    }
    if (delta.getValuesToAdd() != null){
      normalizeValues(delta.getValuesToAdd(), matchingRule);
    }
    
    if (delta.getValuesToDelete() != null){
      normalizeValues(delta.getValuesToDelete(), matchingRule);
    }
  }
}
 
origin: Evolveum/midpoint

@Test
public void testStringCaseInsensitive() throws Exception {
  // GIVEN
  MatchingRule<String> rule = matchingRuleRegistry.getMatchingRule(PrismConstants.STRING_IGNORE_CASE_MATCHING_RULE_NAME,
      DOMUtil.XSD_STRING);
  // WHEN, THEN
  assertMatch(rule, "foo", "foo");
  assertNoMatch(rule, "foo", "bar");
  assertMatch(rule, "foo", "Foo");
  assertMatch(rule, "FOO", "Foo");
  assertNormalized(rule, "bar", "baR");
  assertNormalized(rule, "foo", "FoO");
  assertNormalized(rule, "foobar", "foobar");
}
origin: Evolveum/midpoint

@Test
public void testPolyStringStrict() throws Exception {
  // GIVEN
  MatchingRule<PolyString> rule = matchingRuleRegistry.getMatchingRule(PrismConstants.POLY_STRING_STRICT_MATCHING_RULE_NAME,
      PolyStringType.COMPLEX_TYPE);
  // WHEN, THEN
  assertMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "bar"));
  assertNoMatch(rule, new PolyString("BAR", "bar"), new PolyString("Foo", "bar"));
  assertNoMatch(rule, new PolyString("Bar", "bar"), new PolyString("bAR", "bar"));
  assertNoMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "barbar"));
}
origin: Evolveum/midpoint

@Test
public void testPolyStringOrig() throws Exception {
  // GIVEN
  MatchingRule<PolyString> rule = matchingRuleRegistry.getMatchingRule(PrismConstants.POLY_STRING_ORIG_MATCHING_RULE_NAME,
      PolyStringType.COMPLEX_TYPE);
  // WHEN, THEN
  assertMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "bar"));
  assertNoMatch(rule, new PolyString("BAR", "bar"), new PolyString("Foo", "bar"));
  assertNoMatch(rule, new PolyString("Bar", "bar"), new PolyString("bAR", "bar"));
  assertMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "barbar"));
}
origin: Evolveum/midpoint

@Test
public void testPolyStringNorm() throws Exception {
  // GIVEN
  MatchingRule<PolyString> rule = matchingRuleRegistry.getMatchingRule(PrismConstants.POLY_STRING_NORM_MATCHING_RULE_NAME,
      PolyStringType.COMPLEX_TYPE);
  // WHEN, THEN
  assertMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "bar"));
  assertMatch(rule, new PolyString("BAR", "bar"), new PolyString("Foo", "bar"));
  assertMatch(rule, new PolyString("Bar", "bar"), new PolyString("bAR", "bar"));
  assertNoMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "barbar"));
}
origin: Evolveum/midpoint

@Override
public void initSystem(Task initTask, OperationResult initResult)
    throws Exception {
  super.initSystem(initTask, initResult);
  caseIgnoreMatchingRule = matchingRuleRegistry.getMatchingRule(PrismConstants.STRING_IGNORE_CASE_MATCHING_RULE_NAME, DOMUtil.XSD_STRING);
  preTestCleanup(AssignmentPolicyEnforcementType.FULL);
  repoAddObjectFromFile(ROLE_X_FILE, initResult);
  repoAddObjectFromFile(ROLE_JOKER_FILE, initResult);
  repoAddObjectFromFile(ROLE_UPCASE_BASIC_FILE, initResult);
  repoAddObjectFromFile(ROLE_FOOL_FILE, initResult);
  InternalMonitor.reset();
  InternalMonitor.setTrace(InternalOperationClasses.SHADOW_FETCH_OPERATIONS, false);
  InternalMonitor.setTrace(InternalOperationClasses.RESOURCE_SCHEMA_OPERATIONS, false);
}
com.evolveum.midpoint.prism.matchMatchingRuleRegistrygetMatchingRule

Popular methods of MatchingRuleRegistry

    Popular in Java

    • Running tasks concurrently on multiple threads
    • scheduleAtFixedRate (Timer)
    • onRequestPermissionsResult (Fragment)
    • setContentView (Activity)
    • GridLayout (java.awt)
      The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
    • System (java.lang)
      Provides access to system-related information and resources including standard input and output. Ena
    • ByteBuffer (java.nio)
      A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
    • Permission (java.security)
      Legacy security code; do not use.
    • Map (java.util)
      A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
    • Table (org.hibernate.mapping)
      A relational table
    • Top PhpStorm plugins
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now