~ubuntu-branches/ubuntu/vivid/apgdiff/vivid

« back to all changes in this revision

Viewing changes to src/main/java/cz/startnet/utils/pgdiff/PgDiffTriggers.java

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2010-10-02 19:35:17 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101002193517-9wesve8sksxcktkc
Tags: 2.2-1
* New upstream version.
* Update homepage location.
* Finally enable test suite, yay!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright 2006 StartNet s.r.o.
 
3
 *
 
4
 * Distributed under MIT license
 
5
 */
1
6
package cz.startnet.utils.pgdiff;
2
7
 
3
8
import cz.startnet.utils.pgdiff.schema.PgSchema;
20
25
     * Creates a new instance of PgDiffTriggers.
21
26
     */
22
27
    private PgDiffTriggers() {
23
 
        super();
24
28
    }
25
29
 
26
30
    /**
27
 
     * Outputs commands for creation of new triggers.
 
31
     * Outputs statements for creation of new triggers.
28
32
     *
29
33
     * @param writer writer the output should be written to
30
 
     * @param arguments object containing arguments settings
31
34
     * @param oldSchema original schema
32
35
     * @param newSchema new schema
33
36
     */
34
37
    public static void createTriggers(final PrintWriter writer,
35
 
            final PgDiffArguments arguments, final PgSchema oldSchema,
36
 
            final PgSchema newSchema) {
 
38
            final PgSchema oldSchema, final PgSchema newSchema) {
37
39
        for (final PgTable newTable : newSchema.getTables()) {
38
40
            final PgTable oldTable;
39
41
 
46
48
            // Add new triggers
47
49
            for (final PgTrigger trigger : getNewTriggers(oldTable, newTable)) {
48
50
                writer.println();
49
 
                writer.println(
50
 
                        trigger.getCreationSQL(arguments.isQuoteNames()));
 
51
                writer.println(trigger.getCreationSQL());
51
52
            }
52
53
        }
53
54
    }
54
55
 
55
56
    /**
56
 
     * Outputs commands for dropping triggers.
 
57
     * Outputs statements for dropping triggers.
57
58
     *
58
59
     * @param writer writer the output should be written to
59
 
     * @param arguments object containing arguments settings
60
60
     * @param oldSchema original schema
61
61
     * @param newSchema new schema
62
62
     */
63
63
    public static void dropTriggers(final PrintWriter writer,
64
 
            final PgDiffArguments arguments, final PgSchema oldSchema,
65
 
            final PgSchema newSchema) {
 
64
            final PgSchema oldSchema, final PgSchema newSchema) {
66
65
        for (final PgTable newTable : newSchema.getTables()) {
67
66
            final PgTable oldTable;
68
67
 
76
75
            for (final PgTrigger trigger :
77
76
                    getDropTriggers(oldTable, newTable)) {
78
77
                writer.println();
79
 
                writer.println(trigger.getDropSQL(arguments.isQuoteNames()));
 
78
                writer.println(trigger.getDropSQL());
80
79
            }
81
80
        }
82
81
    }
91
90
     */
92
91
    private static List<PgTrigger> getDropTriggers(final PgTable oldTable,
93
92
            final PgTable newTable) {
 
93
        @SuppressWarnings("CollectionWithoutInitialCapacity")
94
94
        final List<PgTrigger> list = new ArrayList<PgTrigger>();
95
95
 
96
 
        if ((newTable != null) && (oldTable != null)) {
 
96
        if (newTable != null && oldTable != null) {
97
97
            final List<PgTrigger> newTriggers = newTable.getTriggers();
98
98
 
99
99
            for (final PgTrigger oldTrigger : oldTable.getTriggers()) {
116
116
     */
117
117
    private static List<PgTrigger> getNewTriggers(final PgTable oldTable,
118
118
            final PgTable newTable) {
 
119
        @SuppressWarnings("CollectionWithoutInitialCapacity")
119
120
        final List<PgTrigger> list = new ArrayList<PgTrigger>();
120
121
 
121
122
        if (newTable != null) {