From c05c7b20e15a0b6f9ef9cc5c85a2daf188cbaa73 Mon Sep 17 00:00:00 2001 From: jensp Date: Tue, 26 May 2015 11:30:35 +0000 Subject: [PATCH] CCM NG: Entities for org.libreccm.formbuilder git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3429 8810af33-2d31-482b-a856-94f89814c4df --- .../formbuilder/DataDrivenSelect.java | 101 ++++++++++ .../org/libreccm/formbuilder/FormSection.java | 115 ++++++++++++ .../org/libreccm/formbuilder/MetaObject.java | 137 ++++++++++++++ .../org/libreccm/formbuilder/ObjectType.java | 103 +++++++++++ .../java/org/libreccm/formbuilder/Option.java | 111 +++++++++++ .../formbuilder/PersistentDataQuery.java | 136 ++++++++++++++ .../libreccm/formbuilder/ProcessListener.java | 172 ++++++++++++++++++ 7 files changed, 875 insertions(+) create mode 100644 ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java create mode 100644 ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java create mode 100644 ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java create mode 100644 ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java create mode 100644 ccm-core/src/main/java/org/libreccm/formbuilder/Option.java create mode 100644 ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java create mode 100644 ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java b/ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java new file mode 100644 index 000000000..25b48a65b --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2015 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.libreccm.formbuilder; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "formbuilder_data_driven_selects") +public class DataDrivenSelect extends Widget implements Serializable { + + private static final long serialVersionUID = -4477753441663454661L; + + @Column(name = "multiple") + private boolean multiple; + + @Column(name = "query") + private String query; + + public boolean isMultiple() { + return multiple; + } + + public void setMultiple(final boolean multiple) { + this.multiple = multiple; + } + + public String getQuery() { + return query; + } + + public void setQuery(final String query) { + this.query = query; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 41 * hash + (multiple ? 1 : 0); + hash = 41 * hash + Objects.hashCode(query); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final DataDrivenSelect other = (DataDrivenSelect) obj; + if (!other.canEqual(this)) { + return false; + } + + if (multiple != other.isMultiple()) { + return false; + } + return Objects.equals(query, other.getQuery()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof DataDrivenSelect; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", multiple = %b," + + "query = \"%s\"%s", + multiple, + query, + data)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java b/ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java new file mode 100644 index 000000000..1671cca98 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2015 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.libreccm.formbuilder; + +import org.hibernate.annotations.CollectionId; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "formbuilder_formsections") +public class FormSection extends Component implements Serializable { + + private static final long serialVersionUID = -3195157282292906945L; + + @Column(name = "formsection_action") + private String action; + + @OneToMany(mappedBy = "formSection") + private List processListeners; + + public FormSection() { + super(); + processListeners = new ArrayList<>(); + } + + public String getAction() { + return action; + } + + public void setAction(final String action) { + this.action = action; + } + + public List getProcessListeners() { + return Collections.unmodifiableList(processListeners); + } + + protected void setProcessListeners( + final List processListeners) { + this.processListeners = processListeners; + } + + protected void addProcessListener(final ProcessListener listener) { + processListeners.add(listener); + } + + protected void removeListener(final ProcessListener listener) { + processListeners.remove(listener); + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 29 * hash + Objects.hashCode(action); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final FormSection other = (FormSection) obj; + if (!other.canEqual(this)) { + return false; + } + + return Objects.equals(action, other.getAction()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof FormSection; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", action = \"%s\"%s", + action, + data)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java b/ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java new file mode 100644 index 000000000..7f629e90c --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2015 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.libreccm.formbuilder; + +import org.libreccm.core.CcmObject; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = " formbuilder_metaobjects") +public class MetaObject extends CcmObject implements Serializable { + + private static final long serialVersionUID = -3770682858640493776L; + + @Column(name = "pretty_name") + private String prettyName; + + @Column(name = "pretty_plural") + private String prettyPlural; + + @Column(name = "class_name") + private String className; + + @Column(name = "properties_form") + private String propertiesForm; + + public String getPrettyName() { + return prettyName; + } + + public void setPrettyName(final String prettyName) { + this.prettyName = prettyName; + } + + public String getPrettyPlural() { + return prettyPlural; + } + + public void setPrettyPlural(final String prettyPlural) { + this.prettyPlural = prettyPlural; + } + + public String getClassName() { + return className; + } + + public void setClassName(final String className) { + this.className = className; + } + + public String getPropertiesForm() { + return propertiesForm; + } + + public void setPropertiesForm(final String propertiesForm) { + this.propertiesForm = propertiesForm; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 37 * hash + Objects.hashCode(prettyName); + hash = 37 * hash + Objects.hashCode(prettyPlural); + hash = 37 * hash + Objects.hashCode(className); + hash = 37 * hash + Objects.hashCode(propertiesForm); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MetaObject other = (MetaObject) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(prettyName, other.getPrettyName())) { + return false; + } + if (!Objects.equals(prettyPlural, other.getPrettyPlural())) { + return false; + } + if (!Objects.equals(className, other.getClassName())) { + return false; + } + return Objects.equals(propertiesForm, other.getPropertiesForm()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof MetaObject; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", prettyName = \"%s\", " + + "prettyPlural = \"%s\", " + + "className = \"%s\", " + + "propertiesForm = \"%s\"%s", + prettyName, + prettyPlural, + className, + propertiesForm, + data)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java b/ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java new file mode 100644 index 000000000..51e2642a3 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2015 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.libreccm.formbuilder; + +import org.libreccm.core.CcmObject; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "formbuilder_object_types") +public class ObjectType extends CcmObject implements Serializable { + + private static final long serialVersionUID = 5236718507025096569L; + + @Column(name = "app_name") + private String appName; + + @Column(name = "class_name") + private String className; + + public String getAppName() { + return appName; + } + + public void setAppName(final String appName) { + this.appName = appName; + } + + public String getClassName() { + return className; + } + + public void setClassName(final String className) { + this.className = className; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 61 * hash + Objects.hashCode(appName); + hash = 61 * hash + Objects.hashCode(className); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ObjectType other = (ObjectType) obj; + if (!canEqual(this)) { + return false; + } + + if (!Objects.equals(appName, other.getAppName())) { + return false; + } + return Objects.equals(className, other.getClassName()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof ObjectType; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", appName = \"%s\", " + + "className = \"%s\"%s", + appName, + className, + data)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/Option.java b/ccm-core/src/main/java/org/libreccm/formbuilder/Option.java new file mode 100644 index 000000000..11d01cc15 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/Option.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2015 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.libreccm.formbuilder; + +import org.libreccm.l10n.LocalizedString; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.AssociationOverride; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "formbuilder_options") +public class Option extends Component implements Serializable { + + private static final long serialVersionUID = -7528058391772415511L; + + @Column(name = "parameter_value") + private String parameterValue; + + @AssociationOverride(name = "values", + joinTable = @JoinTable(name + = "formbuilder_option_labels", + joinColumns = { + @JoinColumn(name + = "option_id")})) + private LocalizedString label; + + public String getParameterValue() { + return parameterValue; + } + + public void setParameterValue(final String parameterValue) { + this.parameterValue = parameterValue; + } + + public LocalizedString getLabel() { + return label; + } + + public void setLabel(final LocalizedString label) { + this.label = label; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 67 * hash + Objects.hashCode(parameterValue); + hash = 67 * hash + Objects.hashCode(label); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Option other = (Option) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(parameterValue, other.getParameterValue())) { + return false; + } + return Objects.equals(label, other.getLabel()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof Option; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", parameterValue = \"%s\", " + + "label = %s%s", + parameterValue, + Objects.toString(label), + data)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java b/ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java new file mode 100644 index 000000000..971bd7023 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2015 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.libreccm.formbuilder; + +import org.libreccm.core.CcmObject; +import org.libreccm.l10n.LocalizedString; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.AssociationOverride; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "formbuilder_data_queries") +public class PersistentDataQuery extends CcmObject implements Serializable { + + private static final long serialVersionUID = -7344153915501267752L; + + @Column(name = "query_id") + private String queryId; + + @AssociationOverride( + name = "values", + joinTable = @JoinTable(name + = "formbuilder_data_query_names", + joinColumns = { + @JoinColumn(name + = "data_query_id")})) + private LocalizedString name; + + @AssociationOverride( + name = "values", + joinTable = @JoinTable(name + = "formbuilder_data_query_descriptions", + joinColumns = { + @JoinColumn(name + = "data_query_id")})) + private LocalizedString description; + + public String getQueryId() { + return queryId; + } + + public void setQueryId(final String queryId) { + this.queryId = queryId; + } + + public LocalizedString getName() { + return name; + } + + public void setName(final LocalizedString name) { + this.name = name; + } + + public LocalizedString getDescription() { + return description; + } + + public void setDescription(final LocalizedString description) { + this.description = description; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 23 * hash + Objects.hashCode(queryId); + hash = 23 * hash + Objects.hashCode(name); + hash = 23 * hash + Objects.hashCode(description); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersistentDataQuery other = (PersistentDataQuery) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(queryId, other.getQueryId())) { + return false; + } + if (!Objects.equals(name, other.getName())) { + return false; + } + return Objects.equals(description, other.getDescription()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof PersistentDataQuery; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", queryId = \"%s\", " + + "name = %s, " + + "description = %s%s", + queryId, + Objects.toString(name), + Objects.toString(description), + data)); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java new file mode 100644 index 000000000..6ade2933a --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2015 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.libreccm.formbuilder; + +import org.libreccm.core.CcmObject; +import org.libreccm.l10n.LocalizedString; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.AssociationOverride; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "formbuilder_process_listeners") +public class ProcessListener extends CcmObject implements Serializable { + + private static final long serialVersionUID = -3029184333026605708L; + + @AssociationOverride( + name = "values", + joinTable = @JoinTable(name + = "formbuilder_process_listener_names", + joinColumns = { + @JoinColumn(name + = "process_listener_id")})) + private LocalizedString name; + + @AssociationOverride( + name = "values", + joinTable = @JoinTable(name + = "formbuilder_process_listener_descriptions", + joinColumns = { + @JoinColumn(name + = "process_listener_id")})) + + private LocalizedString description; + + @Column(name = "listener_class") + private String listenerClass; + + @ManyToOne + private FormSection formSection; + + @Column(name = "process_listener_order") + private long order; + + public LocalizedString getName() { + return name; + } + + public void setName(final LocalizedString name) { + this.name = name; + } + + public LocalizedString getDescription() { + return description; + } + + public void setDescription(final LocalizedString description) { + this.description = description; + } + + public String getListenerClass() { + return listenerClass; + } + + public void setListenerClass(final String listenerClass) { + this.listenerClass = listenerClass; + } + + public FormSection getFormSection() { + return formSection; + } + + protected void setFormSection(final FormSection formSection) { + this.formSection = formSection; + } + + public long getOrder() { + return order; + } + + public void setOrder(final long order) { + this.order = order; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 37 * hash + Objects.hashCode(name); + hash = 37 * hash + Objects.hashCode(description); + hash = 37 * hash + Objects.hashCode(listenerClass); + hash = 37 * hash + Objects.hashCode(formSection); + hash = 37 * hash + (int) (order ^ (order >>> 32)); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ProcessListener other = (ProcessListener) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(name, other.getName())) { + return false; + } + if (!Objects.equals(description, other.getDescription())) { + return false; + } + if (!Objects.equals(listenerClass, other.getListenerClass())) { + return false; + } + if (!Objects.equals(formSection, other.getFormSection())) { + return false; + } + return order == other.getOrder(); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof ProcessListener; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", name = %s, " + + "description = %s, " + + "listenerClass = \"%s\", " + + "formSection = %s, " + + "order = %d%s", + Objects.toString(name), + Objects.toString(description), + listenerClass, + Objects.toString(formSection), + order, + data)); + } + +}