summaryrefslogtreecommitdiff
path: root/src/plugins/db.core/src/com/motorolamobility/studio/android/db/core/ui/IDbNode.java
blob: 30ff785e5ecd040ade0d8b7a4ef162c6582bd60b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.motorolamobility.studio.android.db.core.ui;

import java.util.List;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.datatools.modelbase.sql.tables.Table;

import com.motorolamobility.studio.android.db.core.model.TableModel;
import com.motorolamobility.studio.android.db.core.ui.action.ITableCreatorNode;

/**
 * This interface is meant to be implemented by databse nodes.
 * it defines standard methods for manipulating a database.
 */
public interface IDbNode extends ITreeNode, ITableCreatorNode
{

    /**
     * Connect to the database.
     * Implementors must connect to the database, load the tables and notify the UI.
     * @return
     */
    IStatus connect();

    /**
     * Connect to the database.
     * Implementors must disconnect from the database, free this node children and notify the UI.
     * @return
     */
    IStatus disconnect();

    /**
     * Checks if db is connected
     * @return true if db is connected, false otherwise
     */
    boolean isConnected();

    /**
     * @param tables
     * @return
     */
    IStatus createTables(List<TableModel> tables);

    /**
     * Create a table in this db.
     * Implementors must create the table and add a TableNode representing the new table as a new child.
     * UI must be notified after child is added.
     * @param table The new table representation
     * @return
     */
    IStatus createTable(TableModel table);

    /**
     * Delete a table from this db.
     * The table node representing this table must also be removed from this dbNode children.
     * UI must be notified.
     * @param tableNode The node table to be removed.
     * @return
     */
    IStatus deleteTable(ITableNode tableNode);

    /**
     * Get all tables from this db.
     * @return A {@link List<Table>} with all tables from this database
     */
    List<Table> getTables();

    /**
     * Get a table from this db with the specified name.
     * @return A {@link List<Table>} with all tables from this database
     */
    Table getTable(String tableName);

    /**
     * Delete the database represented by this node.
     * @return Status.OK if operation is successful, Status.ERROR otherwise. The status message explains the fail reason.
     */
    IStatus deleteDb();
}