ContactableEntity Asset, Organization Asset

* Migrations for ContactEntryKey
* More work on the form for managing assets of these types


git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@6149 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2019-07-23 15:42:09 +00:00
parent ca0589243f
commit abc4ec7ab3
13 changed files with 599 additions and 48 deletions

View File

@ -69,21 +69,29 @@ public abstract class AbstractAssetForm<T extends Asset>
FormSubmissionListener { FormSubmissionListener {
private static final String ASSET_TITLE = "asset-name"; private static final String ASSET_TITLE = "asset-name";
private static final String ASSET_NAME = "asset-title"; private static final String ASSET_NAME = "asset-title";
private final AssetPane assetPane; private final AssetPane assetPane;
private final SingleSelectionModel<Long> selectionModel; private final SingleSelectionModel<Long> selectionModel;
private BoxPanel showLocalePanel; private BoxPanel showLocalePanel;
private SingleSelect showLocaleSelect; private SingleSelect showLocaleSelect;
private Submit showLocaleSubmit; private Submit showLocaleSubmit;
private BoxPanel addLocalePanel; private BoxPanel addLocalePanel;
private SingleSelect addLocaleSelect; private SingleSelect addLocaleSelect;
private Submit addLocaleSubmit; private Submit addLocaleSubmit;
private TextField name; private TextField name;
private TextField title; private TextField title;
private SaveCancelSection saveCancelSection; private SaveCancelSection saveCancelSection;
public AbstractAssetForm(final AssetPane assetPane) { public AbstractAssetForm(final AssetPane assetPane) {
@ -130,13 +138,13 @@ public abstract class AbstractAssetForm<T extends Asset>
final SingleSelect target = (SingleSelect) event final SingleSelect target = (SingleSelect) event
.getTarget(); .getTarget();
target.clearOptions();; target.clearOptions();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final AssetL10NManager l10nManager = cdiUtil final AbstractAssetFormController controller = cdiUtil
.findBean(AssetL10NManager.class); .findBean(AbstractAssetFormController.class);
final List<Locale> availableLocales = new ArrayList<>( final List<Locale> availableLocales = controller
l10nManager.availableLocales(selectedAsset.get())); .availableLocales(selectedAsset.get());
availableLocales.sort((locale1, locale2) -> { availableLocales.sort((locale1, locale2) -> {
return locale1.toString().compareTo(locale2 return locale1.toString().compareTo(locale2
.toString()); .toString());
@ -206,10 +214,11 @@ public abstract class AbstractAssetForm<T extends Asset>
target.clearOptions(); target.clearOptions();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final AssetL10NManager l10nManager = cdiUtil final AbstractAssetFormController controller = cdiUtil
.findBean(AssetL10NManager.class); .findBean(AbstractAssetFormController.class);
final List<Locale> creatableLocales = new ArrayList<>(
l10nManager.creatableLocales(selectedAsset.get())); final List<Locale> creatableLocales = controller
.creatableLocales(selectedAsset.get());
creatableLocales.sort((locale1, locale2) -> { creatableLocales.sort((locale1, locale2) -> {
return locale1 return locale1
.toString() .toString()
@ -298,14 +307,15 @@ public abstract class AbstractAssetForm<T extends Asset>
if (selectedAsset.isPresent()) { if (selectedAsset.isPresent()) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final AbstractAssetFormController controller = cdiUtil
.findBean(AbstractAssetFormController.class);
showLocaleSelect.setValue(state, showLocaleSelect.setValue(state,
getSelectedLocale(state)); getSelectedLocale(state));
title.setValue(state, title.setValue(state,
selectedAsset controller.getTitle(selectedAsset.get(),
.get() getSelectedLocale(state)));
.getTitle()
.getValue(getSelectedLocale(state)));
} else { } else {
showLocaleSelect.setValue(state, showLocaleSelect.setValue(state,
KernelConfig KernelConfig
@ -345,11 +355,13 @@ public abstract class AbstractAssetForm<T extends Asset>
.get() .get()
.getDisplayName()); .getDisplayName());
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final AbstractAssetFormController controller = cdiUtil
.findBean(AbstractAssetFormController.class);
title.setValue(state, title.setValue(state,
selectedAsset controller.getTitle(selectedAsset.get(),
.get() getSelectedLocale(state)));
.getTitle()
.getValue(getSelectedLocale(state)));
showLocale(state); showLocale(state);
} }
} }

View File

@ -0,0 +1,102 @@
/*
* Copyright (C) 2019 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.cms.ui.assets;
import org.librecms.assets.AssetL10NManager;
import org.librecms.contentsection.Asset;
import org.librecms.contentsection.AssetRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class AbstractAssetFormController {
@Inject
private AssetRepository assetRepository;
@Inject
private AssetL10NManager l10nManager;
@Transactional(Transactional.TxType.REQUIRED)
public String getTitle(final Asset asset, final Locale locale) {
Objects.requireNonNull(asset, "Can't get title from asset null.");
Objects.requireNonNull(locale,
"Can't title from asset for locale null");
final Asset result = assetRepository
.findById(asset.getObjectId())
.orElseThrow(
() -> new IllegalArgumentException(
String.format("No asset with ID %d found.",
asset.getObjectId())
)
);
return result.getTitle().getValue(locale);
}
@Transactional(Transactional.TxType.REQUIRED)
public List<Locale> availableLocales(final Asset asset) {
Objects.requireNonNull(asset,
"Can't get available locales from asset null.");
final Asset result = assetRepository
.findById(asset.getObjectId())
.orElseThrow(
() -> new IllegalArgumentException(
String.format("No asset with ID %d found.",
asset.getObjectId())
)
);
return new ArrayList<>(l10nManager.availableLocales(result));
}
@Transactional(Transactional.TxType.REQUIRED)
public List<Locale> creatableLocales(final Asset asset) {
Objects.requireNonNull(asset,
"Can't get creatable locales from asset null.");
final Asset result = assetRepository
.findById(asset.getObjectId())
.orElseThrow(
() -> new IllegalArgumentException(
String.format("No asset with ID %d found.",
asset.getObjectId())
)
);
return new ArrayList<>(l10nManager.creatableLocales(result));
}
}

View File

@ -23,8 +23,14 @@ import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink; import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.Table; import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.Text;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.event.TableActionEvent; import com.arsdigita.bebop.event.TableActionEvent;
@ -45,14 +51,20 @@ import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.l10n.GlobalizationHelper;
import org.librecms.CmsConstants; import org.librecms.CmsConstants;
import org.librecms.assets.ContactEntry; import org.librecms.assets.ContactEntry;
import org.librecms.assets.ContactEntryKeyByLabelComparator;
import org.librecms.assets.ContactEntryKey;
import org.librecms.assets.ContactEntryKeyRepository;
import org.librecms.assets.ContactableEntity; import org.librecms.assets.ContactableEntity;
import org.librecms.assets.PostalAddress;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.TooManyListenersException;
import java.util.stream.Collectors;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
@ -72,6 +84,8 @@ public abstract class AbstractContactableEntityForm<T extends ContactableEntity>
private final AssetPane assetPane; private final AssetPane assetPane;
private SimpleContainer contactEntriesContainer;
private Table contactEntriesTable; private Table contactEntriesTable;
private SingleSelect contactEntryKeySelect; private SingleSelect contactEntryKeySelect;
@ -94,27 +108,97 @@ public abstract class AbstractContactableEntityForm<T extends ContactableEntity>
addPropertyWidgets(); addPropertyWidgets();
contactEntriesContainer = new SimpleContainer() {
@Override
public boolean isVisible(final PageState state) {
return getSelectedAsset(state) != null;
}
};
add(contactEntriesContainer);
contactEntriesTable = buildContactEntriesTable(); contactEntriesTable = buildContactEntriesTable();
add(contactEntriesTable); contactEntriesContainer.add(contactEntriesTable);
contactEntryKeySelect = new SingleSelect(new StringParameter( contactEntryKeySelect = new SingleSelect(new StringParameter(
"contactentry-key")); "contactentry-key"));
add(contactEntryKeySelect); try {
contactEntryKeySelect
.addPrintListener(new ContactEntryKeySelectPrintListener());
} catch (TooManyListenersException ex) {
throw new RuntimeException(ex);
}
contactEntriesContainer.add(new Label(
new GlobalizedMessage(
"cms.ui.authoring.assets.contactable.contactentries.key",
CMS_BUNDLE))
);
contactEntriesContainer.add(contactEntryKeySelect);
contactEntryValueField = new TextField("contact-entry-value");
contactEntriesContainer.add(new Label(
new GlobalizedMessage(
"cms.ui.authoring.assets.contactable.contactentries.value",
CMS_BUNDLE))
);
contactEntriesContainer.add(contactEntryValueField);
addContactEntryLink = new ActionLink(
new GlobalizedMessage(
"cms.ui.authoring.assets.contactable.contactentries.add",
CMS_BUNDLE)
);
addContactEntryLink
.addActionListener(new AddContactEntryActionListener());
contactEntriesContainer.add(addContactEntryLink);
contactEntriesContainer.add(new Label(
new GlobalizedMessage(
"cms.ui.authoring.assets.contactable.postaladdress",
CMS_BUNDLE))
);
postalAddressSearchWidget = new AssetSearchWidget(
"contactable-postaladdress", PostalAddress.class
);
contactEntriesContainer.add(postalAddressSearchWidget);
}
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
super.init(event);
final PageState state = event.getPageState();
final Optional<T> selected = getSelectedAsset(state);
if (selected.isPresent()) {
// ToDo
}
}
@Override
public void register(final Page page) {
super.register(page);
// page.addComponent(addContactEntryLink);
} }
protected abstract void addPropertyWidgets(); protected abstract void addPropertyWidgets();
private Table buildContactEntriesTable() { private Table buildContactEntriesTable() {
final Table table = new Table() { final Table table = new Table();
// {
@Override
public boolean isVisible(final PageState state) {
return getSelectedAsset(state).isPresent();
}
};
// @Override
// public boolean isVisible(final PageState state) {
// return getSelectedAsset(state).isPresent();
// }
// };
final TableColumnModel columnModel = table.getColumnModel(); final TableColumnModel columnModel = table.getColumnModel();
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
COL_CONTACT_ENTRIES_KEY, COL_CONTACT_ENTRIES_KEY,
@ -168,8 +252,9 @@ public abstract class AbstractContactableEntityForm<T extends ContactableEntity>
final Integer rowKey = (Integer) event.getRowKey(); final Integer rowKey = (Integer) event.getRowKey();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContactableEntityFormController controller = cdiUtil final AbstractContactableEntityFormController controller
.findBean(ContactableEntityFormController.class); = cdiUtil
.findBean(AbstractContactableEntityFormController.class);
final Optional<T> selected = getSelectedAsset(event final Optional<T> selected = getSelectedAsset(event
.getPageState()); .getPageState());
if (selected.isPresent()) { if (selected.isPresent()) {
@ -199,8 +284,11 @@ public abstract class AbstractContactableEntityForm<T extends ContactableEntity>
.orElseThrow( .orElseThrow(
() -> new IllegalStateException("No asset selected") () -> new IllegalStateException("No asset selected")
); );
final List<ContactEntry> contactEntries = selected final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
.getContactEntries(); final AbstractContactableEntityFormController controller = cdiUtil
.findBean(AbstractContactableEntityFormController.class);
final List<ContactEntry> contactEntries = controller
.getContactEntries(selected);
return new ContactEntriesTableModel(contactEntries); return new ContactEntriesTableModel(contactEntries);
} }
@ -295,8 +383,33 @@ public abstract class AbstractContactableEntityForm<T extends ContactableEntity>
); );
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContactEntryKeyRepository keyRepo = cdiUtil
.findBean(ContactEntryKeyRepository.class);
final GlobalizationHelper globalizationHelper = cdiUtil
.findBean(GlobalizationHelper.class);
final List<ContactEntryKey> keys = keyRepo
.findAll()
.stream()
.sorted(new ContactEntryKeyByLabelComparator(globalizationHelper
.getNegotiatedLocale()))
.collect(Collectors.toList());
for (final ContactEntryKey key : keys) {
final Text label = new Text(
globalizationHelper
.getValueFromLocalizedString(key.getLabel()));
target.addOption(new Option(key.getEntryKey(), label));
}
}
}
private class AddContactEntryActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }

View File

@ -21,6 +21,11 @@ package com.arsdigita.cms.ui.assets.forms;
import org.librecms.assets.ContactEntry; import org.librecms.assets.ContactEntry;
import org.librecms.assets.ContactableEntity; import org.librecms.assets.ContactableEntity;
import org.librecms.assets.ContactableEntityManager; import org.librecms.assets.ContactableEntityManager;
import org.librecms.assets.ContactableEntityRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
@ -31,11 +36,36 @@ import javax.transaction.Transactional;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@RequestScoped @RequestScoped
public class ContactableEntityFormController { public class AbstractContactableEntityFormController {
@Inject
private ContactableEntityRepository contactableEntityRepository;
@Inject @Inject
private ContactableEntityManager contactableEntityManager; private ContactableEntityManager contactableEntityManager;
@Transactional(Transactional.TxType.REQUIRED)
public List<ContactEntry> getContactEntries(
final ContactableEntity contactable) {
Objects.requireNonNull(contactable,
"Can't get contact entries from null.");
final ContactableEntity entity = contactableEntityRepository
.findById(contactable.getObjectId())
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No ContactEntity with ID %d found.",
contactable.getObjectId())));
final List<ContactEntry> entries = new ArrayList<>();
for(final ContactEntry entry : entity.getContactEntries()) {
entries.add(entry);
}
return entries;
}
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public void addContactEntry(final ContactEntry contactEntry, public void addContactEntry(final ContactEntry contactEntry,
final ContactableEntity toContactableEntity) { final ContactableEntity toContactableEntity) {

View File

@ -31,6 +31,7 @@ import org.librecms.assets.Organization;
import org.librecms.contentsection.Asset; import org.librecms.contentsection.Asset;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
/** /**
* *
@ -45,6 +46,21 @@ public class OrganizationForm extends AbstractContactableEntityForm<Organization
super(assetPane); super(assetPane);
} }
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
super.init(event);
final PageState state = event.getPageState();
final Optional<Organization> selected = getSelectedAsset(state);
if (selected.isPresent()) {
organizationName.setValue(state, selected.get().getName());
}
}
@Override @Override
protected void addPropertyWidgets() { protected void addPropertyWidgets() {

View File

@ -28,6 +28,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
@ -58,8 +60,10 @@ public class ContactEntry implements Serializable {
/** /**
* Key used to identify the entry. * Key used to identify the entry.
*/ */
@Column(name = "ENTRY_KEY", length = 255, nullable = false) // @Column(name = "ENTRY_KEY", length = 255, nullable = false)
private String key; @OneToOne
@JoinColumn(name = "CONTACT_ENTRY_KEY_ID")
private ContactEntryKey key;
/** /**
* The value of the entry. * The value of the entry.
@ -89,11 +93,21 @@ public class ContactEntry implements Serializable {
this.order = order; this.order = order;
} }
public String getKey() { // public String getKey() {
// return key;
// }
//
// public void setKey(final String key) {
// this.key = key;
// }
public ContactEntryKey getKey() {
return key; return key;
} }
public void setKey(final String key) { public void setKey(final ContactEntryKey key) {
this.key = key; this.key = key;
} }
@ -105,6 +119,8 @@ public class ContactEntry implements Serializable {
this.value = value; this.value = value;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 7; int hash = 7;
@ -158,13 +174,13 @@ public class ContactEntry implements Serializable {
return String.format("%s{ " return String.format("%s{ "
+ "contactEntryId = %d, " + "contactEntryId = %d, "
+ "order = %d" + "order = %d"
+ "key = \"%s\", " + "key = %s, "
+ "value = \"%s\"%s" + "value = \"%s\"%s"
+ " }", + " }",
super.toString(), super.toString(),
contactEntryId, contactEntryId,
order, order,
key, Objects.toString(key),
value, value,
data); data);
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.librecms.assets; package org.librecms.assets;
import org.hibernate.envers.Audited;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import java.io.Serializable; import java.io.Serializable;
@ -39,8 +40,10 @@ import static org.librecms.CmsConstants.*;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "CONTACT_ENTRY_KEYS") @Audited
public class ContactEntryKey implements Serializable { @Table(name = "CONTACT_ENTRY_KEYS", schema = DB_SCHEMA)
public class ContactEntryKey
implements Comparable<ContactEntryKey>, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -94,6 +97,12 @@ public class ContactEntryKey implements Serializable {
this.label = Objects.requireNonNull(label); this.label = Objects.requireNonNull(label);
} }
@Override
public int compareTo(final ContactEntryKey other) {
return entryKey.compareTo(other.getEntryKey());
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 7; int hash = 7;

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2019 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 org.librecms.assets;
import com.arsdigita.kernel.KernelConfig;
import org.libreccm.l10n.LocalizedString;
import java.util.Comparator;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ContactEntryKeyByLabelComparator
implements Comparator<ContactEntryKey> {
private final Locale locale;
private final Locale defaultLocale;
public ContactEntryKeyByLabelComparator(final Locale locale) {
this.locale = locale;
defaultLocale = KernelConfig.getConfig().getDefaultLocale();
}
@Override
public int compare(final ContactEntryKey key1, final ContactEntryKey key2) {
final LocalizedString label1 = key1.getLabel();
final LocalizedString label2 = key2.getLabel();
final String localized1 = getLocalizedValue(label1);
final String localized2 = getLocalizedValue(label2);
return localized1.compareTo(localized2);
}
private String getLocalizedValue(final LocalizedString source) {
if (source.hasValue(locale)) {
return source.getValue(locale);
} else if (source.hasValue(defaultLocale)) {
return source.getValue(defaultLocale);
} else {
return source.getValue();
}
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2019 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 org.librecms.assets;
import org.libreccm.core.AbstractEntityRepository;
import javax.enterprise.context.RequestScoped;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class ContactableEntityRepository
extends AbstractEntityRepository<Long, ContactableEntity>{
private static final long serialVersionUID = 1L;
@Override
public Class<ContactableEntity> getEntityClass() {
return ContactableEntity.class;
}
@Override
public String getIdAttributeName() {
return "objectId";
}
@Override
public Long getIdOfEntity(final ContactableEntity entity) {
return entity.getObjectId();
}
@Override
public boolean isNew(final ContactableEntity entity) {
return entity.getObjectId() == 0;
}
}

View File

@ -0,0 +1,63 @@
alter table CCM_CMS.CONTACT_ENTRIES add column CONTACT_ENTRY_KEY_ID bigint;
create table CCM_CMS.CONTACT_ENTRY_KEY_LABELS (
KEY_ID bigint not null,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (KEY_ID, LOCALE)
);
create table CCM_CMS.CONTACT_ENTRY_KEY_LABELS_AUD (
REV integer not null,
KEY_ID bigint not null,
LOCALIZED_VALUE varchar(2147483647) not null,
LOCALE varchar(255) not null,
REVTYPE tinyint,
REVEND integer,
primary key (REV, KEY_ID, LOCALIZED_VALUE, LOCALE)
);
create table CCM_CMS.CONTACT_ENTRY_KEYS (
KEY_ID bigint not null,
ENTRY_KEY varchar(255),
primary key (KEY_ID)
);
create table CCM_CMS.CONTACT_ENTRY_KEYS_AUD (
KEY_ID bigint not null,
REV integer not null,
REVTYPE tinyint,
REVEND integer,
ENTRY_KEY varchar(255),
primary key (KEY_ID, REV)
);
alter table CCM_CMS.CONTACT_ENTRIES
add constraint FKirtfj8sm4y5myworl5hvs1l78
foreign key (CONTACT_ENTRY_KEY_ID)
references CCM_CMS.CONTACT_ENTRY_KEYS;
alter table CCM_CMS.CONTACT_ENTRY_KEY_LABELS
add constraint FK243nk3buqm0pskkr5ifjqfxn5
foreign key (KEY_ID)
references CCM_CMS.CONTACT_ENTRY_KEYS;
alter table CCM_CMS.CONTACT_ENTRY_KEY_LABELS_AUD
add constraint FK6n995k5gao6v63gfcga3yaxcw
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.CONTACT_ENTRY_KEY_LABELS_AUD
add constraint FKdr8ujdpn1ej8l6omlxq8bsxbd
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.CONTACT_ENTRY_KEYS_AUD
add constraint FKcvn2b1h1d4uvvmtbf4qf81l0y
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.CONTACT_ENTRY_KEYS_AUD
add constraint FKkyy4v3tax8w5htnpkmmt8aec1
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;

View File

@ -0,0 +1 @@
alter table CCM_CMS.CONTACT_ENTRIES_AUD add column CONTACT_ENTRY_KEY_ID bigint;

View File

@ -0,0 +1,63 @@
alter table CCM_CMS.CONTACT_ENTRIES add column CONTACT_ENTRY_KEY_ID int8;
create table CCM_CMS.CONTACT_ENTRY_KEY_LABELS (
KEY_ID int8 not null,
LOCALIZED_VALUE text,
LOCALE varchar(255) not null,
primary key (KEY_ID, LOCALE)
);
create table CCM_CMS.CONTACT_ENTRY_KEY_LABELS_AUD (
REV int4 not null,
KEY_ID int8 not null,
LOCALIZED_VALUE text not null,
LOCALE varchar(255) not null,
REVTYPE int2,
REVEND int4,
primary key (REV, KEY_ID, LOCALIZED_VALUE, LOCALE)
);
create table CCM_CMS.CONTACT_ENTRY_KEYS (
KEY_ID int8 not null,
ENTRY_KEY varchar(255),
primary key (KEY_ID)
);
create table CCM_CMS.CONTACT_ENTRY_KEYS_AUD (
KEY_ID int8 not null,
REV int4 not null,
REVTYPE int2,
REVEND int4,
ENTRY_KEY varchar(255),
primary key (KEY_ID, REV)
);
alter table CCM_CMS.CONTACT_ENTRIES
add constraint FKirtfj8sm4y5myworl5hvs1l78
foreign key (CONTACT_ENTRY_KEY_ID)
references CCM_CMS.CONTACT_ENTRY_KEYS;
alter table CCM_CMS.CONTACT_ENTRY_KEY_LABELS
add constraint FK243nk3buqm0pskkr5ifjqfxn5
foreign key (KEY_ID)
references CCM_CMS.CONTACT_ENTRY_KEYS;
alter table CCM_CMS.CONTACT_ENTRY_KEY_LABELS_AUD
add constraint FK6n995k5gao6v63gfcga3yaxcw
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.CONTACT_ENTRY_KEY_LABELS_AUD
add constraint FKdr8ujdpn1ej8l6omlxq8bsxbd
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.CONTACT_ENTRY_KEYS_AUD
add constraint FKcvn2b1h1d4uvvmtbf4qf81l0y
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.CONTACT_ENTRY_KEYS_AUD
add constraint FKkyy4v3tax8w5htnpkmmt8aec1
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;

View File

@ -0,0 +1 @@
alter table CCM_CMS.CONTACT_ENTRIES_AUD add column CONTACT_ENTRY_KEY_ID int8;