@Override public void execute(final GUI gui) { final DialogExport dialog = new DialogExport(gui); if (!dialog.ok()) return; final IOFile root = new IOFile(dialog.path()); // check if existing files will be overwritten if (root.exists()) { IO file = null; boolean overwrite = false; final Data d = gui.context.data(); final IntList il = d.resources.docs(); final int is = il.size(); for (int i = 0; i < is; i++) { file = root.merge(Token.string(d.text(il.get(i), true))); if (file.exists()) { if (overwrite) { // more than one file will be overwritten; check remaining tests file = null; break; } overwrite = true; } } if (overwrite) { // show message for overwriting files or directories final String msg = file == null ? FILES_REPLACE_X : FILE_EXISTS_X; if (file == null) file = root; if (!BaseXDialog.confirm(gui, Util.info(msg, file))) return; } } DialogProgress.execute(gui, new Export(root.path())); }
@Override public boolean eq(final ANode node) { // no database node if (!(node instanceof DBNode)) return false; // ensure that the pre value is contained in the target documents final DBNode db = (DBNode) node; return data == db.data() && pres.contains(db.pre()); }
/** * Returns a document test. This test will be called by {@link AxisPath#index} if the context * value only consists of database nodes. * * @param rt root value * @return document test */ static Test get(final Value rt) { // use simple test if database contains only one document final Data data = rt.data(); if (data.meta.ndocs == 1) return Test.DOC; // adopt nodes from existing sequence if (rt instanceof DBNodeSeq) { final DBNodeSeq seq = (DBNodeSeq) rt; return seq.all() ? Test.DOC : new InvDocTest(new IntList(seq.pres()), data); } // loop through all documents and add pre values of documents // not more than 2^31 documents supported final IntList il = new IntList((int) rt.size()); for (final Item it : rt) il.add(((DBNode) it).pre()); return new InvDocTest(il, data); }