CCM NG:
First part of category administration UI for /ccm/admin/ git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4021 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
19cdc820a8
commit
b14529823b
|
|
@ -29,6 +29,7 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
import com.arsdigita.templating.Templating;
|
import com.arsdigita.templating.Templating;
|
||||||
import com.arsdigita.ui.SiteBanner;
|
import com.arsdigita.ui.SiteBanner;
|
||||||
import com.arsdigita.ui.UserBanner;
|
import com.arsdigita.ui.UserBanner;
|
||||||
|
import com.arsdigita.ui.admin.categories.CategoriesTab;
|
||||||
import com.arsdigita.web.BaseApplicationServlet;
|
import com.arsdigita.web.BaseApplicationServlet;
|
||||||
import com.arsdigita.web.LoginSignal;
|
import com.arsdigita.web.LoginSignal;
|
||||||
import com.arsdigita.xml.Document;
|
import com.arsdigita.xml.Document;
|
||||||
|
|
@ -125,7 +126,7 @@ public class AdminServlet
|
||||||
tabbedPane.addTab(
|
tabbedPane.addTab(
|
||||||
new Label(new GlobalizedMessage("ui.admin.tab.categories.title",
|
new Label(new GlobalizedMessage("ui.admin.tab.categories.title",
|
||||||
BUNDLE_NAME)),
|
BUNDLE_NAME)),
|
||||||
new CategoriesAdminTab());
|
new CategoriesTab());
|
||||||
|
|
||||||
tabbedPane.addTab(
|
tabbedPane.addTab(
|
||||||
new Label(new GlobalizedMessage("ui.admin.tab.workflows.title",
|
new Label(new GlobalizedMessage("ui.admin.tab.workflows.title",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class CategoriesAdminTab extends LayoutPanel {
|
public class CategoriesAdminTab extends LayoutPanel {
|
||||||
|
|
||||||
public CategoriesAdminTab() {
|
public CategoriesAdminTab() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package com.arsdigita.ui.admin.categories;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
|
import com.arsdigita.bebop.SegmentedPanel;
|
||||||
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||||
|
|
||||||
|
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class CategoriesTab extends LayoutPanel {
|
||||||
|
|
||||||
|
protected static final String DOMAINS_FILTER = "domainsFilter";
|
||||||
|
|
||||||
|
private final StringParameter domainIdParameter;
|
||||||
|
private final ParameterSingleSelectionModel<String> selectedDomainId;
|
||||||
|
|
||||||
|
private final Label domainsFilterFormHeader;
|
||||||
|
private final Form domainsFilterForm;
|
||||||
|
private final BoxPanel domainsTablePanel;
|
||||||
|
|
||||||
|
private final DomainForm domainForm;
|
||||||
|
|
||||||
|
public CategoriesTab() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
setClassAttr("sidebarNavPanel");
|
||||||
|
|
||||||
|
domainIdParameter = new StringParameter("selected_domain_id");
|
||||||
|
selectedDomainId = new ParameterSingleSelectionModel<>(domainIdParameter);
|
||||||
|
|
||||||
|
domainsFilterFormHeader = new Label(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domains.table.filter.header",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
domainsFilterForm = new Form("domainFilterForm");
|
||||||
|
final TextField domainsFilter = new TextField(DOMAINS_FILTER);
|
||||||
|
domainsFilterForm.add(domainsFilter);
|
||||||
|
domainsFilterForm.add(new Submit(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domains.table.filter", ADMIN_BUNDLE)));
|
||||||
|
final ActionLink clearLink = new ActionLink(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domains.table.filter.clear",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
clearLink.addActionListener(e -> {
|
||||||
|
final PageState state = e.getPageState();
|
||||||
|
domainsFilter.setValue(state, null);
|
||||||
|
});
|
||||||
|
domainsFilterForm.add(clearLink);
|
||||||
|
|
||||||
|
final SegmentedPanel left = new SegmentedPanel();
|
||||||
|
left.addSegment(domainsFilterFormHeader, domainsFilterForm);
|
||||||
|
|
||||||
|
setLeft(left);
|
||||||
|
|
||||||
|
final BoxPanel body = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
|
|
||||||
|
final DomainsTable domainsTable = new DomainsTable(
|
||||||
|
selectedDomainId, domainsFilter);
|
||||||
|
domainsTable.setStyleAttr("min-width: 30em;");
|
||||||
|
domainsTablePanel = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
|
domainsTablePanel.add(domainsTable);
|
||||||
|
final ActionLink addDomain = new ActionLink(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domains.create_new", ADMIN_BUNDLE));
|
||||||
|
addDomain.addActionListener(e -> {
|
||||||
|
showNewDomainForm(e.getPageState());
|
||||||
|
});
|
||||||
|
domainsTablePanel.add(addDomain);
|
||||||
|
|
||||||
|
body.add(domainsTablePanel);
|
||||||
|
|
||||||
|
domainForm = new DomainForm(this, selectedDomainId);
|
||||||
|
body.add(domainForm);
|
||||||
|
|
||||||
|
setBody(body);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(final Page page) {
|
||||||
|
super.register(page);
|
||||||
|
|
||||||
|
page.addGlobalStateParam(domainIdParameter);
|
||||||
|
|
||||||
|
page.setVisibleDefault(domainsFilterFormHeader, true);
|
||||||
|
page.setVisibleDefault(domainsFilterForm, true);
|
||||||
|
page.setVisibleDefault(domainsTablePanel, true);
|
||||||
|
page.setVisibleDefault(domainForm, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showDomainsTable(final PageState state) {
|
||||||
|
domainsFilterFormHeader.setVisible(state, true);
|
||||||
|
domainsFilterForm.setVisible(state, true);
|
||||||
|
domainsTablePanel.setVisible(state, true);
|
||||||
|
domainForm.setVisible(state, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showNewDomainForm(final PageState state) {
|
||||||
|
domainsFilterFormHeader.setVisible(state, false);
|
||||||
|
domainsFilterForm.setVisible(state, false);
|
||||||
|
domainsTablePanel.setVisible(state, false);
|
||||||
|
domainForm.setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void hideNewDomainForm(final PageState state) {
|
||||||
|
domainsFilterFormHeader.setVisible(state, true);
|
||||||
|
domainsFilterForm.setVisible(state, true);
|
||||||
|
domainsTablePanel.setVisible(state, true);
|
||||||
|
domainForm.setVisible(state, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package com.arsdigita.ui.admin.categories;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.form.Date;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import org.libreccm.categorization.Domain;
|
||||||
|
import org.libreccm.categorization.DomainRepository;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
|
||||||
|
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class DomainForm extends Form {
|
||||||
|
|
||||||
|
private static final String RELEASED = "released";
|
||||||
|
private static final String VERSION = "version";
|
||||||
|
private static final String DOMAIN_URI = "domainUri";
|
||||||
|
private static final String DOMAIN_KEY = "domainKey";
|
||||||
|
|
||||||
|
private final ParameterSingleSelectionModel<String> selectedDomainId;
|
||||||
|
|
||||||
|
private final TextField domainKey;
|
||||||
|
private final TextField domainUri;
|
||||||
|
private final TextField version;
|
||||||
|
private final Date released;
|
||||||
|
private final SaveCancelSection saveCancelSection;
|
||||||
|
|
||||||
|
public DomainForm(
|
||||||
|
final CategoriesTab categoriesTab,
|
||||||
|
final ParameterSingleSelectionModel<String> selectedDomainId) {
|
||||||
|
super("domainForm");
|
||||||
|
|
||||||
|
this.selectedDomainId = selectedDomainId;
|
||||||
|
|
||||||
|
final Label heading = new Label(e -> {
|
||||||
|
final PageState state = e.getPageState();
|
||||||
|
final Label target = (Label) e.getTarget();
|
||||||
|
if (selectedDomainId.getSelectedKey(state) == null) {
|
||||||
|
target.setLabel(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domain_form.heading.create_new",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
} else {
|
||||||
|
final DomainRepository domainRepository = CdiUtil.
|
||||||
|
createCdiUtil().findBean(DomainRepository.class);
|
||||||
|
final Domain domain = domainRepository.findById(Long.parseLong(
|
||||||
|
selectedDomainId.getSelectedKey(state)));
|
||||||
|
target.setLabel(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domain_form.heading.edit",
|
||||||
|
ADMIN_BUNDLE,
|
||||||
|
new String[]{domain.getDomainKey()}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
heading.setClassAttr("heading");
|
||||||
|
add(heading);
|
||||||
|
|
||||||
|
domainKey = new TextField(DOMAIN_KEY);
|
||||||
|
domainKey.setLabel(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domain_form.fields.domain_key",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
add(domainKey);
|
||||||
|
|
||||||
|
domainUri = new TextField(DOMAIN_URI);
|
||||||
|
domainUri.setLabel(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domain_form.fields.domain_uri",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
add(domainUri);
|
||||||
|
|
||||||
|
version = new TextField(VERSION);
|
||||||
|
version.setLabel(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domain_form.fields.version",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
add(version);
|
||||||
|
|
||||||
|
released = new Date(RELEASED);
|
||||||
|
released.setLabel(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domain_form.fields.released",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
add(released);
|
||||||
|
|
||||||
|
saveCancelSection = new SaveCancelSection();
|
||||||
|
add(saveCancelSection);
|
||||||
|
|
||||||
|
addValidationListener(e -> {
|
||||||
|
});
|
||||||
|
|
||||||
|
addProcessListener(e -> {
|
||||||
|
final PageState state = e.getPageState();
|
||||||
|
|
||||||
|
categoriesTab.hideNewDomainForm(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,255 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package com.arsdigita.ui.admin.categories;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.Text;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.logging.log4j.util.Strings;
|
||||||
|
import org.libreccm.categorization.Domain;
|
||||||
|
import org.libreccm.categorization.DomainRepository;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.configuration.ConfigurationConstants;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
|
||||||
|
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class DomainsTable extends Table {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LogManager.getLogger(
|
||||||
|
DomainsTable.class);
|
||||||
|
|
||||||
|
private static final int COL_DOMAIN_KEY = 0;
|
||||||
|
private static final int COL_DOMAIN_URI = 1;
|
||||||
|
private static final int COL_DOMAIN_TITLE = 2;
|
||||||
|
private static final int COL_DOMAIN_DEL = 3;
|
||||||
|
|
||||||
|
private final ParameterSingleSelectionModel<String> selectedDomainId;
|
||||||
|
|
||||||
|
private final TextField domainsFilter;
|
||||||
|
|
||||||
|
public DomainsTable(
|
||||||
|
final ParameterSingleSelectionModel<String> selectedDomainId,
|
||||||
|
final TextField domainsFilter) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
setIdAttr("domainsTable");
|
||||||
|
|
||||||
|
this.selectedDomainId = selectedDomainId;
|
||||||
|
this.domainsFilter = domainsFilter;
|
||||||
|
|
||||||
|
setEmptyView(new Label(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domains.none",
|
||||||
|
ADMIN_BUNDLE)));
|
||||||
|
|
||||||
|
final TableColumnModel columnModel = getColumnModel();
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
COL_DOMAIN_KEY,
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
"ui,admin.categories.domains.table.col_key",
|
||||||
|
ADMIN_BUNDLE))));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
COL_DOMAIN_URI,
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
"ui,admin.categories.domains.table.col_uri",
|
||||||
|
ADMIN_BUNDLE))));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
COL_DOMAIN_TITLE,
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
"ui,admin.categories.domains.table.col_title",
|
||||||
|
ADMIN_BUNDLE))));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
COL_DOMAIN_DEL,
|
||||||
|
new Label(new GlobalizedMessage(
|
||||||
|
"ui,admin.categories.domains.table.col_del",
|
||||||
|
ADMIN_BUNDLE))));
|
||||||
|
|
||||||
|
columnModel.get(COL_DOMAIN_TITLE).setCellRenderer(
|
||||||
|
new TableCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getComponent(final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column) {
|
||||||
|
final LocalizedString title = (LocalizedString) value;
|
||||||
|
final GlobalizationHelper globalizationHelper = CdiUtil.
|
||||||
|
createCdiUtil().findBean(GlobalizationHelper.class);
|
||||||
|
return new Text(title.getValue(globalizationHelper.
|
||||||
|
getNegotiatedLocale()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
columnModel.get(COL_DOMAIN_DEL).setCellRenderer(
|
||||||
|
new TableCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getComponent(final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column) {
|
||||||
|
if (value == null) {
|
||||||
|
return new Text("");
|
||||||
|
} else {
|
||||||
|
final ControlLink link = new ControlLink((Component) value);
|
||||||
|
link.setConfirmation(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domains.table.del_confirm",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addTableActionListener(new TableActionListener() {
|
||||||
|
@Override
|
||||||
|
public void cellSelected(final TableActionEvent event) {
|
||||||
|
//ToDo
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(final TableActionEvent event) {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setModelBuilder(new DomainsTableModelBuilder());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DomainsTableModelBuilder extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableModel makeModel(final Table table,
|
||||||
|
final PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
|
||||||
|
return new DomainsTableModel(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DomainsTableModel implements TableModel {
|
||||||
|
|
||||||
|
private final List<Domain> domains;
|
||||||
|
private int index = -1;
|
||||||
|
|
||||||
|
public DomainsTableModel(final PageState state) {
|
||||||
|
LOGGER.debug("Creating DomainsTableModel");
|
||||||
|
final String filterTerm = (String) domainsFilter.getValue(state);
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final DomainRepository domainRepository = cdiUtil.findBean(
|
||||||
|
DomainRepository.class);
|
||||||
|
if (Strings.isBlank(filterTerm)) {
|
||||||
|
domains = domainRepository.findAll();
|
||||||
|
LOGGER.debug("Found {} domains in the database.",
|
||||||
|
domains.size());
|
||||||
|
} else {
|
||||||
|
domains = domainRepository.search(filterTerm);
|
||||||
|
LOGGER.debug("Found {} domain which match the "
|
||||||
|
+ "filter \"{}\".",
|
||||||
|
domains.size(),
|
||||||
|
filterTerm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
index++;
|
||||||
|
return index < domains.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(final int columnIndex) {
|
||||||
|
LOGGER.debug("Getting element for index {}, column {}...",
|
||||||
|
index,
|
||||||
|
columnIndex);
|
||||||
|
final Domain domain = domains.get(index);
|
||||||
|
switch (columnIndex) {
|
||||||
|
case COL_DOMAIN_KEY:
|
||||||
|
return domain.getDomainKey();
|
||||||
|
case COL_DOMAIN_URI:
|
||||||
|
return domain.getUri();
|
||||||
|
case COL_DOMAIN_TITLE:
|
||||||
|
return domain.getTitle();
|
||||||
|
case COL_DOMAIN_DEL:
|
||||||
|
if (isDeleteable(domain)) {
|
||||||
|
return new Label(new GlobalizedMessage(
|
||||||
|
"ui.admin.categories.domains.table.del",
|
||||||
|
ADMIN_BUNDLE));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Not a valid column index");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(final int columnIndex) {
|
||||||
|
return domains.get(index).getUuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isDeleteable(final Domain domain) {
|
||||||
|
if (ConfigurationConstants.REGISTRY_DOMAIN.equals(domain.
|
||||||
|
getDomainKey())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (domain.getOwners() != null && !domain.getOwners().isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -76,20 +76,26 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
@NamedQuery(name = "Domain.findByKey",
|
@NamedQuery(name = "Domain.findByKey",
|
||||||
query = "SELECT d FROM Domain d WHERE d.domainKey = :key"),
|
query = "SELECT d FROM Domain d WHERE d.domainKey = :key"),
|
||||||
@NamedQuery(name = "Domain.findByUri",
|
@NamedQuery(name = "Domain.findByUri",
|
||||||
query = "SELECT d FROM Domain d WHERE d.uri = :uri")
|
query = "SELECT d FROM Domain d WHERE d.uri = :uri"),
|
||||||
|
@NamedQuery(
|
||||||
|
name = "Domain.search",
|
||||||
|
query
|
||||||
|
= "SELECT d FROM Domain d "
|
||||||
|
+ "WHERE d.domainKey LIKE CONCAT (LOWER(:term), '%') "
|
||||||
|
+ "OR d.uri LIKE CONCAT (LOWER(:term), '%')")
|
||||||
})
|
})
|
||||||
@NamedEntityGraphs({
|
@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "Domain.allCategories",
|
name = "Domain.allCategories",
|
||||||
attributeNodes = {
|
attributeNodes = {
|
||||||
@NamedAttributeNode(value = "root",
|
@NamedAttributeNode(value = "root",
|
||||||
subgraph = "subCategories")},
|
subgraph = "subCategories")},
|
||||||
subgraphs = {
|
subgraphs = {
|
||||||
@NamedSubgraph(
|
@NamedSubgraph(
|
||||||
name = "subCategories",
|
name = "subCategories",
|
||||||
attributeNodes = {
|
attributeNodes = {
|
||||||
@NamedAttributeNode("subCategories")
|
@NamedAttributeNode("subCategories")
|
||||||
})})
|
})})
|
||||||
})
|
})
|
||||||
@DefaultEntityGraph("Domain.allCategories")
|
@DefaultEntityGraph("Domain.allCategories")
|
||||||
@XmlRootElement(name = "domain", namespace = CAT_XML_NS)
|
@XmlRootElement(name = "domain", namespace = CAT_XML_NS)
|
||||||
|
|
@ -131,11 +137,11 @@ public class Domain extends CcmObject implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Embedded
|
@Embedded
|
||||||
@AssociationOverride(
|
@AssociationOverride(
|
||||||
name = "values",
|
name = "values",
|
||||||
joinTable = @JoinTable(name = "DOMAIN_TITLES",
|
joinTable = @JoinTable(name = "DOMAIN_TITLES",
|
||||||
schema = DB_SCHEMA,
|
schema = DB_SCHEMA,
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}))
|
@JoinColumn(name = "OBJECT_ID")}))
|
||||||
@XmlElement(name = "title", namespace = CAT_XML_NS)
|
@XmlElement(name = "title", namespace = CAT_XML_NS)
|
||||||
private LocalizedString title;
|
private LocalizedString title;
|
||||||
|
|
||||||
|
|
@ -144,11 +150,11 @@ public class Domain extends CcmObject implements Serializable {
|
||||||
*/
|
*/
|
||||||
@Embedded
|
@Embedded
|
||||||
@AssociationOverride(
|
@AssociationOverride(
|
||||||
name = "values",
|
name = "values",
|
||||||
joinTable = @JoinTable(name = "DOMAIN_DESCRIPTIONS",
|
joinTable = @JoinTable(name = "DOMAIN_DESCRIPTIONS",
|
||||||
schema = DB_SCHEMA,
|
schema = DB_SCHEMA,
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}))
|
@JoinColumn(name = "OBJECT_ID")}))
|
||||||
@XmlElement(name = "description", namespace = CAT_XML_NS)
|
@XmlElement(name = "description", namespace = CAT_XML_NS)
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
|
|
@ -363,19 +369,19 @@ public class Domain extends CcmObject implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
public String toString(final String data) {
|
public String toString(final String data) {
|
||||||
return String.format(
|
return String.format(
|
||||||
", domainKey = \"%s\", "
|
", domainKey = \"%s\", "
|
||||||
+ "uri = \"%s\", "
|
+ "uri = \"%s\", "
|
||||||
+ "title = \"%s\", "
|
+ "title = \"%s\", "
|
||||||
+ "version = \"%s\", "
|
+ "version = \"%s\", "
|
||||||
+ "released = %tF %<tT, "
|
+ "released = %tF %<tT, "
|
||||||
+ "root = \"%s\"%s",
|
+ "root = \"%s\"%s",
|
||||||
domainKey,
|
domainKey,
|
||||||
Objects.toString(uri),
|
Objects.toString(uri),
|
||||||
Objects.toString(title),
|
Objects.toString(title),
|
||||||
version,
|
version,
|
||||||
released,
|
released,
|
||||||
Objects.toString(root),
|
Objects.toString(root),
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.libreccm.categorization;
|
||||||
import org.libreccm.core.AbstractEntityRepository;
|
import org.libreccm.core.AbstractEntityRepository;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
@ -89,5 +90,13 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
||||||
|
|
||||||
return query.getSingleResult();
|
return query.getSingleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Domain> search(final String term) {
|
||||||
|
final TypedQuery<Domain> query = entityManager.createNamedQuery(
|
||||||
|
"Domain.search", Domain.class);
|
||||||
|
query.setParameter("term", term);
|
||||||
|
|
||||||
|
return query.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -341,3 +341,20 @@ ui.admin.new_user_form.error.givenname.too_long=The given name of a user can't b
|
||||||
ui.admin.new_user_form.error.email.is_empty=The Email address of a user can't be empty.
|
ui.admin.new_user_form.error.email.is_empty=The Email address of a user can't be empty.
|
||||||
ui.admin.new_user_form.error.email.too_long=The Email address of a user can't be longer than 256 characters.
|
ui.admin.new_user_form.error.email.too_long=The Email address of a user can't be longer than 256 characters.
|
||||||
ui.admin.new_user_form.error.password.is_empty=The password of a new user can't be blank.
|
ui.admin.new_user_form.error.password.is_empty=The password of a new user can't be blank.
|
||||||
|
ui.admin.categories.domains.none=No domains available.
|
||||||
|
ui,admin.categories.domains.table.col_key=Key
|
||||||
|
ui,admin.categories.domains.table.col_uri=URI
|
||||||
|
ui,admin.categories.domains.table.col_title=Title
|
||||||
|
ui,admin.categories.domains.table.col_del=Delete
|
||||||
|
ui.admin.categories.domains.table.del_confirm=Are you sure to delete this domain?
|
||||||
|
ui.admin.categories.domains.table.del=Delete
|
||||||
|
ui.admin.categories.domains.table.filter=Apply
|
||||||
|
ui.admin.categories.domains.table.filter.header=Filter domains
|
||||||
|
ui.admin.categories.domains.table.filter.clear=Clear filter
|
||||||
|
ui.admin.categories.domains.create_new=Create new domain
|
||||||
|
ui.admin.categories.domain_form.heading.create_new=Create new domain
|
||||||
|
ui.admin.categories.domain_form.heading.edit=Edit properties of domain {0}
|
||||||
|
ui.admin.categories.domain_form.fields.domain_key=Key
|
||||||
|
ui.admin.categories.domain_form.fields.domain_uri=URI
|
||||||
|
ui.admin.categories.domain_form.fields.version=Version
|
||||||
|
ui.admin.categories.domain_form.fields.released=Released
|
||||||
|
|
|
||||||
|
|
@ -344,3 +344,20 @@ ui.admin.new_user_form.error.givenname.too_long=Der Vorname eines Benutzers darf
|
||||||
ui.admin.new_user_form.error.email.is_empty=Die E-Mail-Adresse eines Benutzers darf nicht leer sein.
|
ui.admin.new_user_form.error.email.is_empty=Die E-Mail-Adresse eines Benutzers darf nicht leer sein.
|
||||||
ui.admin.new_user_form.error.email.too_long=Die E-Mail-Adresse eines Benutzers darf nicht l\u00e4nger als 256 Zeichen sein.
|
ui.admin.new_user_form.error.email.too_long=Die E-Mail-Adresse eines Benutzers darf nicht l\u00e4nger als 256 Zeichen sein.
|
||||||
ui.admin.new_user_form.error.password.is_empty=Das Passwort eines Benutzers kann nicht leer sein.
|
ui.admin.new_user_form.error.password.is_empty=Das Passwort eines Benutzers kann nicht leer sein.
|
||||||
|
ui.admin.categories.domains.none=Keine passenden Domains gefunden.
|
||||||
|
ui,admin.categories.domains.table.col_key=Key
|
||||||
|
ui,admin.categories.domains.table.col_uri=URI
|
||||||
|
ui,admin.categories.domains.table.col_title=Titel
|
||||||
|
ui,admin.categories.domains.table.col_del=L\u00f6schen
|
||||||
|
ui.admin.categories.domains.table.del_confirm=Sind sie sicher, dass sie diese Domain l\u00f6schen wollen?
|
||||||
|
ui.admin.categories.domains.table.del=L\u00f6schen
|
||||||
|
ui.admin.categories.domains.table.filter=Anwenden
|
||||||
|
ui.admin.categories.domains.table.filter.header=Domains filtern
|
||||||
|
ui.admin.categories.domains.table.filter.clear=Filter zur\u00fccksetzen
|
||||||
|
ui.admin.categories.domains.create_new=Neue Domain anlegen
|
||||||
|
ui.admin.categories.domain_form.heading.create_new=Neue Domain anlegen
|
||||||
|
ui.admin.categories.domain_form.heading.edit=Eigenschaften der Domain {0} bearbeiten
|
||||||
|
ui.admin.categories.domain_form.fields.domain_key=Name
|
||||||
|
ui.admin.categories.domain_form.fields.domain_uri=URI
|
||||||
|
ui.admin.categories.domain_form.fields.version=Version
|
||||||
|
ui.admin.categories.domain_form.fields.released=Freigegeben
|
||||||
|
|
|
||||||
|
|
@ -317,3 +317,20 @@ ui.admin.new_user_form.error.givenname.too_long=The given name of a user can't b
|
||||||
ui.admin.new_user_form.error.email.is_empty=The Email address of a user can't be empty.
|
ui.admin.new_user_form.error.email.is_empty=The Email address of a user can't be empty.
|
||||||
ui.admin.new_user_form.error.email.too_long=The Email address of a user can't be longer than 256 characters.
|
ui.admin.new_user_form.error.email.too_long=The Email address of a user can't be longer than 256 characters.
|
||||||
ui.admin.new_user_form.error.password.is_empty=The password of a new user can't be blank.
|
ui.admin.new_user_form.error.password.is_empty=The password of a new user can't be blank.
|
||||||
|
ui.admin.categories.domains.none=No domains available.
|
||||||
|
ui,admin.categories.domains.table.col_key=Key
|
||||||
|
ui,admin.categories.domains.table.col_uri=URI
|
||||||
|
ui,admin.categories.domains.table.col_title=Title
|
||||||
|
ui,admin.categories.domains.table.col_del=Delete
|
||||||
|
ui.admin.categories.domains.table.del_confirm=Are you sure to delete this domain?
|
||||||
|
ui.admin.categories.domains.table.del=Delete
|
||||||
|
ui.admin.categories.domains.table.filter=Apply
|
||||||
|
ui.admin.categories.domains.table.filter.header=Filter domains
|
||||||
|
ui.admin.categories.domains.table.filter.clear=Clear filter
|
||||||
|
ui.admin.categories.domains.create_new=Create new domain
|
||||||
|
ui.admin.categories.domain_form.heading.create_new=Create new domain
|
||||||
|
ui.admin.categories.domain_form.heading.edit=Edit properties of domain {0}
|
||||||
|
ui.admin.categories.domain_form.fields.domain_key=Key
|
||||||
|
ui.admin.categories.domain_form.fields.domain_uri=URI
|
||||||
|
ui.admin.categories.domain_form.fields.version=Version
|
||||||
|
ui.admin.categories.domain_form.fields.released=Released
|
||||||
|
|
|
||||||
|
|
@ -308,3 +308,20 @@ ui.admin.new_user_form.error.givenname.too_long=The given name of a user can't b
|
||||||
ui.admin.new_user_form.error.email.is_empty=The Email address of a user can't be empty.
|
ui.admin.new_user_form.error.email.is_empty=The Email address of a user can't be empty.
|
||||||
ui.admin.new_user_form.error.email.too_long=The Email address of a user can't be longer than 256 characters.
|
ui.admin.new_user_form.error.email.too_long=The Email address of a user can't be longer than 256 characters.
|
||||||
ui.admin.new_user_form.error.password.is_empty=The password of a new user can't be blank.
|
ui.admin.new_user_form.error.password.is_empty=The password of a new user can't be blank.
|
||||||
|
ui.admin.categories.domains.none=No domains available.
|
||||||
|
ui,admin.categories.domains.table.col_key=Key
|
||||||
|
ui,admin.categories.domains.table.col_uri=URI
|
||||||
|
ui,admin.categories.domains.table.col_title=Title
|
||||||
|
ui,admin.categories.domains.table.col_del=Delete
|
||||||
|
ui.admin.categories.domains.table.del_confirm=Are you sure to delete this domain?
|
||||||
|
ui.admin.categories.domains.table.del=Delete
|
||||||
|
ui.admin.categories.domains.table.filter=Apply
|
||||||
|
ui.admin.categories.domains.table.filter.header=Filter domains
|
||||||
|
ui.admin.categories.domains.table.filter.clear=Clear filter
|
||||||
|
ui.admin.categories.domains.create_new=Create new domain
|
||||||
|
ui.admin.categories.domain_form.heading.create_new=Create new domain
|
||||||
|
ui.admin.categories.domain_form.heading.edit=Edit properties of domain {0}
|
||||||
|
ui.admin.categories.domain_form.fields.domain_key=Key
|
||||||
|
ui.admin.categories.domain_form.fields.domain_uri=URI
|
||||||
|
ui.admin.categories.domain_form.fields.version=Version
|
||||||
|
ui.admin.categories.domain_form.fields.released=Released
|
||||||
|
|
|
||||||
|
|
@ -768,7 +768,6 @@ input{
|
||||||
padding: 0.2em;
|
padding: 0.2em;
|
||||||
vertical-align: baseline;
|
vertical-align: baseline;
|
||||||
background-color: #fbfbfb;
|
background-color: #fbfbfb;
|
||||||
height:17.2px;
|
|
||||||
box-shadow: inset 0 0 3px rgba(74,74,74,0.5);
|
box-shadow: inset 0 0 3px rgba(74,74,74,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue