Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TheSmammy
dataprocessor
Commits
89c6ab60
Commit
89c6ab60
authored
Apr 21, 2020
by
jaapjansma
Browse files
Fix for issue #31 now tested and it seems to be working
parent
83252648
Changes
5
Hide whitespace changes
Inline
Side-by-side
Civi/DataProcessor/DataFlow/CombinedDataFlow/CombinedDataFlow.php
View file @
89c6ab60
...
...
@@ -8,10 +8,10 @@ namespace Civi\DataProcessor\DataFlow\CombinedDataFlow;
use
\
Civi\DataProcessor\DataFlow\AbstractDataFlow
;
use
\
Civi\DataProcessor\DataFlow\EndOfFlowException
;
use
Civi\DataProcessor\DataFlow\InvalidFlowException
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\JoinInterface
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\MultipleSourceDataFlows
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow
;
use
\
Civi\DataProcessor\DataSpecification\DataSpecification
;
...
...
@@ -66,6 +66,21 @@ class CombinedDataFlow extends AbstractDataFlow implements MultipleSourceDataFlo
$this
->
sourceDataFlowDescriptions
[]
=
$dataFlowDescription
;
}
/**
* Removes a source data flow
*
* @param \Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription $dataFlowDescription
* @return void
* @throws \Civi\DataProcessor\DataFlow\InvalidFlowException
*/
public
function
removeSourceDataFlow
(
DataFlowDescription
$dataFlowDescription
)
{
foreach
(
$this
->
sourceDataFlowDescriptions
as
$idx
=>
$sourceDataFlowDescription
)
{
if
(
$sourceDataFlowDescription
===
$dataFlowDescription
)
{
unset
(
$this
->
sourceDataFlowDescriptions
[
$idx
]);
}
}
}
/**
* @param \Civi\DataProcessor\FieldOutputHandler\AbstractFieldOutputHandler $outputFieldHandler[]
*/
...
...
Civi/DataProcessor/DataFlow/CombinedDataFlow/CombinedSqlDataFlow.php
View file @
89c6ab60
...
...
@@ -60,6 +60,24 @@ class CombinedSqlDataFlow extends SqlDataFlow implements MultipleSourceDataFlows
$this
->
sourceDataFlowDescriptions
[]
=
$dataFlowDescription
;
}
/**
* Removes a source data flow
*
* @param \Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription $dataFlowDescription
* @return void
* @throws \Civi\DataProcessor\DataFlow\InvalidFlowException
*/
public
function
removeSourceDataFlow
(
DataFlowDescription
$dataFlowDescription
)
{
if
(
!
$dataFlowDescription
->
getDataFlow
()
instanceof
SqlDataFlow
)
{
throw
new
InvalidFlowException
();
}
foreach
(
$this
->
sourceDataFlowDescriptions
as
$idx
=>
$sourceDataFlowDescription
)
{
if
(
$sourceDataFlowDescription
===
$dataFlowDescription
)
{
unset
(
$this
->
sourceDataFlowDescriptions
[
$idx
]);
}
}
}
/**
* Returns the Table part in the from statement.
*
...
...
Civi/DataProcessor/DataFlow/CombinedDataFlow/UnionQueryDataFlow.php
View file @
89c6ab60
...
...
@@ -46,6 +46,24 @@ class UnionQueryDataFlow extends SqlDataFlow implements MultipleSourceDataFlows
$this
->
sourceDataFlowDescriptions
[]
=
$dataFlowDescription
;
}
/**
* Removes a source data flow
*
* @param \Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription $dataFlowDescription
* @return void
* @throws \Civi\DataProcessor\DataFlow\InvalidFlowException
*/
public
function
removeSourceDataFlow
(
DataFlowDescription
$dataFlowDescription
)
{
if
(
!
$dataFlowDescription
->
getDataFlow
()
instanceof
SqlDataFlow
)
{
throw
new
InvalidFlowException
();
}
foreach
(
$this
->
sourceDataFlowDescriptions
as
$idx
=>
$sourceDataFlowDescription
)
{
if
(
$sourceDataFlowDescription
===
$dataFlowDescription
)
{
unset
(
$this
->
sourceDataFlowDescriptions
[
$idx
]);
}
}
}
public
function
getName
()
{
return
$this
->
name
;
}
...
...
Civi/DataProcessor/DataFlow/MultipleDataFlows/MultipleSourceDataFlows.php
View file @
89c6ab60
...
...
@@ -16,4 +16,12 @@ interface MultipleSourceDataFlows {
*/
public
function
addSourceDataFlow
(
DataFlowDescription
$dataFlowDescription
);
}
\ No newline at end of file
/**
* Removes a source data flow
*
* @param \Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription $dataFlowDescription
* @return void
*/
public
function
removeSourceDataFlow
(
DataFlowDescription
$dataFlowDescription
);
}
Civi/DataProcessor/Source/Contact/ACLContactSource.php
View file @
89c6ab60
...
...
@@ -7,6 +7,7 @@
namespace
Civi\DataProcessor\Source\Contact
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\MultipleSourceDataFlows
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\PureSqlStatementJoin
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\AndClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\OrClause
;
...
...
@@ -21,8 +22,10 @@ class ACLContactSource extends ContactSource {
*/
protected
$dataFlow
;
public
function
initialize
()
{
protected
$aclJoins
=
[];
protected
$aclWhereClause
=
null
;
public
function
initialize
()
{
$tables
=
array
();
$whereTables
=
array
();
$where
=
\
CRM_ACL_API
::
whereClause
(
\
CRM_ACL_API
::
VIEW
,
$tables
,
$whereTables
,
NULL
,
FALSE
,
TRUE
,
FALSE
);
...
...
@@ -48,12 +51,13 @@ class ACLContactSource extends ContactSource {
$joinCriteria
=
str_replace
(
'contact_a'
,
$this
->
primaryDataFlow
->
getName
(),
$joinCriteria
);
$join
=
new
PureSqlStatementJoin
(
' JOIN '
.
$tableAndAlias
.
' ON '
.
$joinCriteria
);
$this
->
additionalDataFlowDescriptions
[
$tableAndAlias
]
=
new
DataFlowDescription
(
$aclTable
,
$join
);
$this
->
aclJoins
[]
=
$tableAndAlias
;
}
protected
function
addAclWhere
(
$where
)
{
$where
=
str_replace
(
'contact_a'
,
$this
->
primaryDataFlow
->
getName
(),
$where
);
$
c
lause
=
new
PureSqlStatementClause
(
$where
);
$this
->
primaryDataFlow
->
addWhereClause
(
$
c
lause
);
$
this
->
aclWhereC
lause
=
new
PureSqlStatementClause
(
$where
);
$this
->
primaryDataFlow
->
addWhereClause
(
$
this
->
aclWhereC
lause
);
}
/**
...
...
@@ -98,10 +102,21 @@ class ACLContactSource extends ContactSource {
* @return void
*/
public
function
sourceLoadedFromCache
()
{
// reset the source. This completly looks up all the custom fields etc.. of this source
// ideally we only want to reset the aclWherePart.
$this
->
reset
();
$this
->
initialize
();
if
(
$this
->
primaryDataFlow
&&
$this
->
aclWhereClause
)
{
$this
->
primaryDataFlow
->
removeWhereClause
(
$this
->
aclWhereClause
);
}
$this
->
aclWhereClause
=
null
;
if
(
count
(
$this
->
aclJoins
))
{
foreach
(
$this
->
aclJoins
as
$tableAndAlias
)
{
if
(
isset
(
$this
->
additionalDataFlowDescriptions
[
$tableAndAlias
]))
{
if
(
$this
->
dataFlow
&&
$this
->
dataFlow
instanceof
MultipleSourceDataFlows
)
{
$this
->
dataFlow
->
removeSourceDataFlow
(
$this
->
additionalDataFlowDescriptions
[
$tableAndAlias
]);
}
unset
(
$this
->
additionalDataFlowDescriptions
[
$tableAndAlias
]);
}
}
$this
->
aclJoins
=
[];
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment