summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Schwabe2014-08-20 16:01:44 +0200
committerNils Schwabe2014-08-20 16:01:44 +0200
commit3bd2714d8fc3eee958f3f831556175c26f0bf76b (patch)
tree7974f7b543c85a990a65ab0d02cf40a86a5f9a72
parentRemove some hardcoded stuff (diff)
downloadsatellite-daemon-3bd2714d8fc3eee958f3f831556175c26f0bf76b.tar.gz
satellite-daemon-3bd2714d8fc3eee958f3f831556175c26f0bf76b.tar.xz
satellite-daemon-3bd2714d8fc3eee958f3f831556175c26f0bf76b.zip
Add methods to update image in database
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/DbImage.java38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
index 5169173..be968b9 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
@@ -3,23 +3,30 @@ package org.openslx.satellitedaemon.db;
import java.util.List;
/**
- * Represents an image in the satellite's database (mostly from
+ * Represents an image in the satellites database (mostly from
* m_VLData_imageInfo)
*/
public class DbImage
{
-
+
public final String guid;
public final String name;
public final int rid;
public final String path;
public final String creator;
public final long fileSize;
-
+
+ public enum Status
+ {
+ only_local, to_be_published, being_published, successfully_published, to_be_decentralized, being_decentralized, successfully_decentralized
+ }
+
public DbImage(String guid, String name, Integer rid, String path, String creator, Long fileSize)
{
- if (rid == null) rid = -1;
- if (fileSize == null) fileSize = (long) -1;
+ if ( rid == null )
+ rid = -1;
+ if ( fileSize == null )
+ fileSize = (long) -1;
this.guid = guid;
this.name = name;
this.rid = rid;
@@ -38,22 +45,31 @@ public class DbImage
public static List<DbImage> getAllMarkedForUpload()
{
return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," +
- " Concat(user.loginName, '@', institution.name) AS userID, image.image_filesize" +
+ " Concat(user.loginName, @, institution.name) AS userID, image.image_filesize" +
" FROM m_VLData_imageInfo image" +
" INNER JOIN m_user user ON (image.image_owner = user.userID)" +
" INNER JOIN m_institution institution ON (institution.institutionID = user.institution)" +
- " WHERE image_syncMode = 'to_be_published'" );
+ " WHERE image_syncMode = to_be_published" );
}
-
-
+
public static List<DbImage> getAllMarkedForDownload()
{
return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," +
- " Concat(user.loginName, '@', institution.name) AS userID, image.image_filesize" +
+ " Concat(user.loginName, @, institution.name) AS userID, image.image_filesize" +
" FROM m_VLData_imageInfo image" +
" INNER JOIN m_user user ON (image.image_owner = user.userID)" +
" INNER JOIN m_institution institution ON (institution.institutionID = user.institution)" +
- " WHERE image_syncMode = 'to_be_decentralized'" );
+ " WHERE image_syncMode = to_be_decentralized" );
+ }
+
+ public static void updateStatus( String uuid, Status status )
+ {
+ MySQL.update( "UPDATE m_VLData_imageInfo SET image_syncMode=? WHERE GUID_imageID=?", status.toString(), uuid );
+ }
+
+ public static void updateFilesize( String uuid, long filesize )
+ {
+ MySQL.update( "UPDATE m_VLData_imageInfo SET image_filesize=? WHERE GUID_imageID=?", filesize, uuid );
}
}