Skip to content

Commit

Permalink
[studio] First GUI release
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Jan 6, 2014
1 parent 3ad35ce commit 927d412
Show file tree
Hide file tree
Showing 17 changed files with 315 additions and 160 deletions.
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 1.0.11

([b079c0ca31f3006ce3b8e779f5e778319ce4ed72](https://github.com/cchantep/acolyte/commit/b079c0ca31f3006ce3b8e779f5e778319ce4ed72) @ [studio](https://github.com/cchantep/acolyte/tree/master/studio)) First GUI release

([d9d4e5c831916305c415708203d8c8ef6d6ba5ce](https://github.com/cchantep/acolyte/commit/d9d4e5c831916305c415708203d8c8ef6d6ba5ce) @ [core](https://github.com/cchantep/acolyte/tree/master/core)) Update groupId to publish artifacts on Central via Sonatype

([3cc594b2d3e3030e6b09c91b3384092723eb1020](https://github.com/cchantep/acolyte/commit/3cc594b2d3e3030e6b09c91b3384092723eb1020) @ [scala](https://github.com/cchantep/acolyte/tree/master/scala)) Update limit of row columns from 26 to 52

([d6e4d9a9033ede803ad863a4682ca63123ac7040](https://github.com/cchantep/acolyte/commit/d6e4d9a9033ede803ad863a4682ca63123ac7040) @ [core](https://github.com/cchantep/acolyte/tree/master/core)) Update limit of row columns from 26 to 52

## 1.0.10

([500abb5493a1b6221b5e5c0f2fdf102a5bcf88ff](https://github.com/cchantep/acolyte/commit/500abb5493a1b6221b5e5c0f2fdf102a5bcf88ff) @ [scala](https://github.com/cchantep/acolyte/tree/master/scala)) Connection properties support:
Expand Down Expand Up @@ -118,3 +128,4 @@ list.append("row");
```scala
Acolyte.withQueryHandler({ e: Execution => rowList })
```

2 changes: 1 addition & 1 deletion project/Acolyte.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Acolyte extends Build with Core with Studio {

lazy val root = Project(id = "acolyte", base = file(".")).
aggregate(core, scala, studio).settings(
version := "1.0.11",
version := "1.0.11-2",
scalaVersion := "2.10.3",
publishTo := Some(Resolver.file("file",
new File(Path.userHome.absolutePath+"/.m2/repository"))))
Expand Down
2 changes: 1 addition & 1 deletion project/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ trait Core {
lazy val core = Project(id = "core", base = file("core")).settings(
name := "acolyte-core",
organization := "org.eu.acolyte",
version := "1.0.11",
version := "1.0.11-2",
scalaVersion := "2.10.3",
javacOptions in Test ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
autoScalaLibrary := false,
Expand Down
5 changes: 3 additions & 2 deletions project/Studio.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ trait Studio {
organization <<= pom { _ \\ "project" \ "groupId" text },
name <<= pom { _ \\ "project" \ "artifactId" text },
version <<= pom { _ \\ "project" \ "version" text },
javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
javacOptions in Test ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
scalacOptions += "-feature",
crossPaths := false,
resolvers <<= pom {
_ \\ "project" \ "repositories" \ "repository" map (r
(r \ "name").text at (r \ "url").text)
},
externalResolvers += Resolver.mavenLocal
externalResolvers += Resolver.mavenLocal,
publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))
) ++ externalPom( /*dependencies*/ )
}
2 changes: 1 addition & 1 deletion project/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ LIMIT="5522b798bc436a19bbdf58ac9e2a53c4072e2683"

echo "## $1\n"

git log --grep '^\[core\]' --grep '^\[scala\]' "$LIMIT..HEAD" | grep -v '^Author:' | grep -v '^Date:' | perl -pe 's|^commit (.+)$|# \1|;s|^ ||;s|^\[([a-zA-Z0-9]+)\]|\1|' | awk 'BEGIN { c = ""; d = 0; } { if (c != "" && $0 != "") { d = 1; m = substr($0, 1, index($0, " ")-1); t = substr($0, index($0, " ")+1); printf("([%s](https://github.com/cchantep/acolyte/commit/%s) @ [%s](https://github.com/cchantep/acolyte/tree/master/%s)) %s\n", c, c, m, m, t); } if ($1 == "#") { c = $2; d = 0; } if (d == 1) { if (c != "") { c = ""; } else { printf("%s\n", $0); } } }'
git log --grep '^\[core\]' --grep '^\[scala\]' --grep '^\[studio\]' "$LIMIT..HEAD" | grep -v '^Author:' | grep -v '^Date:' | perl -pe 's|^commit (.+)$|# \1|;s|^ ||;s|^\[([a-zA-Z0-9]+)\]|\1|' | awk 'BEGIN { c = ""; d = 0; } { if (c != "" && $0 != "") { d = 1; m = substr($0, 1, index($0, " ")-1); t = substr($0, index($0, " ")+1); printf("([%s](https://github.com/cchantep/acolyte/commit/%s) @ [%s](https://github.com/cchantep/acolyte/tree/master/%s)) %s\n", c, c, m, m, t); } if ($1 == "#") { c = $2; d = 0; } if (d == 1) { if (c != "") { c = ""; } else { printf("%s\n", $0); } } }'
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,9 @@ Documentation is generated using Maven 3: `mvn -f site.xml site`
To local repository:

```
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=core/target/acolyte-core-$VERSION.pom -Dfile=core/target/acolyte-core-$VERSION.jar -Durl=file://$PATH
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=core/target/acolyte-core-$VERSION.pom -Dfile=core/target/acolyte-core-$VERSION.jar -Durl=file://$REPOPATH
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scala/target/scala-2.10/acolyte-scala_2.10-$VERSION.pom -Dfile=scala/target/scala-2.10/acolyte-scala_2.10-$VERSION.jar -Durl=file://$PATH
mvn gpg:sign-and-deploy-file -Dkeyname=$KEY -DpomFile=scala/target/scala-2.10/acolyte-scala_2.10-$VERSION.pom -Dfile=scala/target/scala-2.10/acolyte-scala_2.10-$VERSION.jar -Durl=file://$REPOPATH
```

At Sonatype:
Expand Down
4 changes: 2 additions & 2 deletions scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "acolyte-scala"

organization := "org.eu.acolyte"

version := "1.0.11-2"
version := "1.0.11-3"

scalaVersion := "2.10.3"

Expand Down Expand Up @@ -54,7 +54,7 @@ sourceGenerators in Compile <+= (baseDirectory in Compile) zip (sourceManaged in
resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"

libraryDependencies ++= Seq(
"org.eu.acolyte" % "acolyte-core" % "1.0.11",
"org.eu.acolyte" % "acolyte-core" % "1.0.11-2",
"org.specs2" %% "specs2" % "2.3.2" % "test")

pomExtra := (
Expand Down
15 changes: 14 additions & 1 deletion studio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,23 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>acolyte.Studio</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
68 changes: 48 additions & 20 deletions studio/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,72 @@ Once connected to database, Acolyte Studio formats query result in Acolyte row s

## Download

PENDING
- Platform independent: [standalone JAR](https://github.com/cchantep/acolyte/releases/download/1.0.11/acolyte-studio-1.0.11.jar)

## Graphical interface

PENDING
![Acolyte Studio GUI](https://github.com/cchantep/acolyte/raw/master/studio/src/site/images/mockup1.png)

General use case is following one.

1. Configure JDBC access.
2. Prepare SQL query.
3. Test SQL query.
4. Define column mappings, then extract rows with that (using previous query).
5. Convert extracted rows to Acolyte syntax.

![Test result](https://github.com/cchantep/acolyte/raw/master/studio/src/site/images/mockup2.png) ![Conversion](https://github.com/cchantep/acolyte/raw/master/studio/src/site/images/mockup3.png)

## Command-line interface

Row formatter can be called from CLI:

```
java -jar STUDIO.jar acolyte.RowFormatter <options>
java -jar STUDIO.jar acolyte.RowFormatter <arguments>
```

Either configuration file is found at `$USER_HOME/.acolyte/studio.properties` and arguments are SQL query followed by column types (after there, from #7), or arguments are:
If second argument is a path to JDBC driver, then arguments are expected to be:

1. JDBC URL,
2. path to JAR of JDBC driver,
3. name of database user,
4. user password,
5. character set of database,
4. character set of database,
5. user password,
6. output format (Java or Scala),
7. SQL query,
8. type of first column,
9. type of second column,
10. ...

## Column types

- bigdecimal: `java.math.BigDecimal`
- bool: `boolean`
- byte: `byte`
- short: `short`
- date: `java.sql.Date`
- double: `double`
- float: `float`
- int: `int`
- long: `long`
- time: `java.sql.Time`
- timestamp: `java.sql.Timestamp`
- string: `String`
Otherwise, arguments #1 to #4 are omitted, values loaded from configuration file `$USER_HOME/.acolyte/studio.properties`:

1. User password,
2. output format (Java or Scala),
3. SQL query,
4. type of first column,
5. type of second column,
6. ...

### Column types

- bigdecimal
- bool
- byte
- short
- date
- double
- float
- int
- long
- time
- timestamp
- string

## Configuration file

File `studio.properties` uses Java properties syntax, with following keys:

- jdbc.url: JDBC URL
- jdbc.driverPath: Path to JDBC driver JAR
- db.user: Name of database user
- db.charset: Database character set
19 changes: 14 additions & 5 deletions studio/src/main/java/acolyte/Formatting.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ enum Formatting {
* Java formatting
*/
Java("Java", "text/java",
"import acolyte.RowList.Column;\r\nimport acolyte.RowLists;",
"Column.defineCol(%s.class, \"%s\")" /* colDef */,
".append(" /* rowStart */,
")\r\n" /* rowEnd */,
"acolyte.RowList.Column.defineCol(%s.class, \"%s\")" /* colDef */,
")" /* rowEnd */,
FormattingConstants.javaMap, /* type map */
", " /* valueSeparator */,
"new java.math.BigDecimal(\"%s\")" /* someBigDecimal */,
Expand Down Expand Up @@ -48,9 +49,10 @@ enum Formatting {
* Scala formatting
*/
Scala("Scala", "text/scala",
".append(" /* rowStart */,
")\r\n" /* rowEnd */,
"import acolyte.RowLists", /* imports */
"classOf[%s] -> \"%s\"", /* colDef */
".append(" /* rowStart */,
")" /* rowEnd */,
FormattingConstants.scalaMap, /* types map */
", " /* valueSeparator */,
"new java.math.BigDecimal(\"%s\")" /* someBigDecimal */,
Expand Down Expand Up @@ -90,6 +92,11 @@ enum Formatting {
*/
public final String mimeType;

/**
* Imports
*/
public final String imports;

/**
* Row start
*/
Expand Down Expand Up @@ -258,9 +265,10 @@ public static Formatting forName(final String format) {
*/
private Formatting(final String format,
final String mimeType,
final String imports,
final String colDef,
final String rowStart,
final String rowEnd,
final String colDef,
final HashMap<ColumnType,String> typeMap,
final String valueSeparator,
final String someBigDecimal,
Expand Down Expand Up @@ -290,6 +298,7 @@ private Formatting(final String format,

this.format = format;
this.mimeType = mimeType;
this.imports = imports;
this.rowStart = rowStart;
this.rowEnd = rowEnd;
this.colDef = colDef;
Expand Down
35 changes: 35 additions & 0 deletions studio/src/main/java/acolyte/Native.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package acolyte;

import java.lang.reflect.Method;

import java.awt.Image;

/**
* Native utility.
*
* @author Cedric Chantepie
*/
final class Native {

/**
* Sets |icon| for Mac OS X dock.
* @return true if set
*/
public static boolean setDockIcon(final Image icon) {
try {
final Class<?> clazz = Class.forName("com.apple.eawt.Application");
final Method am = clazz.getMethod("getApplication");
final Object app = am.invoke(null, new Object[0]);
final Method si = clazz.getMethod("setDockIconImage",
new Class[] { Image.class });

si.invoke(app, new Object[] { icon });

return true;
} catch (Exception e) {
e.printStackTrace();
} // end of catch

return false;
} // end of setDockIcon
} // end of class Native
Loading

0 comments on commit 927d412

Please sign in to comment.