Skip to content
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
/architect.log
/.DS_Store
/custom_jre/
/nbproject/private/
/target
/pom.xml
/lib/power-lib
/install-mvn-deps.sh
124 changes: 124 additions & 0 deletions genPom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/bin/sh
#
#Generate the pom.xml and install-mvn-deps.sh files.
#The install-mvn-deps.sh installs dependencies in the local
#maven repository.

SCRIPT=`readlink -f "$0"`
SCRIPTD=${SCRIPT%/*}

POM="pom.xml"
DEP_SCRIPT="install-mvn-deps.sh"

if [ `pwd` != "${SCRIPTD}" ]; then
echo "Script execution must be from the project directory $SCRIPTD"
return
fi

if [ ! -d ./lib/power-lib ]; then
echo "sqlpower-library libs do not not exist."
echo "copy/link sqlpower-library/lib/main to power-architect/lib/power-lib"
echo "copy/link sqlpower-library/dist/sqlpower_library.jar to power-architect/lib/power-lib"
fi

rm -f "$DEP_SCRIPT"
rm -f "$POM"

touch $DEP_SCRIPT
touch $POM
chmod +x $DEP_SCRIPT

cat <<OUT >> $POM

<?xml version="1.0" ?>
<project>

<modelVersion>4.0.0</modelVersion>
<groupId>com.intellires</groupId>
<artifactId>power-architect</artifactId>
<version>1.0</version>
<name>PowerArchitect</name>
<packaging>jar</packaging>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
OUT

for file in `ls ./lib/*.jar ./lib/power-lib/*.jar`
do
FILENAME=${file##*/}
NAME=${FILENAME%.*}

ALREADY_DONE=`cat "$DEP_SCRIPT" |grep -c $NAME`

if [ $ALREADY_DONE -eq 0 ]; then
echo " <dependency>" >> $POM
echo " <groupId>pwr-arch-local-jar</groupId>" >> $POM
echo " <artifactId>"${NAME}"</artifactId>" >> $POM
echo " <version>1</version>" >> $POM
echo " </dependency>" >> $POM

echo "mvn install:install-file -Dfile="$file" -DgroupId=pwr-arch-local-jar -DartifactId="${NAME}" -Dversion=1 -Dpackaging=jar" >> ./install-mvn-deps.sh >> $DEP_SCRIPT
fi
done;

ALREADY_DONE=`cat "$DEP_SCRIPT" |grep -c sqlpower_library.jar`
if [ $ALREADY_DONE -eq 0 ]; then
echo "copy/link sqlpower-library/dist/sqlpower_library.jar to power-architect/lib/power-lib"
fi

cat <<OUT >> $POM
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>ca.sqlpower.architect.swingui.ArchitectFrame</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<executable>java</executable>
<!-- optional -->
<workingDirectory>/tmp</workingDirectory>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>ca.sqlpower.architect.swingui.ArchitectFrame</argument>
</arguments>
<!--environmentVariables>
<LANG>en_US</LANG>
</environmentVariables-->
</configuration>
</plugin>
</plugins>
</build>
</project>
OUT

4 changes: 2 additions & 2 deletions src/main/java/ca/sqlpower/architect/ArchitectVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public class ArchitectVersion extends Version {
* Minor version number. This changes when new features appear that might
* break forward compatibility.
*/
public static final String APP_VERSION_MINOR = "0";
public static final String APP_VERSION_MINOR = "1";

/**
* Tiny version number. This number changes with each release, but resets
* back to 0 when the minor version changes. All versions under the same
* minor version number are fully compatible with each other.
*/
public static final String APP_VERSION_TINY = "11";
public static final String APP_VERSION_TINY = "1";

/**
* Suffixes indicate pre-release builds. They normally progress from "alpha"
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/ca/sqlpower/architect/ProjectSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class ProjectSettings extends AbstractSPObject {
private boolean showAkTag = true;

private ColumnVisibility columnVisibility = ColumnVisibility.ALL;

private boolean quoteIdentifiers = false;

public static enum ColumnVisibility {
ALL,
Expand Down Expand Up @@ -171,6 +173,18 @@ public void setColumnVisibility(ColumnVisibility columnVisibility) {
firePropertyChange("columnVisibility", oldValue, columnVisibility);
}

@Accessor(isInteresting=true)
public boolean isQuoteIdentifiers() {
return quoteIdentifiers;
}

@Mutator
public void setQuoteIdentifiers(boolean quoteIdentifiers) {
boolean oldValue = this.quoteIdentifiers;
this.quoteIdentifiers= quoteIdentifiers;
firePropertyChange("quoteIdentifiers", oldValue, quoteIdentifiers);
}

@Override
protected boolean removeChildImpl(SPObject child) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Conflict(String type, String catalog, String schema, String name) {
}

public String getQualifiedName() {
return DDLUtils.toQualifiedName(catalog, schema, name);
return DDLUtils.toQualifiedName(catalog, schema, name, "", "");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ca/sqlpower/architect/ddl/DDLStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void setTargetSchema(String targetSchema) {
}

public String toString() {
return getType()+" "+DDLUtils.toQualifiedName(getTargetCatalog(), getTargetSchema(), object.getName());
return getType()+" "+DDLUtils.toQualifiedName(getTargetCatalog(), getTargetSchema(), object.getName(), "", "");
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/ca/sqlpower/architect/ddl/DDLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ private DDLUtils() {
* </ul>
* @throws NullPointerException if table is null
*/
public static String toQualifiedName(SQLTable table) {
public static String toQualifiedName(SQLTable table, String identifierQuoteChar) {
return toQualifiedName(
table.getCatalogName(),
table.getSchemaName(),
table.getName());
table.getName(),
identifierQuoteChar,
identifierQuoteChar);
}

/**
Expand Down
40 changes: 37 additions & 3 deletions src/main/java/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ public boolean isReservedWord(String word){
private ArchitectSwingSession session;

private JDBCDataSourceType dsType = null;

protected String identifierQuoteChar = "";
protected String identifierQuoteCharRight = "";

public boolean isIdentifierQuoted() {
return !identifierQuoteChar.isBlank();
}

public String getQuoteLeft() {
return identifierQuoteChar;
}

public String getQuoteRight() {
return identifierQuoteCharRight;
}

public GenericDDLGenerator(boolean allowConnection) throws SQLException {
this.allowConnection = allowConnection;
Expand All @@ -183,6 +198,18 @@ public GenericDDLGenerator() throws SQLException {

public String generateDDLScript(ArchitectSwingSession architectSwingSession, Collection<SQLTable> tables) throws SQLException, SQLObjectException {
session = architectSwingSession;
if (session.getProjectSettings().isQuoteIdentifiers()) {
if (this instanceof SQLServerDDLGenerator) {
identifierQuoteChar="[";
identifierQuoteCharRight="]";
} else {
identifierQuoteChar = "\"";
identifierQuoteCharRight = "\"";
}
} else {
identifierQuoteChar = "";
identifierQuoteCharRight = "";
}
List<DDLStatement> statements = generateDDLStatements(tables);

ddl = new StringBuffer(4000);
Expand Down Expand Up @@ -1140,7 +1167,12 @@ public String toIdentifier(String name) {
* schema are omitted if null).
*/
public String toQualifiedName(SQLTable t) {
return toQualifiedName(t.getPhysicalName());
return DDLUtils.toQualifiedName(
t.getCatalogName(),
t.getSchemaName(),
t.getPhysicalName(),
identifierQuoteChar,
identifierQuoteCharRight);
}

/**
Expand All @@ -1163,8 +1195,7 @@ public String toQualifiedName(SQLIndex i) {
public String toQualifiedName(String tname) {
String catalog = getTargetCatalog();
String schema = getTargetSchema();
tname = getQuotedPhysicalName(tname);
return DDLUtils.toQualifiedName(catalog, schema, tname);
return DDLUtils.toQualifiedName(catalog, schema, tname, identifierQuoteChar, identifierQuoteCharRight);
}

// ---------------------- accessors and mutators ----------------------
Expand Down Expand Up @@ -1466,6 +1497,9 @@ public boolean supportsEnumeration() {
*/
public String getQuotedPhysicalName(String name) {
logger.debug(" getQuotedphysical name: "+name);
if (name != null && !name.isBlank()) {
return identifierQuoteChar+name+identifierQuoteCharRight;
}
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public void addIndex(SQLIndex index) throws SQLObjectException {
print("UNIQUE ");
}
print("INDEX ");
print(toIdentifier(index.getName()));
print(getQuotedPhysicalName(toIdentifier(index.getName())));
if(index.getType() != null) {
print(" USING " + index.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public boolean supportsEnumeration() {
@Override
public String getQuotedPhysicalName(String name) {
if (name == null) return null;
if (getDsType()!=null && (getDsType().getSupportsQuotingName() || isComparingDMForPostgres())
if (getDsType()!=null && (getDsType().getSupportsQuotingName() || isComparingDMForPostgres() ||isIdentifierQuoted())
&& !name.isEmpty() && !(name.startsWith("\"") && name.endsWith("\""))) {
name = "\""+name+"\"";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,11 @@ public void addComment(SQLTable t, boolean includeColumns) {
// So we only write a SQL comment with the table's comment here

if (t.getRemarks() != null && t.getRemarks().trim().length() > 0) {
print("\n-- Comment for table [" + getPhysicalName(t) + "]: ");
if (isIdentifierQuoted()) {
print("\n-- Comment for table " + getPhysicalName(t) + ": ");
} else {
print("\n-- Comment for table [" + getPhysicalName(t) + "]: ");
}
print(t.getRemarks().replaceAll(REGEX_CRLF, "\n-- "));
endStatement(StatementType.COMMENT, t);

Expand Down Expand Up @@ -515,7 +519,7 @@ public void addIndex(SQLIndex index) throws SQLObjectException {
print(" NONCLUSTERED ");
}
print("INDEX ");
print(DDLUtils.toQualifiedName(null,null,index.getName()));
print(DDLUtils.toQualifiedName(null,null,index.getName(),this.identifierQuoteChar, this.identifierQuoteChar));
print("\n ON ");
print(toQualifiedName(index.getParent()));
print("\n ( ");
Expand Down Expand Up @@ -770,7 +774,7 @@ protected String columnCheckConstraint(SQLColumn c, List<SQLCheckConstraint> che
@Override
public String getQuotedPhysicalName(String name) {
if (name == null) return null;
if (getDsType()!=null && getDsType().getSupportsQuotingName()
if ((getDsType()!=null && getDsType().getSupportsQuotingName() || isIdentifierQuoted())
&& !name.isEmpty() && !(name.startsWith("[") && name.endsWith("]"))) {
name = "["+name+"]";
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ca/sqlpower/architect/etl/kettle/KettleJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void doExport(List<SQLTable> tableList, SQLDatabase targetDB, List<SQLTab

for (SQLTable sourceTable: tableMapping.keySet()) {
StringBuffer buffer = tableMapping.get(sourceTable);
buffer.append(" FROM " + DDLUtils.toQualifiedName(sourceTable));
buffer.append(" FROM " + DDLUtils.toQualifiedName(sourceTable, ""));
}

for (SQLTable sourceTable: tableMapping.keySet()) {
Expand All @@ -331,7 +331,7 @@ public void doExport(List<SQLTable> tableList, SQLDatabase targetDB, List<SQLTab
transMeta.addDatabase(databaseMeta);

TableInputMeta tableInputMeta = new TableInputMeta();
String stepName = databaseMeta.getName() + ":" + DDLUtils.toQualifiedName(sourceTable);
String stepName = databaseMeta.getName() + ":" + DDLUtils.toQualifiedName(sourceTable, "");
StepMeta stepMeta = new StepMeta("TableInput", stepName, tableInputMeta);
stepMeta.setDraw(true);
stepMeta.setLocation(inputSteps.size()==0?spacing:(inputSteps.size())*spacing, (inputSteps.size()+1)*spacing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected boolean doProfileImpl(TableProfileResult tpr)
sql.append(col.getName());
first = false;
}
sql.append(" FROM ").append(DDLUtils.toQualifiedName(table));
sql.append(" FROM ").append(DDLUtils.toQualifiedName(table, ""));

logger.debug("About to execute profiling query: " + sql);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ public static interface Saver {
* Sets whether the AK Tags will be shown
*/
public void setShowAkTag(boolean showAkTag);

/**
* Will DDL identifiers be quoted.
*/
public boolean isQuoteIdentifiers();

/**
* Sets for quoted DDL identifiers.
*/
public void setQuoteIdentifiers(boolean quoteIdentifiers);

/**
* Sets the choice of what columns to show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,14 @@ public void setShowAkTag(boolean showAkTag) {
getProjectSettings().setShowAkTag(showAkTag);
}

public boolean isQuoteIdentifiers() {
return getProjectSettings().isQuoteIdentifiers();
}

public void setQuoteIdentifiers(boolean quoteIdentifiers) {
getProjectSettings().setQuoteIdentifiers(quoteIdentifiers);
}

/**
* Sets the visibility of columns in the playpen of this session.
*
Expand Down
Loading