Skip to content

Commit 748ef14

Browse files
committed
Add key value to list item descriptions. Add name to data class descriptions.
1 parent 1483cb9 commit 748ef14

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

experiment/src/org/labkey/experiment/api/ExpDataClassType.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.labkey.api.data.SQLFragment;
2323
import org.labkey.api.data.TableInfo;
2424
import org.labkey.api.data.TableSelector;
25+
import org.labkey.api.data.dialect.SqlDialect;
2526
import org.labkey.api.exp.Lsid;
2627
import org.labkey.api.exp.PropertyType;
2728
import org.labkey.api.exp.api.ExperimentService;
@@ -56,6 +57,7 @@ public static AttachmentParentType get()
5657
public @NotNull SQLFragment getSelectEntityIdAndDescriptionSql()
5758
{
5859
TableInfo tableInfo = ExperimentService.get().getTinfoDataClass();
60+
SqlDialect dialect = tableInfo.getSqlDialect();
5961

6062
// Get a dialect-specific expression that can extract an ObjectId from the LSID column and a WHERE clause to
6163
// filter the rows to LSIDs containing ObjectIds
@@ -78,7 +80,13 @@ public static AttachmentParentType get()
7880
selectStatements.add(
7981
new SQLFragment("\n SELECT ")
8082
.append(expressionToExtractObjectId)
81-
.append(" AS EntityId, Name AS Description FROM expdataclass.")
83+
.append(" AS EntityId, ")
84+
.append(dialect.concatenate(
85+
new SQLFragment("?", domain.getName()),
86+
new SQLFragment("':'"),
87+
new SQLFragment("Name")
88+
))
89+
.append(" AS Description FROM expdataclass.")
8290
.append(domain.getStorageTableName())
8391
.append(" WHERE ").append(where)
8492
);

list/src/org/labkey/list/view/ListItemType.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
import org.jetbrains.annotations.NotNull;
1919
import org.labkey.api.attachments.AttachmentParentType;
2020
import org.labkey.api.data.SQLFragment;
21+
import org.labkey.api.data.dialect.SqlDialect;
2122
import org.labkey.api.exp.PropertyType;
2223
import org.labkey.api.exp.list.ListDefinition;
2324
import org.labkey.api.exp.list.ListService;
2425
import org.labkey.api.exp.property.Domain;
2526
import org.labkey.api.exp.property.PropertyService;
2627
import org.labkey.list.model.IntegerListDomainKind;
28+
import org.labkey.list.model.ListSchema;
2729
import org.labkey.list.model.PicklistDomainKind;
2830
import org.labkey.list.model.VarcharListDomainKind;
2931

@@ -56,15 +58,22 @@ private ListItemType()
5658
{
5759
ListService svc = ListService.get();
5860
assert null != svc;
59-
61+
SqlDialect dialect = ListSchema.getInstance().getSchema().getSqlDialect();
6062
List<SQLFragment> selectStatements = new LinkedList<>();
6163

6264
PropertyService.get().getContainersWithDomains(Set.of(IntegerListDomainKind.NAMESPACE_PREFIX, VarcharListDomainKind.NAMESPACE_PREFIX, PicklistDomainKind.NAMESPACE_PREFIX)).forEach(c -> {
6365
Map<String, ListDefinition> map = svc.getLists(c, null, false);
6466
map.forEach((k, v) -> {
6567
Domain domain = v.getDomain();
6668
if (null != domain && domain.getProperties().stream().anyMatch(p -> p.getPropertyType() == PropertyType.ATTACHMENT))
67-
selectStatements.add(new SQLFragment("\n SELECT EntityId, ? AS Description FROM list.", domain.getName()).append(domain.getStorageTableName()));
69+
selectStatements.add(new SQLFragment("\n SELECT EntityId, ")
70+
.append(dialect.concatenate(
71+
new SQLFragment("?", domain.getName()),
72+
new SQLFragment("':'"),
73+
new SQLFragment("CAST(").append(dialect.makeDatabaseIdentifier(v.getKeyName()).getSql())).append(" AS VARCHAR)")
74+
)
75+
.append(" AS Description FROM list.").append(domain.getStorageTableName())
76+
);
6877
});
6978
});
7079

0 commit comments

Comments
 (0)