Search in sources :

Example 1 with Item

use of com.evolveum.midpoint.prism.Item in project midpoint by Evolveum.

the class PrismAsserts method assertNoEmptyItem.

public static void assertNoEmptyItem(PrismContainer<?> container) {
    Visitor visitor = new Visitor() {

        @Override
        public void visit(Visitable visitable) {
            if (visitable != null && visitable instanceof Item) {
                assertNotEmpty((Item<?, ?>) visitable);
            }
        }
    };
    container.accept(visitor);
}
Also used : Item(com.evolveum.midpoint.prism.Item) Visitor(com.evolveum.midpoint.prism.Visitor) Visitable(com.evolveum.midpoint.prism.Visitable)

Example 2 with Item

use of com.evolveum.midpoint.prism.Item in project midpoint by Evolveum.

the class PathExpressionEvaluator method evaluate.

/* (non-Javadoc)
	 * @see com.evolveum.midpoint.common.expression.ExpressionEvaluator#evaluate(java.util.Collection, java.util.Map, boolean, java.lang.String, com.evolveum.midpoint.schema.result.OperationResult)
	 */
@Override
public PrismValueDeltaSetTriple<V> evaluate(ExpressionEvaluationContext context) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
    ItemDeltaItem<?, ?> resolveContext = null;
    if (context.getSources() != null && context.getSources().size() == 1) {
        Source<?, ?> source = context.getSources().iterator().next();
        if (path.isEmpty()) {
            PrismValueDeltaSetTriple<V> outputTriple = (PrismValueDeltaSetTriple<V>) source.toDeltaSetTriple();
            return outputTriple.clone();
        }
        resolveContext = source;
    }
    Map<QName, Object> variablesAndSources = ExpressionUtil.compileVariablesAndSources(context);
    ItemPath resolvePath = path;
    ItemPathSegment first = path.first();
    if (first instanceof NameItemPathSegment && first.isVariable()) {
        QName variableName = ((NameItemPathSegment) first).getName();
        Object variableValue;
        if (variablesAndSources.containsKey(variableName)) {
            variableValue = variablesAndSources.get(variableName);
        } else if (QNameUtil.matchAny(variableName, variablesAndSources.keySet())) {
            QName fullVariableName = QNameUtil.resolveNs(variableName, variablesAndSources.keySet());
            variableValue = variablesAndSources.get(fullVariableName);
        } else {
            throw new ExpressionEvaluationException("No variable with name " + variableName + " in " + context.getContextDescription());
        }
        if (variableValue == null) {
            return null;
        }
        if (variableValue instanceof Item || variableValue instanceof ItemDeltaItem<?, ?>) {
            resolveContext = ExpressionUtil.toItemDeltaItem(variableValue, objectResolver, "path expression in " + context.getContextDescription(), context.getResult());
        } else if (variableValue instanceof PrismPropertyValue<?>) {
            PrismValueDeltaSetTriple<V> outputTriple = new PrismValueDeltaSetTriple<>();
            outputTriple.addToZeroSet((V) variableValue);
            return ExpressionUtil.toOutputTriple(outputTriple, outputDefinition, context.getAdditionalConvertor(), null, protector, prismContext);
        } else {
            throw new ExpressionEvaluationException("Unexpected variable value " + variableValue + " (" + variableValue.getClass() + ")");
        }
        resolvePath = path.rest();
    }
    if (resolveContext == null) {
        return null;
    }
    while (!resolvePath.isEmpty()) {
        if (resolveContext.isContainer()) {
            resolveContext = resolveContext.findIdi(resolvePath.head());
            resolvePath = resolvePath.tail();
            if (resolveContext == null) {
                throw new ExpressionEvaluationException("Cannot find item using path " + path + " in " + context.getContextDescription());
            }
        } else if (resolveContext.isStructuredProperty()) {
            // The output path does not really matter. The delta will be converted to triple anyway
            // But the path cannot be null, oherwise the code will die
            resolveContext = resolveContext.resolveStructuredProperty(resolvePath, (PrismPropertyDefinition) outputDefinition, new ItemPath());
            break;
        } else if (resolveContext.isNull()) {
            break;
        } else {
            throw new ExpressionEvaluationException("Cannot resolve path " + resolvePath + " on " + resolveContext + " in " + context.getContextDescription());
        }
    }
    PrismValueDeltaSetTriple<V> outputTriple = ItemDelta.toDeltaSetTriple((Item<V, D>) resolveContext.getItemOld(), (ItemDelta<V, D>) resolveContext.getDelta());
    if (outputTriple == null) {
        return null;
    }
    return ExpressionUtil.toOutputTriple(outputTriple, outputDefinition, context.getAdditionalConvertor(), null, protector, prismContext);
}
Also used : ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) QName(javax.xml.namespace.QName) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPathSegment(com.evolveum.midpoint.prism.path.ItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemDeltaItem(com.evolveum.midpoint.repo.common.expression.ItemDeltaItem) Item(com.evolveum.midpoint.prism.Item) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 3 with Item

use of com.evolveum.midpoint.prism.Item in project midpoint by Evolveum.

the class MappingEvaluator method computeTargetValues.

private <V extends PrismValue, F extends FocusType> Collection<V> computeTargetValues(VariableBindingDefinitionType target, Object defaultTargetContext, ExpressionVariables variables, ObjectResolver objectResolver, String contextDesc, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException {
    if (target == null) {
        // Is this correct? What about default targets?
        return null;
    }
    ItemPathType itemPathType = target.getPath();
    if (itemPathType == null) {
        // Is this correct? What about default targets?
        return null;
    }
    ItemPath path = itemPathType.getItemPath();
    Object object = ExpressionUtil.resolvePath(path, variables, defaultTargetContext, objectResolver, contextDesc, task, result);
    if (object == null) {
        return new ArrayList<>();
    } else if (object instanceof Item) {
        return ((Item) object).getValues();
    } else if (object instanceof PrismValue) {
        return (List<V>) Collections.singletonList((PrismValue) object);
    } else if (object instanceof ItemDeltaItem) {
        ItemDeltaItem<V, ?> idi = (ItemDeltaItem<V, ?>) object;
        PrismValueDeltaSetTriple<V> triple = idi.toDeltaSetTriple();
        return triple != null ? triple.getNonNegativeValues() : new ArrayList<V>();
    } else {
        throw new IllegalStateException("Unsupported target value(s): " + object.getClass() + " (" + object + ")");
    }
}
Also used : Item(com.evolveum.midpoint.prism.Item) ItemDeltaItem(com.evolveum.midpoint.repo.common.expression.ItemDeltaItem) ItemDeltaItem(com.evolveum.midpoint.repo.common.expression.ItemDeltaItem) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ObjectDeltaObject(com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismValue(com.evolveum.midpoint.prism.PrismValue) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 4 with Item

use of com.evolveum.midpoint.prism.Item in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method assertAllowRequestItems.

protected void assertAllowRequestItems(String userOid, String targetRoleOid, AuthorizationDecisionType expectedDefaultDecision, QName... expectedAllowedItemQNames) throws SchemaException, SecurityViolationException, CommunicationException, ObjectNotFoundException, ConfigurationException, ExpressionEvaluationException {
    PrismObject<UserType> user = getUser(userOid);
    PrismObject<RoleType> target = getRole(targetRoleOid);
    ItemSecurityDecisions decisions = modelInteractionService.getAllowedRequestAssignmentItems(user, target);
    display("Request decisions for " + target, decisions);
    assertEquals("Wrong assign default decision", expectedDefaultDecision, decisions.getDefaultDecision());
    assertEquals("Unexpected number of allowed items", expectedAllowedItemQNames.length, decisions.getItemDecisionMap().size());
    decisions.getItemDecisionMap().forEach((path, decision) -> {
        assertEquals("wrong item " + path + " decision", AuthorizationDecisionType.ALLOW, decision);
        QName lastPathName = path.lastNamed().getName();
        if (!Arrays.stream(expectedAllowedItemQNames).anyMatch(qname -> QNameUtil.match(qname, lastPathName))) {
            AssertJUnit.fail("Unexpected path " + path);
        }
    });
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) AuditReferenceValue(com.evolveum.midpoint.audit.api.AuditReferenceValue) Autowired(org.springframework.beans.factory.annotation.Autowired) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Entry(org.opends.server.types.Entry) Map(java.util.Map) UserProfileService(com.evolveum.midpoint.security.api.UserProfileService) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) ObjectQueryUtil(com.evolveum.midpoint.schema.util.ObjectQueryUtil) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) RepositoryDiag(com.evolveum.midpoint.schema.RepositoryDiag) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ModelService(com.evolveum.midpoint.model.api.ModelService) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) FilterInvocation(org.springframework.security.web.FilterInvocation) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Clock(com.evolveum.midpoint.common.Clock) FocusTypeUtil(com.evolveum.midpoint.schema.util.FocusTypeUtil) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) HookRegistry(com.evolveum.midpoint.model.api.hooks.HookRegistry) TestUtil(com.evolveum.midpoint.test.util.TestUtil) ConnectException(java.net.ConnectException) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) AuthorizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) AfterClass(org.testng.annotations.AfterClass) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) IOException(java.io.IOException) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ModelElementContext(com.evolveum.midpoint.model.api.context.ModelElementContext) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) SystemObjectsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) PrismValue(com.evolveum.midpoint.prism.PrismValue) NotificationManager(com.evolveum.midpoint.notifications.api.NotificationManager) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Date(java.util.Date) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ConflictException(com.evolveum.icf.dummy.resource.ConflictException) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) PrismAsserts(com.evolveum.midpoint.prism.util.PrismAsserts) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) AssignmentSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentSelectorType) MiscUtil(com.evolveum.midpoint.util.MiscUtil) Collectors(java.util.stream.Collectors) JAXBException(javax.xml.bind.JAXBException) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) SecurityContext(org.springframework.security.core.context.SecurityContext) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ProvisioningService(com.evolveum.midpoint.provisioning.api.ProvisioningService) SecurityConfig(org.springframework.security.access.SecurityConfig) AnonymousAuthenticationToken(org.springframework.security.authentication.AnonymousAuthenticationToken) Checker(com.evolveum.midpoint.test.Checker) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssertJUnit(org.testng.AssertJUnit) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest) AdminGuiConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AdminGuiConfigurationType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) SchemaTestConstants(com.evolveum.midpoint.schema.util.SchemaTestConstants) DummyAuditService(com.evolveum.midpoint.test.DummyAuditService) OrgFilter(com.evolveum.midpoint.prism.query.OrgFilter) DebugUtil(com.evolveum.midpoint.util.DebugUtil) DummyResourceContoller(com.evolveum.midpoint.test.DummyResourceContoller) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) HashSet(java.util.HashSet) ModelContext(com.evolveum.midpoint.model.api.context.ModelContext) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) IntegrationTestTools(com.evolveum.midpoint.test.IntegrationTestTools) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) RefinedAttributeDefinition(com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition) AuthorizationPhaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationPhaseType) FileInputStream(java.io.FileInputStream) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) TunnelException(com.evolveum.midpoint.util.exception.TunnelException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Consumer(java.util.function.Consumer) ItemSecurityDecisions(com.evolveum.midpoint.security.api.ItemSecurityDecisions) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) PrismReference(com.evolveum.midpoint.prism.PrismReference) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) Arrays(java.util.Arrays) ChangeType(com.evolveum.midpoint.prism.delta.ChangeType) AssertJUnit.assertTrue(org.testng.AssertJUnit.assertTrue) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) AssertJUnit.assertNull(org.testng.AssertJUnit.assertNull) MidpointFunctions(com.evolveum.midpoint.model.api.expr.MidpointFunctions) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) ModelProjectionContext(com.evolveum.midpoint.model.api.context.ModelProjectionContext) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) Holder(com.evolveum.midpoint.util.Holder) Set(java.util.Set) Task(com.evolveum.midpoint.task.api.Task) TriggerType(com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType) SystemException(com.evolveum.midpoint.util.exception.SystemException) QName(javax.xml.namespace.QName) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) Authorization(com.evolveum.midpoint.security.api.Authorization) SchemaViolationException(com.evolveum.icf.dummy.resource.SchemaViolationException) Trace(com.evolveum.midpoint.util.logging.Trace) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) ArrayList(java.util.ArrayList) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) RefinedResourceSchemaImpl(com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl) PrismContext(com.evolveum.midpoint.prism.PrismContext) SynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationType) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) AssertJUnit.assertFalse(org.testng.AssertJUnit.assertFalse) PrismObject(com.evolveum.midpoint.prism.PrismObject) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) File(java.io.File) ModelDiagnosticService(com.evolveum.midpoint.model.api.ModelDiagnosticService) CommonException(com.evolveum.midpoint.util.exception.CommonException) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ShadowUtil(com.evolveum.midpoint.schema.util.ShadowUtil) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) MidPointAsserts(com.evolveum.midpoint.test.util.MidPointAsserts) AssertJUnit.assertNotNull(org.testng.AssertJUnit.assertNotNull) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) ModelAuditService(com.evolveum.midpoint.model.api.ModelAuditService) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) AuthorityUtils(org.springframework.security.core.authority.AuthorityUtils) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) TaskExecutionStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) QNameUtil(com.evolveum.midpoint.util.QNameUtil) MiscSchemaUtil(com.evolveum.midpoint.schema.util.MiscSchemaUtil) DirectoryException(org.opends.server.types.DirectoryException) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) ConfigAttribute(org.springframework.security.access.ConfigAttribute) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) ModelInteractionService(com.evolveum.midpoint.model.api.ModelInteractionService) ResourceTypeUtil(com.evolveum.midpoint.schema.util.ResourceTypeUtil) FileNotFoundException(java.io.FileNotFoundException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) List(java.util.List) Optional(java.util.Optional) Authentication(org.springframework.security.core.Authentication) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Item(com.evolveum.midpoint.prism.Item) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SecurityEnforcer(com.evolveum.midpoint.security.api.SecurityEnforcer) HashMap(java.util.HashMap) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) RoleSelectionSpecification(com.evolveum.midpoint.model.api.RoleSelectionSpecification) ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) AuthorizationDecisionType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationDecisionType) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) DeltaBuilder(com.evolveum.midpoint.prism.delta.builder.DeltaBuilder) DummyResource(com.evolveum.icf.dummy.resource.DummyResource) TaskExecutionStatus(com.evolveum.midpoint.task.api.TaskExecutionStatus) IntegrationTestTools.display(com.evolveum.midpoint.test.IntegrationTestTools.display) Message(com.evolveum.midpoint.notifications.api.transports.Message) QueryBuilder(com.evolveum.midpoint.prism.query.builder.QueryBuilder) FailableProcessor(com.evolveum.midpoint.util.FailableProcessor) SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Collections(java.util.Collections) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) QName(javax.xml.namespace.QName) ItemSecurityDecisions(com.evolveum.midpoint.security.api.ItemSecurityDecisions) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 5 with Item

use of com.evolveum.midpoint.prism.Item in project midpoint by Evolveum.

the class RObject method copyFromJAXB.

public static void copyFromJAXB(PrismContainerValue containerValue, RObject repo, RepositoryContext repositoryContext, RObjectExtensionType ownerType) throws DtoTranslationException {
    RAnyConverter converter = new RAnyConverter(repositoryContext.prismContext);
    Set<RAnyValue> values = new HashSet<RAnyValue>();
    try {
        List<Item<?, ?>> items = containerValue.getItems();
        //TODO: is this ehought??should we try items without definitions??
        if (items != null) {
            for (Item item : items) {
                values.addAll(converter.convertToRValue(item, false));
            }
        }
    } catch (Exception ex) {
        throw new DtoTranslationException(ex.getMessage(), ex);
    }
    for (RAnyValue value : values) {
        ROExtValue ex = (ROExtValue) value;
        ex.setOwner(repo);
        ex.setOwnerType(ownerType);
        if (value instanceof ROExtDate) {
            repo.getDates().add(value);
        } else if (value instanceof ROExtLong) {
            repo.getLongs().add(value);
        } else if (value instanceof ROExtReference) {
            repo.getReferences().add(value);
        } else if (value instanceof ROExtString) {
            repo.getStrings().add(value);
        } else if (value instanceof ROExtPolyString) {
            repo.getPolys().add(value);
        } else if (value instanceof ROExtBoolean) {
            repo.getBooleans().add(value);
        }
    }
    repo.setStringsCount((short) repo.getStrings().size());
    repo.setDatesCount((short) repo.getDates().size());
    repo.setPolysCount((short) repo.getPolys().size());
    repo.setReferencesCount((short) repo.getReferences().size());
    repo.setLongsCount((short) repo.getLongs().size());
    repo.setBooleansCount((short) repo.getBooleans().size());
}
Also used : ROExtLong(com.evolveum.midpoint.repo.sql.data.common.any.ROExtLong) ROExtString(com.evolveum.midpoint.repo.sql.data.common.any.ROExtString) ROExtReference(com.evolveum.midpoint.repo.sql.data.common.any.ROExtReference) ROExtDate(com.evolveum.midpoint.repo.sql.data.common.any.ROExtDate) RAnyConverter(com.evolveum.midpoint.repo.sql.data.common.any.RAnyConverter) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) ROExtValue(com.evolveum.midpoint.repo.sql.data.common.any.ROExtValue) Item(com.evolveum.midpoint.prism.Item) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) ROExtBoolean(com.evolveum.midpoint.repo.sql.data.common.any.ROExtBoolean) ROExtPolyString(com.evolveum.midpoint.repo.sql.data.common.any.ROExtPolyString) RAnyValue(com.evolveum.midpoint.repo.sql.data.common.any.RAnyValue) HashSet(java.util.HashSet)

Aggregations

Item (com.evolveum.midpoint.prism.Item)42 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)25 PrismObject (com.evolveum.midpoint.prism.PrismObject)24 QName (javax.xml.namespace.QName)23 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)19 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)17 SystemException (com.evolveum.midpoint.util.exception.SystemException)17 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)16 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)16 Test (org.testng.annotations.Test)16 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)15 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)15 ItemName (com.evolveum.midpoint.prism.path.ItemName)14 RepoModifyOptions (com.evolveum.midpoint.repo.api.RepoModifyOptions)14 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)14 SqaleUtils (com.evolveum.midpoint.repo.sqale.SqaleUtils)14 Jsonb (com.evolveum.midpoint.repo.sqale.jsonb.Jsonb)14