Skip to content

Commit

Permalink
Merge pull request #351 from viz-centric/staging
Browse files Browse the repository at this point in the history
Threshold alert (#333)
  • Loading branch information
admin-vizcentric authored Dec 20, 2019
2 parents 7e03e60 + 12eb0bf commit b0b1306
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 57 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<dependency>
<groupId>com.project.bi</groupId>
<artifactId>flair-messages</artifactId>
<version>0.0.32</version>
<version>0.0.34</version>
</dependency>
<dependency>
<groupId>com.project.bi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private ScheduleReport toReportProto(SchedulerNotificationDTO dto) {
.setUserid(orEmpty(dto.getReport().getUserid()))
.setDashboardName(orEmpty(dto.getReport().getDashboard_name()))
.setViewName(orEmpty(dto.getReport().getView_name()))
.setViewId(orEmpty(String.valueOf(dto.getReport().getView_id())))
.setShareLink(orEmpty(dto.getReport().getShare_link()))
.setBuildUrl(orEmpty(dto.getReport().getBuild_url()))
.setMailBody(orEmpty(dto.getReport().getMail_body()))
Expand Down Expand Up @@ -250,6 +251,7 @@ private ScheduleReport toReportProto(SchedulerNotificationDTO dto) {
.build()
)
.setQuery(dto.getQuery())
.setConstraints(orEmpty(dto.getConstraints()))
.build();
}

Expand All @@ -272,6 +274,7 @@ private SchedulerNotificationDTO createSchedulerNotificationDTO(ScheduleReport s
report.setTitle_name(scheduleReport.getReport().getTitleName());
report.setUserid(scheduleReport.getReport().getUserid());
report.setView_name(scheduleReport.getReport().getViewName());
report.setView_id(Long.valueOf(scheduleReport.getReport().getViewId()));
report.setThresholdAlert(scheduleReport.getReport().getThresholdAlert());
responseDTO.setReport(report);
ReportLineItem reportLineItem = new ReportLineItem();
Expand Down Expand Up @@ -299,6 +302,7 @@ private SchedulerNotificationDTO createSchedulerNotificationDTO(ScheduleReport s
schedule.setStart_date(scheduleReport.getSchedule().getStartDate());
schedule.setTimezone(scheduleReport.getSchedule().getTimezone());
responseDTO.setSchedule(schedule);
responseDTO.setConstraints(scheduleReport.getConstraints());
return responseDTO;
}

Expand Down
29 changes: 22 additions & 7 deletions src/main/java/com/flair/bi/service/dto/scheduler/ReportDTO.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.flair.bi.service.dto.scheduler;

import lombok.Getter;
import lombok.Setter;

public class ReportDTO {

private String userid;
Expand All @@ -9,6 +12,8 @@ public class ReportDTO {
private String title_name;
private String dashboard_name;
private String view_name;
@Getter @Setter
private Long view_id;
private String share_link;
private String build_url;
private boolean thresholdAlert;
Expand Down Expand Up @@ -96,12 +101,22 @@ public void setThresholdAlert(boolean thresholdAlert) {
this.thresholdAlert = thresholdAlert;
}

@Override
public String toString() {
return "ReportDTO [userid=" + userid + ", mail_body=" + mail_body + ", subject=" + subject + ", report_name="
+ report_name + ", title_name=" + title_name + ", dashboard_name=" + dashboard_name + ", view_name="
+ view_name + ", share_link=" + share_link + ", build_url=" + build_url + ", thresholdAlert="
+ thresholdAlert + "]";
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("ReportDTO{");
sb.append("userid='").append(userid).append('\'');
sb.append(", mail_body='").append(mail_body).append('\'');
sb.append(", subject='").append(subject).append('\'');
sb.append(", report_name='").append(report_name).append('\'');
sb.append(", title_name='").append(title_name).append('\'');
sb.append(", dashboard_name='").append(dashboard_name).append('\'');
sb.append(", view_name='").append(view_name).append('\'');
sb.append(", view_id=").append(view_id);
sb.append(", share_link='").append(share_link).append('\'');
sb.append(", build_url='").append(build_url).append('\'');
sb.append(", thresholdAlert=").append(thresholdAlert);
sb.append('}');
return sb.toString();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.flair.bi.service.dto.scheduler;

import com.project.bi.query.dto.QueryDTO;
import lombok.Getter;
import lombok.Setter;


public class SchedulerDTO {
Expand All @@ -10,19 +12,23 @@ public class SchedulerDTO {
private ReportLineItem report_line_item;
private AssignReport assign_report;
private Schedule schedule;
@Getter @Setter
private String constraints;
private QueryDTO queryDTO;
private boolean putcall;
private boolean emailReporter;

public SchedulerDTO(){}

public SchedulerDTO(long datasourceid, ReportDTO report, ReportLineItem report_line_item,
AssignReport assign_report, Schedule schedule, QueryDTO queryDTO, boolean putcall, boolean emailReporter) {
AssignReport assign_report, Schedule schedule, QueryDTO queryDTO, boolean putcall, boolean emailReporter,
String constraints) {
super();
this.datasourceid = datasourceid;
this.report = report;
this.report_line_item = report_line_item;
this.assign_report = assign_report;
this.constraints = constraints;
this.schedule = schedule;
this.queryDTO = queryDTO;
this.putcall = putcall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class SchedulerNotificationDTO {
private AssignReport assign_report;
private Schedule schedule;
private String query;
private String constraints;
}
7 changes: 6 additions & 1 deletion src/main/java/com/flair/bi/web/rest/SchedulerResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ public ResponseEntity<SchedulerResponse> scheduleReport(@Valid @RequestBody Sche
schedulerDTO.getReport().setTitle_name(visualMetadata.getTitleProperties().getTitleText());
schedulerDTO.getReport_line_item().setVisualization(visualMetadata.getMetadataVisual().getName());
String query=schedulerService.buildQuery(schedulerDTO.getQueryDTO(),visualMetadata, datasource, schedulerDTO.getReport_line_item().getVisualizationid(), schedulerDTO.getReport().getUserid());
SchedulerNotificationDTO schedulerNotificationDTO= new SchedulerNotificationDTO(schedulerDTO.getReport(),schedulerDTO.getReport_line_item(),schedulerDTO.getAssign_report(),schedulerDTO.getSchedule(),query);
SchedulerNotificationDTO schedulerNotificationDTO= new SchedulerNotificationDTO(schedulerDTO.getReport(),
schedulerDTO.getReport_line_item(),
schedulerDTO.getAssign_report(),
schedulerDTO.getSchedule(),
query,
schedulerDTO.getConstraints());

schedulerService.setChannelCredentials(schedulerNotificationDTO);
log.info("Sending schedule report {}", schedulerNotificationDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@
}

function resetTimezone(startDate) {
var date = new Date(startDate);
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
return date;
return startDate;
}

function endOfDay(startDate) {
var date = new Date(startDate);
date.setHours(23, 59 - date.getTimezoneOffset(), 59);
date.setHours(23, 59, 59);
return date;
}

Expand Down Expand Up @@ -231,7 +229,8 @@
}
filterParameters[vm.dimension.name].push(tag['text']);
filterParameters[vm.dimension.name]._meta = {
dataType: vm.dimension.type
dataType: vm.dimension.type,
valueType: 'valueType'
};
filterParametersService.saveSelectedFilter(filterParameters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,72 @@
'@type': 'Compare',
comparatorType: 'GTE',
value: value,
valueType: {value: value, type: dataType, '@type': 'valueType'},
valueType: {
'@type': 'valueType',
value: value,
type: dataType
},
featureName: featureName
};
}

function createCompareExpressionBodyForInterval(value, featureName, interval, operator) {
return {
'@type': 'Compare',
comparatorType: 'GTE',
valueType: {
'@type': 'intervalValueType',
operator: operator,
interval: interval,
value: value
},
featureName: featureName
};
}

function createBodyExpr(values, name) {
var meta = values._meta || {};
var dataType = meta.dataType || '';
var valueType = meta.valueType || '';
if (name.lastIndexOf(dateRangePrefix, 0) === 0) {
setDatesInRightSideFilters(changeDateFormat(values[0]),changeDateFormat(values[1]));
values = [changeDateFormat(values[0]), changeDateFormat(values[1])];
name = name.split('|')[1];
setDatesInRightSideFilters(values[0], values[1]);
}
if (valueType === 'valueType') {
var dataType = meta.dataType || '';
console.log('value type values', values);
if (values.length === 2) {
return createBetweenExpressionBody(changeDateFormat(values[0]),changeDateFormat(values[1]),name.split('|')[1]);
return createBetweenExpressionBody(values[0], values[1], name, dataType);
} else {
return createCompareExpressionBody(values[0], name, dataType);
}
}else {
return createContainsExpressionBody(values, name);
} else if (valueType === 'intervalValueType') {
var operator = meta.operator;
var initialValue = meta.initialValue;
var value = values[0];
console.log('interval value type value', value, 'operator', operator, 'initialValue', initialValue);
return createCompareExpressionBodyForInterval(initialValue, name, value, operator);
}
return createContainsExpressionBody(values, name);
}

function getConditionExpression() {
function getConditionExpression(additionalFeaturesArray) {
var body;
var condition = {
expression: null
};
for (var name in paramObject) {
if (paramObject.hasOwnProperty(name)
&& paramObject[name]
&& paramObject[name].length > 0) {
var values = paramObject[name];
var finalParams = Object.assign({}, paramObject);
if (additionalFeaturesArray) {
for (var i in additionalFeaturesArray) {
var additionalFeaturesItem = additionalFeaturesArray[i];
finalParams = Object.assign(additionalFeaturesItem, finalParams);
}
}
for (var name in finalParams) {
if (finalParams.hasOwnProperty(name)
&& finalParams[name]
&& finalParams[name].length > 0) {
var values = finalParams[name];
if (!condition.expression) {
body = createBodyExpr(values, name);
condition = new ConditionExpression(CryptoService.UUIDv4, body);
Expand Down
Loading

0 comments on commit b0b1306

Please sign in to comment.