Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e289726
Issue 52824: remove domain from cache if it's being updated
labkey-susanh May 16, 2025
0d89e53
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 22, 2025
fd3dea8
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 22, 2025
e96be00
fewer p's
labkey-susanh May 22, 2025
e9cc42f
If not for update, retrieve directly from the database.
labkey-susanh May 22, 2025
a5e4c3d
Mark as readOnly if from the cache.
labkey-susanh May 22, 2025
8ef82c9
Get domain for update when ensuring for UsersDomainKind
labkey-susanh May 23, 2025
b2044c5
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 23, 2025
d456974
More places to mark domains as for update or not
labkey-susanh May 23, 2025
afdab48
Get the mutable domain at the right time
labkey-susanh May 26, 2025
924a644
Merge from develop
labkey-susanh May 26, 2025
48678b5
Add forUpdate parameter to more methods
labkey-susanh May 26, 2025
68b1618
Add forUpdate parameter to more methods that are getting domains
labkey-susanh May 26, 2025
00faafe
get for update
labkey-susanh May 26, 2025
d3d31b3
More forUpdate parameters and make methods for data classes and sampl…
labkey-susanh May 26, 2025
1b03d59
get mutable domain during import
labkey-susanh May 27, 2025
4d41906
isForUpdate -> isMutable
labkey-susanh May 27, 2025
3519d58
Still more forUpdate parameters
labkey-susanh May 28, 2025
210a8ea
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 28, 2025
a6aca25
Use the forUpdate parameter
labkey-susanh May 28, 2025
17f1fa0
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 29, 2025
9342e55
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh Jun 2, 2025
bb2415a
Comments
labkey-susanh Jun 2, 2025
d4c11b4
Better handling of forUpdate and stashed objects
labkey-susanh Jun 2, 2025
2259fce
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh Jun 4, 2025
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
34 changes: 26 additions & 8 deletions api/src/org/labkey/api/assay/AbstractAssayProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,31 +382,37 @@ public static String getDomainURIForPrefixIfExists(ExpProtocol protocol, String
return result;
}

public static Domain getDomainByPrefix(ExpProtocol protocol, String domainPrefix)
public static Domain getDomainByPrefix(ExpProtocol protocol, String domainPrefix, boolean forUpdate)
{
Container container = protocol.getContainer();
return PropertyService.get().getDomain(container, getDomainURIForPrefix(protocol, domainPrefix));
return PropertyService.get().getDomain(container, getDomainURIForPrefix(protocol, domainPrefix), forUpdate);
}

@Nullable
public static Domain getDomainByPrefixIfExists(ExpProtocol protocol, String domainPrefix)
public static Domain getDomainByPrefixIfExists(ExpProtocol protocol, String domainPrefix, boolean forUpdate)
{
String domainURI = getDomainURIForPrefixIfExists(protocol, domainPrefix);
if (null == domainURI)
return null;
Container container = protocol.getContainer();
return PropertyService.get().getDomain(container, domainURI);
return PropertyService.get().getDomain(container, domainURI, forUpdate);
}

@Override
public Domain getResultsDomain(ExpProtocol protocol)
{
return getDomainByPrefix(protocol, ExpProtocol.ASSAY_DOMAIN_DATA);
return getResultsDomain(protocol, false);
}

@Override
public Domain getResultsDomain(ExpProtocol protocol, boolean forUpdate)
{
return getDomainByPrefix(protocol, ExpProtocol.ASSAY_DOMAIN_DATA, forUpdate);
}

protected @Nullable Domain getResultsDomainIfExists(ExpProtocol protocol)
{
return getDomainByPrefixIfExists(protocol, ExpProtocol.ASSAY_DOMAIN_DATA);
return getDomainByPrefixIfExists(protocol, ExpProtocol.ASSAY_DOMAIN_DATA, false);
}

@Override
Expand All @@ -422,13 +428,25 @@ public void afterDomainChange(User user, ExpProtocol protocol, GWTDomain<GWTProp
@Override
public Domain getBatchDomain(ExpProtocol protocol)
{
return getDomainByPrefix(protocol, ExpProtocol.ASSAY_DOMAIN_BATCH);
return getBatchDomain(protocol, false);
}

@Override
public Domain getBatchDomain(ExpProtocol protocol, boolean forUpdate)
{
return getDomainByPrefix(protocol, ExpProtocol.ASSAY_DOMAIN_BATCH, forUpdate);
}

@Override
public Domain getRunDomain(ExpProtocol protocol)
{
return getDomainByPrefix(protocol, ExpProtocol.ASSAY_DOMAIN_RUN);
return getRunDomain(protocol,false);
}

@Override
public Domain getRunDomain(ExpProtocol protocol, boolean forUpdate)
{
return getDomainByPrefix(protocol, ExpProtocol.ASSAY_DOMAIN_RUN, forUpdate);
}

protected PropertyDescriptor addProperty(Container sourceContainer, String name, Integer value, Map<String, Object> dataMap, Collection<PropertyDescriptor> types)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public void beforeDeleteData(List<ExpData> data, User user) throws ExperimentExc
// results/data domain for TSV-style assays
try
{
domain = AbstractAssayProvider.getDomainByPrefixIfExists(protocol, ExpProtocol.ASSAY_DOMAIN_DATA) ;
domain = AbstractAssayProvider.getDomainByPrefixIfExists(protocol, ExpProtocol.ASSAY_DOMAIN_DATA, false) ;
}
catch (IllegalStateException ignored)
{
Expand Down
7 changes: 7 additions & 0 deletions api/src/org/labkey/api/assay/AssayProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,19 @@ enum ReRunSupport
/** Get a schema that includes queries like Batch, Run, Results, and any additional tables. */
AssayProtocolSchema createProtocolSchema(User user, Container container, @NotNull ExpProtocol protocol, @Nullable Container targetStudy);

/** Get a domain that is not intended to be mutated */
Domain getBatchDomain(ExpProtocol protocol);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth a comment to say the default forUpdate is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


Domain getBatchDomain(ExpProtocol protocol, boolean forUpdate);

Domain getRunDomain(ExpProtocol protocol);

Domain getRunDomain(ExpProtocol protocol, boolean forUpdate);

Domain getResultsDomain(ExpProtocol protocol);

Domain getResultsDomain(ExpProtocol protocol, boolean forUpdate);

void beforeDomainChange(User user, ExpProtocol protocol, GWTDomain<GWTPropertyDescriptor> orig, GWTDomain<GWTPropertyDescriptor> update) throws ValidationException;
void afterDomainChange(User user, ExpProtocol protocol, GWTDomain<GWTPropertyDescriptor> orig, GWTDomain<GWTPropertyDescriptor> update) throws ValidationException;

Expand Down
12 changes: 9 additions & 3 deletions api/src/org/labkey/api/audit/AbstractAuditTypeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected AbstractAuditDomainKind getDomainKind()
public void initializeProvider(User user)
{
AbstractAuditDomainKind domainKind = getDomainKind();
Domain domain = getDomain();
Domain domain = getDomain(true);

// if the domain doesn't exist, create it
if (domain == null)
Expand All @@ -138,7 +138,7 @@ public void initializeProvider(User user)
domain.addPropertyOfPropertyDescriptor(pd);
}
domain.save(user);
domain = getDomain();
domain = getDomain(true);
}
catch (ChangePropertyDescriptorException e)
{
Expand Down Expand Up @@ -299,12 +299,18 @@ private void copyTo(DomainProperty dp, PropertyDescriptor pd, Container c)

@Override
public final Domain getDomain()
{
return getDomain(false);
}

@Override
public final Domain getDomain(boolean forUpdate)
{
DomainKind domainKind = getDomainKind();

String domainURI = domainKind.generateDomainURI(QUERY_SCHEMA_NAME, getEventName(), getDomainContainer(), null);

return PropertyService.get().getDomain(getDomainContainer(), domainURI);
return PropertyService.get().getDomain(getDomainContainer(), domainURI, forUpdate);
}


Expand Down
2 changes: 2 additions & 0 deletions api/src/org/labkey/api/audit/AuditTypeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public interface AuditTypeProvider

Domain getDomain();

Domain getDomain(boolean forUpdate);

TableInfo createTableInfo(UserSchema schema, ContainerFilter cf);

<K extends AuditTypeEvent> Class<K> getEventClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public JSONObject getDomainKindProperties(GWTDomain domain, Container container,
}

@Override
public Domain createDomain(GWTDomain domain, JSONObject arguments, Container container, User user, @Nullable TemplateInfo templateInfo)
public Domain createDomain(GWTDomain domain, JSONObject arguments, Container container, User user, @Nullable TemplateInfo templateInfo, boolean forUpdate)
{
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,14 @@ protected void initColumn(MutableColumnInfo col)
@Override
public Domain getDomain()
{
return _provider.getDomain();
return getDomain(false);
}

@Nullable
@Override
public Domain getDomain(boolean forUpdate)
{
return _provider.getDomain(forUpdate);
}

@Nullable
Expand Down
7 changes: 7 additions & 0 deletions api/src/org/labkey/api/data/AbstractTableInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,13 @@ public Domain getDomain()
return null;
}

@Nullable
@Override
public Domain getDomain(boolean forUpdate)
{
return getDomain();
}

@Nullable
@Override
public DomainKind getDomainKind()
Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/data/MutableColumnInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ default void setSortFieldKeysFromXml(String xml)

void setLocked(boolean b);

// return a ColumnInfo that does not suppport MutableColumnInfo or a MutableColumnInfo that is locked
// return a ColumnInfo that does not support MutableColumnInfo or a MutableColumnInfo that is locked
default ColumnInfo lock()
{
setLocked(true);
Expand Down
14 changes: 0 additions & 14 deletions api/src/org/labkey/api/data/NameGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package org.labkey.api.data;

import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -26,17 +24,12 @@
import org.junit.Test;
import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.api.collections.CaseInsensitiveHashSet;
import org.labkey.api.exp.Identifiable;
import org.labkey.api.exp.LsidManager;
import org.labkey.api.exp.PropertyType;
import org.labkey.api.exp.api.ExpData;
import org.labkey.api.exp.api.ExpDataClass;
import org.labkey.api.exp.api.ExpLineage;
import org.labkey.api.exp.api.ExpLineageOptions;
import org.labkey.api.exp.api.ExpLineageService;
import org.labkey.api.exp.api.ExpMaterial;
import org.labkey.api.exp.api.ExpObject;
import org.labkey.api.exp.api.ExpRunItem;
import org.labkey.api.exp.api.ExpSampleType;
import org.labkey.api.exp.api.ExperimentService;
import org.labkey.api.exp.api.SampleTypeService;
Expand All @@ -47,7 +40,6 @@
import org.labkey.api.query.FieldKey;
import org.labkey.api.query.QueryKey;
import org.labkey.api.query.QueryService;
import org.labkey.api.query.RuntimeValidationException;
import org.labkey.api.query.UserSchema;
import org.labkey.api.query.ValidationException;
import org.labkey.api.reader.TabLoader;
Expand All @@ -59,12 +51,9 @@
import org.labkey.api.util.StringExpressionFactory;
import org.labkey.api.util.StringExpressionFactory.AbstractStringExpression.NullValueBehavior;
import org.labkey.api.util.StringExpressionFactory.FieldKeyStringExpression;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.SubstitutionFormat;
import org.labkey.api.util.Tuple3;

import java.io.IOException;
import java.sql.SQLException;
import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand All @@ -73,12 +62,10 @@
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
Expand All @@ -88,7 +75,6 @@
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.labkey.api.data.NameGenerator.NameGenerationExpression.findFirstOpenOrCloseTag;
Expand Down
9 changes: 9 additions & 0 deletions api/src/org/labkey/api/data/SchemaTableInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,15 @@ public Domain getDomain()
return null;
}

@Nullable
@Override
public Domain getDomain(boolean forUpdate)
{
if (forUpdate)
throw new UnsupportedOperationException("Cannot get domain for update.");
return getDomain();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should throw UnsupportedOperationException when passed true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

@Nullable
@Override
public DomainKind getDomainKind()
Expand Down
6 changes: 6 additions & 0 deletions api/src/org/labkey/api/data/TableInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ default List<Pair<String, String>> getValidatedImportTemplates(ViewContext ctx)
@Nullable
Domain getDomain();

/**
* Get Domain associated with this TableInfo if any.
*/
@Nullable
Domain getDomain(boolean forUpdate);

/**
* Get DomainKind associated with this TableInfo if any.
* Domain may or may not exist even if DomainKind is available.
Expand Down
1 change: 0 additions & 1 deletion api/src/org/labkey/api/data/generator/DataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.labkey.api.data.dialect.SqlDialect;
import org.labkey.api.dataiterator.DataIteratorBuilder;
import org.labkey.api.dataiterator.DetailedAuditLogDataIterator;
import org.labkey.api.dataiterator.ListofMapsDataIterator;
import org.labkey.api.dataiterator.MapDataIterator;
import org.labkey.api.exp.ExperimentException;
import org.labkey.api.exp.api.DataClassDomainKindProperties;
Expand Down
36 changes: 33 additions & 3 deletions api/src/org/labkey/api/exp/OntologyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2441,25 +2441,55 @@ public DomainDescriptor load(@NotNull Integer key, @Nullable Object argument)
}
}


public static DomainDescriptor getDomainDescriptor(int id)
{
return getDomainDescriptor(id, false);
}

public static DomainDescriptor getDomainDescriptor(int id, boolean forUpdate)
{
if (forUpdate)
return new DomainDescriptorLoader().load(id, null);

return DOMAIN_DESC_BY_ID_CACHE.get(id);
}

@Nullable
public static DomainDescriptor getDomainDescriptor(String domainURI, Container c)
{
return getDomainDescriptor(domainURI, c, false);
}

@Nullable
public static DomainDescriptor getDomainDescriptor(String domainURI, Container c, boolean forUpdate)
{
if (c == null)
return null;

if (forUpdate)
return getDomainDescriptorForUpdate(domainURI, c);

// cache lookup by project. if not found at project level, check to see if global
DomainDescriptor dd = DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(getCacheKey(domainURI, c));
Pair<String, GUID> key = getCacheKey(domainURI, c);
DomainDescriptor dd = DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(key);
if (null != dd)
return dd;

// Try in the /Shared container too
return DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(getCacheKey(domainURI, _sharedContainer));
key = getCacheKey(domainURI, _sharedContainer);
return DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(key);
}

@Nullable
private static DomainDescriptor getDomainDescriptorForUpdate(String domainURI, Container c)
{
if (c == null)
return null;

DomainDescriptor dd = fetchDomainDescriptorFromDB(domainURI, c);
if (dd == null)
dd = fetchDomainDescriptorFromDB(domainURI, _sharedContainer);
return dd;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion api/src/org/labkey/api/exp/api/ExpDataClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public interface ExpDataClass extends ExpObject, ExpSearchable

void setSampleType(Integer sampleType);

@NotNull
Domain getDomain();

void setDomain(Domain d);
@NotNull
Domain getDomain(boolean forUpdate);

String getDescription();

Expand Down
3 changes: 3 additions & 0 deletions api/src/org/labkey/api/exp/api/ExpSampleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public interface ExpSampleType extends ExpObject, ExpSearchable
@NotNull
Domain getDomain();

@NotNull
Domain getDomain(boolean forUpdate);

String getDescription();

/**
Expand Down
Loading