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;
}
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());
}
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());
}
}
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);
}
}
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;
}
Aggregations