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
ecb96f98
Commit
ecb96f98
authored
Oct 31, 2016
by
Simon Gadient
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IMP] Max records limitation for preview
refs KIME-4583
parent
f95f2ec3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
Classes/WE/SpreadsheetImport/FrontendMappingService.php
Classes/WE/SpreadsheetImport/FrontendMappingService.php
+1
-0
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
+25
-9
No files found.
Classes/WE/SpreadsheetImport/FrontendMappingService.php
View file @
ecb96f98
...
@@ -99,6 +99,7 @@ class FrontendMappingService {
...
@@ -99,6 +99,7 @@ class FrontendMappingService {
* @return array
* @return array
*/
*/
public
function
getMappingPreview
(
$mapping
,
$record
)
{
public
function
getMappingPreview
(
$mapping
,
$record
)
{
$record
=
max
(
$record
,
1
);
$previewObject
=
$this
->
spreadsheetImportService
->
getObjectByRow
(
$record
);
$previewObject
=
$this
->
spreadsheetImportService
->
getObjectByRow
(
$record
);
$preview
=
array
();
$preview
=
array
();
foreach
(
$mapping
as
$property
=>
$columnMapping
)
{
foreach
(
$mapping
as
$property
=>
$columnMapping
)
{
...
...
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
View file @
ecb96f98
...
@@ -99,14 +99,22 @@ class SpreadsheetImportService {
...
@@ -99,14 +99,22 @@ class SpreadsheetImportService {
return
$mappingPropertyAnnotations
;
return
$mappingPropertyAnnotations
;
}
}
/**
* @return array
*/
public
function
getTotalRecords
()
{
$sheet
=
$this
->
getFileActiveSheet
();
$highestColumn
=
$sheet
->
getHighestDataRow
();
return
$highestColumn
-
1
;
}
/**
/**
* @return array
* @return array
*/
*/
public
function
getSpreadsheetColumns
()
{
public
function
getSpreadsheetColumns
()
{
$columns
=
array
();
$columns
=
array
();
$file
=
$this
->
spreadsheetImport
->
getFile
()
->
createTemporaryLocalCopy
();
$sheet
=
$this
->
getFileActiveSheet
();
$reader
=
\PHPExcel_IOFactory
::
load
(
$file
);
$sheet
=
$reader
->
getActiveSheet
();
$highestColumn
=
$sheet
->
getHighestDataColumn
();
$highestColumn
=
$sheet
->
getHighestDataColumn
();
$row
=
$sheet
->
getRowIterator
(
1
,
1
)
->
current
();
$row
=
$sheet
->
getRowIterator
(
1
,
1
)
->
current
();
$cellIterator
=
$row
->
getCellIterator
();
$cellIterator
=
$row
->
getCellIterator
();
...
@@ -130,9 +138,8 @@ class SpreadsheetImportService {
...
@@ -130,9 +138,8 @@ class SpreadsheetImportService {
$domain
=
$this
->
domain
;
$domain
=
$this
->
domain
;
$newObject
=
new
$domain
;
$newObject
=
new
$domain
;
// Plus one to skip the headings
// Plus one to skip the headings
$file
=
$this
->
spreadsheetImport
->
getFile
()
->
createTemporaryLocalCopy
();
$sheet
=
$this
->
getFileActiveSheet
();
$reader
=
\PHPExcel_IOFactory
::
load
(
$file
);
$row
=
$sheet
->
getRowIterator
(
$number
+
1
,
$number
+
1
)
->
current
();
$row
=
$reader
->
getActiveSheet
()
->
getRowIterator
(
$number
+
1
,
$number
+
1
)
->
current
();
$this
->
setObjectPropertiesByRow
(
$newObject
,
$row
);
$this
->
setObjectPropertiesByRow
(
$newObject
,
$row
);
return
$newObject
;
return
$newObject
;
}
}
...
@@ -150,12 +157,11 @@ class SpreadsheetImportService {
...
@@ -150,12 +157,11 @@ class SpreadsheetImportService {
$objectRepository
=
$this
->
getDomainRepository
();
$objectRepository
=
$this
->
getDomainRepository
();
$objectValidator
=
$this
->
validatorResolver
->
getBaseValidatorConjunction
(
$domain
);
$objectValidator
=
$this
->
validatorResolver
->
getBaseValidatorConjunction
(
$domain
);
$identifierProperties
=
$this
->
getDomainMappingIdentifierProperties
();
$identifierProperties
=
$this
->
getDomainMappingIdentifierProperties
();
$file
=
$this
->
spreadsheetImport
->
getFile
()
->
createTemporaryLocalCopy
();
$sheet
=
$this
->
getFileActiveSheet
();
$reader
=
\PHPExcel_IOFactory
::
load
(
$file
);
$numberOfRecordsToPersist
=
$this
->
settings
[
'numberOfRecordsToPersist'
];
$numberOfRecordsToPersist
=
$this
->
settings
[
'numberOfRecordsToPersist'
];
$i
=
0
;
$i
=
0
;
/** @var \PHPExcel_Worksheet_Row $row */
/** @var \PHPExcel_Worksheet_Row $row */
foreach
(
$
reader
->
getActiveSheet
()
->
getRowIterator
(
2
)
as
$row
)
{
foreach
(
$
sheet
->
getRowIterator
(
2
)
as
$row
)
{
$object
=
$this
->
findObjectByIdentifierPropertiesPerRow
(
$identifierProperties
,
$row
);
$object
=
$this
->
findObjectByIdentifierPropertiesPerRow
(
$identifierProperties
,
$row
);
if
(
is_object
(
$object
))
{
if
(
is_object
(
$object
))
{
$objectIds
[]
=
$this
->
persistenceManager
->
getIdentifierByObject
(
$object
);
$objectIds
[]
=
$this
->
persistenceManager
->
getIdentifierByObject
(
$object
);
...
@@ -215,6 +221,16 @@ class SpreadsheetImportService {
...
@@ -215,6 +221,16 @@ class SpreadsheetImportService {
$this
->
spreadsheetImport
->
setTotalSkipped
(
$totalSkipped
);
$this
->
spreadsheetImport
->
setTotalSkipped
(
$totalSkipped
);
}
}
/**
* @return \PHPExcel_Worksheet
*/
private
function
getFileActiveSheet
()
{
$file
=
$this
->
spreadsheetImport
->
getFile
()
->
createTemporaryLocalCopy
();
$reader
=
\PHPExcel_IOFactory
::
load
(
$file
);
$sheet
=
$reader
->
getActiveSheet
();
return
$sheet
;
}
/**
/**
* @return \TYPO3\Flow\Persistence\RepositoryInterface
* @return \TYPO3\Flow\Persistence\RepositoryInterface
*/
*/
...
...
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