Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/1.10' into 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Nov 22, 2016
2 parents f7093a4 + 639268e commit aca16d0
Show file tree
Hide file tree
Showing 35 changed files with 439 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function testGettersSetters()
$this->assertNull($entity->getOrganization());
$entity->setOrganization($organization);
$this->assertSame($organization, $entity->getOrganization());

}

public function testBeforeSave()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,14 @@ public function setStartDate($contact)

public function setEndDate()
{

}

public function setDescription()
{

}

public function setBudget()
{

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public function testBuildForm(array $entities, array $channels, callable $callba
}

$this->extension->buildForm($builder, ['entities' => $entities, 'single_channel_mode' => true]);

}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/OroCRM/Bundle/ContactBundle/Entity/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Oro\Bundle\UserBundle\Entity\User;

use OroCRM\Bundle\AccountBundle\Entity\Account;
use OroCRM\Bundle\ContactBundle\Entity\ContactAddress;
use OroCRM\Bundle\ContactBundle\Model\ExtendContact;

/**
Expand Down Expand Up @@ -1335,6 +1336,10 @@ public function setPrimaryPhone(ContactPhone $phone)
*/
public function addAddress(AbstractAddress $address)
{
if (!$address instanceof ContactAddress) {
throw new \InvalidArgumentException("Address must be instance of ContactAddress");
}

/** @var ContactAddress $address */
if (!$this->addresses->contains($address)) {
//don't allow more than one primary address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,3 @@ OroCRM\Bundle\ContactBundle\Entity\Group:
OroCRM\Bundle\ContactBundle\Entity\ContactAddress:
constraints:
- Oro\Bundle\AddressBundle\Validator\Constraints\ValidRegion: { groups: ['RequirePeriod'] }
properties:
street:
- NotBlank: ~
city:
- NotBlank: ~
postalCode:
- NotBlank: ~
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public function setAddressFirstName($value, $addressId = 0)
$addressFirstName->value($value);

return $this;

}

public function getAddressFirstName($addressId = 0)
Expand All @@ -169,7 +168,6 @@ public function setAddressLastName($value, $addressId = 0)
$addressLastName->value($value);

return $this;

}

public function getAddressLastName($addressId = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function up(Schema $schema, QueryBag $queries)
$table->removeForeignKey('FK_6F7A50CE427EB8A5');
$table->removeForeignKey('FK_6F7A50CE50A89B2C');
$schema->dropTable('orocrm_contactus_request_calls');

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public function loadReports()
}

$this->flush($this->em);

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function setContainer(ContainerInterface $container = null)
$this->group = $entityManager->getRepository('OroUserBundle:Group');
$this->user = $entityManager->getRepository('OroUserBundle:User');
$this->tagManager = $container->get('oro_tag.tag.manager');

}

public function load(ObjectManager $manager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function postAction($customerId)
} else {
$view = $this->view($this->getForm(), Codes::HTTP_BAD_REQUEST);
}

} else {
$view = $this->view($this->getForm(), Codes::HTTP_NOT_FOUND);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getConfigTreeBuilder()
)
->example('10 minutes')
->end()
->scalarNode('initial_import_step_interval')
->scalarNode('import_step_interval')
->defaultValue('7 days')
->cannotBeEmpty()
->info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function write(array $items)
$uniqueKeys[] = $identifier;
$uniqueItems[] = $item;
}

} else {
$uniqueItems[] = $item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function addInitialStatus(ChannelRepository $repository, Channel $inte
$now = new \DateTime('now', new \DateTimeZone('UTC'));

$status = new Status();
$status->setData([AbstractInitialProcessor::INITIAL_SYNCED_TO => $syncStartDate->format(\DateTime::ISO8601)]);
$status->setData([AbstractInitialProcessor::SYNCED_TO => $syncStartDate->format(\DateTime::ISO8601)]);
$status->setConnector($connector);
$status->setDate($now);
$status->setChannel($integration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function setVisitEventAssociationExtension(VisitEventAssociationExtension
*/
public function getMigrationVersion()
{
return 'v1_41_1';
return 'v1_41_2';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ public function up(Schema $schema, QueryBag $queries)
*/
public static function addActivityAssociations(Schema $schema, ActivityExtension $activityExtension)
{
$associationTableName = $activityExtension
->getAssociationTableName('oro_calendar_event', 'orocrm_magento_order');
$associationTableName = $activityExtension->getAssociationTableName(
'oro_calendar_event',
'orocrm_magento_order'
);
if (!$schema->hasTable($associationTableName)) {
$activityExtension->addActivityAssociation($schema, 'oro_calendar_event', 'orocrm_magento_order');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_41_2;

use Doctrine\DBAL\Schema\Schema;

use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension;
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtensionAwareInterface;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class CreateActivityAssociation implements Migration, ActivityExtensionAwareInterface
{
/** @var ActivityExtension */
protected $activityExtension;

/**
* {@inheritdoc}
*/
public function setActivityExtension(ActivityExtension $activityExtension)
{
$this->activityExtension = $activityExtension;
}

/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$associationTableName = $this->activityExtension->getAssociationTableName(
'oro_calendar_event',
'orocrm_magento_order'
);

if (!$schema->hasTable($associationTableName)) {
$this->activityExtension->addActivityAssociation($schema, 'oro_calendar_event', 'orocrm_magento_order');
}
}
}
102 changes: 1 addition & 101 deletions src/OroCRM/Bundle/MagentoBundle/Provider/AbstractInitialProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,14 @@
use Doctrine\ORM\EntityManager;

use Oro\Bundle\IntegrationBundle\Entity\Channel as Integration;
use Oro\Bundle\IntegrationBundle\Entity\Repository\ChannelRepository;
use Oro\Bundle\IntegrationBundle\Entity\Status;
use Oro\Bundle\IntegrationBundle\Provider\ConnectorInterface;
use Oro\Bundle\IntegrationBundle\Provider\SyncProcessor;

use OroCRM\Bundle\MagentoBundle\Entity\MagentoSoapTransport;
use OroCRM\Bundle\MagentoBundle\Provider\Connector\DictionaryConnectorInterface;

abstract class AbstractInitialProcessor extends SyncProcessor
abstract class AbstractInitialProcessor extends MagentoSyncProcessor
{
const INITIAL_SYNC_START_DATE = 'initialSyncStartDate';
const INITIAL_SYNCED_TO = 'initialSyncedTo';
const CONNECTORS_INITIAL_SYNCED_TO = 'connectorsInitialSyncedTo';
const START_SYNC_DATE = 'start_sync_date';
const SKIP_STATUS = 'skip';
const INTERVAL = 'initialSyncInterval';

/** @var string */
protected $channelClassName;

/**
* @param string $channelClassName
*/
public function setChannelClassName($channelClassName)
{
$this->channelClassName = $channelClassName;
}

/**
* @param Integration $integration
* @return \DateTime
*/
protected function getInitialSyncStartDate(Integration $integration)
{
if ($this->isInitialSyncStarted($integration)) {
/** @var MagentoSoapTransport $transport */
$transport = $integration->getTransport();

return $transport->getInitialSyncStartDate();
} else {
return new \DateTime('now', new \DateTimeZone('UTC'));
}
}

/**
* @param Integration $integration
* @return bool
*/
protected function isInitialSyncStarted(Integration $integration)
{
/** @var MagentoSoapTransport $transport */
$transport = $integration->getTransport();

return (bool)$transport->getInitialSyncStartDate();
}

/**
* @param object $entity
Expand All @@ -72,59 +25,6 @@ protected function saveEntity($entity)
$em->flush($entity);
}

/**
* @param Integration $integration
* @param string $connector
* @return bool|\DateTime
*/
protected function getSyncedTo(Integration $integration, $connector)
{
$lastStatus = $this->getLastStatusForConnector($integration, $connector, Status::STATUS_COMPLETED);
if ($lastStatus) {
$statusData = $lastStatus->getData();
if (!empty($statusData[self::INITIAL_SYNCED_TO])) {
return \DateTime::createFromFormat(
\DateTime::ISO8601,
$statusData[self::INITIAL_SYNCED_TO],
new \DateTimeZone('UTC')
);
}
}

return false;
}

/**
* @param Integration $integration
* @param string $connector
* @param int|null $code
* @return null|Status
*/
protected function getLastStatusForConnector(Integration $integration, $connector, $code = null)
{
$status = $this->getChannelRepository()->getLastStatusForConnector($integration, $connector, $code);
if ($status) {
$statusData = $status->getData();
if (!empty($statusData[self::SKIP_STATUS])) {
return null;
}
}

return $status;
}

/**
* @return ChannelRepository
*/
protected function getChannelRepository()
{
if (!$this->channelClassName) {
throw new \InvalidArgumentException('Channel class option is missing');
}

return $this->doctrineRegistry->getRepository($this->channelClassName);
}

/**
* @param Integration $integration
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ protected function initializeFromContext(ContextInterface $context)
$iterator->setSyncRange($interval);
}

$incrementalInterval = $executionContext->get(InitialSyncProcessor::INCREMENTAL_INTERVAL);
if ($incrementalInterval) {
$iterator->setSyncRange($incrementalInterval);
}

$minimalSyncDate = $executionContext->get(InitialSyncProcessor::START_SYNC_DATE);
if ($minimalSyncDate) {
$iterator->setMinSyncDate($minimalSyncDate);
Expand All @@ -173,7 +178,7 @@ protected function initializeFromContext(ContextInterface $context)
protected function getStartDate(Status $status = null)
{
$jobContext = $this->stepExecution->getJobExecution()->getExecutionContext();
$initialSyncedTo = $jobContext->get(InitialSyncProcessor::INITIAL_SYNCED_TO);
$initialSyncedTo = $jobContext->get(InitialSyncProcessor::SYNCED_TO);
if ($initialSyncedTo) {
return $initialSyncedTo;
}
Expand Down
Loading

0 comments on commit aca16d0

Please sign in to comment.