Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
WE.SpreadsheetImport
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Labels
Merge Requests
0
Merge Requests
0
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
packages
WE.SpreadsheetImport
Commits
c1d31909
Commit
c1d31909
authored
Oct 27, 2016
by
Chhengleap Soem
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'KIME-3603' into 'master'
[TASK] Correct importing queue order refs KIME-3603 See merge request
!3
parents
c6ecbfd1
d11970b3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
4 deletions
+33
-4
Classes/WE/SpreadsheetImport/Command/SpreadsheetImportCommandController.php
...heetImport/Command/SpreadsheetImportCommandController.php
+1
-1
Classes/WE/SpreadsheetImport/Domain/Repository/SpreadsheetImportRepository.php
...tImport/Domain/Repository/SpreadsheetImportRepository.php
+17
-1
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
+14
-0
Configuration/Settings.yaml
Configuration/Settings.yaml
+1
-0
Migrations/Mysql/Version20161026173055.php
Migrations/Mysql/Version20161026173055.php
+0
-2
No files found.
Classes/WE/SpreadsheetImport/Command/SpreadsheetImportCommandController.php
View file @
c1d31909
...
@@ -54,7 +54,7 @@ class SpreadsheetImportCommandController extends CommandController {
...
@@ -54,7 +54,7 @@ class SpreadsheetImportCommandController extends CommandController {
$this
->
quit
();
$this
->
quit
();
}
}
/** @var SpreadsheetImport $spreadsheetImport */
/** @var SpreadsheetImport $spreadsheetImport */
$spreadsheetImport
=
$this
->
spreadsheetImportRepository
->
find
OneByImportingStatus
(
SpreadsheetImport
::
IMPORTING_STATUS_IN_QUEUE
);
$spreadsheetImport
=
$this
->
spreadsheetImportRepository
->
find
PreviousOneInQueue
(
);
if
(
$spreadsheetImport
instanceof
SpreadsheetImport
)
{
if
(
$spreadsheetImport
instanceof
SpreadsheetImport
)
{
// mark importing status as "Progressing" before continuing the importing
// mark importing status as "Progressing" before continuing the importing
$spreadsheetImport
->
setImportingStatus
(
SpreadsheetImport
::
IMPORTING_STATUS_IN_PROGRESS
);
$spreadsheetImport
->
setImportingStatus
(
SpreadsheetImport
::
IMPORTING_STATUS_IN_PROGRESS
);
...
...
Classes/WE/SpreadsheetImport/Domain/Repository/SpreadsheetImportRepository.php
View file @
c1d31909
...
@@ -12,7 +12,9 @@ namespace WE\SpreadsheetImport\Domain\Repository;
...
@@ -12,7 +12,9 @@ namespace WE\SpreadsheetImport\Domain\Repository;
* */
* */
use
TYPO3\Flow\Annotations
as
Flow
;
use
TYPO3\Flow\Annotations
as
Flow
;
use
TYPO3\Flow\Persistence\QueryInterface
;
use
TYPO3\Flow\Persistence\Repository
;
use
TYPO3\Flow\Persistence\Repository
;
use
WE\SpreadsheetImport\Domain\Model\SpreadsheetImport
;
/**
/**
* @Flow\Scope("singleton")
* @Flow\Scope("singleton")
...
@@ -22,7 +24,21 @@ class SpreadsheetImportRepository extends Repository {
...
@@ -22,7 +24,21 @@ class SpreadsheetImportRepository extends Repository {
/**
/**
* @var array
* @var array
*/
*/
protected
$defaultOrderings
=
array
(
'scheduleDate'
=>
\TYPO3\Flow\Persistence\QueryInterface
::
ORDER_ASCENDING
);
protected
$defaultOrderings
=
array
(
'scheduleDate'
=>
QueryInterface
::
ORDER_DESCENDING
);
/**
* @return SpreadsheetImport
*/
public
function
findPreviousOneInQueue
()
{
$query
=
$this
->
createQuery
();
$constraint
=
$query
->
logicalAnd
(
$query
->
equals
(
'importingStatus'
,
SpreadsheetImport
::
IMPORTING_STATUS_IN_QUEUE
),
$query
->
lessThanOrEqual
(
'scheduleDate'
,
new
\DateTime
())
);
return
$query
->
matching
(
$constraint
)
->
setOrderings
(
array
(
'scheduleDate'
=>
QueryInterface
::
ORDER_ASCENDING
))
->
execute
()
->
getFirst
();
}
/**
/**
* @param \DateTime $dateTime
* @param \DateTime $dateTime
...
...
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
View file @
c1d31909
...
@@ -190,6 +190,8 @@ class SpreadsheetImportService {
...
@@ -190,6 +190,8 @@ class SpreadsheetImportService {
$identifierProperties
=
$this
->
getDomainMappingIdentifierProperties
();
$identifierProperties
=
$this
->
getDomainMappingIdentifierProperties
();
$file
=
$this
->
spreadsheetImport
->
getFile
()
->
createTemporaryLocalCopy
();
$file
=
$this
->
spreadsheetImport
->
getFile
()
->
createTemporaryLocalCopy
();
$reader
=
\PHPExcel_IOFactory
::
load
(
$file
);
$reader
=
\PHPExcel_IOFactory
::
load
(
$file
);
$numberOfRecordsToPersist
=
$this
->
settings
[
'numberOfRecordsToPersist'
];
$i
=
0
;
/** @var \PHPExcel_Worksheet_Row $row */
/** @var \PHPExcel_Worksheet_Row $row */
foreach
(
$reader
->
getActiveSheet
()
->
getRowIterator
(
2
)
as
$row
)
{
foreach
(
$reader
->
getActiveSheet
()
->
getRowIterator
(
2
)
as
$row
)
{
$object
=
$this
->
findObjectByIdentifierPropertiesPerRow
(
$identifierProperties
,
$row
);
$object
=
$this
->
findObjectByIdentifierPropertiesPerRow
(
$identifierProperties
,
$row
);
...
@@ -199,6 +201,7 @@ class SpreadsheetImportService {
...
@@ -199,6 +201,7 @@ class SpreadsheetImportService {
$this
->
setObjectPropertiesByRow
(
$object
,
$row
);
$this
->
setObjectPropertiesByRow
(
$object
,
$row
);
$objectRepository
->
update
(
$object
);
$objectRepository
->
update
(
$object
);
$totalUpdated
++
;
$totalUpdated
++
;
$i
++
;
}
else
{
}
else
{
$totalSkipped
++
;
$totalSkipped
++
;
}
}
...
@@ -208,17 +211,28 @@ class SpreadsheetImportService {
...
@@ -208,17 +211,28 @@ class SpreadsheetImportService {
$objectRepository
->
add
(
$newObject
);
$objectRepository
->
add
(
$newObject
);
$objectIds
[]
=
$this
->
persistenceManager
->
getIdentifierByObject
(
$newObject
);
$objectIds
[]
=
$this
->
persistenceManager
->
getIdentifierByObject
(
$newObject
);
$totalInserted
++
;
$totalInserted
++
;
$i
++
;
}
else
{
}
else
{
$totalSkipped
++
;
$totalSkipped
++
;
}
}
if
(
$i
>=
$numberOfRecordsToPersist
)
{
$this
->
persistenceManager
->
persistAll
();
$i
=
0
;
}
}
}
// remove objects which are not exist on the spreadsheet
// remove objects which are not exist on the spreadsheet
if
(
$this
->
spreadsheetImport
->
isDeleting
())
{
if
(
$this
->
spreadsheetImport
->
isDeleting
())
{
$notExistingObjects
=
$this
->
findObjectsByExcludedIds
(
$objectIds
);
$notExistingObjects
=
$this
->
findObjectsByExcludedIds
(
$objectIds
);
$i
=
0
;
foreach
(
$notExistingObjects
as
$object
)
{
foreach
(
$notExistingObjects
as
$object
)
{
$objectRepository
->
remove
(
$object
);
$objectRepository
->
remove
(
$object
);
$totalDeleted
++
;
$totalDeleted
++
;
$i
++
;
if
(
$i
>=
$numberOfRecordsToPersist
)
{
$this
->
persistenceManager
->
persistAll
();
$i
=
0
;
}
}
}
}
}
...
...
Configuration/Settings.yaml
View file @
c1d31909
WE
:
WE
:
SpreadsheetImport
:
SpreadsheetImport
:
cleanupImportFromPreviousDay
:
5
cleanupImportFromPreviousDay
:
5
numberOfRecordsToPersist
:
100
swisscomGrb
:
swisscomGrb
:
domain
:
WE\KIME\Domain\Model\User
domain
:
WE\KIME\Domain\Model\User
Configuration
:
Configuration
:
...
...
Migrations/Mysql/Version20161026173055.php
View file @
c1d31909
...
@@ -26,7 +26,6 @@ class Version20161026173055 extends AbstractMigration
...
@@ -26,7 +26,6 @@ class Version20161026173055 extends AbstractMigration
$this
->
abortIf
(
$this
->
connection
->
getDatabasePlatform
()
->
getName
()
!=
'mysql'
,
'Migration can only be executed safely on "mysql".'
);
$this
->
abortIf
(
$this
->
connection
->
getDatabasePlatform
()
->
getName
()
!=
'mysql'
,
'Migration can only be executed safely on "mysql".'
);
$this
->
addSql
(
'ALTER TABLE we_spreadsheetimport_domain_model_spreadsheetimport ADD arguments LONGTEXT NOT NULL'
);
$this
->
addSql
(
'ALTER TABLE we_spreadsheetimport_domain_model_spreadsheetimport ADD arguments LONGTEXT NOT NULL'
);
$this
->
addSql
(
'ALTER TABLE we_spreadsheetimport_domain_model_spreadsheetimport ADD CONSTRAINT FK_19518FA38C9F3610 FOREIGN KEY (file) REFERENCES typo3_flow_resource_resource (persistence_object_identifier)'
);
}
}
/**
/**
...
@@ -37,7 +36,6 @@ class Version20161026173055 extends AbstractMigration
...
@@ -37,7 +36,6 @@ class Version20161026173055 extends AbstractMigration
{
{
$this
->
abortIf
(
$this
->
connection
->
getDatabasePlatform
()
->
getName
()
!=
'mysql'
,
'Migration can only be executed safely on "mysql".'
);
$this
->
abortIf
(
$this
->
connection
->
getDatabasePlatform
()
->
getName
()
!=
'mysql'
,
'Migration can only be executed safely on "mysql".'
);
$this
->
addSql
(
'ALTER TABLE we_spreadsheetimport_domain_model_spreadsheetimport DROP FOREIGN KEY FK_19518FA38C9F3610'
);
$this
->
addSql
(
'ALTER TABLE we_spreadsheetimport_domain_model_spreadsheetimport DROP arguments'
);
$this
->
addSql
(
'ALTER TABLE we_spreadsheetimport_domain_model_spreadsheetimport DROP arguments'
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment