public String getAlias() { for (OMatchFilterItem item : items) { if (item.alias != null) { return item.alias.getStringValue(); } } return null; }
public String getDepthAlias() { for (OMatchFilterItem item : items) { if (item.depthAlias != null) { return item.depthAlias.getStringValue(); } } return null; }
public String getPathAlias() { for (OMatchFilterItem item : items) { if (item.pathAlias != null) { return item.pathAlias.getStringValue(); } } return null; }
public void setValue(Map target, Object value, OCommandContext ctx) { if (target == null) { return; } if (identifier != null) { target.put(identifier.getStringValue(), value); } else if (recordAttribute != null) { target.put(recordAttribute.getName(), value); } }
private OType[] calculateKeyTypes(OCommandContext ctx) { if (keyTypes == null) { return new OType[0]; } return keyTypes.stream().map(x -> OType.valueOf(x.getStringValue())).collect(Collectors.toList()).toArray(new OType[] {}); }
private boolean matchesClass(OEdge edge) { if (targetClass == null) { return true; } return edge.getSchemaType().get().isSubClassOf(targetClass.getStringValue()); }
public OCollate getCollate(OResult currentRecord, OCommandContext ctx) { if (identifier != null && currentRecord != null) { return currentRecord.getRecord().map(x -> (OElement) x).flatMap(elem -> elem.getSchemaType()) .map(clazz -> clazz.getProperty(identifier.getStringValue())).map(prop -> prop.getCollate()).orElse(null); } return null; }
private void checkSuperclasses(OSchema schema, OCommandContext ctx) { if (superclasses != null) { for (OIdentifier superclass : superclasses) { if (!schema.existsClass(superclass.getStringValue())) { throw new OCommandExecutionException("Superclass " + superclass + " not found"); } } } }
private void handleTargetClass(ODeleteExecutionPlan result, OCommandContext ctx, OIdentifier className, boolean profilingEnabled) { if (className != null) { result.chain(new FetchFromClassExecutionStep(className.getStringValue(), null, ctx, null, profilingEnabled)); } }
private void handleCheckType(OInsertExecutionPlan result, OCommandContext ctx, boolean profilingEnabled) { if (targetClass != null) { result.chain(new CheckClassTypeStep(targetClass.getStringValue(), "E", ctx, profilingEnabled)); } }
public boolean isIndexChain(OCommandContext ctx, OClass clazz) { if (suffix != null && suffix.isBaseIdentifier()) { OProperty prop = clazz.getProperty(suffix.identifier.getStringValue()); if (prop == null) { return false; } Collection<OIndex<?>> allIndexes = prop.getAllIndexes(); return allIndexes != null && allIndexes.stream().anyMatch(idx -> idx.getDefinition().getFields().size() == 1); } return false; } }
private void calculate(OCommandContext ctx) { if (executed) { return; } ctx.setVariable(varName.getStringValue(), toList(new OLocalResultSet(subExecutionPlan))); executed = true; }
@Override protected OLuceneFullTextIndex searchForIndex(OFromClause target, OCommandContext ctx, OExpression... args) { OFromItem item = target.getItem(); OIdentifier identifier = item.getIdentifier(); return searchForIndex(identifier.getStringValue(), ctx, args); }
private void handleCheckType(OInsertExecutionPlan result, OCommandContext ctx, boolean profilingEnabled) { if (targetClass != null) { result.chain(new CheckClassTypeStep(targetClass.getStringValue(), "V", ctx, profilingEnabled)); } if (targetClusterName != null) { result.chain(new CheckClusterTypeStep(targetClusterName.getStringValue(), "V", ctx, profilingEnabled)); } if (targetCluster != null) { result.chain(new CheckClusterTypeStep(targetCluster, "V", ctx, profilingEnabled)); } } }
@Override protected OLuceneFullTextIndex searchForIndex(OFromClause target, OCommandContext ctx, OExpression... args) { List<String> fieldNames = (List<String>) args[0].execute((OIdentifiable) null, ctx); OFromItem item = target.getItem(); String className = item.getIdentifier().getStringValue(); return searchForIndex(className, ctx, fieldNames); }
private void handleClassAsTarget(OSelectExecutionPlan plan, OFromClause queryTarget, OCommandContext ctx, boolean profilingEnabled) { OIdentifier identifier = queryTarget.getItem().getIdentifier(); Boolean orderByRidAsc = null;//null: no order. true: asc, false:desc FetchFromClassExecutionStep fetcher = new FetchFromClassExecutionStep(identifier.getStringValue(), null, ctx, orderByRidAsc, profilingEnabled); plan.chain(fetcher); }
private void handleTargetCluster(ODeleteExecutionPlan result, OCommandContext ctx, OIdentifier targetClusterName, boolean profilingEnabled) { if (targetClusterName != null) { String name = targetClusterName.getStringValue(); int clusterId = ctx.getDatabase().getClusterIdByName(name); if (clusterId < 0) { throw new OCommandExecutionException("Cluster not found: " + name); } result.chain(new FetchFromClusterExecutionStep(clusterId, ctx, profilingEnabled)); } }
private void executeInternal(OCommandContext ctx, OResultInternal result) { OSequence.CreateParams params = createParams(ctx, result); OSequence.SEQUENCE_TYPE seqType = type == TYPE_CACHED ? OSequence.SEQUENCE_TYPE.CACHED : OSequence.SEQUENCE_TYPE.ORDERED; result.setProperty("type", seqType.toString()); ctx.getDatabase().getMetadata().getSequenceLibrary().createSequence(this.name.getStringValue(), seqType, params); }
private void calculate(OResultInternal result, OCommandContext ctx) { OBasicCommandContext subCtx = new OBasicCommandContext(); subCtx.setDatabase(ctx.getDatabase()); subCtx.setParentWithoutOverridingChild(ctx); OInternalExecutionPlan subExecutionPlan; if (query.toString().contains("?")) { //with positional parameters, you cannot know if a parameter has the same ordinal as the one cached subExecutionPlan = query.createExecutionPlanNoCache(subCtx, profilingEnabled); } else { subExecutionPlan = query.createExecutionPlan(subCtx, profilingEnabled); } result.setMetadata(varName.getStringValue(), toList(new OLocalResultSet(subExecutionPlan))); }
private OResult createNewRecord(OFromClause commandTarget, OWhereClause initialFilter) { if (commandTarget.getItem().getIdentifier() == null) { throw new OCommandExecutionException("Cannot execute UPSERT on target '" + commandTarget + "'"); } ODocument doc = new ODocument(commandTarget.getItem().getIdentifier().getStringValue()); OUpdatableResult result = new OUpdatableResult(doc); if (initialFilter != null) { setContent(result, initialFilter); } return result; }