From 7e1ce39e77a8d6c1789ea7f2d4b743a5e76451eb Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Tue, 16 Dec 2025 09:25:56 -0800 Subject: [PATCH 1/2] Remove unused User parameters from service methods --- .../labkey/api/audit/AuditTypeProvider.java | 6 +- .../org/labkey/api/data/NameGenerator.java | 8 +- .../labkey/api/data/NameGeneratorState.java | 2 +- .../api/data/generator/DataGenerator.java | 4 +- .../labkey/api/exp/api/ExperimentService.java | 41 ++---- .../api/exp/query/DataClassUserSchema.java | 6 +- .../labkey/experiment/ExpDataIterators.java | 4 +- .../labkey/experiment/ExperimentModule.java | 4 +- .../src/org/labkey/experiment/XarReader.java | 2 +- .../experiment/api/ClosureQueryHelper.java | 14 +- .../labkey/experiment/api/ExpDataImpl.java | 6 +- .../experiment/api/ExperimentServiceImpl.java | 126 +++++++----------- .../controllers/exp/ExperimentController.java | 14 +- .../experiment/lineage/LineageForeignKey.java | 2 +- .../samples/DataClassFolderWriter.java | 2 +- 15 files changed, 100 insertions(+), 141 deletions(-) diff --git a/api/src/org/labkey/api/audit/AuditTypeProvider.java b/api/src/org/labkey/api/audit/AuditTypeProvider.java index 2872cb78b05..925210aed74 100644 --- a/api/src/org/labkey/api/audit/AuditTypeProvider.java +++ b/api/src/org/labkey/api/audit/AuditTypeProvider.java @@ -28,16 +28,14 @@ public interface AuditTypeProvider { /** - * The audit event name associated with this audit provider. Must be - * unique within the system. + * The audit event name associated with this audit provider. Must be unique within the system. */ String getEventName(); String getLabel(); String getDescription(); /** - * Perform any initialization of the provider at registration time such as - * domain creation. + * Perform any initialization of the provider at registration time such as domain creation. * @param user User used when saving the backing Domain. */ void initializeProvider(User user); diff --git a/api/src/org/labkey/api/data/NameGenerator.java b/api/src/org/labkey/api/data/NameGenerator.java index 5dc8b680f72..5cc9af52360 100644 --- a/api/src/org/labkey/api/data/NameGenerator.java +++ b/api/src/org/labkey/api/data/NameGenerator.java @@ -859,7 +859,7 @@ public static boolean isParentInputWithDataType(String[] parts, @Nullable String return false; } - return ExperimentService.get().getDataClass(container, user, dataType) != null; + return ExperimentService.get().getDataClass(container, dataType, true) != null; } private Object getParentLookupTokenPreview(String currentDataType, FieldKey fkTok, String inputPrefix, @Nullable String inputDataType, @Nullable NameExpressionAncestorPartOption ancestorPartOption, String lookupField, User user, Map dataClassNames, Map sampleTypeNames) @@ -924,12 +924,12 @@ else if (ancestorPaths != null && !ancestorPaths.isEmpty()) { if (!StringUtils.isEmpty(inputDataType)) { - ExpDataClass dataClass = ExperimentService.get().getDataClass(_container, user, inputDataType); + ExpDataClass dataClass = ExperimentService.get().getDataClass(_container, inputDataType, true); if (dataClass != null) dataTypes.add(dataClass); } else - dataTypes.addAll(ExperimentService.get().getDataClasses(_container, user, true)); + dataTypes.addAll(ExperimentService.get().getDataClasses(_container, true)); } boolean isCurrentDataType = inputDataType != null && inputDataType.equals(currentDataType); @@ -1114,7 +1114,7 @@ private void initialize(@Nullable Map importAliasesMap) if (_container != null) { - for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(_container, user, true)) + for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(_container, true)) { dataClassLSIDs.put(dataClass.getName(), dataClass.getLSID()); dataClassNames.put(dataClass.getLSID(), dataClass.getName()); diff --git a/api/src/org/labkey/api/data/NameGeneratorState.java b/api/src/org/labkey/api/data/NameGeneratorState.java index 756266e2ef8..acccdcb6c31 100644 --- a/api/src/org/labkey/api/data/NameGeneratorState.java +++ b/api/src/org/labkey/api/data/NameGeneratorState.java @@ -540,7 +540,7 @@ else if (expParentLookupFields.containsKey(FieldKey.fromParts(ExpData.DATA_INPUT Map dataClasses = getDataClasses(); ExpObject parentObjectType = isMaterialParent ? sampleTypes.computeIfAbsent(parentTypeName, (name) -> SampleTypeService.get().getSampleType(_container, _user, name)) - : dataClasses.computeIfAbsent(parentTypeName, (name) -> ExperimentService.get().getDataClass(_container, _user, name)); + : dataClasses.computeIfAbsent(parentTypeName, (name) -> ExperimentService.get().getDataClass(_container, name, true)); if (parentObjectType == null) throw new RuntimeValidationException("Invalid parent type: " + parentTypeName); diff --git a/api/src/org/labkey/api/data/generator/DataGenerator.java b/api/src/org/labkey/api/data/generator/DataGenerator.java index c36e53b6460..d7a81c9cfd9 100644 --- a/api/src/org/labkey/api/data/generator/DataGenerator.java +++ b/api/src/org/labkey/api/data/generator/DataGenerator.java @@ -349,7 +349,7 @@ public void generateSamplesForAllTypes() throws SQLException, BatchValidationExc List dataClassParents = new ArrayList<>(config.getDataClassParents()); // Default to using all types in the container if (dataClassParents.isEmpty()) - dataClassParents.addAll(ExperimentService.get().getDataClasses(getContainer(), getUser(), false).stream().map(ExpDataClass::getName).toList()); + dataClassParents.addAll(ExperimentService.get().getDataClasses(getContainer(), false).stream().map(ExpDataClass::getName).toList()); for (ExpSampleType sampleType : getSampleTypes(_config.getSampleTypeNames())) { _log.info(String.format("Generating %d samples for sample type '%s'.", numSamples, sampleType.getName())); @@ -702,7 +702,7 @@ public int generateDerivedSamples(ExpSampleType sampleType, Collection p { parentInput = "DataInputs"; parentQueryNames.forEach(parentQueryName -> { - ExpObject parentObject = ExperimentService.get().getDataClass(_container, _user, parentQueryName); + ExpObject parentObject = ExperimentService.get().getDataClass(_container, parentQueryName, true); if (parentObject != null) parentObjects.add(parentObject); }); diff --git a/api/src/org/labkey/api/exp/api/ExperimentService.java b/api/src/org/labkey/api/exp/api/ExperimentService.java index 3022b41482d..0fe725d0366 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentService.java +++ b/api/src/org/labkey/api/exp/api/ExperimentService.java @@ -251,7 +251,7 @@ ExpRun createRunForProvenanceRecording(Container container, User user, ExpData getEffectiveData(@NotNull ExpDataClass dataClass, String name, @NotNull Date effectiveDate, @NotNull Container container, @Nullable ContainerFilter cf); /** - * Create a data object. The object will be unsaved, and will have a name which is a GUID. + * Create a data object. The object will be unsaved, and will have a name which is a GUID. */ ExpData createData(Container container, @NotNull DataType type); @@ -293,66 +293,52 @@ ValidationException updateDataClass( void validateDataClassName(@NotNull Container c, @NotNull User u, String name, boolean skipExisting); /** - * Get all DataClass definitions in the container. If includeOtherContainers is true, - * a user must be provided to check for read permission of the containers in scope. + * Get all DataClass definitions in the container */ - // TODO: Remove user parameter (not used) - List getDataClasses(@NotNull Container container, @Nullable User user, boolean includeOtherContainers); + List getDataClasses(@NotNull Container container, boolean includeOtherContainers); /** - * Get a DataClass by name within the definition container. + * Get a DataClass by name within the definition container */ ExpDataClass getDataClass(@NotNull Container definitionContainer, @NotNull String dataClassName); /** - * Get a DataClass by name within scope -- current, project, and shared. - * Requires a user to check for container read permission. + * Get a DataClass by name within scope -- current plus (if includeOtherContainers is true), project and shared */ - // TODO: Remove user parameter (not used) - ExpDataClass getDataClass(@NotNull Container scope, @NotNull User user, @NotNull String dataClassName); + ExpDataClass getDataClass(@NotNull Container scope, @NotNull String dataClassName, boolean includeProjectAndShared); /** - * Get a DataClass by rowId within the definition container. + * Get a DataClass by rowId within the definition container */ ExpDataClass getDataClass(@NotNull Container definitionContainer, long rowId); /** - * Get a DataClass by rowId within scope -- current, project, and shared. - * Requires a user to check for container read permission. + * Get a DataClass by rowId within scope -- current plus (if includeOtherContainers is true), project and shared */ - // TODO: Remove user parameter (not used) - ExpDataClass getDataClass(@NotNull Container scope, @NotNull User user, long rowId); + ExpDataClass getDataClass(@NotNull Container scope, long rowId, boolean includeProjectAndShared); /** * Get a DataClass by LSID. - * NOTE: Prefer using one of the getDataClass methods that accept a Container and User for permission checking. + * NOTE: Prefer using one of the getDataClass methods that accept a Container */ @Nullable ExpDataClass getDataClass(@NotNull String lsid); /** * Get a DataClass by RowId - * NOTE: Prefer using one of the getDataClass methods that accept a Container and User for permission checking. + * NOTE: Prefer using one of the getDataClass methods that accept a Container */ ExpDataClass getDataClass(long rowId); /** * Get a DataClass with name at a specific time. */ - // TODO: Remove user parameter (not used) @Nullable ExpDataClass getEffectiveDataClass( @NotNull Container definitionContainer, - @NotNull User user, @NotNull String dataClassName, @NotNull Date effectiveDate, @Nullable ContainerFilter cf ); - /** - * Get a ExpProtocol with name at a specific time. - */ - // TODO: Delete? - ExpProtocol getEffectiveProtocol(Container container, User user, String schemaName, Date effectiveDate, ContainerFilter dataTypeCF); - /** * Get materials by rowId in this, project, or shared container and within the provided sample type. * @@ -622,9 +608,10 @@ static void validateParentAlias(Map aliasMap, Set reserv * ignoring any sample children derived from ExpData children. */ Set getRelatedChildSamples(Container c, User user, ExpData start); + /** - * Get the lineage for the seed Identifiable object. Typically, the seed object is a ExpMaterial, - * a ExpData (in a DataClass), or an ExpRun. + * Get the lineage for the seed Identifiable object. Typically, the seed object is an ExpMaterial, + * an ExpData (in a DataClass), or an ExpRun. */ @NotNull ExpLineage getLineage(Container c, User user, @NotNull Identifiable start, @NotNull ExpLineageOptions options); diff --git a/api/src/org/labkey/api/exp/query/DataClassUserSchema.java b/api/src/org/labkey/api/exp/query/DataClassUserSchema.java index 6fa8d596029..1dabfa3e55a 100644 --- a/api/src/org/labkey/api/exp/query/DataClassUserSchema.java +++ b/api/src/org/labkey/api/exp/query/DataClassUserSchema.java @@ -48,11 +48,11 @@ public class DataClassUserSchema extends AbstractExpSchema private Map _map; - static private Map getDataClassMap(Container container, User user) + static private Map getDataClassMap(Container container) { Map map = new CaseInsensitiveTreeMap<>(); // User can be null if we're running in a background thread, such as doing a study export. - for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(container, user, true)) + for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(container, true)) { map.put(dataClass.getName(), dataClass); } @@ -73,7 +73,7 @@ private DataClassUserSchema(Container container, User user, Map getDataClasses() { if (_map == null) - _map = getDataClassMap(getContainer(), getUser()); + _map = getDataClassMap(getContainer()); return _map; } diff --git a/experiment/src/org/labkey/experiment/ExpDataIterators.java b/experiment/src/org/labkey/experiment/ExpDataIterators.java index 91329240e4d..c43a7718aad 100644 --- a/experiment/src/org/labkey/experiment/ExpDataIterators.java +++ b/experiment/src/org/labkey/experiment/ExpDataIterators.java @@ -1976,7 +1976,7 @@ else if (DATA_INPUT_PARENT.equalsIgnoreCase(aliasPrefix)) if (skipExistingAliquotParents) continue; - ExpDataClass dataClass = dataClasses.computeIfAbsent(namePart, (name) -> ExperimentService.get().getDataClass(c, user, name)); + ExpDataClass dataClass = dataClasses.computeIfAbsent(namePart, (name) -> ExperimentService.get().getDataClass(c, name, true)); if (dataClass == null) throw new ValidationException(String.format("Invalid import alias: parent DataClass [%1$s] does not exist or may have been deleted", namePart)); @@ -2008,7 +2008,7 @@ else if (DATA_INPUT_PARENT.equalsIgnoreCase(aliasPrefix)) } else if (ExpData.DATA_OUTPUT_CHILD.equalsIgnoreCase(aliasPrefix)) { - ExpDataClass dataClass = dataClasses.computeIfAbsent(namePart, (name) -> ExperimentService.get().getDataClass(c, user, name)); + ExpDataClass dataClass = dataClasses.computeIfAbsent(namePart, (name) -> ExperimentService.get().getDataClass(c, name, true)); if (dataClass == null) throw new ValidationException(String.format("Invalid import alias: child DataClass [%1$s] does not exist or may have been deleted", namePart)); diff --git a/experiment/src/org/labkey/experiment/ExperimentModule.java b/experiment/src/org/labkey/experiment/ExperimentModule.java index dd9c3c52d8e..910158d21dc 100644 --- a/experiment/src/org/labkey/experiment/ExperimentModule.java +++ b/experiment/src/org/labkey/experiment/ExperimentModule.java @@ -966,7 +966,7 @@ public Collection getSummary(Container c) list.add(runCount + " runs of type " + runType.getDescription()); } - int dataClassCount = ExperimentService.get().getDataClasses(c, null, false).size(); + int dataClassCount = ExperimentService.get().getDataClasses(c, false).size(); if (dataClassCount > 0) list.add(dataClassCount + " Data Class" + (dataClassCount > 1 ? "es" : "")); @@ -993,7 +993,7 @@ public Collection getSummary(Container c) summaries.add(new Summary(runGroupCount, "Assay run")); // Number of Data Classes - List dataClasses = ExperimentService.get().getDataClasses(c, user, false); + List dataClasses = ExperimentService.get().getDataClasses(c, false); int dataClassCount = dataClasses.size(); if (dataClassCount > 0) summaries.add(new Summary(dataClassCount, "Data Class")); diff --git a/experiment/src/org/labkey/experiment/XarReader.java b/experiment/src/org/labkey/experiment/XarReader.java index 46a7480f427..83fa4b09162 100644 --- a/experiment/src/org/labkey/experiment/XarReader.java +++ b/experiment/src/org/labkey/experiment/XarReader.java @@ -2409,7 +2409,7 @@ private ExpDataProtocolInput loadDataProtocolInput(DataProtocolInputType pi, boo ExpDataClass dc = null; if (dataClassName != null) { - dc = ExperimentService.get().getDataClass(getContainer(), getUser(), dataClassName); + dc = ExperimentService.get().getDataClass(getContainer(), dataClassName, true); if (dc == null) logErrorAndThrow("DataClass '" + dataClassName + "' not found for protocol input '" + name + "'"); } diff --git a/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java b/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java index 909ff74ed46..f6a5778250c 100644 --- a/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java +++ b/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java @@ -403,7 +403,7 @@ public static void populateDataAncestors(Logger logger) container -> { int totalRows = 0; logger.info("Adding rows to exp.dataAncestors from data classes in container " + container.getPath()); - for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(container, null, false)) + for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(container, false)) { logger.debug(" Adding rows to exp.dataAncestors from data class " + dataClass.getName()); SQLFragment from = new SQLFragment(" FROM exp.data WHERE classId = ?").add(dataClass.getRowId()); @@ -674,7 +674,7 @@ boolean isInstance(ExpObject expObject) @Override Collection getInstances(Container c, User u) { - return ExperimentServiceImpl.get().getDataClasses(c, u,true) + return ExperimentServiceImpl.get().getDataClasses(c, true) .stream() .filter(this::isInstance) .collect(Collectors.toList()); @@ -682,7 +682,7 @@ Collection getInstances(Container c, User u) @Override ExpObject getInstance(Container c, User u, String name) { - return ExperimentServiceImpl.get().getDataClass(c, u, name); + return ExperimentServiceImpl.get().getDataClass(c, name, true); } @Override boolean isInstance(ExpObject expObject) @@ -696,7 +696,7 @@ boolean isInstance(ExpObject expObject) Collection getInstances(Container c, User u) { return ExperimentServiceImpl.get() - .getDataClasses(c, u,true) + .getDataClasses(c, true) .stream() .filter(this::isInstance) .collect(Collectors.toList()); @@ -704,7 +704,7 @@ Collection getInstances(Container c, User u) @Override ExpObject getInstance(Container c, User u, String name) { - return ExperimentServiceImpl.get().getDataClass(c, u, name); + return ExperimentServiceImpl.get().getDataClass(c, name, true); } @Override boolean isInstance(ExpObject expObject) @@ -740,7 +740,7 @@ boolean isInstance(ExpObject expObject) Collection getInstances(Container c, User u) { return ExperimentServiceImpl.get() - .getDataClasses(c, u,true) + .getDataClasses(c, true) .stream() .filter(this::isInstance) .collect(Collectors.toList()); @@ -748,7 +748,7 @@ Collection getInstances(Container c, User u) @Override ExpObject getInstance(Container c, User u, String name) { - return ExperimentServiceImpl.get().getDataClass(c, u, name); + return ExperimentServiceImpl.get().getDataClass(c, name, true); } @Override boolean isInstance(ExpObject expObject) diff --git a/experiment/src/org/labkey/experiment/api/ExpDataImpl.java b/experiment/src/org/labkey/experiment/api/ExpDataImpl.java index b76ee431b56..c54d96aeec5 100644 --- a/experiment/src/org/labkey/experiment/api/ExpDataImpl.java +++ b/experiment/src/org/labkey/experiment/api/ExpDataImpl.java @@ -432,7 +432,7 @@ public ExpDataClassImpl getDataClass(@Nullable User user) if (user == null) return ExperimentServiceImpl.get().getDataClass(getContainer(), _object.getClassId()); else - return ExperimentServiceImpl.get().getDataClass(getContainer(), user, _object.getClassId()); + return ExperimentServiceImpl.get().getDataClass(getContainer(), _object.getClassId(), true); } return null; @@ -836,7 +836,7 @@ private ExpDataClass getDataClass() ViewContext ctx = HttpView.currentContext(); String dataclass = ctx.getActionURL().getParameter(PROPERTY); if (dataclass != null) - return ExperimentService.get().getDataClass(ctx.getContainer(), ctx.getUser(), dataclass); + return ExperimentService.get().getDataClass(ctx.getContainer(), dataclass, true); } return null; } @@ -905,7 +905,7 @@ public HtmlString getExtraHtml(ViewContext ctx) html.append("
"); appendParam(html, null, dataclass, "All", false, url); - for (ExpDataClass dc : ExperimentService.get().getDataClasses(ctx.getContainer(), ctx.getUser(), true)) + for (ExpDataClass dc : ExperimentService.get().getDataClasses(ctx.getContainer(), true)) { appendParam(html, dc.getName(), dataclass, dc.getName(), true, url); } diff --git a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java index ac942ee485e..ae7f3ea06e8 100644 --- a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java @@ -1713,7 +1713,7 @@ public ExpObject findObjectFromLSID(String lsid) } @Override - public List getDataClasses(@NotNull Container container, User user, boolean includeProjectAndShared) + public List getDataClasses(@NotNull Container container, boolean includeProjectAndShared) { SortedSet classes = new TreeSet<>(); List containerIds = createContainerList(container, includeProjectAndShared); @@ -1730,7 +1730,7 @@ public List getDataClasses(@NotNull Container container, User @Override public ExpDataClassImpl getDataClass(@NotNull Container c, @NotNull String dataClassName) { - return getDataClass(c, false, dataClassName); + return getDataClass(c, dataClassName, false); } public ExpDataClassImpl getDataClassByObjectId(Long objectId) @@ -1742,25 +1742,9 @@ public ExpDataClassImpl getDataClassByObjectId(Long objectId) return getDataClass(obj.getObjectURI()); } - @Override - public ExpProtocol getEffectiveProtocol(Container definitionContainer, User user, String schemaName, Date effectiveDate, ContainerFilter cf) - { - Long legacyObjectId = getObjectIdWithLegacyName(schemaName, ExperimentServiceImpl.getNamespacePrefix(ExpProtocol.class), effectiveDate, definitionContainer, cf); - if (legacyObjectId != null) - return getExpProtocol(legacyObjectId); - - ExpProtocol protocol = getExpProtocol(definitionContainer, schemaName, cf); - - if (protocol != null && protocol.getCreated().compareTo(effectiveDate) <= 0) - return protocol; - - return null; - } - @Override public @Nullable ExpDataClass getEffectiveDataClass( @NotNull Container definitionContainer, - @NotNull User user, @NotNull String dataClassName, @NotNull Date effectiveDate, @Nullable ContainerFilter cf @@ -1771,7 +1755,7 @@ public ExpProtocol getEffectiveProtocol(Container definitionContainer, User user return getDataClassByObjectId(legacyObjectId); boolean includeProjectAndShared = cf != null && cf.getType() != ContainerFilter.Type.Current; - ExpDataClassImpl dataClass = getDataClass(definitionContainer, includeProjectAndShared, dataClassName); + ExpDataClassImpl dataClass = getDataClass(definitionContainer, dataClassName, includeProjectAndShared); if (dataClass != null && dataClass.getCreated().compareTo(effectiveDate) <= 0) return dataClass; @@ -1779,12 +1763,7 @@ public ExpProtocol getEffectiveProtocol(Container definitionContainer, User user } @Override - public ExpDataClassImpl getDataClass(@NotNull Container c, @NotNull User user, @NotNull String dataClassName) - { - return getDataClass(c, true, dataClassName); - } - - private ExpDataClassImpl getDataClass(@NotNull Container c, boolean includeProjectAndShared, String dataClassName) + public ExpDataClassImpl getDataClass(@NotNull Container c, @NotNull String dataClassName, boolean includeProjectAndShared) { return getDataClass(c, includeProjectAndShared, (dataClass -> dataClass.getName().equalsIgnoreCase(dataClassName))); } @@ -1796,12 +1775,7 @@ public ExpDataClassImpl getDataClass(@NotNull Container c, long rowId) } @Override - public ExpDataClassImpl getDataClass(@NotNull Container c, @NotNull User user, long rowId) - { - return getDataClass(c, rowId, true); - } - - private ExpDataClassImpl getDataClass(@NotNull Container c, long rowId, boolean includeProjectAndShared) + public ExpDataClassImpl getDataClass(@NotNull Container c, long rowId, boolean includeProjectAndShared) { return getDataClass(c, includeProjectAndShared, (dataClass -> dataClass.getRowId() == rowId)); } @@ -5486,7 +5460,7 @@ public void deleteAllExpObjInContainer(Container c, User user) throws Experiment List exps = getExperiments(c, false, true, true); List sampleTypes = ((SampleTypeServiceImpl) SampleTypeService.get()).getSampleTypes(c, false); - List dataClasses = getDataClasses(c, user, false); + List dataClasses = getDataClasses(c, false); sql = "SELECT RowId FROM " + getTinfoProtocol() + " WHERE Container = ?"; long[] protIds = ArrayUtils.toPrimitive(new SqlSelector(getExpSchema(), sql, c).getArray(Long.class)); @@ -7872,9 +7846,9 @@ public ExpDataClassImpl createDataClass( { domain.setDisabledSystemFields(kind.getDisabledSystemFields(disabledSystemField)); lowerReservedNames = kind.getReservedPropertyNames(domain, u) - .stream() - .map(String::toLowerCase) - .collect(toSet()); + .stream() + .map(String::toLowerCase) + .collect(toSet()); } else lowerReservedNames = emptySet(); @@ -8082,7 +8056,7 @@ public void validateDataClassName(@NotNull Container c, @NotNull User u, String if (!skipExisting) { - ExpDataClass existing = getDataClass(c, u, name); + ExpDataClass existing = getDataClass(c, name, true); if (existing != null) throw new ApiUsageException("DataClass '" + existing.getName() + "' already exists."); } @@ -9212,12 +9186,12 @@ private Map getImportTemplatesMetrics() private Pair getParentAliasMetrics(TableInfo tableInfo, String aliasField) { SQLFragment sql = new SQLFragment("SELECT ") - .append(aliasField) - .append(" FROM ") - .append(tableInfo) - .append(" WHERE ") - .append(aliasField) - .append(" IS NOT NULL"); + .append(aliasField) + .append(" FROM ") + .append(tableInfo) + .append(" WHERE ") + .append(aliasField) + .append(" IS NOT NULL"); List aliases = new SqlSelector(ExperimentService.get().getSchema(), sql).getArrayList(String.class); Long requiredSampleParentCount = 0L; @@ -9370,7 +9344,7 @@ private Map getNameExpressionMetrics() { } } - for (ExpDataClassImpl dataClass : getDataClasses(container, user, true)) + for (ExpDataClassImpl dataClass : getDataClasses(container, true)) { try { @@ -9395,8 +9369,8 @@ public boolean hasMissingRequiredParent(String parentCpasType, String childCpasT SQLFragment totalSql = new SQLFragment("SELECT COUNT(cur.rowId) FROM "); totalSql.append(dataTableInfo, "cur") - .append("\nWHERE cpastype = ? ") - .add(childCpasType); + .append("\nWHERE cpastype = ? ") + .add(childCpasType); if (isSampleChild) { @@ -9410,20 +9384,20 @@ public boolean hasMissingRequiredParent(String parentCpasType, String childCpasT SQLFragment sql = new SQLFragment("SELECT COUNT(DISTINCT cur.rowId) FROM "); sql.append(dataTableInfo, "cur") - .append(" LEFT OUTER JOIN ") - .append(protocolAppTableInfo, "pa") - .append(" ON cur.sourceapplicationid = pa.rowId\n") - .append("JOIN ") - .append(parentInputTableInfo, "ip") - .append(" ON pa.rowId = ip.targetapplicationid\n") - .append("JOIN ") - .append(parentDataTableInfo, "p") - .append(" ON p.rowId = ip.") - .append(inputFieldName) - .append("\nWHERE cur.cpastype = ? ") - .add(childCpasType) - .append(" AND p.cpastype = ? ") - .add(parentCpasType); + .append(" LEFT OUTER JOIN ") + .append(protocolAppTableInfo, "pa") + .append(" ON cur.sourceapplicationid = pa.rowId\n") + .append("JOIN ") + .append(parentInputTableInfo, "ip") + .append(" ON pa.rowId = ip.targetapplicationid\n") + .append("JOIN ") + .append(parentDataTableInfo, "p") + .append(" ON p.rowId = ip.") + .append(inputFieldName) + .append("\nWHERE cur.cpastype = ? ") + .add(childCpasType) + .append(" AND p.cpastype = ? ") + .add(parentCpasType); if (isSampleChild) { sql.append(" AND cur.rowId = cur.rootmaterialrowid"); // exclude aliquots @@ -9488,20 +9462,20 @@ public static Pair getCurrentAndCrossFolderDataCount(Collectio return null; SQLFragment currentFolderCountSql = new SQLFragment() - .append(" SELECT COUNT(*) FROM ") - .append(tableInfo, "t") - .append("\nWHERE Container = ? ") - .add(container.getId()) - .append("\nAND RowId "); + .append(" SELECT COUNT(*) FROM ") + .append(tableInfo, "t") + .append("\nWHERE Container = ? ") + .add(container.getId()) + .append("\nAND RowId "); dialect.appendInClauseSql(currentFolderCountSql, rowIds); int currentFolderSelectionCount = new SqlSelector(expSchema, currentFolderCountSql).getArrayList(Integer.class).get(0); SQLFragment crossFolderCountSql = new SQLFragment() - .append(" SELECT COUNT(*) FROM ") - .append(tableInfo, "t") - .append("\nWHERE Container <> ? ") - .add(container.getId()) - .append("\nAND RowId "); + .append(" SELECT COUNT(*) FROM ") + .append(tableInfo, "t") + .append("\nWHERE Container <> ? ") + .add(container.getId()) + .append("\nAND RowId "); dialect.appendInClauseSql(crossFolderCountSql, rowIds); int crossFolderSelectionCount = new SqlSelector(expSchema, crossFolderCountSql).getArrayList(Integer.class).get(0); @@ -9516,7 +9490,7 @@ public int updateExpObjectContainers(TableInfo tableInfo, List rowIds, Con TableInfo objectTable = OntologyManager.getTinfoObject(); SQLFragment objectUpdate = new SQLFragment("UPDATE ").append(objectTable).append(" SET container = ").appendValue(targetContainer.getEntityId()) - .append(" WHERE objectid IN (SELECT objectid FROM ").append(tableInfo).append(" WHERE rowid "); + .append(" WHERE objectid IN (SELECT objectid FROM ").append(tableInfo).append(" WHERE rowid "); objectTable.getSchema().getSqlDialect().appendInClauseSql(objectUpdate, rowIds); objectUpdate.append(")"); return new SqlExecutor(objectTable.getSchema()).execute(objectUpdate); @@ -9870,16 +9844,16 @@ private boolean moveFile(AbstractAssayProvider.AssayFileMoveData renameData, Con if (!targetFile.getParentFile().mkdirs()) { LOG.warn(String.format("Creation of target directory '%s' to move file '%s' to, for '%s' assay run '%s' (field: '%s') failed.", - targetFile.getParent(), - sourceFile.getAbsolutePath(), - assayName, - runName, - fieldName)); + targetFile.getParent(), + sourceFile.getAbsolutePath(), + assayName, + runName, + fieldName + )); return false; } } - String changeDetail = String.format("assay '%s' run '%s'", assayName, runName); return moveFileLinkFile(sourceFile, targetFile, sourceContainer, user, changeDetail, txAuditEvent, fieldName); } diff --git a/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java b/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java index 6f56d2741e2..46ab34a280a 100644 --- a/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java +++ b/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java @@ -1320,13 +1320,13 @@ public ExpDataClassImpl getDataClass(@Nullable Container container) if (getName() != null) { - dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), getUser(), getName()); + dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), getName(), true); if (dataClass == null) throw new NotFoundException("No data class found for name '" + getName() + "'."); } else if (getRowId() > 0) { - dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), getUser(), getRowId()); + dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), getRowId(), true); } if (dataClass == null) @@ -1517,7 +1517,7 @@ private List getDataClasses(DeleteForm deleteForm) List dataClasses = new ArrayList<>(); for (long rowId : deleteForm.getIds(false)) { - ExpDataClass dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), getUser(), rowId); + ExpDataClass dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), rowId, true); if (dataClass != null) { dataClasses.add(dataClass); @@ -1634,7 +1634,7 @@ public void validateCommand(CreateDataClassFromTemplateForm form, Errors errors) if (StringUtils.isBlank(name)) errors.reject(ERROR_MSG, "DataClass template selection is required."); - else if (ExperimentService.get().getDataClass(getContainer(), getUser(), name) != null) + else if (ExperimentService.get().getDataClass(getContainer(), name, true) != null) errors.reject(ERROR_MSG, "DataClass '" + name + "' already exists."); } @@ -4555,7 +4555,7 @@ protected Map getRenamedColumns() @Override protected Set getLineageImportAliases() throws IOException { - ExpDataClass dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), getUser(), _form.getQueryName()); + ExpDataClass dataClass = ExperimentServiceImpl.get().getDataClass(getContainer(), _form.getQueryName(), true); return new CaseInsensitiveHashSet(dataClass.getImportAliases().keySet()); } @@ -4623,7 +4623,7 @@ public void validateForm(QueryForm queryForm, Errors errors) errors.reject(ERROR_REQUIRED, "Data class name is required"); else { - ExpDataClass dataClass = ExperimentService.get().getDataClass(getContainer(), getUser(), queryForm.getQueryName()); + ExpDataClass dataClass = ExperimentService.get().getDataClass(getContainer(), queryForm.getQueryName(), true); if (dataClass == null) { errors.reject(ERROR_GENERIC, "Data class '" + queryForm.getQueryName() + " not found."); @@ -7400,7 +7400,7 @@ public Object execute(Object o, BindException errors) throws Exception { List> notInIndex = new ArrayList<>(100); - List list = ExperimentService.get().getDataClasses(getContainer(), getUser(), false); + List list = ExperimentService.get().getDataClasses(getContainer(), false); for (ExpDataClass dc : list) { for (ExpData d : dc.getDatas()) diff --git a/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java b/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java index b3d13dce850..99b0e62f72b 100644 --- a/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java +++ b/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java @@ -110,7 +110,7 @@ enum LevelColumnType @Override List getItems(UserSchema s) { - return ExperimentService.get().getDataClasses(s.getContainer(), s.getUser(), true); + return ExperimentService.get().getDataClasses(s.getContainer(), true); } }, Material("Materials", ExpLineageOptions.LineageExpType.Material) diff --git a/experiment/src/org/labkey/experiment/samples/DataClassFolderWriter.java b/experiment/src/org/labkey/experiment/samples/DataClassFolderWriter.java index 287d40adf8a..d98a678487f 100644 --- a/experiment/src/org/labkey/experiment/samples/DataClassFolderWriter.java +++ b/experiment/src/org/labkey/experiment/samples/DataClassFolderWriter.java @@ -68,7 +68,7 @@ public void write(Container c, FolderExportContext ctx, VirtualFile vf) throws E if (exportContext.isDataClassXarCreated()) return; - for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(c, ctx.getUser(), false)) + for (ExpDataClass dataClass : ExperimentService.get().getDataClasses(c, false)) { // ignore data classes that are filtered out if (EXCLUDED_TYPES.contains(dataClass.getName())) From c7e8a95306aa8b502bdc344718bc43920f148dc2 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Tue, 16 Dec 2025 11:03:42 -0800 Subject: [PATCH 2/2] Update SampleTypeService and callers --- .../org/labkey/api/data/NameGenerator.java | 4 +- .../labkey/api/data/NameGeneratorState.java | 2 +- .../api/data/generator/DataGenerator.java | 6 +- .../exp/api/DefaultExperimentSaveHandler.java | 2 +- .../labkey/api/exp/api/ExperimentService.java | 4 +- .../labkey/api/exp/api/SampleTypeService.java | 18 ++---- .../matrix/AbstractMatrixDataHandler.java | 2 +- .../labkey/experiment/ExpDataIterators.java | 8 +-- .../experiment/ExperimentUpgradeCode.java | 8 +-- .../src/org/labkey/experiment/XarReader.java | 4 +- .../experiment/api/ClosureQueryHelper.java | 22 +++---- .../experiment/api/DataClassDomainKind.java | 2 +- .../experiment/api/ExperimentServiceImpl.java | 8 +-- .../experiment/api/SampleTypeServiceImpl.java | 60 ++++++++----------- .../controllers/exp/ExperimentController.java | 31 +++++----- .../experiment/lineage/LineageForeignKey.java | 2 +- .../experiment/pipeline/SampleReloadTask.java | 4 +- .../samples/SampleStatusFolderImporter.java | 2 +- .../samples/SampleTypeFolderWriter.java | 2 +- .../publish/PublishController.java | 2 +- .../SampleTypePublishConfirmAction.java | 2 +- .../publish/SampleTypePublishStartAction.java | 2 +- 22 files changed, 87 insertions(+), 110 deletions(-) diff --git a/api/src/org/labkey/api/data/NameGenerator.java b/api/src/org/labkey/api/data/NameGenerator.java index 5cc9af52360..f2dbaeb97ae 100644 --- a/api/src/org/labkey/api/data/NameGenerator.java +++ b/api/src/org/labkey/api/data/NameGenerator.java @@ -852,7 +852,7 @@ public static boolean isParentInputWithDataType(String[] parts, @Nullable String if (isMaterial || isInput) { - if (SampleTypeService.get().getSampleType(container, user, dataType) != null) + if (SampleTypeService.get().getSampleType(container, dataType, true) != null) return true; if (isMaterial) @@ -913,7 +913,7 @@ else if (ancestorPaths != null && !ancestorPaths.isEmpty()) { if (!StringUtils.isEmpty(inputDataType)) { - ExpSampleType sampleType = SampleTypeService.get().getSampleType(_container, user, inputDataType); + ExpSampleType sampleType = SampleTypeService.get().getSampleType(_container, inputDataType, true); if (sampleType != null) dataTypes.add(sampleType); } diff --git a/api/src/org/labkey/api/data/NameGeneratorState.java b/api/src/org/labkey/api/data/NameGeneratorState.java index acccdcb6c31..123d74df45c 100644 --- a/api/src/org/labkey/api/data/NameGeneratorState.java +++ b/api/src/org/labkey/api/data/NameGeneratorState.java @@ -539,7 +539,7 @@ else if (expParentLookupFields.containsKey(FieldKey.fromParts(ExpData.DATA_INPUT Map sampleTypes = getSampleTypes(); Map dataClasses = getDataClasses(); ExpObject parentObjectType = isMaterialParent ? - sampleTypes.computeIfAbsent(parentTypeName, (name) -> SampleTypeService.get().getSampleType(_container, _user, name)) + sampleTypes.computeIfAbsent(parentTypeName, (name) -> SampleTypeService.get().getSampleType(_container, name, true)) : dataClasses.computeIfAbsent(parentTypeName, (name) -> ExperimentService.get().getDataClass(_container, name, true)); if (parentObjectType == null) throw new RuntimeValidationException("Invalid parent type: " + parentTypeName); diff --git a/api/src/org/labkey/api/data/generator/DataGenerator.java b/api/src/org/labkey/api/data/generator/DataGenerator.java index d7a81c9cfd9..86928911e3f 100644 --- a/api/src/org/labkey/api/data/generator/DataGenerator.java +++ b/api/src/org/labkey/api/data/generator/DataGenerator.java @@ -222,7 +222,7 @@ public List getSampleTypes(List sampleTypeNames { for (String typeName : sampleTypeNames) { - ExpSampleType sampleType = service.getSampleType(getContainer(), getUser(), typeName); + ExpSampleType sampleType = service.getSampleType(getContainer(), typeName, true); if (sampleType == null) _log.warn(String.format("Unable to resolve sample type by name '%s'.", typeName)); else @@ -302,7 +302,7 @@ public void generateSampleTypes(String namePrefix, String namingPatternPrefix) t typeIndex++; sampleTypeName = namePrefix + typeIndex; } - while (service.getSampleType(_container, _user, sampleTypeName) != null); + while (service.getSampleType(_container, sampleTypeName, true) != null); String prefixWithIndex = namingPatternPrefix + typeIndex + "_"; String namingPattern = prefixWithIndex + "${genId}"; ExpSampleType sampleType = generateSampleType(sampleTypeName, namingPattern, numFields); @@ -711,7 +711,7 @@ public int generateDerivedSamples(ExpSampleType sampleType, Collection p { parentInput = "MaterialInputs"; parentQueryNames.forEach(parentQueryName -> { - ExpObject parentObject = SampleTypeService.get().getSampleType(_container, _user, parentQueryName); + ExpObject parentObject = SampleTypeService.get().getSampleType(_container, parentQueryName, true); if (parentObject != null) parentObjects.add(parentObject); }); diff --git a/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java b/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java index cbcfc13361e..6396392949d 100644 --- a/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java +++ b/api/src/org/labkey/api/exp/api/DefaultExperimentSaveHandler.java @@ -505,7 +505,7 @@ else if (materialObject.has(ExperimentJSONConverter.LSID)) else if (sampleTypeJson.has(ExperimentJSONConverter.NAME)) { String sampleTypeName = sampleTypeJson.getString(ExperimentJSONConverter.NAME); - sampleType = SampleTypeService.get().getSampleType(context.getContainer(), context.getUser(), sampleTypeName); + sampleType = SampleTypeService.get().getSampleType(context.getContainer(), sampleTypeName, true); if (sampleType == null) throw new NotFoundException("A sample type named '" + sampleTypeName + "' doesn't exist."); } diff --git a/api/src/org/labkey/api/exp/api/ExperimentService.java b/api/src/org/labkey/api/exp/api/ExperimentService.java index 0fe725d0366..c7321129920 100644 --- a/api/src/org/labkey/api/exp/api/ExperimentService.java +++ b/api/src/org/labkey/api/exp/api/ExperimentService.java @@ -303,7 +303,7 @@ ValidationException updateDataClass( ExpDataClass getDataClass(@NotNull Container definitionContainer, @NotNull String dataClassName); /** - * Get a DataClass by name within scope -- current plus (if includeOtherContainers is true), project and shared + * Get a DataClass by name within scope -- current plus, if includeOtherContainers is true, project and shared */ ExpDataClass getDataClass(@NotNull Container scope, @NotNull String dataClassName, boolean includeProjectAndShared); @@ -313,7 +313,7 @@ ValidationException updateDataClass( ExpDataClass getDataClass(@NotNull Container definitionContainer, long rowId); /** - * Get a DataClass by rowId within scope -- current plus (if includeOtherContainers is true), project and shared + * Get a DataClass by rowId within scope -- current plus, if includeOtherContainers is true, project and shared */ ExpDataClass getDataClass(@NotNull Container scope, long rowId, boolean includeProjectAndShared); diff --git a/api/src/org/labkey/api/exp/api/SampleTypeService.java b/api/src/org/labkey/api/exp/api/SampleTypeService.java index 3be72f4fd6a..60b40823040 100644 --- a/api/src/org/labkey/api/exp/api/SampleTypeService.java +++ b/api/src/org/labkey/api/exp/api/SampleTypeService.java @@ -172,23 +172,15 @@ ExpSampleType createSampleType(Container c, User u, String name, String descript */ List getSampleTypes(@NotNull Container container, boolean includeOtherContainers); - @Deprecated // Temporary just to keep code compiling during migration to new method - default List getSampleTypes(@NotNull Container container, User user, boolean includeOtherContainers) - { - return getSampleTypes(container, includeOtherContainers); - } - /** * Get a SampleType by name within the definition container. */ ExpSampleType getSampleType(@NotNull Container definitionContainer, @NotNull String sampleTypeName); /** - * Get a SampleType by name within scope -- current, project, and shared. - * Requires a user to check for container read permission. + * Get a SampleType by name within scope -- current plus, if includeOtherContainers is true, project and shared */ - // TODO: Remove user parameter (not used) - ExpSampleType getSampleType(@NotNull Container scope, @NotNull User user, @NotNull String sampleTypeName); + ExpSampleType getSampleType(@NotNull Container scope, @NotNull String sampleTypeName, boolean includeOtherContainers); /** Get the sample type with name at a specific time */ @Nullable @@ -205,11 +197,9 @@ default List getSampleTypes(@NotNull Container containe ExpSampleType getSampleType(@NotNull Container definitionContainer, long rowId); /** - * Get a SampleType by rowId within scope -- current, project, and shared. - * Requires a user to check for container read permission. + * Get a SampleType by rowId within scope -- current plus, if includeOtherContainers is true, project and shared */ - // TODO: Remove user parameter (not used) - ExpSampleType getSampleType(@NotNull Container scope, @NotNull User user, long rowId); + ExpSampleType getSampleType(@NotNull Container scope, long rowId, boolean includeOtherContainers); Lsid getSampleTypeLsid(String name, Container container); diff --git a/assay/api-src/org/labkey/api/assay/matrix/AbstractMatrixDataHandler.java b/assay/api-src/org/labkey/api/assay/matrix/AbstractMatrixDataHandler.java index 861e0dc834c..49e48917095 100644 --- a/assay/api-src/org/labkey/api/assay/matrix/AbstractMatrixDataHandler.java +++ b/assay/api-src/org/labkey/api/assay/matrix/AbstractMatrixDataHandler.java @@ -259,7 +259,7 @@ private static List createExpMaterials(Container c, User // If none exist, a new SampleType named "Samples" is created. private static @NotNull ExpSampleType ensureSampleType(Container c, User user) throws ExperimentException { - List sampleTypes = SampleTypeService.get().getSampleTypes(c, user, true); + List sampleTypes = SampleTypeService.get().getSampleTypes(c, true); if (sampleTypes.isEmpty()) { return createSampleType(c, user); diff --git a/experiment/src/org/labkey/experiment/ExpDataIterators.java b/experiment/src/org/labkey/experiment/ExpDataIterators.java index c43a7718aad..d6319804d5d 100644 --- a/experiment/src/org/labkey/experiment/ExpDataIterators.java +++ b/experiment/src/org/labkey/experiment/ExpDataIterators.java @@ -1835,7 +1835,7 @@ private static Pair resolveInputsAndOutp if (isAliquot && !updateOnly) { - ExpSampleType sampleType = sampleTypes.computeIfAbsent(dataType, (name) -> SampleTypeService.get().getSampleType(c, user, name)); + ExpSampleType sampleType = sampleTypes.computeIfAbsent(dataType, (name) -> SampleTypeService.get().getSampleType(c, name, true)); if (sampleType == null) throw new ValidationException("Invalid sample type: " + dataType); @@ -1910,7 +1910,7 @@ else if (aliasPrefix != null && aliasSuffix != null) if (skipExistingAliquotParents) continue; - ExpSampleType sampleType = sampleTypes.computeIfAbsent(namePart, (name) -> SampleTypeService.get().getSampleType(c, user, name)); + ExpSampleType sampleType = sampleTypes.computeIfAbsent(namePart, (name) -> SampleTypeService.get().getSampleType(c, name, true)); if (sampleType == null) throw new ValidationException(String.format("Invalid import alias: parent SampleType [%1$s] does not exist or may have been deleted", namePart)); @@ -1937,7 +1937,7 @@ else if (aliasPrefix != null && aliasSuffix != null) } else if (ExpMaterial.MATERIAL_OUTPUT_CHILD.equalsIgnoreCase(aliasPrefix)) { - ExpSampleType sampleType = sampleTypes.computeIfAbsent(namePart, (name) -> SampleTypeService.get().getSampleType(c, user, name)); + ExpSampleType sampleType = sampleTypes.computeIfAbsent(namePart, (name) -> SampleTypeService.get().getSampleType(c, name, true)); if (sampleType == null) throw new ValidationException(String.format("Invalid import alias: child SampleType [%1$s] does not exist or may have been deleted", namePart)); @@ -2954,7 +2954,7 @@ public boolean next() throws BatchValidationException { if (_isSamples) { - ExpSampleTypeImpl sampleType = _typeColIndex != null ? (ExpSampleTypeImpl) SampleTypeService.get().getSampleType(targetContainer, _user, typeName) : (ExpSampleTypeImpl) _dataType; + ExpSampleTypeImpl sampleType = _typeColIndex != null ? (ExpSampleTypeImpl) SampleTypeService.get().getSampleType(targetContainer, typeName, true) : (ExpSampleTypeImpl) _dataType; if (sampleType == null) _context.getErrors().addRowError(new ValidationException(_typeColName + " '" + typeName + "' not found.") ); else diff --git a/experiment/src/org/labkey/experiment/ExperimentUpgradeCode.java b/experiment/src/org/labkey/experiment/ExperimentUpgradeCode.java index 0612cc27174..476b2adde9a 100644 --- a/experiment/src/org/labkey/experiment/ExperimentUpgradeCode.java +++ b/experiment/src/org/labkey/experiment/ExperimentUpgradeCode.java @@ -323,7 +323,7 @@ private static int convertAmountsToBaseUnits(Container container, User user) .append(" SET Units = ?, StoredAmount = ?, AliquotUnit = ?, AliquotVolume = ?, AvailableAliquotVolume = ? WHERE RowId = ?") .addAll(units, amount, aliquotUnits, aliquotAmount, availableAliquotAmount, rowId), null); - for (ExpSampleType sampleType : SampleTypeService.get().getSampleTypes(container, user, false)) + for (ExpSampleType sampleType : SampleTypeService.get().getSampleTypes(container, false)) { LOG.debug("** Starting upgrade for sample type {} in folder {}", sampleType.getName(), container.getPath()); Map sampleCounts = new HashMap<>(); @@ -335,9 +335,9 @@ private static int convertAmountsToBaseUnits(Container container, User user) AtomicInteger batchCount = new AtomicInteger(); List auditEvents = new ArrayList<>(); SQLFragment sql = new SQLFragment("SELECT m.RowId, m.Name, m.StoredAmount, m.Units, m.AliquotVolume, m.AliquotUnit, m.AvailableAliquotVolume, m.container FROM ") - .append(tInfo, "m") - .append(" WHERE cpastype = ?").add(sampleType.getLSID()) - .append(" AND (m.StoredAmount IS NOT NULL OR m.Units IS NOT NULL OR m.AliquotVolume IS NOT NULL OR m.AliquotUnit IS NOT NULL OR m.AvailableAliquotVolume IS NOT NULL)"); + .append(tInfo, "m") + .append(" WHERE cpastype = ?").add(sampleType.getLSID()) + .append(" AND (m.StoredAmount IS NOT NULL OR m.Units IS NOT NULL OR m.AliquotVolume IS NOT NULL OR m.AliquotUnit IS NOT NULL OR m.AvailableAliquotVolume IS NOT NULL)"); SqlSelector selector = new SqlSelector(scope, sql); selector.mapStream().forEach(sampleMap -> { diff --git a/experiment/src/org/labkey/experiment/XarReader.java b/experiment/src/org/labkey/experiment/XarReader.java index 83fa4b09162..fe38014852d 100644 --- a/experiment/src/org/labkey/experiment/XarReader.java +++ b/experiment/src/org/labkey/experiment/XarReader.java @@ -696,7 +696,7 @@ private ExpDataClass loadDataClass(DataClassType dataClassType) throws Experimen if (dataClassType.getSampleType() != null) { - ExpSampleType sampleType = SampleTypeService.get().getSampleType(getContainer(), getUser(), dataClassType.getSampleType()); + ExpSampleType sampleType = SampleTypeService.get().getSampleType(getContainer(), dataClassType.getSampleType(), true); if (sampleType != null) dataClass.setSampleType(sampleType.getRowId()); else @@ -2444,7 +2444,7 @@ private ExpMaterialProtocolInput loadMaterialProtocolInput(MaterialProtocolInput ExpSampleType sampleType = null; if (sampleTypeName != null) { - sampleType = SampleTypeService.get().getSampleType(getContainer(), getUser(), sampleTypeName); + sampleType = SampleTypeService.get().getSampleType(getContainer(), sampleTypeName, true); if (sampleType == null) logErrorAndThrow("SampleSet '" + sampleTypeName + "' not found for protocol input '" + name + "'"); } diff --git a/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java b/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java index f6a5778250c..1626108d87c 100644 --- a/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java +++ b/experiment/src/org/labkey/experiment/api/ClosureQueryHelper.java @@ -380,7 +380,7 @@ public static void populateMaterialAncestors(Logger logger) container -> { int totalRows = 0; logger.info("Adding rows to exp.materialAncestors from sample types in container " + container.getPath()); - for (ExpSampleType sampleType : SampleTypeService.get().getSampleTypes(container, null, false)) + for (ExpSampleType sampleType : SampleTypeService.get().getSampleTypes(container, false)) { logger.debug(" Adding rows from samples in sampleType " + sampleType.getName()); SQLFragment from = new SQLFragment(" FROM exp.material WHERE materialSourceId = ?").add(sampleType.getRowId()); @@ -653,15 +653,15 @@ public enum TableType Collection getInstances(Container c, User u) { return SampleTypeServiceImpl.get() - .getSampleTypes(c, u,true) - .stream() - .filter(this::isInstance) - .collect(Collectors.toList()); + .getSampleTypes(c,true) + .stream() + .filter(this::isInstance) + .collect(Collectors.toList()); } @Override ExpObject getInstance(Container c, User u, String name) { - return SampleTypeServiceImpl.get().getSampleType(c, u, name); + return SampleTypeServiceImpl.get().getSampleType(c, name, true); } @Override boolean isInstance(ExpObject expObject) @@ -718,15 +718,15 @@ boolean isInstance(ExpObject expObject) Collection getInstances(Container c, User u) { return SampleTypeServiceImpl.get() - .getSampleTypes(c, u,true) - .stream() - .filter(this::isInstance) - .collect(Collectors.toList()); + .getSampleTypes(c,true) + .stream() + .filter(this::isInstance) + .collect(Collectors.toList()); } @Override ExpObject getInstance(Container c, User u, String name) { - return SampleTypeServiceImpl.get().getSampleType(c, u, name); + return SampleTypeServiceImpl.get().getSampleType(c, name, true); } @Override boolean isInstance(ExpObject expObject) diff --git a/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java b/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java index e67a7075bb1..8ac2504a7b8 100644 --- a/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java +++ b/experiment/src/org/labkey/experiment/api/DataClassDomainKind.java @@ -146,7 +146,7 @@ public Map processArguments(Container container, User user, Map< // if "sampleSet" is the Name string, look it up and switch the argument map to use the RowId if (arguments.containsKey("sampleSet") && !StringUtils.isNumeric(arguments.get("sampleSet").toString())) { - ExpSampleType sampleType = SampleTypeService.get().getSampleType(container, user, (String)arguments.get("sampleSet")); + ExpSampleType sampleType = SampleTypeService.get().getSampleType(container, (String)arguments.get("sampleSet"), true); if (sampleType != null) updatedArguments.put("sampleSet", sampleType.getRowId()); } diff --git a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java index ae7f3ea06e8..cd700720b8f 100644 --- a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java @@ -859,7 +859,7 @@ public List getExpMaterialsByName(@NotNull String name, @Nullab @Override public List getExpMaterialsByName(@NotNull Collection names, @NotNull String sampleTypeName, @NotNull Container container, User user) { - ExpSampleType sampleType = SampleTypeService.get().getSampleType(container, user, sampleTypeName); + ExpSampleType sampleType = SampleTypeService.get().getSampleType(container, sampleTypeName, true); if (sampleType == null) return Collections.emptyList(); SimpleFilter filter = new SimpleFilter(FieldKey.fromParts(ExpMaterialTable.Column.Name.name()), names, IN); @@ -8083,7 +8083,7 @@ private void validateDataClassOptions(@NotNull Container c, @NotNull User u, @Nu if (options.getSampleType() != null) { - ExpSampleType st = SampleTypeService.get().getSampleType(c, u, options.getSampleType()); + ExpSampleType st = SampleTypeService.get().getSampleType(c, options.getSampleType(), true); if (st == null) throw new ApiUsageException("SampleType '" + options.getSampleType() + "' not found."); @@ -9421,7 +9421,7 @@ public String getInvalidRequiredImportAliasUpdate(String dataTypeLsid, boolean i String parentCpas = null; if (isParentSamples) { - ExpSampleType sampleTypeParent = SampleTypeService.get().getSampleType(c, u, dataTypeName); + ExpSampleType sampleTypeParent = SampleTypeService.get().getSampleType(c, dataTypeName, true); if (sampleTypeParent != null) parentCpas = sampleTypeParent.getLSID(); } @@ -10012,7 +10012,7 @@ public boolean useStrictCounter() return null; Container c = lookup.getContainer() != null ? lookup.getContainer() : container; - return SampleTypeService.get().getSampleType(c, user, lookup.getQueryName()); + return SampleTypeService.get().getSampleType(c, lookup.getQueryName(), true); } @Override diff --git a/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java b/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java index 882e1ec3559..af04d68fa32 100644 --- a/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/SampleTypeServiceImpl.java @@ -172,7 +172,6 @@ import static org.labkey.api.exp.query.ExpMaterialTable.Column.RawUnits; import static org.labkey.api.exp.query.ExpMaterialTable.Column.StoredAmount; import static org.labkey.api.exp.query.ExpMaterialTable.Column.Units; -import static org.labkey.api.exp.query.ExpSchema.NestedSchemas.materials; public class SampleTypeServiceImpl extends AbstractAuditHandler implements SampleTypeService @@ -454,7 +453,7 @@ public ExpSampleTypeImpl getSampleTypeByObjectId(Long objectId) return getSampleTypeByObjectId(legacyObjectId); boolean includeOtherContainers = cf != null && cf.getType() != ContainerFilter.Type.Current; - ExpSampleTypeImpl sampleType = getSampleType(definitionContainer, includeOtherContainers, sampleTypeName); + ExpSampleTypeImpl sampleType = getSampleType(definitionContainer, sampleTypeName, includeOtherContainers); if (sampleType != null && sampleType.getCreated().compareTo(effectiveDate) <= 0) return sampleType; @@ -482,17 +481,11 @@ public List getSampleTypes(@NotNull Container container, bool @Override public ExpSampleTypeImpl getSampleType(@NotNull Container c, @NotNull String sampleTypeName) { - return getSampleType(c, false, sampleTypeName); + return getSampleType(c, sampleTypeName, false); } - // NOTE: This method used to not take a user or check permissions @Override - public ExpSampleTypeImpl getSampleType(@NotNull Container c, @NotNull User user, @NotNull String sampleTypeName) - { - return getSampleType(c, true, sampleTypeName); - } - - private ExpSampleTypeImpl getSampleType(@NotNull Container c, boolean includeOtherContainers, String sampleTypeName) + public ExpSampleTypeImpl getSampleType(@NotNull Container c, @NotNull String sampleTypeName, boolean includeOtherContainers) { return getSampleType(c, includeOtherContainers, (materialSource -> materialSource.getName().equalsIgnoreCase(sampleTypeName))); } @@ -504,29 +497,7 @@ public ExpSampleTypeImpl getSampleType(@NotNull Container c, long rowId) } @Override - public ExpSampleTypeImpl getSampleType(@NotNull Container c, @NotNull User user, long rowId) - { - return getSampleType(c, rowId, true); - } - - @Override - public ExpSampleTypeImpl getSampleTypeByType(@NotNull String lsid, Container hint) - { - Container c = hint; - String id = sampleTypeCache.get(lsid); - if (null != id && (null == hint || !id.equals(hint.getId()))) - c = ContainerManager.getForId(id); - ExpSampleTypeImpl st = null; - if (null != c) - st = getSampleType(c, false, ms -> lsid.equals(ms.getLSID()) ); - if (null == st) - st = _getSampleType(lsid); - if (null != st && null==id) - sampleTypeCache.put(lsid,st.getContainer().getId()); - return st; - } - - private ExpSampleTypeImpl getSampleType(@NotNull Container c, long rowId, boolean includeOtherContainers) + public ExpSampleTypeImpl getSampleType(@NotNull Container c, long rowId, boolean includeOtherContainers) { return getSampleType(c, includeOtherContainers, (materialSource -> materialSource.getRowId() == rowId)); } @@ -566,6 +537,23 @@ public ExpSampleTypeImpl getSampleType(String lsid) return getSampleTypeByType(lsid, null); } + @Override + public ExpSampleTypeImpl getSampleTypeByType(@NotNull String lsid, Container hint) + { + Container c = hint; + String id = sampleTypeCache.get(lsid); + if (null != id && (null == hint || !id.equals(hint.getId()))) + c = ContainerManager.getForId(id); + ExpSampleTypeImpl st = null; + if (null != c) + st = getSampleType(c, false, ms -> lsid.equals(ms.getLSID()) ); + if (null == st) + st = _getSampleType(lsid); + if (null != st && null==id) + sampleTypeCache.put(lsid,st.getContainer().getId()); + return st; + } + @Nullable @Override public DataState getSampleState(Container container, Long stateRowId) @@ -651,7 +639,7 @@ public void deleteSampleType(long rowId, Container c, User user, @Nullable Strin CPUTimer timer = new CPUTimer("delete sample type"); timer.start(); - ExpSampleTypeImpl source = getSampleType(c, user, rowId); + ExpSampleTypeImpl source = getSampleType(c, rowId, true); if (null == source) throw new IllegalArgumentException("Can't find SampleType with rowId " + rowId); if (!source.getContainer().equals(c)) @@ -1049,7 +1037,7 @@ public void validateSampleTypeName(Container container, User user, String name, if (!skipExistingCheck) { - if (getSampleType(container, user, name) != null) + if (getSampleType(container, name, true) != null) throw new ApiUsageException("A Sample Type with name '" + name + "' already exists."); } @@ -1306,7 +1294,7 @@ else if (tInfo != null) UserSchema schema = tInfo.getUserSchema(); if (schema != null) { - ExpSampleType sampleType = getSampleType(c, schema.getUser(), tInfo.getName()); + ExpSampleType sampleType = getSampleType(c, tInfo.getName(), true); if (sampleType != null) { event.setSampleType(sampleType.getName()); diff --git a/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java b/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java index 46ab34a280a..1d257d8b06f 100644 --- a/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java +++ b/experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java @@ -892,7 +892,7 @@ public class ShowSampleTypeAction extends SimpleViewAction @Override public ModelAndView getView(ExpObjectForm form, BindException errors) { - _sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), getUser(), form.getRowId()); + _sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), form.getRowId(), true); if (_sampleType == null && form.getLsid() != null) { if (form.getLsid().equalsIgnoreCase("Material") || form.getLsid().equalsIgnoreCase("Sample")) @@ -909,7 +909,7 @@ public ModelAndView getView(ExpObjectForm form, BindException errors) throw new NotFoundException("No matching sample type found"); } - List allScopedSampleTypes = (List) SampleTypeService.get().getSampleTypes(getContainer(), getUser(), true); + List allScopedSampleTypes = (List) SampleTypeService.get().getSampleTypes(getContainer(), true); if (!allScopedSampleTypes.contains(_sampleType)) { ensureCorrectContainer(getContainer(), _sampleType, getViewContext()); @@ -1626,7 +1626,7 @@ public void validateCommand(CreateDataClassFromTemplateForm form, Errors errors) if (template.getOptions().containsKey("sampleSet")) { String sampleTypeName = template.getOptions().get("sampleSet").toString(); - ExpSampleType sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), getUser(), sampleTypeName); + ExpSampleType sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), sampleTypeName, true); if (sampleType == null) errors.reject(ERROR_MSG, "Unable to find a sample type in this container with name: " + sampleTypeName + "."); } @@ -4116,7 +4116,7 @@ private List getSampleTypes(DeleteForm deleteForm) List sources = new ArrayList<>(); for (long rowId : deleteForm.getIds(false)) { - ExpSampleType sampleType = SampleTypeService.get().getSampleType(getContainer(), getUser(), rowId); + ExpSampleType sampleType = SampleTypeService.get().getSampleType(getContainer(), rowId, true); if (sampleType != null) { sources.add(sampleType); @@ -4368,7 +4368,7 @@ public void validateForm(QueryForm queryForm, Errors errors) { if (!_isCrossTypeImport) { - _sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), getUser(), queryForm.getQueryName()); + _sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), queryForm.getQueryName(), true); if (_sampleType == null) { errors.reject(ERROR_GENERIC, "Sample type '" + queryForm.getQueryName() + " not found."); @@ -4422,7 +4422,7 @@ protected Map getRenamedColumns() } else { - ExpSampleTypeImpl sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), getUser(), _form.getQueryName()); + ExpSampleTypeImpl sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), _form.getQueryName(), true); aliases.addAll(sampleType.getImportAliases().keySet()); } return aliases; @@ -5112,7 +5112,7 @@ public boolean handlePost(ExportOptionsForm form, BindException errors) throws E { throw new NotFoundException("No sampleTypeId parameter specified"); } - ExpSampleType sampleType = SampleTypeService.get().getSampleType(getContainer(), getUser(), rowId.intValue()); + ExpSampleType sampleType = SampleTypeService.get().getSampleType(getContainer(), rowId.intValue(), true); if (sampleType == null) { throw new NotFoundException("No such sample type with RowId " + rowId); @@ -5587,7 +5587,7 @@ public void setDataRegionSelectionKey(String key) private List getUploadableSampleTypes() { // Make a copy so we can modify it - List sampleTypes = new ArrayList<>(SampleTypeService.get().getSampleTypes(getContainer(), getUser(), true)); + List sampleTypes = new ArrayList<>(SampleTypeService.get().getSampleTypes(getContainer(), true)); sampleTypes.removeIf(sampleType -> !sampleType.canImportMoreSamples()); return sampleTypes; } @@ -5618,7 +5618,7 @@ public ModelAndView getView(DeriveMaterialForm form, boolean reshow, BindExcepti if (form.getTargetSampleTypeId() == 0) throw new NotFoundException("Target sample type required for the derived samples"); - ExpSampleTypeImpl sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), getUser(), form.getTargetSampleTypeId()); + ExpSampleTypeImpl sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), form.getTargetSampleTypeId(), true); if (sampleType == null) throw new NotFoundException("Could not find sample type with rowId " + form.getTargetSampleTypeId()); @@ -5707,7 +5707,7 @@ public void validateCommand(DeriveMaterialForm form, Errors errors) @Override public boolean handlePost(DeriveMaterialForm form, BindException errors) { - ExpSampleTypeImpl sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), getUser(), form.getTargetSampleTypeId()); + ExpSampleTypeImpl sampleType = SampleTypeServiceImpl.get().getSampleType(getContainer(), form.getTargetSampleTypeId(), true); DerivedSamplePropertyHelper helper = new DerivedSamplePropertyHelper(sampleType, form.getOutputCount(), getContainer(), getUser()); @@ -8206,10 +8206,9 @@ public ModelAndView getView(Object o, BindException errors) throws SQLException try (var ignore = SpringActionController.ignoreSqlUpdates()) { Container container = getContainer(); - User user = getUser(); List sampleTypes = SampleTypeService.get() - .getSampleTypes(container, user, true); + .getSampleTypes(container, true); HtmlStringBuilder builder = HtmlStringBuilder.of(); builder.unsafeAppend(""); @@ -8222,10 +8221,10 @@ public ModelAndView getView(Object o, BindException errors) throws SQLException // we could check "if (0 < updatedCount) refresh(rollup)", but since this is a "manual" usage lets just always refresh SampleTypeServiceImpl.get().refreshSampleTypeMaterializedView(sampleType, update); builder.unsafeAppend(""); + .append(sampleType.getName()) + .unsafeAppend(""); } builder.unsafeAppend("
Sample Type#Recomputed
") - .append(sampleType.getName()) - .unsafeAppend("") - .append(updatedCount) - .unsafeAppend("
") + .append(updatedCount) + .unsafeAppend("
"); diff --git a/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java b/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java index 99b0e62f72b..49e0f58d76a 100644 --- a/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java +++ b/experiment/src/org/labkey/experiment/lineage/LineageForeignKey.java @@ -118,7 +118,7 @@ List getItems(UserSchema s) @Override List getItems(UserSchema s) { - return SampleTypeService.get().getSampleTypes(s.getContainer(), s.getUser(), true); + return SampleTypeService.get().getSampleTypes(s.getContainer(), true); } }, ExperimentRun("Runs", ExpLineageOptions.LineageExpType.ExperimentRun) diff --git a/experiment/src/org/labkey/experiment/pipeline/SampleReloadTask.java b/experiment/src/org/labkey/experiment/pipeline/SampleReloadTask.java index 8655106c681..eec9c9e2a45 100644 --- a/experiment/src/org/labkey/experiment/pipeline/SampleReloadTask.java +++ b/experiment/src/org/labkey/experiment/pipeline/SampleReloadTask.java @@ -117,7 +117,7 @@ else if ("summary".equalsIgnoreCase(auditLevel)) if (params.containsKey(SAMPLE_NAME_KEY)) { sampleName = params.get(SAMPLE_NAME_KEY); - sampleType = SampleTypeService.get().getSampleType(job.getContainer(), job.getUser(), sampleName); + sampleType = SampleTypeService.get().getSampleType(job.getContainer(), sampleName, true); if (sampleType != null) log.info("Sample Type matching the 'name' capture group was resolved : " + sampleName); else @@ -144,7 +144,7 @@ else if (params.containsKey(SAMPLE_ID_KEY)) // if we aren't trying a named capture group resolution, see if there is a match of an existing sample type // by file name if (!params.containsKey(SAMPLE_NAME_KEY)) - sampleType = SampleTypeService.get().getSampleType(job.getContainer(), job.getUser(), sampleName); + sampleType = SampleTypeService.get().getSampleType(job.getContainer(), sampleName, true); // still no resolution to an existing sample type, create a new one inferring the schema from the data file if (sampleType == null) diff --git a/experiment/src/org/labkey/experiment/samples/SampleStatusFolderImporter.java b/experiment/src/org/labkey/experiment/samples/SampleStatusFolderImporter.java index 7d3e441d744..2631837438a 100644 --- a/experiment/src/org/labkey/experiment/samples/SampleStatusFolderImporter.java +++ b/experiment/src/org/labkey/experiment/samples/SampleStatusFolderImporter.java @@ -88,7 +88,7 @@ else if (file.toLowerCase().endsWith(".tsv")) XarReader typesReader = getXarReader(job, ctx, root, typesXarFile); XarContext xarContext = typesReader.getXarSource().getXarContext(); List sampleTypeNames = typesReader.getSampleTypeNames(); - List sampleTypes = SampleTypeService.get().getSampleTypes(ctx.getContainer(), ctx.getUser(), false) + List sampleTypes = SampleTypeService.get().getSampleTypes(ctx.getContainer(), false) .stream().filter(sampleType -> sampleTypeNames.contains(sampleType.getName())).collect(Collectors.toList()); // process any sample status data files diff --git a/experiment/src/org/labkey/experiment/samples/SampleTypeFolderWriter.java b/experiment/src/org/labkey/experiment/samples/SampleTypeFolderWriter.java index 33c5053d650..9d445f31a41 100644 --- a/experiment/src/org/labkey/experiment/samples/SampleTypeFolderWriter.java +++ b/experiment/src/org/labkey/experiment/samples/SampleTypeFolderWriter.java @@ -80,7 +80,7 @@ public void write(Container c, FolderExportContext ctx, VirtualFile vf) throws E return; Lsid sampleTypeLsid = new Lsid(ExperimentService.get().generateLSID(c, ExpSampleType.class, "export")); - for (ExpSampleType sampleType : SampleTypeService.get().getSampleTypes(c, ctx.getUser(), true)) + for (ExpSampleType sampleType : SampleTypeService.get().getSampleTypes(c, true)) { // ignore the magic sample type that is used for the specimen repository, it is managed by the specimen importer StudyService ss = StudyService.get(); diff --git a/study/src/org/labkey/study/controllers/publish/PublishController.java b/study/src/org/labkey/study/controllers/publish/PublishController.java index 10af3f7d354..17eb162cc55 100644 --- a/study/src/org/labkey/study/controllers/publish/PublishController.java +++ b/study/src/org/labkey/study/controllers/publish/PublishController.java @@ -170,7 +170,7 @@ public void setRowId(int rowId) if (rowId == -1) throw new NotFoundException("rowId required"); - ExpSampleType st = SampleTypeService.get().getSampleType(scope, user, rowId); + ExpSampleType st = SampleTypeService.get().getSampleType(scope, rowId, true); if (st == null) throw new NotFoundException("SampleType not found: " + rowId); diff --git a/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java b/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java index 662067ca5c4..486f3bdc492 100644 --- a/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java +++ b/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java @@ -55,7 +55,7 @@ public ExpSampleType getSampleType() if (_sampleType == null) { if (getRowId() != null) - _sampleType = SampleTypeService.get().getSampleType(getContainer(), getUser(), getRowId()); + _sampleType = SampleTypeService.get().getSampleType(getContainer(), getRowId(), true); else throw new NotFoundException("Sample Type ID not specified."); diff --git a/study/src/org/labkey/study/controllers/publish/SampleTypePublishStartAction.java b/study/src/org/labkey/study/controllers/publish/SampleTypePublishStartAction.java index a9e800eb83b..84ecd957e67 100644 --- a/study/src/org/labkey/study/controllers/publish/SampleTypePublishStartAction.java +++ b/study/src/org/labkey/study/controllers/publish/SampleTypePublishStartAction.java @@ -119,7 +119,7 @@ protected List getDataIDs(SampleTypePublishStartForm form) if (_ids.isEmpty() && !form.isSampleTypeIds() && null != form.getRowId()) { _ids = getCheckboxIds(getViewContext()); - _sampleType = SampleTypeService.get().getSampleType(form.getContainer(), form.getUser(), form.getRowId()); + _sampleType = SampleTypeService.get().getSampleType(form.getContainer(), form.getRowId(), true); form.setAutoLinkEnabled(_sampleType != null && _sampleType.getAutoLinkCategory() != null); } return _ids;