Skip to content

Commit

Permalink
Added dataURL parameter...still needs schemaURL and shapeMapURL param…
Browse files Browse the repository at this point in the history
…eter
  • Loading branch information
labra committed Apr 4, 2018
1 parent b811e39 commit e7f43f4
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 54 deletions.
39 changes: 22 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ lazy val rdf4jVersion = "2.2.4"
lazy val scalacheckVersion = "1.13.5"
lazy val scalacticVersion = "3.0.4"
lazy val scalaGraphVersion = "1.11.5"
lazy val scalaTestVersion = "3.0.4"
lazy val scalaTestVersion = "3.0.5"
lazy val scalatagsVersion = "0.6.7"
lazy val scallopVersion = "3.1.1"
lazy val seleniumVersion = "2.35.0"
lazy val sextVersion = "0.2.6"
lazy val typesafeConfigVersion = "1.3.2"
lazy val xercesVersion = "2.11.0"
Expand All @@ -53,34 +54,36 @@ lazy val kindProjectorVersion = "0.9.5"
lazy val scalaMacrosVersion = "2.1.1"

// Dependency modules
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % logbackVersion
lazy val typesafeConfig = "com.typesafe" % "config" % typesafeConfigVersion
lazy val sext = "com.github.nikita-volkov" % "sext" % sextVersion
lazy val jgraphtCore = "org.jgrapht" % "jgrapht-core" % jgraphtVersion
lazy val antlr4 = "org.antlr" % "antlr4" % antlrVersion
lazy val xercesImpl = "xerces" % "xercesImpl" % xercesVersion
lazy val jenaArq = "org.apache.jena" % "jena-arq" % jenaVersion
lazy val rdf4j_runtime = "org.eclipse.rdf4j" % "rdf4j-runtime" % rdf4jVersion
lazy val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % loggingVersion
lazy val scallop = "org.rogach" %% "scallop" % scallopVersion
lazy val scalactic = "org.scalactic" %% "scalactic" % scalacticVersion
lazy val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion
lazy val catsCore = "org.typelevel" %% "cats-core" % catsVersion
lazy val catsKernel = "org.typelevel" %% "cats-kernel" % catsVersion
lazy val catsMacros = "org.typelevel" %% "cats-macros" % catsVersion
lazy val circeCore = "io.circe" %% "circe-core" % circeVersion
lazy val circeGeneric = "io.circe" %% "circe-generic" % circeVersion
lazy val circeParser = "io.circe" %% "circe-parser" % circeVersion
lazy val commonsText = "org.apache.commons" % "commons-text" % commonsTextVersion
lazy val diffsonCirce = "org.gnieh" %% "diffson-circe" % diffsonVersion
lazy val eff = "org.atnos" %% "eff" % effVersion
lazy val http4sDsl = "org.http4s" %% "http4s-dsl" % http4sVersion
lazy val http4sBlazeServer = "org.http4s" %% "http4s-blaze-server" % http4sVersion
lazy val http4sBlazeClient = "org.http4s" %% "http4s-blaze-client" % http4sVersion
lazy val http4sCirce = "org.http4s" %% "http4s-circe" % http4sVersion
lazy val http4sTwirl = "org.http4s" %% "http4s-twirl" % http4sVersion
lazy val scalatags = "com.lihaoyi" %% "scalatags" % scalatagsVersion
lazy val eff = "org.atnos" %% "eff" % effVersion
lazy val jgraphtCore = "org.jgrapht" % "jgrapht-core" % jgraphtVersion
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % logbackVersion
lazy val jenaArq = "org.apache.jena" % "jena-arq" % jenaVersion
lazy val rdf4j_runtime = "org.eclipse.rdf4j" % "rdf4j-runtime" % rdf4jVersion
lazy val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % loggingVersion
lazy val scallop = "org.rogach" %% "scallop" % scallopVersion
lazy val scalactic = "org.scalactic" %% "scalactic" % scalacticVersion
lazy val scalacheck = "org.scalacheck" %% "scalacheck" % scalacheckVersion
lazy val diffsonCirce = "org.gnieh" %% "diffson-circe" % diffsonVersion
lazy val commonsText = "org.apache.commons" % "commons-text" % commonsTextVersion
lazy val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion
lazy val scalatags = "com.lihaoyi" %% "scalatags" % scalatagsVersion
lazy val selenium = "org.seleniumhq.selenium" % "selenium-java" % seleniumVersion
// lazy val htmlUnit = "org.seleniumhq.selenium" % "htmlunit-driver" % seleniumVersion
lazy val sext = "com.github.nikita-volkov" % "sext" % sextVersion
lazy val typesafeConfig = "com.typesafe" % "config" % typesafeConfigVersion
lazy val xercesImpl = "xerces" % "xercesImpl" % xercesVersion

// Compiler plugin modules
lazy val scalaMacrosParadise = "org.scalamacros" % "paradise" % scalaMacrosVersion cross CrossVersion.full
Expand Down Expand Up @@ -229,7 +232,8 @@ lazy val server = project
http4sBlazeClient,
http4sCirce,
http4sTwirl,
scalatags
scalatags,
selenium
)
)

Expand Down Expand Up @@ -407,6 +411,7 @@ lazy val compilationSettings = Seq(
"-Xfuture", // Turn on future language features.
"-Xlint",
"-Yrangepos",
// "-Ylog-classpath",
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
Expand Down
101 changes: 74 additions & 27 deletions modules/server/src/main/resources/staticviews/js/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,46 +265,93 @@ $("#permalink").click(function(e) {
var schema = codeMirrorSchema.getValue();
var dataActiveTab = $("#rdfDataActiveTab").attr("value");
var dataFormat = "";
var dataPart="";
switch (dataActiveTab) {
case "#dataTextArea": dataFormat = $("#dataFormatTextArea").find(":selected").text();
break;
case "#dataFile": dataFormat = $("#dataFormatFile").find(":selected").text();
break;
case "#dataUrl": dataFormat = $("#dataFormatUrl").find(":selected").text();
break;
default: console.log("Unknown value of dataActiveTab:" + dataActiveTab);
dataFormat = $("#dataFormatTextArea").find(":selected").text();
break;
case "#dataTextArea":
dataFormat = $("#dataFormatTextArea").find(":selected").text();
dataPart = "data=" + encodeURIComponent(data) ;
break;
case "#dataFile":
dataFormat = $("#dataFormatFile").find(":selected").text();
dataPart = "data=" + encodeURIComponent(data) ;
break;
case "#dataUrl":
dataFormat = $("#dataFormatUrl").find(":selected").text();
var dataURL = $("#dataURL").val();
dataPart = "dataURL=" + encodeURIComponent(dataURL) ;
break;
default:
console.log("Unknown value of dataActiveTab:" + dataActiveTab);
dataFormat = $("#dataFormatTextArea").find(":selected").text();
dataPart = "data=" + encodeURIComponent(data) ;
break;
}
var schemaFormat = "";
var schemaPart = "";
var activeSchemaTab = $("#activeSchemaTab").attr("value");
switch (activeSchemaTab) {
case "#schemaTextArea": schemaFormat = $("#schemaFormatTextArea").find(":selected").text();
break;
case "#schemaFile": schemaFormat = $("#schemaFormatFile").find(":selected").text();
break;
case "#schemaUrl": schemaFormat = $("#schemaFormatUrl").find(":selected").text();
break;
default: console.log("Unknown value of activeSchemaTab:" + activeSchemaTab);
schemaFormat = $("#schemaFormatTextArea").find(":selected").text();
break;
case "#schemaTextArea":
schemaFormat = $("#schemaFormatTextArea").find(":selected").text();
schemaPart = "schema=" + encodeURIComponent(schema) ;
break;
case "#schemaFile":
schemaFormat = $("#schemaFormatFile").find(":selected").text();
schemaPart = "schema=" + encodeURIComponent(schema) ;
break;
case "#schemaUrl":
schemaFormat = $("#schemaFormatUrl").find(":selected").text();
var schemaURL = $("#schemaURL").val();
schemaPart = "schemaURL=" + encodeURIComponent(schemaURL) ;
break;
default:
console.log("Unknown value of activeSchemaTab:" + activeSchemaTab);
schemaFormat = $("#schemaFormatTextArea").find(":selected").text();
schemaPart = "schema=" + encodeURIComponent(schema) ;
break;
}
var schemaEngine = $("#schemaEngine").find(":selected").text();
var triggerMode = $("#triggerMode").find(":selected").text();
var inference = $("#inference").find(":selected").text();
var shapeMap = codeMirrorShapeMap.getValue(); // prepareShapeMap();
var shapeMapFormat = "";
var shapeMapPart = "";
var shapeMapActiveTab = $("#shapeMapActiveTab").attr("value");
switch (shapeMapActiveTab) {
case "#shapeMapTextArea":
shapeMapFormat = $("#shapeMapFormatTextArea").find(":selected").text();
shapeMapPart = "&shapeMap=" + encodeURIComponent(shapeMap) ;
break;
case "#shapeMapFile":
shapeMapFormat = $("#shapeMapFormatFile").find(":selected").text();
shapeMapPart = "&shapeMap=" + encodeURIComponent(shapeMap) ;
break;
case "#shapeMapUrl":
shapeMapFormat = $("#shapeMapFormatUrl").find(":selected").text();
var shapeMapURL = $("#shapeMapURL").val();
shapeMapPart = "&shapeMapURL=" + encodeURIComponent(shapeMapURL) ;
break;
default:
console.log("Unknown value of shapeMapActiveTab:" + shapeMapActiveTab);
shapeMapFormat = $("#shapeMapFormatTextArea").find(":selected").text();
shapeMapPart = "&shapeMap=" + encodeURIComponent(shapeMap) ;
break;
}
var schemaEmbedded = $("#schemaEmbedded").is(":checked");
if (schemaEmbedded) { schema = ""; }

var location = "/validate?" +
"data=" + encodeURIComponent(data) +
"&dataFormat=" + encodeURIComponent(dataFormat) +
"&schema=" + encodeURIComponent(schema) +
"&schemaFormat=" + encodeURIComponent(schemaFormat) +
"&schemaEngine=" + encodeURIComponent(schemaEngine) +
"&triggerMode=" + encodeURIComponent(triggerMode) +
"&schemaEmbedded=" + encodeURIComponent(schemaEmbedded) +
"&inference=" + encodeURIComponent(inference) +
"&shapeMap=" + encodeURIComponent(shapeMap);
dataPart + "&" +
"dataFormat=" + encodeURIComponent(dataFormat) + "&" +
schemaPart + "&" +
"schemaFormat=" + encodeURIComponent(schemaFormat) + "&" +
"schemaEngine=" + encodeURIComponent(schemaEngine) + "&" +
"triggerMode=" + encodeURIComponent(triggerMode) + "&" +
"schemaEmbedded=" + encodeURIComponent(schemaEmbedded) + "&" +
"inference=" + encodeURIComponent(inference) + "&" +
"activeDataTab=" + encodeURIComponent(dataActiveTab) + "&" +
"activeSchemaTab=" + encodeURIComponent(activeSchemaTab) + "&" +
"activeShapeMapTab=" + encodeURIComponent(shapeMapActiveTab) + "&" +
shapeMapPart ;
var href = urlShaclex + location
console.log("NewHRef: " + href)
window.location.assign(href) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ShaclexServer(host: String, port: Int) {
req
}

def build() =
def build(): fs2.Stream[IO, ExitCode] =
BlazeBuilder[IO]
.bindHttp(port, host)
.mountService(service).
Expand Down
13 changes: 12 additions & 1 deletion modules/server/src/main/scala/es/weso/server/WebService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ object WebService {

case req@GET -> Root / "dataConversions" :?
OptDataParam(optData) +&
OptDataURLParam(optDataURL) +&
DataFormatParam(optDataFormat) +&
InferenceParam(optInference) +&
OptEndpointParam(optEndpoint) +&
OptActiveDataTabParam(optActiveDataTab) +&
TargetDataFormatParam(optTargetDataFormat) => {
Ok(html.dataConversions(
optData,
optDataURL,
availableDataFormats,
optDataFormat.getOrElse(defaultDataFormat),
availableInferenceEngines,
Expand All @@ -62,6 +64,7 @@ object WebService {
val targetFormat = dp.targetDataFormat.getOrElse(defaultDataFormat)
val result = rdf.serialize(targetFormat).map(Some(_))
Ok(html.dataConversions(dp.data,
dp.dataURL,
availableDataFormats,
dp.dataFormat.getOrElse(defaultDataFormat),
availableInferenceEngines,
Expand All @@ -78,6 +81,7 @@ object WebService {

case req@GET -> Root / "dataInfo" :?
OptDataParam(optData) +&
OptDataURLParam(optDataURL) +&
DataFormatParam(optDataFormat) +&
InferenceParam(optInference) +&
OptEndpointParam(optEndpoint) +&
Expand All @@ -86,6 +90,7 @@ object WebService {
str => BadRequest(str),
rdf => Ok(html.dataInfo(dataInfo(rdf),
optData,
optDataURL,
availableDataFormats,
defaultDataFormat,
availableInferenceEngines,
Expand All @@ -104,6 +109,7 @@ object WebService {
case Right((rdf,dp)) =>
Ok(html.dataInfo(dataInfo(rdf),
dp.data,
dp.dataURL,
availableDataFormats,
dp.dataFormat.getOrElse(defaultDataFormat),
availableInferenceEngines,
Expand Down Expand Up @@ -261,6 +267,7 @@ object WebService {
case Right((schema, sp)) => for {
tp <- {
println(s">>>>>>>>>>>>>>>> Data: ${rdf.serialize()}\ndata string:${dp.data}")
println(s">>>>>>>>>>>>>>>> Data URL: ${dp.dataURL}")
println(s">>>>>>>>>>>>>>>> Schema: $schema")
TriggerModeParam.mkTriggerModeParam(partsMap)
}
Expand Down Expand Up @@ -355,6 +362,7 @@ object WebService {
Ok(html.validate(
result.map(_._1),
optData,
optDataURL,
availableDataFormats,
optDataFormat.getOrElse(defaultDataFormat),
optSchema,
Expand All @@ -381,6 +389,7 @@ object WebService {
}
case req@GET -> Root / "query" :?
OptDataParam(optData) +&
OptDataURLParam(optDataURL) +&
DataFormatParam(optDataFormat) +&
OptQueryParam(optQuery) +&
InferenceParam(optInference) +&
Expand All @@ -392,6 +401,7 @@ object WebService {
Ok(html.query(
result,
optData,
optDataURL,
availableDataFormats,
optDataFormat.getOrElse(defaultDataFormat),
optQuery,
Expand Down Expand Up @@ -421,6 +431,7 @@ object WebService {
Ok(html.query(
result,
dp.data,
dp.dataURL,
availableDataFormats,
dp.dataFormat.getOrElse(defaultDataFormat),
optQueryStr,
Expand Down Expand Up @@ -461,7 +472,7 @@ object WebService {
dp: DataParam,
sp: SchemaParam,
tp: TriggerModeParam): IO[Response[IO]] =
Ok(html.validate(Some(result),dp.data,
Ok(html.validate(Some(result),dp.data,dp.dataURL,
availableDataFormats,
dp.dataFormat.getOrElse(defaultDataFormat),
sp.schema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@(data: Option[String],
dataURL: Option[String],
availableDataFormats: List[String],
currentDataFormat: String,
availableInferenceEngines: List[String],
Expand All @@ -22,7 +23,7 @@
}

<form action="/dataConversions" method="POST" enctype="multipart/form-data" id="convert">
@dataPanel("convert", data,availableDataFormats,currentDataFormat,availableInferenceEngines,currentInference,endpoint,activeDataTab,false)
@dataPanel("convert",data,dataURL,availableDataFormats,currentDataFormat,availableInferenceEngines,currentInference,endpoint,activeDataTab,false)
@selectTargetDataFormat("convert",availableDataFormats,currentDataFormat)
<div class="submit">
<button type="submit">Convert</button>
Expand Down
3 changes: 2 additions & 1 deletion modules/server/src/main/twirl/es/weso/dataInfo.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@(result: Option[Json],
data: Option[String],
dataURL: Option[String],
availableDataFormats: List[String],
currentDataFormat: String,
availableInferenceEngines: List[String],
Expand All @@ -19,7 +20,7 @@ <h1>Info about RDF Data</h1>
<div id="resultDiv" data-result='@{Html(JsonTwirl.json2htmlAttr(result.getOrElse(Json.Null)))}'></div>

<form action="/dataInfo" method="POST" enctype="multipart/form-data" id="info">
@dataPanel("info",data,availableDataFormats,currentDataFormat,availableInferenceEngines,currentInference,endpoint,activeDataTab,false)
@dataPanel("info",data,dataURL,availableDataFormats,currentDataFormat,availableInferenceEngines,currentInference,endpoint,activeDataTab,false)
<button type="submit">Data Info</button>
</form>
<div class="otherOptions">
Expand Down
3 changes: 2 additions & 1 deletion modules/server/src/main/twirl/es/weso/dataPanel.scala.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@(formName: String,
data:Option[String],
dataURL: Option[String],
availableDataFormats: List[String],
currentDataFormat: String,
availableInferenceEngines: List[String],
Expand Down Expand Up @@ -36,7 +37,7 @@
</div>
<div class='@{if (activeDataTab=="#dataUrl") "tab-pane fade show active" else "tab-pane fade"}'
id="dataUrl" role="tabpanel" aria-labelledby="dataUrl-tab">
<input type="url" name="dataURL" >
<input type="url" name="dataURL" id="dataURL" value='@{dataURL.getOrElse("")}' />
@selectDataFormat(formName,"Url",availableDataFormats,currentDataFormat)
</div>
<div class='@{if (activeDataTab=="#dataFile") "tab-pane fade show active" else "tab-pane fade"}'
Expand Down
3 changes: 2 additions & 1 deletion modules/server/src/main/twirl/es/weso/query.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@(result: Either[String,Json],
data:Option[String],
dataURL:Option[String],
availableDataFormats: List[String],
currentDataFormat: String,
query:Option[String],
Expand All @@ -26,7 +27,7 @@
<div id="resultDiv" data-result='null' class="alert alert-danger" role="alert"><code>@{result.left.get}</code></div>
}
<form action="/query" method="POST" enctype="multipart/form-data" id="query">
@dataPanel("query", data, availableDataFormats, currentDataFormat,
@dataPanel("query", data, dataURL, availableDataFormats, currentDataFormat,
availableInferenceEngines, currentInferenceEngine, endpoint, activeDataTab, true)
<div id="queryDiv">
@queryPanel("query", query, activeQueryTab)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>
<div class='@{if (activeSchemaTab=="#schemaUrl") "tab-pane fade show active" else "tab-pane fade"}'
id="schemaUrl" role="tabpanel" aria-labelledby="schemaUrl-tab">
<input type="url" name="schemaURL" >
<input type="url" name="schemaURL" id="schemaURL">
@selectSchemaFormat(formName,"Url",availableSchemaFormats,currentSchemaFormat)
</div>
<div class='@{if (activeSchemaTab=="#schemaFile") "tab-pane fade show active" else "tab-pane fade"}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
<div class='@{if (activeShapeMapTab=="#shapeMapUrl") "tab-pane fade show active" else "tab-pane fade"}'
id="shapeMapUrl" role="tabpanel" aria-labelledby="shapeMapUrl-tab">
<input type="url" name="shapeMapURL" >
<input type="url" name="shapeMapURL" id="shapeMapURL">
@selectFormat("shapeMap",formName,"Url",availableShapeMapFormats,currentShapeMapFormat)
</div>
<div class='@{if (activeShapeMapTab=="#shapeMapFile") "tab-pane fade show active" else "tab-pane fade"}'
Expand Down
Loading

0 comments on commit e7f43f4

Please sign in to comment.