Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dataprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
dataprocessor
Commits
d19bd10d
Commit
d19bd10d
authored
5 years ago
by
sarvesh21
Browse files
Options
Downloads
Patches
Plain Diff
adding soft contributions
parent
745a88bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!29
Adding Soft Contributions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Civi/DataProcessor/Source/Contribution/ContributionSource.php
+115
-0
115 additions, 0 deletions
.../DataProcessor/Source/Contribution/ContributionSource.php
with
115 additions
and
0 deletions
Civi/DataProcessor/Source/Contribution/ContributionSource.php
+
115
−
0
View file @
d19bd10d
...
@@ -6,12 +6,43 @@
...
@@ -6,12 +6,43 @@
namespace
Civi\DataProcessor\Source\Contribution
;
namespace
Civi\DataProcessor\Source\Contribution
;
use
Civi\DataProcessor\DataFlow\CombinedDataFlow\CombinedSqlDataFlow
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\SimpleJoin
;
use
Civi\DataProcessor\DataFlow\CombinedDataFlow\SubqueryDataFlow
;
use
Civi\DataProcessor\DataFlow\SqlTableDataFlow
;
use
Civi\DataProcessor\DataSpecification\DataSpecification
;
use
Civi\DataProcessor\Source\AbstractCivicrmEntitySource
;
use
Civi\DataProcessor\Source\AbstractCivicrmEntitySource
;
use
Civi\DataProcessor\DataSpecification\Utils
as
DataSpecificationUtils
;
use
CRM_Dataprocessor_ExtensionUtil
as
E
;
use
CRM_Dataprocessor_ExtensionUtil
as
E
;
class
ContributionSource
extends
AbstractCivicrmEntitySource
{
class
ContributionSource
extends
AbstractCivicrmEntitySource
{
/**
* @var SqlTableDataFlow
*/
protected
$contributionDataFlow
;
/**
* @var SqlTableDataFlow
*/
protected
$contributionSoftDataFlow
;
public
function
__construct
()
{
parent
::
__construct
();
// Create the contribution data flow and data flow description
$this
->
contributionDataFlow
=
new
SqlTableDataFlow
(
$this
->
getTable
(),
$this
->
getSourceName
()
.
'_contribution'
,
$this
->
getSourceTitle
());
DataSpecificationUtils
::
addDAOFieldsToDataSpecification
(
'CRM_Contribute_DAO_Contribution'
,
$this
->
contributionDataFlow
->
getDataSpecification
());
// Create the contribution soft data flow and data flow description
$this
->
contributionSoftDataFlow
=
new
SqlTableDataFlow
(
'civicrm_contribution_soft'
,
$this
->
getSourceName
()
.
'_contribution_soft'
);
DataSpecificationUtils
::
addDAOFieldsToDataSpecification
(
'CRM_Contribute_DAO_ContributionSoft'
,
$this
->
contributionSoftDataFlow
->
getDataSpecification
(),
array
(
'id'
),
''
,
'contribution_soft_'
,
E
::
ts
(
'Soft :: '
));
}
/**
/**
* Returns the entity name
* Returns the entity name
*
*
...
@@ -29,4 +60,88 @@ class ContributionSource extends AbstractCivicrmEntitySource {
...
@@ -29,4 +60,88 @@ class ContributionSource extends AbstractCivicrmEntitySource {
protected
function
getTable
()
{
protected
function
getTable
()
{
return
'civicrm_contribution'
;
return
'civicrm_contribution'
;
}
}
/**
* Initialize this data source.
*
* @throws \Exception
*/
public
function
initialize
()
{
if
(
!
$this
->
primaryDataFlow
)
{
$this
->
primaryDataFlow
=
$this
->
getEntityDataFlow
();
}
$this
->
addFilters
(
$this
->
configuration
);
if
(
count
(
$this
->
customGroupDataFlowDescriptions
)
||
count
(
$this
->
additionalDataFlowDescriptions
))
{
$this
->
dataFlow
=
new
CombinedSqlDataFlow
(
''
,
$this
->
primaryDataFlow
->
getPrimaryTable
(),
$this
->
contributionDataFlow
->
getTableAlias
());
$this
->
dataFlow
->
addSourceDataFlow
(
new
DataFlowDescription
(
$this
->
primaryDataFlow
));
foreach
(
$this
->
additionalDataFlowDescriptions
as
$additionalDataFlowDescription
)
{
$this
->
dataFlow
->
addSourceDataFlow
(
$additionalDataFlowDescription
);
}
foreach
(
$this
->
customGroupDataFlowDescriptions
as
$customGroupDataFlowDescription
)
{
$this
->
dataFlow
->
addSourceDataFlow
(
$customGroupDataFlowDescription
);
}
}
else
{
$this
->
dataFlow
=
$this
->
primaryDataFlow
;
}
}
/**
* @return \Civi\DataProcessor\DataFlow\SqlDataFlow
* @throws \Exception
*/
protected
function
getEntityDataFlow
()
{
$contributionDataDescription
=
new
DataFlowDescription
(
$this
->
contributionDataFlow
);
$join
=
new
SimpleJoin
(
$this
->
contributionDataFlow
->
getTableAlias
(),
'id'
,
$this
->
contributionSoftDataFlow
->
getTableAlias
(),
'contribution_id'
);
$join
->
setDataProcessor
(
$this
->
dataProcessor
);
$contributionSoftDataDescription
=
new
DataFlowDescription
(
$this
->
contributionSoftDataFlow
,
$join
);
// Create the subquery data flow
$entityDataFlow
=
new
SubqueryDataFlow
(
$this
->
getSourceName
(),
$this
->
getTable
(),
$this
->
getSourceName
());
$entityDataFlow
->
addSourceDataFlow
(
$contributionDataDescription
);
$entityDataFlow
->
addSourceDataFlow
(
$contributionSoftDataDescription
);
return
$entityDataFlow
;
}
/**
* Ensure that the entity table is added the to the data flow.
*
* @return \Civi\DataProcessor\DataFlow\AbstractDataFlow
* @throws \Exception
*/
protected
function
ensureEntity
()
{
if
(
$this
->
primaryDataFlow
&&
$this
->
primaryDataFlow
instanceof
SubqueryDataFlow
&&
$this
->
primaryDataFlow
->
getPrimaryTable
()
===
$this
->
getTable
())
{
return
$this
->
primaryDataFlow
;
}
elseif
(
empty
(
$this
->
primaryDataFlow
))
{
$this
->
primaryDataFlow
=
$this
->
getEntityDataFlow
();
return
$this
->
primaryDataFlow
;
}
foreach
(
$this
->
additionalDataFlowDescriptions
as
$additionalDataFlowDescription
)
{
if
(
$additionalDataFlowDescription
->
getDataFlow
()
->
getTable
()
==
$this
->
getTable
())
{
return
$additionalDataFlowDescription
->
getDataFlow
();
}
}
$entityDataFlow
=
$this
->
getEntityDataFlow
();
$join
=
new
SimpleJoin
(
$this
->
getSourceName
(),
'id'
,
$this
->
getSourceName
(),
'entity_id'
,
'LEFT'
);
$join
->
setDataProcessor
(
$this
->
dataProcessor
);
$additionalDataFlowDescription
=
new
DataFlowDescription
(
$entityDataFlow
,
$join
);
$this
->
additionalDataFlowDescriptions
[]
=
$additionalDataFlowDescription
;
return
$additionalDataFlowDescription
->
getDataFlow
();
}
/**
* Load the fields from this entity.
*
* @param DataSpecification $dataSpecification
* @throws \Civi\DataProcessor\DataSpecification\FieldExistsException
*/
protected
function
loadFields
(
DataSpecification
$dataSpecification
,
$fieldsToSkip
=
array
())
{
$daoClass
=
\CRM_Core_DAO_AllCoreTables
::
getFullName
(
$this
->
getEntity
());
$aliasPrefix
=
$this
->
getSourceName
()
.
'_'
;
DataSpecificationUtils
::
addDAOFieldsToDataSpecification
(
$daoClass
,
$dataSpecification
,
$fieldsToSkip
,
''
,
$aliasPrefix
);
DataSpecificationUtils
::
addDAOFieldsToDataSpecification
(
'CRM_Contribute_DAO_ContributionSoft'
,
$dataSpecification
,
array
(
'id'
,
'contribution_id'
),
'contribution_soft_'
,
$aliasPrefix
,
E
::
ts
(
'Soft :: '
));
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment