Skip to content
Snippets Groups Projects
Commit e3c228e8 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Changed the media path to filename

parent 7eef0e6c
Branches
No related tags found
No related merge requests found
Showing
with 12 additions and 39 deletions
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false"> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" /> <output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" /> <output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
...@@ -35,5 +35,6 @@ ...@@ -35,5 +35,6 @@
<orderEntry type="library" name="Maven: com.j256.ormlite:ormlite-jdbc:5.0" level="project" /> <orderEntry type="library" name="Maven: com.j256.ormlite:ormlite-jdbc:5.0" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:6.0.5" level="project" /> <orderEntry type="library" name="Maven: mysql:mysql-connector-java:6.0.5" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" /> <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" name="scala-sdk-2.12.1" level="application" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -8,7 +8,7 @@ import java.util.UUID ...@@ -8,7 +8,7 @@ import java.util.UUID
class Path { class Path {
var id: UUID = UUID.randomUUID() var id: UUID = UUID.randomUUID()
var path: String = _ var filename: String = _
var pad: Pad = _ var pad: Pad = _
} }
...@@ -19,7 +19,7 @@ class PathLoader { ...@@ -19,7 +19,7 @@ class PathLoader {
val path = new Path() val path = new Path()
path.id = UUID.fromString(json.get(PATH_ID).getAsString) path.id = UUID.fromString(json.get(PATH_ID).getAsString)
path.path = json.get(PATH_PATH).getAsString path.filename = json.get(PATH_PATH).getAsString
path.pad = pad path.pad = pad
path path
......
...@@ -21,7 +21,7 @@ class PathLoader(val connection: Connection) { ...@@ -21,7 +21,7 @@ class PathLoader(val connection: Connection) {
while (result.next()) { while (result.next()) {
val path = new Path() val path = new Path()
path.id = UUID.fromString(result.getString(PATH_ID)) path.id = UUID.fromString(result.getString(PATH_ID))
path.path = result.getString(PATH_NAME) path.filename = result.getString(PATH_NAME)
path.pad = pad path.pad = pad
paths = path :: paths paths = path :: paths
......
...@@ -12,7 +12,7 @@ class PathSaver { ...@@ -12,7 +12,7 @@ class PathSaver {
val jsonObject = new JsonObject() val jsonObject = new JsonObject()
jsonObject.addProperty(PATH_ID, path.id.toString) jsonObject.addProperty(PATH_ID, path.id.toString)
jsonObject.addProperty(PATH_PATH, path.path) jsonObject.addProperty(PATH_PATH, path.filename)
jsonObject jsonObject
} }
......
...@@ -12,7 +12,7 @@ import de.tobias.playpad.server.server.SqlHelper ...@@ -12,7 +12,7 @@ import de.tobias.playpad.server.server.SqlHelper
class PathSaver(val connection: Connection) { class PathSaver(val connection: Connection) {
def save(path: Path): Unit = { def save(path: Path): Unit = {
SqlHelper.insertOrUpdate(connection, PATH, path.id, PATH_PAD_REF, path.pad.id) SqlHelper.insertOrUpdate(connection, PATH, path.id, PATH_PAD_REF, path.pad.id)
SqlHelper.insertOrUpdate(connection, PATH, path.id, PATH_NAME, path.path) SqlHelper.insertOrUpdate(connection, PATH, path.id, PATH_NAME, path.filename)
} }
} }
...@@ -22,7 +22,7 @@ object JsonDef { ...@@ -22,7 +22,7 @@ object JsonDef {
val PAD_DESIGN = "design" val PAD_DESIGN = "design"
val PATH_ID = "id" val PATH_ID = "id"
val PATH_PATH = "path" val PATH_PATH = "filename"
val DESIGN_ID = "id" val DESIGN_ID = "id"
val DESIGN_BACKGROUND_COLOR = "background_color" val DESIGN_BACKGROUND_COLOR = "background_color"
......
...@@ -25,7 +25,7 @@ object SqlDef { ...@@ -25,7 +25,7 @@ object SqlDef {
val PATH = "Path" val PATH = "Path"
val PATH_ID = "id" val PATH_ID = "id"
val PATH_NAME = "path" val PATH_NAME = "filename"
val PATH_PAD_REF = "pad_id" val PATH_PAD_REF = "pad_id"
val DESIGN = "Design" val DESIGN = "Design"
......
...@@ -9,7 +9,7 @@ import de.tobias.playpad.server.account.Account ...@@ -9,7 +9,7 @@ import de.tobias.playpad.server.account.Account
import de.tobias.playpad.server.server.project.sync.listener.design.{DesignAddListener, DesignUpdateListener} import de.tobias.playpad.server.server.project.sync.listener.design.{DesignAddListener, DesignUpdateListener}
import de.tobias.playpad.server.server.project.sync.listener.pad.{PadAddListener, PadClearListener, PadRemoveListener, PadUpdateListener} import de.tobias.playpad.server.server.project.sync.listener.pad.{PadAddListener, PadClearListener, PadRemoveListener, PadUpdateListener}
import de.tobias.playpad.server.server.project.sync.listener.page.{PageAddListener, PageRemoveListener, PageUpdateListener} import de.tobias.playpad.server.server.project.sync.listener.page.{PageAddListener, PageRemoveListener, PageUpdateListener}
import de.tobias.playpad.server.server.project.sync.listener.path.{PathAddListener, PathRemoveListener, PathUpdateListener} import de.tobias.playpad.server.server.project.sync.listener.path.{PathAddListener, PathRemoveListener}
import de.tobias.playpad.server.server.project.sync.listener.project.{ProjectAddListener, ProjectRemoveListener, ProjectUpdateListener} import de.tobias.playpad.server.server.project.sync.listener.project.{ProjectAddListener, ProjectRemoveListener, ProjectUpdateListener}
import org.eclipse.jetty.websocket.api.Session import org.eclipse.jetty.websocket.api.Session
import org.eclipse.jetty.websocket.api.annotations.{OnWebSocketClose, OnWebSocketConnect, OnWebSocketMessage, WebSocket} import org.eclipse.jetty.websocket.api.annotations.{OnWebSocketClose, OnWebSocketConnect, OnWebSocketMessage, WebSocket}
...@@ -41,7 +41,6 @@ import scala.collection.{Map, mutable} ...@@ -41,7 +41,6 @@ import scala.collection.{Map, mutable}
"pad-clear" -> new PadClearListener(), "pad-clear" -> new PadClearListener(),
"path-add" -> new PathAddListener(), "path-add" -> new PathAddListener(),
"path-update" -> new PathUpdateListener(),
"path-rm" -> new PathRemoveListener(), "path-rm" -> new PathRemoveListener(),
"design-add" -> new DesignAddListener(), "design-add" -> new DesignAddListener(),
......
...@@ -19,8 +19,8 @@ class PathAddListener extends Listener { ...@@ -19,8 +19,8 @@ class PathAddListener extends Listener {
SqlHelper.insertOrUpdate(connection, SqlDef.PATH, pathId, SqlDef.PATH_PAD_REF, padId) SqlHelper.insertOrUpdate(connection, SqlDef.PATH, pathId, SqlDef.PATH_PAD_REF, padId)
if (json.get("path") != null) { if (json.get("filename") != null) {
val path = json.get("path").getAsString val path = json.get("filename").getAsString
SqlHelper.insertOrUpdate(connection, SqlDef.PATH, pathId, SqlDef.PATH_NAME, path) SqlHelper.insertOrUpdate(connection, SqlDef.PATH, pathId, SqlDef.PATH_NAME, path)
} }
} }
......
package de.tobias.playpad.server.server.project.sync.listener.path
import java.sql.Connection
import java.util.UUID
import com.google.gson.JsonObject
import de.tobias.playpad.server.account.Session
import de.tobias.playpad.server.project.utils.SqlDef
import de.tobias.playpad.server.server.SqlHelper
import de.tobias.playpad.server.server.project.sync.listener.Listener
/**
* Created by tobias on 19.02.17.
*/
class PathUpdateListener extends Listener {
override def onChange(json: JsonObject, connection: Connection, session: Session): Unit = {
val pathId = UUID.fromString(json.get("id").getAsString)
val padId = UUID.fromString(json.get("pad").getAsString)
val field = json.get("field").getAsString
SqlHelper.insertOrUpdate(connection, SqlDef.PATH, pathId, SqlDef.PATH_PAD_REF, padId)
field match {
case "path" => SqlHelper.insertOrUpdate(connection, SqlDef.PATH, pathId, SqlDef.PATH_NAME, json.get("value").getAsString)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment