Search in sources :

Example 16 with PrismReferenceDefinition

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

the class PageDebugList method createResourceRefSearchItem.

private PropertySearchItem createResourceRefSearchItem(Search search) {
    PrismReferenceDefinition resourceRefDef = getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByCompileTimeClass(ShadowType.class).findReferenceDefinition(ShadowType.F_RESOURCE_REF);
    PropertySearchItem<ObjectReferenceType> item = new PropertySearchItem<>(search, new SearchItemDefinition(ShadowType.F_RESOURCE_REF, resourceRefDef, null)) {

        @Override
        protected boolean canRemoveSearchItem() {
            return false;
        }
    };
    ObjectReferenceType ref = new ObjectReferenceType();
    ref.setType(ResourceType.COMPLEX_TYPE);
    item.setValue(new SearchValue<>(ref));
    return item;
}
Also used : PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition)

Example 17 with PrismReferenceDefinition

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

the class SearchPropertyPanel method initSearchItemField.

protected void initSearchItemField(WebMarkupContainer searchItemContainer) {
    Component searchItemField;
    PropertySearchItem<T> item = getModelObject();
    IModel<List<DisplayableValue<?>>> choices = null;
    switch(item.getSearchItemType()) {
        case REFERENCE:
            searchItemField = new ReferenceValueSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"), (PrismReferenceDefinition) item.getDefinition().getDef()) {

                @Override
                public Boolean isItemPanelEnabled() {
                    return item.isEnabled();
                }

                @Override
                protected boolean isAllowedNotFoundObjectRef() {
                    return item.getSearch().getTypeClass().equals(AuditEventRecordType.class);
                }

                @Override
                protected List<QName> getAllowedRelations() {
                    if (item.getSearch().getTypeClass().equals(AuditEventRecordType.class)) {
                        return Collections.emptyList();
                    }
                    return super.getAllowedRelations();
                }
            };
            break;
        case BOOLEAN:
            choices = (IModel) createBooleanChoices();
        case ENUM:
            if (choices == null) {
                choices = new ListModel(item.getAllowedValues(getPageBase()));
            }
            searchItemField = WebComponentUtil.createDropDownChoices(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), "value"), (IModel) choices, true, getPageBase());
            break;
        case DATE:
            searchItemField = new DateIntervalSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), "fromDate"), new PropertyModel(getModel(), "toDate"));
            break;
        case ITEM_PATH:
            searchItemField = new ItemPathSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), "value.value"));
            break;
        case TEXT:
            PrismObject<LookupTableType> lookupTable = WebComponentUtil.findLookupTable(item.getDefinition().getDef(), getPageBase());
            if (lookupTable != null) {
                searchItemField = createAutoCompetePanel(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"), lookupTable.asObjectable());
            } else {
                searchItemField = new TextPanel<String>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"));
            }
            break;
        default:
            searchItemField = new TextPanel<String>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value"));
    }
    if (searchItemField instanceof InputPanel && !(searchItemField instanceof AutoCompleteTextPanel)) {
        FormComponent<?> baseFormComponent = ((InputPanel) searchItemField).getBaseFormComponent();
        baseFormComponent.add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
        baseFormComponent.add(AttributeAppender.append("style", "width: 140px; max-width: 400px !important;"));
        baseFormComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
        baseFormComponent.add(new VisibleEnableBehaviour() {

            @Override
            public boolean isEnabled() {
                return item.isEnabled();
            }

            @Override
            public boolean isVisible() {
                return item.isVisible();
            }
        });
    }
    searchItemField.setOutputMarkupId(true);
    searchItemContainer.add(searchItemField);
}
Also used : IModel(org.apache.wicket.model.IModel) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PropertyModel(org.apache.wicket.model.PropertyModel) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) ListModel(org.apache.wicket.model.util.ListModel) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)

Example 18 with PrismReferenceDefinition

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

the class SqaleUtils method referenceWithTypeFixed.

/**
 * Fixes reference type if `null` and tries to use default from definition.
 * Use returned value.
 */
public static Referencable referenceWithTypeFixed(Referencable value) {
    if (value.getType() != null) {
        return value;
    }
    PrismReferenceDefinition def = value.asReferenceValue().getDefinition();
    QName defaultType = def.getTargetTypeName();
    if (defaultType == null) {
        throw new IllegalArgumentException("Can't modify reference with no target type" + " specified and no default type in the definition. Value: " + value + " Definition: " + def);
    }
    value = new ObjectReferenceType().oid(value.getOid()).type(defaultType).relation(value.getRelation());
    return value;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) QName(javax.xml.namespace.QName) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition)

Example 19 with PrismReferenceDefinition

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

the class SchemaTestUtil method assertFocusDefinition.

public static void assertFocusDefinition(ComplexTypeDefinition complexTypeDefinition, String defDesc, QName expectedExtensionTypeName, int expectedExtensionItemDefs) {
    assertNotNull("No " + defDesc + " definition", complexTypeDefinition);
    PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
    PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_NAME, "ObjectType.name");
    PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_NAME, 0);
    PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
    PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_DESCRIPTION, "ObjectType.description");
    PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_DESCRIPTION, 10);
    assertFalse("" + defDesc + " definition is marked as runtime", complexTypeDefinition.isRuntimeSchema());
    PrismContainerDefinition extensionContainer = complexTypeDefinition.findContainerDefinition(UserType.F_EXTENSION);
    PrismAsserts.assertDefinition(extensionContainer, UserType.F_EXTENSION, expectedExtensionTypeName, 0, 1);
    assertTrue("Extension is NOT runtime", extensionContainer.isRuntimeSchema());
    // assertTrue("Extension is NOT dynamic", extensionContainer.isDynamic());
    assertEquals("Extension size", expectedExtensionItemDefs, extensionContainer.getDefinitions().size());
    PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, UserType.F_EXTENSION, "ObjectType.extension");
    PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, UserType.F_EXTENSION, 1000);
    PrismContainerDefinition<ActivationType> activationContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ACTIVATION);
    PrismAsserts.assertDefinition(activationContainer, UserType.F_ACTIVATION, ActivationType.COMPLEX_TYPE, 0, 1);
    assertFalse("Activation is runtime", activationContainer.isRuntimeSchema());
    assertEquals("Activation size", 12, activationContainer.getDefinitions().size());
    PrismAsserts.assertPropertyDefinition(activationContainer, ActivationType.F_ADMINISTRATIVE_STATUS, SchemaConstants.C_ACTIVATION_STATUS_TYPE, 0, 1);
    PrismContainerDefinition<AssignmentType> assignmentContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ASSIGNMENT);
    PrismAsserts.assertDefinition(assignmentContainer, UserType.F_ASSIGNMENT, AssignmentType.COMPLEX_TYPE, 0, -1);
    assertFalse("Assignment is runtime", assignmentContainer.isRuntimeSchema());
    assertEquals("Assignment definition size", 24, assignmentContainer.getDefinitions().size());
    PrismContainerDefinition<ConstructionType> constructionContainer = assignmentContainer.findContainerDefinition(AssignmentType.F_CONSTRUCTION);
    PrismAsserts.assertDefinition(constructionContainer, AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE, 0, 1);
    assertFalse("Construction is runtime", constructionContainer.isRuntimeSchema());
    PrismReferenceDefinition accountRefDef = complexTypeDefinition.findItemDefinition(UserType.F_LINK_REF, PrismReferenceDefinition.class);
    PrismAsserts.assertDefinition(accountRefDef, UserType.F_LINK_REF, ObjectReferenceType.COMPLEX_TYPE, 0, -1);
    assertEquals("Wrong target type in accountRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
    PrismContainerDefinition<MetadataType> metadataContainer = complexTypeDefinition.findContainerDefinition(UserType.F_METADATA);
    assertFalse("Metadata is runtime", metadataContainer.isRuntimeSchema());
    assertFalse("Metadata is dynamic", metadataContainer.isDynamic());
    assertTrue("Metadata is NOT operational", metadataContainer.isOperational());
    assertEquals("Metadata size", 23, metadataContainer.getDefinitions().size());
    PrismReferenceDefinition tenantRefDef = complexTypeDefinition.findItemDefinition(UserType.F_TENANT_REF, PrismReferenceDefinition.class);
    PrismAsserts.assertDefinition(tenantRefDef, UserType.F_TENANT_REF, ObjectReferenceType.COMPLEX_TYPE, 0, 1);
    assertEquals("Wrong target type in tenantRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition)

Aggregations

PrismReferenceDefinition (com.evolveum.midpoint.prism.PrismReferenceDefinition)19 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)4 QName (javax.xml.namespace.QName)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 ArrayList (java.util.ArrayList)3 PrismReference (com.evolveum.midpoint.prism.PrismReference)2 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)2 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)2 ConstructionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType)2 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)2 IModel (org.apache.wicket.model.IModel)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 ActivationComputer (com.evolveum.midpoint.common.ActivationComputer)1 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)1