Skip to content

Commit ca98623

Browse files
committed
Display rdf:type in /backlinks & /search
1 parent b3fa837 commit ca98623

File tree

3 files changed

+83
-30
lines changed

3 files changed

+83
-30
lines changed

scala/forms/src/main/scala/deductions/runtime/services/ParameterizedPARQL.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ abstract trait ParameterizedSPARQL[Rdf <: RDF, DATASET]
6262
httpRequest: HTTPrequest = HTTPrequest())(
6363
implicit
6464
queryMaker: SPARQLQueryMaker[Rdf]): Future[NodeSeq] = {
65-
println(s"search($search) 1: starting TRANSACTION for dataset $dataset")
65+
logger.debug(s"search($search) 1: starting TRANSACTION for dataset $dataset")
6666
val elem0 = rdfStore.rw(dataset, {
6767
val uris = search_onlyNT(search, variables, httpRequest)
68-
println(s"\tsearch(): URI's size ${uris.size}")
68+
logger.info(s"\tsearch(): URI's size ${uris.size}")
6969
val graph: Rdf#Graph = allNamedGraph
7070
val elems = Seq(
7171
<button value="Sort" id="sort"> Sort </button>,
@@ -81,7 +81,7 @@ abstract trait ParameterizedSPARQL[Rdf <: RDF, DATASET]
8181
}</div>)
8282
elems
8383
})
84-
println(s"search: leaving TRANSACTION for dataset $dataset")
84+
logger.debug(s"search: leaving TRANSACTION for dataset $dataset")
8585
val elem = elem0.get
8686
Future.successful(elem)
8787
}

scala/forms/src/main/scala/deductions/runtime/views/ResultsDisplay.scala

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ extends ThumbnailInference[Rdf, DATASET] {
5252
uri, lang, graph,
5353
hrefPrefix = hrefPrefix,
5454
label = label,
55-
sortAnd1rowPerElement = sortAnd1rowPerElement )
55+
sortAnd1rowPerElement = sortAnd1rowPerElement ) ++
56+
separatorSpan ++
57+
makeHyperlinkForURIBriefly(
58+
getClassOrNullURI(uri)(allNamedGraph),
59+
lang)
5660
// ++
5761
// <div style="font-size:10px; opacity:.8;">{ val uriString = fromUri(uri)
5862
// URLEncoder.encode( s"DROP GRAPH <$uriString>", "utf-8") }</div>
@@ -65,14 +69,16 @@ extends ThumbnailInference[Rdf, DATASET] {
6569
sortAnd1rowPerElement = sortAnd1rowPerElement ),
6670
lit => <div>{ lit.toString() }</div>
6771
)
68-
}</div> , <span>&#160;&#160;</span> )
72+
}</div> , separatorSpan )
6973
}
7074
}
7175
columnsFormResults
7276
}</div><!-- end of wrapping div displayResults -->
7377
}
7478

75-
/** make HTML hyperlink For given URI;
79+
val separatorSpan = <span>&#160;&#160;&#160;&#160;</span>
80+
81+
/** make HTML hyperlink For given URI, with bells and whistles;
7682
* this links to semantic_forms page for displaying this URI;
7783
* NOTE: this reuses code in Form2HTMLDisplay.createHTMLResourceReadonlyField()
7884
*
@@ -92,6 +98,22 @@ extends ThumbnailInference[Rdf, DATASET] {
9298
property = nullURI, type_ = `type` )
9399
}
94100

101+
def makeHyperlinkForURIBriefly(
102+
node: Rdf#Node,
103+
lang: String,
104+
label: String = "",
105+
graph: Rdf#Graph = allNamedGraph
106+
) : NodeSeq = {
107+
val displayLabel =
108+
if( label != "" )
109+
label
110+
else
111+
makeInstanceLabel(node, graph, lang)
112+
val `type` = getClassOrNullURI(node)(graph)
113+
displayNodeBriefly(uriNodeToURI(node), displayLabel,
114+
property = nullURI, type_ = `type` )
115+
}
116+
95117
/** make HTML hyperlink For given URI;
96118
* this links to semantic_forms page for displaying this URI;
97119
* NOTE: this reuses code in Form2HTMLDisplay.createHTMLResourceReadonlyField()
@@ -112,38 +134,55 @@ extends ThumbnailInference[Rdf, DATASET] {
112134

113135
/** display given URI with bells and whistles,
114136
* implementation: call createHTMLResourceReadonlyField() in trait Form2HTMLDisplay */
115-
private def displayNode(uri: Rdf#URI, hrefPrefix: String = config.hrefDisplayPrefix,
116-
label: String,
137+
private def displayNode(uri: Rdf#URI,
138+
hrefPrefix: String = config.hrefDisplayPrefix,
139+
label: String,
117140
property: Rdf#URI,
118141
type_ : Rdf#Node
119142
): NodeSeq = {
120143
if( uri != nullURI ) {
144+
val resourceEntry = makeResourceEntry(uri, label, property, type_)
145+
146+
def hyperlink =
147+
if( hrefPrefix != "" &&
148+
hrefPrefix != config.hrefDisplayPrefix )
149+
<a href={
150+
createHyperlinkString(hrefPrefix, fromUri(uri), false)
151+
} class="" title={s"hyperlink to Triples in Graph at URI <$uri>"}>
152+
{ label } </a>
153+
else NodeSeq.Empty
154+
155+
hyperlink ++
156+
createHTMLResourceReadonlyField( resourceEntry, hrefPrefix)
157+
} else
158+
<span>null URI</span>
159+
}
160+
161+
private def displayNodeBriefly(uri: Rdf#URI,
162+
label: String,
163+
property: Rdf#URI,
164+
type_ : Rdf#Node
165+
): NodeSeq = {
166+
createHTMLResourceReadonlyFieldBriefly(
167+
makeResourceEntry(uri, label, property, type_ ) )
168+
}
169+
170+
private def makeResourceEntry(uri: Rdf#URI,
171+
label: String,
172+
property: Rdf#URI,
173+
type_ : Rdf#Node
174+
) = {
121175
val fmod = new FormModule[Rdf#Node, Rdf#URI ]{
122-
val nullURI= ops.URI("")
123-
}
124-
val types = getClasses(uri)(allNamedGraph)
125-
// println(s"==== displayNode: types: $types")
126-
val resourceEntry =
127-
new fmod.ResourceEntry(
176+
val nullURI= ops.URI("")
177+
}
178+
val types = getClasses(uri)(allNamedGraph)
179+
// println(s"==== displayNode: types: $types")
180+
new fmod.ResourceEntry(
128181
valueLabel=label,
129182
property=property,
130183
value=uri,
131184
thumbnail = getURIimage(uri),
132185
type_ = types)
133-
134-
def hyperlink =
135-
if( hrefPrefix != "" &&
136-
hrefPrefix != config.hrefDisplayPrefix )
137-
<a href={
138-
createHyperlinkString(hrefPrefix, fromUri(uri), false)
139-
} class="" title={s"hyperlink to Triples in Graph at URI <$uri>"}>
140-
{ label } </a>
141-
else NodeSeq.Empty
142-
143-
hyperlink ++
144-
createHTMLResourceReadonlyField( resourceEntry, hrefPrefix)
145-
} else
146-
<span>null URI</span>
147186
}
148-
187+
149188
}

scala/html/src/main/scala/deductions/runtime/html/Form2HTMLDisplay.scala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ trait Form2HTMLDisplay[NODE, URI <: NODE]
4141
* */
4242
def createHTMLResourceReadonlyField(
4343
resourceEntry: formMod#ResourceEntry,
44-
hrefPrefix: String = hrefDisplayPrefix,
44+
// TODO remove arg:
45+
hrefPrefixxxxx: String = hrefDisplayPrefix,
4546
request: HTTPrequest = HTTPrequest()
4647
): NodeSeq = {
4748

@@ -78,6 +79,19 @@ trait Form2HTMLDisplay[NODE, URI <: NODE]
7879
<span class="sf-statistics">{widgets}</span>
7980
}
8081

82+
/** TODO duplication with preceding function */
83+
def createHTMLResourceReadonlyFieldBriefly(
84+
resourceEntry: formMod#ResourceEntry,
85+
request: HTTPrequest = HTTPrequest()): NodeSeq = {
86+
import resourceEntry._
87+
val typ = firstNODEOrElseEmptyString(type_)
88+
val objectURIstringValue = value.toString()
89+
hyperlinkToURI(hrefDisplayPrefix, objectURIstringValue, valueLabel,
90+
typ, // TODO pass type_
91+
resourceEntry) ++
92+
displayThumbnail(resourceEntry)
93+
}
94+
8195
/** hyperlink To RDF property */
8296
private def hyperlinkToField(resourceEntry: formMod#ResourceEntry
8397
// , objectURIstringValue: String

0 commit comments

Comments
 (0)