Skip to content

Commit

Permalink
Feature #12603: optimizing the DomainDriver API in orer to improve pe…
Browse files Browse the repository at this point in the history
…rformances.

Adding new signatures that permit to request about several user data instead of requesting data user by user like it is done today.

The manager of domain driver is now able to fetch domain users from several silverpeas's identifiers.

The LDAP driver has been also improved in order to permits to request several user data in a same time by their ids.

Adding to UserDAO the necessary to fetch several users by their id or domain specific id.

Adding to UserFull and OrganizationController chain the signatures to fetch several user full instances from several user silverpeas's identifiers.
  • Loading branch information
SilverYoCha committed Sep 29, 2021
1 parent e13f1a6 commit e4c118b
Show file tree
Hide file tree
Showing 22 changed files with 615 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toMap;
import static org.silverpeas.core.persistence.jdbc.sql.JdbcSqlExecutorProvider.getJdbcSqlExecutor;

/**
Expand Down Expand Up @@ -703,6 +707,39 @@ public static <I, T> Map<I, List<T>> executeBySplittingOn(final Collection<I> di
return result;
}

/**
* Split executor.
* @param <I> the type of list of discriminant data.
* @param <T> the type of the entity into result.
* @param discriminantData a discriminant list of data.
* @return a stream between given discriminant identifiers and the corresponding data.
* @throws java.sql.SQLException on SQL error.
*/
public static <I, T> Stream<T> streamBySplittingOn(final Collection<I> discriminantData,
final SplitListProcess<I, List<T>> process) throws SQLException {
Stream<T> result = Stream.empty();
for (Collection<I> d : CollectionUtil.split(discriminantData, SPLIT_BATCH)) {
result = Stream.concat(result, process.execute(d).stream());
}
return result;
}

/**
* Split executor giving a result sorted exactly like the discriminantData parameter is sorted.
* @param <I> the type of list of discriminant data.
* @param <T> the type of the entity into result.
* @param discriminantData a discriminant list of data.
* @param idGetter permits to get the id from T entity in order to sort the result.
* @return a stream between given discriminant identifiers and the corresponding data.
* @throws java.sql.SQLException on SQL error.
*/
public static <I, T> Stream<T> streamBySplittingOn(final Collection<I> discriminantData,
final SplitListProcess<I, List<T>> process, Function<T, I> idGetter) throws SQLException {
final Map<I, T> indexedResult = streamBySplittingOn(discriminantData, process)
.collect(toMap(idGetter, r -> r));
return discriminantData.stream().map(indexedResult::get).filter(Objects::nonNull);
}

/**
* Select executor.
* @param <R> the type of the items in the list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public interface SplitExecuteProcess<D, T> {

/**
* Processes on a slice of entire list of discriminant data.
* @param discriminantSlice a slice of discriminant data.
* @param result the result which has to be be filled.
* @param idBatch a slice of discriminant data.
* @param result the result which has to be filled.
* @throws SQLException on SQL errors.
*/
void execute(final Collection<D> discriminantSlice, final Map<D, List<T>> result) throws SQLException;
void execute(final Collection<D> idBatch, final Map<D, List<T>> result) throws SQLException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2000 - 2021 Silverpeas
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* As a special exception to the terms and conditions of version 3.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* Open Source Software ("FLOSS") applications as described in Silverpeas's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* "https://www.silverpeas.org/legal/floss_exception.html"
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.silverpeas.core.persistence.jdbc.sql;

import java.sql.SQLException;
import java.util.Collection;

/**
* Split Processor on discriminant data used for list queries.
* @param <D> the type of list of discriminant data.
* @param <T> the type of the entity into result.
*/
@FunctionalInterface
public interface SplitListProcess<D, T> {

/**
* Processes on a slice of entire list of discriminant data.
* @param idBatch a slice of discriminant data.
* @throws SQLException on SQL errors.
*/
T execute(final Collection<D> idBatch) throws SQLException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ public UserFull getUserFull(final String sUserId) {
return null;
}

@Override
public List<UserFull> getUserFulls(final Collection<String> userIds) {
return null;
}

@Override
public UserDetail getUserDetail(final String sUserId) {
UserDetail user = new UserDetail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.silverpeas.core.admin.user.model.UserFull;
import org.silverpeas.core.util.SettingBundle;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -226,15 +227,35 @@ private ActionConstants() {

void updateUserDetail(UserDetail user) throws AdminException;

/**
* Retrieves common user information from database.
* @param specificId The user id as stored in the database.
* @return The full User object that contain ALL user information.
*/
UserDetail getUser(String specificId) throws AdminException;

/**
* Retrieve user information from database
* @param specificId The user id as stored in the database
* @return The full User object that contain ALL user informations
* Retrieves the common user information from database against the given identifiers.
* @param specificIds The user ids as stored in the database.
* @return a list of common User object.
*/
List<UserDetail> listUsers(Collection<String> specificIds) throws AdminException;

/**
* Retrieves common user information from database with the additional data.
* @param specificId The user id as stored in the database.
* @return The full User object that contain ALL user information.
*/
UserFull getUserFull(String specificId) throws AdminException;

/**
* Retrieves common user information with the additional data from database against the given
* identifiers.
* @param specificIds The user ids as stored in the database.
* @return a list of full User object.
*/
List<UserFull> listUserFulls(Collection<String> specificIds) throws AdminException;

String[] getUserMemberGroupIds(String specificId) throws AdminException;

UserDetail[] getAllUsers() throws AdminException;
Expand Down

0 comments on commit e4c118b

Please sign in to comment.