diff --git a/core/amber/build.sbt b/core/amber/build.sbt index 279aab6f0c3..2a4847cfefa 100644 --- a/core/amber/build.sbt +++ b/core/amber/build.sbt @@ -186,6 +186,9 @@ libraryDependencies += "org.scalamock" %% "scalamock" % "5.2.0" % Test libraryDependencies += "ch.vorburger.mariaDB4j" % "mariaDB4j" % "2.4.0" % Test // https://www.scalatest.org/getting_started_with_fun_suite libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.15" % Test +// JUnit related dependencies +libraryDependencies += "junit" % "junit" % "4.13.2" % Test // JUnit dependency for Java tests +libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test // SBT interface for JUnit ///////////////////////////////////////////////////////////////////////////// // Workflow version control related diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Indexes.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Indexes.java index e12fe67f2cc..d2ca0386055 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Indexes.java +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Indexes.java @@ -4,6 +4,9 @@ package edu.uci.ics.texera.web.model.jooq.generated; +import edu.uci.ics.texera.web.model.jooq.generated.tables.Dataset; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetUserAccess; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetVersion; import edu.uci.ics.texera.web.model.jooq.generated.tables.File; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfProject; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfWorkflow; @@ -36,6 +39,14 @@ public class Indexes { // INDEX definitions // ------------------------------------------------------------------------- + public static final Index DATASET_IDX_DATASET_NAME_DESCRIPTION = Indexes0.DATASET_IDX_DATASET_NAME_DESCRIPTION; + public static final Index DATASET_OWNER_UID = Indexes0.DATASET_OWNER_UID; + public static final Index DATASET_PRIMARY = Indexes0.DATASET_PRIMARY; + public static final Index DATASET_USER_ACCESS_PRIMARY = Indexes0.DATASET_USER_ACCESS_PRIMARY; + public static final Index DATASET_USER_ACCESS_UID = Indexes0.DATASET_USER_ACCESS_UID; + public static final Index DATASET_VERSION_DID = Indexes0.DATASET_VERSION_DID; + public static final Index DATASET_VERSION_IDX_DATASET_VERSION_NAME = Indexes0.DATASET_VERSION_IDX_DATASET_VERSION_NAME; + public static final Index DATASET_VERSION_PRIMARY = Indexes0.DATASET_VERSION_PRIMARY; public static final Index FILE_IDX_FILE_NAME_DESCRIPTION = Indexes0.FILE_IDX_FILE_NAME_DESCRIPTION; public static final Index FILE_OWNER_UID = Indexes0.FILE_OWNER_UID; public static final Index FILE_PRIMARY = Indexes0.FILE_PRIMARY; @@ -77,6 +88,14 @@ public class Indexes { // ------------------------------------------------------------------------- private static class Indexes0 { + public static Index DATASET_IDX_DATASET_NAME_DESCRIPTION = Internal.createIndex("idx_dataset_name_description", Dataset.DATASET, new OrderField[] { Dataset.DATASET.NAME, Dataset.DATASET.DESCRIPTION }, false); + public static Index DATASET_OWNER_UID = Internal.createIndex("owner_uid", Dataset.DATASET, new OrderField[] { Dataset.DATASET.OWNER_UID }, false); + public static Index DATASET_PRIMARY = Internal.createIndex("PRIMARY", Dataset.DATASET, new OrderField[] { Dataset.DATASET.DID }, true); + public static Index DATASET_USER_ACCESS_PRIMARY = Internal.createIndex("PRIMARY", DatasetUserAccess.DATASET_USER_ACCESS, new OrderField[] { DatasetUserAccess.DATASET_USER_ACCESS.DID, DatasetUserAccess.DATASET_USER_ACCESS.UID }, true); + public static Index DATASET_USER_ACCESS_UID = Internal.createIndex("uid", DatasetUserAccess.DATASET_USER_ACCESS, new OrderField[] { DatasetUserAccess.DATASET_USER_ACCESS.UID }, false); + public static Index DATASET_VERSION_DID = Internal.createIndex("did", DatasetVersion.DATASET_VERSION, new OrderField[] { DatasetVersion.DATASET_VERSION.DID }, false); + public static Index DATASET_VERSION_IDX_DATASET_VERSION_NAME = Internal.createIndex("idx_dataset_version_name", DatasetVersion.DATASET_VERSION, new OrderField[] { DatasetVersion.DATASET_VERSION.NAME }, false); + public static Index DATASET_VERSION_PRIMARY = Internal.createIndex("PRIMARY", DatasetVersion.DATASET_VERSION, new OrderField[] { DatasetVersion.DATASET_VERSION.DVID }, true); public static Index FILE_IDX_FILE_NAME_DESCRIPTION = Internal.createIndex("idx_file_name_description", File.FILE, new OrderField[] { File.FILE.NAME, File.FILE.DESCRIPTION }, false); public static Index FILE_OWNER_UID = Internal.createIndex("owner_uid", File.FILE, new OrderField[] { File.FILE.OWNER_UID, File.FILE.NAME }, true); public static Index FILE_PRIMARY = Internal.createIndex("PRIMARY", File.FILE, new OrderField[] { File.FILE.FID }, true); diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Keys.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Keys.java index 181307949b7..7d265f769f8 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Keys.java +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Keys.java @@ -4,6 +4,9 @@ package edu.uci.ics.texera.web.model.jooq.generated; +import edu.uci.ics.texera.web.model.jooq.generated.tables.Dataset; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetUserAccess; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetVersion; import edu.uci.ics.texera.web.model.jooq.generated.tables.File; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfProject; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfWorkflow; @@ -20,6 +23,9 @@ import edu.uci.ics.texera.web.model.jooq.generated.tables.WorkflowRuntimeStatistics; import edu.uci.ics.texera.web.model.jooq.generated.tables.WorkflowUserAccess; import edu.uci.ics.texera.web.model.jooq.generated.tables.WorkflowVersion; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetRecord; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetUserAccessRecord; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetVersionRecord; import edu.uci.ics.texera.web.model.jooq.generated.tables.records.FileOfProjectRecord; import edu.uci.ics.texera.web.model.jooq.generated.tables.records.FileOfWorkflowRecord; import edu.uci.ics.texera.web.model.jooq.generated.tables.records.FileRecord; @@ -55,6 +61,8 @@ public class Keys { // IDENTITY definitions // ------------------------------------------------------------------------- + public static final Identity IDENTITY_DATASET = Identities0.IDENTITY_DATASET; + public static final Identity IDENTITY_DATASET_VERSION = Identities0.IDENTITY_DATASET_VERSION; public static final Identity IDENTITY_FILE = Identities0.IDENTITY_FILE; public static final Identity IDENTITY_PROJECT = Identities0.IDENTITY_PROJECT; public static final Identity IDENTITY_USER = Identities0.IDENTITY_USER; @@ -66,6 +74,9 @@ public class Keys { // UNIQUE and PRIMARY KEY definitions // ------------------------------------------------------------------------- + public static final UniqueKey KEY_DATASET_PRIMARY = UniqueKeys0.KEY_DATASET_PRIMARY; + public static final UniqueKey KEY_DATASET_USER_ACCESS_PRIMARY = UniqueKeys0.KEY_DATASET_USER_ACCESS_PRIMARY; + public static final UniqueKey KEY_DATASET_VERSION_PRIMARY = UniqueKeys0.KEY_DATASET_VERSION_PRIMARY; public static final UniqueKey KEY_FILE_OWNER_UID = UniqueKeys0.KEY_FILE_OWNER_UID; public static final UniqueKey KEY_FILE_PRIMARY = UniqueKeys0.KEY_FILE_PRIMARY; public static final UniqueKey KEY_FILE_OF_PROJECT_PRIMARY = UniqueKeys0.KEY_FILE_OF_PROJECT_PRIMARY; @@ -91,6 +102,10 @@ public class Keys { // FOREIGN KEY definitions // ------------------------------------------------------------------------- + public static final ForeignKey DATASET_IBFK_1 = ForeignKeys0.DATASET_IBFK_1; + public static final ForeignKey DATASET_USER_ACCESS_IBFK_1 = ForeignKeys0.DATASET_USER_ACCESS_IBFK_1; + public static final ForeignKey DATASET_USER_ACCESS_IBFK_2 = ForeignKeys0.DATASET_USER_ACCESS_IBFK_2; + public static final ForeignKey DATASET_VERSION_IBFK_1 = ForeignKeys0.DATASET_VERSION_IBFK_1; public static final ForeignKey FILE_IBFK_1 = ForeignKeys0.FILE_IBFK_1; public static final ForeignKey FILE_OF_PROJECT_IBFK_1 = ForeignKeys0.FILE_OF_PROJECT_IBFK_1; public static final ForeignKey FILE_OF_PROJECT_IBFK_2 = ForeignKeys0.FILE_OF_PROJECT_IBFK_2; @@ -120,6 +135,8 @@ public class Keys { // ------------------------------------------------------------------------- private static class Identities0 { + public static Identity IDENTITY_DATASET = Internal.createIdentity(Dataset.DATASET, Dataset.DATASET.DID); + public static Identity IDENTITY_DATASET_VERSION = Internal.createIdentity(DatasetVersion.DATASET_VERSION, DatasetVersion.DATASET_VERSION.DVID); public static Identity IDENTITY_FILE = Internal.createIdentity(File.FILE, File.FILE.FID); public static Identity IDENTITY_PROJECT = Internal.createIdentity(Project.PROJECT, Project.PROJECT.PID); public static Identity IDENTITY_USER = Internal.createIdentity(User.USER, User.USER.UID); @@ -129,6 +146,9 @@ private static class Identities0 { } private static class UniqueKeys0 { + public static final UniqueKey KEY_DATASET_PRIMARY = Internal.createUniqueKey(Dataset.DATASET, "KEY_dataset_PRIMARY", Dataset.DATASET.DID); + public static final UniqueKey KEY_DATASET_USER_ACCESS_PRIMARY = Internal.createUniqueKey(DatasetUserAccess.DATASET_USER_ACCESS, "KEY_dataset_user_access_PRIMARY", DatasetUserAccess.DATASET_USER_ACCESS.DID, DatasetUserAccess.DATASET_USER_ACCESS.UID); + public static final UniqueKey KEY_DATASET_VERSION_PRIMARY = Internal.createUniqueKey(DatasetVersion.DATASET_VERSION, "KEY_dataset_version_PRIMARY", DatasetVersion.DATASET_VERSION.DVID); public static final UniqueKey KEY_FILE_OWNER_UID = Internal.createUniqueKey(File.FILE, "KEY_file_owner_uid", File.FILE.OWNER_UID, File.FILE.NAME); public static final UniqueKey KEY_FILE_PRIMARY = Internal.createUniqueKey(File.FILE, "KEY_file_PRIMARY", File.FILE.FID); public static final UniqueKey KEY_FILE_OF_PROJECT_PRIMARY = Internal.createUniqueKey(FileOfProject.FILE_OF_PROJECT, "KEY_file_of_project_PRIMARY", FileOfProject.FILE_OF_PROJECT.FID, FileOfProject.FILE_OF_PROJECT.PID); @@ -152,6 +172,10 @@ private static class UniqueKeys0 { } private static class ForeignKeys0 { + public static final ForeignKey DATASET_IBFK_1 = Internal.createForeignKey(edu.uci.ics.texera.web.model.jooq.generated.Keys.KEY_USER_PRIMARY, Dataset.DATASET, "dataset_ibfk_1", Dataset.DATASET.OWNER_UID); + public static final ForeignKey DATASET_USER_ACCESS_IBFK_1 = Internal.createForeignKey(edu.uci.ics.texera.web.model.jooq.generated.Keys.KEY_DATASET_PRIMARY, DatasetUserAccess.DATASET_USER_ACCESS, "dataset_user_access_ibfk_1", DatasetUserAccess.DATASET_USER_ACCESS.DID); + public static final ForeignKey DATASET_USER_ACCESS_IBFK_2 = Internal.createForeignKey(edu.uci.ics.texera.web.model.jooq.generated.Keys.KEY_USER_PRIMARY, DatasetUserAccess.DATASET_USER_ACCESS, "dataset_user_access_ibfk_2", DatasetUserAccess.DATASET_USER_ACCESS.UID); + public static final ForeignKey DATASET_VERSION_IBFK_1 = Internal.createForeignKey(edu.uci.ics.texera.web.model.jooq.generated.Keys.KEY_DATASET_PRIMARY, DatasetVersion.DATASET_VERSION, "dataset_version_ibfk_1", DatasetVersion.DATASET_VERSION.DID); public static final ForeignKey FILE_IBFK_1 = Internal.createForeignKey(edu.uci.ics.texera.web.model.jooq.generated.Keys.KEY_USER_PRIMARY, File.FILE, "file_ibfk_1", File.FILE.OWNER_UID); public static final ForeignKey FILE_OF_PROJECT_IBFK_1 = Internal.createForeignKey(edu.uci.ics.texera.web.model.jooq.generated.Keys.KEY_FILE_PRIMARY, FileOfProject.FILE_OF_PROJECT, "file_of_project_ibfk_1", FileOfProject.FILE_OF_PROJECT.FID); public static final ForeignKey FILE_OF_PROJECT_IBFK_2 = Internal.createForeignKey(edu.uci.ics.texera.web.model.jooq.generated.Keys.KEY_PROJECT_PRIMARY, FileOfProject.FILE_OF_PROJECT, "file_of_project_ibfk_2", FileOfProject.FILE_OF_PROJECT.PID); diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Tables.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Tables.java index c1358fc5152..814fccf3aa9 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Tables.java +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/Tables.java @@ -4,6 +4,9 @@ package edu.uci.ics.texera.web.model.jooq.generated; +import edu.uci.ics.texera.web.model.jooq.generated.tables.Dataset; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetUserAccess; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetVersion; import edu.uci.ics.texera.web.model.jooq.generated.tables.File; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfProject; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfWorkflow; @@ -28,6 +31,21 @@ @SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class Tables { + /** + * The table texera_db.dataset. + */ + public static final Dataset DATASET = Dataset.DATASET; + + /** + * The table texera_db.dataset_user_access. + */ + public static final DatasetUserAccess DATASET_USER_ACCESS = DatasetUserAccess.DATASET_USER_ACCESS; + + /** + * The table texera_db.dataset_version. + */ + public static final DatasetVersion DATASET_VERSION = DatasetVersion.DATASET_VERSION; + /** * The table texera_db.file. */ diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/TexeraDb.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/TexeraDb.java index 7d3123704e5..294e07a37c8 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/TexeraDb.java +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/TexeraDb.java @@ -4,6 +4,9 @@ package edu.uci.ics.texera.web.model.jooq.generated; +import edu.uci.ics.texera.web.model.jooq.generated.tables.Dataset; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetUserAccess; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetVersion; import edu.uci.ics.texera.web.model.jooq.generated.tables.File; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfProject; import edu.uci.ics.texera.web.model.jooq.generated.tables.FileOfWorkflow; @@ -36,13 +39,28 @@ @SuppressWarnings({ "all", "unchecked", "rawtypes" }) public class TexeraDb extends SchemaImpl { - private static final long serialVersionUID = 304546079; + private static final long serialVersionUID = -1679894118; /** * The reference instance of texera_db */ public static final TexeraDb TEXERA_DB = new TexeraDb(); + /** + * The table texera_db.dataset. + */ + public final Dataset DATASET = edu.uci.ics.texera.web.model.jooq.generated.tables.Dataset.DATASET; + + /** + * The table texera_db.dataset_user_access. + */ + public final DatasetUserAccess DATASET_USER_ACCESS = edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetUserAccess.DATASET_USER_ACCESS; + + /** + * The table texera_db.dataset_version. + */ + public final DatasetVersion DATASET_VERSION = edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetVersion.DATASET_VERSION; + /** * The table texera_db.file. */ @@ -145,6 +163,9 @@ public final List> getTables() { private final List> getTables0() { return Arrays.>asList( + Dataset.DATASET, + DatasetUserAccess.DATASET_USER_ACCESS, + DatasetVersion.DATASET_VERSION, File.FILE, FileOfProject.FILE_OF_PROJECT, FileOfWorkflow.FILE_OF_WORKFLOW, diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/enums/DatasetUserAccessPrivilege.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/enums/DatasetUserAccessPrivilege.java new file mode 100644 index 00000000000..09b530b3124 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/enums/DatasetUserAccessPrivilege.java @@ -0,0 +1,49 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.enums; + + +import org.jooq.Catalog; +import org.jooq.EnumType; +import org.jooq.Schema; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public enum DatasetUserAccessPrivilege implements EnumType { + + NONE("NONE"), + + READ("READ"), + + WRITE("WRITE"); + + private final String literal; + + private DatasetUserAccessPrivilege(String literal) { + this.literal = literal; + } + + @Override + public Catalog getCatalog() { + return null; + } + + @Override + public Schema getSchema() { + return null; + } + + @Override + public String getName() { + return "dataset_user_access_privilege"; + } + + @Override + public String getLiteral() { + return literal; + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/Dataset.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/Dataset.java new file mode 100644 index 00000000000..7e80fb1ecfc --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/Dataset.java @@ -0,0 +1,189 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables; + + +import edu.uci.ics.texera.web.model.jooq.generated.Indexes; +import edu.uci.ics.texera.web.model.jooq.generated.Keys; +import edu.uci.ics.texera.web.model.jooq.generated.TexeraDb; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetRecord; + +import java.sql.Timestamp; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row7; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.TableImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Dataset extends TableImpl { + + private static final long serialVersionUID = 578477320; + + /** + * The reference instance of texera_db.dataset + */ + public static final Dataset DATASET = new Dataset(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return DatasetRecord.class; + } + + /** + * The column texera_db.dataset.did. + */ + public final TableField DID = createField(DSL.name("did"), org.jooq.impl.SQLDataType.INTEGERUNSIGNED.nullable(false).identity(true), this, ""); + + /** + * The column texera_db.dataset.owner_uid. + */ + public final TableField OWNER_UID = createField(DSL.name("owner_uid"), org.jooq.impl.SQLDataType.INTEGERUNSIGNED.nullable(false), this, ""); + + /** + * The column texera_db.dataset.name. + */ + public final TableField NAME = createField(DSL.name("name"), org.jooq.impl.SQLDataType.VARCHAR(128).nullable(false), this, ""); + + /** + * The column texera_db.dataset.is_public. + */ + public final TableField IS_PUBLIC = createField(DSL.name("is_public"), org.jooq.impl.SQLDataType.TINYINT.nullable(false).defaultValue(org.jooq.impl.DSL.inline("1", org.jooq.impl.SQLDataType.TINYINT)), this, ""); + + /** + * The column texera_db.dataset.storage_path. + */ + public final TableField STORAGE_PATH = createField(DSL.name("storage_path"), org.jooq.impl.SQLDataType.VARCHAR(512).nullable(false), this, ""); + + /** + * The column texera_db.dataset.description. + */ + public final TableField DESCRIPTION = createField(DSL.name("description"), org.jooq.impl.SQLDataType.VARCHAR(512).nullable(false), this, ""); + + /** + * The column texera_db.dataset.creation_time. + */ + public final TableField CREATION_TIME = createField(DSL.name("creation_time"), org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaultValue(org.jooq.impl.DSL.field("CURRENT_TIMESTAMP", org.jooq.impl.SQLDataType.TIMESTAMP)), this, ""); + + /** + * Create a texera_db.dataset table reference + */ + public Dataset() { + this(DSL.name("dataset"), null); + } + + /** + * Create an aliased texera_db.dataset table reference + */ + public Dataset(String alias) { + this(DSL.name(alias), DATASET); + } + + /** + * Create an aliased texera_db.dataset table reference + */ + public Dataset(Name alias) { + this(alias, DATASET); + } + + private Dataset(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Dataset(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("")); + } + + public Dataset(Table child, ForeignKey key) { + super(child, key, DATASET); + } + + @Override + public Schema getSchema() { + return TexeraDb.TEXERA_DB; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.DATASET_IDX_DATASET_NAME_DESCRIPTION, Indexes.DATASET_OWNER_UID, Indexes.DATASET_PRIMARY); + } + + @Override + public Identity getIdentity() { + return Keys.IDENTITY_DATASET; + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_DATASET_PRIMARY; + } + + @Override + public List> getKeys() { + return Arrays.>asList(Keys.KEY_DATASET_PRIMARY); + } + + @Override + public List> getReferences() { + return Arrays.>asList(Keys.DATASET_IBFK_1); + } + + public User user() { + return new User(this, Keys.DATASET_IBFK_1); + } + + @Override + public Dataset as(String alias) { + return new Dataset(DSL.name(alias), this); + } + + @Override + public Dataset as(Name alias) { + return new Dataset(alias, this); + } + + /** + * Rename this table + */ + @Override + public Dataset rename(String name) { + return new Dataset(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Dataset rename(Name name) { + return new Dataset(name, null); + } + + // ------------------------------------------------------------------------- + // Row7 type methods + // ------------------------------------------------------------------------- + + @Override + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/DatasetUserAccess.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/DatasetUserAccess.java new file mode 100644 index 00000000000..143b70ac291 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/DatasetUserAccess.java @@ -0,0 +1,167 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables; + + +import edu.uci.ics.texera.web.model.jooq.generated.Indexes; +import edu.uci.ics.texera.web.model.jooq.generated.Keys; +import edu.uci.ics.texera.web.model.jooq.generated.TexeraDb; +import edu.uci.ics.texera.web.model.jooq.generated.enums.DatasetUserAccessPrivilege; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetUserAccessRecord; + +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row3; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.TableImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetUserAccess extends TableImpl { + + private static final long serialVersionUID = -996212423; + + /** + * The reference instance of texera_db.dataset_user_access + */ + public static final DatasetUserAccess DATASET_USER_ACCESS = new DatasetUserAccess(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return DatasetUserAccessRecord.class; + } + + /** + * The column texera_db.dataset_user_access.did. + */ + public final TableField DID = createField(DSL.name("did"), org.jooq.impl.SQLDataType.INTEGERUNSIGNED.nullable(false), this, ""); + + /** + * The column texera_db.dataset_user_access.uid. + */ + public final TableField UID = createField(DSL.name("uid"), org.jooq.impl.SQLDataType.INTEGERUNSIGNED.nullable(false), this, ""); + + /** + * The column texera_db.dataset_user_access.privilege. + */ + public final TableField PRIVILEGE = createField(DSL.name("privilege"), org.jooq.impl.SQLDataType.VARCHAR(5).nullable(false).defaultValue(org.jooq.impl.DSL.inline("NONE", org.jooq.impl.SQLDataType.VARCHAR)).asEnumDataType(edu.uci.ics.texera.web.model.jooq.generated.enums.DatasetUserAccessPrivilege.class), this, ""); + + /** + * Create a texera_db.dataset_user_access table reference + */ + public DatasetUserAccess() { + this(DSL.name("dataset_user_access"), null); + } + + /** + * Create an aliased texera_db.dataset_user_access table reference + */ + public DatasetUserAccess(String alias) { + this(DSL.name(alias), DATASET_USER_ACCESS); + } + + /** + * Create an aliased texera_db.dataset_user_access table reference + */ + public DatasetUserAccess(Name alias) { + this(alias, DATASET_USER_ACCESS); + } + + private DatasetUserAccess(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private DatasetUserAccess(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("")); + } + + public DatasetUserAccess(Table child, ForeignKey key) { + super(child, key, DATASET_USER_ACCESS); + } + + @Override + public Schema getSchema() { + return TexeraDb.TEXERA_DB; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.DATASET_USER_ACCESS_PRIMARY, Indexes.DATASET_USER_ACCESS_UID); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_DATASET_USER_ACCESS_PRIMARY; + } + + @Override + public List> getKeys() { + return Arrays.>asList(Keys.KEY_DATASET_USER_ACCESS_PRIMARY); + } + + @Override + public List> getReferences() { + return Arrays.>asList(Keys.DATASET_USER_ACCESS_IBFK_1, Keys.DATASET_USER_ACCESS_IBFK_2); + } + + public Dataset dataset() { + return new Dataset(this, Keys.DATASET_USER_ACCESS_IBFK_1); + } + + public User user() { + return new User(this, Keys.DATASET_USER_ACCESS_IBFK_2); + } + + @Override + public DatasetUserAccess as(String alias) { + return new DatasetUserAccess(DSL.name(alias), this); + } + + @Override + public DatasetUserAccess as(Name alias) { + return new DatasetUserAccess(alias, this); + } + + /** + * Rename this table + */ + @Override + public DatasetUserAccess rename(String name) { + return new DatasetUserAccess(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public DatasetUserAccess rename(Name name) { + return new DatasetUserAccess(name, null); + } + + // ------------------------------------------------------------------------- + // Row3 type methods + // ------------------------------------------------------------------------- + + @Override + public Row3 fieldsRow() { + return (Row3) super.fieldsRow(); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/DatasetVersion.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/DatasetVersion.java new file mode 100644 index 00000000000..699bde6aca7 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/DatasetVersion.java @@ -0,0 +1,184 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables; + + +import edu.uci.ics.texera.web.model.jooq.generated.Indexes; +import edu.uci.ics.texera.web.model.jooq.generated.Keys; +import edu.uci.ics.texera.web.model.jooq.generated.TexeraDb; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetVersionRecord; + +import java.sql.Timestamp; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.TableImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetVersion extends TableImpl { + + private static final long serialVersionUID = 25893167; + + /** + * The reference instance of texera_db.dataset_version + */ + public static final DatasetVersion DATASET_VERSION = new DatasetVersion(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return DatasetVersionRecord.class; + } + + /** + * The column texera_db.dataset_version.dvid. + */ + public final TableField DVID = createField(DSL.name("dvid"), org.jooq.impl.SQLDataType.INTEGERUNSIGNED.nullable(false).identity(true), this, ""); + + /** + * The column texera_db.dataset_version.did. + */ + public final TableField DID = createField(DSL.name("did"), org.jooq.impl.SQLDataType.INTEGERUNSIGNED.nullable(false), this, ""); + + /** + * The column texera_db.dataset_version.creator_uid. + */ + public final TableField CREATOR_UID = createField(DSL.name("creator_uid"), org.jooq.impl.SQLDataType.INTEGERUNSIGNED.nullable(false), this, ""); + + /** + * The column texera_db.dataset_version.name. + */ + public final TableField NAME = createField(DSL.name("name"), org.jooq.impl.SQLDataType.VARCHAR(128).nullable(false), this, ""); + + /** + * The column texera_db.dataset_version.version_hash. + */ + public final TableField VERSION_HASH = createField(DSL.name("version_hash"), org.jooq.impl.SQLDataType.VARCHAR(64).nullable(false), this, ""); + + /** + * The column texera_db.dataset_version.creation_time. + */ + public final TableField CREATION_TIME = createField(DSL.name("creation_time"), org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaultValue(org.jooq.impl.DSL.field("CURRENT_TIMESTAMP", org.jooq.impl.SQLDataType.TIMESTAMP)), this, ""); + + /** + * Create a texera_db.dataset_version table reference + */ + public DatasetVersion() { + this(DSL.name("dataset_version"), null); + } + + /** + * Create an aliased texera_db.dataset_version table reference + */ + public DatasetVersion(String alias) { + this(DSL.name(alias), DATASET_VERSION); + } + + /** + * Create an aliased texera_db.dataset_version table reference + */ + public DatasetVersion(Name alias) { + this(alias, DATASET_VERSION); + } + + private DatasetVersion(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private DatasetVersion(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("")); + } + + public DatasetVersion(Table child, ForeignKey key) { + super(child, key, DATASET_VERSION); + } + + @Override + public Schema getSchema() { + return TexeraDb.TEXERA_DB; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.DATASET_VERSION_DID, Indexes.DATASET_VERSION_IDX_DATASET_VERSION_NAME, Indexes.DATASET_VERSION_PRIMARY); + } + + @Override + public Identity getIdentity() { + return Keys.IDENTITY_DATASET_VERSION; + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_DATASET_VERSION_PRIMARY; + } + + @Override + public List> getKeys() { + return Arrays.>asList(Keys.KEY_DATASET_VERSION_PRIMARY); + } + + @Override + public List> getReferences() { + return Arrays.>asList(Keys.DATASET_VERSION_IBFK_1); + } + + public Dataset dataset() { + return new Dataset(this, Keys.DATASET_VERSION_IBFK_1); + } + + @Override + public DatasetVersion as(String alias) { + return new DatasetVersion(DSL.name(alias), this); + } + + @Override + public DatasetVersion as(Name alias) { + return new DatasetVersion(alias, this); + } + + /** + * Rename this table + */ + @Override + public DatasetVersion rename(String name) { + return new DatasetVersion(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public DatasetVersion rename(Name name) { + return new DatasetVersion(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetDao.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetDao.java new file mode 100644 index 00000000000..e7c4b99fe2a --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetDao.java @@ -0,0 +1,147 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.daos; + + +import edu.uci.ics.texera.web.model.jooq.generated.tables.Dataset; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetRecord; + +import java.sql.Timestamp; +import java.util.List; + +import org.jooq.Configuration; +import org.jooq.impl.DAOImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetDao extends DAOImpl { + + /** + * Create a new DatasetDao without any configuration + */ + public DatasetDao() { + super(Dataset.DATASET, edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.Dataset.class); + } + + /** + * Create a new DatasetDao with an attached configuration + */ + public DatasetDao(Configuration configuration) { + super(Dataset.DATASET, edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.Dataset.class, configuration); + } + + @Override + public UInteger getId(edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.Dataset object) { + return object.getDid(); + } + + /** + * Fetch records that have did BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfDid(UInteger lowerInclusive, UInteger upperInclusive) { + return fetchRange(Dataset.DATASET.DID, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have did IN (values) + */ + public List fetchByDid(UInteger... values) { + return fetch(Dataset.DATASET.DID, values); + } + + /** + * Fetch a unique record that has did = value + */ + public edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.Dataset fetchOneByDid(UInteger value) { + return fetchOne(Dataset.DATASET.DID, value); + } + + /** + * Fetch records that have owner_uid BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfOwnerUid(UInteger lowerInclusive, UInteger upperInclusive) { + return fetchRange(Dataset.DATASET.OWNER_UID, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have owner_uid IN (values) + */ + public List fetchByOwnerUid(UInteger... values) { + return fetch(Dataset.DATASET.OWNER_UID, values); + } + + /** + * Fetch records that have name BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfName(String lowerInclusive, String upperInclusive) { + return fetchRange(Dataset.DATASET.NAME, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have name IN (values) + */ + public List fetchByName(String... values) { + return fetch(Dataset.DATASET.NAME, values); + } + + /** + * Fetch records that have is_public BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfIsPublic(Byte lowerInclusive, Byte upperInclusive) { + return fetchRange(Dataset.DATASET.IS_PUBLIC, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have is_public IN (values) + */ + public List fetchByIsPublic(Byte... values) { + return fetch(Dataset.DATASET.IS_PUBLIC, values); + } + + /** + * Fetch records that have storage_path BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfStoragePath(String lowerInclusive, String upperInclusive) { + return fetchRange(Dataset.DATASET.STORAGE_PATH, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have storage_path IN (values) + */ + public List fetchByStoragePath(String... values) { + return fetch(Dataset.DATASET.STORAGE_PATH, values); + } + + /** + * Fetch records that have description BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfDescription(String lowerInclusive, String upperInclusive) { + return fetchRange(Dataset.DATASET.DESCRIPTION, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have description IN (values) + */ + public List fetchByDescription(String... values) { + return fetch(Dataset.DATASET.DESCRIPTION, values); + } + + /** + * Fetch records that have creation_time BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfCreationTime(Timestamp lowerInclusive, Timestamp upperInclusive) { + return fetchRange(Dataset.DATASET.CREATION_TIME, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have creation_time IN (values) + */ + public List fetchByCreationTime(Timestamp... values) { + return fetch(Dataset.DATASET.CREATION_TIME, values); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetUserAccessDao.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetUserAccessDao.java new file mode 100644 index 00000000000..7b719aef073 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetUserAccessDao.java @@ -0,0 +1,85 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.daos; + + +import edu.uci.ics.texera.web.model.jooq.generated.enums.DatasetUserAccessPrivilege; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetUserAccess; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetUserAccessRecord; + +import java.util.List; + +import org.jooq.Configuration; +import org.jooq.Record2; +import org.jooq.impl.DAOImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetUserAccessDao extends DAOImpl> { + + /** + * Create a new DatasetUserAccessDao without any configuration + */ + public DatasetUserAccessDao() { + super(DatasetUserAccess.DATASET_USER_ACCESS, edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.DatasetUserAccess.class); + } + + /** + * Create a new DatasetUserAccessDao with an attached configuration + */ + public DatasetUserAccessDao(Configuration configuration) { + super(DatasetUserAccess.DATASET_USER_ACCESS, edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.DatasetUserAccess.class, configuration); + } + + @Override + public Record2 getId(edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.DatasetUserAccess object) { + return compositeKeyRecord(object.getDid(), object.getUid()); + } + + /** + * Fetch records that have did BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfDid(UInteger lowerInclusive, UInteger upperInclusive) { + return fetchRange(DatasetUserAccess.DATASET_USER_ACCESS.DID, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have did IN (values) + */ + public List fetchByDid(UInteger... values) { + return fetch(DatasetUserAccess.DATASET_USER_ACCESS.DID, values); + } + + /** + * Fetch records that have uid BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfUid(UInteger lowerInclusive, UInteger upperInclusive) { + return fetchRange(DatasetUserAccess.DATASET_USER_ACCESS.UID, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have uid IN (values) + */ + public List fetchByUid(UInteger... values) { + return fetch(DatasetUserAccess.DATASET_USER_ACCESS.UID, values); + } + + /** + * Fetch records that have privilege BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfPrivilege(DatasetUserAccessPrivilege lowerInclusive, DatasetUserAccessPrivilege upperInclusive) { + return fetchRange(DatasetUserAccess.DATASET_USER_ACCESS.PRIVILEGE, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have privilege IN (values) + */ + public List fetchByPrivilege(DatasetUserAccessPrivilege... values) { + return fetch(DatasetUserAccess.DATASET_USER_ACCESS.PRIVILEGE, values); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetVersionDao.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetVersionDao.java new file mode 100644 index 00000000000..7508635b901 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/daos/DatasetVersionDao.java @@ -0,0 +1,133 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.daos; + + +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetVersion; +import edu.uci.ics.texera.web.model.jooq.generated.tables.records.DatasetVersionRecord; + +import java.sql.Timestamp; +import java.util.List; + +import org.jooq.Configuration; +import org.jooq.impl.DAOImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetVersionDao extends DAOImpl { + + /** + * Create a new DatasetVersionDao without any configuration + */ + public DatasetVersionDao() { + super(DatasetVersion.DATASET_VERSION, edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.DatasetVersion.class); + } + + /** + * Create a new DatasetVersionDao with an attached configuration + */ + public DatasetVersionDao(Configuration configuration) { + super(DatasetVersion.DATASET_VERSION, edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.DatasetVersion.class, configuration); + } + + @Override + public UInteger getId(edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.DatasetVersion object) { + return object.getDvid(); + } + + /** + * Fetch records that have dvid BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfDvid(UInteger lowerInclusive, UInteger upperInclusive) { + return fetchRange(DatasetVersion.DATASET_VERSION.DVID, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have dvid IN (values) + */ + public List fetchByDvid(UInteger... values) { + return fetch(DatasetVersion.DATASET_VERSION.DVID, values); + } + + /** + * Fetch a unique record that has dvid = value + */ + public edu.uci.ics.texera.web.model.jooq.generated.tables.pojos.DatasetVersion fetchOneByDvid(UInteger value) { + return fetchOne(DatasetVersion.DATASET_VERSION.DVID, value); + } + + /** + * Fetch records that have did BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfDid(UInteger lowerInclusive, UInteger upperInclusive) { + return fetchRange(DatasetVersion.DATASET_VERSION.DID, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have did IN (values) + */ + public List fetchByDid(UInteger... values) { + return fetch(DatasetVersion.DATASET_VERSION.DID, values); + } + + /** + * Fetch records that have creator_uid BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfCreatorUid(UInteger lowerInclusive, UInteger upperInclusive) { + return fetchRange(DatasetVersion.DATASET_VERSION.CREATOR_UID, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have creator_uid IN (values) + */ + public List fetchByCreatorUid(UInteger... values) { + return fetch(DatasetVersion.DATASET_VERSION.CREATOR_UID, values); + } + + /** + * Fetch records that have name BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfName(String lowerInclusive, String upperInclusive) { + return fetchRange(DatasetVersion.DATASET_VERSION.NAME, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have name IN (values) + */ + public List fetchByName(String... values) { + return fetch(DatasetVersion.DATASET_VERSION.NAME, values); + } + + /** + * Fetch records that have version_hash BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfVersionHash(String lowerInclusive, String upperInclusive) { + return fetchRange(DatasetVersion.DATASET_VERSION.VERSION_HASH, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have version_hash IN (values) + */ + public List fetchByVersionHash(String... values) { + return fetch(DatasetVersion.DATASET_VERSION.VERSION_HASH, values); + } + + /** + * Fetch records that have creation_time BETWEEN lowerInclusive AND upperInclusive + */ + public List fetchRangeOfCreationTime(Timestamp lowerInclusive, Timestamp upperInclusive) { + return fetchRange(DatasetVersion.DATASET_VERSION.CREATION_TIME, lowerInclusive, upperInclusive); + } + + /** + * Fetch records that have creation_time IN (values) + */ + public List fetchByCreationTime(Timestamp... values) { + return fetch(DatasetVersion.DATASET_VERSION.CREATION_TIME, values); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDataset.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDataset.java new file mode 100644 index 00000000000..413252a5aee --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDataset.java @@ -0,0 +1,102 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces; + + +import java.io.Serializable; +import java.sql.Timestamp; + +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public interface IDataset extends Serializable { + + /** + * Setter for texera_db.dataset.did. + */ + public void setDid(UInteger value); + + /** + * Getter for texera_db.dataset.did. + */ + public UInteger getDid(); + + /** + * Setter for texera_db.dataset.owner_uid. + */ + public void setOwnerUid(UInteger value); + + /** + * Getter for texera_db.dataset.owner_uid. + */ + public UInteger getOwnerUid(); + + /** + * Setter for texera_db.dataset.name. + */ + public void setName(String value); + + /** + * Getter for texera_db.dataset.name. + */ + public String getName(); + + /** + * Setter for texera_db.dataset.is_public. + */ + public void setIsPublic(Byte value); + + /** + * Getter for texera_db.dataset.is_public. + */ + public Byte getIsPublic(); + + /** + * Setter for texera_db.dataset.storage_path. + */ + public void setStoragePath(String value); + + /** + * Getter for texera_db.dataset.storage_path. + */ + public String getStoragePath(); + + /** + * Setter for texera_db.dataset.description. + */ + public void setDescription(String value); + + /** + * Getter for texera_db.dataset.description. + */ + public String getDescription(); + + /** + * Setter for texera_db.dataset.creation_time. + */ + public void setCreationTime(Timestamp value); + + /** + * Getter for texera_db.dataset.creation_time. + */ + public Timestamp getCreationTime(); + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + /** + * Load data from another generated Record/POJO implementing the common interface IDataset + */ + public void from(edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDataset from); + + /** + * Copy data into another generated Record/POJO implementing the common interface IDataset + */ + public E into(E into); +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDatasetUserAccess.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDatasetUserAccess.java new file mode 100644 index 00000000000..d0a2abe8db0 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDatasetUserAccess.java @@ -0,0 +1,63 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces; + + +import edu.uci.ics.texera.web.model.jooq.generated.enums.DatasetUserAccessPrivilege; + +import java.io.Serializable; + +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public interface IDatasetUserAccess extends Serializable { + + /** + * Setter for texera_db.dataset_user_access.did. + */ + public void setDid(UInteger value); + + /** + * Getter for texera_db.dataset_user_access.did. + */ + public UInteger getDid(); + + /** + * Setter for texera_db.dataset_user_access.uid. + */ + public void setUid(UInteger value); + + /** + * Getter for texera_db.dataset_user_access.uid. + */ + public UInteger getUid(); + + /** + * Setter for texera_db.dataset_user_access.privilege. + */ + public void setPrivilege(DatasetUserAccessPrivilege value); + + /** + * Getter for texera_db.dataset_user_access.privilege. + */ + public DatasetUserAccessPrivilege getPrivilege(); + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + /** + * Load data from another generated Record/POJO implementing the common interface IDatasetUserAccess + */ + public void from(edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDatasetUserAccess from); + + /** + * Copy data into another generated Record/POJO implementing the common interface IDatasetUserAccess + */ + public E into(E into); +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDatasetVersion.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDatasetVersion.java new file mode 100644 index 00000000000..38ab3a5c0e8 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/interfaces/IDatasetVersion.java @@ -0,0 +1,92 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces; + + +import java.io.Serializable; +import java.sql.Timestamp; + +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public interface IDatasetVersion extends Serializable { + + /** + * Setter for texera_db.dataset_version.dvid. + */ + public void setDvid(UInteger value); + + /** + * Getter for texera_db.dataset_version.dvid. + */ + public UInteger getDvid(); + + /** + * Setter for texera_db.dataset_version.did. + */ + public void setDid(UInteger value); + + /** + * Getter for texera_db.dataset_version.did. + */ + public UInteger getDid(); + + /** + * Setter for texera_db.dataset_version.creator_uid. + */ + public void setCreatorUid(UInteger value); + + /** + * Getter for texera_db.dataset_version.creator_uid. + */ + public UInteger getCreatorUid(); + + /** + * Setter for texera_db.dataset_version.name. + */ + public void setName(String value); + + /** + * Getter for texera_db.dataset_version.name. + */ + public String getName(); + + /** + * Setter for texera_db.dataset_version.version_hash. + */ + public void setVersionHash(String value); + + /** + * Getter for texera_db.dataset_version.version_hash. + */ + public String getVersionHash(); + + /** + * Setter for texera_db.dataset_version.creation_time. + */ + public void setCreationTime(Timestamp value); + + /** + * Getter for texera_db.dataset_version.creation_time. + */ + public Timestamp getCreationTime(); + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + /** + * Load data from another generated Record/POJO implementing the common interface IDatasetVersion + */ + public void from(edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDatasetVersion from); + + /** + * Copy data into another generated Record/POJO implementing the common interface IDatasetVersion + */ + public E into(E into); +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/Dataset.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/Dataset.java new file mode 100644 index 00000000000..aea39303d03 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/Dataset.java @@ -0,0 +1,166 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.pojos; + + +import edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDataset; + +import java.sql.Timestamp; + +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Dataset implements IDataset { + + private static final long serialVersionUID = 860030245; + + private UInteger did; + private UInteger ownerUid; + private String name; + private Byte isPublic; + private String storagePath; + private String description; + private Timestamp creationTime; + + public Dataset() {} + + public Dataset(IDataset value) { + this.did = value.getDid(); + this.ownerUid = value.getOwnerUid(); + this.name = value.getName(); + this.isPublic = value.getIsPublic(); + this.storagePath = value.getStoragePath(); + this.description = value.getDescription(); + this.creationTime = value.getCreationTime(); + } + + public Dataset( + UInteger did, + UInteger ownerUid, + String name, + Byte isPublic, + String storagePath, + String description, + Timestamp creationTime + ) { + this.did = did; + this.ownerUid = ownerUid; + this.name = name; + this.isPublic = isPublic; + this.storagePath = storagePath; + this.description = description; + this.creationTime = creationTime; + } + + @Override + public UInteger getDid() { + return this.did; + } + + @Override + public void setDid(UInteger did) { + this.did = did; + } + + @Override + public UInteger getOwnerUid() { + return this.ownerUid; + } + + @Override + public void setOwnerUid(UInteger ownerUid) { + this.ownerUid = ownerUid; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public void setName(String name) { + this.name = name; + } + + @Override + public Byte getIsPublic() { + return this.isPublic; + } + + @Override + public void setIsPublic(Byte isPublic) { + this.isPublic = isPublic; + } + + @Override + public String getStoragePath() { + return this.storagePath; + } + + @Override + public void setStoragePath(String storagePath) { + this.storagePath = storagePath; + } + + @Override + public String getDescription() { + return this.description; + } + + @Override + public void setDescription(String description) { + this.description = description; + } + + @Override + public Timestamp getCreationTime() { + return this.creationTime; + } + + @Override + public void setCreationTime(Timestamp creationTime) { + this.creationTime = creationTime; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Dataset ("); + + sb.append(did); + sb.append(", ").append(ownerUid); + sb.append(", ").append(name); + sb.append(", ").append(isPublic); + sb.append(", ").append(storagePath); + sb.append(", ").append(description); + sb.append(", ").append(creationTime); + + sb.append(")"); + return sb.toString(); + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IDataset from) { + setDid(from.getDid()); + setOwnerUid(from.getOwnerUid()); + setName(from.getName()); + setIsPublic(from.getIsPublic()); + setStoragePath(from.getStoragePath()); + setDescription(from.getDescription()); + setCreationTime(from.getCreationTime()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/DatasetUserAccess.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/DatasetUserAccess.java new file mode 100644 index 00000000000..c4ac78da249 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/DatasetUserAccess.java @@ -0,0 +1,101 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.pojos; + + +import edu.uci.ics.texera.web.model.jooq.generated.enums.DatasetUserAccessPrivilege; +import edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDatasetUserAccess; + +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetUserAccess implements IDatasetUserAccess { + + private static final long serialVersionUID = 1783622787; + + private UInteger did; + private UInteger uid; + private DatasetUserAccessPrivilege privilege; + + public DatasetUserAccess() {} + + public DatasetUserAccess(IDatasetUserAccess value) { + this.did = value.getDid(); + this.uid = value.getUid(); + this.privilege = value.getPrivilege(); + } + + public DatasetUserAccess( + UInteger did, + UInteger uid, + DatasetUserAccessPrivilege privilege + ) { + this.did = did; + this.uid = uid; + this.privilege = privilege; + } + + @Override + public UInteger getDid() { + return this.did; + } + + @Override + public void setDid(UInteger did) { + this.did = did; + } + + @Override + public UInteger getUid() { + return this.uid; + } + + @Override + public void setUid(UInteger uid) { + this.uid = uid; + } + + @Override + public DatasetUserAccessPrivilege getPrivilege() { + return this.privilege; + } + + @Override + public void setPrivilege(DatasetUserAccessPrivilege privilege) { + this.privilege = privilege; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("DatasetUserAccess ("); + + sb.append(did); + sb.append(", ").append(uid); + sb.append(", ").append(privilege); + + sb.append(")"); + return sb.toString(); + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IDatasetUserAccess from) { + setDid(from.getDid()); + setUid(from.getUid()); + setPrivilege(from.getPrivilege()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/DatasetVersion.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/DatasetVersion.java new file mode 100644 index 00000000000..4c177e80a7b --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/pojos/DatasetVersion.java @@ -0,0 +1,150 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.pojos; + + +import edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDatasetVersion; + +import java.sql.Timestamp; + +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetVersion implements IDatasetVersion { + + private static final long serialVersionUID = -1253265124; + + private UInteger dvid; + private UInteger did; + private UInteger creatorUid; + private String name; + private String versionHash; + private Timestamp creationTime; + + public DatasetVersion() {} + + public DatasetVersion(IDatasetVersion value) { + this.dvid = value.getDvid(); + this.did = value.getDid(); + this.creatorUid = value.getCreatorUid(); + this.name = value.getName(); + this.versionHash = value.getVersionHash(); + this.creationTime = value.getCreationTime(); + } + + public DatasetVersion( + UInteger dvid, + UInteger did, + UInteger creatorUid, + String name, + String versionHash, + Timestamp creationTime + ) { + this.dvid = dvid; + this.did = did; + this.creatorUid = creatorUid; + this.name = name; + this.versionHash = versionHash; + this.creationTime = creationTime; + } + + @Override + public UInteger getDvid() { + return this.dvid; + } + + @Override + public void setDvid(UInteger dvid) { + this.dvid = dvid; + } + + @Override + public UInteger getDid() { + return this.did; + } + + @Override + public void setDid(UInteger did) { + this.did = did; + } + + @Override + public UInteger getCreatorUid() { + return this.creatorUid; + } + + @Override + public void setCreatorUid(UInteger creatorUid) { + this.creatorUid = creatorUid; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public void setName(String name) { + this.name = name; + } + + @Override + public String getVersionHash() { + return this.versionHash; + } + + @Override + public void setVersionHash(String versionHash) { + this.versionHash = versionHash; + } + + @Override + public Timestamp getCreationTime() { + return this.creationTime; + } + + @Override + public void setCreationTime(Timestamp creationTime) { + this.creationTime = creationTime; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("DatasetVersion ("); + + sb.append(dvid); + sb.append(", ").append(did); + sb.append(", ").append(creatorUid); + sb.append(", ").append(name); + sb.append(", ").append(versionHash); + sb.append(", ").append(creationTime); + + sb.append(")"); + return sb.toString(); + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IDatasetVersion from) { + setDvid(from.getDvid()); + setDid(from.getDid()); + setCreatorUid(from.getCreatorUid()); + setName(from.getName()); + setVersionHash(from.getVersionHash()); + setCreationTime(from.getCreationTime()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetRecord.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetRecord.java new file mode 100644 index 00000000000..05eb41a1765 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetRecord.java @@ -0,0 +1,368 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.records; + + +import edu.uci.ics.texera.web.model.jooq.generated.tables.Dataset; +import edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDataset; + +import java.sql.Timestamp; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record7; +import org.jooq.Row7; +import org.jooq.impl.UpdatableRecordImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetRecord extends UpdatableRecordImpl implements Record7, IDataset { + + private static final long serialVersionUID = -1105041155; + + /** + * Setter for texera_db.dataset.did. + */ + @Override + public void setDid(UInteger value) { + set(0, value); + } + + /** + * Getter for texera_db.dataset.did. + */ + @Override + public UInteger getDid() { + return (UInteger) get(0); + } + + /** + * Setter for texera_db.dataset.owner_uid. + */ + @Override + public void setOwnerUid(UInteger value) { + set(1, value); + } + + /** + * Getter for texera_db.dataset.owner_uid. + */ + @Override + public UInteger getOwnerUid() { + return (UInteger) get(1); + } + + /** + * Setter for texera_db.dataset.name. + */ + @Override + public void setName(String value) { + set(2, value); + } + + /** + * Getter for texera_db.dataset.name. + */ + @Override + public String getName() { + return (String) get(2); + } + + /** + * Setter for texera_db.dataset.is_public. + */ + @Override + public void setIsPublic(Byte value) { + set(3, value); + } + + /** + * Getter for texera_db.dataset.is_public. + */ + @Override + public Byte getIsPublic() { + return (Byte) get(3); + } + + /** + * Setter for texera_db.dataset.storage_path. + */ + @Override + public void setStoragePath(String value) { + set(4, value); + } + + /** + * Getter for texera_db.dataset.storage_path. + */ + @Override + public String getStoragePath() { + return (String) get(4); + } + + /** + * Setter for texera_db.dataset.description. + */ + @Override + public void setDescription(String value) { + set(5, value); + } + + /** + * Getter for texera_db.dataset.description. + */ + @Override + public String getDescription() { + return (String) get(5); + } + + /** + * Setter for texera_db.dataset.creation_time. + */ + @Override + public void setCreationTime(Timestamp value) { + set(6, value); + } + + /** + * Getter for texera_db.dataset.creation_time. + */ + @Override + public Timestamp getCreationTime() { + return (Timestamp) get(6); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record7 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); + } + + @Override + public Row7 valuesRow() { + return (Row7) super.valuesRow(); + } + + @Override + public Field field1() { + return Dataset.DATASET.DID; + } + + @Override + public Field field2() { + return Dataset.DATASET.OWNER_UID; + } + + @Override + public Field field3() { + return Dataset.DATASET.NAME; + } + + @Override + public Field field4() { + return Dataset.DATASET.IS_PUBLIC; + } + + @Override + public Field field5() { + return Dataset.DATASET.STORAGE_PATH; + } + + @Override + public Field field6() { + return Dataset.DATASET.DESCRIPTION; + } + + @Override + public Field field7() { + return Dataset.DATASET.CREATION_TIME; + } + + @Override + public UInteger component1() { + return getDid(); + } + + @Override + public UInteger component2() { + return getOwnerUid(); + } + + @Override + public String component3() { + return getName(); + } + + @Override + public Byte component4() { + return getIsPublic(); + } + + @Override + public String component5() { + return getStoragePath(); + } + + @Override + public String component6() { + return getDescription(); + } + + @Override + public Timestamp component7() { + return getCreationTime(); + } + + @Override + public UInteger value1() { + return getDid(); + } + + @Override + public UInteger value2() { + return getOwnerUid(); + } + + @Override + public String value3() { + return getName(); + } + + @Override + public Byte value4() { + return getIsPublic(); + } + + @Override + public String value5() { + return getStoragePath(); + } + + @Override + public String value6() { + return getDescription(); + } + + @Override + public Timestamp value7() { + return getCreationTime(); + } + + @Override + public DatasetRecord value1(UInteger value) { + setDid(value); + return this; + } + + @Override + public DatasetRecord value2(UInteger value) { + setOwnerUid(value); + return this; + } + + @Override + public DatasetRecord value3(String value) { + setName(value); + return this; + } + + @Override + public DatasetRecord value4(Byte value) { + setIsPublic(value); + return this; + } + + @Override + public DatasetRecord value5(String value) { + setStoragePath(value); + return this; + } + + @Override + public DatasetRecord value6(String value) { + setDescription(value); + return this; + } + + @Override + public DatasetRecord value7(Timestamp value) { + setCreationTime(value); + return this; + } + + @Override + public DatasetRecord values(UInteger value1, UInteger value2, String value3, Byte value4, String value5, String value6, Timestamp value7) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + return this; + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IDataset from) { + setDid(from.getDid()); + setOwnerUid(from.getOwnerUid()); + setName(from.getName()); + setIsPublic(from.getIsPublic()); + setStoragePath(from.getStoragePath()); + setDescription(from.getDescription()); + setCreationTime(from.getCreationTime()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached DatasetRecord + */ + public DatasetRecord() { + super(Dataset.DATASET); + } + + /** + * Create a detached, initialised DatasetRecord + */ + public DatasetRecord(UInteger did, UInteger ownerUid, String name, Byte isPublic, String storagePath, String description, Timestamp creationTime) { + super(Dataset.DATASET); + + set(0, did); + set(1, ownerUid); + set(2, name); + set(3, isPublic); + set(4, storagePath); + set(5, description); + set(6, creationTime); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetUserAccessRecord.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetUserAccessRecord.java new file mode 100644 index 00000000000..75a4cf0d5fc --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetUserAccessRecord.java @@ -0,0 +1,207 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.records; + + +import edu.uci.ics.texera.web.model.jooq.generated.enums.DatasetUserAccessPrivilege; +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetUserAccess; +import edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDatasetUserAccess; + +import org.jooq.Field; +import org.jooq.Record2; +import org.jooq.Record3; +import org.jooq.Row3; +import org.jooq.impl.UpdatableRecordImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetUserAccessRecord extends UpdatableRecordImpl implements Record3, IDatasetUserAccess { + + private static final long serialVersionUID = -417509378; + + /** + * Setter for texera_db.dataset_user_access.did. + */ + @Override + public void setDid(UInteger value) { + set(0, value); + } + + /** + * Getter for texera_db.dataset_user_access.did. + */ + @Override + public UInteger getDid() { + return (UInteger) get(0); + } + + /** + * Setter for texera_db.dataset_user_access.uid. + */ + @Override + public void setUid(UInteger value) { + set(1, value); + } + + /** + * Getter for texera_db.dataset_user_access.uid. + */ + @Override + public UInteger getUid() { + return (UInteger) get(1); + } + + /** + * Setter for texera_db.dataset_user_access.privilege. + */ + @Override + public void setPrivilege(DatasetUserAccessPrivilege value) { + set(2, value); + } + + /** + * Getter for texera_db.dataset_user_access.privilege. + */ + @Override + public DatasetUserAccessPrivilege getPrivilege() { + return (DatasetUserAccessPrivilege) get(2); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record2 key() { + return (Record2) super.key(); + } + + // ------------------------------------------------------------------------- + // Record3 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row3 fieldsRow() { + return (Row3) super.fieldsRow(); + } + + @Override + public Row3 valuesRow() { + return (Row3) super.valuesRow(); + } + + @Override + public Field field1() { + return DatasetUserAccess.DATASET_USER_ACCESS.DID; + } + + @Override + public Field field2() { + return DatasetUserAccess.DATASET_USER_ACCESS.UID; + } + + @Override + public Field field3() { + return DatasetUserAccess.DATASET_USER_ACCESS.PRIVILEGE; + } + + @Override + public UInteger component1() { + return getDid(); + } + + @Override + public UInteger component2() { + return getUid(); + } + + @Override + public DatasetUserAccessPrivilege component3() { + return getPrivilege(); + } + + @Override + public UInteger value1() { + return getDid(); + } + + @Override + public UInteger value2() { + return getUid(); + } + + @Override + public DatasetUserAccessPrivilege value3() { + return getPrivilege(); + } + + @Override + public DatasetUserAccessRecord value1(UInteger value) { + setDid(value); + return this; + } + + @Override + public DatasetUserAccessRecord value2(UInteger value) { + setUid(value); + return this; + } + + @Override + public DatasetUserAccessRecord value3(DatasetUserAccessPrivilege value) { + setPrivilege(value); + return this; + } + + @Override + public DatasetUserAccessRecord values(UInteger value1, UInteger value2, DatasetUserAccessPrivilege value3) { + value1(value1); + value2(value2); + value3(value3); + return this; + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IDatasetUserAccess from) { + setDid(from.getDid()); + setUid(from.getUid()); + setPrivilege(from.getPrivilege()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached DatasetUserAccessRecord + */ + public DatasetUserAccessRecord() { + super(DatasetUserAccess.DATASET_USER_ACCESS); + } + + /** + * Create a detached, initialised DatasetUserAccessRecord + */ + public DatasetUserAccessRecord(UInteger did, UInteger uid, DatasetUserAccessPrivilege privilege) { + super(DatasetUserAccess.DATASET_USER_ACCESS); + + set(0, did); + set(1, uid); + set(2, privilege); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetVersionRecord.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetVersionRecord.java new file mode 100644 index 00000000000..144b34b87e6 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/model/jooq/generated/tables/records/DatasetVersionRecord.java @@ -0,0 +1,328 @@ +/* + * This file is generated by jOOQ. + */ +package edu.uci.ics.texera.web.model.jooq.generated.tables.records; + + +import edu.uci.ics.texera.web.model.jooq.generated.tables.DatasetVersion; +import edu.uci.ics.texera.web.model.jooq.generated.tables.interfaces.IDatasetVersion; + +import java.sql.Timestamp; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.impl.UpdatableRecordImpl; +import org.jooq.types.UInteger; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatasetVersionRecord extends UpdatableRecordImpl implements Record6, IDatasetVersion { + + private static final long serialVersionUID = -870558780; + + /** + * Setter for texera_db.dataset_version.dvid. + */ + @Override + public void setDvid(UInteger value) { + set(0, value); + } + + /** + * Getter for texera_db.dataset_version.dvid. + */ + @Override + public UInteger getDvid() { + return (UInteger) get(0); + } + + /** + * Setter for texera_db.dataset_version.did. + */ + @Override + public void setDid(UInteger value) { + set(1, value); + } + + /** + * Getter for texera_db.dataset_version.did. + */ + @Override + public UInteger getDid() { + return (UInteger) get(1); + } + + /** + * Setter for texera_db.dataset_version.creator_uid. + */ + @Override + public void setCreatorUid(UInteger value) { + set(2, value); + } + + /** + * Getter for texera_db.dataset_version.creator_uid. + */ + @Override + public UInteger getCreatorUid() { + return (UInteger) get(2); + } + + /** + * Setter for texera_db.dataset_version.name. + */ + @Override + public void setName(String value) { + set(3, value); + } + + /** + * Getter for texera_db.dataset_version.name. + */ + @Override + public String getName() { + return (String) get(3); + } + + /** + * Setter for texera_db.dataset_version.version_hash. + */ + @Override + public void setVersionHash(String value) { + set(4, value); + } + + /** + * Getter for texera_db.dataset_version.version_hash. + */ + @Override + public String getVersionHash() { + return (String) get(4); + } + + /** + * Setter for texera_db.dataset_version.creation_time. + */ + @Override + public void setCreationTime(Timestamp value) { + set(5, value); + } + + /** + * Getter for texera_db.dataset_version.creation_time. + */ + @Override + public Timestamp getCreationTime() { + return (Timestamp) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return DatasetVersion.DATASET_VERSION.DVID; + } + + @Override + public Field field2() { + return DatasetVersion.DATASET_VERSION.DID; + } + + @Override + public Field field3() { + return DatasetVersion.DATASET_VERSION.CREATOR_UID; + } + + @Override + public Field field4() { + return DatasetVersion.DATASET_VERSION.NAME; + } + + @Override + public Field field5() { + return DatasetVersion.DATASET_VERSION.VERSION_HASH; + } + + @Override + public Field field6() { + return DatasetVersion.DATASET_VERSION.CREATION_TIME; + } + + @Override + public UInteger component1() { + return getDvid(); + } + + @Override + public UInteger component2() { + return getDid(); + } + + @Override + public UInteger component3() { + return getCreatorUid(); + } + + @Override + public String component4() { + return getName(); + } + + @Override + public String component5() { + return getVersionHash(); + } + + @Override + public Timestamp component6() { + return getCreationTime(); + } + + @Override + public UInteger value1() { + return getDvid(); + } + + @Override + public UInteger value2() { + return getDid(); + } + + @Override + public UInteger value3() { + return getCreatorUid(); + } + + @Override + public String value4() { + return getName(); + } + + @Override + public String value5() { + return getVersionHash(); + } + + @Override + public Timestamp value6() { + return getCreationTime(); + } + + @Override + public DatasetVersionRecord value1(UInteger value) { + setDvid(value); + return this; + } + + @Override + public DatasetVersionRecord value2(UInteger value) { + setDid(value); + return this; + } + + @Override + public DatasetVersionRecord value3(UInteger value) { + setCreatorUid(value); + return this; + } + + @Override + public DatasetVersionRecord value4(String value) { + setName(value); + return this; + } + + @Override + public DatasetVersionRecord value5(String value) { + setVersionHash(value); + return this; + } + + @Override + public DatasetVersionRecord value6(Timestamp value) { + setCreationTime(value); + return this; + } + + @Override + public DatasetVersionRecord values(UInteger value1, UInteger value2, UInteger value3, String value4, String value5, Timestamp value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IDatasetVersion from) { + setDvid(from.getDvid()); + setDid(from.getDid()); + setCreatorUid(from.getCreatorUid()); + setName(from.getName()); + setVersionHash(from.getVersionHash()); + setCreationTime(from.getCreationTime()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached DatasetVersionRecord + */ + public DatasetVersionRecord() { + super(DatasetVersion.DATASET_VERSION); + } + + /** + * Create a detached, initialised DatasetVersionRecord + */ + public DatasetVersionRecord(UInteger dvid, UInteger did, UInteger creatorUid, String name, String versionHash, Timestamp creationTime) { + super(DatasetVersion.DATASET_VERSION); + + set(0, dvid); + set(1, did); + set(2, creatorUid); + set(3, name); + set(4, versionHash); + set(5, creationTime); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/service/GitVersionControlLocalFileStorage.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/service/GitVersionControlLocalFileStorage.java new file mode 100644 index 00000000000..354dfcf0115 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/service/GitVersionControlLocalFileStorage.java @@ -0,0 +1,152 @@ +package edu.uci.ics.texera.web.resource.dashboard.user.dataset.service; + +import edu.uci.ics.texera.web.resource.dashboard.user.dataset.type.FileNode; +import edu.uci.ics.texera.web.resource.dashboard.user.dataset.utils.JGitVersionControl; +import org.eclipse.jgit.api.errors.GitAPIException; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.Comparator; +import java.util.Set; + +/** + * Git-based implementation of the VersionControlFileStorageService, using local file storage. + */ +public class GitVersionControlLocalFileStorage { + + /** + * Writes content from the InputStream to a file at the given path. And stage the file addition/modification to git + * This function WILL create the missing parent directory along the path + + * This method is NOT THREAD SAFE, as it did the file I/O and the git add operation + * @param filePath The path within the repository to write the file. + * @param inputStream The InputStream from which to read the content. + * @throws IOException If an I/O error occurs. + */ + public static void writeFileToRepo(Path repoPath, Path filePath, InputStream inputStream) throws IOException, GitAPIException { + Files.createDirectories(filePath.getParent()); + Files.copy(inputStream, filePath, StandardCopyOption.REPLACE_EXISTING); + // stage the addition/modification + JGitVersionControl.add(repoPath, filePath); + } + + /** + * Deletes a file at the given path. + * If the file path is pointing to a directory, or if file does not exist, error will be thrown + + * This method is NOT THREAD SAFE, as it did the file I/O and the git rm operation + * @param filePath The path of the file to delete. + * @throws IOException If an I/O error occurs. + */ + public static void removeFileFromRepo(Path repoPath, Path filePath) throws IOException, GitAPIException { + if (Files.isDirectory(filePath)) { + throw new IllegalArgumentException("Provided path is a directory, not a file: " + filePath); + } + + Files.delete(filePath); + // stage the deletion + JGitVersionControl.rm(repoPath, filePath); + } + + /** + * Deletes the entire repository specified by the path. + + * This method is NOT THREAD SAFE, as it did the file I/O recursively + * @param directoryPath The path of the directory to delete. + * @throws IOException If an I/O error occurs. + */ + public static void deleteRepo(Path directoryPath) throws IOException { + Files.walk(directoryPath) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } + + /** + * Initializes a new repository for version control at the specified path. + + * This method is THREAD SAFE + * @param baseRepoPath Path to initialize the repository at. + * @return The branch identifier + * @throws IOException If an I/O error occurs. + * @throws GitAPIException If the JGit operation is interrupted. + */ + public static String initRepo(Path baseRepoPath) throws IOException, GitAPIException { + return JGitVersionControl.initRepo(baseRepoPath); + } + + /** + * Executes a group of file operations as a single versioned transaction. The version is bumped after the operations finish. + + * This method is NOT THREAD SAFE as it potentially does lots of file I/O along with git operations + * @param baseRepoPath The repository path. + * @param versionName The name or message associated with the version. + * @param operations The file operations to be executed within this versioned transaction. + * @throws IOException If an I/O error occurs. + * @throws GitAPIException If a Git operation fails. + */ + public static String withCreateVersion(Path baseRepoPath, String versionName, Runnable operations) throws IOException, GitAPIException { + // Execute the provided file operations + operations.run(); + // After successful execution, create a new version with the specified name + return JGitVersionControl.commit(baseRepoPath, versionName); + } + + /** + * Retrieves the set of file nodes at the root level, identified by its commit hash. + + * This method is THREAD SAFE + * @param baseRepoPath The repository path. + * @param versionCommitHashVal The commit hash of the version. + * @return A set of file nodes at the root level of the given repo at given version + */ + public static Set retrieveRootFileNodesOfVersion(Path baseRepoPath, String versionCommitHashVal) throws Exception { + return JGitVersionControl.getRootFileNodeOfCommit(baseRepoPath, versionCommitHashVal); + } + + /** + * Retrieves the content of a specific file from a specific version identified by its commit hash. + * Writes the file content to the provided OutputStream. + + * This method is THREAD SAFE + * @param baseRepoPath The repository path. + * @param commitHash The commit hash of the version from which the file content is retrieved. + * @param filePath The path of the file within the repository. + * @param outputStream The OutputStream to which the file content is written. + * @throws IOException If an I/O error occurs. + * @throws GitAPIException If the operation is interrupted. + */ + public static void retrieveFileContentOfVersion(Path baseRepoPath, String commitHash, Path filePath, OutputStream outputStream) throws IOException, GitAPIException { + JGitVersionControl.readFileContentOfCommit(baseRepoPath, commitHash, filePath, outputStream); + } + + /** + * Check if there is any uncommitted change in the given repo + + * This method is THREAD SAFE + * @param repoPath The repository path + * @return True if there are uncommitted changes. + * @throws GitAPIException + * @throws IOException + */ + public static boolean hasUncommittedChanges(Path repoPath) throws GitAPIException, IOException { + return JGitVersionControl.hasUncommittedChanges(repoPath); + } + + /** + * Recovers the repository to its latest version, discarding any uncommitted changes if any. + + * This method is NOT THREAD SAFE + * @param baseRepoPath The repository path. + * @throws IOException If an I/O error occurs. + * @throws GitAPIException If the operation is interrupted. + */ + public static void discardUncommittedChanges(Path baseRepoPath) throws IOException, GitAPIException { + JGitVersionControl.discardUncommittedChanges(baseRepoPath); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/type/FileNode.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/type/FileNode.java new file mode 100644 index 00000000000..4e4ebeb570a --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/type/FileNode.java @@ -0,0 +1,54 @@ +package edu.uci.ics.texera.web.resource.dashboard.user.dataset.type; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +public class FileNode { + private final Path path; + private final Set children; + + public FileNode(Path path) { + this.path = path; + this.children = new HashSet<>(); + } + + public boolean isFile() { + return Files.isRegularFile(path); + } + + public boolean isDirectory() { + return Files.isDirectory(path); + } + + public Path getPath() { + return path; + } + + public void addChildNode(FileNode child) { + if (!child.getPath().getParent().equals(this.path)) { + throw new IllegalArgumentException("Child node is not a direct subpath of the parent node"); + } + this.children.add(child); + } + + public Set getChildren() { + return children; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + FileNode fileNode = (FileNode) o; + return Objects.equals(path, fileNode.path) && + Objects.equals(children, fileNode.children); + } + + @Override + public int hashCode() { + return Objects.hash(path, children); + } +} diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/utils/JGitVersionControl.java b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/utils/JGitVersionControl.java new file mode 100644 index 00000000000..c547a44aea1 --- /dev/null +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/dashboard/user/dataset/utils/JGitVersionControl.java @@ -0,0 +1,184 @@ +package edu.uci.ics.texera.web.resource.dashboard.user.dataset.utils; + +import edu.uci.ics.texera.web.resource.dashboard.user.dataset.type.FileNode; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.ResetCommand; +import org.eclipse.jgit.api.Status; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.ObjectLoader; +import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.revwalk.RevWalk; +import org.eclipse.jgit.storage.file.FileRepositoryBuilder; +import org.eclipse.jgit.treewalk.TreeWalk; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class JGitVersionControl { + + public static String initRepo(Path path) throws GitAPIException, IOException { + File gitDir = path.resolve(".git").toFile(); + if (gitDir.exists()) { + throw new IOException("Repository already exists at " + path); + } + // try-with-resource make sure the resource is released + try (Git git = Git.init().setDirectory(path.toFile()).call()) { + // Retrieve the default branch name + Ref head = git.getRepository().exactRef("HEAD"); + if (head == null || head.getTarget() == null) { + return null; + } + String refName = head.getTarget().getName(); + // HEAD should be in the form of 'ref: refs/heads/defaultBranchName' + if (!refName.startsWith("refs/heads/")) { + return null; + } + return refName.substring("refs/heads/".length()); + } + } + + public static void readFileContentOfCommit(Path repoPath, String commitHash, Path filePath, OutputStream outputStream) throws IOException { + if (!filePath.startsWith(repoPath)) { + throw new IllegalArgumentException("File path must be under the repository path."); + } + + if (Files.isDirectory(filePath)) { + throw new IllegalArgumentException("File path points to a directory, not a file."); + } + + try (Repository repository = new FileRepositoryBuilder() + .setGitDir(repoPath.resolve(".git").toFile()) + .build(); + RevWalk revWalk = new RevWalk(repository)) { + + RevCommit commit = revWalk.parseCommit(repository.resolve(commitHash)); + TreeWalk treeWalk = + TreeWalk.forPath(repository, repoPath.relativize(filePath).toString(), commit.getTree()); + if (treeWalk == null) { + throw new IOException("File not found in commit: " + filePath); + } + ObjectId objectId = treeWalk.getObjectId(0); + ObjectLoader loader = repository.open(objectId); + + loader.copyTo(outputStream); + } + } + + public static Set getRootFileNodeOfCommit(Path repoPath, String commitHash) throws Exception { + Map pathToFileNodeMap = new HashMap<>(); + Set rootNodes = new HashSet<>(); + + try (Repository repository = new FileRepositoryBuilder() + .setGitDir(repoPath.resolve(".git").toFile()) + .build(); + RevWalk revWalk = new RevWalk(repository)) { + ObjectId commitId = repository.resolve(commitHash); + RevCommit commit = revWalk.parseCommit(commitId); + + // initialize the treeWalk to traverse the file tree + TreeWalk treeWalk = new TreeWalk(repository); + treeWalk.addTree(commit.getTree()); + treeWalk.setRecursive(true); + + while (treeWalk.next()) { + Path fullPath = repoPath.resolve(treeWalk.getPathString()); + String pathStr = fullPath.toString(); + + // Determine if the current path is at the root level + if (treeWalk.getDepth() == 0) { + FileNode rootNode = new FileNode(fullPath); + rootNodes.add(rootNode); + pathToFileNodeMap.put(pathStr, rootNode); + } else { + // For child nodes, find or create the parent node based on the directory structure + Path parentPath = fullPath.getParent(); + String parentPathStr = parentPath.toString(); + FileNode parentNode = pathToFileNodeMap.get(parentPathStr); + + if (parentNode == null) { + parentNode = new FileNode(parentPath); + pathToFileNodeMap.put(parentPathStr, parentNode); + // Determine if this parent should be added to rootNodes + if (parentPath.getParent().equals(repoPath)) { + rootNodes.add(parentNode); + } + } + + FileNode childNode = new FileNode(fullPath); + parentNode.addChildNode(childNode); + // Map child node to its path for potential future children + pathToFileNodeMap.put(pathStr, childNode); + } + } + } + return rootNodes; + } + + public static void add(Path repoPath, Path filePath) throws IOException, GitAPIException { + try (Git git = Git.open(repoPath.toFile())) { + // Stage the file addition/modification + git.add().addFilepattern(repoPath.relativize(filePath).toString()).call(); + } + } + + public static void rm(Path repoPath, Path filePath) throws IOException, GitAPIException { + try (Git git = Git.open(repoPath.toFile())) { + git.rm().addFilepattern(repoPath.relativize(filePath).toString()).call(); // Stages the file deletion + } + } + + // create a commit, and return the commit hash + public static String commit(Path repoPath, String commitMessage) throws IOException, GitAPIException { + FileRepositoryBuilder builder = new FileRepositoryBuilder(); + try (Repository repository = builder.setGitDir(repoPath.resolve(".git").toFile()) + .readEnvironment() // scan environment GIT_* variables + .findGitDir() // scan up the file system tree + .build()) { + + try (Git git = new Git(repository)) { + // Commit the changes that have been staged + RevCommit commit = git.commit().setMessage(commitMessage).call(); + + // Return the commit hash + return commit.getId().getName(); + } + } + } + + public static void discardUncommittedChanges(Path repoPath) throws IOException, GitAPIException { + try (Repository repository = new FileRepositoryBuilder() + .setGitDir(repoPath.resolve(".git").toFile()) + .build(); + Git git = new Git(repository)) { + + // Reset hard to discard changes in tracked files + git.reset().setMode(ResetCommand.ResetType.HARD).call(); + + // Clean the working directory to remove untracked files + git.clean().setCleanDirectories(true).call(); + } + } + + public static boolean hasUncommittedChanges(Path repoPath) throws IOException, GitAPIException { + try (Repository repository = new FileRepositoryBuilder() + .setGitDir(repoPath.resolve(".git").toFile()) + .readEnvironment() + .findGitDir() + .build(); + Git git = new Git(repository)) { + + Status status = git.status().call(); + return !status.isClean(); + } + } +} diff --git a/core/amber/src/test/java/edu/uci/ics/texera/web/resource/dashboard/user/dataset/GitVersionControlLocalFileStorageSpec.java b/core/amber/src/test/java/edu/uci/ics/texera/web/resource/dashboard/user/dataset/GitVersionControlLocalFileStorageSpec.java new file mode 100644 index 00000000000..67236d96767 --- /dev/null +++ b/core/amber/src/test/java/edu/uci/ics/texera/web/resource/dashboard/user/dataset/GitVersionControlLocalFileStorageSpec.java @@ -0,0 +1,201 @@ +package edu.uci.ics.texera.web.resource.dashboard.user.dataset; + +import edu.uci.ics.texera.web.resource.dashboard.user.dataset.service.GitVersionControlLocalFileStorage; +import edu.uci.ics.texera.web.resource.dashboard.user.dataset.type.FileNode; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.Assert; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class GitVersionControlLocalFileStorageSpec { + + private Path testRepoPath; + + private List testRepoMasterCommitHashes; + private final String testFile1Name = "testFile1.txt"; + + private final String testFile2Name = "testFile2.txt"; + private final String testDirectoryName = "testDir"; + + private final String testFile1ContentV1 = "This is a test file1 v1"; + private final String testFile1ContentV2 = "This is a test file1 v2"; + private final String testFile1ContentV3 = "This is a test file1 v3"; + + private final String testFile2Content = "This is a test file2 in the testDir"; + + private void writeFileToRepo(Path filePath, String fileContent) throws IOException, GitAPIException { + try (ByteArrayInputStream input = new ByteArrayInputStream(fileContent.getBytes())) { + GitVersionControlLocalFileStorage.writeFileToRepo(testRepoPath, filePath, input); + } + } + + @Before + public void setUp() throws IOException, GitAPIException { + // Create a temporary directory for the repository + testRepoPath = Files.createTempDirectory("testRepo"); + GitVersionControlLocalFileStorage.initRepo(testRepoPath); + + Path file1Path = testRepoPath.resolve(testFile1Name); + // Version 1 + String v1Hash = GitVersionControlLocalFileStorage.withCreateVersion( + testRepoPath, + "v1", + () -> { + try { + writeFileToRepo(file1Path, testFile1ContentV1); + } catch (IOException | GitAPIException e) { + throw new RuntimeException(e); + } + }); + + String v2Hash = GitVersionControlLocalFileStorage.withCreateVersion( + testRepoPath, + "v2", + () -> { + try { + writeFileToRepo(file1Path, testFile1ContentV2); + } catch (IOException | GitAPIException e) { + throw new RuntimeException(e); + }}); + + // Version 3 + String v3Hash = GitVersionControlLocalFileStorage.withCreateVersion( + testRepoPath, + "v3", + () -> { + try { + writeFileToRepo(file1Path, testFile1ContentV3); + } catch (IOException | GitAPIException e) { + throw new RuntimeException(e); + }}); + + testRepoMasterCommitHashes = new ArrayList() {{ + add(v1Hash); + add(v2Hash); + add(v3Hash); + }}; + } + + @After + public void tearDown() throws IOException { + // Clean up the test repository directory + GitVersionControlLocalFileStorage.deleteRepo(testRepoPath); + } + + @Test + public void testFileContentAcrossVersions() throws IOException, GitAPIException { + // File path for the test file + Path filePath = testRepoPath.resolve(testFile1Name); + + // testRepoMasterCommitHashes is populated in chronological order: v1, v2, v3 + // Retrieve and compare file content for version 1 + ByteArrayOutputStream outputV1 = new ByteArrayOutputStream(); + GitVersionControlLocalFileStorage.retrieveFileContentOfVersion(testRepoPath, testRepoMasterCommitHashes.get(0), filePath, outputV1); + String retrievedContentV1 = outputV1.toString(); + Assert.assertEquals( + "Content for version 1 does not match", + testFile1ContentV1, + retrievedContentV1); + + // Retrieve and compare file content for version 2 + ByteArrayOutputStream outputV2 = new ByteArrayOutputStream(); + GitVersionControlLocalFileStorage.retrieveFileContentOfVersion(testRepoPath, testRepoMasterCommitHashes.get(1), filePath, outputV2); + String retrievedContentV2 = outputV2.toString(); + Assert.assertEquals( + "Content for version 2 does not match", + testFile1ContentV2, + retrievedContentV2); + + // Retrieve and compare file content for version 3 + ByteArrayOutputStream outputV3 = new ByteArrayOutputStream(); + GitVersionControlLocalFileStorage.retrieveFileContentOfVersion(testRepoPath, testRepoMasterCommitHashes.get(2), filePath, outputV3); + String retrievedContentV3 = outputV3.toString(); + Assert.assertEquals( + "Content for version 3 does not match", + testFile1ContentV3, + retrievedContentV3); + } + + @Test + public void testFileTreeRetrieval() throws Exception { + // File path for the test file + Path file1Path = testRepoPath.resolve(testFile1Name); + FileNode file1Node = new FileNode(file1Path); + Set fileNodes = new HashSet() {{ + add(file1Node); + }}; + + // first retrieve the latest version's file tree + Assert.assertEquals("File Tree should match", + fileNodes, + GitVersionControlLocalFileStorage.retrieveRootFileNodesOfVersion(testRepoPath, testRepoMasterCommitHashes.get(testRepoMasterCommitHashes.size() - 1))); + + // now we add a new file testDir/testFile2.txt + Path testDirPath = testRepoPath.resolve(testDirectoryName); + Path file2Path = testDirPath.resolve(testFile2Name); + + String v4Hash = GitVersionControlLocalFileStorage.withCreateVersion(testRepoPath, "v4", () -> { + try { + writeFileToRepo(file2Path, testFile2Content); + } catch (IOException | GitAPIException e) { + throw new RuntimeException(e); + } + }); + testRepoMasterCommitHashes.add(v4Hash); + + FileNode dirNode = new FileNode(testDirPath); + dirNode.addChildNode(new FileNode(file2Path)); + // update the expected fileNodes + fileNodes.add(dirNode); + + // check the file tree + Assert.assertEquals( + "File Tree should match", + fileNodes, + GitVersionControlLocalFileStorage.retrieveRootFileNodesOfVersion(testRepoPath, v4Hash)); + + // now we delete the file1, check the filetree + String v5Hash = GitVersionControlLocalFileStorage.withCreateVersion(testRepoPath, "v5", () -> { + try { + GitVersionControlLocalFileStorage.removeFileFromRepo(testRepoPath, file1Path); + } catch (IOException | GitAPIException e) { + throw new RuntimeException(e); + } + }); + + fileNodes.remove(file1Node); + Assert.assertEquals( + "File1 should be gone", + fileNodes, + GitVersionControlLocalFileStorage.retrieveRootFileNodesOfVersion(testRepoPath, v5Hash) + ); + + } + + @Test + public void testUncommittedCheckAndRecoverToLatest() throws Exception { + Path tempFilePath = testRepoPath.resolve("tempFile"); + String content = "some random content"; + writeFileToRepo(tempFilePath, content); + + Assert.assertTrue( + "There should be some uncommitted changes", + GitVersionControlLocalFileStorage.hasUncommittedChanges(testRepoPath)); + + GitVersionControlLocalFileStorage.discardUncommittedChanges(testRepoPath); + + Assert.assertFalse("There should be no uncommitted changes", + GitVersionControlLocalFileStorage.hasUncommittedChanges(testRepoPath)); + } +} diff --git a/core/scripts/sql/texera_ddl.sql b/core/scripts/sql/texera_ddl.sql index 87feb08d4ef..3eeb24b1e10 100644 --- a/core/scripts/sql/texera_ddl.sql +++ b/core/scripts/sql/texera_ddl.sql @@ -15,6 +15,9 @@ DROP TABLE IF EXISTS `workflow_of_project`; DROP TABLE IF EXISTS `file_of_workflow`; DROP TABLE IF EXISTS `file_of_project`; DROP TABLE IF EXISTS `workflow_executions`; +DROP TABLE IF EXISTS `dataset`; +DROP TABLE IF EXISTS `dataset_user_access`; +DROP TABLE IF EXISTS `dataset_version`; SET PERSIST time_zone = '+00:00'; -- this line is mandatory SET PERSIST sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')); @@ -205,6 +208,41 @@ CREATE TABLE IF NOT EXISTS workflow_runtime_statistics FOREIGN KEY (`execution_id`) REFERENCES `workflow_executions` (`eid`) ON DELETE CASCADE ) ENGINE = INNODB; +CREATE TABLE IF NOT EXISTS dataset +( + `did` INT UNSIGNED AUTO_INCREMENT NOT NULL, + `owner_uid` INT UNSIGNED NOT NULL, + `name` VARCHAR(128) NOT NULL, + `is_public` TINYINT NOT NULL DEFAULT 1, + `storage_path` VARCHAR(512) NOT NULL, + `description` VARCHAR(512) NOT NULL, + `creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(`did`), + FOREIGN KEY (`owner_uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE + ) ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS dataset_user_access +( + `did` INT UNSIGNED NOT NULL, + `uid` INT UNSIGNED NOT NULL, + `privilege` ENUM('NONE', 'READ', 'WRITE') NOT NULL DEFAULT 'NONE', + PRIMARY KEY(`did`, `uid`), + FOREIGN KEY (`did`) REFERENCES `dataset` (`did`) ON DELETE CASCADE, + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE + ) ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS dataset_version +( + `dvid` INT UNSIGNED AUTO_INCREMENT NOT NULL, + `did` INT UNSIGNED NOT NULL, + `creator_uid` INT UNSIGNED NOT NULL, + `name` VARCHAR(128) NOT NULL, + `version_hash` VARCHAR(64) NOT NULL, + `creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(`dvid`), + FOREIGN KEY (`did`) REFERENCES `dataset` (`did`) ON DELETE CASCADE + ) ENGINE = INNODB; + -- create fulltext search indexes CREATE FULLTEXT INDEX `idx_workflow_name_description_content` ON `texera_db`.`workflow` (name, description, content); @@ -214,3 +252,7 @@ CREATE FULLTEXT INDEX `idx_user_name` ON `texera_db`.`user` (name); CREATE FULLTEXT INDEX `idx_user_project_name_description` ON `texera_db`.`project` (name, description); CREATE FULLTEXT INDEX `idx_file_name_description` ON `texera_db`.`file` (name, description); + +CREATE FULLTEXT INDEX `idx_dataset_name_description` ON `texera_db`.`dataset` (name, description); + +CREATE FULLTEXT INDEX `idx_dataset_version_name` ON `texera_db`.`dataset_version` (name); \ No newline at end of file diff --git a/core/scripts/sql/update/07.sql b/core/scripts/sql/update/07.sql new file mode 100644 index 00000000000..0b8d8463f30 --- /dev/null +++ b/core/scripts/sql/update/07.sql @@ -0,0 +1,41 @@ +USE `texera_db`; + +-- Create new tables for dataset management +CREATE TABLE IF NOT EXISTS dataset +( + `did` INT UNSIGNED AUTO_INCREMENT NOT NULL, + `owner_uid` INT UNSIGNED NOT NULL, + `name` VARCHAR(128) NOT NULL, + `is_public` TINYINT NOT NULL DEFAULT 1, + `storage_path` VARCHAR(512) NOT NULL, + `description` VARCHAR(512) NOT NULL, + `creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(`did`), + FOREIGN KEY (`owner_uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE +) ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS dataset_user_access +( + `did` INT UNSIGNED NOT NULL, + `uid` INT UNSIGNED NOT NULL, + `privilege` ENUM('NONE', 'READ', 'WRITE') NOT NULL DEFAULT 'NONE', + PRIMARY KEY(`did`, `uid`), + FOREIGN KEY (`did`) REFERENCES `dataset` (`did`) ON DELETE CASCADE, + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE +) ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS dataset_version +( + `dvid` INT UNSIGNED AUTO_INCREMENT NOT NULL, + `did` INT UNSIGNED NOT NULL, + `creator_uid` INT UNSIGNED NOT NULL, + `name` VARCHAR(128) NOT NULL, + `version_hash` VARCHAR(64) NOT NULL, + `creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(`dvid`), + FOREIGN KEY (`did`) REFERENCES `dataset` (`did`) ON DELETE CASCADE +) ENGINE = INNODB; + +-- Create fulltext indexes for the new tables +CREATE FULLTEXT INDEX `idx_dataset_name_description` ON `texera_db`.`dataset` (name, description); +CREATE FULLTEXT INDEX `idx_dataset_version_name` ON `texera_db`.`dataset_version` (name); \ No newline at end of file