Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,29 @@ oid="00000000-0000-0000-0000-000000000380">
<path>fullName</path>
</target>
</mapping>
<mapping id="3">
<name>generate-display-name</name>
<description>Generate displayName from preferredName, falling back to fullName.</description>
<strength>strong</strength>
<source>
<path>preferredName</path>
</source>
<source>
<path>fullName</path>
</source>
<expression>
<script>
<code>
preferredNameString = basic.trim(basic.stringify(preferredName))
if (preferredNameString) {
return preferredName
}
return fullName
</code>
</script>
</expression>
<target>
<path>displayName</path>
</target>
</mapping>
</objectTemplate>
5 changes: 5 additions & 0 deletions config/initial-objects/report/110-report-user-list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@
</export>
<previousColumn>orgColumn</previousColumn>
</column>
<column id="12">
<name>displayNameColumn</name>
<path>displayName</path>
<previousColumn>accountColumn</previousColumn>
</column>
<type>UserType</type>
</view>
</objectCollection>
Expand Down
1 change: 1 addition & 0 deletions config/initial-objects/user/050-user-administrator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<name>administrator</name>
<indestructible>true</indestructible>
<fullName>midPoint Administrator</fullName>
<displayName>midPoint Administrator</displayName>
<givenName>midPoint</givenName>
<familyName>Administrator</familyName>
<assignment id="1">
Expand Down
16 changes: 16 additions & 0 deletions config/sql/native/postgres-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,22 @@ CREATE INDEX m_connector_typeVersionHost_key
WHERE connectorHostRefTargetOid IS NOT NULL;
$aa$);

-- @change: Adds display and preferred name columns and indexes to users.
-- @since: 4.11
-- @affects: table m_user | Modified table | Adds display and preferred name columns.
-- @affects: index m_user_displayNameOrig_idx | New index | Supports lookup by original display name.
-- @affects: index m_user_preferredNameOrig_idx | New index | Supports lookup by original preferred name.
call apply_change(58, $aa$

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add annotations for schema generator :)

ALTER TABLE m_user
ADD COLUMN displayNameOrig TEXT,
ADD COLUMN displayNameNorm TEXT,
ADD COLUMN preferredNameOrig TEXT,
ADD COLUMN preferredNameNorm TEXT;

CREATE INDEX m_user_displayNameOrig_idx ON m_user (displayNameOrig);
CREATE INDEX m_user_preferredNameOrig_idx ON m_user (preferredNameOrig);
$aa$);

---
-- WRITE CHANGES ABOVE ^^
-- IMPORTANT: update apply_change number at the end of postgres-new.sql
Expand Down
16 changes: 15 additions & 1 deletion config/sql/native/postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,10 @@ CREATE TABLE m_user (
additionalNameOrig TEXT,
-- @description: Additional name in normalized form used for searches.
additionalNameNorm TEXT,
-- @description: Display name in original form.
displayNameOrig TEXT,
-- @description: Display name in normalized form used for searches.
displayNameNorm TEXT,
-- @description: Employee number assigned to the user.
employeeNumber TEXT,
-- @description: Family name in original form.
Expand Down Expand Up @@ -877,6 +881,10 @@ CREATE TABLE m_user (
nickNameNorm TEXT,
-- @description: Personal number assigned to the user.
personalNumber TEXT,
-- @description: Preferred name in original form.
preferredNameOrig TEXT,
-- @description: Preferred name in normalized form used for searches.
preferredNameNorm TEXT,
-- @description: Title in original form.
titleOrig TEXT,
-- @description: Title in normalized form used for searches.
Expand Down Expand Up @@ -910,6 +918,9 @@ CREATE INDEX m_user_policySituation_idx ON m_user USING gin(policysituations gin
-- @description: Speeds up filtering by indexed extension values.
-- @usedFor: extension item filters
CREATE INDEX m_user_ext_idx ON m_user USING gin(ext);
-- @description: Speeds up lookup by display name.
-- @usedFor: display name searches
CREATE INDEX m_user_displayNameOrig_idx ON m_user (displayNameOrig);
-- @description: Speeds up lookup by original full name.
-- @usedFor: full name searches
CREATE INDEX m_user_fullNameOrig_idx ON m_user (fullNameOrig);
Expand All @@ -922,6 +933,9 @@ CREATE INDEX m_user_givenNameOrig_idx ON m_user (givenNameOrig);
-- @description: Speeds up lookup by employee number.
-- @usedFor: employee number searches
CREATE INDEX m_user_employeeNumber_idx ON m_user (employeeNumber);
-- @description: Speeds up lookup by preferred name.
-- @usedFor: preferred name searches
CREATE INDEX m_user_preferredNameOrig_idx ON m_user (preferredNameOrig);
-- @description: Speeds up filtering by object subtype.
-- @usedFor: subtype filters
CREATE INDEX m_user_subtypes_idx ON m_user USING gin(subtypes);
Expand Down Expand Up @@ -4155,4 +4169,4 @@ END $$;
-- This is important to avoid applying any change more than once.
-- Also update SqaleUtils.CURRENT_SCHEMA_CHANGE_NUMBER
-- repo/repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleUtils.java
call apply_change(57, $$ SELECT 1 $$, true);
call apply_change(58, $$ SELECT 1 $$, true);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This page documents schema changes applied to existing databases by `config/sql/
| Changes range

| xref:postgres-upgrade/4.11.adoc[midPoint 4.11]
| 52-57
| 52-58

| xref:postgres-upgrade/4.10.adoc[midPoint 4.10]
| 51
Expand Down Expand Up @@ -46,6 +46,9 @@ This page documents schema changes applied to existing databases by `config/sql/
| Change
| Description

| xref:postgres-upgrade/4.11.adoc#change-58[Change 58]
| Adds display and preferred name columns and indexes to users.

| xref:postgres-upgrade/4.11.adoc#change-57[Change 57]
| Recreates connector type/version uniqueness indexes with connector-host specific predicates.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
| Change
| Description

| <<change-58,Change 58>>
| Adds display and preferred name columns and indexes to users.

| <<change-57,Change 57>>
| Recreates connector type/version uniqueness indexes with connector-host specific predicates.

Expand All @@ -27,6 +30,33 @@

|===

[[change-58]]
== Change 58

Since version: 4.11

Adds display and preferred name columns and indexes to users.

[cols="1,1,3", options="header"]
|===
| Object
| Change type
| Description

| `m_user`
| Modified table
| Adds display and preferred name columns.

| `m_user_displayNameOrig_idx`
| New index
| Supports lookup by original display name.

| `m_user_preferredNameOrig_idx`
| New index
| Supports lookup by original preferred name.

|===

[[change-57]]
== Change 57

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,16 @@ Inherits from: xref:#m_focus[`m_focus`]
|
| Additional name in normalized form used for searches.

| `displayNameOrig`
| `TEXT`
|
| Display name in original form.

| `displayNameNorm`
| `TEXT`
|
| Display name in normalized form used for searches.

| `employeeNumber`
| `TEXT`
|
Expand Down Expand Up @@ -533,6 +543,16 @@ Inherits from: xref:#m_focus[`m_focus`]
|
| Personal number assigned to the user.

| `preferredNameOrig`
| `TEXT`
|
| Preferred name in original form.

| `preferredNameNorm`
| `TEXT`
|
| Preferred name in normalized form used for searches.

| `titleOrig`
| `TEXT`
|
Expand Down Expand Up @@ -579,6 +599,10 @@ Inherits from: xref:#m_focus[`m_focus`]
| `USING gin (ext)`
| Speeds up filtering by indexed extension values. Used for: extension item filters

| `m_user_displayNameOrig_idx`
| `displayNameOrig`
| Speeds up lookup by display name. Used for: display name searches

| `m_user_fullNameOrig_idx`
| `fullNameOrig`
| Speeds up lookup by original full name. Used for: full name searches
Expand All @@ -595,6 +619,10 @@ Inherits from: xref:#m_focus[`m_focus`]
| `employeeNumber`
| Speeds up lookup by employee number. Used for: employee number searches

| `m_user_preferredNameOrig_idx`
| `preferredNameOrig`
| Speeds up lookup by preferred name. Used for: preferred name searches

| `m_user_subtypes_idx`
| `USING gin (subtypes)`
| Speeds up filtering by object subtype. Used for: subtype filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,9 @@ public static String getReferencedObjectDisplayNameAndName(Referencable ref, boo
return getReferencedObjectDisplayNamesAndNames(ref, false, true);
}
ObjectType object = prismObject.asObjectable();
String displayName = null;
if (object instanceof UserType) {
displayName = getTranslatedPolyString(((UserType) object).getFullName());
} else if (object instanceof AbstractRoleType) {
displayName = getTranslatedPolyString(((AbstractRoleType) object).getDisplayName());
}
String displayName = getTranslatedPolyString(ObjectTypeUtil.getDisplayName(object));
String name = getTranslatedPolyString(object.getName());
return StringUtils.isNotEmpty(displayName) ? displayName + " (" + name + ")" : name;
return StringUtils.isNotEmpty(displayName) && !Objects.equals(displayName, name) ? displayName + " (" + name + ")" : name;
}

public static String getReferencedObjectDisplayNamesAndNames(List<ObjectReferenceType> refs, boolean showTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public class SearchBoxConfigurationBuilder {
ItemPath.create(ObjectType.F_NAME))
);
FIXED_SEARCH_ITEMS.put(UserType.class, Arrays.asList(
ItemPath.create(UserType.F_FULL_NAME)
ItemPath.create(UserType.F_FULL_NAME),
ItemPath.create(UserType.F_DISPLAY_NAME)
));
FIXED_SEARCH_ITEMS.put(AbstractRoleType.class, Arrays.asList(
ItemPath.create(RoleType.F_DISPLAY_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public SearchableItemsDefinitions additionalSearchContext(SearchContext ctx) {
ItemPath.create(UserType.F_GIVEN_NAME),
ItemPath.create(UserType.F_FAMILY_NAME),
ItemPath.create(UserType.F_FULL_NAME),
ItemPath.create(UserType.F_DISPLAY_NAME),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we search preferred name as well?

ItemPath.create(UserType.F_ADDITIONAL_NAME),
ItemPath.create(UserType.F_EMPLOYEE_NUMBER),
ItemPath.create(UserType.F_ORGANIZATIONAL_UNIT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.util.function.Function;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Page;

import com.evolveum.midpoint.gui.api.page.PageBase;
Expand All @@ -22,6 +21,7 @@
import com.evolveum.midpoint.schema.constants.ExpressionConstants;
import com.evolveum.midpoint.schema.expression.VariablesMap;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
Expand Down Expand Up @@ -74,8 +74,8 @@ default ObjectFilter createAutocompleteFilter(String text, SearchFilterType filt

default String getDefaultUserDisplayName(PrismObject<UserType> o) {
String name = WebComponentUtil.getOrigStringFromPoly(o.getName());
String fullName = WebComponentUtil.getOrigStringFromPoly(o.asObjectable().getFullName());
String displayName = WebComponentUtil.getOrigStringFromPoly(ObjectTypeUtil.getDisplayName(o));

return StringUtils.isNotEmpty(fullName) ? fullName + " (" + name + ")" : name;
return displayName != null && !displayName.equals(name) ? displayName + " (" + name + ")" : name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.LocalizationUtil;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.component.input.DateTimePickerPanel;
import com.evolveum.midpoint.gui.impl.page.admin.user.PageUser;
Expand Down Expand Up @@ -624,8 +625,8 @@ private String getUserDisplayName(){
} else {
UserType delegationUser = getModelObject().getDelegationOwner();
if (getModelObject().getDelegationOwner() != null) {
if (delegationUser.getFullName() != null && StringUtils.isNotEmpty(delegationUser.getFullName().getOrig())) {
displayName = delegationUser.getFullName().getOrig() + " (" + delegationUser.getName().getOrig() + ")";
if (delegationUser.getDisplayName() != null && StringUtils.isNotEmpty(delegationUser.getDisplayName().getOrig())) {
displayName = delegationUser.getDisplayName().getOrig() + " (" + delegationUser.getName().getOrig() + ")";
} else {
displayName = delegationUser.getName() != null ? delegationUser.getName().getOrig() : "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ public static <T extends ObjectType> List<IColumn<SelectableBean<T>, String>> ge
SelectableBeanImpl.F_VALUE + ".familyName", false, true),
new ColumnTypeDto<>("UserType.fullName", UserType.F_FULL_NAME.getLocalPart(),
SelectableBeanImpl.F_VALUE + ".fullName", false, true),
new ColumnTypeDto<>("UserType.displayName", UserType.F_DISPLAY_NAME.getLocalPart(),
SelectableBeanImpl.F_VALUE + ".displayName", false, true),
new ColumnTypeDto<>("UserType.emailAddress", UserType.F_EMAIL_ADDRESS.getLocalPart(),
SelectableBeanImpl.F_VALUE + ".emailAddress", false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile;
import com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.security.api.MidPointPrincipal;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -132,6 +133,9 @@ private String getShortUserName() {
}

if (principalObj instanceof MidPointPrincipal principal) {
if (principal.getFocus() != null) {
return WebComponentUtil.getOrigStringFromPoly(ObjectTypeUtil.getDisplayName(principal.getFocus()));
}
return WebComponentUtil.getOrigStringFromPoly(principal.getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

import org.apache.commons.lang3.StringUtils;

import static com.evolveum.midpoint.gui.api.page.PageBase.createEnumResourceKey;
import static com.evolveum.midpoint.gui.api.page.PageBase.createStringResourceStatic;
import static com.evolveum.midpoint.schema.util.CertCampaignTypeUtil.norm;
Expand Down Expand Up @@ -65,7 +67,7 @@ public static String resolveOwnerName(ObjectReferenceType ownerRef, PageBase pag
ObjectType owner = ownerObject.asObjectable();
if (owner instanceof UserType) {
UserType user = (UserType) owner;
return WebComponentUtil.getName(user) + " (" + WebComponentUtil.getOrigStringFromPoly(user.getFullName()) + ")";
return WebComponentUtil.getName(user) + " (" + WebComponentUtil.getOrigStringFromPoly(user.getDisplayName()) + ")";
} else {
return WebComponentUtil.getName(owner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ public String getCaseInfoButtonTitle(IModel<? extends CertCaseOrWorkItemDto> row
String objectType = getLocalizedTypeName(acase.getObjectRef().getType(), page);
String objectName = dto.getObjectName();

// If object is UserType, display user's fullName in addition to the name
// If object is UserType, display user's displayName in addition to the name
if (QNameUtil.match(acase.getObjectRef().getType(), UserType.COMPLEX_TYPE)) {
try {
PrismObject<UserType> object = page.getModelService().getObject(UserType.class, acase.getObjectRef().getOid(), null, page.getPageTask(), page.getPageTask().getResult());

if (object != null) {
UserType userObj = object.asObjectable();
PolyStringType fullName = userObj.getFullName();
if (fullName != null && !StringUtils.isEmpty(fullName.getOrig())) {
objectName = fullName.getOrig() + " (" + objectName + ")";
PolyStringType displayName = userObj.getDisplayName();
if (displayName != null && !StringUtils.isEmpty(displayName.getOrig())) {
objectName = displayName.getOrig() + " (" + objectName + ")";
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void initLayout(Class<F> type){

Label fullNameLabel;
if (UserType.class.equals(type)){
fullNameLabel = new Label(ID_OBJECT_FULLNAME, ((UserType) mergeObject).getFullName());
fullNameLabel = new Label(ID_OBJECT_FULLNAME, ((UserType) mergeObject).getDisplayName());
} else {
fullNameLabel = new Label(ID_OBJECT_FULLNAME, ((AbstractRoleType) mergeObject).getDisplayName());
}
Expand Down
Loading
Loading