4.9.1. User Preferences

4.9.1.1. Description

The User Preferences feature gives users of applications generated with the MetaFactory tool the ability to set their preferences. Based on the user’s preferences, when a user starts to create a new instance of an object, the attributes and/or references of this object that have specific metadata will be initialized with the values set in the user’s preferences.

4.9.1.2. Examples

  • Hours application: the preferred hour amount and hour task can be set by the user.

  • AMI application: the preferred section dealer and section account manager (amongst others) can be set by the user.

4.9.1.3. Objects

The following objects are involved in modeling the feature: UserPreferences, User, plus all project specific objects that need User Preferences.

4.9.1.4. Metadata

The following metadata are involved in modeling the feature:

Listing 4.43 context for metadata: <attribute>, <reference>
<user.preferences></user.preferences>
Listing 4.44 context for metadata: <package>
<dto>
        <owner>
                <keyword>Owner</keyword>
                <prefix>my</prefix>
                <role>USER</role>
                <url.prefix>owner</url.prefix>
        </owner>
</dto>

4.9.1.5. Patterns

The following patterns are involved in generating the feature:

Library specific patterns:

  • metafactory-internal-library\pattern\package\service-using-jpa-repository.xml

  • metafactory-internal-library\pattern\package\backend\rest\rest-dto.xml

  • metafactory-internal-library\pattern\package\backend\service\service-dto.xml

  • metafactory-jhipster-library\jhipster620_angular800\frontend\webapp\app\account\account_route_ts.xml

  • metafactory-jhipster-library\jhipster620_angular800\frontend\webapp\app\account\index_ts.xml

  • metafactory-jhipster-library\jhipster620_angular800\frontend\webapp\app\account\preferences_route_ts.xml

Note

The service-using-jpa-repository.xml pattern generates the UserPreferencesService class, with method getMyPreferences() (My is the value of dto.owner.prefix)

The UserPreferencesService class uses the following classes:
the User class
the UserRepositoryJPA class
the UserPreferences class
the UserPreferencesRepositoryJPA class

Note

The rest-dto.xml pattern generates the OwnerUserPreferencesDtoRestController class with method getOwnerUserPreferencesEditDto().

Note

The service-dto.xml pattern generates the OwnerUserPreferencesConverterService class, with method getMyOwnerUserPreferencesEditDto().

Project specific patterns:

  • Depends on the project.

4.9.1.6. Snippets

The following snippets are involved in generating the feature:

Library specific snippets:

  • metafactory-angular-library\snippet\file\angular\services\angular-service.ftl

  • metafactory-internal-library\snippet\condition\backend\has_user_preferences.ftl

  • metafactory-internal-library\snippet\backend\rest\dto\get_owner_user_preferences_edit_dto.ftl

  • metafactory-internal-library\snippet\backend\service\jpa2\get_my_preferences.ftl

  • metafactory-internal-library\snippet\java\service\createNew.ftl

  • metafactory-jhipster-library\snippets\jhipster620_angular800\frontend\webapp\app\account\account_route_ts.ftl

  • metafactory-jhipster-library\snippets\jhipster620_angular800\frontend\webapp\app\account\index_ts.ftl

  • metafactory-jhipster-library\snippets\jhipster620_angular800\frontend\webapp\app\account\preferences_route_ts.ftl

  • metafactory-jhipster-library\snippets\jhipster620_angular800\frontend\webapp\app\layouts\navbar\navbar_component_html.ftl

Project specific snippets:

  • [project]-metafactory\src\snippets\[frontend]\owner\edit\edit-component-userpreferences.ftl

  • [project]-metafactory\src\snippets\[frontend]\owner\edit\edit-template-userpreferences.ftl

Note

The edit-template-userpreferences.ftl snippet generates the custom rendering of the user preferences edit screen.