This topic is under construction for the 21.7 (July 2021) release of LabKey Server. For current documentation of this feature, click here.
This topic describes creation and population of a data class within the user interface.
Data Class User Interface
The web part "Data Classes" displays a list of the DataClasses in the current folder.
- Enter (Admin) > Page Admin Mode.
- Select Data Classes from the selector in the lower left, then click Add.
- Note that there is a "narrow" web part for data classes available on the the right side of the page. It does not have the controls described below, but can be used as a shortcut once you have set up your classes.
- Click Exit Admin Mode.
You can create a DataClass from scratch, using the designer interface, or from a domain template
Create New Data Class
To create a new DataClass, click New Data Class
. If any templates are defined, this link will open a menu from which you'll select Design Manually
to follow these steps.
Data Class Properties
The first panel defines Data Class Properties
- Name: Required. This is the name of the class itself. Note that this name cannot be changed after data class creation.
- Description: Optional short description.
- Naming Pattern: Unless your data will already include unique identifiers for each member of this class, use the Naming Pattern to specify how to generate unique names. Names can be generated with a combination of fixed strings, auto-incrementing integers, and column values. If you don't provide a naming pattern, your data must contain a Name column. Learn more about naming in this topic.
- Category: Select a category, if applicable.
- Sample Type: (Optional) The default sample type where new samples will be created for this data class.
Before saving, continue to add any Fields
To add fields, you have several options. When there are no fields defined yet you can:
- Import or Infer Fields from File:
- Infer them from a example data-bearing spreadsheet by dropping it into the upload area or clicking to browse and select it.
- Supported file types are listed below the panel.
- If your spreadsheet contains data for 'reserved fields', they will not be shown in the inferral, but are always created for you by the system. A banner will indicate that these fields are not shown.
- Import field definitions from a specially formatted JSON file.
- Click Manually Define Fields, then use the Field Editor to add fields and set their properties. For details, see Field Editor.
Once you have defined the fields, click Save
to create the new data class. You will see it listed.
Create Data Class from Template
If there is a data class template
available, you can use it to create a new data class.
Select New Data Class > Create From Template
Select the template to use and click Create
You will use the same data class designer described above
to define the properties and fields for your new data class. The information from the template you selected will be prepopulated for you, and you can make adjustments as needed. Click Save
to create the data class.
Populate a Data Class
To add data to a Data Class, you can insert individual rows or more commonly bulk import data from a spreadsheet.
- In the Data Classes web part, click the name of the class you want to add data to.
- In the grid below the properties, select (Insert data) and whichever import method you prefer:
- Insert new row: Use a data entry panel with entry boxes for every field to add a single row.
- Import bulk data: Similar to importing bulk sample type data, you can:
- Click Download Template to obtain an empty spreadsheet matching the data class structure.
- Use the Copy/paste text box to add tab- or comma-separated data directly (include the column headers).
- Use the Upload file (.xlsx, .xls, .csv, .txt) panel to import a file directly.
- Both import options allow you to Import Lookups by Alternate Key if you have lookups that should be resolved using a column other than the primary key.
Merge Data During Import
Once your data class has been populated and is in use, new data added must be correctly merged with existing data.
- As you insert/import new data, unique naming will only insert data for names that are not already taken. If you import new data for the same
- When you update existing data, only the columns you update (for the rows you specify) will be changed. Existing data in other columns remains unchanged. This allows you to make a known change (update a review status for example) without needing to know the contents of all other columns.