Skip to content

Commit 40ed0fa

Browse files
committed
Refactorings
1 parent 7b26a4f commit 40ed0fa

File tree

11 files changed

+35
-31
lines changed

11 files changed

+35
-31
lines changed

src/it/scala/de/upb/cs/swt/delphi/webapi/FeatureExtractorCheck.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package de.upb.cs.swt.delphi.webapi
1818

19-
import de.upb.cs.swt.delphi.featuredefinitions.FeatureExtractor
19+
import de.upb.cs.swt.delphi.webapi.featuredefinitions.FeatureExtractor
2020
import org.scalatest.{FlatSpec, Matchers}
2121

2222
class FeatureExtractorCheck extends FlatSpec with Matchers {

src/it/scala/de/upb/cs/swt/delphi/webapi/SearchQueryTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package de.upb.cs.swt.delphi.webapi
1818

19-
import de.upb.cs.swt.delphi.featuredefinitions.FeatureExtractor
19+
import de.upb.cs.swt.delphi.webapi.featuredefinitions.FeatureExtractor
2020
import org.scalatest.{FlatSpec, Matchers}
2121

2222
import scala.util.Success

src/main/scala/de/upb/cs/swt/delphi/webapi/Configuration.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ import scala.util.{Failure, Success, Try}
2626
/**
2727
* @author Ben Hermann
2828
*/
29-
class Configuration( //Server and Elasticsearch configuration
30-
val bindHost: String = "0.0.0.0",
31-
val bindPort: Int = 8080,
32-
val esIndex : String = "delphi",
33-
val esType : String = "project",
29+
class Configuration( //Server and Elasticsearch configuration
30+
val bindHost: String = "0.0.0.0",
31+
val bindPort: Int = 8080,
32+
val esIndex: String = "delphi",
33+
val esType: String = "project",
3434

35-
//Actor system configuration
36-
val elasticActorPoolSize: Int = 8
35+
//Actor system configuration
36+
val elasticActorPoolSize: Int = 8
3737
) {
3838

3939
lazy val esProjectIndex: IndexAndType = esIndex / esType
4040
lazy val elasticsearchClientUri: ElasticsearchClientUri = ElasticsearchClientUri(
4141
elasticsearchInstance.host + ":" + elasticsearchInstance.portNumber)
4242

43-
lazy val elasticsearchInstance : Instance = InstanceRegistry.retrieveElasticSearchInstance( configuration = this) match {
43+
lazy val elasticsearchInstance: Instance = InstanceRegistry.retrieveElasticSearchInstance(configuration = this) match {
4444
case Success(instance) => instance
4545
case Failure(_) => Instance(
4646
None,
@@ -51,18 +51,18 @@ class Configuration( //Server and Elasticsearch configuration
5151
None,
5252
InstanceState.Running)
5353
}
54-
val defaultElasticSearchPort : Int = 9200
55-
val defaultElasticSearchHost : String = "elasticsearch://localhost"
54+
val defaultElasticSearchPort: Int = 9200
55+
val defaultElasticSearchHost: String = "elasticsearch://localhost"
5656
val instanceName = "MyWebApiInstance"
57-
val instanceRegistryUri : String = sys.env.getOrElse("DELPHI_IR_URI", "http://localhost:8087")
58-
lazy val usingInstanceRegistry : Boolean = assignedID match {
57+
val instanceRegistryUri: String = sys.env.getOrElse("DELPHI_IR_URI", "http://localhost:8087")
58+
lazy val usingInstanceRegistry: Boolean = assignedID match {
5959
case Some(_) => true
6060
case None => false
6161
}
62-
lazy val assignedID : Option[Long] = InstanceRegistry.handleInstanceStart(configuration = this)
62+
lazy val assignedID: Option[Long] = InstanceRegistry.handleInstanceStart(configuration = this)
6363

64-
lazy val fallbackElasticSearchPort : Int = sys.env.get("DELPHI_ELASTIC_URI") match {
65-
case Some(hostString) => if(hostString.count(c => c == ':') == 3){
64+
lazy val fallbackElasticSearchPort: Int = sys.env.get("DELPHI_ELASTIC_URI") match {
65+
case Some(hostString) => if (hostString.count(c => c == ':') == 3) {
6666
Try(hostString.split(":")(2).toInt) match {
6767
case Success(port) => port
6868
case Failure(_) => defaultElasticSearchPort
@@ -73,17 +73,17 @@ class Configuration( //Server and Elasticsearch configuration
7373
case None => defaultElasticSearchPort
7474
}
7575

76-
lazy val fallbackElasticSearchHost : String = sys.env.get("DELPHI_ELASTIC_URI") match {
76+
lazy val fallbackElasticSearchHost: String = sys.env.get("DELPHI_ELASTIC_URI") match {
7777
case Some(hostString) =>
78-
if(hostString.count(c => c == ':') == 2){
79-
hostString.substring(0,hostString.lastIndexOf(":"))
78+
if (hostString.count(c => c == ':') == 2) {
79+
hostString.substring(0, hostString.lastIndexOf(":"))
8080
} else {
8181
defaultElasticSearchHost
8282
}
8383
case None => defaultElasticSearchHost
8484

8585
}
86-
lazy val instanceId : Option[Long] = InstanceRegistry.handleInstanceStart(configuration = this)
86+
lazy val instanceId: Option[Long] = InstanceRegistry.handleInstanceStart(configuration = this)
8787

8888
}
8989

src/main/scala/de/upb/cs/swt/delphi/webapi/SearchQuery.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package de.upb.cs.swt.delphi.webapi
1818

1919
import com.sksamuel.elastic4s.http.{ElasticClient, RequestSuccess}
20-
import de.upb.cs.swt.delphi.featuredefinitions.FeatureExtractor
21-
import de.upb.cs.swt.delphi.querylanguage._
20+
import de.upb.cs.swt.delphi.webapi.featuredefinitions.FeatureExtractor
21+
import de.upb.cs.swt.delphi.webapi.querylanguage._
2222
import com.sksamuel.elastic4s.http.ElasticDsl._
2323
import com.sksamuel.elastic4s.http.search.SearchHits
2424
import com.sksamuel.elastic4s.searches.queries.{NoopQuery, Query}
@@ -33,7 +33,11 @@ class SearchQuery(configuration: Configuration, featureExtractor: FeatureExtract
3333
val fields = collectFieldNames(ast)
3434
if (fields.diff(featureExtractor.featureList.toSeq).size > 0) return Failure(null)
3535

36-
val query = searchWithType(configuration.esProjectIndex) query translate(ast) sourceInclude (ArtifactTransformer.baseFields ++ fields.intersect(featureExtractor.featureList.toSeq).map(i => addPrefix(i)))
36+
val query = searchWithType(configuration.esProjectIndex)
37+
.query(translate(ast))
38+
.sourceInclude(ArtifactTransformer.baseFields ++ fields.intersect(featureExtractor.featureList.toSeq).map(i => addPrefix(i)))
39+
40+
3741

3842
val response = client.execute {
3943
query

src/main/scala/de/upb/cs/swt/delphi/webapi/Server.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import akka.http.scaladsl.model.{HttpResponse, StatusCodes}
2323
import akka.http.scaladsl.server.{HttpApp, Route}
2424
import akka.stream.ActorMaterializer
2525
import akka.util.Timeout
26-
import de.upb.cs.swt.delphi.featuredefinitions.{FeatureExtractor, FeatureListMapping}
26+
import de.upb.cs.swt.delphi.webapi.featuredefinitions.{FeatureExtractor, FeatureListMapping}
2727
import de.upb.cs.swt.delphi.instancemanagement.InstanceRegistry
2828
import spray.json._
2929
import de.upb.cs.swt.delphi.webapi.artifacts.ArtifactJson._

src/main/scala/de/upb/cs/swt/delphi/featuredefinitions/FeatureDescription.scala renamed to src/main/scala/de/upb/cs/swt/delphi/webapi/featuredefinitions/FeatureDescription.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
package de.upb.cs.swt.delphi.featuredefinitions
17+
package de.upb.cs.swt.delphi.webapi.featuredefinitions
1818

1919
//Describes all relevant fields for conducting searches on this class
2020
case class FeatureDescription(fType: String)

src/main/scala/de/upb/cs/swt/delphi/featuredefinitions/FeatureExtractor.scala renamed to src/main/scala/de/upb/cs/swt/delphi/webapi/featuredefinitions/FeatureExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
package de.upb.cs.swt.delphi.featuredefinitions
17+
package de.upb.cs.swt.delphi.webapi.featuredefinitions
1818

1919
import com.sksamuel.elastic4s.http.{ElasticClient, RequestSuccess}
2020
import com.sksamuel.elastic4s.http.ElasticDsl._

src/main/scala/de/upb/cs/swt/delphi/featuredefinitions/FeatureListMapping.scala renamed to src/main/scala/de/upb/cs/swt/delphi/webapi/featuredefinitions/FeatureListMapping.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
package de.upb.cs.swt.delphi.featuredefinitions
17+
package de.upb.cs.swt.delphi.webapi.featuredefinitions
1818

1919
object FeatureListMapping {
2020

src/main/scala/de/upb/cs/swt/delphi/querylanguage/AST.scala renamed to src/main/scala/de/upb/cs/swt/delphi/webapi/querylanguage/AST.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
package de.upb.cs.swt.delphi.querylanguage
17+
package de.upb.cs.swt.delphi.webapi.querylanguage
1818

1919
trait CombinatorialExpr
2020

src/main/scala/de/upb/cs/swt/delphi/querylanguage/Syntax.scala renamed to src/main/scala/de/upb/cs/swt/delphi/webapi/querylanguage/Syntax.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
package de.upb.cs.swt.delphi.querylanguage
17+
package de.upb.cs.swt.delphi.webapi.querylanguage
1818

1919
import org.parboiled2.{CharPredicate, Parser, ParserInput, Rule1}
2020

0 commit comments

Comments
 (0)