Skip to content
Snippets Groups Projects
Commit 5821bd2f authored by uhensler's avatar uhensler
Browse files

Revert "00-3304: Expand quality data collections, generators and analysis to sub-organisations"

This reverts commit 782a807a.

The check of sub-organisations is not necessary in these queries
because the user roles contains already all sub-organisation and these
roles organisations are injected in these queries.
parent 7ef19413
No related branches found
No related tags found
No related merge requests found
Showing
with 48 additions and 109 deletions
......@@ -19,7 +19,7 @@
*/
package org.olat.modules.quality;
import java.util.List;
import java.util.Collection;
import org.olat.basesecurity.IdentityRef;
import org.olat.core.id.OrganisationRef;
......@@ -33,7 +33,7 @@ import org.olat.core.id.OrganisationRef;
public class QualityDataCollectionViewSearchParams {
private QualityDataCollectionRef dataCollectionRef;
private List<? extends OrganisationRef> organisationRefs;
private Collection<? extends OrganisationRef> organsationRefs;
private IdentityRef reportAccessIdentity;
public QualityDataCollectionRef getDataCollectionRef() {
......@@ -44,12 +44,12 @@ public class QualityDataCollectionViewSearchParams {
this.dataCollectionRef = dataCollectionRef;
}
public List<? extends OrganisationRef> getOrganisationRefs() {
return organisationRefs;
public Collection<? extends OrganisationRef> getOrgansationRefs() {
return organsationRefs;
}
public void setOrganisationRefs(List<? extends OrganisationRef> organisationRefs) {
this.organisationRefs = organisationRefs;
public void setOrgansationRefs(Collection<? extends OrganisationRef> organsationRefs) {
this.organsationRefs = organsationRefs;
}
public IdentityRef getReportAccessIdentity() {
......
......@@ -19,7 +19,7 @@
*/
package org.olat.modules.quality.analysis;
import java.util.List;
import java.util.Collection;
import org.olat.core.id.OrganisationRef;
......@@ -31,13 +31,13 @@ import org.olat.core.id.OrganisationRef;
*/
public class EvaluationFormViewSearchParams {
private List<? extends OrganisationRef> organisationRefs;
private Collection<? extends OrganisationRef> organisationRefs;
public List<? extends OrganisationRef> getOrganisationRefs() {
public Collection<? extends OrganisationRef> getOrganisationRefs() {
return organisationRefs;
}
public void setOrganisationRefs(List<? extends OrganisationRef> organisationRefs) {
public void setOrganisationRefs(Collection<? extends OrganisationRef> organisationRefs) {
this.organisationRefs = organisationRefs;
}
......
......@@ -20,11 +20,13 @@
package org.olat.modules.quality.analysis.manager;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.TypedQuery;
import org.olat.core.commons.persistence.DB;
import org.olat.core.commons.persistence.QueryBuilder;
import org.olat.core.id.OrganisationRef;
import org.olat.modules.forms.EvaluationFormSessionStatus;
import org.olat.modules.quality.QualityDataCollectionLight;
import org.olat.modules.quality.QualityDataCollectionStatus;
......@@ -81,31 +83,15 @@ public class EvaluationFormDAO {
sb.append("collection.key in (");
sb.append(" select dataCollection.key");
sb.append(" from qualitydatacollectiontoorganisation dcToOrg");
sb.append(" where ");
// load the organisations and all children
for (int i = 0; i < searchParams.getOrganisationRefs().size(); i++) {
if (i == 0) {
sb.append("(");
} else {
sb.append(" or ");
}
sb.append("dcToOrg.organisation.materializedPathKeys like :orgPath").append(i);
if (i == searchParams.getOrganisationRefs().size() - 1) {
sb.append(")");
}
}
sb.append(" where dcToOrg.organisation.key in :organisationKeys");
sb.append(")");
}
}
private void appendParameters(TypedQuery<EvaluationFormView> query, EvaluationFormViewSearchParams searchParams) {
if (searchParams.getOrganisationRefs() != null) {
for (int i = 0; i < searchParams.getOrganisationRefs().size(); i++) {
String parameter = new StringBuilder(12).append("orgPath").append(i).toString();
Long key = searchParams.getOrganisationRefs().get(i).getKey();
String value = new StringBuilder(32).append("%/").append(key).append("/%").toString();
query.setParameter(parameter, value);
}
List<Long> organisationKeys = searchParams.getOrganisationRefs().stream().map(OrganisationRef::getKey).collect(Collectors.toList());
query.setParameter("organisationKeys", organisationKeys);
}
}
......
......@@ -20,7 +20,6 @@
package org.olat.modules.quality.generator;
import java.util.Collection;
import java.util.List;
import org.olat.core.id.OrganisationRef;
......@@ -33,7 +32,7 @@ import org.olat.core.id.OrganisationRef;
public class QualityGeneratorSearchParams {
private Collection<? extends QualityGeneratorRef> generatorRefs;
private List<? extends OrganisationRef> organisationRefs;
private Collection<? extends OrganisationRef> organisationRefs;
private String providerType;
public Collection<? extends QualityGeneratorRef> getGeneratorRefs() {
......@@ -44,11 +43,11 @@ public class QualityGeneratorSearchParams {
this.generatorRefs = generatorRefs;
}
public List<? extends OrganisationRef> getOrganisationRefs() {
public Collection<? extends OrganisationRef> getOrganisationRefs() {
return organisationRefs;
}
public void setOrganisationRefs(List<? extends OrganisationRef> organisationRefs) {
public void setOrganisationRefs(Collection<? extends OrganisationRef> organisationRefs) {
this.organisationRefs = organisationRefs;
}
......
......@@ -27,6 +27,7 @@ import java.util.List;
import javax.persistence.TypedQuery;
import org.olat.core.commons.persistence.DB;
import org.olat.core.id.OrganisationRef;
import org.olat.core.util.StringHelper;
import org.olat.modules.quality.generator.QualityGenerator;
import org.olat.modules.quality.generator.QualityGeneratorRef;
......@@ -139,19 +140,7 @@ public class QualityGeneratorDAO {
sb.append(" and generator.key in (");
sb.append(" select generatorToOrganisation.generator.key");
sb.append(" from qualitygeneratortoorganisation as generatorToOrganisation");
sb.append(" where ");
// load the organisations and all children
for (int i = 0; i < searchParams.getOrganisationRefs().size(); i++) {
if (i == 0) {
sb.append("(");
} else {
sb.append(" or ");
}
sb.append("generatorToOrganisation.organisation.materializedPathKeys like :orgPath").append(i);
if (i == searchParams.getOrganisationRefs().size() - 1) {
sb.append(")");
}
}
sb.append(" where generatorToOrganisation.organisation.key in :organisationKeys");
sb.append(" )");
}
if (StringHelper.containsNonWhitespace(searchParams.getProviderType())) {
......@@ -168,12 +157,8 @@ public class QualityGeneratorDAO {
query.setParameter("generatorKeys", generatorKeys);
}
if (searchParams.getOrganisationRefs() != null && !searchParams.getOrganisationRefs().isEmpty()) {
for (int i = 0; i < searchParams.getOrganisationRefs().size(); i++) {
String parameter = new StringBuilder(12).append("orgPath").append(i).toString();
Long key = searchParams.getOrganisationRefs().get(i).getKey();
String value = new StringBuilder(32).append("%/").append(key).append("/%").toString();
query.setParameter(parameter, value);
}
List<Long> organiationKeys = searchParams.getOrganisationRefs().stream().map(OrganisationRef::getKey).collect(toList());
query.setParameter("organisationKeys", organiationKeys);
}
if (StringHelper.containsNonWhitespace(searchParams.getProviderType())) {
query.setParameter("providerType", searchParams.getProviderType());
......
......@@ -19,6 +19,7 @@
*/
package org.olat.modules.quality.manager;
import static java.util.stream.Collectors.toList;
import static org.olat.modules.quality.QualityDataCollectionStatus.READY;
import static org.olat.modules.quality.QualityDataCollectionStatus.RUNNING;
......@@ -419,26 +420,14 @@ public class QualityDataCollectionDAO {
if (searchParams.getDataCollectionRef() != null && searchParams.getDataCollectionRef().getKey() != null) {
sb.and().append("collection.key = :collectionKey");
}
if (hasEntries(searchParams.getOrganisationRefs()) || searchParams.getReportAccessIdentity() != null) {
if (hasEntries(searchParams.getOrgansationRefs()) || searchParams.getReportAccessIdentity() != null) {
sb.and().append("(");
boolean or = false;
if (hasEntries(searchParams.getOrganisationRefs())) {
if (hasEntries(searchParams.getOrgansationRefs())) {
sb.append("collection.key in (");
sb.append("select collectionToOrganisation.dataCollection.key");
sb.append(" from qualitydatacollectiontoorganisation as collectionToOrganisation");
sb.append(" where ");
// load the organisations and all children
for (int i = 0; i < searchParams.getOrganisationRefs().size(); i++) {
if (i == 0) {
sb.append("(");
} else {
sb.append(" or ");
}
sb.append("collectionToOrganisation.organisation.materializedPathKeys like :orgPath").append(i);
if (i == searchParams.getOrganisationRefs().size() - 1) {
sb.append(")");
}
}
sb.append(" where collectionToOrganisation.organisation.key in :organisationKeys");
sb.append(")");
or = true;
}
......@@ -518,14 +507,10 @@ public class QualityDataCollectionDAO {
if (searchParams.getDataCollectionRef() != null && searchParams.getDataCollectionRef().getKey() != null) {
query.setParameter("collectionKey", searchParams.getDataCollectionRef().getKey());
}
if (hasEntries(searchParams.getOrganisationRefs()) || searchParams.getReportAccessIdentity() != null) {
if (hasEntries(searchParams.getOrganisationRefs())) {
for (int i = 0; i < searchParams.getOrganisationRefs().size(); i++) {
String parameter = new StringBuilder(12).append("orgPath").append(i).toString();
Long key = searchParams.getOrganisationRefs().get(i).getKey();
String value = new StringBuilder(32).append("%/").append(key).append("/%").toString();
query.setParameter(parameter, value);
}
if (hasEntries(searchParams.getOrgansationRefs()) || searchParams.getReportAccessIdentity() != null) {
if (hasEntries(searchParams.getOrgansationRefs())) {
List<Long> organiationKeys = searchParams.getOrgansationRefs().stream().map(OrganisationRef::getKey).collect(toList());
query.setParameter("organisationKeys", organiationKeys);
}
if (searchParams.getReportAccessIdentity() != null) {
query.setParameter("reportAccessIdentityKey", searchParams.getReportAccessIdentity().getKey());
......
......@@ -20,6 +20,7 @@
package org.olat.modules.quality.ui;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
......@@ -51,11 +52,11 @@ public class DataCollectionDataSource implements FlexiTableDataSourceDelegate<Da
@Autowired
private QualityService qualityService;
public DataCollectionDataSource(Translator translator, List<? extends OrganisationRef> organsationRefs,
public DataCollectionDataSource(Translator translator, Collection<? extends OrganisationRef> organsationRefs,
IdentityRef identityRef) {
this.translator = translator;
searchParams = new QualityDataCollectionViewSearchParams();
searchParams.setOrganisationRefs(organsationRefs);
searchParams.setOrgansationRefs(organsationRefs);
searchParams.setReportAccessIdentity(identityRef);
CoreSpringFactory.autowireObject(this);
}
......
......@@ -19,6 +19,7 @@
*/
package org.olat.modules.quality.ui;
import java.util.Collection;
import java.util.List;
import org.olat.basesecurity.OrganisationRoles;
......@@ -119,7 +120,7 @@ public class DataCollectionListController extends FormBasicController implements
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, DataCollectionCols.creationDate));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, DataCollectionCols.generatorTitle));
List<? extends OrganisationRef> organisationRefs = organisationService.getOrganisations(getIdentity(),
Collection<? extends OrganisationRef> organisationRefs = organisationService.getOrganisations(getIdentity(),
ureq.getUserSession().getRoles(), secCallback.getViewDataCollectionRoles());
DataCollectionDataSource dataSource = new DataCollectionDataSource(getTranslator(), organisationRefs, getIdentity());
dataModel = new DataCollectionDataModel(dataSource, columnsModel, getTranslator(), secCallback);
......
......@@ -21,11 +21,11 @@ package org.olat.modules.quality.analysis.manager;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toMap;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
......@@ -233,20 +233,14 @@ public class EvaluationFormDAOTest extends OlatTestCase {
public void shouldFilterByOrganisations() {
RepositoryEntry formEntry = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry otherFormEntry = JunitTestHelper.createAndPersistRepositoryEntry();
Organisation superOrganisation = organisationService.createOrganisation("", "", null, null, null);
Organisation organisation = organisationService.createOrganisation("", "", null, superOrganisation, null);
Organisation subOrganisation = organisationService.createOrganisation("", "", null, organisation, null);
List<Organisation> organisations = singletonList(organisation);
Organisation organisation = organisationService.createOrganisation("", "", null, null, null);
List<Organisation> organisations = Collections.singletonList(organisation);
Organisation otherOrganisation = organisationService.createOrganisation("", "", null, null, null);
List<Organisation> otherOrganisations = singletonList(otherOrganisation);
QualityDataCollection dataCollectionSuper = qualityService.createDataCollection(singletonList(superOrganisation), formEntry);
qualityTestHelper.updateStatus(dataCollectionSuper, QualityDataCollectionStatus.FINISHED);
List<Organisation> otherOrganisations = Collections.singletonList(otherOrganisation);
QualityDataCollection dataCollection1 = qualityService.createDataCollection(organisations, formEntry);
qualityTestHelper.updateStatus(dataCollection1, QualityDataCollectionStatus.FINISHED);
QualityDataCollection dataCollection2 = qualityService.createDataCollection(organisations, formEntry);
qualityTestHelper.updateStatus(dataCollection2, QualityDataCollectionStatus.FINISHED);
QualityDataCollection dataCollectionSub = qualityService.createDataCollection(singletonList(subOrganisation), formEntry);
qualityTestHelper.updateStatus(dataCollectionSub, QualityDataCollectionStatus.FINISHED);
QualityDataCollection dataCollectionOtherOrganisation = qualityService.createDataCollection(otherOrganisations, formEntry);
qualityTestHelper.updateStatus(dataCollectionOtherOrganisation, QualityDataCollectionStatus.FINISHED);
QualityDataCollection dataCollectionOtherForm = qualityService.createDataCollection(otherOrganisations, otherFormEntry);
......@@ -258,7 +252,7 @@ public class EvaluationFormDAOTest extends OlatTestCase {
searchParams.setOrganisationRefs(organisations);
List<EvaluationFormView> forms = sut.load(searchParams);
Long expectedNumberDataCollections = (long) asList(dataCollection1, dataCollection2, dataCollectionSub).size();
Long expectedNumberDataCollections = (long) asList(dataCollection1, dataCollection2).size();
assertThat(forms)
.hasSize(1)
.extracting(EvaluationFormView::getNumberDataCollections)
......
......@@ -178,15 +178,11 @@ public class QualityGeneratorDAOTest extends OlatTestCase {
@Test
public void shouldFilterGeneratorViewByOrganisations() {
Organisation superOrganisation = qualityTestHelper.createOrganisation();
Organisation organisation1 = qualityTestHelper.createOrganisation(superOrganisation);
Organisation subOrganisation = qualityTestHelper.createOrganisation(organisation1);
Organisation organisation1 = qualityTestHelper.createOrganisation();
Organisation organisation2 = qualityTestHelper.createOrganisation();
Organisation otherOrganisation = qualityTestHelper.createOrganisation();
QualityGenerator generatorSuper = qualityTestHelper.createGenerator(singletonList(superOrganisation));
QualityGenerator generator1 = qualityTestHelper.createGenerator(singletonList(organisation1));
QualityGenerator generator2 = qualityTestHelper.createGenerator(Arrays.asList(organisation2, organisation1));
QualityGenerator generatorSub = qualityTestHelper.createGenerator(singletonList(subOrganisation));
QualityGenerator otherGenerator = qualityTestHelper.createGenerator(singletonList(otherOrganisation));
dbInstance.commitAndCloseSession();
......@@ -195,8 +191,8 @@ public class QualityGeneratorDAOTest extends OlatTestCase {
List<QualityGeneratorView> generators = sut.load(searchParams);
assertThat(generators).extracting(QualityGeneratorRef::getKey)
.containsExactlyInAnyOrder(generator1.getKey(), generator2.getKey(), generatorSub.getKey())
.doesNotContain(generatorSuper.getKey(), otherGenerator.getKey());
.containsExactlyInAnyOrder(generator1.getKey(), generator2.getKey())
.doesNotContain(otherGenerator.getKey());
}
......
......@@ -529,24 +529,20 @@ public class QualityDataCollectionDAOTest extends OlatTestCase {
@Test
public void shouldFilterDataCollectionsByOrganisations() {
Organisation superOrganisation = qualityTestHelper.createOrganisation();
Organisation organisation = qualityTestHelper.createOrganisation(superOrganisation);
Organisation subOrganisation = qualityTestHelper.createOrganisation(organisation);
QualityDataCollection dataCollectionSuper = qualityTestHelper.createDataCollection(superOrganisation);
Organisation organisation = qualityTestHelper.createOrganisation();
QualityDataCollection dataCollection1 = qualityTestHelper.createDataCollection(organisation);
QualityDataCollection dataCollection2 = qualityTestHelper.createDataCollection(organisation);
QualityDataCollection dataCollectionSub = qualityTestHelper.createDataCollection(subOrganisation);
QualityDataCollection otherDataCollection = qualityTestHelper.createDataCollection();
dbInstance.commitAndCloseSession();
QualityDataCollectionViewSearchParams searchParams = new QualityDataCollectionViewSearchParams();
searchParams.setOrganisationRefs(Collections.singletonList(organisation));
searchParams.setOrgansationRefs(Collections.singletonList(organisation));
List<QualityDataCollectionView> dataCollections = sut.loadDataCollections(TRANSLATOR, searchParams, 0, -1);
List<Long> loadedKeys = dataCollections.stream().map(QualityDataCollectionView::getKey).collect(toList());
assertThat(loadedKeys)
.containsExactlyInAnyOrder(dataCollection1.getKey(), dataCollection2.getKey(), dataCollectionSub.getKey())
.doesNotContain(otherDataCollection.getKey(), dataCollectionSuper.getKey());
.containsExactlyInAnyOrder(dataCollection1.getKey(), dataCollection2.getKey())
.doesNotContain(otherDataCollection.getKey());
}
@Test
......@@ -621,7 +617,7 @@ public class QualityDataCollectionDAOTest extends OlatTestCase {
QualityDataCollectionViewSearchParams searchParams = new QualityDataCollectionViewSearchParams();
Organisation organisation = qualityTestHelper.createOrganisation();
searchParams.setOrganisationRefs(Collections.singletonList(organisation));
searchParams.setOrgansationRefs(Collections.singletonList(organisation));
searchParams.setReportAccessIdentity(reportViewer);
List<QualityDataCollectionView> dataCollections = sut.loadDataCollections(TRANSLATOR, searchParams, 0, -1);
......
......@@ -234,10 +234,6 @@ public class QualityTestHelper {
return organisationService.createOrganisation(UUID.randomUUID().toString(), UUID.randomUUID().toString(), null, null, null);
}
public Organisation createOrganisation(Organisation parent) {
return organisationService.createOrganisation(UUID.randomUUID().toString(), UUID.randomUUID().toString(), null, parent, null);
}
public Curriculum createCurriculum() {
return createCurriculum(createOrganisation());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment