Skip to content

Commit 0c1caed

Browse files
committed
Strip [label](id) markdown so v2 table renderer linking works
V2 SOLRQueryProcessor (SOLRQueryProcessor.java:1086-1094) emits PLAIN LABEL TEXT in the Upstream_Class/Downstream_Class columns, never markdown. The frontend splits the composite ID column (upstream_id----downstream_id) and applies its own <a> tags to both label columns. VFBquery returns the partner-class column as markdown ([label](id)) so V3 can render it directly; strip the wrapper here so the v2 layout matches the v2 convention. CSV export of the broken state on v2-dev confirms the shape: upstream_class="[mushroom body dopaminergic neuron](FBbt_00048138)" downstream_class="[FBbt_00100246](FBbt_00100246)" ^ my synthesised wrapper After the fix: upstream_class="mushroom body dopaminergic neuron" downstream_class="FBbt_00100246" ^ id text only; frontend resolves the link via composite ID. Human label would need the VFBquery API to return it (it does not today) or a second lookup; deferred. Generic path (Shape A migrations) also strips markdown defensively for any column whose value happens to be wrapped — pass-through for plain text cells (NeuronNeuronConnectivityQuery is unaffected).
1 parent e2b6dc9 commit 0c1caed

1 file changed

Lines changed: 43 additions & 11 deletions

File tree

src/main/java/uk/ac/vfb/geppetto/VFBqueryJsonProcessor.java

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,18 @@ private void buildClassConnectivityRows(Variable variable, QueryResults in, Quer
151151
out.getHeader().add("Avg_Weight");
152152

153153
String queriedId = variable != null && variable.getId() != null ? variable.getId() : "";
154-
// Markdown link form matches the rest of the VFB table column format —
155-
// the V3 frontend renders these as in-app navigation links. We don't
156-
// have the term's human label at this layer; the renderer resolves it
157-
// from the id, same as it does for the partner classes.
158-
String queriedMarkdown = "[" + queriedId + "](" + queriedId + ")";
154+
// V2 SOLRQueryProcessor emits PLAIN LABEL TEXT in the Upstream_Class /
155+
// Downstream_Class columns (SOLRQueryProcessor.java:1087-1088), not
156+
// markdown — the frontend reads the composite ID column
157+
// (upstream_id----downstream_id) and applies its own linking on top of
158+
// the plain label text. VFBquery's API returns the partner column as
159+
// markdown ("[label](id)"); strip that to the label only so the v2
160+
// frontend can link both label columns from the composite ID.
161+
// For the queried-term column we don't have the human label (the
162+
// Variable EClass doesn't expose it cleanly at compile time and we'd
163+
// otherwise need a second API call). Fall back to the id; the
164+
// frontend will still resolve and link it via the composite ID.
165+
String queriedLabel = queriedId;
159166

160167
String partnerColumn = upstreamCall ? COL_UPSTREAM : COL_DOWNSTREAM;
161168

@@ -177,15 +184,15 @@ private void buildClassConnectivityRows(Variable variable, QueryResults in, Quer
177184
SerializableQueryResult r = DatasourcesFactory.eINSTANCE.createSerializableQueryResult();
178185

179186
String partnerId = stringValue(in, COL_ID, i);
180-
String partnerMarkdown = stringValue(in, partnerColumn, i);
187+
String partnerLabel = stripMarkdownLink(stringValue(in, partnerColumn, i));
181188
String upstreamId = upstreamCall ? partnerId : queriedId;
182189
String downstreamId = upstreamCall ? queriedId : partnerId;
183-
String upstreamMarkdown = upstreamCall ? partnerMarkdown : queriedMarkdown;
184-
String downstreamMarkdown = upstreamCall ? queriedMarkdown : partnerMarkdown;
190+
String upstreamLabel = upstreamCall ? partnerLabel : queriedLabel;
191+
String downstreamLabel = upstreamCall ? queriedLabel : partnerLabel;
185192

186193
r.getValues().add(upstreamId + DELIM + downstreamId);
187-
r.getValues().add(upstreamMarkdown);
188-
r.getValues().add(downstreamMarkdown);
194+
r.getValues().add(upstreamLabel);
195+
r.getValues().add(downstreamLabel);
189196
r.getValues().add(formatInt(in, COL_TOTAL_N, i, 6));
190197
r.getValues().add(formatInt(in, COL_CONNECTED_N, i, 6));
191198
r.getValues().add(formatPercent(in, COL_PERCENT, i));
@@ -262,7 +269,32 @@ private static String formatGenericCell(Object v)
262269
}
263270
return v.toString();
264271
}
265-
return v.toString();
272+
// Strip `[label](id)` markdown wrappers when present so the v2 frontend
273+
// table renderer (which is plain-text + composite-ID-driven linking)
274+
// shows clean labels. Plain-text cells pass through untouched.
275+
return stripMarkdownLink(v.toString());
276+
}
277+
278+
/**
279+
* Strip a markdown link wrapper {@code [label](id)} down to just the label
280+
* text. VFBquery returns its `markdown`-typed columns in that wrapped form
281+
* (because V3 renders them as markdown), but the v2 frontend's table
282+
* renderer is plain-text + splits the composite ID column
283+
* ({@code upstream_id----downstream_id}) to apply linking on top — so the
284+
* label columns must NOT contain markdown.
285+
*
286+
* Pattern: starts with '[', has a "](" somewhere in the middle, ends with
287+
* ')'. Anything not matching is passed through unchanged so plain-text
288+
* cells (e.g. the `label` column on NeuronNeuronConnectivityQuery, which
289+
* is already plain) are unaffected.
290+
*/
291+
private static String stripMarkdownLink(String s)
292+
{
293+
if (s == null || s.length() < 4) return s == null ? "" : s;
294+
if (s.charAt(0) != '[' || s.charAt(s.length() - 1) != ')') return s;
295+
int close = s.indexOf("](");
296+
if (close <= 0) return s;
297+
return s.substring(1, close);
266298
}
267299

268300
private static Object safeGetValue(QueryResults in, String col, int rowIdx)

0 commit comments

Comments
 (0)