diff --git a/laboratory/resources/schemas/dbscripts/postgresql/laboratory-12.305-12.306.sql b/laboratory/resources/schemas/dbscripts/postgresql/laboratory-12.305-12.306.sql
new file mode 100644
index 00000000..df0e0a4b
--- /dev/null
+++ b/laboratory/resources/schemas/dbscripts/postgresql/laboratory-12.305-12.306.sql
@@ -0,0 +1,11 @@
+ALTER TABLE laboratory.species ADD rowid SERIAL;
+ALTER TABLE laboratory.species ADD container entityid;
+ALTER TABLE laboratory.species ADD created timestamp;
+ALTER TABLE laboratory.species ADD createdby int;
+ALTER TABLE laboratory.species ADD modified timestamp;
+ALTER TABLE laboratory.species ADD modifiedby int;
+
+UPDATE laboratory.species SET container = (SELECT entityid FROM core.containers WHERE name = 'Shared');
+
+ALTER TABLE laboratory.species DROP CONSTRAINT PK_species;
+ALTER TABLE laboratory.species ADD CONSTRAINT PK_species PRIMARY KEY (rowid);
\ No newline at end of file
diff --git a/laboratory/resources/schemas/dbscripts/sqlserver/laboratory-12.305-12.306.sql b/laboratory/resources/schemas/dbscripts/sqlserver/laboratory-12.305-12.306.sql
new file mode 100644
index 00000000..e64122d0
--- /dev/null
+++ b/laboratory/resources/schemas/dbscripts/sqlserver/laboratory-12.305-12.306.sql
@@ -0,0 +1,11 @@
+ALTER TABLE laboratory.species ADD rowid INT identity(1,1);
+ALTER TABLE laboratory.species ADD container entityid;
+ALTER TABLE laboratory.species ADD created datetime;
+ALTER TABLE laboratory.species ADD createdby int;
+ALTER TABLE laboratory.species ADD modified datetime;
+ALTER TABLE laboratory.species ADD modifiedby int;
+GO
+UPDATE laboratory.species SET container = (SELECT entityid FROM core.containers WHERE name = 'Shared');
+
+ALTER TABLE laboratory.species DROP CONSTRAINT PK_species;
+ALTER TABLE laboratory.species ADD CONSTRAINT PK_species PRIMARY KEY (rowid);
\ No newline at end of file
diff --git a/laboratory/resources/schemas/laboratory.xml b/laboratory/resources/schemas/laboratory.xml
index a80cf3be..8c435647 100644
--- a/laboratory/resources/schemas/laboratory.xml
+++ b/laboratory/resources/schemas/laboratory.xml
@@ -841,6 +841,9 @@
DETAILED
+
+ true
+
@@ -850,6 +853,29 @@
true
MHC Prefix
+
+ false
+
+
+ true
+
+
+ false
+ false
+ false
+ true
+ true
+
+
+ true
+
+
+ false
+ false
+ false
+ true
+ true
+
diff --git a/laboratory/resources/views/populateInitialValues.html b/laboratory/resources/views/populateInitialValues.html
index 7c844215..d99cd4f6 100644
--- a/laboratory/resources/views/populateInitialValues.html
+++ b/laboratory/resources/views/populateInitialValues.html
@@ -13,7 +13,7 @@
LABKEY.Ajax.request({
url : LABKEY.ActionURL.buildURL('laboratory', 'populateDefaults'),
params: {
- tableNames: ['sample_type']
+ tableNames: ['sample_type', 'species']
},
method : 'POST',
scope: this,
diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java b/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java
index bb5f1811..007fbeb9 100644
--- a/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java
+++ b/laboratory/src/org/labkey/laboratory/LaboratoryContainerListener.java
@@ -63,7 +63,7 @@ public void containerCreated(Container c, User user)
{
try
{
- LaboratoryManager.get().populateDefaultData(user, c, null);
+ LaboratoryManager.get().populateDefaultData(user, c);
}
catch (IllegalArgumentException e)
{
@@ -208,7 +208,7 @@ private void possiblyInitializeOnActiveModuleChange(PropertyChangeEvent evt)
try
{
- LaboratoryManager.get().populateDefaultData(u, ce.container, null);
+ LaboratoryManager.get().populateDefaultData(u, ce.container);
}
catch (Exception e)
{
diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryManager.java b/laboratory/src/org/labkey/laboratory/LaboratoryManager.java
index 4b61aa6d..1f9c73dd 100644
--- a/laboratory/src/org/labkey/laboratory/LaboratoryManager.java
+++ b/laboratory/src/org/labkey/laboratory/LaboratoryManager.java
@@ -18,6 +18,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.assay.AssayProvider;
import org.labkey.api.assay.AssayService;
@@ -336,26 +337,33 @@ public void updateWorkbookTags(User u, Container c, Collection tags, boo
}
}
+ public void populateDefaultData(User u, Container c)
+ {
+ populateDefaultData(u, c, Arrays.asList(LaboratorySchema.TABLE_SAMPLE_TYPE, LaboratorySchema.TABLE_SPECIES));
+ }
+
//pass null to populate all supported tables
- public void populateDefaultData(User u, Container c, @Nullable List tableNames)
+ public void populateDefaultData(User u, Container c, @NotNull List tableNames)
{
if (c.isWorkbook())
{
return;
}
- if (tableNames == null)
- {
- tableNames = new ArrayList<>();
- tableNames.add(LaboratorySchema.TABLE_SAMPLE_TYPE);
- }
-
for (String name : tableNames)
{
- if (LaboratorySchema.TABLE_SAMPLE_TYPE.equalsIgnoreCase(name))
+ if (LaboratorySchema.TABLE_SAMPLE_TYPE.equalsIgnoreCase(name) )
{
populateDefaultDataForTable(u, c, "laboratory", LaboratorySchema.TABLE_SAMPLE_TYPE, PageFlowUtil.set("type"), "type");
}
+ else if (LaboratorySchema.TABLE_SPECIES.equalsIgnoreCase(name) )
+ {
+ populateDefaultDataForTable(u, c, "laboratory", LaboratorySchema.TABLE_SPECIES, PageFlowUtil.set("common_name", "scientific_name", "mhc_prefix"), "common_name");
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown table: " + name);
+ }
}
}
diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryModule.java b/laboratory/src/org/labkey/laboratory/LaboratoryModule.java
index 15fbffd0..1721e500 100644
--- a/laboratory/src/org/labkey/laboratory/LaboratoryModule.java
+++ b/laboratory/src/org/labkey/laboratory/LaboratoryModule.java
@@ -76,7 +76,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
- return 12.305;
+ return 12.306;
}
@Override
diff --git a/laboratory/src/org/labkey/laboratory/LaboratorySchema.java b/laboratory/src/org/labkey/laboratory/LaboratorySchema.java
index 2a5fa678..5c9d38b8 100644
--- a/laboratory/src/org/labkey/laboratory/LaboratorySchema.java
+++ b/laboratory/src/org/labkey/laboratory/LaboratorySchema.java
@@ -38,6 +38,7 @@ public class LaboratorySchema
public static final String TABLE_WORKBOOKS = "workbooks";
public static final String TABLE_WORKBOOK_TAGS = "workbook_tags";
public static final String TABLE_ASSAY_RUN_TEMPLATES = "assay_run_templates";
+ public static final String TABLE_SPECIES = "species";
public static LaboratorySchema getInstance()
{
diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryUserSchema.java b/laboratory/src/org/labkey/laboratory/LaboratoryUserSchema.java
index ebc0c579..bfefbb45 100644
--- a/laboratory/src/org/labkey/laboratory/LaboratoryUserSchema.java
+++ b/laboratory/src/org/labkey/laboratory/LaboratoryUserSchema.java
@@ -49,6 +49,8 @@ protected TableInfo createWrappedTable(String name, @NotNull TableInfo sourceTab
return getSubjectsTable(name, sourceTable, cf);
else if (LaboratorySchema.TABLE_FREEZERS.equalsIgnoreCase(name))
return getContainerScopedTable(name, sourceTable, cf, "name");
+ else if (LaboratorySchema.TABLE_SPECIES.equalsIgnoreCase(name))
+ return getContainerScopedTable(name, sourceTable, cf, "common_name");
else if (LaboratorySchema.TABLE_SAMPLE_TYPE.equalsIgnoreCase(name))
return getContainerScopedTable(name, sourceTable, cf, "type");
else if (LaboratorySchema.TABLE_DNA_OLIGOS.equalsIgnoreCase(name))