Skip to content

Show UUID's in references #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
dev-master
----------

- [references] Show UUIDs when listing reference properties
- [transport] Added transport layer for experimental Jackalope FS implementation
- [misc] Wildcard (single asterisk) support in paths
- [node] Added wilcard support to applicable node commands, including "node:list", "node:remove" and "node:property:show"
Expand Down
16 changes: 8 additions & 8 deletions features/all/phpcr_node_references.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ Feature: Show node references
And I execute the "node:references . --no-ansi" command
Then the command should not fail
And I should see a table containing the following rows:
| Type | Property | Node Path |
| weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 |
| weak | ref1 | /tests_general_base/idExample/jcr:content/weakreference_source1 |
| Path | Property | Type |
| /tests_general_base/idExample/jcr:content/weakreference_source1 |ref1 | weak |
| /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak |

Scenario: List named weak references
Given the current node is "/tests_general_base/idExample/jcr:content/weakreference_target"
And I execute the "node:references . ref2 --no-ansi" command
Then the command should not fail
And I should see a table containing the following rows:
| Type | Property | Node Path |
| weak | ref2 | /tests_general_base/idExample/jcr:content/weakreference_source2 |
| Path | Property | Type |
| /tests_general_base/idExample/jcr:content/weakreference_source2 |ref2 | weak |

Scenario: List strong references
Given the current node is "/tests_general_base/idExample"
And I execute the "node:references . --no-ansi" command
Then the command should not fail
And I should see a table containing the following rows:
| Type | Property | Node Path |
| strong | ref | /tests_general_base/numberPropertyNode/jcr:content |
| strong | multiref | /tests_general_base/numberPropertyNode/jcr:content |
| Path | Property | Type |
| /tests_general_base/numberPropertyNode/jcr:content | multiref | strong |
| /tests_general_base/numberPropertyNode/jcr:content | ref | strong |

Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public function execute(InputInterface $input, OutputInterface $output)

$table = $this->get('helper.table')->create();
$table->setHeaders(array(
'Type', 'Property', 'Node Path'
'Path', 'Property', 'Type',
));

foreach ($references as $type => $typeReferences) {
foreach ($typeReferences as $property) {
$nodePath = $property->getParent()->getPath();

$table->addRow(array(
$type,
$nodePath,
$property->getName(),
$nodePath
$type,
));
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,19 @@ public function getPropertyTypeName($typeInteger)
*/
public function formatQueryResult(QueryResultInterface $result, OutputInterface $output, $elapsed)
{
$selectorNames = $result->getSelectorNames();

$table = $this->tableHelper->create();
$table->setHeaders(array_merge(array(
'Path',
'Index',
), $result->getColumnNames()));

foreach ($result->getRows() as $i => $row) {
foreach ($result->getRows() as $row) {
$values = array_merge(array(
$row->getPath(),
$row->getNode()->getIndex(),
), $row->getValues());

foreach ($values as $columnName => &$value) {
foreach ($values as &$value) {
$value = $this->normalizeValue($value);
}

Expand All @@ -90,13 +88,17 @@ public function normalizeValue($value)

foreach ($array as $i => $value) {
if ($value instanceof NodeInterface) {
$uuid = $value->getIdentifier();
$value = $value->getPath();
if ($uuid) {
$value .= ' (' . $uuid . ')';
}
} elseif (is_object($value)) {
$value = '<UNKNOWN OBJECT>';
} else {
$value = $value;
}
$value = '[' . $i . '] ' . $this->textHelper->truncate($value);
$value = '[' . $i . '] ' . $this->textHelper->truncate($value, 255);
$values[] = $value;
}

Expand All @@ -112,10 +114,8 @@ public function normalizeValue($value)

public function formatValue(PropertyInterface $value, $showBinary = false)
{
$v = $value->getValue();

if (is_array($v)) {
return $this->normalizeValue($v);
if (is_array($value->getValue())) {
return $this->normalizeValue($value->getValue());
}

switch (intval($value->getType())) {
Expand Down