Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.0 #173

Merged
merged 13 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hotfix - API + APP - Filtra por campo de auto-relación (#168)
jortilles authored Jun 19, 2024
commit 273fa1d5d64f7e96852fe54af9215620c1deb045
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ export class MySqlBuilderService extends QueryBuilderService {
// JOINS
let joinString: any[];
let alias: any;
// joined == EDA2
if (this.queryTODO.joined) {
/**tree */
const responseJoins = this.setJoins(joinTree, joinType, schema, valueListJoins);
@@ -95,6 +96,9 @@ export class MySqlBuilderService extends QueryBuilderService {

filters.forEach(f => {
const column = this.findColumn(f.filter_table, f.filter_column);
column.autorelation = f.autorelation;
column.joins = f.joins;
column.valueListSource = f.valueListSource;
const colname = this.getFilterColname(column);
if (f.filter_type === 'not_null' || f.filter_type === 'not_null_nor_empty' || f.filter_type === 'null_or_empty') {
filtersString += '\nand ' + this.filterToString(f);
@@ -182,7 +186,6 @@ export class MySqlBuilderService extends QueryBuilderService {


public setJoins(joinTree: any[], joinType: string, schema: string, valueListJoins: string[]) {

// Inicialización de variables
const joinExists = new Set();
const aliasTables = {};
@@ -249,7 +252,7 @@ export class MySqlBuilderService extends QueryBuilderService {
}
}
}

return {
joinString,
aliasTables
@@ -273,7 +276,9 @@ export class MySqlBuilderService extends QueryBuilderService {
el.order !== 0 && el.table_id !== origin && !dest.includes(el.table_id) ? dest.push(el.table_id) : false;

let table_column;
if (el.autorelation && !el.valueListSource) {

if (el.autorelation && !el.valueListSource && !this.queryTODO.forSelector ) {

table_column = `\`${el.joins[el.joins.length-1][0]}\`.\`${el.column_name}\``;
} else {
table_column = `\`${el.table_id}\`.\`${el.column_name}\``;
@@ -410,9 +415,14 @@ export class MySqlBuilderService extends QueryBuilderService {
public filterToString(filterObject: any): any {
const column = this.findColumn(filterObject.filter_table, filterObject.filter_column);
const colType = filterObject.filter_column_type;

if (!column.hasOwnProperty('minimumFractionDigits')) {
column.minimumFractionDigits = 0;
}

column.autorelation = filterObject.autorelation;
column.joins = filterObject.joins || [];
column.valueListSource = filterObject.valueListSource;
const colname=this.getFilterColname(column);

switch (this.setFilterType(filterObject.filter_type)) {
@@ -451,7 +461,13 @@ export class MySqlBuilderService extends QueryBuilderService {
public getFilterColname(column: any){
let colname:String ;
if( column.computed_column == 'no' || ! column.hasOwnProperty('computed_column') ){
colname = `\`${column.table_id}\`.\`${column.column_name}\`` ;

if (column.autorelation && !column.valueListSource) {
colname = `\`${column.joins[column.joins.length-1][0]}\`.\`${column.column_name}\``;
} else {
colname = `\`${column.table_id}\`.\`${column.column_name}\`` ;
}

}else{
if(column.column_type == 'numeric'){
colname = `CAST( ${column.SQLexpression} as decimal(32,${column.minimumFractionDigits}))`;
@@ -475,8 +491,9 @@ export class MySqlBuilderService extends QueryBuilderService {
let filtersString = `\nhaving 1=1 `;

filters.forEach(f => {

const column = this.findHavingColumn(f.filter_table, f.filter_column);
column.autorelation = f.autorelation;
column.joins = f.joins;
const colname = this.getHavingColname(column);
if (f.filter_type === 'not_null') {
filtersString += `\nand ${colname} is not null `;
@@ -521,8 +538,14 @@ export class MySqlBuilderService extends QueryBuilderService {
*/
public getHavingColname(column: any){
let colname:String ;
if( column.computed_column === 'no' || ! column.hasOwnProperty('computed_column') ){
colname = `cast(${column.aggregation_type}(\`${column.table_id}\`.\`${column.column_name}\`) as decimal(32,${column.minimumFractionDigits||0}) ) ` ;
if( column.computed_column === 'no' || !column.hasOwnProperty('computed_column') ){
let table_id = column.table_id;

if (column.autorelation && !column.valueListSource) {
table_id = column.joins[column.joins.length-1][0];
}

colname = `cast(${column.aggregation_type}(\`${table_id}\`.\`${column.column_name}\`) as decimal(32,${column.minimumFractionDigits||0}) ) ` ;
}else{
if(column.column_type == 'numeric'){
colname = `CAST( ${column.SQLexpression} as decimal(32,${column.minimumFractionDigits}))`;
@@ -540,6 +563,8 @@ public getHavingColname(column: any){
*/
public havingToString(filterObject: any) {
const column = this.findHavingColumn(filterObject.filter_table, filterObject.filter_column);
column.autorelation = filterObject.autorelation;
column.joins = filterObject.joins;

if (!column.hasOwnProperty('minimumFractionDigits')) {
column.minimumFractionDigits = 0;
Original file line number Diff line number Diff line change
@@ -632,7 +632,7 @@ export abstract class QueryBuilderService {
}

public findHavingColumn(table: string, column: string) {
return this.queryTODO.fields.find((f: any)=> f.table_id === table.split('.')[0] && f.column_name === column);
return this.queryTODO.fields.find((f: any)=> f.table_id === table && f.column_name === column);
}

public setFilterType(filter: string) {
Original file line number Diff line number Diff line change
@@ -123,6 +123,7 @@ export class ColumnDialogComponent extends EdaDialogAbstract {
const selectedRange = this.filter.range;
const valueListSource = this.selectedColumn.valueListSource;
const joins = this.selectedColumn.joins;
const autorelation = this.selectedColumn.autorelation;

const filter = this.columnUtils.setFilter({
obj: this.filterValue,
@@ -132,6 +133,7 @@ export class ColumnDialogComponent extends EdaDialogAbstract {
type,
selectedRange,
valueListSource,
autorelation,
joins
});

Original file line number Diff line number Diff line change
@@ -72,13 +72,14 @@ export class FilterDialogComponent extends EdaDialogAbstract {
}

addFilter() {
const table = this.selectedColumn.table_id;
const table = this.selectedColumn.table_id;
const column_type = this.selectedColumn.column_type;
const column = this.selectedColumn.column_name;
const type = this.filterSelected.value;
const selectedRange = this.filter.range;
const valueListSource = this.selectedColumn.valueListSource;
const joins = this.selectedColumn.joins;
const autorelation = this.selectedColumn.autorelation;

const filter = this.columnUtils.setFilter({
obj: this.filterValue,
@@ -88,6 +89,7 @@ export class FilterDialogComponent extends EdaDialogAbstract {
type,
selectedRange,
valueListSource,
autorelation,
joins
});

Original file line number Diff line number Diff line change
@@ -187,6 +187,7 @@ export const PanelInteractionUtils = {
type: 'child',
label: childLabel,
child_id: child_id.trim(),
autorelation: relation.autorelation,
joins
};

Original file line number Diff line number Diff line change
@@ -311,10 +311,11 @@ export class GlobalFilterDialogComponent implements OnInit, OnDestroy {

public onNodeSelect(panel: any, event: any): void {
const node = event?.node;

const table_id = node.table_id || node.child_id;
const pathList = this.globalFilter.pathList;

if (this.globalFilter.selectedTable.table_name !== table_id.split('.')[0]) {
if (node.autorelation || this.globalFilter.selectedTable.table_name !== table_id.split('.')[0]) {
this.alertService.addWarning($localize`:@@invalidPathForm: Ruta incorrecta para el filtro seleccionado`);
setTimeout(() => {
pathList[panel.id].table_id = null;
@@ -324,6 +325,8 @@ export class GlobalFilterDialogComponent implements OnInit, OnDestroy {
pathList[panel.id].table_id = table_id;
pathList[panel.id].path = node.joins || [];

this.globalFilter.autorelation = node.autorelation;

if (!this.globalFilter.panelList.includes(panel.id)) {
this.globalFilter.panelList.push(panel.id);
}
2 changes: 2 additions & 0 deletions eda/eda_app/src/app/services/api/global-filters.service.ts
Original file line number Diff line number Diff line change
@@ -257,6 +257,7 @@ export class GlobalFiltersService {
child_id: child_id.trim(),
type: 'child',
label: childLabel,
autorelation: relation.autorelation,
joins
};

@@ -328,6 +329,7 @@ export class GlobalFiltersService {
pathList: pathList,
isGlobal: true,
applyToAll: globalFilter.applyToAll,
autorelation: globalFilter.autorelation,
valueListSource: globalFilter.selectedColumn.valueListSource
}

4 changes: 3 additions & 1 deletion eda/eda_app/src/app/services/utils/column-utils.service.ts
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ interface FilterOptions {
type: string;
selectedRange: string;
valueListSource?: {};
autorelation?: boolean;
joins?: any[];
}
@Injectable()
@@ -59,7 +60,7 @@ export class ColumnUtilsService {
}

public setFilter(options: FilterOptions): object {
const { obj, table, column, column_type, type, selectedRange, valueListSource, joins } = options;
const { obj, table, column, column_type, type, selectedRange, valueListSource, joins, autorelation } = options;

const values = Object.keys(obj).map((key) => {
if (!_.isNil(obj[key])) {
@@ -76,6 +77,7 @@ export class ColumnUtilsService {
filter_type: type,
filter_elements: values,
selectedRange: selectedRange,
autorelation,
joins
};