]> saetta.ns0.it Git - zakform/gdaex/commitdiff
Added FormElement extension.
authorAndrea Zagli <azagli@libero.it>
Mon, 13 Feb 2017 17:16:50 +0000 (18:16 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 19 Feb 2017 09:04:18 +0000 (10:04 +0100)
Added function ::get_where_str.

src/Makefile.am
src/form.c
src/form.h
src/formelementextension.c [new file with mode: 0644]
src/formelementextension.h [new file with mode: 0644]

index b1848b5d4aefa354eaad63a7cc8633febd61f3e5..26c934f2adff5a5e0360a82897256c1342f226ea 100644 (file)
@@ -7,12 +7,14 @@ AM_CPPFLAGS = $(ZAKFORMGDAEX_CFLAGS) \
 lib_LTLIBRARIES = libzakformgdaex.la
 
 libzakformgdaex_la_SOURCES = \
-                             form.c
+                             form.c \
+                             formelementextension.c
 
 libzakformgdaex_la_LDFLAGS = -no-undefined
 
 libzakformgdaex_include_HEADERS = \
                                   libzakformgdaex.h \
-                                  form.h
+                                  form.h \
+                                  formelementextension.h
 
 libzakformgdaex_includedir = $(includedir)/libzakformgdaex
index 07b0c95a6106d18deb59d279091282e4b645e191..3511092d0e891e9e847696c8b42363ca6935eb1e 100644 (file)
 #include <libzakutils/libzakutils.h>
 
 #include "form.h"
+#include "formelementextension.h"
 
 static void zak_form_gdaex_provider_class_init (ZakFormGdaexProviderClass *class);
 static void zak_form_gdaex_provider_init (ZakFormGdaexProvider *zak_form_gdaex_provider);
 static void zak_form_iprovider_interface_init (ZakFormIProviderInterface *iface);
 
 static void zak_form_gdaex_provider_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
+                                                  guint property_id,
+                                                  const GValue *value,
+                                                  GParamSpec *pspec);
 static void zak_form_gdaex_provider_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
+                                                  guint property_id,
+                                                  GValue *value,
+                                                  GParamSpec *pspec);
 
 static void zak_form_gdaex_provider_dispose (GObject *gobject);
 static void zak_form_gdaex_provider_finalize (GObject *gobject);
 
+static GValue *zak_form_gdaex_provider_new_gvalue_from_element (ZakFormElement *element, gboolean for_where);
+
 static gboolean zak_form_gdaex_provider_load (ZakFormIProvider *provider, GPtrArray *elements);
 static gboolean zak_form_gdaex_provider_insert (ZakFormIProvider *provider, GPtrArray *elements);
 static gboolean zak_form_gdaex_provider_update (ZakFormIProvider *provider, GPtrArray *elements);
@@ -61,8 +64,8 @@ struct _ZakFormGdaexProviderPrivate
        };
 
 G_DEFINE_TYPE_WITH_CODE (ZakFormGdaexProvider, zak_form_gdaex_provider, G_TYPE_OBJECT,
-                                                G_IMPLEMENT_INTERFACE (ZAK_FORM_TYPE_IPROVIDER,
-                                                                                               zak_form_iprovider_interface_init))
+                         G_IMPLEMENT_INTERFACE (ZAK_FORM_TYPE_IPROVIDER,
+                                                zak_form_iprovider_interface_init))
 
 static void
 zak_form_gdaex_provider_class_init (ZakFormGdaexProviderClass *class)
@@ -118,12 +121,112 @@ ZakFormGdaexProvider
        return zak_form_gdaex_provider;
 }
 
+/**
+ * zak_form_gdaex_provider_get_where_str:
+ * @provider:
+ * @elements:
+ *
+ * Returns: the string of the where part of sql statement.
+ */
+gchar
+*zak_form_gdaex_provider_get_where_str (ZakFormGdaexProvider *provider, GPtrArray *elements)
+{
+       guint i;
+       guint l;
+
+       GdaExSqlBuilder *sqlb;
+
+       GValue *value;
+
+       ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (provider);
+
+       sqlb = gdaex_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
+
+       gdaex_sql_builder_from (sqlb, priv->table, "");
+
+       gdaex_sql_builder_field (sqlb,
+                                priv->table,
+                                "*",
+                                "",
+                                NULL);
+
+       for (i = 0; i < elements->len; i++)
+               {
+                       ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (elements, i);
+
+                       GPtrArray *extensions = zak_form_element_get_extensions_by_type (element, ZAK_FORM_GDAEX_TYPE_ELEMENT_EXTENSION);
+
+                       value = zak_form_gdaex_provider_new_gvalue_from_element (element, TRUE);
+                       if (gda_value_is_null (value)) continue;
+
+                       for (l = 0; l < extensions->len; l++)
+                               {
+                                       gchar *table;
+                                       gchar *table_alias;
+                                       gchar *field;
+                                       gchar *field_alias;
+                                       GdaSqlOperatorType type;
+
+                                       ZakFormGdaExElementExtension *extension = (ZakFormGdaExElementExtension *)g_ptr_array_index (extensions, l);
+
+                                       table = zak_form_gdaex_element_extension_get_where_table (extension);
+                                       table_alias = zak_form_gdaex_element_extension_get_where_table_alias (extension);
+                                       field = zak_form_gdaex_element_extension_get_where_field (extension);
+                                       field_alias = zak_form_gdaex_element_extension_get_where_field_alias (extension);
+                                       type = zak_form_gdaex_element_extension_get_where_type (extension);
+
+                                       if (table != NULL)
+                                               {
+                                                       gdaex_sql_builder_from (sqlb, table, table_alias == NULL ? "" : table_alias);
+                                               }
+
+                                       if (type == GDA_SQL_OPERATOR_TYPE_LIKE
+                                           || type == GDA_SQL_OPERATOR_TYPE_ILIKE
+                                           || type == GDA_SQL_OPERATOR_TYPE_NOTLIKE
+                                           || type == GDA_SQL_OPERATOR_TYPE_NOTILIKE)
+                                               {
+                                                       gchar *str;
+                                                       gint like_type;
+
+                                                       str = g_value_dup_string (value);
+
+                                                       like_type = zak_form_gdaex_element_extension_get_where_like_type (extension);
+                                                       if (like_type < 0)
+                                                               {
+                                                                       g_value_set_string (value, g_strdup_printf ("%%%s", str));
+                                                               }
+                                                       else if (like_type > 0)
+                                                               {
+                                                                       g_value_set_string (value, g_strdup_printf ("%s%%", str));
+                                                               }
+                                                       else
+                                                               {
+                                                                       g_value_set_string (value, g_strdup_printf ("%%%s%%", str));
+                                                               }
+                                               }
+
+                                       gdaex_sql_builder_where (sqlb,
+                                                                0,
+                                                                table == NULL ? priv->table : table,
+                                                                field == NULL ? zak_form_element_get_name (element) : field,
+                                                                field_alias == NULL ? "" : field_alias,
+                                                                type,
+                                                                value,
+                                                                NULL);
+                               }
+
+                       g_value_unset (value);
+               }
+
+       return gdaex_sql_builder_get_sql_where (sqlb, (GdaConnection *)gdaex_get_gdaconnection (priv->gdaex), NULL);
+}
+
 /* PRIVATE */
 static void
 zak_form_gdaex_provider_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
+                                      guint property_id,
+                                      const GValue *value,
+                                      GParamSpec *pspec)
 {
        ZakFormGdaexProvider *zak_form_gdaex_provider = (ZakFormGdaexProvider *)object;
        ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider);
@@ -138,9 +241,9 @@ zak_form_gdaex_provider_set_property (GObject *object,
 
 static void
 zak_form_gdaex_provider_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
+                                      guint property_id,
+                                      GValue *value,
+                                      GParamSpec *pspec)
 {
        ZakFormGdaexProvider *zak_form_gdaex_provider = (ZakFormGdaexProvider *)object;
        ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (zak_form_gdaex_provider);
@@ -176,7 +279,7 @@ zak_form_gdaex_provider_finalize (GObject *gobject)
 }
 
 static GValue
-*zak_form_gdaex_provider_new_gvalue_from_element (ZakFormElement *element)
+*zak_form_gdaex_provider_new_gvalue_from_element (ZakFormElement *element, gboolean for_where)
 {
        GValue *ret;
 
@@ -197,7 +300,14 @@ static GValue
 
                        unformatted = zak_utils_unformat_money_full (value, thousands_saparator, NULL);
 
-                       ret = zak_utils_gvalue_new_int ((gint)unformatted);
+                       if (for_where && unformatted == 0.0)
+                               {
+                                       ret = gda_value_new_null ();
+                               }
+                       else
+                               {
+                                       ret = zak_utils_gvalue_new_int ((gint)unformatted);
+                               }
                }
        else if (g_ascii_strcasecmp (type, "float") == 0)
                {
@@ -209,11 +319,26 @@ static GValue
                        currency_symbol = (gchar *)g_hash_table_lookup (format, "currency_symbol");
 
                        unformatted = zak_utils_unformat_money_full (value, thousands_saparator, currency_symbol);
-                       ret = zak_utils_gvalue_new_float (unformatted);
+
+                       if (for_where && unformatted == 0.0)
+                               {
+                                       ret = gda_value_new_null ();
+                               }
+                       else
+                               {
+                                       ret = zak_utils_gvalue_new_float (unformatted);
+                               }
                }
        else if (g_ascii_strcasecmp (type, "string") == 0)
                {
-                       ret = zak_utils_gvalue_new_string (value);
+                       if (for_where && g_strcmp0 (g_strstrip (g_strdup (value)), "") == 0)
+                               {
+                                       ret = gda_value_new_null ();
+                               }
+                       else
+                               {
+                                       ret = zak_utils_gvalue_new_string (value);
+                               }
                }
        else if (g_ascii_strcasecmp (type, "boolean") == 0)
                {
@@ -324,24 +449,23 @@ zak_form_gdaex_provider_load (ZakFormIProvider *provider, GPtrArray *elements)
                        if (zak_form_element_get_to_load (element))
                                {
                                        gdaex_sql_builder_field (sqlb,
-                                                                                        priv->table,
-                                                                                        zak_form_element_get_name (element),
-                                                                                        "",
-                                                                                        NULL);
-
+                                                                priv->table,
+                                                                zak_form_element_get_name (element),
+                                                                "",
+                                                                NULL);
                                }
 
                        if (zak_form_element_get_is_key (element))
                                {
-                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element);
+                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element, FALSE);
 
                                        gdaex_sql_builder_where (sqlb, (with_key ? GDA_SQL_OPERATOR_TYPE_AND : 0),
-                                                                                        priv->table,
-                                                                                        zak_form_element_get_name (element),
-                                                                                        "",
-                                                                                        GDA_SQL_OPERATOR_TYPE_EQ,
-                                                                                        value,
-                                                                                        NULL);
+                                                                priv->table,
+                                                                zak_form_element_get_name (element),
+                                                                "",
+                                                                GDA_SQL_OPERATOR_TYPE_EQ,
+                                                                value,
+                                                                NULL);
                                        with_key = TRUE;
 
                                        g_value_unset (value);
@@ -383,8 +507,6 @@ zak_form_gdaex_provider_insert (ZakFormIProvider *provider, GPtrArray *elements)
 
        GdaExSqlBuilder *sqlb;
 
-       GdaDataModel *dm;
-
        GValue *value;
 
        ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (provider);
@@ -402,19 +524,18 @@ zak_form_gdaex_provider_insert (ZakFormIProvider *provider, GPtrArray *elements)
                        ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (elements, i);
                        if (zak_form_element_get_to_save (element))
                                {
-                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element);
+                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element, FALSE);
 
                                        gdaex_sql_builder_field (sqlb,
-                                                                                        priv->table,
-                                                                                        zak_form_element_get_name (element),
-                                                                                        "",
-                                                                                        value);
+                                                                priv->table,
+                                                                zak_form_element_get_name (element),
+                                                                "",
+                                                                value);
 
                                        g_value_unset (value);
                                }
                }
 
-
        if (gdaex_sql_builder_execute (sqlb, priv->gdaex, NULL) != 1)
                {
                        ret = FALSE;
@@ -452,28 +573,28 @@ zak_form_gdaex_provider_update (ZakFormIProvider *provider, GPtrArray *elements)
                        ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (elements, i);
                        if (zak_form_element_get_to_save (element))
                                {
-                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element);
+                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element, FALSE);
 
                                        gdaex_sql_builder_field (sqlb,
-                                                                                        priv->table,
-                                                                                        zak_form_element_get_name (element),
-                                                                                        "",
-                                                                                        value);
+                                                                priv->table,
+                                                                zak_form_element_get_name (element),
+                                                                "",
+                                                                value);
 
                                        g_value_unset (value);
                                }
 
                        if (zak_form_element_get_is_key (element))
                                {
-                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element);
+                                       value = zak_form_gdaex_provider_new_gvalue_from_element (element, FALSE);
 
                                        gdaex_sql_builder_where (sqlb, (with_key ? GDA_SQL_OPERATOR_TYPE_AND : 0),
-                                                                                        priv->table,
-                                                                                        zak_form_element_get_name (element),
-                                                                                        "",
-                                                                                        GDA_SQL_OPERATOR_TYPE_EQ,
-                                                                                        value,
-                                                                                        NULL);
+                                                                priv->table,
+                                                                zak_form_element_get_name (element),
+                                                                "",
+                                                                GDA_SQL_OPERATOR_TYPE_EQ,
+                                                                value,
+                                                                NULL);
                                        with_key = TRUE;
 
                                        g_value_unset (value);
index 36c2574d6c65ef4bd2c070f82560d74642665552..670095eb91635df5ec026fcc46dd66ff1b4b8678 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -40,6 +40,9 @@ struct _ZakFormGdaexProviderClass
 ZakFormGdaexProvider *zak_form_gdaex_provider_new (GdaEx *gdaex, const gchar *table);
 
 
+gchar *zak_form_gdaex_provider_get_where_str (ZakFormGdaexProvider *provider, GPtrArray *elements);
+
+
 G_END_DECLS
 
 
diff --git a/src/formelementextension.c b/src/formelementextension.c
new file mode 100644 (file)
index 0000000..9d2c162
--- /dev/null
@@ -0,0 +1,450 @@
+/*
+ * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ *
+ * 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
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <libxml/xpath.h>
+
+#include "formelementextension.h"
+
+enum
+       {
+               PROP_0
+       };
+
+static void zak_form_gdaex_element_extension_class_init (ZakFormGdaExElementExtensionClass *class);
+static void zak_form_gdaex_element_extension_init (ZakFormGdaExElementExtension *zak_form_gdaex_element_extension);
+
+static void zak_form_gdaex_element_extension_set_property (GObject *object,
+                                                           guint property_id,
+                                                           const GValue *value,
+                                                           GParamSpec *pspec);
+static void zak_form_gdaex_element_extension_get_property (GObject *object,
+                                                           guint property_id,
+                                                           GValue *value,
+                                                           GParamSpec *pspec);
+
+static void zak_form_gdaex_element_extension_dispose (GObject *gobject);
+static void zak_form_gdaex_element_extension_finalize (GObject *gobject);
+
+typedef struct
+       {
+               gchar *table;
+               gchar *table_alias;
+               gchar *field;
+               gchar *field_alias;
+               GdaSqlOperatorType type;
+               gint like_type;
+       } ZakFormGdaExElementExtensionPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (ZakFormGdaExElementExtension, zak_form_gdaex_element_extension, G_TYPE_OBJECT)
+
+static void
+zak_form_gdaex_element_extension_class_init (ZakFormGdaExElementExtensionClass *class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+       object_class->set_property = zak_form_gdaex_element_extension_set_property;
+       object_class->get_property = zak_form_gdaex_element_extension_get_property;
+       object_class->dispose = zak_form_gdaex_element_extension_dispose;
+       object_class->finalize = zak_form_gdaex_element_extension_finalize;
+}
+
+static void
+zak_form_gdaex_element_extension_init (ZakFormGdaExElementExtension *zak_form_gdaex_element_extension)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (zak_form_gdaex_element_extension);
+
+       priv->table = NULL;
+       priv->table_alias = NULL;
+       priv->field = NULL;
+       priv->field_alias = NULL;
+       priv->type = 0;
+       priv->like_type = 0;
+}
+
+GObject
+*zak_form_gdaex_element_extension_new (void)
+{
+       GObject *ret = g_object_new (zak_form_gdaex_element_extension_get_type (), NULL);
+
+       return ret;
+}
+
+/**
+ * zak_form_gdaex_element_extension_xml_parsing:
+ * @extension:
+ * @xnode:
+ *
+ */
+gboolean
+zak_form_gdaex_element_extension_xml_parsing (GObject *extension, xmlNode *xnode)
+{
+       xmlNode *xnodetmp;
+       gchar *prop;
+
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (ZAK_FORM_GDAEX_ELEMENT_EXTENSION (extension));
+
+       xnodetmp = xnode->children;
+       while (xnodetmp)
+               {
+                       if (g_strcmp0 ((gchar *)xnodetmp->name, "where") == 0)
+                               {
+                                       zak_form_gdaex_element_extension_set_where_table ((ZakFormGdaExElementExtension *)extension,
+                                                                                         (const gchar *)xmlGetProp (xnodetmp, (const xmlChar *)"table"));
+                                       zak_form_gdaex_element_extension_set_where_table_alias ((ZakFormGdaExElementExtension *)extension,
+                                                                                               (const gchar *)xmlGetProp (xnodetmp, (const xmlChar *)"table_alias"));
+
+                                       zak_form_gdaex_element_extension_set_where_field ((ZakFormGdaExElementExtension *)extension,
+                                                                                         (const gchar *)xmlGetProp (xnodetmp, (const xmlChar *)"field"));
+                                       zak_form_gdaex_element_extension_set_where_field_alias ((ZakFormGdaExElementExtension *)extension,
+                                                                                               (const gchar *)xmlGetProp (xnodetmp, (const xmlChar *)"field_alias"));
+
+                                       prop = xmlGetProp (xnodetmp, (const xmlChar *)"type");
+                                       if (g_strcmp0 (prop, "lt") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_LT);
+                                               }
+                                       else if (g_strcmp0 (prop, "let") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_LEQ);
+                                               }
+                                       else if (g_strcmp0 (prop, "e") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_EQ);
+                                               }
+                                       else if (g_strcmp0 (prop, "ne") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_DIFF);
+                                               }
+                                       else if (g_strcmp0 (prop, "gt") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_GT);
+                                               }
+                                       else if (g_strcmp0 (prop, "get") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_GEQ);
+                                               }
+                                       else if (g_strcmp0 (prop, "like") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_LIKE);
+                                               }
+                                       else if (g_strcmp0 (prop, "nlike") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_NOTLIKE);
+                                               }
+                                       else if (g_strcmp0 (prop, "ilike") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_ILIKE);
+                                               }
+                                       else if (g_strcmp0 (prop, "nilike") == 0)
+                                               {
+                                                       zak_form_gdaex_element_extension_set_where_type ((ZakFormGdaExElementExtension *)extension,
+                                                                                                        GDA_SQL_OPERATOR_TYPE_NOTILIKE);
+                                               }
+
+                                       if (g_strcmp0 (prop, "like") == 0
+                                               || g_strcmp0 (prop, "nlike") == 0
+                                           || g_strcmp0 (prop, "ilike") == 0
+                                               || g_strcmp0 (prop, "nilike") == 0)
+                                               {
+                                                       prop = xmlGetProp (xnodetmp, (const xmlChar *)"like");
+                                                       if (g_strcmp0 (prop, "start") == 0)
+                                                               {
+                                                                       zak_form_gdaex_element_extension_set_where_like_type ((ZakFormGdaExElementExtension *)extension, -1);
+                                                               }
+                                                       else if (g_strcmp0 (prop, "end") == 0)
+                                                               {
+                                                                       zak_form_gdaex_element_extension_set_where_like_type ((ZakFormGdaExElementExtension *)extension, 1);
+                                                               }
+                                                       else
+                                                               {
+                                                                       zak_form_gdaex_element_extension_set_where_like_type ((ZakFormGdaExElementExtension *)extension, 0);
+                                                               }
+                                               }
+                               }
+
+                       xnodetmp = xnodetmp->next;
+               }
+
+       return TRUE;
+}
+
+/**
+ * zak_form_gdaex_element_extension_get_where_table:
+ * @extension:
+ *
+ * Returns: the table.
+ */
+gchar
+*zak_form_gdaex_element_extension_get_where_table (ZakFormGdaExElementExtension *extension)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       return priv->table;
+}
+
+/**
+ * zak_form_gdaex_element_extension_set_where_table:
+ * @extension:
+ * @table:
+ */
+void
+zak_form_gdaex_element_extension_set_where_table (ZakFormGdaExElementExtension *extension, const gchar *table)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       if (table != NULL)
+               {
+                       priv->table = g_strdup (table);
+                       if (g_strcmp0 (g_strstrip (priv->table), "") == 0)
+                               {
+                                       g_free (priv->table);
+                                       priv->table = NULL;
+                               }
+               }
+}
+
+/**
+ * zak_form_gdaex_element_extension_get_where_table_alias:
+ * @extension:
+ *
+ * Returns: the table alias.
+ */
+gchar
+*zak_form_gdaex_element_extension_get_where_table_alias (ZakFormGdaExElementExtension *extension)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       return priv->table_alias;
+}
+
+/**
+ * zak_form_gdaex_element_extension_set_where_table_alias:
+ * @extension:
+ * @table_alias:
+ */
+void
+zak_form_gdaex_element_extension_set_where_table_alias (ZakFormGdaExElementExtension *extension, const gchar *table_alias)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       if (table_alias != NULL)
+               {
+                       priv->table_alias = g_strdup (table_alias);
+                       if (g_strcmp0 (g_strstrip (priv->table_alias), "") == 0)
+                               {
+                                       g_free (priv->table_alias);
+                                       priv->table_alias = NULL;
+                               }
+               }
+}
+
+/**
+ * zak_form_gdaex_element_extension_get_where_field:
+ * @extension:
+ *
+ * Returns: the field.
+ */
+gchar
+*zak_form_gdaex_element_extension_get_where_field (ZakFormGdaExElementExtension *extension)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       return priv->field;
+}
+
+/**
+ * zak_form_gdaex_element_extension_set_where_field:
+ * @extension:
+ * @field:
+ */
+void
+zak_form_gdaex_element_extension_set_where_field (ZakFormGdaExElementExtension *extension, const gchar *field)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       if (field != NULL)
+               {
+                       priv->field = g_strdup (field);
+                       if (g_strcmp0 (g_strstrip (priv->field), "") == 0)
+                               {
+                                       g_free (priv->field);
+                                       priv->field = NULL;
+                               }
+               }
+}
+
+/**
+ * zak_form_gdaex_element_extension_get_where_field_alias:
+ * @extension:
+ *
+ * Returns: the field alias.
+ */
+gchar
+*zak_form_gdaex_element_extension_get_where_field_alias (ZakFormGdaExElementExtension *extension)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       return priv->field_alias;
+}
+
+/**
+ * zak_form_gdaex_element_extension_set_where_field_alias:
+ * @extension:
+ * @field_alias:
+ */
+void
+zak_form_gdaex_element_extension_set_where_field_alias (ZakFormGdaExElementExtension *extension, const gchar *field_alias)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       if (field_alias != NULL)
+               {
+                       priv->field_alias = g_strdup (field_alias);
+                       if (g_strcmp0 (g_strstrip (priv->field_alias), "") == 0)
+                               {
+                                       g_free (priv->field_alias);
+                                       priv->field_alias = NULL;
+                               }
+               }
+}
+
+/**
+ * zak_form_gdaex_element_extension_get_where_type:
+ * @extension:
+ *
+ * Returns: the where type.
+ */
+GdaSqlOperatorType
+zak_form_gdaex_element_extension_get_where_type (ZakFormGdaExElementExtension *extension)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       return priv->type;
+}
+
+/**
+ * zak_form_gdaex_element_extension_set_where_type:
+ * @extension:
+ * @type:
+ */
+void
+zak_form_gdaex_element_extension_set_where_type (ZakFormGdaExElementExtension *extension, GdaSqlOperatorType type)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       priv->type = type;
+}
+
+/**
+ * zak_form_gdaex_element_extension_get_where_like_type:
+ * @extension:
+ *
+ * Returns: the where like type.
+ */
+gint
+zak_form_gdaex_element_extension_get_where_like_type (ZakFormGdaExElementExtension *extension)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       return priv->like_type;
+}
+
+/**
+ * zak_form_gdaex_element_extension_set_where_like_type:
+ * @extension:
+ * @type:
+ */
+void
+zak_form_gdaex_element_extension_set_where_like_type (ZakFormGdaExElementExtension *extension, gint type)
+{
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (extension);
+
+       priv->like_type = type;
+}
+
+/* PRIVATE */
+static void
+zak_form_gdaex_element_extension_set_property (GObject *object,
+                   guint property_id,
+                   const GValue *value,
+                   GParamSpec *pspec)
+{
+       ZakFormGdaExElementExtension *zak_form_gdaex_element_extension = (ZakFormGdaExElementExtension *)object;
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (zak_form_gdaex_element_extension);
+
+       switch (property_id)
+               {
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+               }
+}
+
+static void
+zak_form_gdaex_element_extension_get_property (GObject *object,
+                   guint property_id,
+                   GValue *value,
+                   GParamSpec *pspec)
+{
+       ZakFormGdaExElementExtension *zak_form_gdaex_element_extension = (ZakFormGdaExElementExtension *)object;
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (zak_form_gdaex_element_extension);
+
+       switch (property_id)
+               {
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+               }
+}
+
+static void
+zak_form_gdaex_element_extension_dispose (GObject *gobject)
+{
+       ZakFormGdaExElementExtension *zak_form_gdaex_element_extension = (ZakFormGdaExElementExtension *)gobject;
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (zak_form_gdaex_element_extension);
+
+
+
+       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+       parent_class->dispose (gobject);
+}
+
+static void
+zak_form_gdaex_element_extension_finalize (GObject *gobject)
+{
+       ZakFormGdaExElementExtension *zak_form_gdaex_element_extension = (ZakFormGdaExElementExtension *)gobject;
+       ZakFormGdaExElementExtensionPrivate *priv = zak_form_gdaex_element_extension_get_instance_private (zak_form_gdaex_element_extension);
+
+
+
+       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+       parent_class->finalize (gobject);
+}
diff --git a/src/formelementextension.h b/src/formelementextension.h
new file mode 100644 (file)
index 0000000..32ab23f
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ *
+ * 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
+ */
+
+#ifndef __ZAK_FORM_GDAEX_ELEMENT_EXTENSION_H__
+#define __ZAK_FORM_GDAEX_ELEMENT_EXTENSION_H__
+
+#include <glib-object.h>
+
+#include <libgda/sql-parser/gda-sql-statement.h>
+
+
+G_BEGIN_DECLS
+
+
+#define ZAK_FORM_GDAEX_TYPE_ELEMENT_EXTENSION zak_form_gdaex_element_extension_get_type ()
+G_DECLARE_DERIVABLE_TYPE (ZakFormGdaExElementExtension, zak_form_gdaex_element_extension, ZAK_FORM_GDAEX, ELEMENT_EXTENSION, GObject)
+
+struct _ZakFormGdaExElementExtensionClass
+{
+       GObjectClass parent_cleass;
+};
+
+GObject *zak_form_gdaex_element_extension_new (void);
+
+gchar *zak_form_gdaex_element_extension_get_where_table (ZakFormGdaExElementExtension *extension);
+void zak_form_gdaex_element_extension_set_where_table (ZakFormGdaExElementExtension *extension, const gchar *table);
+
+gchar *zak_form_gdaex_element_extension_get_where_table_alias (ZakFormGdaExElementExtension *extension);
+void zak_form_gdaex_element_extension_set_where_table_alias (ZakFormGdaExElementExtension *extension, const gchar *table_alias);
+
+gchar *zak_form_gdaex_element_extension_get_where_field (ZakFormGdaExElementExtension *extension);
+void zak_form_gdaex_element_extension_set_where_field (ZakFormGdaExElementExtension *extension, const gchar *field);
+
+gchar *zak_form_gdaex_element_extension_get_where_field_alias (ZakFormGdaExElementExtension *extension);
+void zak_form_gdaex_element_extension_set_where_field_alias (ZakFormGdaExElementExtension *extension, const gchar *field_alias);
+
+GdaSqlOperatorType zak_form_gdaex_element_extension_get_where_type (ZakFormGdaExElementExtension *extension);
+void zak_form_gdaex_element_extension_set_where_type (ZakFormGdaExElementExtension *extension, GdaSqlOperatorType type);
+
+gint zak_form_gdaex_element_extension_get_where_like_type (ZakFormGdaExElementExtension *extension);
+void zak_form_gdaex_element_extension_set_where_like_type (ZakFormGdaExElementExtension *extension, gint where_like_type);
+
+
+G_END_DECLS
+
+
+#endif /* __ZAK_FORM_GDAEX_ELEMENT_EXTENSION_H__ */