Commit 816fba30 authored by Dorel Butaciu's avatar Dorel Butaciu

upload projects

parent 79c132bf
/target
.classpath
.project
.settings
.idea
*.iml
pipeline {
agent any
tools {
maven 'maven3.6'
jdk 'jdk8'
}
stages {
stage ('Build Catalyst Data Model ') {
steps {
script {
String branchName = env.BRANCH_NAME.replaceAll("/", "%2F")
try{
build job: "catalyst-data-model-downstream/"+ branchName, propagate: true, wait: true
}catch(error) {
echo 'could not execute on ' + branchName
build job: "catalyst-data-model-downstream/master", propagate: true, wait: true
}
}
}
}
stage ('Build') {
steps {
sh '${M2_HOME}/bin/mvn --batch-mode -V -U -e clean verify -Dsurefire.useFile=false -Dmaven.test.failure.ignore'
}
}
stage ('Analysis') {
steps {
sh '${M2_HOME}/bin/mvn --batch-mode -V -U -e checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs spotbugs:spotbugs'
}
}
stage('Sonarqube') {
environment {
scannerHome = tool 'SonarQubeScanner'
}
steps {
withSonarQubeEnv('Sonar') {
sh ' mvn clean install sonar:sonar'
}
timeout(time: 10, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
}
}
}
}
}
pipeline {
agent any
tools {
maven 'maven3.6'
jdk 'jdk8'
}
stages {
stage ('Build') {
steps {
sh '${M2_HOME}/bin/mvn --batch-mode -V -U -e clean verify -Dsurefire.useFile=false -Dmaven.test.failure.ignore'
}
}
stage ('Analysis') {
steps {
sh '${M2_HOME}/bin/mvn --batch-mode -V -U -e checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs spotbugs:spotbugs'
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ro.tuc.dsrl.catalyst</groupId>
<artifactId>catalyst-ebb-service</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<name>catalyst-ebb-electric</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- <scope>runtime</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ro.tuc.dsrl.catalyst</groupId>
<artifactId>data-model</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>catalyst-ebb</warName>
</configuration>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.8-SNAPSHOT</version>
<dependencies>
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>3.1.8</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.11</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>target/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>target/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
sonar.projectKey=catalyst-ebb
sonar.host.url=http://193.226.5.80:9000
sonar.login=1efb585341252e4334505d39b6fe2c1d016a1ac3
sonar.language=java
sonar.java.binaries=**/target/classes
sonar.sources=src/main
package ro.tuc.dsrl.catalyst.ebbservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import java.util.TimeZone;
//@SpringBootApplication
//public class EbbServiceApplication {
// public static void main(String[] args) {
// SpringApplication.run(EbbServiceApplication.class, args);
// }
//}
@SpringBootApplication
public class EbbServiceApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(EbbServiceApplication.class);
}
public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
SpringApplication.run(EbbServiceApplication.class, args);
}
}
package ro.tuc.dsrl.catalyst.ebbservice;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@Configuration
public class ThreadConfig {
@Bean
public ScheduledThreadPoolExecutor threadPoolExecutor() {
return new ScheduledThreadPoolExecutor(10);
}
}
package ro.tuc.dsrl.catalyst.ebbservice.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ro.tuc.dsrl.catalyst.ebbservice.controller.preconditions.EnergyProfilePreconditions;
import ro.tuc.dsrl.catalyst.ebbservice.predictions.AlgorithmsBroker;
import ro.tuc.dsrl.catalyst.model.dto.EnergyProfileDTO;
import ro.tuc.dsrl.catalyst.model.enums.*;
import ro.tuc.dsrl.catalyst.model.utils.DateUtils;
import java.util.UUID;
@RestController
@RequestMapping("/electrical/prediction")
public class EnergyPredictionController {
private final AlgorithmsBroker algorithmsBroker;
@Autowired
public EnergyPredictionController(AlgorithmsBroker algorithmsBroker) {
this.algorithmsBroker = algorithmsBroker;
}
@GetMapping(value =
"/{data-scenario}/{prediction-type}/{flexibility-type}/{granularity}/{dataCenterID}/entireDC/{startTime}")
public EnergyProfileDTO getEnergyPredictionForEntireDC(
@PathVariable("data-scenario") String dataScenario,
@PathVariable("prediction-type") String predictionType,
@PathVariable ("flexibility-type") String flexibilityType,
@PathVariable("granularity") String granularity,
@PathVariable("dataCenterID") String dataCenterID,
@PathVariable("startTime") Long startTime) {
EnergyProfilePreconditions.validateDatacenter(dataScenario, predictionType, flexibilityType, granularity,
dataCenterID, startTime);
return algorithmsBroker.computeEnergyPrediction(
DataScenario.getDataScenario(dataScenario),
PredictionType.setType(predictionType),
PredictionGranularity.valueOf(granularity.toUpperCase()),
UUID.fromString(dataCenterID),
TopologyComponentType.DATACENTER,
UUID.fromString(dataCenterID),
DateUtils.millisToLocalDateTime(startTime),
FlexibilityType.setType(flexibilityType));
}
/* TODO: we can write only a single method
we do not use componentID when retrieving data
- use only a single method!
- delete endTime and componentID*/
@GetMapping(value = "/{data-scenario}/{prediction-type}/{flexibility-type}/{granularity}/{dataCenterID}/{component-type}/{component-id}/{startTime}/{endTime}")
public EnergyProfileDTO getEnergyPredictionForComponent(
@PathVariable("data-scenario") String dataScenario,
@PathVariable("prediction-type") String predictionType,
@PathVariable("flexibility-type") String flexibilityType,
@PathVariable("granularity") String granularity,
@PathVariable("dataCenterID") String dataCenterID,
@PathVariable("component-type") String componentType,
@PathVariable("component-id") String componentID,
@PathVariable("startTime") Long startTime) {
EnergyProfilePreconditions.validateComponent(dataScenario, granularity, dataCenterID, componentType,
componentID, startTime);
return algorithmsBroker.computeEnergyPrediction(
DataScenario.getDataScenario(dataScenario),
PredictionType.setType(predictionType),
PredictionGranularity.valueOf(granularity.toUpperCase()),
UUID.fromString(dataCenterID),
TopologyComponentType.setType(componentType),
UUID.fromString(componentID),
DateUtils.millisToLocalDateTime(startTime),
FlexibilityType.setType(flexibilityType));
}
}
package ro.tuc.dsrl.catalyst.ebbservice.controller.preconditions;
import ro.tuc.dsrl.catalyst.model.enums.DataScenario;
import ro.tuc.dsrl.catalyst.model.enums.FlexibilityType;
import ro.tuc.dsrl.catalyst.model.enums.PredictionType;
import ro.tuc.dsrl.catalyst.model.error_handler.ErrorMessageConstants;
import ro.tuc.dsrl.catalyst.model.error_handler.IncorrectParameterException;
import javax.xml.crypto.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class EnergyProfilePreconditions {
private EnergyProfilePreconditions() {
}
public static void validateDatacenter(String dataScenario, String predictionType, String flexibilityType,
String granularity, String dataCenterID, Long startTime) {
List<String> errors = new ArrayList<>();