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

OO-2880: add reference count in the author list of resources, add a filter in...

OO-2880: add reference count in the author list of resources, add a filter in the extended to search used and not used resources
parent 250b0a4c
No related branches found
No related tags found
No related merge requests found
Showing
with 221 additions and 5 deletions
...@@ -53,6 +53,8 @@ public interface RepositoryEntryAuthorView extends OLATResourceable, RepositoryE ...@@ -53,6 +53,8 @@ public interface RepositoryEntryAuthorView extends OLATResourceable, RepositoryE
public RepositoryEntryLifecycle getLifecycle(); public RepositoryEntryLifecycle getLifecycle();
public int getNumOfReferences();
public Date getDeletionDate(); public Date getDeletionDate();
public String getDeletedByFullName(); public String getDeletedByFullName();
......
...@@ -135,6 +135,10 @@ cif.membership.mandatory=Meine Kurse ...@@ -135,6 +135,10 @@ cif.membership.mandatory=Meine Kurse
cif.objectives=Lernziele cif.objectives=Lernziele
cif.ores_id=OpenOLAT-Ressourcen-ID cif.ores_id=OpenOLAT-Ressourcen-ID
cif.owned.resources.only=Meine Ressourcen cif.owned.resources.only=Meine Ressourcen
cif.owned.resources.usage=Referenzierte Ressourcen
cif.owned.resources.usage.all=Alle
cif.owned.resources.usage.used=Referenziert
cif.owned.resources.usage.notUsed=Nicht referenziert
cif.owners=Autoren cif.owners=Autoren
cif.private.dates=Datum cif.private.dates=Datum
cif.public.dates=Semester cif.public.dates=Semester
...@@ -545,6 +549,7 @@ table.header.mark=<i class\="o_icon o_icon_bookmark_header o_icon-lg" title\="Fa ...@@ -545,6 +549,7 @@ table.header.mark=<i class\="o_icon o_icon_bookmark_header o_icon-lg" title\="Fa
table.header.online=$org.olat.group.ui.main\:table.header.online table.header.online=$org.olat.group.ui.main\:table.header.online
table.header.participants=$org.olat.group.ui.main\:table.header.participants table.header.participants=$org.olat.group.ui.main\:table.header.participants
table.header.participantsCount=$org.olat.group.ui.main\:table.header.participantsCount table.header.participantsCount=$org.olat.group.ui.main\:table.header.participantsCount
table.header.references=Ref.
table.header.remove=$org.olat.group.ui.main\:table.header.remove table.header.remove=$org.olat.group.ui.main\:table.header.remove
table.header.role=$org.olat.group.ui.main\:table.header.role table.header.role=$org.olat.group.ui.main\:table.header.role
table.header.start=Starten table.header.start=Starten
......
...@@ -130,7 +130,11 @@ cif.managedflags=Externally managed modules ...@@ -130,7 +130,11 @@ cif.managedflags=Externally managed modules
cif.membership.mandatory=My courses only cif.membership.mandatory=My courses only
cif.objectives=Objectives cif.objectives=Objectives
cif.ores_id=OpenOLAT resource ID cif.ores_id=OpenOLAT resource ID
cif.owned.resources.only=My ressources cif.owned.resources.only=My resources
cif.owned.resources.usage=Referenced resources
cif.owned.resources.usage.all=All
cif.owned.resources.usage.used=Referenced
cif.owned.resources.usage.notUsed=Not referenced
cif.owners=Authoring rights cif.owners=Authoring rights
cif.private.dates=Dates cif.private.dates=Dates
cif.public.dates=Semester cif.public.dates=Semester
...@@ -542,6 +546,7 @@ table.header.mark=<i class\="o_icon o_icon_bookmark_header o_icon-lg" title\="Bo ...@@ -542,6 +546,7 @@ table.header.mark=<i class\="o_icon o_icon_bookmark_header o_icon-lg" title\="Bo
table.header.online=$org.olat.group.ui.main\:table.header.online table.header.online=$org.olat.group.ui.main\:table.header.online
table.header.participants=$org.olat.group.ui.main\:table.header.participants table.header.participants=$org.olat.group.ui.main\:table.header.participants
table.header.participantsCount=$org.olat.group.ui.main\:table.header.participantsCount table.header.participantsCount=$org.olat.group.ui.main\:table.header.participantsCount
table.header.references=Ref.
table.header.remove=$org.olat.group.ui.main\:table.header.remove table.header.remove=$org.olat.group.ui.main\:table.header.remove
table.header.role=$org.olat.group.ui.main\:table.header.role table.header.role=$org.olat.group.ui.main\:table.header.role
table.header.start=Launch table.header.start=Launch
......
...@@ -41,6 +41,7 @@ import org.olat.repository.RepositoryEntryAuthorView; ...@@ -41,6 +41,7 @@ import org.olat.repository.RepositoryEntryAuthorView;
import org.olat.repository.model.RepositoryEntryAuthorImpl; import org.olat.repository.model.RepositoryEntryAuthorImpl;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams; import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy; import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.ResourceUsage;
import org.olat.user.UserImpl; import org.olat.user.UserImpl;
import org.olat.user.UserManager; import org.olat.user.UserManager;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -97,6 +98,9 @@ public class RepositoryEntryAuthorQueries { ...@@ -97,6 +98,9 @@ public class RepositoryEntryAuthorQueries {
Number numOffers = (Number)object[2]; Number numOffers = (Number)object[2];
long offers = numOffers == null ? 0l : numOffers.longValue(); long offers = numOffers == null ? 0l : numOffers.longValue();
Number numOfReferences = (Number)object[3];
int references = numOfReferences == null ? 0 : numOfReferences.intValue();
String deletedByName = null; String deletedByName = null;
if(params.isDeleted()) { if(params.isDeleted()) {
Identity deletedBy = re.getDeletedBy(); Identity deletedBy = re.getDeletedBy();
...@@ -105,7 +109,7 @@ public class RepositoryEntryAuthorQueries { ...@@ -105,7 +109,7 @@ public class RepositoryEntryAuthorQueries {
} }
} }
views.add(new RepositoryEntryAuthorImpl(re, hasMarks, offers, deletedByName)); views.add(new RepositoryEntryAuthorImpl(re, hasMarks, offers, references, deletedByName));
} }
return views; return views;
} }
...@@ -138,8 +142,11 @@ public class RepositoryEntryAuthorQueries { ...@@ -138,8 +142,11 @@ public class RepositoryEntryAuthorQueries {
needIdentity = true; needIdentity = true;
} }
sb.append(" (select count(offer.key) from acoffer as offer ") sb.append(" (select count(offer.key) from acoffer as offer ")
.append(" where offer.resource=res and offer.valid=true") .append(" where offer.resource.key=res.key and offer.valid=true")
.append(" ) as offers") .append(" ) as offers,")
.append(" (select count(ref.key) from references as ref ")
.append(" where ref.target.key=res.key")
.append(" ) as references")
.append(" from repositoryentry as v") .append(" from repositoryentry as v")
.append(" inner join ").append(oracle ? "" : "fetch").append(" v.olatResource as res") .append(" inner join ").append(oracle ? "" : "fetch").append(" v.olatResource as res")
.append(" inner join fetch v.statistics as stats") .append(" inner join fetch v.statistics as stats")
...@@ -179,6 +186,14 @@ public class RepositoryEntryAuthorQueries { ...@@ -179,6 +186,14 @@ public class RepositoryEntryAuthorQueries {
.append(" ))"); .append(" ))");
} }
if(params.getResourceUsage() != null && params.getResourceUsage() != ResourceUsage.all) {
sb.append(" and res.resName!='CourseModule' and");
if(params.getResourceUsage() == ResourceUsage.notUsed) {
sb.append(" not");
}
sb.append(" exists (select ref.key from references as ref where ref.target.key=res.key)");
}
if(params.getRepoEntryKeys() != null && params.getRepoEntryKeys().size() > 0) { if(params.getRepoEntryKeys() != null && params.getRepoEntryKeys().size() > 0) {
sb.append(" and v.key in (:repoEntryKeys)"); sb.append(" and v.key in (:repoEntryKeys)");
} }
...@@ -369,6 +384,14 @@ public class RepositoryEntryAuthorQueries { ...@@ -369,6 +384,14 @@ public class RepositoryEntryAuthorQueries {
sb.append(" order by offers desc, lower(v.displayname) desc"); sb.append(" order by offers desc, lower(v.displayname) desc");
} }
break; break;
case references: {
if(asc) {
sb.append(" order by references asc, lower(v.displayname) asc");
} else {
sb.append(" order by references desc, lower(v.displayname) desc");
}
break;
}
case creationDate: case creationDate:
sb.append(" order by v.creationDate "); sb.append(" order by v.creationDate ");
appendAsc(sb, asc).append(", lower(v.displayname) asc"); appendAsc(sb, asc).append(", lower(v.displayname) asc");
......
...@@ -56,6 +56,8 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView { ...@@ -56,6 +56,8 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView {
private final Date lastUsage; private final Date lastUsage;
public int numOfReferences;
private final Date deletionDate; private final Date deletionDate;
private final String deletedByFullName; private final String deletedByFullName;
...@@ -66,7 +68,7 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView { ...@@ -66,7 +68,7 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView {
private final long offers; private final long offers;
public RepositoryEntryAuthorImpl(RepositoryEntry re, boolean marked, long offers, String deletedByFullName) { public RepositoryEntryAuthorImpl(RepositoryEntry re, boolean marked, long offers, int numOfReferences, String deletedByFullName) {
key = re.getKey(); key = re.getKey();
creationDate = re.getCreationDate(); creationDate = re.getCreationDate();
...@@ -87,6 +89,8 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView { ...@@ -87,6 +89,8 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView {
lastUsage = re.getStatistics().getLastUsage(); lastUsage = re.getStatistics().getLastUsage();
this.numOfReferences = numOfReferences;
deletionDate = re.getDeletionDate(); deletionDate = re.getDeletionDate();
this.deletedByFullName = deletedByFullName; this.deletedByFullName = deletedByFullName;
...@@ -190,6 +194,11 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView { ...@@ -190,6 +194,11 @@ public class RepositoryEntryAuthorImpl implements RepositoryEntryAuthorView {
return lifecycle; return lifecycle;
} }
@Override
public int getNumOfReferences() {
return numOfReferences;
}
@Override @Override
public boolean isMarked() { public boolean isMarked() {
return marked; return marked;
......
...@@ -38,6 +38,7 @@ public class SearchAuthorRepositoryEntryViewParams { ...@@ -38,6 +38,7 @@ public class SearchAuthorRepositoryEntryViewParams {
private Boolean marked; private Boolean marked;
private boolean deleted = false; private boolean deleted = false;
private boolean ownedResourcesOnly; private boolean ownedResourcesOnly;
private ResourceUsage resourceUsage = ResourceUsage.all;
private String idAndRefs; private String idAndRefs;
private String idRefsAndTitle; private String idRefsAndTitle;
...@@ -174,6 +175,14 @@ public class SearchAuthorRepositoryEntryViewParams { ...@@ -174,6 +175,14 @@ public class SearchAuthorRepositoryEntryViewParams {
this.marked = marked; this.marked = marked;
} }
public ResourceUsage getResourceUsage() {
return resourceUsage;
}
public void setResourceUsage(ResourceUsage resourceUsage) {
this.resourceUsage = resourceUsage;
}
public enum OrderBy { public enum OrderBy {
key, key,
favorit, favorit,
...@@ -192,7 +201,14 @@ public class SearchAuthorRepositoryEntryViewParams { ...@@ -192,7 +201,14 @@ public class SearchAuthorRepositoryEntryViewParams {
lifecycleSoftkey, lifecycleSoftkey,
lifecycleStart, lifecycleStart,
lifecycleEnd, lifecycleEnd,
references,
deletionDate, deletionDate,
deletedBy deletedBy
} }
public enum ResourceUsage {
all,
used,
notUsed
}
} }
...@@ -101,8 +101,10 @@ import org.olat.repository.handlers.RepositoryHandlerFactory; ...@@ -101,8 +101,10 @@ import org.olat.repository.handlers.RepositoryHandlerFactory;
import org.olat.repository.handlers.RepositoryHandlerFactory.OrderedRepositoryHandler; import org.olat.repository.handlers.RepositoryHandlerFactory.OrderedRepositoryHandler;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams; import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy; import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.OrderBy;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.ResourceUsage;
import org.olat.repository.ui.RepositoyUIFactory; import org.olat.repository.ui.RepositoyUIFactory;
import org.olat.repository.ui.author.AuthoringEntryDataModel.Cols; import org.olat.repository.ui.author.AuthoringEntryDataModel.Cols;
import org.olat.resource.references.ReferenceManager;
import org.olat.user.UserManager; import org.olat.user.UserManager;
import org.olat.util.logging.activity.LoggingResourceable; import org.olat.util.logging.activity.LoggingResourceable;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -132,6 +134,7 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -132,6 +134,7 @@ public class AuthorListController extends FormBasicController implements Activat
private AuthorSearchController searchCtrl; private AuthorSearchController searchCtrl;
private UserSearchController userSearchCtr; private UserSearchController userSearchCtr;
private DialogBoxController copyDialogCtrl; private DialogBoxController copyDialogCtrl;
private ReferencesController referencesCtrl;
private CopyRepositoryEntryController copyCtrl; private CopyRepositoryEntryController copyCtrl;
private ConfirmCloseController closeCtrl; private ConfirmCloseController closeCtrl;
private ConfirmDeleteSoftlyController confirmDeleteCtrl; private ConfirmDeleteSoftlyController confirmDeleteCtrl;
...@@ -290,6 +293,9 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -290,6 +293,9 @@ public class AuthorListController extends FormBasicController implements Activat
true, OrderBy.creationDate.name())); true, OrderBy.creationDate.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastUsage.i18nKey(), Cols.lastUsage.ordinal(), columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Cols.lastUsage.i18nKey(), Cols.lastUsage.ordinal(),
true, OrderBy.lastUsage.name())); true, OrderBy.lastUsage.name()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.references.i18nKey(), Cols.references.ordinal(),
true, OrderBy.references.name()));
initActionsColumns(columnsModel); initActionsColumns(columnsModel);
model = new AuthoringEntryDataModel(dataSource, columnsModel); model = new AuthoringEntryDataModel(dataSource, columnsModel);
...@@ -466,6 +472,7 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -466,6 +472,7 @@ public class AuthorListController extends FormBasicController implements Activat
searchParams.setDisplayname(null); searchParams.setDisplayname(null);
searchParams.setDescription(null); searchParams.setDescription(null);
searchParams.setOwnedResourcesOnly(false); searchParams.setOwnedResourcesOnly(false);
searchParams.setResourceUsage(ResourceUsage.all);
} }
} else if(userSearchCtr == source) { } else if(userSearchCtr == source) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -488,6 +495,11 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -488,6 +495,11 @@ public class AuthorListController extends FormBasicController implements Activat
toolsCalloutCtrl.deactivate(); toolsCalloutCtrl.deactivate();
cleanUp(); cleanUp();
} }
} else if(referencesCtrl == source) {
if(event == Event.DONE_EVENT) {
toolsCalloutCtrl.deactivate();
cleanUp();
}
} else if(closeCtrl == source) { } else if(closeCtrl == source) {
if(event == Event.CANCELLED_EVENT) { if(event == Event.CANCELLED_EVENT) {
cmc.deactivate(); cmc.deactivate();
...@@ -588,6 +600,9 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -588,6 +600,9 @@ public class AuthorListController extends FormBasicController implements Activat
} else if("tools".equals(cmd)) { } else if("tools".equals(cmd)) {
AuthoringEntryRow row = (AuthoringEntryRow)link.getUserObject(); AuthoringEntryRow row = (AuthoringEntryRow)link.getUserObject();
doOpenTools(ureq, row, link); doOpenTools(ureq, row, link);
} else if("references".equals(cmd)) {
AuthoringEntryRow row = (AuthoringEntryRow)link.getUserObject();
doOpenReferences(ureq, row, link);
} }
} else if(source == tableEl) { } else if(source == tableEl) {
if(event instanceof SelectionEvent) { if(event instanceof SelectionEvent) {
...@@ -649,6 +664,25 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -649,6 +664,25 @@ public class AuthorListController extends FormBasicController implements Activat
} }
} }
private void doOpenReferences(UserRequest ureq, AuthoringEntryRow row, FormLink link) {
removeAsListenerAndDispose(toolsCtrl);
removeAsListenerAndDispose(toolsCalloutCtrl);
RepositoryEntry entry = repositoryService.loadByKey(row.getKey());
if(entry == null) {
tableEl.reloadData();
showWarning("repositoryentry.not.existing");
} else {
referencesCtrl = new ReferencesController(ureq, getWindowControl(), entry);
listenTo(referencesCtrl);
toolsCalloutCtrl = new CloseableCalloutWindowController(ureq, getWindowControl(),
referencesCtrl.getInitialComponent(), link.getFormDispatchId(), "", true, "");
listenTo(toolsCalloutCtrl);
toolsCalloutCtrl.activate();
}
}
private void doImport(UserRequest ureq) { private void doImport(UserRequest ureq) {
if(importCtrl != null) return; if(importCtrl != null) return;
...@@ -720,6 +754,7 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -720,6 +754,7 @@ public class AuthorListController extends FormBasicController implements Activat
searchParams.setIdAndRefs(se.getId()); searchParams.setIdAndRefs(se.getId());
searchParams.setAuthor(se.getAuthor()); searchParams.setAuthor(se.getAuthor());
searchParams.setOwnedResourcesOnly(se.isOwnedResourcesOnly()); searchParams.setOwnedResourcesOnly(se.isOwnedResourcesOnly());
searchParams.setResourceUsage(se.getResourceUsage());
searchParams.setDisplayname(se.getDisplayname()); searchParams.setDisplayname(se.getDisplayname());
searchParams.setDescription(se.getDescription()); searchParams.setDescription(se.getDescription());
tableEl.reset(true, true, true); tableEl.reset(true, true, true);
...@@ -989,6 +1024,13 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -989,6 +1024,13 @@ public class AuthorListController extends FormBasicController implements Activat
} }
} }
private void launch(UserRequest ureq, RepositoryEntryRef ref) {
String businessPath = "[RepositoryEntry:" + ref.getKey() + "]";
if(!NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl())) {
tableEl.reloadData();
}
}
private void launchCatalog(UserRequest ureq, RepositoryEntryRef ref) { private void launchCatalog(UserRequest ureq, RepositoryEntryRef ref) {
String businessPath = "[RepositoryEntry:" + ref.getKey() + "][Catalog:0]"; String businessPath = "[RepositoryEntry:" + ref.getKey() + "][Catalog:0]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl()); NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
...@@ -1055,6 +1097,57 @@ public class AuthorListController extends FormBasicController implements Activat ...@@ -1055,6 +1097,57 @@ public class AuthorListController extends FormBasicController implements Activat
toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg"); toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
toolsLink.setUserObject(row); toolsLink.setUserObject(row);
row.setToolsLink(toolsLink); row.setToolsLink(toolsLink);
//references
if(row.getNumOfReferences() > 0) {
String numOfReferences = Integer.toString(row.getNumOfReferences());
FormLink referencesLink = uifactory.addFormLink("tools_" + counter.incrementAndGet(), "references", numOfReferences, null, null, Link.NONTRANSLATED);
referencesLink.setUserObject(row);
row.setReferencesLink(referencesLink);
}
}
private class ReferencesController extends BasicController {
@Autowired
private ReferenceManager referenceManager;
public ReferencesController(UserRequest ureq, WindowControl wControl, RepositoryEntry entry) {
super(ureq, wControl);
setTranslator(AuthorListController.this.getTranslator());
VelocityContainer mainVC = createVelocityContainer("references");
List<RepositoryEntry> refs = referenceManager.getRepositoryReferencesTo(entry.getOlatResource());
List<String> refLinks = new ArrayList<>(refs.size());
for(RepositoryEntry ref:refs) {
String name = "ref-" + counter.incrementAndGet();
Link refLink = LinkFactory.createLink(name, "reference", getTranslator(), mainVC, this, Link.NONTRANSLATED);
refLink.setCustomDisplayText(StringHelper.escapeHtml(ref.getDisplayname()));
refLink.setUserObject(ref);
refLink.setIconLeftCSS("o_icon o_icon-fw " + RepositoyUIFactory.getIconCssClass(ref));
refLinks.add(name);
}
mainVC.contextPut("referenceLinks", refLinks);
putInitialPanel(mainVC);
}
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if(source instanceof Link) {
fireEvent(ureq, Event.DONE_EVENT);
Link link = (Link)source;
if("reference".equals(link.getCommand())) {
RepositoryEntryRef uobject = (RepositoryEntryRef)link.getUserObject();
launch(ureq, uobject);
}
}
}
@Override
protected void doDispose() {
//
}
} }
private class ToolsController extends BasicController { private class ToolsController extends BasicController {
......
...@@ -44,6 +44,7 @@ import org.olat.core.util.Util; ...@@ -44,6 +44,7 @@ import org.olat.core.util.Util;
import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryManager;
import org.olat.repository.handlers.RepositoryHandlerFactory; import org.olat.repository.handlers.RepositoryHandlerFactory;
import org.olat.repository.handlers.RepositoryHandlerFactory.OrderedRepositoryHandler; import org.olat.repository.handlers.RepositoryHandlerFactory.OrderedRepositoryHandler;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.ResourceUsage;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
...@@ -55,12 +56,14 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -55,12 +56,14 @@ import org.springframework.beans.factory.annotation.Autowired;
public class AuthorSearchController extends FormBasicController implements ExtendedFlexiTableSearchController { public class AuthorSearchController extends FormBasicController implements ExtendedFlexiTableSearchController {
private static final String[] keys = new String[]{ "my" }; private static final String[] keys = new String[]{ "my" };
private static final String[] usageKeys = new String[]{ ResourceUsage.all.name(), ResourceUsage.used.name(), ResourceUsage.notUsed.name() };
private TextElement id; // only for admins private TextElement id; // only for admins
private TextElement displayName; private TextElement displayName;
private TextElement author; private TextElement author;
private TextElement description; private TextElement description;
private SingleSelection types; private SingleSelection types;
private SingleSelection resourceUsageEl;
private MultipleSelectionElement ownedResourcesOnlyEl; private MultipleSelectionElement ownedResourcesOnlyEl;
private FormLink searchButton; private FormLink searchButton;
...@@ -117,6 +120,14 @@ public class AuthorSearchController extends FormBasicController implements Exten ...@@ -117,6 +120,14 @@ public class AuthorSearchController extends FormBasicController implements Exten
ownedResourcesOnlyEl = uifactory.addCheckboxesHorizontal("cif_my", "cif.owned.resources.only", rightContainer, keys, new String[]{ "" }); ownedResourcesOnlyEl = uifactory.addCheckboxesHorizontal("cif_my", "cif.owned.resources.only", rightContainer, keys, new String[]{ "" });
ownedResourcesOnlyEl.select(keys[0], true); ownedResourcesOnlyEl.select(keys[0], true);
String[] usageValues = new String[] {
translate("cif.owned.resources.usage.all"),
translate("cif.owned.resources.usage.used"),
translate("cif.owned.resources.usage.notUsed")
};
resourceUsageEl = uifactory.addRadiosHorizontal("cif_used", "cif.owned.resources.usage", rightContainer, usageKeys, usageValues);
resourceUsageEl.select(usageKeys[0], true);
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator()); FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout); formLayout.add(buttonLayout);
searchButton = uifactory.addFormLink("search", buttonLayout, Link.BUTTON); searchButton = uifactory.addFormLink("search", buttonLayout, Link.BUTTON);
...@@ -132,6 +143,9 @@ public class AuthorSearchController extends FormBasicController implements Exten ...@@ -132,6 +143,9 @@ public class AuthorSearchController extends FormBasicController implements Exten
author.setValue(se.getAuthor()); author.setValue(se.getAuthor());
ownedResourcesOnlyEl.select(keys[0], se.isOwnedResourcesOnly()); ownedResourcesOnlyEl.select(keys[0], se.isOwnedResourcesOnly());
description.setValue(se.getDescription()); description.setValue(se.getDescription());
if(se.getResourceUsage() != null) {
resourceUsageEl.select(se.getResourceUsage().name(), true);
}
String type = se.getType(); String type = se.getType();
if(StringHelper.containsNonWhitespace(type)) { if(StringHelper.containsNonWhitespace(type)) {
...@@ -197,6 +211,13 @@ public class AuthorSearchController extends FormBasicController implements Exten ...@@ -197,6 +211,13 @@ public class AuthorSearchController extends FormBasicController implements Exten
return ownedResourcesOnlyEl.isAtLeastSelected(1); return ownedResourcesOnlyEl.isAtLeastSelected(1);
} }
public ResourceUsage getResourceUsage() {
if(resourceUsageEl.isOneSelected()) {
return ResourceUsage.valueOf(resourceUsageEl.getSelectedKey());
}
return ResourceUsage.all;
}
@Override @Override
public void setEnabled(boolean enable) { public void setEnabled(boolean enable) {
this.enabled = enable; this.enabled = enable;
...@@ -242,6 +263,7 @@ public class AuthorSearchController extends FormBasicController implements Exten ...@@ -242,6 +263,7 @@ public class AuthorSearchController extends FormBasicController implements Exten
e.setDescription(getDescription()); e.setDescription(getDescription());
e.setType(getRestrictedType()); e.setType(getRestrictedType());
e.setOwnedResourcesOnly(isOwnedResourcesOnly()); e.setOwnedResourcesOnly(isOwnedResourcesOnly());
e.setResourceUsage(getResourceUsage());
fireEvent(ureq, e); fireEvent(ureq, e);
} }
......
...@@ -85,6 +85,12 @@ class AuthoringEntryDataModel extends DefaultFlexiTableDataSourceModel<Authoring ...@@ -85,6 +85,12 @@ class AuthoringEntryDataModel extends DefaultFlexiTableDataSourceModel<Authoring
case deletedBy: return item.getDeletedByFullName(); case deletedBy: return item.getDeletedByFullName();
case deletionDate: return item.getDeletionDate(); case deletionDate: return item.getDeletionDate();
case mark: return item.getMarkLink(); case mark: return item.getMarkLink();
case references: {
if(item.getNumOfReferences() <= 0) {
return null;
}
return item.getReferencesLink();
}
case detailsSupported: { case detailsSupported: {
RepositoryHandler handler = handlerFactory.getRepositoryHandler(item.getResourceType()); RepositoryHandler handler = handlerFactory.getRepositoryHandler(item.getResourceType());
return (handler != null) ? Boolean.TRUE : Boolean.FALSE; return (handler != null) ? Boolean.TRUE : Boolean.FALSE;
...@@ -125,6 +131,7 @@ class AuthoringEntryDataModel extends DefaultFlexiTableDataSourceModel<Authoring ...@@ -125,6 +131,7 @@ class AuthoringEntryDataModel extends DefaultFlexiTableDataSourceModel<Authoring
access("table.header.access"), access("table.header.access"),
creationDate("table.header.date"), creationDate("table.header.date"),
lastUsage("table.header.lastusage"), lastUsage("table.header.lastusage"),
references("table.header.references"),
deletedBy("table.header.deletedby"), deletedBy("table.header.deletedby"),
deletionDate("table.header.deletiondate"), deletionDate("table.header.deletiondate"),
mark("table.header.mark"), mark("table.header.mark"),
......
...@@ -68,6 +68,8 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig ...@@ -68,6 +68,8 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
private Date lifecycleStart; private Date lifecycleStart;
private Date lifecycleEnd; private Date lifecycleEnd;
private int numOfReferences;
private final String deletedByFullName; private final String deletedByFullName;
private final Date deletionDate; private final Date deletionDate;
...@@ -77,6 +79,7 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig ...@@ -77,6 +79,7 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
private FormLink markLink; private FormLink markLink;
private FormLink toolsLink; private FormLink toolsLink;
private FormLink referencesLink;
public AuthoringEntryRow(RepositoryEntryAuthorView view, String fullnameAuthor) { public AuthoringEntryRow(RepositoryEntryAuthorView view, String fullnameAuthor) {
key = view.getKey(); key = view.getKey();
...@@ -119,6 +122,8 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig ...@@ -119,6 +122,8 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
} }
} }
numOfReferences = view.getNumOfReferences();
deletedByFullName = view.getDeletedByFullName(); deletedByFullName = view.getDeletedByFullName();
deletionDate = view.getDeletionDate(); deletionDate = view.getDeletionDate();
} }
...@@ -204,6 +209,10 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig ...@@ -204,6 +209,10 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
public Date getLifecycleEnd() { public Date getLifecycleEnd() {
return lifecycleEnd; return lifecycleEnd;
} }
public int getNumOfReferences() {
return numOfReferences;
}
public String getDeletedByFullName() { public String getDeletedByFullName() {
return deletedByFullName; return deletedByFullName;
...@@ -282,6 +291,14 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig ...@@ -282,6 +291,14 @@ public class AuthoringEntryRow implements RepositoryEntryRef, RepositoryEntryLig
this.toolsLink = toolsLink; this.toolsLink = toolsLink;
} }
public FormLink getReferencesLink() {
return referencesLink;
}
public void setReferencesLink(FormLink referencesLink) {
this.referencesLink = referencesLink;
}
@Override @Override
public int hashCode() { public int hashCode() {
return key == null ? -79224867 : key.hashCode(); return key == null ? -79224867 : key.hashCode();
......
...@@ -21,6 +21,7 @@ package org.olat.repository.ui.author; ...@@ -21,6 +21,7 @@ package org.olat.repository.ui.author;
import org.olat.core.gui.control.Event; import org.olat.core.gui.control.Event;
import org.olat.core.id.context.StateEntry; import org.olat.core.id.context.StateEntry;
import org.olat.repository.model.SearchAuthorRepositoryEntryViewParams.ResourceUsage;
/** /**
* *
...@@ -38,6 +39,7 @@ public class SearchEvent extends Event implements StateEntry { ...@@ -38,6 +39,7 @@ public class SearchEvent extends Event implements StateEntry {
private String description; private String description;
private String type; private String type;
private boolean ownedResourcesOnly; private boolean ownedResourcesOnly;
private ResourceUsage resourceUsage;
public SearchEvent() { public SearchEvent() {
super("re-search"); super("re-search");
...@@ -92,6 +94,14 @@ public class SearchEvent extends Event implements StateEntry { ...@@ -92,6 +94,14 @@ public class SearchEvent extends Event implements StateEntry {
this.ownedResourcesOnly = ownedResourcesOnly; this.ownedResourcesOnly = ownedResourcesOnly;
} }
public ResourceUsage getResourceUsage() {
return resourceUsage;
}
public void setResourceUsage(ResourceUsage resourceUsage) {
this.resourceUsage = resourceUsage;
}
@Override @Override
public SearchEvent clone() { public SearchEvent clone() {
SearchEvent clone = new SearchEvent(); SearchEvent clone = new SearchEvent();
...@@ -101,6 +111,7 @@ public class SearchEvent extends Event implements StateEntry { ...@@ -101,6 +111,7 @@ public class SearchEvent extends Event implements StateEntry {
clone.description = description; clone.description = description;
clone.type = type; clone.type = type;
clone.ownedResourcesOnly = ownedResourcesOnly; clone.ownedResourcesOnly = ownedResourcesOnly;
clone.resourceUsage = resourceUsage;
return clone; return clone;
} }
} }
$r.translate("details.referenceinfo.txt")
<ul class="o_dropdown list-unstyled">
#foreach($referenceLink in $referenceLinks)
<li>$r.render($referenceLink)</li>
#end
</ul>
\ 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