Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions api/src/org/labkey/api/audit/AuditTypeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions api/src/org/labkey/api/data/NameGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -852,14 +852,14 @@ 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)
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<String, String> dataClassNames, Map<String, String> sampleTypeNames)
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -1114,7 +1114,7 @@ private void initialize(@Nullable Map<String, String> 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());
Expand Down
4 changes: 2 additions & 2 deletions api/src/org/labkey/api/data/NameGeneratorState.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ else if (expParentLookupFields.containsKey(FieldKey.fromParts(ExpData.DATA_INPUT
Map<String, ExpSampleType> sampleTypes = getSampleTypes();
Map<String, ExpDataClass> 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));
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);

Expand Down
10 changes: 5 additions & 5 deletions api/src/org/labkey/api/data/generator/DataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public List<? extends ExpSampleType> getSampleTypes(List<String> 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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -349,7 +349,7 @@ public void generateSamplesForAllTypes() throws SQLException, BatchValidationExc
List<String> 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()));
Expand Down Expand Up @@ -702,7 +702,7 @@ public int generateDerivedSamples(ExpSampleType sampleType, Collection<String> 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);
});
Expand All @@ -711,7 +711,7 @@ public int generateDerivedSamples(ExpSampleType sampleType, Collection<String> 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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down
41 changes: 14 additions & 27 deletions api/src/org/labkey/api/exp/api/ExperimentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 <code>includeOtherContainers</code> 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<? extends ExpDataClass> getDataClasses(@NotNull Container container, @Nullable User user, boolean includeOtherContainers);
List<? extends ExpDataClass> 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 <code>includeOtherContainers</code> 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 <code>includeOtherContainers</code> 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.
*
Expand Down Expand Up @@ -622,9 +608,10 @@ static void validateParentAlias(Map<String, String> aliasMap, Set<String> reserv
* ignoring any sample children derived from ExpData children.
*/
Set<ExpMaterial> 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);
Expand Down
18 changes: 4 additions & 14 deletions api/src/org/labkey/api/exp/api/SampleTypeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,15 @@ ExpSampleType createSampleType(Container c, User u, String name, String descript
*/
List<? extends ExpSampleType> getSampleTypes(@NotNull Container container, boolean includeOtherContainers);

@Deprecated // Temporary just to keep code compiling during migration to new method
default List<? extends ExpSampleType> 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 <code>includeOtherContainers</code> 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
Expand All @@ -205,11 +197,9 @@ default List<? extends ExpSampleType> 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 <code>includeOtherContainers</code> 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);

Expand Down
6 changes: 3 additions & 3 deletions api/src/org/labkey/api/exp/query/DataClassUserSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public class DataClassUserSchema extends AbstractExpSchema

private Map<String, ExpDataClass> _map;

static private Map<String, ExpDataClass> getDataClassMap(Container container, User user)
static private Map<String, ExpDataClass> getDataClassMap(Container container)
{
Map<String, ExpDataClass> 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);
}
Expand All @@ -73,7 +73,7 @@ private DataClassUserSchema(Container container, User user, Map<String, ExpDataC
private Map<String, ExpDataClass> getDataClasses()
{
if (_map == null)
_map = getDataClassMap(getContainer(), getUser());
_map = getDataClassMap(getContainer());
return _map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private static List<? extends ExpMaterial> 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<? extends ExpSampleType> sampleTypes = SampleTypeService.get().getSampleTypes(c, user, true);
List<? extends ExpSampleType> sampleTypes = SampleTypeService.get().getSampleTypes(c, true);
if (sampleTypes.isEmpty())
{
return createSampleType(c, user);
Expand Down
Loading