ilgrosso commented on a change in pull request #213: URL: https://github.com/apache/syncope/pull/213#discussion_r485375660
########## File path: client/console/src/main/resources/org/apache/syncope/client/console/panels/GroupDirectoryPanel_fr_CA.properties ########## @@ -16,3 +16,4 @@ # under the License. any.edit=Modifier ${anyTO.type} ${anyTO.name} group.members=${right} membres de ${left.name} +auditHistory.title=${anyTO.type} ${anyTO.fullGroupName != "-" ? anyTO.fullGroupName : anyTO.name} histoire Review comment: Please do a straight commit for this fix, both for `2_1_X` and `master`, no need to include it in this PR. ########## File path: core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java ########## @@ -448,7 +448,7 @@ public NumbersInfo numbers() { numbersInfo.getConfCompleteness().put( NumbersInfo.ConfItem.NOTIFICATION.name(), !notificationDAO.findAll().isEmpty()); numbersInfo.getConfCompleteness().put( - NumbersInfo.ConfItem.PULL_TASK.name(), !taskDAO.findAll(TaskType.PULL).isEmpty()); Review comment: Did you remove the `TaskType` enum completely, right? ########## File path: core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPATaskExec.java ########## @@ -42,6 +43,7 @@ * The referred task. */ @ManyToOne(optional = false) + @JoinColumn(name = "task_id", nullable = false) Review comment: Is this `@JoinColumn` annotation really needed? What if you remove it? ########## File path: core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java ########## @@ -458,11 +441,12 @@ public void delete(final Task task) { } entityManager().remove(task); + publisher.publishEvent(new TaskDeletedEvent(this, task.getKey(), AuthContextUtils.getDomain())); Review comment: Why not doing this only for propagation tasks, as done above, instead? ########## File path: fit/core-reference/pom.xml ########## @@ -443,6 +443,74 @@ under the License. </build> <profiles> + <profile> Review comment: Please revert the changes to this file, they are not needed. ########## File path: core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java ########## @@ -167,11 +141,11 @@ private String getEntityTableName(final TaskType type) { return query.getResultList(); } - private <T extends Task> StringBuilder buildFindAllQueryJPA(final TaskType type) { + private <T extends Task> StringBuilder buildFindAllQueryJPA(final Class<T> reference) { StringBuilder builder = new StringBuilder("SELECT t FROM "). - append(getEntityReference(type).getSimpleName()). + append(getEntityReference(reference).getSimpleName()). append(" t WHERE "); - if (type == TaskType.SCHEDULED) { + if (SchedTask.class.isAssignableFrom(reference)) { Review comment: This is not correct, as `type == TaskType.SCHEDULE` used to match only `SchedTask` while now this is also matching `PushTask`, `PullTask` and so on. ########## File path: core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java ########## @@ -216,84 +190,86 @@ private StringBuilder buildFindAllQuery( final List<Object> queryParameters) { if (resource != null - && type != TaskType.PROPAGATION && type != TaskType.PUSH && type != TaskType.PULL) { + && !PropagationTask.class.isAssignableFrom(reference) + && !PushTask.class.isAssignableFrom(reference) + && !PullTask.class.isAssignableFrom(reference)) { - throw new IllegalArgumentException(type + " is not related to " + ExternalResource.class.getSimpleName()); + throw new IllegalArgumentException(reference.getSimpleName() + " is not related to " + + ExternalResource.class.getSimpleName()); } if ((anyTypeKind != null || entityKey != null) - && type != TaskType.PROPAGATION && type != TaskType.NOTIFICATION) { + && !PropagationTask.class.isAssignableFrom(reference) + && !NotificationTask.class.isAssignableFrom(reference)) { - throw new IllegalArgumentException(type + " is not related to users, groups or any objects"); + throw new IllegalArgumentException(reference.getSimpleName() + + " is not related to users, groups or any objects"); } - if (notification != null && type != TaskType.NOTIFICATION) { - throw new IllegalArgumentException(type + " is not related to notifications"); + if (notification != null && !NotificationTask.class.isAssignableFrom(reference)) { + throw new IllegalArgumentException(reference.getSimpleName() + " is not related to notifications"); } - StringBuilder queryString = new StringBuilder("SELECT ").append(AbstractTask.TABLE).append(".*"); + String tableName = getEntityTableName(reference); + StringBuilder queryString = new StringBuilder("SELECT ").append(tableName).append(".*"); if (orderByTaskExecInfo) { queryString.append(",").append(JPATaskExec.TABLE).append(".startDate AS startDate"). append(",").append(JPATaskExec.TABLE).append(".endDate AS endDate"). append(",").append(JPATaskExec.TABLE).append(".status AS status"). - append(" FROM ").append(AbstractTask.TABLE). + append(" FROM ").append(tableName). append(",").append(JPATaskExec.TABLE).append(",").append("(SELECT "). append(JPATaskExec.TABLE).append(".task_id, "). append("MAX(").append(JPATaskExec.TABLE).append(".startDate) AS startDate"). append(" FROM ").append(JPATaskExec.TABLE). append(" GROUP BY ").append(JPATaskExec.TABLE).append(".task_id) GRP"). append(" WHERE "). - append(AbstractTask.TABLE).append(".id=").append(JPATaskExec.TABLE).append(".task_id"). - append(" AND ").append(AbstractTask.TABLE).append(".id=").append("GRP.task_id"). - append(" AND ").append(JPATaskExec.TABLE).append(".startDate=").append("GRP.startDate"). - append(" AND ").append(AbstractTask.TABLE).append(".DTYPE = ?1"); + append(tableName).append(".id=").append(JPATaskExec.TABLE).append(".task_id"). + append(" AND ").append(tableName).append(".id=").append("GRP.task_id"). + append(" AND ").append(JPATaskExec.TABLE).append(".startDate=").append("GRP.startDate"); } else { - queryString.append(", null AS startDate, null AS endDate, null AS status FROM ").append(AbstractTask.TABLE). - append(" WHERE ").append(AbstractTask.TABLE).append(".DTYPE = ?1"); + queryString. + append(", null AS startDate, null AS endDate, null AS status FROM "). + append(tableName). + append(" WHERE 1=1"); } - queryParameters.add(getEntityTableName(type)); - if (type == TaskType.SCHEDULED) { + queryParameters.add(getEntityTableName(reference)); + if (SchedTask.class.isAssignableFrom(reference)) { Review comment: Same here as above. ########## File path: core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java ########## @@ -436,7 +413,13 @@ public int count( @Transactional(rollbackFor = { Throwable.class }) @Override public <T extends Task> T save(final T task) { - return entityManager().merge(task); + T merged = entityManager().merge(task); + + // propagate the event only for Propagation tasks + if (merged instanceof PropagationTask) { + publisher.publishEvent(new TaskCreatedUpdatedEvent<>(this, merged, AuthContextUtils.getDomain())); Review comment: Maybe `TaskCreatedUpdatedEvent` shall be renamed as `PropagationTaskCreatedUpdatedEvent`? ########## File path: fit/console-reference/pom.xml ########## @@ -276,6 +276,7 @@ under the License. <properties> <skipTests>true</skipTests> + <docker.autoCreateCustomNetworks>true</docker.autoCreateCustomNetworks> Review comment: Please revert the changes to this file, they are not needed. ########## File path: core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/AbstractSchedTask.java ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.core.persistence.jpa.entity.task; + +import java.util.Date; +import javax.persistence.MappedSuperclass; +import javax.persistence.OneToOne; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotNull; +import org.apache.syncope.common.lib.types.ImplementationType; +import org.apache.syncope.core.persistence.api.entity.Implementation; +import org.apache.syncope.core.persistence.api.entity.task.SchedTask; +import org.apache.syncope.core.persistence.jpa.entity.JPAImplementation; + +@MappedSuperclass +public abstract class AbstractSchedTask extends AbstractTask implements SchedTask { Review comment: Since `JPASchedTask` implements `SchedTask`, I think it would be cleaner to remove `implements SchedTask` from here. ########## File path: core/persistence-jpa/src/test/resources/domains/Master.properties ########## @@ -16,6 +16,7 @@ # under the License. Master.driverClassName=org.h2.Driver Master.url=jdbc:h2:mem:syncopedb;DB_CLOSE_DELAY=-1 +#Master.url=jdbc:h2:file:~/syncopedb;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE Review comment: Please revert this change. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org