Search in sources :

Example 1 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class SearchingUtils method createObjectOrderings.

@NotNull
public static List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam, boolean isWorkItem, PrismContext prismContext) {
    if (sortParam == null || sortParam.getProperty() == null) {
        return Collections.emptyList();
    }
    String propertyName = sortParam.getProperty();
    ItemPath casePath = isWorkItem ? ItemName.fromQName(T_PARENT) : ItemPath.EMPTY_PATH;
    ItemPath campaignPath = casePath.append(T_PARENT);
    ItemPath primaryItemPath;
    if (TARGET_NAME.equals(propertyName)) {
        primaryItemPath = casePath.append(AccessCertificationCaseType.F_TARGET_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
    } else if (OBJECT_NAME.equals(propertyName)) {
        primaryItemPath = casePath.append(AccessCertificationCaseType.F_OBJECT_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
    } else if (TENANT_NAME.equals(propertyName)) {
        primaryItemPath = casePath.append(AccessCertificationCaseType.F_TENANT_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
    } else if (ORG_NAME.equals(propertyName)) {
        primaryItemPath = casePath.append(AccessCertificationCaseType.F_ORG_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
    } else if (CURRENT_REVIEW_DEADLINE.equals(propertyName)) {
        primaryItemPath = casePath.append(AccessCertificationCaseType.F_CURRENT_STAGE_DEADLINE);
    } else if (CURRENT_REVIEW_REQUESTED_TIMESTAMP.equals(propertyName)) {
        primaryItemPath = casePath.append(AccessCertificationCaseType.F_CURRENT_STAGE_CREATE_TIMESTAMP);
    } else if (CAMPAIGN_NAME.equals(propertyName)) {
        primaryItemPath = campaignPath.append(ObjectType.F_NAME);
    } else {
        primaryItemPath = new ItemName(SchemaConstantsGenerated.NS_COMMON, propertyName);
    }
    List<ObjectOrdering> rv = new ArrayList<>();
    rv.add(prismContext.queryFactory().createOrdering(primaryItemPath, sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING));
    // additional criteria are used to avoid random shuffling if first criteria is too vague)
    // campaign OID
    rv.add(prismContext.queryFactory().createOrdering(campaignPath.append(PrismConstants.T_ID), OrderDirection.ASCENDING));
    // case ID
    rv.add(prismContext.queryFactory().createOrdering(casePath.append(PrismConstants.T_ID), OrderDirection.ASCENDING));
    if (isWorkItem) {
        // work item ID
        rv.add(prismContext.queryFactory().createOrdering(ItemName.fromQName(PrismConstants.T_ID), OrderDirection.ASCENDING));
    }
    return rv;
}
Also used : ArrayList(java.util.ArrayList) ItemName(com.evolveum.midpoint.prism.path.ItemName) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class TestResourceSchema method assertResourceSchema.

private void assertResourceSchema(ResourceSchema unSchema) {
    ResourceObjectClassDefinition objectClassDef = unSchema.findObjectClassDefinition(new ItemName(MidPointConstants.NS_RI, "AccountObjectClass"));
    assertNotNull("No object class def", objectClassDef);
    assertEquals(new ItemName(MidPointConstants.NS_RI, "AccountObjectClass"), objectClassDef.getTypeName());
    assertTrue("AccountObjectClass class not a DEFAULT account", objectClassDef.isDefaultAccountDefinition());
    PrismPropertyDefinition<String> loginDef = objectClassDef.findPropertyDefinition(new ItemName(MidPointConstants.NS_RI, "login"));
    assertEquals(new ItemName(MidPointConstants.NS_RI, "login"), loginDef.getItemName());
    assertEquals(DOMUtil.XSD_STRING, loginDef.getTypeName());
    PrismPropertyDefinition<ProtectedStringType> passwdDef = objectClassDef.findPropertyDefinition(new ItemName(MidPointConstants.NS_RI, "password"));
    assertEquals(new ItemName(MidPointConstants.NS_RI, "password"), passwdDef.getItemName());
    assertEquals(ProtectedStringType.COMPLEX_TYPE, passwdDef.getTypeName());
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 3 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class AbstractImportTest method assertDummyResource.

private void assertDummyResource(PrismObject<ResourceType> resource, boolean fromRepo) {
    PrismContainer<Containerable> configurationPropertiesContainer = assertResource(resource, "Dummy Resource", RESOURCE_DUMMY_NAMESPACE, dummyConnector.getOid());
    PrismProperty<ProtectedStringType> guardedProperty = configurationPropertiesContainer.findProperty(new ItemName(CONNECTOR_DUMMY_NAMESPACE, "uselessGuardedString"));
    // The resource was pulled from the repository. Therefore it does not have the right schema here. We should proceed with caution
    // and inspect the DOM elements there
    assertNotNull("No uselessGuardedString property in configuration properties", guardedProperty);
    PrismPropertyValue<ProtectedStringType> guardedPVal = guardedProperty.getValue();
    if (fromRepo) {
        Object passwordRawElement = guardedPVal.getRawElement();
        if (!(passwordRawElement instanceof MapXNode)) {
            AssertJUnit.fail("Expected password value of type " + MapXNode.class + " but got " + passwordRawElement.getClass());
        }
        MapXNode passwordXNode = (MapXNode) passwordRawElement;
        assertTrue("uselessGuardedString was not encrypted (clearValue)", passwordXNode.get(new QName("clearValue")) == null);
        assertTrue("uselessGuardedString was not encrypted (no encryptedData)", passwordXNode.get(new QName("encryptedData")) != null);
    } else {
        ProtectedStringType psType = guardedPVal.getValue();
        assertNull("uselessGuardedString was not encrypted (clearValue)", psType.getClearValue());
        assertNotNull("uselessGuardedString was not encrypted (no EncryptedData)", psType.getEncryptedDataType());
    }
}
Also used : QName(javax.xml.namespace.QName) ItemName(com.evolveum.midpoint.prism.path.ItemName) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 4 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class ReportUtils method getItemRealValue.

public static <C extends Containerable> Object getItemRealValue(PrismContainerValue<C> containerValue, String itemName) {
    Item<?, ?> item = containerValue.findItem(new ItemName(itemName));
    if (item == null || item.size() == 0) {
        return null;
    }
    if (item.size() > 1) {
        throw new IllegalStateException("More than one value in item " + item);
    }
    PrismValue value = item.getAnyValue();
    if (value == null) {
        return null;
    }
    if (value instanceof PrismPropertyValue) {
        return ((PrismPropertyValue<?>) value).getValue();
    } else if (value instanceof PrismReferenceValue) {
        ObjectReferenceType ort = new ObjectReferenceType();
        ort.setupReferenceValue((PrismReferenceValue) value);
        return ort;
    } else if (value instanceof PrismContainerValue) {
        // questionable
        return ((PrismContainerValue<?>) value).asContainerable();
    } else {
        throw new IllegalStateException("Unknown PrismValue: " + value);
    }
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 5 with ItemName

use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.

the class LensUtil method createActivationTimestampDelta.

public static PropertyDelta<XMLGregorianCalendar> createActivationTimestampDelta(ActivationStatusType status, XMLGregorianCalendar now, PrismContainerDefinition<ActivationType> activationDefinition, OriginType origin, PrismContext prismContext) {
    ItemName timestampPropertyName;
    if (status == null || status == ActivationStatusType.ENABLED) {
        timestampPropertyName = ActivationType.F_ENABLE_TIMESTAMP;
    } else if (status == ActivationStatusType.DISABLED) {
        timestampPropertyName = ActivationType.F_DISABLE_TIMESTAMP;
    } else if (status == ActivationStatusType.ARCHIVED) {
        timestampPropertyName = ActivationType.F_ARCHIVE_TIMESTAMP;
    } else {
        throw new IllegalArgumentException("Unknown activation status " + status);
    }
    PrismPropertyDefinition<XMLGregorianCalendar> timestampDef = activationDefinition.findPropertyDefinition(timestampPropertyName);
    PropertyDelta<XMLGregorianCalendar> timestampDelta = timestampDef.createEmptyDelta(FocusType.F_ACTIVATION.append(timestampPropertyName));
    timestampDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(now, origin, null));
    return timestampDelta;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ItemName(com.evolveum.midpoint.prism.path.ItemName)

Aggregations

ItemName (com.evolveum.midpoint.prism.path.ItemName)89 Test (org.testng.annotations.Test)24 QName (javax.xml.namespace.QName)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)13 NotNull (org.jetbrains.annotations.NotNull)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 Task (com.evolveum.midpoint.task.api.Task)6 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)5 MUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser)5 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)5 Element (org.w3c.dom.Element)5 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 ArrayList (java.util.ArrayList)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3