Skip to content
Snippets Groups Projects
Commit 1dd4e2fb authored by srosse's avatar srosse
Browse files

OO-4251: add organisation to the curriculum list

parent 940dd56a
No related branches found
No related tags found
No related merge requests found
...@@ -93,6 +93,12 @@ public interface OrganisationService { ...@@ -93,6 +93,12 @@ public interface OrganisationService {
*/ */
public List<Organisation> getOrganisations(); public List<Organisation> getOrganisations();
/**
*
* @return true if an other organisation as the default is available
*/
public boolean isMultiOrganisations();
/** /**
* Search the organisations by status. * Search the organisations by status.
* *
......
...@@ -183,6 +183,16 @@ public class OrganisationDAO { ...@@ -183,6 +183,16 @@ public class OrganisationDAO {
.getResultList(); .getResultList();
} }
public long count(OrganisationStatus[] status) {
QueryBuilder sb = new QueryBuilder(256);
sb.append("select count(org.key) from organisation org")
.append(" where org.status ").in(status);
List<Long> count = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Long.class)
.getResultList();
return count == null || count.isEmpty() || count.get(0) == null ? 0 : count.get(0).longValue();
}
public List<OrganisationMember> getMembers(OrganisationRef organisation, SearchMemberParameters params) { public List<OrganisationMember> getMembers(OrganisationRef organisation, SearchMemberParameters params) {
QueryBuilder sb = new QueryBuilder(256); QueryBuilder sb = new QueryBuilder(256);
sb.append("select ident, membership.role, membership.inheritanceModeString from organisation org") sb.append("select ident, membership.role, membership.inheritanceModeString from organisation org")
......
...@@ -292,6 +292,12 @@ public class OrganisationServiceImpl implements OrganisationService, Initializin ...@@ -292,6 +292,12 @@ public class OrganisationServiceImpl implements OrganisationService, Initializin
return organisationDao.find(OrganisationStatus.notDelete()); return organisationDao.find(OrganisationStatus.notDelete());
} }
@Override
public boolean isMultiOrganisations() {
// TODO Auto-generated method stub
return organisationDao.count(OrganisationStatus.notDelete()) > 1;
}
@Override @Override
public List<Organisation> getOrganisations(OrganisationStatus[] status) { public List<Organisation> getOrganisations(OrganisationStatus[] status) {
return organisationDao.find(status); return organisationDao.find(status);
......
...@@ -25,6 +25,8 @@ import java.util.List; ...@@ -25,6 +25,8 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.olat.basesecurity.OrganisationModule;
import org.olat.basesecurity.OrganisationService;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component; import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.form.flexible.FormItem; import org.olat.core.gui.components.form.flexible.FormItem;
...@@ -99,10 +101,15 @@ public class CurriculumListManagerController extends FormBasicController impleme ...@@ -99,10 +101,15 @@ public class CurriculumListManagerController extends FormBasicController impleme
private int counter = 0; private int counter = 0;
private final Roles roles; private final Roles roles;
private final boolean isMultiOrganisations;
private final CurriculumSecurityCallback secCallback; private final CurriculumSecurityCallback secCallback;
@Autowired @Autowired
private CurriculumService curriculumService; private CurriculumService curriculumService;
@Autowired
private OrganisationModule organisationModule;
@Autowired
private OrganisationService organisationService;
public CurriculumListManagerController(UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbarPanel, public CurriculumListManagerController(UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbarPanel,
CurriculumSecurityCallback secCallback) { CurriculumSecurityCallback secCallback) {
...@@ -111,6 +118,7 @@ public class CurriculumListManagerController extends FormBasicController impleme ...@@ -111,6 +118,7 @@ public class CurriculumListManagerController extends FormBasicController impleme
this.secCallback = secCallback; this.secCallback = secCallback;
roles = ureq.getUserSession().getRoles(); roles = ureq.getUserSession().getRoles();
toolbarPanel.addListener(this); toolbarPanel.addListener(this);
isMultiOrganisations = organisationService.isMultiOrganisations();
initForm(ureq); initForm(ureq);
loadModel(null, true); loadModel(null, true);
...@@ -136,6 +144,9 @@ public class CurriculumListManagerController extends FormBasicController impleme ...@@ -136,6 +144,9 @@ public class CurriculumListManagerController extends FormBasicController impleme
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CurriculumCols.displayName, "select")); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CurriculumCols.displayName, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CurriculumCols.identifier, "select")); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CurriculumCols.identifier, "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, CurriculumCols.externalId, "select")); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, CurriculumCols.externalId, "select"));
if(organisationModule.isEnabled()) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(isMultiOrganisations, CurriculumCols.organisation));
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CurriculumCols.numOfElements)); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CurriculumCols.numOfElements));
DefaultFlexiColumnModel editCol = new DefaultFlexiColumnModel("edit.icon", CurriculumCols.edit.ordinal(), "edit", DefaultFlexiColumnModel editCol = new DefaultFlexiColumnModel("edit.icon", CurriculumCols.edit.ordinal(), "edit",
new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("edit"), "edit"), new BooleanCellRenderer(new StaticFlexiCellRenderer(translate("edit"), "edit"),
......
...@@ -93,6 +93,7 @@ implements SortableFlexiTableDataModel<CurriculumRow>, FilterableFlexiTableModel ...@@ -93,6 +93,7 @@ implements SortableFlexiTableDataModel<CurriculumRow>, FilterableFlexiTableModel
case displayName: return row.getDisplayName(); case displayName: return row.getDisplayName();
case identifier: return row.getIdentifier(); case identifier: return row.getIdentifier();
case externalId: return row.getExternalId(); case externalId: return row.getExternalId();
case organisation: return row.getOrganisation();
case numOfElements: return row.getNumOfElements(); case numOfElements: return row.getNumOfElements();
case edit: return row.canManage(); case edit: return row.canManage();
case tools: return row.getTools(); case tools: return row.getTools();
...@@ -119,7 +120,8 @@ implements SortableFlexiTableDataModel<CurriculumRow>, FilterableFlexiTableModel ...@@ -119,7 +120,8 @@ implements SortableFlexiTableDataModel<CurriculumRow>, FilterableFlexiTableModel
externalId("table.header.external.id"), externalId("table.header.external.id"),
numOfElements("table.header.num.elements"), numOfElements("table.header.num.elements"),
edit("edit.icon"), edit("edit.icon"),
tools("table.header.tools"); tools("table.header.tools"),
organisation("table.header.organisation");
private final String i18nHeaderKey; private final String i18nHeaderKey;
......
...@@ -80,6 +80,13 @@ public class CurriculumRow implements CurriculumRef { ...@@ -80,6 +80,13 @@ public class CurriculumRow implements CurriculumRef {
return curriculum.getExternalId(); return curriculum.getExternalId();
} }
public String getOrganisation() {
if(curriculum.getOrganisation() != null) {
return curriculum.getOrganisation().getDisplayName();
}
return null;
}
public long getNumOfElements() { public long getNumOfElements() {
return numOfElements; return numOfElements;
} }
......
...@@ -120,6 +120,7 @@ table.header.num.of.members=Mitglieder ...@@ -120,6 +120,7 @@ table.header.num.of.members=Mitglieder
table.header.num.of.participants=Teilnehmer table.header.num.of.participants=Teilnehmer
table.header.num.of.coaches=Betreuer table.header.num.of.coaches=Betreuer
table.header.num.of.owners=Besitzer table.header.num.of.owners=Besitzer
table.header.organisation=Organisation
table.header.repository.entry.displayName=Titel der Lernressource table.header.repository.entry.displayName=Titel der Lernressource
table.header.repository.entry.externalRef=Identifier table.header.repository.entry.externalRef=Identifier
table.header.resources=Ref. table.header.resources=Ref.
......
...@@ -120,6 +120,7 @@ table.header.num.of.coaches=Coaches ...@@ -120,6 +120,7 @@ table.header.num.of.coaches=Coaches
table.header.num.of.members=Members table.header.num.of.members=Members
table.header.num.of.owners=Owners table.header.num.of.owners=Owners
table.header.num.of.participants=Participants table.header.num.of.participants=Participants
table.header.organisation=Organisation
table.header.repository.entry.displayName=Title of learning resource table.header.repository.entry.displayName=Title of learning resource
table.header.repository.entry.externalRef=Reference table.header.repository.entry.externalRef=Reference
table.header.resources=Ref. table.header.resources=Ref.
......
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