i
Users
The model class contains the properties with its getters and setters, while the service class contains the operations performed with the model.
Model Class Content
A user's model contains:
•Model constructor.
•Getters and setters of its attributes.
Getters to get user attributes
The model class for a case contains a set of getters for the attributes of the case.
Operation |
Description |
Parameters |
---|---|---|
getFirstName() |
Gets the user first name. |
|
getLastName() |
Gets the user last name. |
|
getEmail() |
Gets the user email. |
|
getUserCode() |
Gets the user code. |
|
getAlias() |
Gets the user alias. |
|
getOrganizationalUnit() |
Gets the user organizational unit. |
|
getAuthorizedUserCode() |
Gets the authorizer user code. |
|
getCalendar() |
Gets the user calendar. |
|
getJobs() |
Gets the job positions. |
|
getDelegates() |
Gets the user delegated users. |
|
getDelegatesOf() |
Gets the users where the user is defined as a delegate user. |
|
getActive() |
Gets the user state.
Possible values: 1 - Active 0- Inactive |
|
getExpiration() |
Gets the user expiration date. |
|
getUserDurationDays() |
Gets the number of days the password expires since the user was created.
Possible values: 0 - Never 30 - 30 days 60 - 60 days 90 - 90 days |
|
getLicenses() |
Gets a list of licensed products for the user. |
|
getPermissions() |
Gets a list with the user permissions.
|
|
getRoles() |
Gets a list with the user roles. |
|
getIdentificationType() |
Gets the identification type of the user personal data. |
|
getIdentificationNumber() |
Gets the identification number of the user personal data. |
|
getPhone() |
Gets the user phone number. |
|
getExtensionNumber() |
Gets the user phone extension number. |
|
getNationality() |
Gets the user nationality. |
|
getBirthday() |
Gets the user birthdate. |
|
getCountry() |
Gets the user country. |
|
getState() |
Gets the user state |
|
getCity() |
Gets the user city. |
|
getZipCode() |
Gets the user zip code. |
|
getStreetName() |
Gets the user street name. |
|
getStreetNumber() |
Gets the user street number. |
|
getDepartament() |
Gets the user department code. |
|
getLinkedinAccount() |
Gets the linkedin user code. |
|
getTwitterAccount() |
Gets the twitter user code. |
|
getFacebookAccount() |
Gets the facebook user code. |
|
getYouTubeAccount() |
Gets the youtube user code. |
|
getSkypeAccount() |
Gets the skype user code. |
|
getObservation() |
Gets the user observations. |
Service Class Content
The service allows the following operations to be performed:
Operation |
Description |
Parameters |
---|---|---|
read(user) |
Reads an instance. |
User user: Model object to read |
create(user) |
If the executing user has permission to create users, a user is created. If successful, it returns the user code, otherwise it gives an exception with an error message. |
User user: Model object to create |
update(user) |
If the executing user has permission to modify users, the modification is performed. If successful, it returns the user code, otherwise it gives an exception with an error message. |
User user: Model object to modify |
delete(user) |
If the executing user has permission to delete users, it deletes them. If it is not successful, it throws an exception with an error message. |
User user: Model object to delete |
getUserImage(user) |
Gets the user profile image. |
User user: Model object to read |
getThumbnail(user) |
Gets the thumbnail image of the user profile. |
User user: Model object to read |
verifySecurity(user,function) |
Returns true if the user has the security function specified as a parameter in his permissions, and false if otherwise. |
User user: Model object to read
String function: Code of the specified safety function |
search(searchCriteria) |
Allows to retrieve the user instances that meet the search criteria. |
SearchCriteria searchCriteria: Search criteria |
invite(Mail, Subject, Text, IdApplication, OrganizationalUnit, Licenses, Permissions, Roles) |
Allows inviting users to a specific application of Deyel. If it is not reported, Global application is assumed.
If the invited user has a user account, the permissions from the invitation they did not previously have are added. If the session is open, the user enters the specified application, otherwise, the user is redirected to the login page of that application. If the invited user does not have a user account, one will be created when they accept the invitation, and they will be logged into Deyel from the specified invitation.
If any of the data is not valid, an exception is returned indicating the reason. |
String Mail: email of the user to invite
String Subject: email subject to be sent.
String Text: content of the email to be sent.
String IdApplication: identifier of the application to which the invited user will enter
String OrganizationalUnit: organizational unit code of the invited user
List<User.Licenses> Licenses: License types assigned to the invited user
List<User.Permissions> Permissions: permissions assigned to the invited user
List<User.Roles> Roles: roles assigned to the invited user |
Example of Use
The examples use the Deyel user object and each example contains the "User" model class and the "UserService" service class.
1.Service creation
This service is created only once in the rule and is reused in different operations.
UserService userService = new UserService(getApiClient());
|
2.User reading
In this example, a user with the userCode "AFARIAS" is read, using the read(user) method of the "UserService" service class. The value of the lastName property is obtained with the getter of the "User" model class.
User user = new User(); user.setUserCode("AFARIAS"); user = userService.read(user);
|
3.Create a user
This example creates a user with the userCode property with value "NEW". It is activated with a license for the Deyel product and the End user permission.
UserService userService = new UserService(getApiClient()); User user = new User(); user.setUserCode("NEW"); user.setFirstName("New"); user.setLastName("User"); user.setEmail("newuser@optaris.com"); user.setAlias("newuser@optaris.com"); user.setOrganizationalUnit("0000000003"); user.setActive(1); List<User.Licenses> licensesList = new ArrayList<>(); User.Licenses licenses = new User.Licenses(); licenses.setProduct("DEYEL"); licenses.setLicenseType("EVE"); licensesList.add(licenses); list<User.Permissions> permissionsList = new ArrayList<>(); User.Permissions permissions = new User.Permissions(); permissions.setApplication("DEYEL"); permissions.setPermissionCode("ENDUSER"); permissionsList.add(permissions); user.setLicenses(licensesList); user.setPermissions(permissionsList); userService.create(user);
|
4.User update
In this example, the user identified with userCode "AFARIAS" is updated. It is inactivated and the organizational unit is changed.
User user = new User(); user.setUserCode(“AFARIAS”); user = userService.read(user); user.setOrganizationalUnit("0000000008"); user.setActive(0); userService.update(user);
|
5.User deletion
In this example, the user identified with userCode "AFARIAS" is deleted.
User user = new User(); user.setUserCode(“AFARIAS”); user = userService.read(user); userService.delete(user);
|
6.Get the user profile image
In this example, a user identified with the userCode "AFARIAS" is read and its profile image is obtained through the getUserImage(user) method of the "UserService" service class.
User user = new User(); user.setUserCode("AFARIAS"); userService.getUserImage(user);
|
7.Get the thumbnail image of the user profile.
In this example, a user identified with the userCode "AFARIAS" is read and its thumbnail profile image is obtained through the getThumbnail(user) method of the "UserService" service class.
User user = new User(); user.setUserCode("AFARIAS"); userService.getThumbnail(user);
|
8.Security check
In this example it is verified if a user identified with userCode “AFARIAS' has the “DUU0C001” security function defined. The verifySecurity((user, “DuU0C001”) method of the “UserService” service class is used with a user that has been read using the read(user) method and the specified security function, as parameters.
User user = new User(); user.setUserCode("AFARIAS"); user = userService.read(user); boolean userHasAccess = userService.verifySecurity(user, "DUU0C001");
|
9.Invitation to users
In this example, an invitation is sent to the email “proof@optaris.com”. This invitation contains: a license for two products, two permissions and two roles. The specific application that the user must access is established.
UserService userService = new UserService(getApiClient()); List<User.Licenses> licensesList = new ArrayList<>(); // Define 2 licenses User.Licenses licenses1 = new User.Licenses(); licenses1.setProduct("DEYEL"); licenses1.setLicenseType("NOM"); User.Licenses licenses2 = new User.Licenses(); licenses2.setProduct("CONT"); licenses2.setLicenseType("MIT"); licensesList.add(licenses1); licensesList.add(licenses2); // Define 2 permissions List<User.Permissions> permissionsList = new ArrayList<>(); User.Permissions permissions1 = new User.Permissions(); permissions1.setApplication("DEYEL"); permissions1.setPermissionCode("ENDUSER"); permissions2.setApplication("GLOBAL"); permissions2.setPermissionCode("MODELER"); permissionsList.add(permissions1); permissionsList.add(permissions2); // Define 2 roles List<User.Roles> rolesList = new ArrayList<>(); User.Roles role1 = new User.Roles(); role1.setRole("DEYEL_TESTFUNCTIONS"); role1.setApplication("DEYEL"); User.Roles role2 = new User.Roles(); role2.setRole("ARGLOBAL_TIMCOMMUNICATION"); role2.setApplication("GLOBAL"); rolesList.add(role1); rolesList.add(role2); //Define the application String idApp = "AED9B9C79826C48"; try { userService.invite("test@optaris.com", "Invitation test with app", "test text", idApp, "0000000008", licensesList, permissionsList, rolesList); } catch (Exception e) { log(e.getMessage()); }
|
Search
There are two types of search: Eager and Lazy.
Search on users can be performed by using the SearchCriteria object. Such an object implements the setReadTypeLazy() and setReadTypeEager() methods to indicate the type of search to perform, and the getReadType() method to retrieve the set search type.
It is not necessary to specify the use of Eager search with the setReadTypyEager() method because it is the one used by default.
Lazy search reading by default retrieves the values of the following user properties: UserCode, FirstName, LastName, Active, Type, Alias, Email, OrganizationalUnit, Calendar, the user image reference that is retrieved by the getUserImagelLink() method, and the user thumbnail image reference that is retrieved by the method getThumbnailLink() of the User object.
The searchCriteria object implements the setLazyFields() method where the properties to be obtained are defined. This method is used when the value of a property that is not retrieved by default in the Lazy search is required.
To retrieve the user properties: dsFirstName, dsLastName, cdActive, codeMail, ImgUser, the setLazyFields() method is used, which implements the searchCriteria object.
List xProjection = new java.util.ArrayList(); xProjection.add("dsFirstName"); xProjection.add("dsLastName"); xProjection.add("cdActive"); xProjection.add("codigoAMail"); xProjection.add("imgUser"); xSearchCriteria.setLazyFields(xProjection);
|
Search Examples
1.Eager Search
In this example a list is retrieved with the users that in the dsEmail property contain "gmail" and that in the cdOrgUnit property have the identifier of the "Sales" organizational unit (0000000007). The results are sorted by last name in ascending order. The list is scrolled displaying the first and last names of the users. The same criteria are used as for the form search.
SearchCriteria searchCriteria = new SearchCriteria(); Criteria criteria1 = Criteria.like("dsEmail", "gmail"); Criteria criteria2 = Criteria.eq("cdOrgUnit", "0000000007"); searchCriteria.addCriteria(criteria1); searchCriteria.addCriteria(criteria2); searchCriteria.addOrderAsc("dsLastName"); SearchResult SearchResult = userService.search(searchCriteria); Iterator it = SearchResult.getResult().iterator(); while (it.hasNext()) { User user = (User) it.next(); log(user.getFirstName() + " " + user.getLastName()); }
|
2.Lazy Search
This is an example to get the values of the properties “dsFirstName” and “dsLastName”.
The users retrieved are those that in the cdOrgUnit property have values of the organizational unit identifier other than "Sales" (0000000007) and "Systems" (0000000008). The results are sorted by last name in descending order and the page size is set to 5.
The list is scrolled displaying the first and last names of the users. The same criteria are used as for the form search.
SearchCriteria xSearchCriteria = new SearchCriteria(); xSearchCriteria.setReadTypeLazy(); xSearchCriteria.addCriteria(Criteria.nin("cdOrgUnit", java.util.Arrays.asList("0000000007", "0000000008" ))); xSearchCriteria.setPageSize(5); List xProjection = new java.util.ArrayList(); xProjection.add("dsFirstName"); xProjection.add("dsLastName"); xSearchCriteria.addOrderDesc("dsLastName"); xSearchCriteria.setLazyFields(xProjection); SearchResult xSearchResult= xUserService.search(xSearchCriteria); for (int page = 1; page <= xSearchResult.getPages(); page++) { List<User> lsUser = xSearchResult.goToPage(page).getResult(); for (User xUser : lsUser) { log(xUser.getFirstName() + " " + xUser.getLastName()+ " page = "+page); } }
|