This is an automated email from the git hooks/post-receive script. New commit to branch feature/1_socialauth in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit ea9adfdeef6f6b852daeba235c7bd9452691d2dc Author: Kevin Morin <morin@codelutin.com> Date: Fri Aug 11 17:52:10 2017 +0200 refs #1 ajout des credentials sur le user --- .../persistence/entity/PollenUserTopiaDao.java | 22 +++++++++++++++++++-- .../db/migration/h2/V3_0_0_8__add_credentials.sql | 13 ++++++++++++ .../postgresql/V3_0_0_8__add_credentials.sql | 12 +++++++++++ pollen-persistence/src/main/xmi/pollen.properties | 2 +- pollen-persistence/src/main/xmi/pollen.zargo | Bin 26949 -> 27595 bytes 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java index a71e1cc1..06f84e33 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenUserTopiaDao.java @@ -21,14 +21,16 @@ package org.chorem.pollen.persistence.entity; * #L% */ -import com.google.common.collect.Maps; import org.apache.commons.lang3.StringUtils; import org.chorem.pollen.persistence.DaoUtils; import org.nuiton.util.pagination.PaginationParameter; import org.nuiton.util.pagination.PaginationResult; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Optional; /** * @author Tony Chemit - dev@tchemit.fr @@ -42,7 +44,7 @@ public class PollenUserTopiaDao extends AbstractPollenUserTopiaDao<PollenUser> { public PaginationResult<PollenUser> findAll(PaginationParameter page, String search) { - Map<String, Object> parameters = Maps.newHashMap(); + Map<String, Object> parameters = new HashMap<>(); String hql = "SELECT user FROM " + PollenUser.class.getName() + " as user"; if (StringUtils.isNotBlank(search)) { @@ -68,4 +70,20 @@ public class PollenUserTopiaDao extends AbstractPollenUserTopiaDao<PollenUser> { super.delete(entity); } + + public Optional<PollenUser> tryFindUserWithCredential(String providerId, String userId) { + Objects.requireNonNull(providerId); + Objects.requireNonNull(userId); + + Map<String, Object> parameters = new HashMap<>(); + + String hql = "SELECT user FROM " + PollenUser.class.getName() + " as user " + + "INNER JOIN user." + PollenUser.PROPERTY_USER_CREDENTIAL + " as credentials " + + "WHERE credentials." + UserCredential.PROPERTY_PROVIDER + " = :providerId " + + "AND credentials." + UserCredential.PROPERTY_USER_ID + " = :userId"; + parameters.put("providerId", providerId); + parameters.put("userId", userId); + + return Optional.ofNullable(findUniqueOrNull(hql, parameters)); + } } diff --git a/pollen-persistence/src/main/resources/db/migration/h2/V3_0_0_8__add_credentials.sql b/pollen-persistence/src/main/resources/db/migration/h2/V3_0_0_8__add_credentials.sql new file mode 100644 index 00000000..1825b8ae --- /dev/null +++ b/pollen-persistence/src/main/resources/db/migration/h2/V3_0_0_8__add_credentials.sql @@ -0,0 +1,13 @@ +-- credentials + +CREATE TABLE USERCREDENTIAL ( + TOPIAID VARCHAR(255) NOT NULL PRIMARY KEY, + TOPIAVERSION BIGINT NOT NULL, + TOPIACREATEDATE TIMESTAMP, + PROVIDER VARCHAR(255), + USERID VARCHAR(255), + EMAIL VARCHAR(255), + POLLENUSER VARCHAR(255), + FOREIGN KEY (POLLENUSER) references POLLENUSER(TOPIAID) +); + diff --git a/pollen-persistence/src/main/resources/db/migration/postgresql/V3_0_0_8__add_credentials.sql b/pollen-persistence/src/main/resources/db/migration/postgresql/V3_0_0_8__add_credentials.sql new file mode 100644 index 00000000..2280308e --- /dev/null +++ b/pollen-persistence/src/main/resources/db/migration/postgresql/V3_0_0_8__add_credentials.sql @@ -0,0 +1,12 @@ +-- credentials + +CREATE TABLE USERCREDENTIAL ( + TOPIAID VARCHAR(255) NOT NULL PRIMARY KEY, + TOPIAVERSION BIGINT NOT NULL, + TOPIACREATEDATE TIMESTAMP, + PROVIDER VARCHAR(255), + USERID VARCHAR(255), + EMAIL VARCHAR(255), + POLLENUSER VARCHAR(255), + FOREIGN KEY (POLLENUSER) references POLLENUSER(TOPIAID) +); diff --git a/pollen-persistence/src/main/xmi/pollen.properties b/pollen-persistence/src/main/xmi/pollen.properties index 49cb0e8f..16d95ab4 100644 --- a/pollen-persistence/src/main/xmi/pollen.properties +++ b/pollen-persistence/src/main/xmi/pollen.properties @@ -18,7 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # #L% ###m -model.tagvalue.version=3.0.0.7 +model.tagvalue.version=3.0.0.8 #model.tagValue.notGenerateToString=true #model.tagValue.constantPrefix=PROPERTY_ #model.tagValue.useEnumerationName=true diff --git a/pollen-persistence/src/main/xmi/pollen.zargo b/pollen-persistence/src/main/xmi/pollen.zargo index f967fa89..72886764 100644 Binary files a/pollen-persistence/src/main/xmi/pollen.zargo and b/pollen-persistence/src/main/xmi/pollen.zargo differ -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.