core: [ExternalTasks] When adding new step...

[ExternalTasks] When adding new step, state is always STARTED

Removing the state parameter when adding a new step, it is really set
implicitly to STARTED.

Change-Id: I16ad3d25d527360b8cfb9eaefc66569700a3e4b0
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=988087
Signed-off-by: Eli Mesika <emesika@redhat.com>
core: Underscores in tag names break tags

Fixing tag regular expression matching in TagHandler.
We are adding backslashes for the SQL search query but should remove
them when the regular expression is matched.

Change-Id: I0925cdba0ed34e3dc68a8396eca0b17589dfa853
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=949484
Signed-off-by: Eli Mesika <emesika@redhat.com>
core: [ExternalTasks] Cannot end existing job

Enable to set the JobId or Step Id as parameters to commands that are
not monitored but handle the External Job/Tasks :
EndExternalJobCommand
ClearExternalJobCommand
EndExternalStepCommand

Change-Id: I78f72cd619e32e5763f46391932ec70730a2b4b7
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=988094
Signed-off-by: Eli Mesika <emesika@redhat.com>
core:  QueryData2 generates slow SQL for...

QueryData2 generates slow SQL for AuditLog with no parameters

This patch fixes two issues
When the inner query condition of getting the events is empty it omits
the inner query.
i.e.
Instead of
SELECT * FROM (SELECT * FROM audit_log WHERE ( audit_log_id > 0 and
audit_log_id IN (SELECT audit_log.audit_log_id FROM  audit_log  ) and
not deleted)  ORDER BY audit_log_id DESC ,audit_log_id DESC ) as T1
OFFSET (1 -1) LIMIT 100

Perform:
SELECT * FROM (SELECT * FROM audit_log WHERE ( audit_log_id > 0 and not
deleted)  ORDER BY audit_log_id DESC ,audit_log_id DESC ) as T1 OFFSET
(1 -1) LIMIT 100;

In addition, this patch fixes the redundancy in the SORT , so final
query is :

SELECT * FROM (SELECT * FROM audit_log WHERE ( audit_log_id > 0 and not
deleted)  ORDER BY audit_log_id DESC) as T1 OFFSET
(1 -1) LIMIT 100;

Change-Id: Id148adcc734c5742548c74ea754fb70252155e34
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=960831
Signed-off-by: Eli Mesika <emesika@redhat.com>
core:[ExternalTasks] Cannot add sub-step under...

[ExternalTasks] Cannot add sub-step under existing (parent) step

1) Fixing mandatory parameters step.parentStep.id => parentStep.id
2) Adding handling to the add method to inject the step parent

Change-Id: Ibc610d6f295a688ceec1b038107c07d43390b431
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=988082
Signed-off-by: Eli Mesika <emesika@redhat.com>
core: Search query sortby return some wrongly...

Search query sortby return some wrongly sorted results

Adding explicitly "NULLS LAST" when DESC ORDER BY is used

This is the ORDER BY Syntax :

    ORDER BY sort_expression1 [ASC | DESC] [NULLS { FIRST | LAST }]
     [, sort_expression2 [ASC | DESC] [NULLS { FIRST | LAST }] ...]

The NULLS FIRST and NULLS LAST options can be used to determine whether
nulls appear before or after non-null values in the sort ordering. By
default, null values sort as if larger than any non-null value; that is,
NULLS FIRST is the default for DESC order, and NULLS LAST otherwise.

Change-Id: Ib1f25076ffe7c0c6e1dbd609f7b175c8c9e34ac5
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=962560
Signed-off-by: Eli Mesika <emesika@redhat.com>