~ubuntu-branches/debian/jessie/arb/jessie

« back to all changes in this revision

Viewing changes to MERGE/MG_names.cxx

  • Committer: Package Import Robot
  • Author(s): Elmar Pruesse, Andreas Tille, Elmar Pruesse
  • Date: 2014-09-02 15:15:06 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140902151506-jihq58b3iz342wif
Tags: 6.0.2-1
[ Andreas Tille ]
* New upstream version
  Closes: #741890
* debian/upstream -> debian/upstream/metadata
* debian/control:
   - Build-Depends: added libglib2.0-dev
   - Depends: added mafft, mrbayes
* debian/rules
   - Add explicite --remove-section=.comment option to manual strip call
* cme fix dpkg-control
* arb-common.dirs: Do not create unneeded lintian dir
* Add turkish debconf translation (thanks for the patch to Mert Dirik
  <mertdirik@gmail.com>)
  Closes: #757497

[ Elmar Pruesse ]
* patches removed:
   - 10_config.makefiles.patch,
     80_no_GL.patch
       removed in favor of creating file from config.makefile.template via 
       sed in debian/control
   - 20_Makefile_main.patch
       merged upstream
   - 21_Makefiles.patch
       no longer needed
   - 30_tmpfile_CVE-2008-5378.patch: 
       merged upstream
   - 50_fix_gcc-4.8.patch:
       merged upstream
   - 40_add_libGLU.patch:
       libGLU not needed for arb_ntree)
   - 60_use_debian_packaged_raxml.patch:
       merged upstream
   - 70_hardening.patch
       merged upstream
   - 72_add_math_lib_to_linker.patch
       does not appear to be needed
* patches added:
   - 10_upstream_r12793__show_db_load_progress:
       backported patch showing progress while ARB is loading a database
       (needed as indicator/splash screen while ARB is launching)
   - 20_upstream_r12794__socket_permissions:
       backported security fix
   - 30_upstream_r12814__desktop_keywords:
       backported add keywords to desktop (fixes lintian warning)
   - 40_upstream_r12815__lintian_spelling:
       backported fix for lintian reported spelling errors
   - 50_private_nameservers
       change configuration to put nameservers into users home dirs
       (avoids need for shared writeable directory)
   - 60_use_debian_phyml
       use phyml from debian package for both interfaces in ARB
* debian/rules:
   - create config.makefile from override_dh_configure target
   - use "make tarfile" in override_dh_install
   - remove extra cleaning not needed for ARB 6
   - use "dh_install --list-missing" to avoid missing files
   - added override_dh_fixperms target
* debian/control:
   - added libarb-dev package
   - Depends: added phyml, xdg-utils
   - Suggests: removed phyml
   - fix lintian duplicate-short-description (new descriptions)
* debian/*.install:
   - "unrolled" confusing globbing to select files
   - pick files from debian/tmp
   - moved all config files to /etc/arb
* debian/arb-common.templates: updated
* scripts:
   - removed arb-add-pt-server
   - launch-wrapper: 
     - only add demo.arb to newly created $ARBUSERDATA
     - pass commandline arguments through bin/arb wrapper
   - preinst: removing old PT server index files on upgrade from 5.5*
   - postinst: set setgid on shared PT dir
* rewrote arb.1 manfile
* added file icon for ARB databases
* using upstream arb_tcp.dat

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <cstdio>
2
 
#include <cstdlib>
3
 
#include <cstring>
4
 
 
5
 
#include <arbdb.h>
 
1
// =============================================================== //
 
2
//                                                                 //
 
3
//   File      : MG_names.cxx                                      //
 
4
//   Purpose   :                                                   //
 
5
//                                                                 //
 
6
//   Institute of Microbiology (Technical University Munich)       //
 
7
//   http://www.arb-home.de/                                       //
 
8
//                                                                 //
 
9
// =============================================================== //
 
10
 
 
11
#include "merge.hxx"
 
12
 
 
13
#include <AW_rename.hxx>
6
14
#include <aw_root.hxx>
7
 
#include <aw_device.hxx>
 
15
#include <aw_awar.hxx>
 
16
#include <aw_msg.hxx>
8
17
#include <aw_window.hxx>
9
 
#include <AW_rename.hxx>
10
 
#include "merge.hxx"
 
18
#include <arb_progress.h>
11
19
 
12
20
// --------------------------------------------------------------------------------
13
21
 
14
 
#define AWAR_MERGE_ADDID "tmp/merge1/addid"
15
 
#define AWAR_DEST_ADDID  "tmp/merge2/addid"
 
22
#define AWAR_ADDID_SRC  AWAR_MERGE_TMP_SRC "addid"
 
23
#define AWAR_ADDID_DST  AWAR_MERGE_TMP_DST "addid"
16
24
 
17
 
#define AWAR_ADDID_MATCH   "tmp/merge/addidmatch"
18
 
#define AWAR_RENAME_STATUS "tmp/merge/renamestat"
19
 
#define AWAR_ALLOW_DUPS    "tmp/merge/allowdups"
20
 
#define AWAR_OVERRIDE      "tmp/merge/override"
 
25
#define AWAR_ADDID_MATCH   AWAR_MERGE_TMP "addidmatch"
 
26
#define AWAR_RENAME_STATUS AWAR_MERGE_TMP "renamestat"
 
27
#define AWAR_ALLOW_DUPS    AWAR_MERGE_TMP "allowdups"
 
28
#define AWAR_OVERRIDE      AWAR_MERGE_TMP "override"
21
29
 
22
30
// --------------------------------------------------------------------------------
23
31
 
31
39
// --------------------------------------------------------------------------------
32
40
 
33
41
static const char *addids_match_info(AW_root *aw_root) {
34
 
    char       *addid1 = aw_root->awar(AWAR_MERGE_ADDID)->read_string();
35
 
    char       *addid2 = aw_root->awar(AWAR_DEST_ADDID)->read_string();
36
 
    const char *result = (strcmp(addid1, addid2) == 0) ? "Ok" : "MISMATCH!";
37
 
 
38
 
    free(addid2);
39
 
    free(addid1);
40
 
    
 
42
    char *src_addid = aw_root->awar(AWAR_ADDID_SRC)->read_string();
 
43
    char *dst_addid = aw_root->awar(AWAR_ADDID_DST)->read_string();
 
44
 
 
45
    const char *result = (strcmp(src_addid, dst_addid) == 0) ? "Ok" : "MISMATCH!";
 
46
 
 
47
    free(dst_addid);
 
48
    free(src_addid);
 
49
 
41
50
    return result;
42
51
}
43
52
 
44
53
static void addids_match_info_refresh_cb(AW_root *aw_root) {
45
54
    aw_root->awar(AWAR_ADDID_MATCH)->write_string(addids_match_info(aw_root));
46
 
    MG_set_renamed(false, aw_root, "Needed (add.field changed)"); 
 
55
    MG_set_renamed(false, aw_root, "Needed (add.field changed)");
47
56
}
48
57
 
49
 
void MG_create_db_dependent_rename_awars(AW_root *aw_root, GBDATA *gb_merge, GBDATA *gb_dest) {
 
58
void MG_create_db_dependent_rename_awars(AW_root *aw_root, GBDATA *gb_src, GBDATA *gb_dst) {
50
59
    static bool created = false;
51
60
 
52
61
    if (!created) {
53
 
        GB_transaction t1(gb_merge);
54
 
        GB_transaction t2(gb_dest);
 
62
        GB_transaction src_ta(gb_src);
 
63
        GB_transaction dst_ta(gb_dst);
55
64
        GB_ERROR       error = 0;
56
65
 
57
66
        // Awars for additional ID need to be mapped, cause they use same db-path in both DBs
58
67
 
59
 
        GBDATA     *gb_addid1 = GB_search(gb_merge, AWAR_NAMESERVER_ADDID, GB_STRING);
60
 
        GBDATA     *gb_addid2 = GB_search(gb_dest, AWAR_NAMESERVER_ADDID, GB_STRING);
61
 
        const char *addid1    = gb_addid1 ? GB_read_char_pntr(gb_addid1) : "";
62
 
        const char *addid2    = gb_addid2 ? GB_read_char_pntr(gb_addid2) : "";
 
68
        GBDATA *gb_src_addid = GB_search(gb_src, AWAR_NAMESERVER_ADDID, GB_STRING);
 
69
        GBDATA *gb_dst_addid = GB_search(gb_dst, AWAR_NAMESERVER_ADDID, GB_STRING);
 
70
 
 
71
        const char *src_addid = gb_src_addid ? GB_read_char_pntr(gb_src_addid) : "";
 
72
        const char *dst_addid = gb_dst_addid ? GB_read_char_pntr(gb_dst_addid) : "";
63
73
 
64
74
        // use other as default (needed e.g. for import)
65
 
        if (gb_addid1 && !gb_addid2) {
66
 
            gb_addid2             = GB_create(gb_dest, AWAR_NAMESERVER_ADDID, GB_STRING);
67
 
            if (!gb_addid2) error = GB_await_error();
68
 
            else error            = GB_write_string(gb_addid2, addid1);
 
75
        if (gb_src_addid && !gb_dst_addid) {
 
76
            gb_dst_addid             = GB_create(gb_dst, AWAR_NAMESERVER_ADDID, GB_STRING);
 
77
            if (!gb_dst_addid) error = GB_await_error();
 
78
            else error               = GB_write_string(gb_dst_addid, src_addid);
69
79
        }
70
 
        else if (!gb_addid1 && gb_addid2) {
71
 
            gb_addid1             = GB_create(gb_merge, AWAR_NAMESERVER_ADDID, GB_STRING);
72
 
            if (!gb_addid1) error = GB_await_error();
73
 
            else error            = GB_write_string(gb_addid1, addid2);
 
80
        else if (!gb_src_addid && gb_dst_addid) {
 
81
            gb_src_addid             = GB_create(gb_src, AWAR_NAMESERVER_ADDID, GB_STRING);
 
82
            if (!gb_src_addid) error = GB_await_error();
 
83
            else error               = GB_write_string(gb_src_addid, dst_addid);
74
84
        }
75
85
 
76
86
        if (!error) {
77
 
            AW_awar *awar_addid1 = aw_root->awar_string(AWAR_MERGE_ADDID, "xxx", gb_merge);
78
 
            AW_awar *awar_addid2 = aw_root->awar_string(AWAR_DEST_ADDID, "xxx", gb_dest);
79
 
 
80
 
            awar_addid1->unmap(); awar_addid1->map(gb_addid1);
81
 
            awar_addid2->unmap(); awar_addid2->map(gb_addid2);
82
 
 
83
 
            awar_addid1->add_callback(addids_match_info_refresh_cb);
84
 
            awar_addid2->add_callback(addids_match_info_refresh_cb);
 
87
            AW_awar *awar_src_addid = aw_root->awar_string(AWAR_ADDID_SRC, "xxx", gb_src);
 
88
            AW_awar *awar_dst_addid = aw_root->awar_string(AWAR_ADDID_DST, "xxx", gb_dst);
 
89
 
 
90
            awar_src_addid->unmap(); awar_src_addid->map(gb_src_addid);
 
91
            awar_dst_addid->unmap(); awar_dst_addid->map(gb_dst_addid);
 
92
 
 
93
            awar_src_addid->add_callback(addids_match_info_refresh_cb);
 
94
            awar_dst_addid->add_callback(addids_match_info_refresh_cb);
85
95
 
86
96
            addids_match_info_refresh_cb(aw_root);
87
97
        }
88
 
        
 
98
 
89
99
        if (error) {
90
 
            error = t1.close(error);
91
 
            error = t2.close(error);
 
100
            error = src_ta.close(error);
 
101
            error = dst_ta.close(error);
92
102
            aw_message(error);
93
103
        }
94
104
        else {
108
118
 
109
119
GB_ERROR MG_expect_renamed() {
110
120
    GB_ERROR error = 0;
111
 
    if (!was_renamed) error = "First you have to rename species in both databases";
 
121
    if (!was_renamed) error = "First you have to synchronize species IDs in both databases";
112
122
    return error;
113
123
}
114
124
 
115
125
// --------------------------------------------------------------------------------
116
126
 
117
127
static GB_ERROR renameDB(const char *which, GBDATA *gb_db, bool allowDups) {
118
 
    aw_openstatus(GBS_global_string("Generating new names in %s database", which));
119
 
    aw_status("Contacting name server");
120
 
 
121
 
    bool     isDuplicatesWarning;
122
 
    GB_ERROR error = AWTC_pars_names(gb_db, 1, &isDuplicatesWarning);
 
128
    arb_progress progress(GBS_global_string("Generating new names in %s database", which));
 
129
    bool         isDuplicatesWarning;
 
130
    GB_ERROR     error = AWTC_pars_names(gb_db, &isDuplicatesWarning);
123
131
 
124
132
    if (error) {
125
133
        error = GBS_global_string("While renaming %s DB:\n%s", which, error);
130
138
        }
131
139
    }
132
140
 
133
 
    aw_closestatus();
134
141
    return error;
135
142
}
136
143
 
141
148
    bool      allowDups = aw_root->awar(AWAR_ALLOW_DUPS)->read_int();
142
149
 
143
150
    if (strcmp(match, "Ok") == 0) {
144
 
        error = renameDB("source", GLOBAL_gb_merge, allowDups);
145
 
        if (!error) error = renameDB("destination", GLOBAL_gb_dest, allowDups);
 
151
        error = renameDB("source", GLOBAL_gb_src, allowDups);
 
152
        if (!error) error = renameDB("destination", GLOBAL_gb_dst, allowDups);
146
153
    }
147
154
    else {
148
155
        error = "Denying rename - additional fields have to match!";
169
176
    }
170
177
}
171
178
 
172
 
AW_window *MG_merge_names_cb(AW_root *awr){
173
 
    static AW_window_simple *aws = 0;
174
 
    if (!aws) {
175
 
        aws = new AW_window_simple;
176
 
        aws->init( awr, "MERGE_AUTORENAME_SPECIES", "SYNCHRONIZE NAMES");
177
 
        aws->load_xfig("merge/names.fig");
178
 
 
179
 
        aws->at("close");aws->callback((AW_CB0)AW_POPDOWN);
180
 
        aws->create_button("CLOSE","CLOSE","C");
181
 
 
182
 
        aws->at("help");
183
 
        aws->callback(AW_POPUP_HELP,(AW_CL)"mg_names.hlp");
184
 
        aws->create_button("HELP","HELP","H");
185
 
 
186
 
        aws->at("addid1");
187
 
        aws->create_input_field(AWAR_MERGE_ADDID, 10);
188
 
 
189
 
        aws->at("addid2");
190
 
        aws->create_input_field(AWAR_DEST_ADDID, 10);
191
 
 
192
 
        aws->at("dups");
193
 
        aws->label("Allow merging duplicates (dangerous! see HELP)");
194
 
        aws->create_toggle(AWAR_ALLOW_DUPS);
195
 
 
196
 
        aws->at("override");
197
 
        aws->label("Override (even more dangerous! see HELP)");
198
 
        aws->callback(override_toggle_cb);
199
 
        aws->create_toggle(AWAR_OVERRIDE);
200
 
 
201
 
        aws->at("match");
202
 
        aws->button_length(12);
203
 
        aws->create_button("MATCH", AWAR_ADDID_MATCH, 0, "+");
204
 
 
205
 
        aws->at("status");
206
 
        aws->button_length(25);
207
 
        aws->label("Status:");
208
 
        aws->create_button("STATUS", AWAR_RENAME_STATUS, 0, "+");
209
 
 
210
 
        aws->at("rename");
211
 
        aws->callback(rename_both_databases);
212
 
        aws->create_autosize_button("RENAME_DATABASES","Rename species");
213
 
        
214
 
        aws->button_length(0);
215
 
        aws->shadow_width(1);
216
 
        aws->at("icon");
217
 
        aws->callback(AW_POPUP_HELP,(AW_CL)"mg_names.hlp");
218
 
        aws->create_button("HELP_MERGE", "#merge/icon.bitmap");
219
 
    }
 
179
AW_window *MG_create_merge_names_window(AW_root *awr) {
 
180
    AW_window_simple *aws = new AW_window_simple;
 
181
 
 
182
    aws->init(awr, "MERGE_AUTORENAME_SPECIES", "Synchronize IDs");
 
183
    aws->load_xfig("merge/names.fig");
 
184
 
 
185
    aws->at("close"); aws->callback((AW_CB0)AW_POPDOWN);
 
186
    aws->create_button("CLOSE", "CLOSE", "C");
 
187
 
 
188
    aws->at("help");
 
189
    aws->callback(makeHelpCallback("mg_names.hlp"));
 
190
    aws->create_button("HELP", "HELP", "H");
 
191
 
 
192
    aws->at("addid1");
 
193
    aws->create_input_field(AWAR_ADDID_SRC, 10);
 
194
 
 
195
    aws->at("addid2");
 
196
    aws->create_input_field(AWAR_ADDID_DST, 10);
 
197
 
 
198
    aws->at("dups");
 
199
    aws->label("Allow merging duplicates (dangerous! see HELP)");
 
200
    aws->create_toggle(AWAR_ALLOW_DUPS);
 
201
 
 
202
    aws->at("override");
 
203
    aws->label("Override (even more dangerous! see HELP)");
 
204
    aws->callback(override_toggle_cb);
 
205
    aws->create_toggle(AWAR_OVERRIDE);
 
206
 
 
207
    aws->at("match");
 
208
    aws->button_length(12);
 
209
    aws->create_button(0, AWAR_ADDID_MATCH, 0, "+");
 
210
 
 
211
    aws->at("status");
 
212
    aws->button_length(25);
 
213
    aws->label("Status:");
 
214
    aws->create_button(0, AWAR_RENAME_STATUS, 0, "+");
 
215
 
 
216
    aws->at("rename");
 
217
    aws->callback(rename_both_databases);
 
218
    aws->create_autosize_button("RENAME_DATABASES", "Synchronize");
 
219
 
 
220
    aws->button_length(0);
 
221
    aws->shadow_width(1);
 
222
    aws->at("icon");
 
223
    aws->callback(makeHelpCallback("mg_names.hlp"));
 
224
    aws->create_button("HELP_MERGE", "#merge/icon.xpm");
 
225
 
220
226
    return aws;
221
227
}