| | 34 | void _midgard_core_qb_set_metadata_sql(GString *str, const gchar *table) |
|---|
| | 35 | { |
|---|
| | 36 | if(table == NULL) { |
|---|
| | 37 | |
|---|
| | 38 | g_string_append(str, |
|---|
| | 39 | "guid, sitegroup, " |
|---|
| | 40 | "metadata_creator, " |
|---|
| | 41 | "metadata_created, " |
|---|
| | 42 | "metadata_revisor, " |
|---|
| | 43 | "metadata_revised, " |
|---|
| | 44 | "metadata_revision, " |
|---|
| | 45 | "metadata_locker, " |
|---|
| | 46 | "metadata_locked, " |
|---|
| | 47 | "metadata_approver, " |
|---|
| | 48 | "metadata_approved, " |
|---|
| | 49 | "metadata_authors, metadata_owner, " |
|---|
| | 50 | "metadata_schedule_start, " |
|---|
| | 51 | "metadata_schedule_end, " |
|---|
| | 52 | "metadata_hidden, " |
|---|
| | 53 | "metadata_nav_noentry, metadata_size, metadata_published, " |
|---|
| | 54 | "metadata_exported, " |
|---|
| | 55 | "metadata_imported," |
|---|
| | 56 | "metadata_deleted, metadata_score, "); |
|---|
| | 57 | |
|---|
| | 58 | return; |
|---|
| | 59 | } |
|---|
| | 60 | |
|---|
| | 61 | g_string_append_printf(str, |
|---|
| | 62 | "%s.guid, %s.sitegroup, " |
|---|
| | 63 | "%s.metadata_creator, " |
|---|
| | 64 | "NULLIF(%s.metadata_created,'0000-00-00 00:00:00') AS metadata_created, " |
|---|
| | 65 | "%s.metadata_revisor, " |
|---|
| | 66 | "NULLIF(%s.metadata_revised,'0000-00-00 00:00:00') AS metadata_revised, " |
|---|
| | 67 | "%s.metadata_revision, " |
|---|
| | 68 | "%s.metadata_locker, " |
|---|
| | 69 | "NULLIF(%s.metadata_locked,'0000-00-00 00:00:00') AS metadata_locked, " |
|---|
| | 70 | "%s.metadata_approver, " |
|---|
| | 71 | "NULLIF(%s.metadata_approved,'0000-00-00 00:00:00') AS metadata_approved, " |
|---|
| | 72 | "%s.metadata_authors, %s.metadata_owner, " |
|---|
| | 73 | "NULLIF(%s.metadata_schedule_start,'0000-00-00 00:00:00') AS metadata_schedule_start, " |
|---|
| | 74 | "NULLIF(%s.metadata_schedule_end,'0000-00-00 00:00:00') AS metadata_schedule_end, " |
|---|
| | 75 | "%s.metadata_hidden, " |
|---|
| | 76 | "%s.metadata_nav_noentry, %s.metadata_size, %s.metadata_published, " |
|---|
| | 77 | "NULLIF(%s.metadata_exported,'0000-00-00 00:00:00') AS metadata_exported, " |
|---|
| | 78 | "NULLIF(%s.metadata_imported,'0000-00-00 00:00:00') AS metadata_imported," |
|---|
| | 79 | "%s.metadata_deleted, %s.metadata_score, ", |
|---|
| | 80 | table, table, table, table, table, table, table, table, table, |
|---|
| | 81 | table, table, table, table, table, table, table, table, table, |
|---|
| | 82 | table, table, table, table, table); |
|---|
| | 83 | } |
|---|
| | 84 | |
|---|
| | 85 | gchar *__get_multilang_select(MidgardQueryBuilder *builder) |
|---|
| | 86 | { |
|---|
| | 87 | GString *str = g_string_new("SELECT "); |
|---|
| | 88 | _midgard_core_qb_set_metadata_sql(str, NULL); |
|---|
| | 89 | |
|---|
| | 90 | guint n_props, i, j = 0; |
|---|
| | 91 | MidgardObjectClass *klass = MIDGARD_OBJECT_CLASS(g_type_class_peek(builder->type)); |
|---|
| | 92 | GParamSpec **pspecs = |
|---|
| | 93 | g_object_class_list_properties(G_OBJECT_CLASS(klass), &n_props); |
|---|
| | 94 | |
|---|
| | 95 | if(!pspecs) |
|---|
| | 96 | g_error("__get_multilang_select. No properties."); |
|---|
| | 97 | |
|---|
| | 98 | for(i = 0; i < n_props; i++) { |
|---|
| | 99 | |
|---|
| | 100 | /* UGLY, FIXME */ |
|---|
| | 101 | if(g_str_equal(pspecs[i]->name, "guid") |
|---|
| | 102 | || g_str_equal(pspecs[i]->name, "sitegroup") |
|---|
| | 103 | || g_str_equal(pspecs[i]->name, "metadata") |
|---|
| | 104 | || g_str_equal(pspecs[i]->name, "action")) |
|---|
| | 105 | continue; |
|---|
| | 106 | |
|---|
| | 107 | if(j > 0) |
|---|
| | 108 | g_string_append_printf(str, ", %s", pspecs[i]->name); |
|---|
| | 109 | else |
|---|
| | 110 | g_string_append_printf(str, " %s", pspecs[i]->name); |
|---|
| | 111 | |
|---|
| | 112 | j++; |
|---|
| | 113 | } |
|---|
| | 114 | |
|---|
| | 115 | g_string_append(str, " FROM ( "); |
|---|
| | 116 | |
|---|
| | 117 | return g_string_free(str, FALSE); |
|---|
| | 118 | } |
|---|
| | 119 | |
|---|
| | 120 | gboolean _midgard_core_qb_is_multilingual(MidgardQueryBuilder *builder) |
|---|
| | 121 | { |
|---|
| | 122 | if(builder->unset_lang) |
|---|
| | 123 | return FALSE; |
|---|
| | 124 | |
|---|
| | 125 | if(builder->lang < 0) |
|---|
| | 126 | return TRUE; |
|---|
| | 127 | |
|---|
| | 128 | return FALSE; |
|---|
| | 129 | } |
|---|
| | 130 | |
|---|