fix import

This commit is contained in:
yuri
2015-04-10 11:49:42 +03:00
parent d83a19e316
commit 66fb7b4e81
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ class Import extends \Espo\Core\ORM\Repositories\RDB
case 'duplicates':
$part = "import_entity.is_duplicate = 1";
break;
case 'updates':
case 'updated':
$part = "import_entity.is_updated = 1";
break;
}
+11 -3
View File
@@ -218,7 +218,7 @@ class Import extends \Espo\Services\Record
if ($entity) {
$this->getEntityManager()->removeEntity($entity);
}
$this->getEntityManager()->getRepository($scope)->deleteFromDb($entityId);
$this->getEntityManager()->getRepository($entityType)->deleteFromDb($entityId);
}
$this->getEntityManager()->removeEntity($import);
@@ -347,6 +347,12 @@ class Import extends \Espo\Services\Record
$recordService = $this->getRecordService($scope);
$entity = $this->getEntityManager()->getEntity($scope, $id);
if (!$entity) {
$entity = $this->getEntityManager()->getEntity($scope);
$entity->set('id', $id);
}
$isNew = $entity->isNew();
$entity->set('assignedUserId', $this->getUser()->id);
@@ -469,10 +475,12 @@ class Import extends \Espo\Services\Record
$a = $entity->toArray();
try {
$isDuplicate = $recordService->checkEntityForDuplicate($entity);
if ($isNew) {
$isDuplicate = $recordService->checkEntityForDuplicate($entity);
}
if ($this->getEntityManager()->saveEntity($entity, array('noStream' => true, 'noNotifications' => true))) {
$result['id'] = $entity->id;
if (empty($id)) {
if ($isNew) {
$result['isImported'] = true;
if ($isDuplicate) {
$result['isDuplicate'] = true;