Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Override anotations #258

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class PgTable extends PgRelation {
* List of names of inherited tables.
*/
@SuppressWarnings("CollectionWithoutInitialCapacity")
private final List<Pair<String,String>> inherits = new ArrayList<Pair<String,String>>();
private final List<Pair<String, String>> inherits = new ArrayList<Pair<String, String>>();
/**
* WITH clause. If value is null then it is not set, otherwise can be set to
* OIDS=true, OIDS=false, or storage parameters can be set.
Expand Down Expand Up @@ -117,6 +117,7 @@ public List<PgConstraint> getConstraints() {
*
* @return relation kind
*/
@Override
public String getRelationKind() {
return "TABLE";
}
Expand Down Expand Up @@ -170,14 +171,14 @@ public String getCreationSQL(final PgSchema schema) {

first = true;

for (final Pair<String,String> inheritPair : inherits) {
for (final Pair<String, String> inheritPair : inherits) {
if (first) {
first = false;
} else {
sbSQL.append(", ");
}
String inheritTableName = null;
if(schema.getName().equals(inheritPair.getL())){
if (schema.getName().equals(inheritPair.getL())) {
inheritTableName = inheritPair.getR();
} else {
inheritTableName = String.format("%s.%s", inheritPair.getL(), inheritPair.getR());
Expand Down Expand Up @@ -209,7 +210,7 @@ public String getCreationSQL(final PgSchema schema) {
sbSQL.append("SERVER ");
sbSQL.append(getForeignServer());
}

if (tablespace != null && !tablespace.isEmpty()) {
sbSQL.append(System.getProperty("line.separator"));
sbSQL.append("TABLESPACE ");
Expand All @@ -220,7 +221,7 @@ public String getCreationSQL(final PgSchema schema) {

//Inherited column default override
for (PgInheritedColumn column : getInheritedColumns()) {
if(column.getDefaultValue() != null){
if (column.getDefaultValue() != null) {
sbSQL.append(System.getProperty("line.separator"));
sbSQL.append(System.getProperty("line.separator"));
sbSQL.append("ALTER TABLE ONLY ");
Expand Down Expand Up @@ -261,9 +262,9 @@ public String getCreationSQL(final PgSchema schema) {
public void addInherits(final String schemaName, final String tableName) {
inherits.add(new Pair<String, String>(schemaName, tableName));
final PgTable inheritedTable = database.getSchema(schemaName).getTable(tableName);
for( PgColumn column : inheritedTable.getColumns() ) {
PgInheritedColumn inheritedColumn = new PgInheritedColumn(column);
inheritedColumns.add(inheritedColumn);
for (PgColumn column : inheritedTable.getColumns()) {
PgInheritedColumn inheritedColumn = new PgInheritedColumn(column);
inheritedColumns.add(inheritedColumn);
}
}

Expand All @@ -272,7 +273,7 @@ public void addInherits(final String schemaName, final String tableName) {
*
* @return {@link #inherits}
*/
public List<Pair<String,String>> getInherits() {
public List<Pair<String, String>> getInherits() {
return Collections.unmodifiableList(inherits);
}

Expand All @@ -299,6 +300,7 @@ public String getWith() {
*
* @return {@link #tablespace}
*/
@Override
public String getTablespace() {
return tablespace;
}
Expand All @@ -308,6 +310,7 @@ public String getTablespace() {
*
* @param tablespace {@link #tablespace}
*/
@Override
public void setTablespace(final String tablespace) {
this.tablespace = tablespace;
}
Expand All @@ -317,6 +320,7 @@ public void setTablespace(final String tablespace) {
*
* @param column column
*/
@Override
public void addColumn(final PgColumn column) {
columns.add(column);
}
Expand All @@ -338,6 +342,7 @@ public void addInheritedColumn(final PgInheritedColumn inheritedColumn) {
* @return found inheritedColumn or null if no such inheritedColumn
* has been found
*/
@Override
public PgInheritedColumn getInheritedColumn(final String name) {
if (inherits != null && !inherits.isEmpty()) {
for (PgInheritedColumn inheritedColumn : inheritedColumns) {
Expand Down Expand Up @@ -376,6 +381,7 @@ public void addConstraint(final PgConstraint constraint) {
* @return true if table contains given inheritedColumn {@code name},
* otherwise false
*/
@Override
public boolean containsInheritedColumn(final String name) {
if (inherits != null && !inherits.isEmpty()) {
for (PgInheritedColumn inheritedColumn : inheritedColumns) {
Expand Down Expand Up @@ -431,32 +437,32 @@ public boolean isUnlogged() {
public void setUnlogged(boolean unlogged) {
this.unlogged = unlogged;
}

/**
* Foreign Tables
*/

@Override
public String getDropSQL() {

return "DROP " + ((isForeign()) ? "FOREIGN ":"") + getRelationKind() + " " + PgDiffUtils.getDropIfExists() +
PgDiffUtils.getQuotedName(getName()) + ";";
}

public boolean isForeign() {
return foreign;
}

public void setForeign(boolean foreign) {
this.foreign = foreign;
}
public void setForeignServer(String server){
foreignServer = server;

public void setForeignServer(String server) {
foreignServer = server;
}
public String getForeignServer(){
return foreignServer;

public String getForeignServer() {
return foreignServer;
}

public Boolean hasRLSEnabled() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public List<String> getDeclaredColumnNames() {
*
* @return relation kind
*/
@Override
public String getRelationKind() {
if (materialized)
return "MATERIALIZED VIEW";
Expand Down Expand Up @@ -189,6 +190,7 @@ public String getQuery() {
*
* @return found column or null if no such column has been found
*/
@Override
public PgColumn getColumn(final String name) {
PgColumn col = super.getColumn(name);
if (col == null && !declareColumnNames) {
Expand All @@ -210,6 +212,7 @@ public PgColumn getColumn(final String name) {
*
* @return true if table contains given column {@code name}, otherwise false
*/
@Override
public boolean containsColumn(final String name) {
return true;
}
Expand Down