Skip to content
Snippets Groups Projects
Commit e607e691 authored by Alonso Ibarra, Juncal's avatar Alonso Ibarra, Juncal
Browse files

Adds ViolationsHandler m12

parent 335825a0
No related branches found
No related tags found
No related merge requests found
Showing
with 486 additions and 1 deletion
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eu.DECIDEh2020.adapt.violationhandler</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="eu.DECIDEh2020.adapt.violationhandler">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.5"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>
disabled=06target
eclipse.preferences.version=1
eclipse.preferences.version=1
org.jboss.ide.eclipse.as.core.singledeployable.deployableList=
<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>
<parent>
<groupId>es.experis</groupId>
<artifactId>decide</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>eu.DECIDEh2020</groupId>
<artifactId>violationhandler</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>es.experis</groupId>
<artifactId>decide-dbmodel</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
/*
* Copyright (c) 2017 Experis IT.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the
* MIT License which accompanies
* this distribution, and is available at
D1.1 Project Management and Quality Plan Version 1.0 – Final. Date: 28.02.2017
© DECIDE Consortium Contract No. GA 731533 Page 22 of 46
www.decide-h2020.eu
* https://opensource.org/licenses/MIT
*
* Contributors:
*
* Luis Silva - Experis IT
**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*/
package eu.DECIDEh2020.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("eu.DECIDEh2020.violationhandler")
public class ViolationHandlerConfig {
}
\ No newline at end of file
/*
* Copyright (c) 2017 Experis IT.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the
* MIT License which accompanies
* this distribution, and is available at
D1.1 Project Management and Quality Plan Version 1.0 Final. Date: 28.02.2017
DECIDE Consortium Contract No. GA 731533 Page 22 of 46
www.decide-h2020.eu
* https://opensource.org/licenses/MIT
*
* Contributors:
*
* Luis Silva - Experis IT
**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*/
package eu.DECIDEh2020.violationhandler;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class EvalMatch {
@SerializedName("metric")
@Expose
private String metric;
@SerializedName("tags")
@Expose
private Tags tags;
@SerializedName("value")
@Expose
private Integer value;
public String getMetric() {
return metric;
}
public void setMetric(String metric) {
this.metric = metric;
}
public EvalMatch withMetric(String metric) {
this.metric = metric;
return this;
}
public Tags getTags() {
return tags;
}
public void setTags(Tags tags) {
this.tags = tags;
}
public EvalMatch withTags(Tags tags) {
this.tags = tags;
return this;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public EvalMatch withValue(Integer value) {
this.value = value;
return this;
}
@Override
public String toString() {
return "EvalMatch ["
+ "\n metric=" + metric + "\n tags=" + tags.toString() + "\n value=" + value + "]";
}
}
/*
* Copyright (c) 2017 Experis IT.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the
* MIT License which accompanies
* this distribution, and is available at
D1.1 Project Management and Quality Plan Version 1.0 Final. Date: 28.02.2017
DECIDE Consortium Contract No. GA 731533 Page 22 of 46
www.decide-h2020.eu
* https://opensource.org/licenses/MIT
*
* Contributors:
*
* Luis Silva - Experis IT
**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*/
package eu.DECIDEh2020.violationhandler;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Grafanahook {
@SerializedName("title")
@Expose
private String title;
@SerializedName("ruleId")
@Expose
private Integer ruleId;
@SerializedName("ruleName")
@Expose
private String ruleName;
@SerializedName("ruleUrl")
@Expose
private String ruleUrl;
@SerializedName("state")
@Expose
private String state;
@SerializedName("imageUrl")
@Expose
private String imageUrl;
@SerializedName("message")
@Expose
private String message;
@SerializedName("evalMatches")
@Expose
private List<EvalMatch> evalMatches = null;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Grafanahook withTitle(String title) {
this.title = title;
return this;
}
public Integer getRuleId() {
return ruleId;
}
public void setRuleId(Integer ruleId) {
this.ruleId = ruleId;
}
public Grafanahook withRuleId(Integer ruleId) {
this.ruleId = ruleId;
return this;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public Grafanahook withRuleName(String ruleName) {
this.ruleName = ruleName;
return this;
}
public String getRuleUrl() {
return ruleUrl;
}
public void setRuleUrl(String ruleUrl) {
this.ruleUrl = ruleUrl;
}
public Grafanahook withRuleUrl(String ruleUrl) {
this.ruleUrl = ruleUrl;
return this;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Grafanahook withState(String state) {
this.state = state;
return this;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public Grafanahook withImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
return this;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Grafanahook withMessage(String message) {
this.message = message;
return this;
}
public List<EvalMatch> getEvalMatches() {
return evalMatches;
}
public void setEvalMatches(List<EvalMatch> evalMatches) {
this.evalMatches = evalMatches;
}
public Grafanahook withEvalMatches(List<EvalMatch> evalMatches) {
this.evalMatches = evalMatches;
return this;
}
@Override
public String toString() {
return "\ntitle=" + title + "\nruleId=" + ruleId + "\nruleName=" + ruleName + "\nruleUrl=" + ruleUrl
+ "\nstate=" + state + "\nimageUrl=" + imageUrl + "\nmessage=" + message + "\nevalMatches="
+ evalMatches.toString() + "]";
}
}
/*
* Copyright (c) 2017 Experis IT.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the
* MIT License which accompanies
* this distribution, and is available at
D1.1 Project Management and Quality Plan Version 1.0 – Final. Date: 28.02.2017
© DECIDE Consortium Contract No. GA 731533 Page 22 of 46
www.decide-h2020.eu
* https://opensource.org/licenses/MIT
*
* Contributors:
*
* Luis Silva - Experis IT
**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*/
package eu.DECIDEh2020.violationhandler;
public class Tags {
@Override
public String toString() {
return "Tags []";
}
}
/*
* Copyright (c) 2017 Experis IT.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the
* MIT License which accompanies
* this distribution, and is available at
D1.1 Project Management and Quality Plan Version 1.0 – Final. Date: 28.02.2017
© DECIDE Consortium Contract No. GA 731533 Page 22 of 46
www.decide-h2020.eu
* https://opensource.org/licenses/MIT
*
* Contributors:
*
* Luis Silva - Experis IT
**Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*/
package eu.DECIDEh2020.violationhandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import es.experis.decide.persist.dao.ViolationsDAO;
@Service
public class ViolationHandler {
@Autowired
private ViolationsDAO violationsDAO;
public String decision(Grafanahook AlertJSON)
{
String action = null;
String risk = null;
boolean result = violationsDAO.findAction(AlertJSON.getTitle().toString());
if (!result) {
return "Without Data";
} else {
if (result) {
risk = "High";
action = "Manual Simulation";
} else {
risk = "Low";
action = "Automatic Simulation";
}
return "RISK: " + risk +
"\nALERT DATA: " + AlertJSON.toString() +
"\nACTION: " + action ;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment