Skip to content

Commit

Permalink
Distribute schema-related classes to api/impl
Browse files Browse the repository at this point in the history
Again, assuming prism-impl will be visible from schema module.
  • Loading branch information
mederly committed Dec 4, 2018
1 parent 14f313e commit 984ebd5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 56 deletions.
Expand Up @@ -27,11 +27,11 @@
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.ItemProcessing;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.util.DefinitionUtil;
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinitionImpl;
import org.apache.commons.lang.BooleanUtils;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.schema.SchemaProcessorUtil;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
Expand Down Expand Up @@ -490,10 +490,10 @@ static <T> RefinedAttributeDefinition<T> parse(ResourceAttributeDefinition<T> sc

private static void applyLimitationsType(PropertyLimitations limitations, PropertyLimitationsType layerLimitationsType) {
if (layerLimitationsType.getMinOccurs() != null) {
limitations.setMinOccurs(SchemaProcessorUtil.parseMultiplicity(layerLimitationsType.getMinOccurs()));
limitations.setMinOccurs(DefinitionUtil.parseMultiplicity(layerLimitationsType.getMinOccurs()));
}
if (layerLimitationsType.getMaxOccurs() != null) {
limitations.setMaxOccurs(SchemaProcessorUtil.parseMultiplicity(layerLimitationsType.getMaxOccurs()));
limitations.setMaxOccurs(DefinitionUtil.parseMultiplicity(layerLimitationsType.getMaxOccurs()));
}
if (layerLimitationsType.isIgnore() != null) {
limitations.setProcessing(ItemProcessing.IGNORE);
Expand Down
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.prism.util;

import com.evolveum.midpoint.prism.schema.SchemaProcessorUtil;

/**
*
*/
public class DefinitionUtil {
public static Integer parseMultiplicity(String stringMultiplicity) {
if (stringMultiplicity == null) {
return null;
}
if (stringMultiplicity.equals(SchemaProcessorUtil.MULTIPLICITY_UNBOUNDED)) {
return -1;
}
return Integer.parseInt(stringMultiplicity);
}
}
Expand Up @@ -129,14 +129,4 @@ public static Integer getAnnotationInteger(XSAnnotation annotation, QName qname)
return getAnnotationConverted(annotation, qname, Integer.class);
}

public static Integer parseMultiplicity(String stringMultiplicity) {
if (stringMultiplicity == null) {
return null;
}
if (stringMultiplicity.equals(MULTIPLICITY_UNBOUNDED)) {
return -1;
}
return Integer.parseInt(stringMultiplicity);
}

}

This file was deleted.

Expand Up @@ -31,7 +31,7 @@
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.schema.SchemaProcessorUtil;
import com.evolveum.midpoint.prism.util.DefinitionUtil;
import com.evolveum.midpoint.util.exception.NoFocusNameSchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.BooleanUtils;
Expand Down Expand Up @@ -401,11 +401,11 @@ private <O extends ObjectType> void checkItemLimitations(PrismObject<O> object,
return;
}
int count = getValueCount(item);
Integer min = SchemaProcessorUtil.parseMultiplicity(limitation.getMinOccurs());
Integer min = DefinitionUtil.parseMultiplicity(limitation.getMinOccurs());
if (min != null && min > 0 && count < min) {
throw new SchemaException("Expected at least " + min + " values of " + path + ", got " + count);
}
Integer max = SchemaProcessorUtil.parseMultiplicity(limitation.getMaxOccurs());
Integer max = DefinitionUtil.parseMultiplicity(limitation.getMaxOccurs());
if (max != null && max >= 0 && count > max) {
throw new SchemaException("Expected at most " + max + " values of " + path + ", got " + count);
}
Expand Down

0 comments on commit 984ebd5

Please sign in to comment.