use of com.enonic.xp.repo.impl.ReturnValue in project xp by enonic.
the class NodeVersionQueryResultFactory method createVersionEntry.
private static NodeVersionMetadata createVersionEntry(final SearchHit hit) {
final String timestamp = getStringValue(hit, VersionIndexPath.TIMESTAMP, true);
final String versionId = getStringValue(hit, VersionIndexPath.VERSION_ID, true);
final String nodeBlobKey = getStringValue(hit, VersionIndexPath.NODE_BLOB_KEY, true);
final String indexConfigBlobKey = getStringValue(hit, VersionIndexPath.INDEX_CONFIG_BLOB_KEY, true);
final String accessControlBlobKey = getStringValue(hit, VersionIndexPath.ACCESS_CONTROL_BLOB_KEY, true);
final ReturnValue binaryBlobKeyReturnValue = hit.getField(VersionIndexPath.BINARY_BLOB_KEYS.getPath(), false);
final String nodePath = getStringValue(hit, VersionIndexPath.NODE_PATH, true);
final String nodeId = getStringValue(hit, VersionIndexPath.NODE_ID, true);
final String commitId = getStringValue(hit, VersionIndexPath.COMMIT_ID, false);
final NodeVersionKey nodeVersionKey = NodeVersionKey.from(nodeBlobKey, indexConfigBlobKey, accessControlBlobKey);
final BlobKeys binaryBlobKeys = toBlobKeys(binaryBlobKeyReturnValue);
return NodeVersionMetadata.create().nodeVersionId(NodeVersionId.from(versionId)).nodeVersionKey(nodeVersionKey).binaryBlobKeys(binaryBlobKeys).timestamp(isNullOrEmpty(timestamp) ? null : Instant.parse(timestamp)).nodePath(NodePath.create(nodePath).build()).nodeId(NodeId.from(nodeId)).nodeCommitId(isNullOrEmpty(commitId) ? null : NodeCommitId.from(commitId)).build();
}
use of com.enonic.xp.repo.impl.ReturnValue in project xp by enonic.
the class FindNodesDependenciesCommand method addNodeIdsFromReferenceReturnValues.
private void addNodeIdsFromReferenceReturnValues(final SearchResult result, final NodeIds.Builder builder) {
for (SearchHit hit : result.getHits()) {
final ReturnValue returnValue = hit.getReturnValues().get(NodeIndexPath.REFERENCE.getPath());
if (returnValue == null || returnValue.getValues().isEmpty()) {
continue;
}
returnValue.getValues().stream().map((value) -> NodeId.from(value.toString())).filter((value) -> !processed.contains(value)).filter((value) -> !excludedIds.contains(value)).forEach(builder::add);
}
}
use of com.enonic.xp.repo.impl.ReturnValue in project xp by enonic.
the class SearchHit method doGetField.
private ReturnValue doGetField(final String fieldName, final boolean failOnMissing) {
final String normalizedFieldName = IndexFieldNameNormalizer.normalize(fieldName);
final ReturnValue returnValue = returnValues.get(normalizedFieldName);
if (failOnMissing && returnValue == null) {
throw new RuntimeException("Expected field " + normalizedFieldName + " in result not found");
}
return returnValue;
}
use of com.enonic.xp.repo.impl.ReturnValue in project xp by enonic.
the class NodeVersionFactory method create.
public static NodeVersionMetadata create(final GetResult getResult) {
final ReturnValues values = getResult.getReturnValues();
final String versionId = values.getSingleValue(VersionIndexPath.VERSION_ID.getPath()).toString();
final String nodeBlobKey = values.getSingleValue(VersionIndexPath.NODE_BLOB_KEY.getPath()).toString();
final String indexConfigBlobKey = values.getSingleValue(VersionIndexPath.INDEX_CONFIG_BLOB_KEY.getPath()).toString();
final String accessControlBlobKey = values.getSingleValue(VersionIndexPath.ACCESS_CONTROL_BLOB_KEY.getPath()).toString();
final ReturnValue binaryBlobKeysReturnValue = values.get(VersionIndexPath.BINARY_BLOB_KEYS.getPath());
final Instant timestamp = Instant.parse(values.getSingleValue(VersionIndexPath.TIMESTAMP.getPath()).toString());
final String id = values.getSingleValue(VersionIndexPath.NODE_ID.getPath()).toString();
final String path = values.getSingleValue(VersionIndexPath.NODE_PATH.getPath()).toString();
final Object commitId = values.getSingleValue(VersionIndexPath.COMMIT_ID.getPath());
final NodeVersionKey nodeVersionKey = NodeVersionKey.from(nodeBlobKey, indexConfigBlobKey, accessControlBlobKey);
final BlobKeys binaryBlobKeys = toBlobKeys(binaryBlobKeysReturnValue);
return NodeVersionMetadata.create().nodeId(NodeId.from(id)).nodePath(NodePath.create(path).build()).timestamp(timestamp).nodeVersionId(NodeVersionId.from(versionId)).nodeVersionKey(nodeVersionKey).binaryBlobKeys(binaryBlobKeys).nodeCommitId(commitId == null ? null : NodeCommitId.from(commitId.toString())).build();
}
use of com.enonic.xp.repo.impl.ReturnValue in project xp by enonic.
the class ReturnValueTest method addList.
@Test
public void addList() throws Exception {
List<String> values = new ArrayList<>();
values.add("a");
values.add("b");
values.add("c");
final ReturnValue returnValue = ReturnValue.create(values);
assertEquals(3, returnValue.getValues().size());
assertEquals("a", returnValue.getSingleValue());
}
Aggregations