Skip to content

Commit

Permalink
Add the use of today date in the names of the indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandravv committed Apr 13, 2021
1 parent 18b2641 commit c7fe37d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.fhg.iese</groupId>
<artifactId>qrapids-eval</artifactId>
<version>2.0</version>
<version>2.1</version>
<name>qrapids-eval</name>
<description>Q-Rapids Evaluation</description>

Expand Down
4 changes: 4 additions & 0 deletions projects/default/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ sonarqube.measures.bcKey=de.fhg.iese.dd.platform.parent:platform-parent:master
sonarqube.issues.index=sonarqube.issues
sonarqube.issues.project=de.fhg.iese.dd.platform.parent:platform-parent:master

# metric beats index
# if index name contains date in YYYY.MM.dd format, use #TODAY# tag to specify it
metricsbeats.index=metricbeat-#TODAY#

########################
#### TARGET INDEXES ####
########################
Expand Down
51 changes: 13 additions & 38 deletions src/main/java/eval2/QueryDef.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eval2;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -35,35 +37,6 @@ public QueryDef( String name, Properties projectProperties, String queryTemplate
this.props = props;

}

/**
* Get properties as Map<String,Object>
* @return
*/
public Map<String,Object> getPropertiesMap() {

Map<String,Object> result = new HashMap<>();

for ( String propName : props.stringPropertyNames() ) {

String prop = props.getProperty(propName);

Object o;
// project variables start with "$$"
if ( prop.startsWith("$$") ) {
String projectPropertyKey = prop.substring(2);
String projectPropertyValue = projectProperties.getProperty(projectPropertyKey);
o = NumberUtils.getNumberOrString( projectPropertyValue );
} else {
o = NumberUtils.getNumberOrString(prop);
}

result.put( propName, o );
}

return result;
}


public String getQueryTemplate() {
return queryTemplate;
Expand All @@ -81,15 +54,17 @@ public String getProperty( String key ) {

String propValue = props.getProperty(key);

if ( propValue == null)
return null;

if ( propValue.startsWith("$$") ) {
return projectProperties.getProperty( propValue.substring(2) );
} else {
return propValue;
if ( propValue != null && propValue.startsWith("$$") ) {
String projectValue = projectProperties.getProperty( propValue.substring(2) );
if (projectValue != null && projectValue.contains("#TODAY#")){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY.MM.dd");
propValue = projectValue.replace("#TODAY#", LocalDate.now().format(formatter));
System.out.println("INDEX REFORMADO: " + propValue);
} else {
propValue = projectValue;
}
}

return propValue;
}

public Map<String,String> getResults() {
Expand All @@ -113,7 +88,7 @@ public Map<String,Object> getQueryParameter() {
Map<String,Object> parameter = new HashMap<>();

for ( String p : props.stringPropertyNames() ) {

//properties that correspond to parameters
if ( p.startsWith( prefix ) ) {

String resultName = p.substring(prefix.length());
Expand Down

0 comments on commit c7fe37d

Please sign in to comment.