Skip to content

Commit

Permalink
feat: Add index in analytics setting attribute in profile property se…
Browse files Browse the repository at this point in the history
…ttings - MEED-8002 - Meeds-io/MIPs#171

Add index in analytics setting attribute in profile property settings
  • Loading branch information
hakermi committed Jan 24, 2025
1 parent 757ccc9 commit 6f72ace
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,10 @@ public interface ProfilePropertyService {
*/
List<Long> getHiddenProfilePropertyIds(long userIdentityId);

/**
* Gets excluded analytics index properties
*
* @return {@link List} of {@link String}
*/
List<String> getExcludedAnalyticsIndexProperties();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class ProfilePropertySetting {

private boolean isHiddenbale;

private boolean indexInAnalytics;

private boolean isRequired;

private boolean isMultiValued;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public class ProfilePropertySettingEntity implements Serializable {
@Column(name = "IS_DROPDOWN")
private boolean isDropdownList;

@Column(name = "INDEX_IN_ANALYTICS")
private boolean indexInAnalytics;

@Column(name = "PROPERTY_TYPE")
private String propertyType;

Expand All @@ -107,6 +110,7 @@ public String toString() {
builder.append(":").append(isRequired());
builder.append(":").append(isGroupSynchronized());
builder.append(":").append(isHiddenable());
builder.append(":").append(isIndexInAnalytics());
builder.append(":").append(getPropertyType());
builder.append(":").append(getParentId());
return builder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ public class ProfileProperty {

private boolean hiddenable;

private boolean indexInAnalytics;

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected void createProperties(ProfilePropertyService profilePropertyService) {
profilePropertySetting.setEditable(data.isEditable());
profilePropertySetting.setOrder(Long.valueOf(data.getOrder()));
profilePropertySetting.setDropdownList(data.isDropdownList());
profilePropertySetting.setIndexInAnalytics(data.isIndexInAnalytics());
profilePropertySetting.setVisible(data.isVisible());
profilePropertySetting.setGroupSynchronized(data.isGroupSynchronized());
profilePropertySetting.setRequired(data.isRequired());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ public class ProfilePropertyServiceImpl implements ProfilePropertyService, Start

private static final String EXCLUDED_QUICK_SEARCH_PROPERTIES_PARAM = "excludedQuickSearchProperties";

private static final String EXCLUDED_ANALYTICS_INDEX_PROPERTIES = "excludedAnalyticsIndexProperties";

protected List<ProfilePropertyDatabaseInitializer> profielPropertyPlugins = new ArrayList<>();

private List<String> synchronizedGroupDisabledProperties = new ArrayList<>();

private static List<String> nonHiddenableProps = new ArrayList<>();

private static List<String> excludedQuickSearchProps = new ArrayList<>();

private static List<String> excludedAnalyticsIndexProps = new ArrayList<>();

private static final Scope HIDDEN_PROFILE_PROPERTY_SETTINGS_SCOPE =
Scope.APPLICATION.id("ProfilePropertySettings");
Expand Down Expand Up @@ -106,6 +110,9 @@ public ProfilePropertyServiceImpl(InitParams params,
excludedQuickSearchProps = Arrays.asList(params.getValueParam(EXCLUDED_QUICK_SEARCH_PROPERTIES_PARAM)
.getValue()
.split(","));
excludedAnalyticsIndexProps = Arrays.asList(params.getValueParam(EXCLUDED_ANALYTICS_INDEX_PROPERTIES)
.getValue()
.split(","));
} catch (Exception e) {
LOG.warn("List of disabled properties for synchronization not provided, all properties can be synchronized! ");
}
Expand All @@ -127,6 +134,11 @@ public ProfilePropertySetting getProfileSettingByName(String name) {
return profileSettingStorage.findProfileSettingByName(name);
}

@Override
public List<String> getExcludedAnalyticsIndexProperties() {
return excludedAnalyticsIndexProps;
}

@Override
public ProfilePropertySetting getProfileSettingById(Long id) {
return profileSettingStorage.getProfileSettingById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private ProfilePropertySettingEntity convertToEntity(ProfilePropertySetting prof
profilePropertySettingEntity.setOrder(profilePropertySetting.getOrder());
profilePropertySettingEntity.setMultiValued(profilePropertySetting.isMultiValued());
profilePropertySettingEntity.setHiddenable(profilePropertySetting.isHiddenbale());
profilePropertySettingEntity.setIndexInAnalytics(profilePropertySetting.isIndexInAnalytics());
profilePropertySettingEntity.setPropertyType(profilePropertySetting.getPropertyType());
profilePropertySettingEntity.setPropertyOptions(toPropertyOptionEntities(profilePropertySettingEntity, profilePropertySetting.getPropertyOptions()));
profilePropertySettingEntity.setUpdatedDate(new Date(profilePropertySetting.getUpdated()));
Expand All @@ -123,6 +124,7 @@ private ProfilePropertySetting convertFromEntity(ProfilePropertySettingEntity pr
profilePropertySetting.setOrder(profilePropertySettingEntity.getOrder());
profilePropertySetting.setMultiValued(profilePropertySettingEntity.isMultiValued());
profilePropertySetting.setHiddenbale(profilePropertySettingEntity.isHiddenable());
profilePropertySetting.setIndexInAnalytics(profilePropertySettingEntity.isIndexInAnalytics());
profilePropertySetting.setPropertyType(profilePropertySettingEntity.getPropertyType());
profilePropertySetting.setPropertyOptions(toPropertyOptions(profilePropertySettingEntity.getPropertyOptions()));
profilePropertySetting.setUpdated(profilePropertySettingEntity.getUpdatedDate().getTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,4 +1191,10 @@
<append value=" ENGINE=INNODB CHARSET=UTF8 COLLATE utf8_general_ci" />
</modifySql>
</changeSet>

<changeSet author="social" id="1.0.0-mip-171-04">
<addColumn tableName="SOC_PROFILE_PROPERTY_SETTING">
<column name="INDEX_IN_ANALYTICS" type="BOOLEAN" defaultValue="false"/>
</addColumn>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void testOnEvent() {
false,
true,
false,
false,
new ArrayList<>(),
System.currentTimeMillis());
Event<ProfilePropertyService, ProfilePropertySetting> event = new Event<>("profile-property-setting-updated", profilePropertyService, profilePropertySetting);
Expand Down Expand Up @@ -96,6 +97,7 @@ public void testOnEvent() {
false,
true,
false,
false,
new ArrayList<>(),
System.currentTimeMillis());
event = new Event<>("profile-property-setting-updated", profilePropertyService, profilePropertySetting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ public void testDropdownListPropertySetting() throws ObjectAlreadyExistsExceptio
assertThrows(IllegalArgumentException.class, () -> profilePropertyService.updatePropertySetting(propertySetting));
}

public void testIndexedInAnalyticsPropertySetting() throws ObjectAlreadyExistsException {
ProfilePropertySetting indexedInAnalyticsPropertySetting = createProfileSettingInstance("propIndexedInAnalytics");
indexedInAnalyticsPropertySetting.setIndexInAnalytics(true);
ProfilePropertySetting propertySetting = profilePropertyService.createPropertySetting(indexedInAnalyticsPropertySetting);
assertTrue(propertySetting.isIndexInAnalytics());
}

public void testSavePropertySettingWithOptions() throws ObjectAlreadyExistsException {
ProfilePropertySetting dropdownListPropertySetting = createProfileSettingInstanceWithOptions("propDropdown", 3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ public static ProfilePropertySettingEntity buildEntityProfilePropertySetting(Pro
profilePropertySettingEntity.setMultiValued(profilePropertySetting.isMultiValued());
profilePropertySettingEntity.setGroupSynchronizationEnabled(profilePropertyService.isGroupSynchronizedEnabledProperty(profilePropertySetting));
profilePropertySettingEntity.setHiddenable(profilePropertyService.isPropertySettingHiddenable(profilePropertySetting));
profilePropertySettingEntity.setIndexInAnalytics(profilePropertySetting.isIndexInAnalytics());
profilePropertySettingEntity.setPropertyType(profilePropertySetting.getPropertyType());
profilePropertySettingEntity.setLabels(profileLabelService.findLabelByObjectTypeAndObjectId(objectType,
String.valueOf(profilePropertySetting.getId())));
Expand Down Expand Up @@ -2116,6 +2117,7 @@ public static ProfilePropertySetting buildProfilePropertySettingFromEntity(Profi
profilePropertySetting.setOrder(profilePropertySettingEntity.getOrder());
profilePropertySetting.setMultiValued(profilePropertySettingEntity.isMultiValued());
profilePropertySetting.setHiddenbale(profilePropertySettingEntity.isHiddenable());
profilePropertySetting.setIndexInAnalytics(profilePropertySettingEntity.isIndexInAnalytics());
profilePropertySetting.setPropertyType(profilePropertySettingEntity.getPropertyType());
profilePropertySetting.setPropertyOptions(toProfilePropertyOptions(profilePropertySettingEntity.getPropertyOptions()));
profilePropertySetting.setUpdated(profilePropertySettingEntity.getUpdated());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Response getLabel(@Context
@PathParam("id")
String id,
@Parameter(description = "language", required = true)
@PathParam("id")
@PathParam("language")
String language) {
try {
ProfileLabel profileLabel = profileLabelService.findLabelByObjectTypeAndObjectIdAndLang(type, id, language);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public Response getPropertySettings(@Context
properties = properties.stream().filter(prop -> prop.isVisible() || prop.isEditable()).toList();
}
List<String> unHiddenbaleProperties = profilePropertyService.getUnhiddenableProfileProperties();
List<String> excludedAnalyticsIndexProperties = profilePropertyService.getExcludedAnalyticsIndexProperties();
List<String> excludedQuickSearchProperties = profilePropertyService.getExcludedQuickSearchProperties();
List<ProfilePropertySettingEntity> propertySettingEntities =
EntityBuilder.buildEntityProfilePropertySettingList(properties,
Expand All @@ -102,6 +103,8 @@ public Response getPropertySettings(@Context
settings.put("settings", propertySettingEntities);
settings.put("unHiddenableProperties", unHiddenbaleProperties);
settings.put("excludedQuickSearchProperties", excludedQuickSearchProperties);
settings.put("excludedAnalyticsIndexProperties", excludedAnalyticsIndexProperties);

return Response.ok(settings).build();
}catch (Exception e) {
LOG.error("An error occurred while getting list of settings", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class ProfilePropertySettingEntity {

private boolean isHiddenable;

private boolean indexInAnalytics;

private List<ProfileLabel> labels;

private List<ProfilePropertySettingEntity> children;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,9 @@ profileSettings.dialog.deleteOption.title=Delete value
profileSettings.dialog.deleteOption.message=You are deleting the value {0}. It will remove the value on the user profiles. Are you sure you want to delete this value?
profileSettings.dialog.deleteOption.ok=Delete
profileSettings.dialog.deleteOption.cancel=Cancel
profileSettings.label.index.in.analytics=Indexed in the analytics
profileSettings.label.index.in.analytics.info=The attribute will be added to any operation done by the user
profileSettings.label.excluded.index.in.analytics.info=This attribute cannot be indexed in the analytics
#####################################################################################
# Translation Drawer #
#####################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,9 @@ profileSettings.dialog.deleteOption.title=Supprimer la valeur
profileSettings.dialog.deleteOption.message=Vous \u00EAtes en train de supprimer la valeur {0}. Elle sera supprim\u00E9 des profiles des utilisateurs. \u00EAtes-vous s\u00FBr de vouloir supprimer cette valeur ?
profileSettings.dialog.deleteOption.ok=Supprimer
profileSettings.dialog.deleteOption.cancel=Annuler
profileSettings.label.index.in.analytics=Index\u00E9 dans les Analytiques
profileSettings.label.index.in.analytics.info=L'attribut sera ajout\u00E9 \u00E0 chaque op\u00E9ration r\u00E9alis\u00E9e par l'utilisateur
profileSettings.label.excluded.index.in.analytics.info=Cet attribut ne peut pas \u00EAtre index\u00E9 dans les Analytiques
#####################################################################################
# Translation Drawer #
#####################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@
<name>excludedQuickSearchProperties</name>
<value>${social.profile.excluded.quickSearch.properties:fullName,firstName,lastName,email,phones,ims,urls,acceptedTermsAndConditions,github,passwordSalt128,user.other-info.external}</value>
</value-param>
<value-param>
<name>excludedAnalyticsIndexProperties</name>
<value>${social.profile.excludedAnalyticsIndex.properties:fullName,firstName,lastName,email}</value>
</value-param>
</init-params>
</component>

Expand Down
Loading

0 comments on commit 6f72ace

Please sign in to comment.