Skip to content

Commit

Permalink
Merge branch 'release23.11-SNAPSHOT' into 23.11_fb_EnvironmentalInpur…
Browse files Browse the repository at this point in the history
…tForm

# Conflicts:
#	onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
  • Loading branch information
Ohsudev committed Mar 20, 2024
2 parents 06c3c38 + 8daba62 commit fccf455
Show file tree
Hide file tree
Showing 47 changed files with 1,423 additions and 384 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/branch_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Create branches and PRs
uses: LabKey/gitHubActions/branch-release@develop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Merge PR
uses: LabKey/gitHubActions/merge-release@develop
Expand Down
2 changes: 2 additions & 0 deletions GeneticsCore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {

dependencies {
BuildUtils.addLabKeyDependency(project: project, config: "implementation", depProjectPath: ":server:modules:LabDevKitModules:LDK", depProjectConfig: "apiJarFile")
BuildUtils.addLabKeyDependency(project: project, config: "implementation", depProjectPath: ":server:modules:ehrModules:ehr", depProjectConfig: "apiJarFile")

BuildUtils.addLabKeyDependency(project: project, config: "modules", depProjectPath: ":server:modules:ehrModules:ehr", depProjectConfig: 'published', depExtension: 'module')
BuildUtils.addLabKeyDependency(project: project, config: "modules", depProjectPath: ":server:modules:LabDevKitModules:LDK", depProjectConfig: 'published', depExtension: 'module')
BuildUtils.addLabKeyDependency(project: project, config: "implementation", depProjectPath: ":server:modules:dataintegration", depProjectConfig: "apiJarFile")
Expand Down
14 changes: 14 additions & 0 deletions GeneticsCore/resources/etls/KinshipDataImport.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<etl xmlns="http://labkey.org/etl/xml">
<name>KinshipDataImport</name>
<description>Import PRIMe-seq Kinship Data</description>
<transforms>
<transform id="kinship" type="TaskRefTransformStep">
<taskref ref="org.labkey.GeneticsCore.etl.ImportGeneticsCalculationsStep">
<settings>

</settings>
</taskref>
</transform>
</transforms>
</etl>
7 changes: 7 additions & 0 deletions GeneticsCore/resources/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
</editPermissions>
<description>This is the containerPath to the folder holding the primary data for Parentage. Use of slashes is very important - it should be in the format '/myProject/folder'</description>
</propertyDescriptor>
<propertyDescriptor name="KinshipDataPath">
<canSetPerContainer>true</canSetPerContainer>
<editPermissions>
<permission>ADMIN</permission>
</editPermissions>
<description>This is the filepath of a folder where externally kinship/inbreeding TSVs calculated externally will be deposited. It is used by the KinshipData ETL to initiate import.</description>
</propertyDescriptor>
</properties>
<clientDependencies>
<dependency path="clientapi/ext4.lib.xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.labkey.GeneticsCore.mhc.MhcTaskRef;
import org.labkey.api.action.ApiResponse;
import org.labkey.api.action.ApiSimpleResponse;
import org.labkey.api.action.ConfirmAction;
import org.labkey.api.action.MutatingApiAction;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.di.DataIntegrationService;
import org.labkey.api.security.RequiresPermission;
import org.labkey.api.security.permissions.AdminPermission;
import org.labkey.api.security.permissions.UpdatePermission;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.HtmlView;
Expand Down Expand Up @@ -62,4 +67,26 @@ public URLHelper getSuccessURL(Object o)
return getContainer().getStartURL(getUser());
}
}


@RequiresPermission(UpdatePermission.class)
public static class ImportGeneticsDataAction extends MutatingApiAction<Object>
{
@Override
public ApiResponse execute(Object form, BindException errors)
{
try
{
DataIntegrationService.get().runTransformNow(getContainer(), getUser(), "{GeneticsCore}/KinshipDataImport");

return new ApiSimpleResponse("success", true);
}
catch (Exception e)
{
_log.error("Unable to initiate genetics data import", e);
errors.reject(ERROR_MSG, "Unable to initiate genetics data import");
return null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ private void deleteForRun(User user, ExpRun run)

TableInfo data = ap.createProtocolSchema(user, run.getContainer(), run.getProtocol(), null).createDataTable(null);

if (data.getColumn("RowId") == null || data.getColumn("SubjectId") == null || data.getColumn("Run") == null)
{
return;
}
TableSelector ts = new TableSelector(data, PageFlowUtil.set("RowId", "SubjectId"), new SimpleFilter(FieldKey.fromString("Run"), run.getRowId()), null);
List<Map<String, Object>> resultRows = new ArrayList<>();
ts.forEachResults(rs -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package org.labkey.GeneticsCore.etl;

import org.apache.commons.lang3.StringUtils;
import org.apache.xmlbeans.XmlException;
import org.jetbrains.annotations.NotNull;
import org.labkey.GeneticsCore.GeneticsCoreModule;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.di.TaskRefTask;
import org.labkey.api.ehr.EHRService;
import org.labkey.api.module.Module;
import org.labkey.api.module.ModuleLoader;
import org.labkey.api.module.ModuleProperty;
import org.labkey.api.pipeline.PipelineJob;
import org.labkey.api.pipeline.PipelineJobException;
import org.labkey.api.pipeline.RecordedActionSet;
import org.labkey.api.security.permissions.UpdatePermission;
import org.labkey.api.view.UnauthorizedException;
import org.labkey.api.writer.ContainerUser;

import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class ImportGeneticsCalculationsStep implements TaskRefTask
{
protected ContainerUser _containerUser;

@Override
public RecordedActionSet run(@NotNull PipelineJob job) throws PipelineJobException
{
Module ehr = ModuleLoader.getInstance().getModule("ehr");
Module geneticsCore = ModuleLoader.getInstance().getModule(GeneticsCoreModule.class);

ModuleProperty mp = ehr.getModuleProperties().get("EHRStudyContainer");
String ehrContainerPath = StringUtils.trimToNull(mp.getEffectiveValue(_containerUser.getContainer()));
if (ehrContainerPath == null)
{
throw new PipelineJobException("EHRStudyContainer has not been set");
}

Container ehrContainer = ContainerManager.getForPath(ehrContainerPath);
if (ehrContainer == null)
{
throw new PipelineJobException("Invalid container: " + ehrContainerPath);
}

if (!_containerUser.getContainer().equals(ehrContainer))
{
throw new PipelineJobException("This ETL can only be run from the EHRStudyContainer");
}

// Downstream import events will get additional permissions checks
if (!ehrContainer.hasPermission(_containerUser.getUser(), UpdatePermission.class))
{
throw new UnauthorizedException();
}

ModuleProperty mp2 = geneticsCore.getModuleProperties().get("KinshipDataPath");
String pipeDirPath = StringUtils.trimToNull(mp2.getEffectiveValue(ehrContainer));
if (pipeDirPath == null)
{
throw new PipelineJobException("Must provide the filepath to import data using the KinshipDataPath module property");
}

File pipeDir = new File(pipeDirPath);
if (!pipeDir.exists())
{
throw new PipelineJobException("Path does not exist: " + pipeDir.getPath());
}

File kinship = new File(pipeDir, "kinship.txt");
if (!kinship.exists())
{
throw new PipelineJobException("File does not exist: " + kinship.getPath());
}

File inbreeding = new File(pipeDir, "inbreeding.txt");
if (!inbreeding.exists())
{
throw new PipelineJobException("File does not exist: " + inbreeding.getPath());
}

EHRService.get().standaloneProcessKinshipAndInbreeding(ehrContainer, _containerUser.getUser(), pipeDir, job.getLogger());

return new RecordedActionSet();
}

@Override
public List<String> getRequiredSettings()
{
return Collections.emptyList();
}

@Override
public void setSettings(Map<String, String> settings) throws XmlException
{

}

@Override
public void setContainerUser(ContainerUser containerUser)
{
_containerUser = containerUser;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="SciShield_Data" tableDbType="TABLE">
<tableTitle>SciShield Data</tableTitle>
<columns>
</columns>
</table>
</tables>
</metadata>
</query>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<customView xmlns="http://labkey.org/data/xml/queryCustomView">
<columns>
<column name="employeeid"/>

<column name="requirementname"/>
<column name="date"/>
<column name="processed"/>
<column name="comment"/>

</columns>
<sorts>
<sort column="employeeid" descending="false"/>
<sort column="requirementname" descending="false"/>
<sort column="date" descending="true"/>
<sort column="created" descending="true"/>
</sorts>
<filters>
<filter column="processed" operator="isblank"/>
</filters>
</customView>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="SciShield_Reference_Data" tableDbType="NOT_IN_DB">
<tableTitle>SciShield Reference Data</tableTitle>

<columns>
<column columnName ="rowId">
<isHidden>true</isHidden>
</column>
<column columnName="value">
<columnTitle>Value</columnTitle>
</column>
<column columnName="endDate">
<columnTitle>End Date</columnTitle>
</column>

<column columnName="columnName">
<columnTitle>Column Name</columnTitle>
</column>

<column columnName="Label">
<columnTitle>Label</columnTitle>
</column>

<column columnName="sort_order">
<columnTitle>Sort Order</columnTitle>
</column>
</columns>
</table>
</tables>
</metadata>
</query>

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

CREATE SCHEMA onprc_ehr_compliancedb;
GO

CREATE TABLE onprc_ehr_compliancedb.SciShield_Data
(
RowId INT IDENTITY(1,1) NOT NULL,
employeeId nvarchar(255) not null,
requirementname nvarchar(255) null,
Date datetime null,
Container ENTITYID NOT NULL,
comment nvarchar(2000) null,
CreatedBy USERID,
Created datetime,
ModifiedBy USERID,
Modified datetime,
processed int NULL

CONSTRAINT PK_ScieShield_Data PRIMARY KEY (RowId),
CONSTRAINT FK_ONPRC_EHR_COMPLIANCE_SCISHIELD_DATA_CONTAINER FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
);
CREATE INDEX IX_ONPRC_EHR_COMPLIANCEDB_SCISHIELD_DATA_CONTAINER ON onprc_ehr_compliancedb.SciShield_Data (Container);

CREATE TABLE onprc_ehr_compliancedb.SciShield_Reference_Data
(
rowId int identity(1,1),
label nvarchar(250) NULL,
value nvarchar(255) NOT NULL ,
columnName nvarchar(255) NOT NULL,
sort_order integer null,
endDate datetime NULL,
Container ENTITYID NOT NULL,
CreatedBy USERID,
Created datetime,
ModifiedBy USERID,
Modified datetime,

CONSTRAINT pk_SciShield_reference PRIMARY KEY (value),
CONSTRAINT FK_ONPRC_EHR_COMPLIANCE_REFERENCE_DATA_CONTAINER FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
);
CREATE INDEX IX_ONPRC_EHR_COMPLIANCEDB_SCISHIELD_REFERENCE_DATA_CONTAINER ON onprc_ehr_compliancedb.SciShield_Reference_Data (Container);

GO
Loading

0 comments on commit fccf455

Please sign in to comment.