i

Please enable JavaScript to view this site.

Documentation 8.6

The model class contains the properties with its getters and setters, while the service class contains the operations to be 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 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 authorizing 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.


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()

Returns a list of licensed products for the user.


getPermissions()

Returns a list with the user permissions.

 


getRoles()

Returns 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

Example of Use

 

The examples use the Deyel user object and each example contains the use of 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 method 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");

 

 

Search

 

There are two types of search: Eager and Lazy.

 

Searches 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("AMail code");

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 searches.

 

 

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 searches.

 

 

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);

 }

}

 

Send us your comments
Share on X Share on Linkedin Send by Email Print