Skip to content

Commit bd1a7fb

Browse files
committed
MERGE: Merge branch '3.0' into 4.0
2 parents 2f2f02b + 9a85eb4 commit bd1a7fb

30 files changed

Lines changed: 930 additions & 205 deletions

.travis.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
language: php
2+
sudo: false
3+
git:
4+
depth: 5
5+
submodules: false
6+
addons:
7+
apt:
8+
packages:
9+
- oracle-java8-set-default
210
matrix:
311
include:
412
- php: 7.0
513
env: ES=1
614
- php: 7.0
715
env: ES=2
16+
- php: 7.0
17+
env: ES=5
818
- php: 7.1
919
env: ES=1
1020
- php: 7.1
1121
env: ES=2
12-
sudo: false
22+
- php: 7.1
23+
env: ES=5
1324
before_install:
25+
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle
1426
- export NEOS_TARGET_VERSION=3.0
1527
- cd ..
1628
- if [ "$ES" = 1 ]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.zip && unzip elasticsearch-1.7.6.zip && mv elasticsearch-1.7.6 elasticsearch; fi
17-
- if [ "$ES" = 2 ]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.5.zip && unzip elasticsearch-2.4.5.zip && mv elasticsearch-2.4.5 elasticsearch; fi
29+
- if [ "$ES" = 2 ]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.4.6.zip && unzip elasticsearch-2.4.6.zip && mv elasticsearch-2.4.6 elasticsearch; fi
30+
- if [ "$ES" = 5 ]; then wget --no-check-certificate https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.8.zip && unzip elasticsearch-5.6.8.zip && mv elasticsearch-5.6.8 elasticsearch; fi
1831
- cd elasticsearch
1932
- bin/elasticsearch -d
2033
- cd ..
2134
- git clone https://github.com/neos/neos-base-distribution.git -b ${NEOS_TARGET_VERSION}
2235
- cd neos-base-distribution
23-
- composer require --no-update --no-interaction flowpack/elasticsearch-contentrepositoryadaptor:dev-master
36+
- composer require --no-update --no-interaction flowpack/elasticsearch-contentrepositoryadaptor:4.0.x-dev
2437
install:
2538
- composer install --no-interaction
2639
- cd ..
@@ -31,3 +44,4 @@ script:
3144
- bin/phpunit --colors -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Unit
3245
- if [ "$ES" = 1 ]; then FLOW_CONTEXT="Testing/ElasticVersion1" bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional; fi
3346
- if [ "$ES" = 2 ]; then FLOW_CONTEXT="Testing/ElasticVersion2" bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional; fi
47+
- if [ "$ES" = 5 ]; then FLOW_CONTEXT="Testing/ElasticVersion5" bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional; fi

Classes/Command/NodeIndexCommandController.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*/
1313

1414
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Indexer\Error\ErrorInterface;
15+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\NodeTypeMappingBuilderInterface;
1516
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\LoggerInterface;
16-
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder;
1717
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\ErrorHandlingService;
1818
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\IndexWorkspaceTrait;
1919
use Flowpack\ElasticSearch\Domain\Model\Mapping;
@@ -23,13 +23,12 @@
2323
use Neos\ContentRepository\Domain\Repository\NodeDataRepository;
2424
use Neos\ContentRepository\Domain\Repository\WorkspaceRepository;
2525
use Neos\ContentRepository\Domain\Service\ContentDimensionPresetSourceInterface;
26-
use Neos\ContentRepository\Domain\Service\Context;
27-
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
2826
use Neos\ContentRepository\Search\Indexer\NodeIndexerInterface;
2927
use Neos\Flow\Annotations as Flow;
3028
use Neos\Flow\Cli\CommandController;
3129
use Neos\Flow\Configuration\ConfigurationManager;
3230
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
31+
use Neos\Neos\Controller\CreateContentContextTrait;
3332
use Symfony\Component\Yaml\Yaml;
3433

3534
/**
@@ -41,6 +40,8 @@ class NodeIndexCommandController extends CommandController
4140
{
4241
use IndexWorkspaceTrait;
4342

43+
use CreateContentContextTrait;
44+
4445
/**
4546
* @Flow\Inject
4647
* @var ErrorHandlingService
@@ -79,7 +80,7 @@ class NodeIndexCommandController extends CommandController
7980

8081
/**
8182
* @Flow\Inject
82-
* @var NodeTypeMappingBuilder
83+
* @var NodeTypeMappingBuilderInterface
8384
*/
8485
protected $nodeTypeMappingBuilder;
8586

@@ -95,12 +96,6 @@ class NodeIndexCommandController extends CommandController
9596
*/
9697
protected $configurationManager;
9798

98-
/**
99-
* @Flow\Inject
100-
* @var ContextFactoryInterface
101-
*/
102-
protected $contextFactory;
103-
10499
/**
105100
* @var array
106101
*/
@@ -311,31 +306,6 @@ public function cleanupCommand()
311306
}
312307
}
313308

314-
/**
315-
* Create a ContentContext based on the given workspace name
316-
*
317-
* @param string $workspaceName Name of the workspace to set for the context
318-
* @param array $dimensions Optional list of dimensions and their values which should be set
319-
* @return Context
320-
*/
321-
protected function createContentContext($workspaceName, array $dimensions = [])
322-
{
323-
$contextProperties = [
324-
'workspaceName' => $workspaceName,
325-
'invisibleContentShown' => true,
326-
'inaccessibleContentShown' => true
327-
];
328-
329-
if ($dimensions !== []) {
330-
$contextProperties['dimensions'] = $dimensions;
331-
$contextProperties['targetDimensions'] = array_map(function ($dimensionValues) {
332-
return array_shift($dimensionValues);
333-
}, $dimensions);
334-
}
335-
336-
return $this->contextFactory->create($contextProperties);
337-
}
338-
339309
/**
340310
* Create a new index with the given $postfix.
341311
*
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver;
3+
4+
/*
5+
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package.
6+
*
7+
* (c) Contributors of the Neos Project - www.neos.io
8+
*
9+
* This package is Open Source Software. For the full copyright and license
10+
* information, please view the LICENSE file which was distributed with this
11+
* source code.
12+
*/
13+
14+
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
15+
use Neos\Error\Messages\Result;
16+
use Neos\Flow\Annotations as Flow;
17+
use Neos\Flow\Configuration\ConfigurationManager;
18+
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
19+
20+
/**
21+
* Builds the mapping information for Content Repository Node Types in Elasticsearch
22+
*
23+
* @Flow\Scope("singleton")
24+
*/
25+
abstract class AbstractNodeTypeMappingBuilder implements NodeTypeMappingBuilderInterface
26+
{
27+
/**
28+
* The default configuration for a given property type in NodeTypes.yaml, if no explicit elasticSearch section defined there.
29+
*
30+
* @var array
31+
*/
32+
protected $defaultConfigurationPerType;
33+
34+
/**
35+
* @Flow\Inject
36+
* @var NodeTypeManager
37+
*/
38+
protected $nodeTypeManager;
39+
40+
/**
41+
* @var Result
42+
*/
43+
protected $lastMappingErrors;
44+
45+
/**
46+
* @Flow\Inject
47+
* @var ConfigurationManager
48+
*/
49+
protected $configurationManager;
50+
51+
/**
52+
* Called by the Flow object framework after creating the object and resolving all dependencies.
53+
*
54+
* @param integer $cause Creation cause
55+
*/
56+
public function initializeObject($cause)
57+
{
58+
if ($cause === ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED) {
59+
$settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.ContentRepository.Search');
60+
$this->defaultConfigurationPerType = $settings['defaultConfigurationPerType'];
61+
}
62+
}
63+
64+
/**
65+
* Converts a Content Repository Node Type name into a name which can be used for an Elasticsearch Mapping
66+
*
67+
* @param string $nodeTypeName
68+
* @return string
69+
*/
70+
public function convertNodeTypeNameToMappingName($nodeTypeName)
71+
{
72+
return str_replace('.', '-', $nodeTypeName);
73+
}
74+
75+
/**
76+
* @return Result
77+
*/
78+
public function getLastMappingErrors()
79+
{
80+
return $this->lastMappingErrors;
81+
}
82+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver;
3+
4+
/*
5+
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package.
6+
*
7+
* (c) Contributors of the Neos Project - www.neos.io
8+
*
9+
* This package is Open Source Software. For the full copyright and license
10+
* information, please view the LICENSE file which was distributed with this
11+
* source code.
12+
*/
13+
14+
use Flowpack\ElasticSearch\Domain\Model\Index;
15+
use Flowpack\ElasticSearch\Mapping\MappingCollection;
16+
use Neos\Error\Messages\Result;
17+
18+
/**
19+
* NodeTypeMappingBuilder Interface
20+
*/
21+
interface NodeTypeMappingBuilderInterface
22+
{
23+
24+
/**
25+
* Converts a Content Repository Node Type name into a name which can be used for an Elasticsearch Mapping
26+
*
27+
* @param string $nodeTypeName
28+
* @return string
29+
*/
30+
public function convertNodeTypeNameToMappingName($nodeTypeName);
31+
32+
/**
33+
* Builds a Mapping Collection from the configured node types
34+
*
35+
* @param Index $index
36+
* @return MappingCollection<\Flowpack\ElasticSearch\Domain\Model\Mapping>
37+
*/
38+
public function buildMappingInformation(Index $index);
39+
40+
/**
41+
* @return Result
42+
*/
43+
public function getLastMappingErrors();
44+
}

Classes/Driver/Version1/DocumentDriver.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\AbstractDriver;
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\DocumentDriverInterface;
16-
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder;
16+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\DriverInterface;
17+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\NodeTypeMappingBuilderInterface;
1718
use Flowpack\ElasticSearch\Domain\Model\Index;
1819
use Neos\ContentRepository\Domain\Model\NodeInterface;
1920
use Neos\ContentRepository\Domain\Model\NodeType;
@@ -26,6 +27,12 @@
2627
*/
2728
class DocumentDriver extends AbstractDriver implements DocumentDriverInterface
2829
{
30+
/**
31+
* @Flow\Inject
32+
* @var NodeTypeMappingBuilderInterface
33+
*/
34+
protected $nodeTypeMappingBuilder;
35+
2936
/**
3037
* {@inheritdoc}
3138
*/
@@ -34,7 +41,7 @@ public function delete(NodeInterface $node, $identifier)
3441
return [
3542
[
3643
'delete' => [
37-
'_type' => NodeTypeMappingBuilder::convertNodeTypeNameToMappingName($node->getNodeType()),
44+
'_type' => $this->nodeTypeMappingBuilder->convertNodeTypeNameToMappingName($node->getNodeType()),
3845
'_id' => $identifier
3946
]
4047
]
@@ -56,7 +63,7 @@ public function deleteDuplicateDocumentNotMatchingType(Index $index, $documentId
5663
],
5764
'must_not' => [
5865
'term' => [
59-
'_type' => NodeTypeMappingBuilder::convertNodeTypeNameToMappingName($nodeType->getName())
66+
'_type' => $this->nodeTypeMappingBuilder->convertNodeTypeNameToMappingName($nodeType->getName())
6067
]
6168
],
6269
]

Classes/Driver/Version1/IndexerDriver.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\AbstractIndexerDriver;
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\IndexerDriverInterface;
16-
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder;
16+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\NodeTypeMappingBuilderInterface;
1717
use Flowpack\ElasticSearch\Domain\Model\Document as ElasticSearchDocument;
1818
use Neos\ContentRepository\Domain\Model\NodeInterface;
1919
use Neos\Flow\Annotations as Flow;
@@ -25,6 +25,12 @@
2525
*/
2626
class IndexerDriver extends AbstractIndexerDriver implements IndexerDriverInterface
2727
{
28+
/**
29+
* @Flow\Inject
30+
* @var NodeTypeMappingBuilderInterface
31+
*/
32+
protected $nodeTypeMappingBuilder;
33+
2834
/**
2935
* {@inheritdoc}
3036
*/
@@ -99,7 +105,7 @@ public function fulltext(NodeInterface $node, array $fulltextIndexOfNode, $targe
99105
return [
100106
[
101107
'update' => [
102-
'_type' => NodeTypeMappingBuilder::convertNodeTypeNameToMappingName($closestFulltextNode->getNodeType()->getName()),
108+
'_type' => $this->nodeTypeMappingBuilder->convertNodeTypeNameToMappingName($closestFulltextNode->getNodeType()->getName()),
103109
'_id' => $closestFulltextNodeDocumentIdentifier
104110
]
105111
],

0 commit comments

Comments
 (0)