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
952ceece
Commit
952ceece
authored
5 years ago
by
jaapjansma
Browse files
Options
Downloads
Patches
Plain Diff
Added location to event data source
parent
7dae749f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Civi/DataProcessor/Source/Event/EventSource.php
+83
-0
83 additions, 0 deletions
Civi/DataProcessor/Source/Event/EventSource.php
with
83 additions
and
0 deletions
Civi/DataProcessor/Source/Event/EventSource.php
+
83
−
0
View file @
952ceece
...
...
@@ -6,12 +6,23 @@
namespace
Civi\DataProcessor\Source\Event
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\SimpleNonRequiredJoin
;
use
Civi\DataProcessor\DataFlow\SqlTableDataFlow
;
use
Civi\DataProcessor\DataSpecification\DataSpecification
;
use
Civi\DataProcessor\DataSpecification\FieldSpecification
;
use
Civi\DataProcessor\DataSpecification\Utils
;
use
Civi\DataProcessor\Source\AbstractCivicrmEntitySource
;
use
CRM_Dataprocessor_ExtensionUtil
as
E
;
class
EventSource
extends
AbstractCivicrmEntitySource
{
/**
* @var SqlTableDataFlow
*/
protected
$locBlockDataFlow
;
/**
* Returns the entity name
*
...
...
@@ -30,4 +41,76 @@ class EventSource extends AbstractCivicrmEntitySource {
return
'civicrm_event'
;
}
/**
* Load the fields from this entity.
*
* @param DataSpecification $dataSpecification
* @throws \Civi\DataProcessor\DataSpecification\FieldExistsException
*/
protected
function
loadFields
(
DataSpecification
$dataSpecification
,
$fieldsToSkip
=
array
())
{
parent
::
loadFields
(
$dataSpecification
,
$fieldsToSkip
);
// Add the location block fields.
$daoClass
=
\CRM_Core_DAO_AllCoreTables
::
getFullName
(
'LocBlock'
);
$aliasPrefix
=
$this
->
getSourceName
()
.
'_locblock_'
;
Utils
::
addDAOFieldsToDataSpecification
(
$daoClass
,
$dataSpecification
,
array
(
'id'
),
''
,
$aliasPrefix
);
}
/**
* Ensure that the entity table is added the to the data flow.
*
* @return \Civi\DataProcessor\DataFlow\AbstractDataFlow
* @throws \Exception
*/
protected
function
ensureEntity
()
{
$dataFlow
=
parent
::
ensureEntity
();
$locBlockDataFlowFound
=
false
;
foreach
(
$this
->
additionalDataFlowDescriptions
as
$descriptor
)
{
if
(
$descriptor
->
getDataFlow
()
->
getName
()
==
$this
->
getSourceName
()
.
'_locblock'
)
{
$locBlockDataFlowFound
=
true
;
}
}
if
(
!
$locBlockDataFlowFound
)
{
$this
->
locBlockDataFlow
=
new
SqlTableDataFlow
(
'civicrm_loc_block'
,
$this
->
getSourceName
()
.
'_locblock'
);
$join
=
new
SimpleNonRequiredJoin
(
$this
->
primaryDataFlow
->
getName
(),
'loc_block_id'
,
$this
->
getSourceName
()
.
'_locblock'
,
'id'
);
$join
->
setDataProcessor
(
$this
->
dataProcessor
);
$this
->
additionalDataFlowDescriptions
[]
=
new
DataFlowDescription
(
$this
->
locBlockDataFlow
,
$join
);
}
return
$dataFlow
;
}
/**
* Ensure that filter field is accesible in the query
*
* @param String $fieldName
* @return \Civi\DataProcessor\DataFlow\AbstractDataFlow|null
* @throws \Exception
*/
public
function
ensureField
(
$fieldName
)
{
if
(
$this
->
getAvailableFilterFields
()
->
doesFieldExist
(
$fieldName
))
{
$spec
=
$this
->
getAvailableFilterFields
()
->
getFieldSpecificationByName
(
$fieldName
);
if
(
stripos
(
$spec
->
alias
,
$this
->
getSourceName
()
.
'_locblock_'
)
===
0
)
{
$this
->
ensureEntity
();
return
$this
->
locBlockDataFlow
;
}
}
return
parent
::
ensureField
(
$fieldName
);
}
/**
* Ensures a field is in the data source
*
* @param \Civi\DataProcessor\DataSpecification\FieldSpecification $fieldSpecification
* @return SourceInterface
* @throws \Exception
*/
public
function
ensureFieldInSource
(
FieldSpecification
$fieldSpecification
)
{
if
(
stripos
(
$fieldSpecification
->
alias
,
$this
->
getSourceName
()
.
'_locblock_'
)
===
0
)
{
$this
->
ensureEntity
();
$this
->
locBlockDataFlow
->
getDataSpecification
()
->
addFieldSpecification
(
$fieldSpecification
);
}
else
{
parent
::
ensureFieldInSource
(
$fieldSpecification
);
}
}
}
\ 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