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

OO-534: implements list, implements owner/author per item

parent b30f01c9
No related branches found
No related tags found
No related merge requests found
Showing
with 975 additions and 39 deletions
......@@ -38,7 +38,15 @@ public interface QuestionPoolService {
public void deleteItems(List<QuestionItem> items);
public void addAuthors(List<Identity> authors, List<QuestionItem> items);
public int countItems(Identity author);
public List<QuestionItem> getItems(Identity author, int firstResult, int maxResults, SortKey... orderBy);
//pools
public List<Pool> getPools(Identity identity);
public int getNumOfItemsInPool(Pool pool);
......@@ -48,13 +56,14 @@ public interface QuestionPoolService {
public void addItemToPool(QuestionItem item, Pool pool);
//favorit
public int getNumOfFavoritItems(Identity identity);
public List<QuestionItem> getFavoritItems(Identity identity, int firstResult, int maxResults);
public List<QuestionItem> getFavoritItems(Identity identity, int firstResult, int maxResults, SortKey... orderBy);
public List<QuestionItem> getItems(Identity identity, int firstResult, int maxResults);
//share
public void shareItems(List<QuestionItem> items, List<BusinessGroup> groups);
public List<BusinessGroup> getResourcesWithSharedItems(Identity identity);
......@@ -63,5 +72,16 @@ public interface QuestionPoolService {
public List<QuestionItem> getSharedItemByResource(OLATResource resource, int firstResult, int maxResults, SortKey... orderBy);
//list
public QuestionItemCollection createCollection(Identity owner, String collectionName, List<QuestionItem> initialItems);
public void addItemToCollection(QuestionItem item, QuestionItemCollection collection);
public List<QuestionItemCollection> getCollections(Identity owner);
public int countItemsOfCollection(QuestionItemCollection collection);
public List<QuestionItem> getItemsOfCollection(QuestionItemCollection collection, int firstResult, int maxResults, SortKey... orderBy);
}
......@@ -72,7 +72,7 @@ public class CollectionDAO {
return items.get(0);
}
public void addItemToCollection(QuestionItemCollection collection, QuestionItem item) {
public void addItemToCollection(QuestionItem item, QuestionItemCollection collection) {
QuestionItem lockedItem = questionItemDao.loadForUpdate(item.getKey());
if(!isInCollection(collection, lockedItem)) {
CollectionToItem coll2Item = new CollectionToItem();
......@@ -95,6 +95,16 @@ public class CollectionDAO {
return count.intValue() > 0;
}
public int countItemsOfCollection(QuestionItemCollection collection) {
StringBuilder sb = new StringBuilder();
sb.append("select count(coll2item) from qcollection2item coll2item where coll2item.collection.key=:collectionKey");
return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Number.class)
.setParameter("collectionKey", collection.getKey())
.getSingleResult().intValue();
}
public List<QuestionItem> getItemsOfCollection(QuestionItemCollection collection, int firstResult, int maxResults, SortKey... orderBy) {
StringBuilder sb = new StringBuilder();
sb.append("select coll2item.item from qcollection2item coll2item where coll2item.collection.key=:collectionKey");
......@@ -104,11 +114,21 @@ public class CollectionDAO {
.createQuery(sb.toString(), QuestionItem.class)
.setParameter("collectionKey", collection.getKey());
if(firstResult >= 0) {
query.setFirstResult(0);
query.setFirstResult(firstResult);
}
if(maxResults > 0) {
query.setMaxResults(maxResults);
}
return query.getResultList();
}
public List<QuestionItemCollection> getCollections(Identity me) {
StringBuilder sb = new StringBuilder();
sb.append("select coll from qcollection coll where coll.owner.key=:identityKey");
return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), QuestionItemCollection.class)
.setParameter("identityKey", me.getKey())
.getResultList();
}
}
......@@ -94,7 +94,7 @@ public class NullPoolService implements ApplicationListener<ContextRefreshedEven
for(int i=0; i<200; i++) {
long randomIndex = Math.round(Math.random() * (fields.size() - 1));
StudyField field = fields.get((int)randomIndex);
QuestionItem item = questionItemDao.create("NGC " + i, QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), field, randomType());
QuestionItem item = questionItemDao.create(null, "NGC " + i, QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), field, randomType());
poolDao.addItemToPool(item, pools.get(0));
}
}
......
......@@ -131,7 +131,7 @@ public class PoolDAO {
.createQuery(sb.toString(), QuestionItem.class)
.setParameter("poolKey", pool.getKey());
if(firstResult >= 0) {
query.setFirstResult(0);
query.setFirstResult(firstResult);
}
if(maxResults > 0) {
query.setMaxResults(maxResults);
......
......@@ -27,6 +27,8 @@ import javax.persistence.EntityManager;
import javax.persistence.LockModeType;
import javax.persistence.TypedQuery;
import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.SecurityGroup;
import org.olat.basesecurity.SecurityGroupMembershipImpl;
import org.olat.core.commons.persistence.DB;
import org.olat.core.commons.persistence.SortKey;
......@@ -54,8 +56,11 @@ public class QuestionItemDAO {
@Autowired
private DB dbInstance;
@Autowired
private BaseSecurity securityManager;
public QuestionItem create(String subject, String format, String language, StudyField field, QuestionType type) {
public QuestionItem create(Identity owner, String subject, String format, String language,
StudyField field, QuestionType type) {
QuestionItemImpl item = new QuestionItemImpl();
item.setCreationDate(new Date());
item.setLastModified(new Date());
......@@ -66,10 +71,61 @@ public class QuestionItemDAO {
item.setFormat(format);
item.setLanguage(language);
item.setStudyField(field);
SecurityGroup authorGroup = securityManager.createAndPersistSecurityGroup();
item.setAuthorGroup(authorGroup);
dbInstance.getCurrentEntityManager().persist(item);
if(owner != null) {
securityManager.addIdentityToSecurityGroup(owner, authorGroup);
}
return item;
}
public void addAuthors(List<Identity> authors, QuestionItem item) {
QuestionItemImpl lockedItem = loadForUpdate(item.getKey());
SecurityGroup secGroup = lockedItem.getAuthorGroup();
for(Identity author:authors) {
if(!securityManager.isIdentityInSecurityGroup(author, secGroup)) {
securityManager.addIdentityToSecurityGroup(author, secGroup);
}
}
dbInstance.commit();
}
public int countItems(Identity me) {
StringBuilder sb = new StringBuilder();
sb.append("select count(item) from questionitem item")
.append(" inner join item.authorGroup authorGroup ")
.append(" where authorGroup in (")
.append(" select vmember.securityGroup from ").append(SecurityGroupMembershipImpl.class.getName()).append(" as vmember ")
.append(" where vmember.identity.key=:identityKey and vmember.securityGroup=authorGroup")
.append(" )");
return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Number.class)
.setParameter("identityKey", me.getKey())
.getSingleResult().intValue();
}
public List<QuestionItem> getItems(Identity me, int firstResult, int maxResults, SortKey... orderBy) {
StringBuilder sb = new StringBuilder();
sb.append("select item from questionitem item")
.append(" inner join item.authorGroup authorGroup ")
.append(" where authorGroup in (")
.append(" select vmember.securityGroup from ").append(SecurityGroupMembershipImpl.class.getName()).append(" as vmember ")
.append(" where vmember.identity.key=:identityKey and vmember.securityGroup=authorGroup")
.append(" )");
TypedQuery<QuestionItem> query = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), QuestionItem.class)
.setParameter("identityKey", me.getKey());
if(firstResult >= 0) {
query.setFirstResult(firstResult);
}
if(maxResults > 0) {
query.setMaxResults(maxResults);
}
return query.getResultList();
}
public void delete(List<QuestionItem> items) {
EntityManager em = dbInstance.getCurrentEntityManager();
for(QuestionItem item:items) {
......@@ -92,11 +148,11 @@ public class QuestionItemDAO {
return items.get(0);
}
public QuestionItem loadForUpdate(Long key) {
public QuestionItemImpl loadForUpdate(Long key) {
StringBuilder sb = new StringBuilder();
sb.append("select item from questionitem item where item.key=:key");
QuestionItem item = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), QuestionItem.class)
QuestionItemImpl item = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), QuestionItemImpl.class)
.setParameter("key", key)
.setLockMode(LockModeType.PESSIMISTIC_WRITE)
.getSingleResult();
......
......@@ -28,6 +28,7 @@ import org.olat.core.id.Identity;
import org.olat.group.BusinessGroup;
import org.olat.modules.qpool.Pool;
import org.olat.modules.qpool.QuestionItem;
import org.olat.modules.qpool.QuestionItemCollection;
import org.olat.modules.qpool.QuestionPoolService;
import org.olat.modules.qpool.model.QuestionItemImpl;
import org.olat.resource.OLATResource;
......@@ -48,6 +49,8 @@ public class QuestionPoolServiceImpl implements QuestionPoolService {
@Autowired
private PoolDAO poolDao;
@Autowired
private CollectionDAO collectionDao;
@Autowired
private StudyFieldDAO studyFieldDao;
@Autowired
private QuestionItemDAO questionItemDao;
......@@ -70,6 +73,27 @@ public class QuestionPoolServiceImpl implements QuestionPoolService {
questionItemDao.delete(items);
}
@Override
public void addAuthors(List<Identity> authors, List<QuestionItem> items) {
if(authors == null || authors.isEmpty() || items == null || items.isEmpty()) {
return;//nothing to do
}
for(QuestionItem item:items) {
questionItemDao.addAuthors(authors, item);
}
}
@Override
public int countItems(Identity author) {
return questionItemDao.countItems(author);
}
@Override
public List<QuestionItem> getItems(Identity author, int firstResult, int maxResults, SortKey... orderBy) {
return questionItemDao.getItems(author, firstResult, maxResults, orderBy);
}
@Override
public List<Pool> getPools(Identity identity) {
return poolDao.getPools();
......@@ -96,7 +120,7 @@ public class QuestionPoolServiceImpl implements QuestionPoolService {
}
@Override
public List<QuestionItem> getFavoritItems(Identity identity, int firstResult, int maxResults) {
public List<QuestionItem> getFavoritItems(Identity identity, int firstResult, int maxResults, SortKey... orderBy) {
return questionItemDao.getFavoritItems(identity, firstResult, maxResults);
}
......@@ -133,7 +157,32 @@ public class QuestionPoolServiceImpl implements QuestionPoolService {
}
@Override
public List<QuestionItem> getItems(Identity identity, int firstResult, int maxResults) {
return new ArrayList<QuestionItem>();
public QuestionItemCollection createCollection(Identity owner, String collectionName, List<QuestionItem> initialItems) {
QuestionItemCollection coll = collectionDao.createCollection(collectionName, owner);
for(QuestionItem item:initialItems) {
collectionDao.addItemToCollection(item, coll);
}
return coll;
}
@Override
public void addItemToCollection(QuestionItem item, QuestionItemCollection coll) {
collectionDao.addItemToCollection(item, coll);
}
@Override
public List<QuestionItemCollection> getCollections(Identity owner) {
return collectionDao.getCollections(owner);
}
@Override
public int countItemsOfCollection(QuestionItemCollection collection) {
return collectionDao.countItemsOfCollection(collection);
}
@Override
public List<QuestionItem> getItemsOfCollection(QuestionItemCollection collection, int firstResult,
int maxResults, SortKey... orderBy) {
return collectionDao.getItemsOfCollection(collection, firstResult, maxResults, orderBy);
}
}
......@@ -24,6 +24,7 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
......@@ -36,6 +37,8 @@ import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.hibernate.annotations.GenericGenerator;
import org.olat.basesecurity.SecurityGroup;
import org.olat.basesecurity.SecurityGroupImpl;
import org.olat.core.id.CreateInfo;
import org.olat.core.id.ModifiedInfo;
import org.olat.core.id.Persistable;
......@@ -85,6 +88,9 @@ public class QuestionItemImpl implements QuestionItem, CreateInfo, ModifiedInfo,
//rights
@Column(name="q_copyright", nullable=true, insertable=true, updatable=true)
private String copyright;
@ManyToOne(targetEntity=SecurityGroupImpl.class,fetch=FetchType.LAZY,optional=false)
@JoinColumn(name="fk_author_grp_id", nullable=false, insertable=true, updatable=false)
private SecurityGroup authorGroup;
//usage
@Column(name="q_point", nullable=true, insertable=true, updatable=true)
......@@ -266,6 +272,14 @@ public class QuestionItemImpl implements QuestionItem, CreateInfo, ModifiedInfo,
this.copyright = copyright;
}
public SecurityGroup getAuthorGroup() {
return authorGroup;
}
public void setAuthorGroup(SecurityGroup authorGroup) {
this.authorGroup = authorGroup;
}
public BigDecimal getDifficulty() {
return difficulty;
}
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.qpool.ui;
import java.util.List;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.persistence.SortKey;
import org.olat.modules.qpool.QuestionItem;
import org.olat.modules.qpool.QuestionItemCollection;
import org.olat.modules.qpool.QuestionPoolService;
/**
*
* Initial date: 25.02.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CollectionOfItemsSource implements QuestionItemsSource {
private final QuestionPoolService qpoolService;
private final QuestionItemCollection collection;
public CollectionOfItemsSource(QuestionItemCollection collection) {
this.collection = collection;
qpoolService = CoreSpringFactory.getImpl(QuestionPoolService.class);
}
@Override
public int getNumOfItems() {
return qpoolService.countItemsOfCollection(collection);
}
@Override
public List<QuestionItem> getItems(int firstResult, int maxResults, SortKey... orderBy) {
return qpoolService.getItemsOfCollection(collection, firstResult, maxResults);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.qpool.ui;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.util.StringHelper;
/**
*
* Initial date: 25.02.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CreateCollectionController extends FormBasicController {
private Object userObject;
private TextElement nameEl;
public CreateCollectionController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl);
initForm(ureq);
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("create.collection.description");
nameEl = uifactory.addTextElement("collection.name", "collection.name", 128, "", formLayout);
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
uifactory.addFormSubmitButton("ok", "ok", buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
@Override
protected void doDispose() {
//
}
public Object getUserObject() {
return userObject;
}
public void setUserObject(Object userObject) {
this.userObject = userObject;
}
public String getName() {
return nameEl.getValue();
}
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
String name = nameEl.getValue();
nameEl.clearError();
if(!StringHelper.containsNonWhitespace(name)) {
nameEl.setErrorKey("", null);
}
return allOk && super.validateFormLogic(ureq);
}
@Override
protected void formOK(UserRequest ureq) {
fireEvent(ureq, Event.DONE_EVENT);
}
@Override
protected void formCancelled(UserRequest ureq) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.qpool.ui;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.olat.admin.user.UserSearchFlexiController;
import org.olat.basesecurity.events.MultiIdentityChosenEvent;
import org.olat.basesecurity.events.SingleIdentityChosenEvent;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.impl.Form;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.wizard.StepFormBasicController;
import org.olat.core.gui.control.generic.wizard.StepsEvent;
import org.olat.core.gui.control.generic.wizard.StepsRunContext;
import org.olat.core.id.Identity;
/**
*
* Initial date: 25.02.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class ImportAuthorBySearchController extends StepFormBasicController {
private UserSearchFlexiController searchController;
public ImportAuthorBySearchController(UserRequest ureq, WindowControl wControl, Form rootForm, StepsRunContext runContext) {
super(ureq, wControl, rootForm, runContext, LAYOUT_CUSTOM, "import_search");
searchController = new UserSearchFlexiController(ureq, wControl, rootForm);
listenTo(searchController);
initForm (ureq);
}
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if(event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent e = (SingleIdentityChosenEvent)event;
String key = e.getChosenIdentity().getKey().toString();
addToRunContext("keys", Collections.singletonList(key));
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
} else if(event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent e = (MultiIdentityChosenEvent)event;
Collection<String> keys = new ArrayList<String>();
for(Identity identity: e.getChosenIdentities()) {
keys.add(identity.getKey().toString());
}
addToRunContext("keys", keys);
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
} else {
super.event(ureq, source, event);
}
}
@Override
protected void formOK(UserRequest ureq) {
List<Identity> identities = searchController.getSelectedIdentities();
Collection<String> keys = new ArrayList<String>();
for(Identity identity: identities) {
keys.add(identity.getKey().toString());
}
addToRunContext("keys", keys);
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.add("search", searchController.getInitialFormItem());
}
@Override
protected void doDispose() {
//
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.qpool.ui;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.olat.core.commons.persistence.SortKey;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModel;
import org.olat.core.gui.components.table.DefaultTableDataModel;
import org.olat.core.id.Identity;
import org.olat.user.propertyhandlers.UserPropertyHandler;
/**
*
* Initial date: 25.02.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class ImportAuthorOverviewDataModel extends DefaultTableDataModel<Identity> implements FlexiTableDataModel {
private final Locale locale;
private final boolean isAdministrativeUser;
private FlexiTableColumnModel columnModel;
private final List<UserPropertyHandler> userPropertyHandlers;
public ImportAuthorOverviewDataModel(List<Identity> identities, List<UserPropertyHandler> userPropertyHandlers,
boolean isAdministrativeUser, Locale locale, FlexiTableColumnModel columnModel) {
super(identities);
this.locale = locale;
this.columnModel = columnModel;
this.isAdministrativeUser = isAdministrativeUser;
this.userPropertyHandlers = userPropertyHandlers;
}
@Override
public FlexiTableColumnModel getTableColumnModel() {
return columnModel;
}
@Override
public void setTableColumnModel(FlexiTableColumnModel tableColumnModel) {
columnModel = tableColumnModel;
}
@Override
public int getColumnCount() {
return columnModel.getColumnCount();
}
@Override
public void load(int firstResult, int maxResults, SortKey... orderBy) {
//already loaded
}
@Override
public Object getValueAt(int row, int col) {
Identity identity = getObject(row);
if(col == 0 && isAdministrativeUser) {
return identity.getName();
}
int pos = isAdministrativeUser ? col - 1 : col;
if(pos >= 0 && pos < userPropertyHandlers.size()) {
UserPropertyHandler handler = userPropertyHandlers.get(pos);
return handler.getUserProperty(identity.getUser(), locale);
}
return "";
}
@Override
public ImportAuthorOverviewDataModel createCopyWithEmptyList() {
return new ImportAuthorOverviewDataModel(new ArrayList<Identity>(), userPropertyHandlers, isAdministrativeUser, locale, columnModel);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.qpool.ui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.olat.admin.user.UserTableDataModel;
import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.BaseSecurityModule;
import org.olat.basesecurity.Constants;
import org.olat.basesecurity.SecurityGroup;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.persistence.PersistenceHelper;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.impl.Form;
import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.wizard.StepFormBasicController;
import org.olat.core.gui.control.generic.wizard.StepsEvent;
import org.olat.core.gui.control.generic.wizard.StepsRunContext;
import org.olat.core.gui.translator.Translator;
import org.olat.core.id.Identity;
import org.olat.user.UserManager;
import org.olat.user.propertyhandlers.UserPropertyHandler;
/**
*
* Initial date: 25.02.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class ImportAuthorOverviewIdentitiesController extends StepFormBasicController {
private static final String usageIdentifyer = UserTableDataModel.class.getCanonicalName();
private List<Identity> oks;
private boolean isAdministrativeUser;
private final UserManager userManager;
private final BaseSecurity securityManager;
private final BaseSecurityModule securityModule;
public ImportAuthorOverviewIdentitiesController(UserRequest ureq, WindowControl wControl, Form rootForm, StepsRunContext runContext) {
super(ureq, wControl, rootForm, runContext, LAYOUT_VERTICAL, null);
userManager = UserManager.getInstance();
securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
oks = null;
if(containsRunContextKey("logins")) {
String logins = (String)runContext.get("logins");
oks = loadModel(logins);
} else if(containsRunContextKey("keys")) {
@SuppressWarnings("unchecked")
List<String> keys = (List<String>)runContext.get("keys");
oks = loadModel(keys);
}
isAdministrativeUser = securityModule.isUserAllowedAdminProps(ureq.getUserSession().getRoles());
initForm (ureq);
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
//add the table
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
int colIndex = 0;
if(isAdministrativeUser) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.user.login", colIndex++));
}
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<UserPropertyHandler>();
// followed by the users fields
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer , userPropertyHandler);
if(visible) {
resultingPropertyHandlers.add(userPropertyHandler);
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex++));
}
}
Translator myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
ImportAuthorOverviewDataModel userTableModel = new ImportAuthorOverviewDataModel(oks, resultingPropertyHandlers,
isAdministrativeUser, getLocale(), tableColumnModel);
uifactory.addTableElement(ureq, "users", userTableModel, myTrans, formLayout);
}
private List<Identity> loadModel(List<String> keys) {
List<Identity> existIdents = Collections.emptyList();//securityManager.getIdentitiesOfSecurityGroup(securityGroup);
List<Identity> oks = new ArrayList<Identity>();
List<String> isanonymous = new ArrayList<String>();
List<String> notfounds = new ArrayList<String>();
List<String> alreadyin = new ArrayList<String>();
SecurityGroup anonymousSecGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS);
for (String identityKey : keys) {
Identity ident = securityManager.loadIdentityByKey(Long.parseLong(identityKey));
if (ident == null) { // not found, add to not-found-list
notfounds.add(identityKey);
} else if (securityManager.isIdentityInSecurityGroup(ident, anonymousSecGroup)) {
isanonymous.add(identityKey);
} else {
// check if already in group
boolean inGroup = PersistenceHelper.containsPersistable(existIdents, ident);
if (inGroup) {
// added to warning: already in group
alreadyin.add(ident.getName());
} else {
// ok to add -> preview (but filter duplicate entries)
if (!PersistenceHelper.containsPersistable(oks, ident)) {
oks.add(ident);
}
}
}
}
return oks;
}
private List<Identity> loadModel(String inp) {
List<Identity> existIdents = Collections.emptyList();//securityManager.getIdentitiesOfSecurityGroup(securityGroup);
List<Identity> oks = new ArrayList<Identity>();
List<String> isanonymous = new ArrayList<String>();
List<String> notfounds = new ArrayList<String>();
List<String> alreadyin = new ArrayList<String>();
SecurityGroup anonymousSecGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS);
String[] lines = inp.split("\r?\n");
for (int i = 0; i < lines.length; i++) {
String username = lines[i].trim();
if (!username.equals("")) { // skip empty lines
Identity ident = securityManager.findIdentityByName(username);
if (ident == null) { // not found, add to not-found-list
notfounds.add(username);
} else if (securityManager.isIdentityInSecurityGroup(ident, anonymousSecGroup)) {
isanonymous.add(username);
} else {
// check if already in group
boolean inGroup = PersistenceHelper.containsPersistable(existIdents, ident);
if (inGroup) {
// added to warning: already in group
alreadyin.add(ident.getName());
} else {
// ok to add -> preview (but filter duplicate entries)
if (!PersistenceHelper.containsPersistable(oks, ident)) {
oks.add(ident);
}
}
}
}
}
return oks;
}
public boolean validate() {
return true;
}
@Override
protected void formOK(UserRequest ureq) {
addToRunContext("members", oks);
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
@Override
protected void doDispose() {
//
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.qpool.ui;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.impl.Form;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.wizard.BasicStep;
import org.olat.core.gui.control.generic.wizard.PrevNextFinishConfig;
import org.olat.core.gui.control.generic.wizard.StepFormController;
import org.olat.core.gui.control.generic.wizard.StepsRunContext;
import org.olat.modules.qpool.QuestionItem;
/**
*
* Initial date: 25.02.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class ImportAuthor_1_ChooseMemberStep extends BasicStep {
private final List<QuestionItem> items;
public ImportAuthor_1_ChooseMemberStep(UserRequest ureq, List<QuestionItem> items) {
super(ureq);
this.items = items;
setNextStep(new ImportAuthor_2_ConfirmMemberChoiceStep(ureq));
setI18nTitleAndDescr("author.choose.title", "author.choose.title");
}
@Override
public PrevNextFinishConfig getInitialPrevNextFinishConfig() {
return new PrevNextFinishConfig(false, true, false);
}
@Override
public StepFormController getStepController(UserRequest ureq, WindowControl wControl, StepsRunContext runContext, Form form) {
runContext.put("items", items);
ImportAuthorBySearchController controller = new ImportAuthorBySearchController(ureq, wControl, form, runContext);
return controller;
}
}
\ No newline at end of file
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.qpool.ui;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.impl.Form;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.wizard.BasicStep;
import org.olat.core.gui.control.generic.wizard.PrevNextFinishConfig;
import org.olat.core.gui.control.generic.wizard.StepFormController;
import org.olat.core.gui.control.generic.wizard.StepsRunContext;
/**
*
* Initial date: 25.02.2013<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class ImportAuthor_2_ConfirmMemberChoiceStep extends BasicStep {
public ImportAuthor_2_ConfirmMemberChoiceStep(UserRequest ureq) {
super(ureq);
setNextStep(NOSTEP);
setI18nTitleAndDescr("author.confirm.title", "author.confirm.title");
}
@Override
public PrevNextFinishConfig getInitialPrevNextFinishConfig() {
return new PrevNextFinishConfig(true, false, true);
}
@Override
public StepFormController getStepController(UserRequest ureq, WindowControl wControl, StepsRunContext runContext, Form form) {
ImportAuthorOverviewIdentitiesController controller = new ImportAuthorOverviewIdentitiesController(ureq, wControl, form, runContext);
return controller;
}
}
\ No newline at end of file
......@@ -45,7 +45,7 @@ public class MyQuestionItemsSource implements QuestionItemsSource {
@Override
public int getNumOfItems() {
return 0;
return qpoolService.countItems(me);
}
@Override
......
......@@ -34,6 +34,8 @@ public class QPoolEvent extends MultiUserEvent {
public static final String ITEM_SHARED = "qpool-item-shared";
public static final String ITEM_MARKED = "qpool-item-marked";
public static final String ITEM_DELETED = "qpool-item-deleted";
public static final String COLL_CREATED = "qpool-coll-created";
public QPoolEvent(String cmd) {
super(cmd);
......
......@@ -50,6 +50,11 @@ import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController;
import org.olat.core.gui.control.generic.modal.DialogBoxController;
import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.gui.control.generic.wizard.Step;
import org.olat.core.gui.control.generic.wizard.StepRunnerCallback;
import org.olat.core.gui.control.generic.wizard.StepsMainRunController;
import org.olat.core.gui.control.generic.wizard.StepsRunContext;
import org.olat.core.id.Identity;
import org.olat.group.BusinessGroup;
import org.olat.group.model.BusinessGroupSelectionEvent;
import org.olat.group.ui.main.SelectBusinessGroupController;
......@@ -64,7 +69,7 @@ import org.olat.modules.qpool.ui.QuestionItemDataModel.Cols;
*/
public class QuestionListController extends FormBasicController implements StackedControllerAware, ItemRowsSource {
private FormLink createList, shareItem, deleteItem;
private FormLink createList, shareItem, deleteItem, authorItem;
private FlexiTableElement itemsTable;
private QuestionItemDataModel model;
......@@ -73,6 +78,8 @@ public class QuestionListController extends FormBasicController implements Stack
private CloseableModalController cmc;
private DialogBoxController confirmDeleteBox;
private SelectBusinessGroupController selectGroupCtrl;
private CreateCollectionController createCollectionCtrl;
private StepsMainRunController importAuthorsWizard;
private final MarkManager markManager;
private final QuestionPoolService qpoolService;
......@@ -114,6 +121,7 @@ public class QuestionListController extends FormBasicController implements Stack
createList = uifactory.addFormLink("create.list", formLayout, Link.BUTTON);
shareItem = uifactory.addFormLink("share.item", formLayout, Link.BUTTON);
authorItem = uifactory.addFormLink("author.item", formLayout, Link.BUTTON);
deleteItem = uifactory.addFormLink("delete.item", formLayout, Link.BUTTON);
}
......@@ -142,8 +150,8 @@ public class QuestionListController extends FormBasicController implements Stack
FormLink link = (FormLink)source;
if(link == createList) {
Set<Integer> selections = itemsTable.getMultiSelectedIndex();
System.out.println(selections.size());
List<QuestionItem> items = getQuestionItems(selections);
doAskCollectionName(ureq, items);
} else if(link == shareItem) {
Set<Integer> selections = itemsTable.getMultiSelectedIndex();
if(selections.size() > 0) {
......@@ -156,6 +164,12 @@ public class QuestionListController extends FormBasicController implements Stack
List<QuestionItem> items = getQuestionItems(selections);
doConfirmDelete(ureq, items);
}
} else if(link == authorItem) {
Set<Integer> selections = itemsTable.getMultiSelectedIndex();
if(selections.size() > 0) {
List<QuestionItem> items = getQuestionItems(selections);
doChooseAuthoren(ureq, items);
}
} else if("select".equals(link.getCmd())) {
QuestionItemRow row = (QuestionItemRow)link.getUserObject();
doSelect(ureq, row.getItem());
......@@ -191,12 +205,27 @@ public class QuestionListController extends FormBasicController implements Stack
List<BusinessGroup> groups = bge.getGroups();
if(groups.size() > 0) {
@SuppressWarnings("unchecked")
List<QuestionItem> items = (List<QuestionItem>)((SelectBusinessGroupController)source).getUserObject();
List<QuestionItem> items = (List<QuestionItem>)selectGroupCtrl.getUserObject();
doShareItems(ureq, items, groups);
}
}
cmc.deactivate();
cleanUp();
} else if(source == createCollectionCtrl) {
if(Event.DONE_EVENT == event) {
@SuppressWarnings("unchecked")
List<QuestionItem> items = (List<QuestionItem>)createCollectionCtrl.getUserObject();
String collectionName = createCollectionCtrl.getName();
doCreateCollection(ureq, collectionName, items);
}
cmc.deactivate();
cleanUp();
} else if(source == importAuthorsWizard) {
if(event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
getWindowControl().pop();
removeAsListenerAndDispose(importAuthorsWizard);
importAuthorsWizard = null;
}
} else if(source == confirmDeleteBox) {
boolean delete = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
if(delete) {
......@@ -213,8 +242,10 @@ public class QuestionListController extends FormBasicController implements Stack
private void cleanUp() {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(selectGroupCtrl);
removeAsListenerAndDispose(createCollectionCtrl);
cmc = null;
selectGroupCtrl = null;
createCollectionCtrl = null;
}
public List<QuestionItem> getQuestionItems(Set<Integer> index) {
......@@ -236,6 +267,49 @@ public class QuestionListController extends FormBasicController implements Stack
return null;
}
private void doAskCollectionName(UserRequest ureq, List<QuestionItem> items) {
removeAsListenerAndDispose(createCollectionCtrl);
createCollectionCtrl = new CreateCollectionController(ureq, getWindowControl());
createCollectionCtrl.setUserObject(items);
listenTo(createCollectionCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"),
createCollectionCtrl.getInitialComponent(), true, translate("create.list"));
cmc.activate();
listenTo(cmc);
}
private void doCreateCollection(UserRequest ureq, String name, List<QuestionItem> items) {
qpoolService.createCollection(getIdentity(), name, items);
fireEvent(ureq, new QPoolEvent(QPoolEvent.COLL_CREATED));
}
private void doChooseAuthoren(UserRequest ureq, List<QuestionItem> items) {
removeAsListenerAndDispose(importAuthorsWizard);
Step start = new ImportAuthor_1_ChooseMemberStep(ureq, items);
StepRunnerCallback finish = new StepRunnerCallback() {
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
addAuthors(ureq, runContext);
return StepsMainRunController.DONE_MODIFIED;
}
};
importAuthorsWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null,
translate("author.item"), "o_sel_qpool_import_1_wizard");
listenTo(importAuthorsWizard);
getWindowControl().pushAsModalDialog(importAuthorsWizard.getInitialComponent());
}
private void addAuthors(UserRequest ureq, StepsRunContext runContext) {
@SuppressWarnings("unchecked")
List<QuestionItem> items = (List<QuestionItem>)runContext.get("items");
@SuppressWarnings("unchecked")
List<Identity> authors = (List<Identity>)runContext.get("members");
qpoolService.addAuthors(authors, items);
}
private void doConfirmDelete(UserRequest ureq, List<QuestionItem> items) {
confirmDeleteBox = activateYesNoDialog(ureq, null, translate("confirm.delete"), confirmDeleteBox);
confirmDeleteBox.setUserObject(items);
......
......@@ -45,6 +45,7 @@ import org.olat.core.id.context.StateEntry;
import org.olat.group.BusinessGroup;
import org.olat.modules.qpool.Pool;
import org.olat.modules.qpool.QuestionItem;
import org.olat.modules.qpool.QuestionItemCollection;
import org.olat.modules.qpool.QuestionPoolService;
/**
......@@ -56,17 +57,20 @@ import org.olat.modules.qpool.QuestionPoolService;
public class QuestionPoolMainEditorController extends BasicController implements Activateable2, StackedControllerAware {
private final MenuTree menuTree;
private GenericTreeNode sharesNode;
private GenericTreeNode sharesNode, myNode;
private final Panel content;
private StackedController stackPanel;
private QuestionsController currentCtrl;
private QuestionsController myQuestionsCtrl;
private QuestionsController markedQuestionsCtrl;
private QuestionsController selectedPoolCtrl;
private QuestionsController sharedItemsCtrl;
private QuestionsController currentCtrl;
private QuestionsController collItemsCtrl;
private QuestionsController selectedPoolCtrl;
private QuestionsController markedQuestionsCtrl;
private StudyFieldAdminController studyFieldCtrl;
private LayoutMain3ColsController columnLayoutCtr;
private QuestionPoolAdminStatisticsController adminStatisticsCtrl;
private final MarkManager markManager;
private final QuestionPoolService qpoolService;
......@@ -129,6 +133,9 @@ public class QuestionPoolMainEditorController extends BasicController implements
} else if(uNode instanceof BusinessGroup) {
BusinessGroup group = (BusinessGroup)uNode;
doSelect(ureq, group);
} else if(uNode instanceof QuestionItemCollection) {
QuestionItemCollection coll = (QuestionItemCollection)uNode;
doSelect(ureq, coll);
}
}
}
......@@ -140,7 +147,10 @@ public class QuestionPoolMainEditorController extends BasicController implements
if(QPoolEvent.ITEM_SHARED.equals(event.getCommand())) {
buildShareSubTreeModel(sharesNode);
menuTree.setDirty(true);
}
} else if(QPoolEvent.COLL_CREATED.equals(event.getCommand())) {
buildMySubTreeModel(myNode);
menuTree.setDirty(true);
}
}
super.event(ureq, source, event);
}
......@@ -165,6 +175,9 @@ public class QuestionPoolMainEditorController extends BasicController implements
} else if(userObj instanceof Pool) {
qpoolService.addItemToPool(item, (Pool)userObj);
showInfo("item.pooled", item.getSubject());
} else if(userObj instanceof QuestionItemCollection) {
qpoolService.addItemToCollection(item, (QuestionItemCollection)userObj);
showInfo("item.collectioned", item.getSubject());
} else if("menu.database.favorit".equals(userObj)) {
String businessPath = "[QuestionItem:" + item.getKey() + "]";
markManager.setMark(item, getIdentity(), null, businessPath);
......@@ -176,9 +189,6 @@ public class QuestionPoolMainEditorController extends BasicController implements
}
}
private QuestionPoolAdminStatisticsController adminStatisticsCtrl;
private StudyFieldAdminController studyFieldCtrl;
private void doSelectAdmin(UserRequest ureq) {
if(adminStatisticsCtrl == null) {
adminStatisticsCtrl = new QuestionPoolAdminStatisticsController(ureq, getWindowControl());
......@@ -241,6 +251,18 @@ public class QuestionPoolMainEditorController extends BasicController implements
content.setContent(sharedItemsCtrl.getInitialComponent());
}
private void doSelect(UserRequest ureq, QuestionItemCollection coll) {
if(collItemsCtrl == null) {
collItemsCtrl = new QuestionsController(ureq, getWindowControl(), new CollectionOfItemsSource(coll));
collItemsCtrl.setStackedController(stackPanel);
listenTo(collItemsCtrl);
} else {
collItemsCtrl.updateSource(new CollectionOfItemsSource(coll));
}
currentCtrl = collItemsCtrl;
content.setContent(collItemsCtrl.getInitialComponent());
}
private TreeModel buildTreeModel() {
QuestionPoolMenuTreeModel gtm = new QuestionPoolMenuTreeModel();
GenericTreeNode rootNode = new GenericTreeNode(translate("topnav.qpool"), "topnav.qpool.alt");
......@@ -248,17 +270,11 @@ public class QuestionPoolMainEditorController extends BasicController implements
gtm.setRootNode(rootNode);
//question database
GenericTreeNode databaseNode = new GenericTreeNode(translate("menu.database"), "menu.database");
databaseNode.setCssClass("o_sel_qpool_database");
rootNode.addChild(databaseNode);
GenericTreeNode node = new GenericTreeNode(translate("menu.database.my"), "menu.database.my");
node.setIconCssClass("o_sel_qpool_my_items");
databaseNode.addChild(node);
node = new GenericTreeNode(translate("menu.database.favorit"), "menu.database.favorit");
node.setIconCssClass("o_sel_qpool_favorits");
databaseNode.addChild(node);
myNode = new GenericTreeNode(translate("menu.database"), "menu.database");
myNode.setCssClass("o_sel_qpool_database");
rootNode.addChild(myNode);
buildMySubTreeModel(myNode);
//pools
GenericTreeNode poolNode = new GenericTreeNode(translate("menu.pools"), "menu.pools.alt");
......@@ -267,7 +283,7 @@ public class QuestionPoolMainEditorController extends BasicController implements
List<Pool> pools = qpoolService.getPools(getIdentity());
for(Pool pool:pools) {
node = new GenericTreeNode(pool.getName(), pool);
GenericTreeNode node = new GenericTreeNode(pool.getName(), pool);
node.setIconCssClass("o_sel_qpool_pool");
poolNode.addChild(node);
}
......@@ -283,13 +299,32 @@ public class QuestionPoolMainEditorController extends BasicController implements
adminNode.setCssClass("o_sel_qpool_admin");
rootNode.addChild(adminNode);
node = new GenericTreeNode(translate("menu.admin.studyfields"), "menu.admin.studyfields");
GenericTreeNode node = new GenericTreeNode(translate("menu.admin.studyfields"), "menu.admin.studyfields");
node.setIconCssClass("o_sel_qpool_study_fields");
adminNode.addChild(node);
return gtm;
}
private void buildMySubTreeModel(GenericTreeNode myNode) {
myNode.removeAllChildren();
GenericTreeNode node = new GenericTreeNode(translate("menu.database.my"), "menu.database.my");
node.setIconCssClass("o_sel_qpool_my_items");
myNode.addChild(node);
node = new GenericTreeNode(translate("menu.database.favorit"), "menu.database.favorit");
node.setIconCssClass("o_sel_qpool_favorits");
myNode.addChild(node);
List<QuestionItemCollection> collections = qpoolService.getCollections(getIdentity());
for(QuestionItemCollection coll: collections) {
node = new GenericTreeNode(coll.getName(), coll);
node.setIconCssClass("o_sel_qpool_collection");
myNode.addChild(node);
}
}
private void buildShareSubTreeModel(GenericTreeNode sharesNode) {
sharesNode.removeAllChildren();
......
$r.render("identityList")
\ No newline at end of file
$r.render("search")
\ No newline at end of file
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