comparison src/jdbcpgbackup/DbBackupObject.java @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:7ecd1a4ef557
1 /* Copyright (c) 2012 Tomislav Gountchev <tomi@gountchev.net> */
2
3 package jdbcpgbackup;
4
5 abstract class DbBackupObject {
6
7 protected final String name;
8 protected final Schema schema;
9 protected final String owner;
10
11 protected DbBackupObject(String name, Schema schema, String owner) {
12 this.name = name;
13 this.schema = schema;
14 this.owner = owner;
15 }
16
17 final String getName() {
18 return name;
19 }
20
21 String getFullname() {
22 return schema.getName() + "." + name;
23 }
24
25 final String getOwner() {
26 return owner;
27 }
28
29 String getSql(DataFilter dataFilter) {
30 StringBuilder buf = new StringBuilder();
31 if (!owner.equals(schema.getOwner())) {
32 buf.append("SET ROLE ").append(owner);
33 buf.append(" ;\n");
34 }
35 appendCreateSql(buf, dataFilter);
36 if (!owner.equals(schema.getOwner())) {
37 buf.append("SET ROLE ").append(schema.getOwner());
38 buf.append(" ;\n");
39 }
40 return buf.toString();
41 }
42
43 protected abstract StringBuilder appendCreateSql(StringBuilder buf);
44
45 protected StringBuilder appendCreateSql(StringBuilder buf, DataFilter dataFilter) {
46 return appendCreateSql(buf);
47 }
48
49 }