Search in sources :

Example 26 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class PersonaProcessor method readExistingPersonas.

public <F extends FocusType> List<FocusType> readExistingPersonas(LensContext<F> context, Task task, OperationResult result) {
    LensFocusContext<F> focusContext = context.getFocusContext();
    PrismObject<F> focus = focusContext.getObjectNew();
    List<FocusType> personas = new ArrayList<>();
    String desc = "personaRef in " + focus;
    for (ObjectReferenceType personaRef : focus.asObjectable().getPersonaRef()) {
        try {
            FocusType persona = objectResolver.resolve(personaRef, FocusType.class, null, desc, task, result);
            personas.add(persona);
        } catch (ObjectNotFoundException | SchemaException e) {
            LOGGER.warn("Cannot find persona {} referenced from {}", personaRef.getOid(), focus);
        // But go on...
        }
    }
    return personas;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ArrayList(java.util.ArrayList)

Example 27 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class ObjectPolicyConfigurationEditor method createNameModel.

private IModel<String> createNameModel(final IModel<ObjectPolicyConfigurationTypeDto> model) {
    return new LoadableModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String load() {
            StringBuilder sb = new StringBuilder();
            ObjectPolicyConfigurationTypeDto config = model.getObject();
            if (config != null) {
                ObjectReferenceType ref = config.getTemplateRef();
                if (ref != null) {
                    sb.append(WebComponentUtil.getOrigStringFromPoly(ref.getTargetName())).append(": ");
                }
                if (config.getType() != null) {
                    sb.append(config.getType().getLocalPart());
                }
                if (config.getSubtype() != null) {
                    sb.append("(").append(config.getSubtype()).append(")");
                }
            }
            return sb.toString();
        }
    };
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 28 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AssignmentTablePanel method removeResourceFromAccConstruction.

/**
	 * remove this method after model is updated - it has to remove resource
	 * from accountConstruction
	 */
@Deprecated
private void removeResourceFromAccConstruction(AssignmentType assignment) {
    ConstructionType accConstruction = assignment.getConstruction();
    if (accConstruction == null || accConstruction.getResource() == null) {
        return;
    }
    ObjectReferenceType ref = new ObjectReferenceType();
    ref.setOid(assignment.getConstruction().getResource().getOid());
    ref.setType(ResourceType.COMPLEX_TYPE);
    assignment.getConstruction().setResourceRef(ref);
    assignment.getConstruction().setResource(null);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType)

Example 29 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestParseResource method assertResourceJaxb.

private void assertResourceJaxb(ResourceType resourceType, boolean isSimple) throws SchemaException {
    assertEquals("Wrong oid (JAXB)", TestConstants.RESOURCE_OID, resourceType.getOid());
    assertEquals("Wrong name (JAXB)", PrismTestUtil.createPolyStringType("Embedded Test OpenDJ"), resourceType.getName());
    String expectedNamespace = TestConstants.RESOURCE_NAMESPACE;
    if (isSimple) {
        expectedNamespace = MidPointConstants.NS_RI;
    }
    assertEquals("Wrong namespace (JAXB)", expectedNamespace, ResourceTypeUtil.getResourceNamespace(resourceType));
    ObjectReferenceType connectorRef = resourceType.getConnectorRef();
    assertNotNull("No connectorRef (JAXB)", connectorRef);
    assertEquals("Wrong type in connectorRef (JAXB)", ConnectorType.COMPLEX_TYPE, connectorRef.getType());
    SearchFilterType filter = connectorRef.getFilter();
    assertNotNull("No filter in connectorRef (JAXB)", filter);
    MapXNode filterElement = filter.getFilterClauseXNode();
    assertNotNull("No filter element in connectorRef (JAXB)", filterElement);
    EvaluationTimeType resolutionTime = connectorRef.getResolutionTime();
    if (isSimple) {
        assertEquals("Wrong resolution time in connectorRef (JAXB)", EvaluationTimeType.RUN, resolutionTime);
    } else {
        assertEquals("Wrong resolution time in connectorRef (JAXB)", EvaluationTimeType.IMPORT, resolutionTime);
    }
    XmlSchemaType xmlSchemaType = resourceType.getSchema();
    SchemaHandlingType schemaHandling = resourceType.getSchemaHandling();
    if (isSimple) {
        assertNull("Schema sneaked in", xmlSchemaType);
        assertNull("SchemaHandling sneaked in", schemaHandling);
    } else {
        assertNotNull("No schema element (JAXB)", xmlSchemaType);
        SchemaDefinitionType definition = xmlSchemaType.getDefinition();
        assertNotNull("No definition element in schema (JAXB)", definition);
        List<Element> anyElements = definition.getAny();
        assertNotNull("Null element list in definition element in schema (JAXB)", anyElements);
        assertFalse("Empty element list in definition element in schema (JAXB)", anyElements.isEmpty());
        assertNotNull("No schema handling (JAXB)", schemaHandling);
        for (ResourceObjectTypeDefinitionType accountType : schemaHandling.getObjectType()) {
            String name = accountType.getIntent();
            assertNotNull("Account type without a name", name);
            assertNotNull("Account type " + name + " does not have an objectClass", accountType.getObjectClass());
            boolean foundDescription = false;
            boolean foundDepartmentNumber = false;
            for (ResourceAttributeDefinitionType attributeDefinitionType : accountType.getAttribute()) {
                if ("description".equals(ItemPathUtil.getOnlySegmentQName(attributeDefinitionType.getRef()).getLocalPart())) {
                    foundDescription = true;
                    MappingType outbound = attributeDefinitionType.getOutbound();
                    JAXBElement<?> valueEvaluator = outbound.getExpression().getExpressionEvaluator().get(0);
                    System.out.println("value evaluator for description = " + valueEvaluator);
                    assertNotNull("no expression evaluator for description", valueEvaluator);
                    assertEquals("wrong expression evaluator element name for description", SchemaConstantsGenerated.C_VALUE, valueEvaluator.getName());
                    assertEquals("wrong expression evaluator actual type for description", RawType.class, valueEvaluator.getValue().getClass());
                } else if ("departmentNumber".equals(ItemPathUtil.getOnlySegmentQName(attributeDefinitionType.getRef()).getLocalPart())) {
                    foundDepartmentNumber = true;
                    MappingType outbound = attributeDefinitionType.getOutbound();
                    VariableBindingDefinitionType source = outbound.getSource().get(0);
                    System.out.println("source for departmentNumber = " + source);
                    assertNotNull("no source for outbound mapping for departmentNumber", source);
                    //<path xmlns:z="http://z/">$user/extension/z:dept</path>
                    ItemPath expected = new ItemPath(new NameItemPathSegment(new QName("user"), true), new NameItemPathSegment(new QName("extension")), namespaces ? new NameItemPathSegment(new QName("http://z/", "dept")) : new NameItemPathSegment(new QName("dept")));
                    PrismAsserts.assertPathEqualsExceptForPrefixes("source for departmentNubmer", expected, source.getPath().getItemPath());
                }
            }
            assertTrue("ri:description attribute was not found", foundDescription);
            assertTrue("ri:departmentNumber attribute was not found", foundDepartmentNumber);
        }
        // checking <class> element in fetch result
        OperationResultType fetchResult = resourceType.getFetchResult();
        assertNotNull("No fetchResult (JAXB)", fetchResult);
        JAXBElement<?> value = fetchResult.getParams().getEntry().get(0).getEntryValue();
        assertNotNull("No fetchResult param value (JAXB)", value);
        assertEquals("Wrong value class", UnknownJavaObjectType.class, value.getValue().getClass());
        UnknownJavaObjectType unknownJavaObjectType = (UnknownJavaObjectType) value.getValue();
        assertEquals("Wrong value class", "my.class", unknownJavaObjectType.getClazz());
        assertEquals("Wrong value toString value", "my.value", unknownJavaObjectType.getToString());
    }
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 30 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestSchemaDelta method testDeleteInducementConstructionSameNullIdApplyToObject.

@Test
public void testDeleteInducementConstructionSameNullIdApplyToObject() throws Exception {
    final String TEST_NAME = "testDeleteInducementConstructionSameNullIdApplyToObject";
    displayTestTile(TEST_NAME);
    // GIVEN
    PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
    //Delta
    ConstructionType construction = new ConstructionType();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(ROLE_CONSTRUCTION_RESOURCE_OID);
    resourceRef.setType(ObjectTypes.RESOURCE.getTypeQName());
    construction.setResourceRef(resourceRef);
    // No container ID
    ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(ROLE_CONSTRUCTION_INDUCEMENT_ID), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), getPrismContext(), construction);
    // WHEN
    roleDelta.applyTo(role);
    // THEN
    System.out.println("Role after delta application:");
    System.out.println(role.debugDump());
    assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
    PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
    PrismContainer<AssignmentType> inducementContainer = role.findContainer(RoleType.F_INDUCEMENT);
    assertNotNull("No inducement", inducementContainer);
    assertEquals("Unexpected number of inducement values", 1, inducementContainer.size());
    PrismContainerValue<AssignmentType> inducementValue = inducementContainer.getValues().iterator().next();
    AssignmentType inducement = inducementValue.asContainerable();
    ConstructionType constructionAfter = inducement.getConstruction();
    // construction should be gone (the error is that it is empty and not gone)
    assertNull("Construction is not gone", constructionAfter);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)225 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)100 Test (org.testng.annotations.Test)79 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)78 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)77 Task (com.evolveum.midpoint.task.api.Task)50 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)41 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)36 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)32 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)31 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 QName (javax.xml.namespace.QName)29 ArrayList (java.util.ArrayList)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)25 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)22 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)17