@Test public void Statements_and_Symbols() { QueryMetadata metadata = new SortableQueryMetadata(); QStatement stmt = new QStatement("stmt"); QSymbol sub = new QSymbol("subject"); QSymbol obj = new QSymbol("object"); metadata.addJoin(JoinType.DEFAULT, stmt); metadata.addJoin(JoinType.INNERJOIN, sub); metadata.addJoin(JoinType.INNERJOIN, obj); assertEquals(stmt, metadata.getJoins().get(0).getTarget()); assertEquals(sub, metadata.getJoins().get(1).getTarget()); assertEquals(obj, metadata.getJoins().get(2).getTarget()); }
@Override public List<JoinExpression> getJoins() { List<JoinExpression> joins = super.getJoins(); List<JoinExpression> rv = new ArrayList<JoinExpression>(joins.size()); for (JoinExpression join : joins) { if (join.getType() == JoinType.DEFAULT) { rv.add(join); } else { String[] path = SPLIT.split(join.getTarget().toString()); boolean added = false; for (int i = rv.size() - 1; i >= 0 && !added; i--) { String[] joinPath = SPLIT.split(rv.get(i).getTarget().toString()); if (path[0].equals(joinPath[0])) { rv.add(i + 1, join); added = true; } } if (!added) { rv.add(join); } } } return rv; }
SortableQueryMetadata extends DefaultQueryMetadata { @Override public List<JoinExpression> getJoins() { List<JoinExpression> joins = super.getJoins(); List<JoinExpression> rv = new ArrayList<JoinExpression>(joins.size()); for (JoinExpression join : joins) { if (join.getType() == JoinType.DEFAULT) { rv.add(join); } else { String[] path = SPLIT.split(join.getTarget().toString()); boolean added = false; for (int i = rv.size() - 1; i >= 0 && !added; i--) { String[] joinPath = SPLIT.split(rv.get(i).getTarget().toString()); if (path[0].equals(joinPath[0])) { rv.add(i + 1, join); added = true; } } if (!added) { rv.add(join); } } } return rv; } }
SortableQueryMetadata extends DefaultQueryMetadata { @Override public List<JoinExpression> getJoins() { List<JoinExpression> joins = super.getJoins(); List<JoinExpression> rv = new ArrayList<JoinExpression>(joins.size()); for (JoinExpression join : joins) { if (join.getType() == JoinType.DEFAULT) { rv.add(join); } else { String[] path = SPLIT.split(join.getTarget().toString()); boolean added = false; for (int i = rv.size() - 1; i >= 0 && !added; i--) { String[] joinPath = SPLIT.split(rv.get(i).getTarget().toString()); if (path[0].equals(joinPath[0])) { rv.add(i + 1, join); added = true; } } if (!added) { rv.add(join); } } } return rv; } SortableQueryMetadata(); }
SortableQueryMetadata extends DefaultQueryMetadata { @Override public List<JoinExpression> getJoins() { List<JoinExpression> joins = super.getJoins(); List<JoinExpression> rv = new ArrayList<JoinExpression>(joins.size()); for (JoinExpression join : joins) { if (join.getType() == JoinType.DEFAULT) { rv.add(join); } else { String[] path = SPLIT.split(join.getTarget().toString()); boolean added = false; for (int i = rv.size() - 1; i >= 0 && !added; i--) { String[] joinPath = SPLIT.split(rv.get(i).getTarget().toString()); if (path[0].equals(joinPath[0])) { rv.add(i + 1, join); added = true; } } if (!added) { rv.add(join); } } } return rv; } SortableQueryMetadata(); @Override List<JoinExpression> getJoins(); }
SortableQueryMetadata extends DefaultQueryMetadata { @Override public List<JoinExpression> getJoins() { List<JoinExpression> joins = super.getJoins(); List<JoinExpression> rv = new ArrayList<JoinExpression>(joins.size()); for (JoinExpression join : joins) { if (join.getType() == JoinType.DEFAULT) { rv.add(join); } else { String[] path = SPLIT.split(join.getTarget().toString()); boolean added = false; for (int i = rv.size() - 1; i >= 0 && !added; i--) { String[] joinPath = SPLIT.split(rv.get(i).getTarget().toString()); if (path[0].equals(joinPath[0])) { rv.add(i + 1, join); added = true; } } if (!added) { rv.add(join); } } } return rv; } SortableQueryMetadata(); @Override List<JoinExpression> getJoins();  }