-
Notifications
You must be signed in to change notification settings - Fork 7
Issue 52339: Try to use shorter URIs for domains when possible #6805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7859c68
bb3bfb8
808479d
077c4ea
d85f8ca
3ffd027
26667c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import org.labkey.api.exp.OntologyManager; | ||
| import org.labkey.api.exp.api.ExperimentService; | ||
| import org.labkey.api.exp.property.Domain; | ||
| import org.labkey.api.exp.property.DomainKind; | ||
| import org.labkey.api.exp.property.DomainProperty; | ||
| import org.labkey.api.gwt.client.DefaultValueType; | ||
| import org.labkey.api.query.ValidationException; | ||
|
|
@@ -59,13 +60,28 @@ public class DefaultValueServiceImpl implements DefaultValueService | |
| private String getContainerDefaultsLSID(Container container, Domain domain) | ||
| { | ||
| String suffix = "Folder-" + container.getRowId(); | ||
| return (new Lsid(DOMAIN_DEFAULT_VALUE_LSID_PREFIX, suffix, domain.getName())).toString(); | ||
| DomainKind<?> kind = domain.getDomainKind(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this cause backward compatibility issue? If a default value is set prior to this change, would it be lost since the default lsid is different now?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will be ok because when the domain is user-defined, the objectId from the domain LSID is the same as the encoded name. I tested it locally, but it would be good to double check by creating a list while on develop that has some default values defined for properties then verifying the default values still show up when using the list on this branch. |
||
| if (kind != null && kind.isUserCreatedType()) | ||
| { | ||
| Lsid domainLsid = new Lsid(domain.getTypeURI()); | ||
| return (new Lsid(DOMAIN_DEFAULT_VALUE_LSID_PREFIX, suffix, Lsid.decodePart(domainLsid.getObjectId()))).toString(); | ||
| } | ||
| else // for internal domains (such as audit domains), the domain name and objectId are often not the same. | ||
| return (new Lsid(DOMAIN_DEFAULT_VALUE_LSID_PREFIX, suffix, domain.getName())).toString(); | ||
|
|
||
| } | ||
|
|
||
| private String getUserDefaultsParentLSID(Container container, User user, Domain domain) | ||
| { | ||
| String suffix = "Folder-" + container.getRowId() + ".User-" + user.getUserId(); | ||
| return (new Lsid(USER_DEFAULT_VALUE_DOMAIN_PARENT, suffix, domain.getName())).toString(); | ||
| DomainKind<?> kind = domain.getDomainKind(); | ||
| if (kind != null && kind.isUserCreatedType()) | ||
| { | ||
| Lsid domainLsid = new Lsid(domain.getTypeURI()); | ||
| return (new Lsid(USER_DEFAULT_VALUE_DOMAIN_PARENT, suffix, Lsid.decodePart(domainLsid.getObjectId()))).toString(); | ||
| } | ||
| else // for internal domains (such as audit domains), the domain name and objectId are often not the same. | ||
| return (new Lsid(USER_DEFAULT_VALUE_DOMAIN_PARENT, suffix, domain.getName())).toString(); | ||
| } | ||
|
|
||
| private static final String WILD_CARD_PLACEHOLDER = "WILDCARD"; | ||
|
|
@@ -390,4 +406,4 @@ public boolean hasDefaultValues(Container container, Domain domain, User user, S | |
| } | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import org.labkey.api.data.ColumnInfo; | ||
| import org.labkey.api.data.Container; | ||
| import org.labkey.api.data.ContainerFilter; | ||
| import org.labkey.api.data.ContainerManager; | ||
| import org.labkey.api.data.DbScope; | ||
| import org.labkey.api.data.JdbcType; | ||
| import org.labkey.api.data.PropertyStorageSpec; | ||
|
|
@@ -39,6 +40,7 @@ | |
| import org.labkey.api.di.DataIntegrationService; | ||
| import org.labkey.api.exp.DomainNotFoundException; | ||
| import org.labkey.api.exp.Lsid; | ||
| import org.labkey.api.exp.LsidManager; | ||
| import org.labkey.api.exp.OntologyManager; | ||
| import org.labkey.api.exp.PropertyDescriptor; | ||
| import org.labkey.api.exp.PropertyType; | ||
|
|
@@ -268,20 +270,18 @@ public Set<PropertyStorageSpec.Index> getPropertyIndices(Domain domain) | |
| return Collections.emptySet(); // TODO: Allow this to return the Key Column | ||
| } | ||
|
|
||
| public static Lsid generateDomainURI(String name, Container c, KeyType keyType, @Nullable ListDefinition.Category category) | ||
| public static Lsid generateDomainURI(Container c, KeyType keyType, @Nullable ListDefinition.Category category) | ||
| { | ||
| String type = getType(keyType, category); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to this PR, but surprised to see category is hard wired to picklist. |
||
| StringBuilder typeURI = getBaseURI(name, type, c); | ||
|
|
||
| // Issue 13131: uniqueify the lsid for situations where a preexisting list was renamed | ||
| int i = 1; | ||
| String sTypeURI = typeURI.toString(); | ||
| String uniqueURI = sTypeURI; | ||
| while (OntologyManager.getDomainDescriptor(uniqueURI, c) != null) | ||
| Lsid lsid; | ||
| // assure LSID does not collide with previous lsids that may have had number names | ||
| do | ||
| { | ||
| uniqueURI = sTypeURI + '-' + (i++); | ||
| } | ||
| return new Lsid(uniqueURI); | ||
| String dbSeqStr = String.valueOf(LsidManager.getLsidPrefixDbSeq(type, 1).next()); | ||
| lsid = new Lsid(type, "Folder-" + c.getRowId(), dbSeqStr); | ||
| } while (OntologyManager.getDomainDescriptor(lsid.toString(), c) != null); | ||
|
|
||
| return lsid; | ||
| } | ||
|
|
||
| public static Lsid createPropertyURI(String listName, String columnName, Container c, ListDefinition.KeyType keyType) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this is safe because container RowIds are included in many LSIDs, but since containers can be moved, would it make sense to have a single sequence used server-wide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can certainly change the usage for Lists so it uses the root container. If this method is updated now, we'd need to change the usage from the Experiment module so it can skip over LSIDs already in use from the project-scoped LSIDs.
@XingY Was there a reason not to make this server-wide when you were adding these sequences in
ExperimentServiceImpl?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically we had always included folder / container as part of lsid. The change I introduced was switching from data type name to use a db sequence when generating lsid, in order to support datatype/data renaming. LSIDs are not updated during a folder move, and shouldn't cause issues/conflict.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't a move that would cause the conflict but the restarting of the sequence if we switch it to use a different container where the conflict may occur. (Previous project's sequence value of 1 vs. new project's sequence value of 1.) But, yes, when there is a folder id in the LSID, there won't be a problem here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My future self may not thank me for this, but I'm opting for leaving the
Experimentusages as is and adding a method that provides for an easy way to use a root container sequence, which we'll use for lists.