Skip to content
Snippets Groups Projects
Commit 4ba08039 authored by jaapjansma's avatar jaapjansma
Browse files

Added default configuration for data source

parent cee98cb7
No related branches found
No related tags found
No related merge requests found
......@@ -121,6 +121,10 @@ class CRM_Dataprocessor_Form_Source extends CRM_Core_Form {
$source = CRM_Dataprocessor_BAO_Source::getValues(array('id' => $this->id));
$values = $this->exportValues();
$factory = dataprocessor_get_factory();
$sourceClass = $factory->getDataSourceByName($values['type']);
if (!empty($values['name'])) {
$params['name'] = $values['name'];
} else {
......@@ -138,16 +142,18 @@ class CRM_Dataprocessor_Form_Source extends CRM_Core_Form {
}
if ($this->id) {
$params['id'] = $this->id;
} else {
$params['configuration'] = $sourceClass->getDefaultConfiguration();
}
if (isset($source[$this->id])) {
$params['join_configuration'] = $source[$this->id]['join_configuration'];
}
$result = CRM_Dataprocessor_BAO_Source::add($params);
$factory = dataprocessor_get_factory();
$configurationUrl = false;
$sourceClass = $factory->getDataSourceByName($values['type']);
if ($sourceClass->getConfigurationUrl()) {
$configurationUrl = CRM_Utils_System::url($sourceClass->getConfigurationUrl(), [
'reset' => 1,
......
......@@ -94,6 +94,15 @@ abstract class AbstractSource implements SourceInterface {
return $this;
}
/**
* Returns the default configuration for this data source
*
* @return array
*/
public function getDefaultConfiguration() {
return array();
}
/**
* @return \Civi\DataProcessor\DataFlow\AbstractDataFlow|\Civi\DataProcessor\DataFlow\AbstractDataFlow
* @throws \Exception
......
......@@ -58,6 +58,34 @@ class ActivitySource extends AbstractCivicrmEntitySource {
return 'civicrm_activity';
}
/**
* Returns the default configuration for this data source
*
* @return array
*/
public function getDefaultConfiguration() {
return array(
'filter' => array(
'is_current_revision' => array (
'op' => '=',
'value' => '1',
),
'is_deleted' => array (
'op' => '=',
'value' => '0',
),
'is_test' => array (
'op' => '=',
'value' => '0',
),
'activity_contact_record_type_id' => array (
'op' => 'IN',
'value' => array(3), // Activity Targets
)
)
);
}
/**
* @return \Civi\DataProcessor\DataFlow\SqlDataFlow
* @throws \Exception
......
......@@ -44,4 +44,20 @@ class ContactSource extends AbstractCivicrmEntitySource {
return $this->availableFilterFields;
}
/**
* Returns the default configuration for this data source
*
* @return array
*/
public function getDefaultConfiguration() {
return array(
'filter' => array(
'is_deleted' => array (
'op' => '=',
'value' => '0',
)
)
);
}
}
\ No newline at end of file
......@@ -51,6 +51,22 @@ class HouseholdSource extends AbstractCivicrmEntitySource {
return 'civicrm_contact';
}
/**
* Returns the default configuration for this data source
*
* @return array
*/
public function getDefaultConfiguration() {
return array(
'filter' => array(
'is_deleted' => array (
'op' => '=',
'value' => '0',
)
)
);
}
/**
* @return \Civi\DataProcessor\DataSpecification\DataSpecification
* @throws \Exception
......
......@@ -39,6 +39,26 @@ class IndividualSource extends AbstractCivicrmEntitySource {
return 'civicrm_contact';
}
/**
* Returns the default configuration for this data source
*
* @return array
*/
public function getDefaultConfiguration() {
return array(
'filter' => array(
'is_deleted' => array (
'op' => '=',
'value' => '0',
),
'is_deceased' => array(
'op' => '=',
'value' => '0',
),
)
);
}
/**
* @return \Civi\DataProcessor\DataSpecification\DataSpecification
* @throws \Exception
......
......@@ -47,6 +47,22 @@ class OrganizationSource extends AbstractCivicrmEntitySource {
return 'civicrm_contact';
}
/**
* Returns the default configuration for this data source
*
* @return array
*/
public function getDefaultConfiguration() {
return array(
'filter' => array(
'is_deleted' => array (
'op' => '=',
'value' => '0',
)
)
);
}
/**
* @return \Civi\DataProcessor\DataSpecification\DataSpecification
* @throws \Exception
......
......@@ -51,6 +51,13 @@ interface SourceInterface {
*/
public function setConfiguration($configuration);
/**
* Returns the default configuration for this data source
*
* @return array
*/
public function getDefaultConfiguration();
/**
* @return \Civi\DataProcessor\DataSpecification\DataSpecification
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment