CCM NG: /ccm/admin: UI for managing mappings of a domain
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4029 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
3ebe0cfa7c
commit
1564f16678
|
|
@ -27,7 +27,6 @@ import com.arsdigita.bebop.PageState;
|
|||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
|
|
@ -43,7 +42,7 @@ import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainDescriptionForm extends Form {
|
||||
class DomainDescriptionForm extends Form {
|
||||
|
||||
private static final String LOCALIZED_DOMAIN_DESC = "description";
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainDescriptionTable extends Table {
|
||||
class DomainDescriptionTable extends Table {
|
||||
|
||||
private static final int COL_LOCALE = 0;
|
||||
private static final int COL_VALUE = 1;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import com.arsdigita.bebop.BoxPanel;
|
|||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.PropertySheet;
|
||||
|
|
@ -45,13 +44,12 @@ import java.util.Set;
|
|||
import java.util.TooManyListenersException;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
import static org.bouncycastle.asn1.x500.style.RFC4519Style.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainDetails extends SegmentedPanel {
|
||||
class DomainDetails extends SegmentedPanel {
|
||||
|
||||
private final CategoriesTab categoriesTab;
|
||||
private final ParameterSingleSelectionModel<String> selectedDomainId;
|
||||
|
|
@ -118,11 +116,15 @@ public class DomainDetails extends SegmentedPanel {
|
|||
ADMIN_BUNDLE)),
|
||||
descPanel);
|
||||
|
||||
final BoxPanel mappingsPanel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
mappingsPanel.add(new DomainMappingsTable(categoriesTab,
|
||||
selectedDomainId));
|
||||
mappingsPanel.add(new DomainMappingAddForm(selectedDomainId));
|
||||
addSegment(
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.mappings",
|
||||
ADMIN_BUNDLE)),
|
||||
new Text("domain_mappings_placeholder"));
|
||||
mappingsPanel);
|
||||
}
|
||||
|
||||
private class DomainTitleAddForm extends Form {
|
||||
|
|
|
|||
|
|
@ -35,15 +35,13 @@ import org.libreccm.categorization.DomainManager;
|
|||
import org.libreccm.categorization.DomainRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainForm extends Form {
|
||||
class DomainForm extends Form {
|
||||
|
||||
private static final String RELEASED = "released";
|
||||
private static final String VERSION = "version";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* 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.BoxPanel;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.Text;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import org.libreccm.categorization.Domain;
|
||||
import org.libreccm.categorization.DomainManager;
|
||||
import org.libreccm.categorization.DomainRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.web.ApplicationRepository;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class DomainMappingAddForm extends Form {
|
||||
|
||||
private static final String DOMAIN_MAPPING_OWNER = "domainMappingOwner";
|
||||
|
||||
public DomainMappingAddForm(
|
||||
final ParameterSingleSelectionModel<String> selectedDomainId) {
|
||||
|
||||
super("domainMappingAddForm", new BoxPanel(BoxPanel.HORIZONTAL));
|
||||
//
|
||||
// final Label heading = new Label(new GlobalizedMessage(
|
||||
// "ui.admin.categories.domain_details.mappings.add", ADMIN_BUNDLE));
|
||||
// heading.setClassAttr("heading");
|
||||
// add(heading);
|
||||
|
||||
final SingleSelect appSelect = new SingleSelect(DOMAIN_MAPPING_OWNER);
|
||||
appSelect.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.mappings.add", ADMIN_BUNDLE));
|
||||
try {
|
||||
appSelect.addPrintListener(e -> {
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ApplicationRepository appRepository = cdiUtil.findBean(
|
||||
ApplicationRepository.class);
|
||||
final DomainRepository domainRepository = cdiUtil.findBean(
|
||||
DomainRepository.class);
|
||||
final DomainManager domainManager = cdiUtil.findBean(
|
||||
DomainManager.class);
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(
|
||||
selectedDomainId.getSelectedKey(e.getPageState())),
|
||||
"Domain.withOwners");
|
||||
|
||||
final List<CcmApplication> applications = appRepository
|
||||
.findAll();
|
||||
|
||||
final SingleSelect target = (SingleSelect) e.getTarget();
|
||||
target.clearOptions();
|
||||
|
||||
target.addOption(new Option("0", new Text("")));
|
||||
|
||||
applications.forEach(a -> {
|
||||
if (!domainManager.isDomainOwner(a, domain)) {
|
||||
target.addOption(new Option(Long.toString(a
|
||||
.getObjectId()),
|
||||
new Text(a.getPrimaryUrl())));
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
add(appSelect);
|
||||
|
||||
add(new Submit(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.mappings.create", ADMIN_BUNDLE)));
|
||||
|
||||
addValidationListener(e -> {
|
||||
final PageState state = e.getPageState();
|
||||
final FormData data = e.getFormData();
|
||||
|
||||
final String appId = data.getString(DOMAIN_MAPPING_OWNER);
|
||||
if ("0".equals(appId)) {
|
||||
data.addError(
|
||||
DOMAIN_MAPPING_OWNER,
|
||||
new GlobalizedMessage(
|
||||
"ui.admin.categories.doamin_details.mappings.error"
|
||||
+ ".please_select_app",
|
||||
ADMIN_BUNDLE));
|
||||
}
|
||||
});
|
||||
|
||||
addProcessListener(e -> {
|
||||
final PageState state = e.getPageState();
|
||||
final FormData data = e.getFormData();
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final DomainRepository domainRepository = cdiUtil.findBean(
|
||||
DomainRepository.class);
|
||||
final DomainManager domainManager = cdiUtil.findBean(
|
||||
DomainManager.class);
|
||||
final ApplicationRepository appRepository = cdiUtil.findBean(
|
||||
ApplicationRepository.class);
|
||||
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)),
|
||||
"Domain.withOwners");
|
||||
final CcmApplication application = appRepository.findById(
|
||||
Long.parseLong(data.getString(DOMAIN_MAPPING_OWNER)),
|
||||
"CcmApplication.withDomains");
|
||||
|
||||
domainManager.addDomainOwner(application, domain);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
/*
|
||||
* 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.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 org.libreccm.categorization.Domain;
|
||||
import org.libreccm.categorization.DomainManager;
|
||||
import org.libreccm.categorization.DomainOwnership;
|
||||
import org.libreccm.categorization.DomainRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.web.ApplicationRepository;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class DomainMappingsTable extends Table {
|
||||
|
||||
private static final int COL_APPLICATION = 0;
|
||||
private static final int COL_REMOVE = 1;
|
||||
|
||||
private final CategoriesTab categoriesTab;
|
||||
private final ParameterSingleSelectionModel<String> selectedDomainId;
|
||||
|
||||
public DomainMappingsTable(
|
||||
final CategoriesTab categoriesTab,
|
||||
final ParameterSingleSelectionModel<String> selectedDomainId) {
|
||||
super();
|
||||
|
||||
this.categoriesTab = categoriesTab;
|
||||
this.selectedDomainId = selectedDomainId;
|
||||
|
||||
setIdAttr("domainMappingsTable");
|
||||
|
||||
setEmptyView(new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.mappings.none",
|
||||
ADMIN_BUNDLE)));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(
|
||||
COL_APPLICATION,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.mappings.col_app",
|
||||
ADMIN_BUNDLE))));
|
||||
// columnModel.add(new TableColumn(
|
||||
// COL_CONTEXT,
|
||||
// new Label(new GlobalizedMessage(
|
||||
// "ui.admin.categories.domain_details.mappings.col_context",
|
||||
// ADMIN_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_REMOVE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.mappings.col_remove",
|
||||
ADMIN_BUNDLE))));
|
||||
|
||||
columnModel.get(COL_REMOVE).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.domain_details.mappings.remove.confirm",
|
||||
ADMIN_BUNDLE));
|
||||
return link;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
addTableActionListener(new TableActionListener() {
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
switch (event.getColumn()) {
|
||||
case COL_REMOVE:
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final DomainRepository domainRepository = cdiUtil
|
||||
.findBean(DomainRepository.class);
|
||||
final DomainManager domainManager = cdiUtil.findBean(
|
||||
DomainManager.class);
|
||||
final ApplicationRepository appRepository = cdiUtil
|
||||
.findBean(ApplicationRepository.class);
|
||||
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(event
|
||||
.getPageState())));
|
||||
|
||||
final CcmApplication owner = appRepository.findById(
|
||||
Long.parseLong((String)event.getRowKey()));
|
||||
|
||||
domainManager.removeDomainOwner(owner, domain);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
setModelBuilder(new DomainMappingsTableModelBuilder());
|
||||
}
|
||||
|
||||
private class DomainMappingsTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table,
|
||||
final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
return new DomainMappingsTableModel(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DomainMappingsTableModel implements TableModel {
|
||||
|
||||
private final List<DomainOwnership> domainOwnerships;
|
||||
private int index = -1;
|
||||
|
||||
public DomainMappingsTableModel(final PageState state) {
|
||||
final DomainRepository domainRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(DomainRepository.class);
|
||||
final Domain domain = domainRepository.findById(
|
||||
Long.parseLong(selectedDomainId.getSelectedKey(state)),
|
||||
"Domain.withOwners");
|
||||
|
||||
domainOwnerships = new ArrayList<>(domain.getOwners());
|
||||
|
||||
domainOwnerships.sort((o1, o2) -> {
|
||||
return ((Long)o1.getOwnerOrder()).compareTo(o2.getOwnerOrder());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
index++;
|
||||
return index < domainOwnerships.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
switch(columnIndex) {
|
||||
case COL_APPLICATION:
|
||||
return domainOwnerships.get(index).getOwner().getPrimaryUrl();
|
||||
case COL_REMOVE:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.categories.domain_details.mappings.remove",
|
||||
ADMIN_BUNDLE));
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Not a valid column index");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return domainOwnerships.get(index).getOwner().getObjectId();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainPropertySheetModel implements PropertySheetModel {
|
||||
class DomainPropertySheetModel implements PropertySheetModel {
|
||||
|
||||
private static enum DomainProperty {
|
||||
DOMAIN_KEY,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.libreccm.cdi.utils.CdiUtil;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainPropertySheetModelBuilder
|
||||
class DomainPropertySheetModelBuilder
|
||||
extends LockableImpl
|
||||
implements PropertySheetModelBuilder {
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainTitleForm extends Form {
|
||||
class DomainTitleForm extends Form {
|
||||
|
||||
private static final String LOCALIZED_DOMAIN_TITLE = "title";
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
|||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainTitleTable extends Table {
|
||||
class DomainTitleTable extends Table {
|
||||
|
||||
private static final int COL_LOCALE = 0;
|
||||
private static final int COL_VALUE = 1;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.ui.admin.categories;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
|
|
@ -49,15 +48,13 @@ import org.libreccm.configuration.ConfigurationConstants;
|
|||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class DomainsTable extends Table {
|
||||
class DomainsTable extends Table {
|
||||
|
||||
private final static Logger LOGGER = LogManager.getLogger(
|
||||
DomainsTable.class);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,12 @@ package org.libreccm.categorization;
|
|||
import org.libreccm.web.ApplicationRepository;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
|
|
@ -57,6 +60,7 @@ public class DomainManager {
|
|||
*
|
||||
* @return The new domain.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Domain createDomain(final String domainKey,
|
||||
final String rootCategoryName) {
|
||||
final Domain domain = new Domain();
|
||||
|
|
@ -113,10 +117,31 @@ public class DomainManager {
|
|||
* @param domain The {@code Domain} from which owners the provided
|
||||
* {@code CcmApplication} should be removed.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void removeDomainOwner(final CcmApplication application,
|
||||
final Domain domain) {
|
||||
// TODO implement method
|
||||
throw new UnsupportedOperationException();
|
||||
final CcmApplication owner = applicationRepo.findById(
|
||||
application.getObjectId(), "CcmApplication.withDomains");
|
||||
final Domain ownedDomain = domainRepo.findById(
|
||||
domain.getObjectId(), "Domain.withOwners");
|
||||
|
||||
final TypedQuery<DomainOwnership> query = entityManager
|
||||
.createNamedQuery("DomainOwnership.findByOwnerAndDomain",
|
||||
DomainOwnership.class);
|
||||
query.setParameter("owner", owner);
|
||||
query.setParameter("domain", ownedDomain);
|
||||
|
||||
final List<DomainOwnership> result = query.getResultList();
|
||||
|
||||
if (result != null) {
|
||||
result.forEach(o -> {
|
||||
ownedDomain.removeOwner(o);
|
||||
owner.removeDomain(o);
|
||||
entityManager.remove(o);
|
||||
domainRepo.save(ownedDomain);
|
||||
applicationRepo.save(owner);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,10 +153,18 @@ public class DomainManager {
|
|||
* @return {@code true} if the provided {@code CcmApplication} is an owner
|
||||
* of the provided {@code Domain}, {@code false} otherwise.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public boolean isDomainOwner(final CcmApplication application,
|
||||
final Domain domain) {
|
||||
// TODO implement method
|
||||
throw new UnsupportedOperationException();
|
||||
final TypedQuery<DomainOwnership> query = entityManager
|
||||
.createNamedQuery("DomainOwnership.findByOwnerAndDomain",
|
||||
DomainOwnership.class);
|
||||
query.setParameter("owner", application);
|
||||
query.setParameter("domain", domain);
|
||||
|
||||
final List<DomainOwnership> result = query.getResultList();
|
||||
|
||||
return (result != null && !result.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,10 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
||||
/**
|
||||
* Association class for the association between a {@link Domain} and a
|
||||
* {@link CcmObject}. Instances of this class should not be created manually.
|
||||
|
|
@ -45,6 +46,12 @@ import javax.persistence.Table;
|
|||
*/
|
||||
@Entity
|
||||
@Table(name = "DOMAIN_OWNERSHIPS", schema = DB_SCHEMA)
|
||||
@NamedQueries({
|
||||
@NamedQuery(
|
||||
name = "DomainOwnership.findByOwnerAndDomain",
|
||||
query = "SELECT o FROM DomainOwnership o "
|
||||
+ "WHERE o.owner = :owner AND o.domain = :domain")
|
||||
})
|
||||
public class DomainOwnership implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 201504301305L;
|
||||
|
|
@ -212,4 +219,5 @@ public class DomainOwnership implements Serializable {
|
|||
ownerOrder,
|
||||
data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ import java.util.Objects;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.NamedAttributeNode;
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
import javax.persistence.NamedEntityGraphs;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
|
|
@ -58,6 +61,13 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
query = "SELECT A FROM CcmApplication a "
|
||||
+ "WHERE a.applicationType = :type")
|
||||
})
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(
|
||||
name = "CcmApplication.withDomains",
|
||||
attributeNodes = {
|
||||
@NamedAttributeNode(value = "domains")
|
||||
})
|
||||
})
|
||||
@XmlRootElement(name = "application", namespace = WEB_XML_NS)
|
||||
public class CcmApplication extends Resource implements Serializable {
|
||||
|
||||
|
|
|
|||
|
|
@ -397,3 +397,12 @@ ui.admin.categories.domain.description.label=Description
|
|||
ui.admin.categories.domain.description.error.not_blank=The description of a domain can't be blank.
|
||||
ui.admin.categories.domain_details.domain_desc.add.label=Add description for language
|
||||
ui.admin.categories.domain_details.domain_desc.add.submit=Add
|
||||
ui.admin.categories.domain_details.mappings.none=No mappings
|
||||
ui.admin.categories.domain_details.mappings.col_app=Application
|
||||
ui.admin.categories.domain_details.mappings.col_context=Context
|
||||
ui.admin.categories.domain_details.mappings.col_remove=Remove
|
||||
ui.admin.categories.domain_details.mappings.remove=Remove
|
||||
ui.admin.categories.domain_details.mappings.add=Add mapping for application
|
||||
ui.admin.categories.domain_details.mappings.create=Create
|
||||
ui.admin.categories.doamin_details.mappings.error.please_select_app=Please select an application.
|
||||
ui.admin.categories.domain_details.mappings.remove.confirm=Are you sure to remove this domain mapping?
|
||||
|
|
|
|||
|
|
@ -400,3 +400,12 @@ ui.admin.categories.domain.description.label=Beschreibung
|
|||
ui.admin.categories.domain.description.error.not_blank=Die Beschreibung einer Domain darf nicht leer sein.
|
||||
ui.admin.categories.domain_details.domain_desc.add.label=Beschreibung f\u00fcr Sprache
|
||||
ui.admin.categories.domain_details.domain_desc.add.submit=hinzuf\u00fcgen
|
||||
ui.admin.categories.domain_details.mappings.none=Keine Mappings
|
||||
ui.admin.categories.domain_details.mappings.col_app=Application
|
||||
ui.admin.categories.domain_details.mappings.col_context=Kontext
|
||||
ui.admin.categories.domain_details.mappings.col_remove=Entfernen
|
||||
ui.admin.categories.domain_details.mappings.remove=Entfernen
|
||||
ui.admin.categories.domain_details.mappings.add=Mapping f\u00fcr Application
|
||||
ui.admin.categories.domain_details.mappings.create=hinzuf\u00fcgen
|
||||
ui.admin.categories.doamin_details.mappings.error.please_select_app=Bitte w\u00e4hlen Sie eine Applikation aus.
|
||||
ui.admin.categories.domain_details.mappings.remove.confirm=Sind Sie sicher, dass Sie dieses Mapping entfernen wollen?
|
||||
|
|
|
|||
|
|
@ -373,3 +373,12 @@ ui.admin.categories.domain.description.label=Description
|
|||
ui.admin.categories.domain.description.error.not_blank=The description of a domain can't be blank.
|
||||
ui.admin.categories.domain_details.domain_desc.add.label=Add description for language
|
||||
ui.admin.categories.domain_details.domain_desc.add.submit=Add
|
||||
ui.admin.categories.domain_details.mappings.none=No mappings
|
||||
ui.admin.categories.domain_details.mappings.col_app=Application
|
||||
ui.admin.categories.domain_details.mappings.col_context=Context
|
||||
ui.admin.categories.domain_details.mappings.col_remove=Remove
|
||||
ui.admin.categories.domain_details.mappings.remove=Remove
|
||||
ui.admin.categories.domain_details.mappings.add=Add mapping for application
|
||||
ui.admin.categories.domain_details.mappings.create=Create
|
||||
ui.admin.categories.doamin_details.mappings.error.please_select_app=Please select an application.
|
||||
ui.admin.categories.domain_details.mappings.remove.confirm=Are you sure to remove this domain mapping?
|
||||
|
|
|
|||
|
|
@ -364,3 +364,12 @@ ui.admin.categories.domain.description.label=Description
|
|||
ui.admin.categories.domain.description.error.not_blank=The description of a domain can't be blank.
|
||||
ui.admin.categories.domain_details.domain_desc.add.label=Add description for language
|
||||
ui.admin.categories.domain_details.domain_desc.add.submit=Add
|
||||
ui.admin.categories.domain_details.mappings.none=No mappings
|
||||
ui.admin.categories.domain_details.mappings.col_app=Application
|
||||
ui.admin.categories.domain_details.mappings.col_context=Context
|
||||
ui.admin.categories.domain_details.mappings.col_remove=Remove
|
||||
ui.admin.categories.domain_details.mappings.remove=Remove
|
||||
ui.admin.categories.domain_details.mappings.add=Add mapping for application
|
||||
ui.admin.categories.domain_details.mappings.create=Create
|
||||
ui.admin.categories.doamin_details.mappings.error.please_select_app=Please select an application.
|
||||
ui.admin.categories.domain_details.mappings.remove.confirm=Are you sure to remove this domain mapping?
|
||||
|
|
|
|||
Loading…
Reference in New Issue