private void handleCreateRecord(OInsertExecutionPlan result, OInsertBody body, OCommandContext ctx, boolean profilingEnabled) { int tot = 1; if (body != null && body.getValueExpressions() != null && body.getValueExpressions().size() > 0) { tot = body.getValueExpressions().size(); } result.chain(new CreateRecordStep(ctx, tot, profilingEnabled)); }
@Override public OResult next() { if (!hasNext()) { throw new IllegalStateException(); } //TODO OIndex<?> index = ctx.getDatabase().getMetadata().getIndexManager().getIndex(targetIndex.getIndexName()); if (index == null) { throw new OCommandExecutionException("Index not found: " + targetIndex); } List<OInsertSetExpression> setExps = body.getSetExpressions(); if (body.getContent() != null) { throw new OCommandExecutionException("Invalid expression: INSERT INTO INDEX:... CONTENT ..."); } int count; if (setExps != null) { count = handleSet(setExps, index, ctx); } else { count = handleKeyValues(body.getIdentifierList(), body.getValueExpressions(), index, ctx); } executed = true; OResultInternal result = new OResultInternal(); result.setProperty("count", count); return result; }
private void handleSetFields(OInsertExecutionPlan result, OInsertBody insertBody, OCommandContext ctx, boolean profilingEnabled) { if (insertBody == null) { return; } if (insertBody.getIdentifierList() != null) { result.chain(new InsertValuesStep(insertBody.getIdentifierList(), insertBody.getValueExpressions(), ctx, profilingEnabled)); } else if (insertBody.getContent() != null) { result.chain(new UpdateContentStep(insertBody.getContent(), ctx, profilingEnabled)); } else if (insertBody.getContentInputParam() != null) { result.chain(new UpdateContentStep(insertBody.getContentInputParam(), ctx, profilingEnabled)); } else if (insertBody.getSetExpressions() != null) { List<OUpdateItem> items = new ArrayList<>(); for (OInsertSetExpression exp : insertBody.getSetExpressions()) { OUpdateItem item = new OUpdateItem(-1); item.setOperator(OUpdateItem.OPERATOR_EQ); item.setLeft(exp.getLeft().copy()); item.setRight(exp.getRight().copy()); items.add(item); } result.chain(new UpdateSetStep(items, ctx, profilingEnabled)); } }
private void handleSetFields(OInsertExecutionPlan result, OInsertBody insertBody, OCommandContext ctx, boolean profilingEnabled) { if (insertBody == null) { return; } if (insertBody.getIdentifierList() != null) { result.chain(new InsertValuesStep(insertBody.getIdentifierList(), insertBody.getValueExpressions(), ctx, profilingEnabled)); } else if (insertBody.getContent() != null) { result.chain(new UpdateContentStep(insertBody.getContent(), ctx, profilingEnabled)); } else if (insertBody.getContentInputParam() != null) { result.chain(new UpdateContentStep(insertBody.getContentInputParam(), ctx, profilingEnabled)); } else if (insertBody.getSetExpressions() != null) { List<OUpdateItem> items = new ArrayList<>(); for (OInsertSetExpression exp : insertBody.getSetExpressions()) { OUpdateItem item = new OUpdateItem(-1); item.setOperator(OUpdateItem.OPERATOR_EQ); item.setLeft(exp.getLeft().copy()); item.setRight(exp.getRight().copy()); items.add(item); } result.chain(new UpdateSetStep(items, ctx, profilingEnabled)); } }