Skip to content

Commit df450b5

Browse files
committed
Initial version 0.9.0
1 parent 3756852 commit df450b5

File tree

15 files changed

+631
-0
lines changed

15 files changed

+631
-0
lines changed

Diff for: .gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.class
2+
*.log
3+
.idea
4+
project/target
5+
target

Diff for: build.sbt

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
ThisBuild / organization := "de.upb.cs.swt.delphi"
2+
ThisBuild / organizationName := "Delphi Project"
3+
ThisBuild / organizationHomepage := Some(url("https://delphi.cs.uni-paderborn.de/"))
4+
5+
ThisBuild / scmInfo := Some(
6+
ScmInfo(
7+
url("https://github.com/delphi-hub/delphi-core"),
8+
"scm:[email protected]:delphi-hub/delphi-core.git"
9+
)
10+
)
11+
12+
ThisBuild / developers := List(
13+
Developer(
14+
id = "bhermann",
15+
name = "Ben Hermann",
16+
email = "[email protected]",
17+
url = url("https://www.thewhitespace.de")
18+
)
19+
)
20+
ThisBuild / description := "Core components for Delphi."
21+
ThisBuild / licenses := List("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt"))
22+
ThisBuild / homepage := Some(url("https://delphi.cs.uni-paderborn.de/"))
23+
24+
ThisBuild / pomIncludeRepository := { _ => false }
25+
ThisBuild / publishTo := {
26+
val nexus = "https://oss.sonatype.org/"
27+
if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots")
28+
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
29+
}
30+
ThisBuild / publishMavenStyle := true
31+
32+
ThisBuild / version := "0.9.0"
33+
34+
lazy val scala212 = "2.12.10"
35+
lazy val scala213 = "2.13.1"
36+
lazy val supportedScalaVersions = List(scala212, scala213)
37+
38+
ThisBuild / scalaVersion := scala213
39+
40+
41+
useGpg := true
42+
43+
lazy val root = (project in file("."))
44+
.settings (
45+
crossScalaVersions := Nil,
46+
publish / skip := true
47+
)
48+
.aggregate(core, client)
49+
50+
51+
lazy val core = project
52+
.settings(
53+
crossScalaVersions := supportedScalaVersions,
54+
// other settings
55+
)
56+
lazy val client = project
57+
.settings(
58+
crossScalaVersions := supportedScalaVersions,
59+
// other settings
60+
)
61+
.dependsOn(core)

Diff for: client/build.sbt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name := "delphi-client"
2+
3+
libraryDependencies += "io.spray" %% "spray-json" % "1.3.5"
4+
libraryDependencies += "joda-time" % "joda-time" % "2.10.5"
5+
6+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
trait Result{
22+
val id: String
23+
val metadata: ArtifactMetadata
24+
val metricResults: Map[String, Int]
25+
26+
def toMavenIdentifier() : String = s"${metadata.groupId}:${metadata.artifactId}:${metadata.version}"
27+
28+
def fieldNames() : List[String] = metricResults.keys.toList.sorted
29+
}
30+
31+
case class SearchResult(id: String,
32+
metadata: ArtifactMetadata,
33+
metricResults: Map[String, Int]) extends Result
34+
35+
case class RetrieveResult(id: String,
36+
metadata: ArtifactMetadata,
37+
metricResults: Map[String, Int]) extends Result
38+
39+
case class ArtifactMetadata(val artifactId: String,
40+
val source: String,
41+
val groupId: String,
42+
val version: String,
43+
val discovered: String)
44+
45+
object SearchResultJson extends DefaultJsonProtocol {
46+
implicit val artifactFormat = jsonFormat5(ArtifactMetadata)
47+
implicit val searchResultFormat = jsonFormat3(SearchResult)
48+
implicit val retrieveResultFormat = jsonFormat3(RetrieveResult)
49+
}

Diff for: core/build.sbt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name := "delphi-core"
2+
3+
libraryDependencies += "io.spray" %% "spray-json" % "1.3.5"
4+
libraryDependencies += "joda-time" % "joda-time" % "2.10.5"
5+
libraryDependencies += "org.parboiled" %% "parboiled" % "2.1.8"
6+
7+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.core.model
18+
19+
case class Artifact(id: String, metadata: ArtifactMetadata, metricResults: Map[String, Int])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.core.model
18+
19+
import org.joda.time.DateTime
20+
import org.joda.time.format.{DateTimeFormatter, ISODateTimeFormat}
21+
import spray.json.{DefaultJsonProtocol, DeserializationException, JsString, JsValue, RootJsonFormat}
22+
23+
object ArtifactJson extends DefaultJsonProtocol {
24+
25+
implicit object DateJsonFormat extends RootJsonFormat[DateTime] {
26+
27+
private val parserISO: DateTimeFormatter = ISODateTimeFormat.dateTime()
28+
29+
override def write(obj: DateTime) = JsString(parserISO.print(obj))
30+
31+
override def read(json: JsValue): DateTime = json match {
32+
case JsString(s) => parserISO.parseDateTime(s)
33+
case _ => throw new DeserializationException("Error info you want here ...")
34+
}
35+
}
36+
37+
implicit val artifactMetadataFormat = jsonFormat5(ArtifactMetadata)
38+
implicit val artifactFormat = jsonFormat3(Artifact)
39+
40+
def prettyPrint(pretty: Option[_], value: JsValue): String = {
41+
pretty.isDefined match {
42+
case true => value.sortedPrint
43+
case false => value.compactPrint
44+
}
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.core.model
18+
19+
import org.joda.time.DateTime
20+
21+
case class ArtifactMetadata(source: String, discovered: DateTime, groupId: String, artifactId: String, version: String)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.core.model
18+
19+
/**
20+
* Represents an identifier for a software artifact
21+
*/
22+
trait Identifier
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package de.upb.cs.swt.delphi.core.model
2+
3+
import java.net.{URI, URLEncoder}
4+
import java.nio.charset.StandardCharsets
5+
6+
case class MavenIdentifier(val repository: Option[String], val groupId: String, val artifactId: String, val version: Option[String]) extends Identifier {
7+
8+
def toUniqueString: String = {
9+
repository.getOrElse(MavenIdentifier.DefaultRepository) + ":" + groupId + ":" + artifactId + ":" + version.getOrElse("")
10+
}
11+
12+
override val toString: String = groupId + ":" + artifactId + ":" + version
13+
14+
def toJarLocation : URI = {
15+
constructArtifactBaseUri().resolve(encode(artifactId) + "-" + encode(version.getOrElse("")) + ".jar")
16+
}
17+
18+
def toPomLocation : URI = {
19+
constructArtifactBaseUri().resolve(encode(artifactId) + "-" + encode(version.getOrElse("")) + ".pom")
20+
}
21+
22+
private def constructArtifactBaseUri(): URI =
23+
new URI(repository.getOrElse(MavenIdentifier.DefaultRepository))
24+
.resolve(encode(groupId).replace('.', '/') + "/")
25+
.resolve(encode(artifactId) + "/")
26+
.resolve(encode(version.getOrElse("")) + "/")
27+
28+
private def encode(input : String) : String =
29+
URLEncoder.encode(input, StandardCharsets.UTF_8.toString())
30+
}
31+
32+
object MavenIdentifier {
33+
private val DefaultRepository = "http://repo1.maven.org/maven2/"
34+
35+
private implicit def wrapOption[A](value : A) : Option[A] = Some(value)
36+
37+
def apply(s: String): Option[MavenIdentifier] = {
38+
val splitString: Array[String] = s.split(':')
39+
if (splitString.length < 2 || splitString.length > 3) return None
40+
41+
MavenIdentifier(None, splitString(0), splitString(1), if (splitString.length < 3) None else splitString(2))
42+
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.core.ql
18+
19+
trait CombinatorialExpr
20+
21+
case class AndExpr(left: CombinatorialExpr, right: CombinatorialExpr) extends CombinatorialExpr
22+
case class OrExpr(left: CombinatorialExpr, right: CombinatorialExpr) extends CombinatorialExpr
23+
case class NotExpr(expr: CombinatorialExpr) extends CombinatorialExpr
24+
case class XorExpr(left: CombinatorialExpr, right: CombinatorialExpr) extends CombinatorialExpr
25+
26+
trait SingularConditionExpr extends CombinatorialExpr
27+
28+
case class EqualExpr(left: FieldReference, right: String) extends SingularConditionExpr
29+
case class NotEqualExpr(left: FieldReference, right: String) extends SingularConditionExpr
30+
case class GreaterThanExpr(left: FieldReference, right: String) extends SingularConditionExpr
31+
case class GreaterOrEqualExpr(left: FieldReference, right: String) extends SingularConditionExpr
32+
case class LessThanExpr(left: FieldReference, right: String) extends SingularConditionExpr
33+
case class LessOrEqualExpr(left: FieldReference, right: String) extends SingularConditionExpr
34+
case class LikeExpr(left: FieldReference, right: String) extends SingularConditionExpr
35+
case class IsTrueExpr(fieldName: FieldReference) extends SingularConditionExpr
36+
case class FieldReference(fieldName: String) extends CombinatorialExpr

0 commit comments

Comments
 (0)