Skip to content

Commit ab483ce

Browse files
committed
Added new objects to furnish the client
1 parent a9e80b1 commit ab483ce

File tree

6 files changed

+79
-1
lines changed

6 files changed

+79
-1
lines changed

client/build.sbt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name := "delphi-client"
22

3-
libraryDependencies += "io.spray" %% "spray-json" % "1.3.5"
43
libraryDependencies += "joda-time" % "joda-time" % "2.10.5"
54

5+
/*
6+
libraryDependencies ++= Seq(
7+
"com.softwaremill.sttp" %% "core" % "1.5.4",
8+
"com.softwaremill.sttp" %% "spray-json" % "1.5.4"
9+
)*/
10+
611
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package de.upb.cs.swt.delphi.client
2+
3+
import scala.util.Try
4+
import de.upb.cs.swt.delphi.client.QueryJson._
5+
import de.upb.cs.swt.delphi.core.model.Artifact
6+
7+
abstract class DelphiClient(baseUri : String) {
8+
def search(query : Query, prettyPrint : Boolean = false) : Try[Seq[SearchResult]]
9+
/* = {
10+
val queryParams = prettyPrint match {
11+
case true => Map("pretty" -> "")
12+
case false => Map()
13+
}
14+
val searchUri = uri"${baseUri}/search?$queryParams"
15+
16+
val request = sttp.body(query.toJson).post(searchUri)
17+
18+
//val (res, time) = processRequest(request)
19+
//res.foreach(processResults(_, time))
20+
}
21+
*/
22+
def features() : Try[Seq[FieldDefinition]]
23+
24+
def retrieve(identifier : String) : Try[Artifact]
25+
26+
def version() : Try[String]
27+
28+
def statistics() : Try[Statistics]
29+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (C) 2018 The Delphi Team.
2+
// See the LICENCE file distributed with this work for additional
3+
// information regarding copyright ownership.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package de.upb.cs.swt.delphi.client
18+
19+
import spray.json.DefaultJsonProtocol
20+
21+
case class FieldDefinition(name : String, description : String)
22+
23+
object FieldDefinitionJson extends DefaultJsonProtocol {
24+
implicit val transform = jsonFormat2(FieldDefinition)
25+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package de.upb.cs.swt.delphi.client
2+
3+
import spray.json.DefaultJsonProtocol
4+
5+
case class Query(query : String, limit : Option[Int] = Some(50))
6+
7+
object QueryJson extends DefaultJsonProtocol {
8+
implicit val queryRequestFormat = jsonFormat2(Query)
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package de.upb.cs.swt.delphi.client
2+
3+
case class Statistics(total : Long, hermesEnabled : Long)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package de.upb.cs.swt.delphi.client
2+
3+
import spray.json.DefaultJsonProtocol
4+
5+
object StatisticsJson extends DefaultJsonProtocol {
6+
implicit val statisticsFormat = jsonFormat2(Statistics)
7+
}

0 commit comments

Comments
 (0)