Skip to content

Commit 3ea0cd3

Browse files
committed
...
1 parent 7117477 commit 3ea0cd3

3 files changed

Lines changed: 34 additions & 22 deletions

File tree

hyperquery/src/main/java/org/slowcoders/hyperquery/core/QInlineView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ protected HSchema loadSchema() {
1818
}
1919

2020
@Override
21-
public String getQuery() {
21+
protected String getQuery() {
2222
return viewDefinition;
2323
}
2424

2525
@Override
26-
public String getTableName() {
26+
protected String getTableName() {
2727
return "";
2828
}
2929
}

hyperquery/src/main/java/org/slowcoders/hyperquery/impl/HModel.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44

55
public abstract class HModel {
66

7-
protected abstract HSchema loadSchema();
8-
97
public void initialize() {
108
}
119

12-
public abstract String getQuery();
10+
protected abstract HSchema loadSchema();
11+
12+
protected abstract String getQuery();
1313

14-
public abstract String getTableName();
14+
protected abstract String getTableName();
1515

16-
public String translateProperty(String property) {
16+
protected String translateProperty(String property) {
1717
return property;
1818
}
1919

20-
public QJoin getJoin(String alias) {
20+
protected QJoin getJoin(String alias) {
2121
return null;
2222
}
2323

24-
public QLambda getLambda(String alias) {
24+
protected QLambda getLambda(String alias) {
2525
return null;
2626
}
2727
}

hyperquery/src/main/java/org/slowcoders/hyperquery/impl/HSchema.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
import java.util.HashMap;
1111
import java.util.Map;
1212

13-
public class HSchema extends QView {
13+
public class HSchema extends HModel {
1414
private final Class<? extends QView> entityType;
15+
private final String tableName;
1516
private Map<String, QJoin> joins;
1617
private Map<String, QLambda> lambdas;
1718
private Map<String, String> properties;
1819

1920
private static final HashMap<Class<?>, HSchema> relations = new HashMap<>();
2021

2122
public HSchema(Class<? extends QView> entityType) {
22-
super(getTableName(entityType));
2323
this.entityType = entityType;
24+
this.tableName = (getTableName(entityType));
2425
}
2526

2627
static String getTableName(Class<? extends QView> entityType) {
@@ -35,33 +36,33 @@ public String translateProperty(String property) {
3536
String alias = property.substring(0, p);
3637
String name = property.substring(p + 1);
3738
String[] joinStack = alias.split("@");
38-
QView view = getView(this, joinStack);
39-
property = view.translateProperty(name);
39+
HModel model = getModel(this, joinStack);
40+
property = model.translateProperty(name);
4041
} else {
4142
property = properties.get(property);
4243
}
4344
return property;
4445
}
4546

46-
private static QView getView(QView view, String[] joinStack) {
47+
private static HModel getModel(HModel model, String[] joinStack) {
4748
for (String alias : joinStack) {
4849
if (alias.isEmpty()) continue;
49-
view.initialize();
50-
view = view.getJoin(alias).getTargetRelation();
50+
model.initialize();
51+
model = model.getJoin(alias).getTargetRelation();
5152
}
52-
return view;
53+
return model;
5354
}
5455

5556
public QLambda getLambda(String alias) {
5657
return lambdas.get(alias);
5758
}
5859
public QLambda getLambda(String[] joinPath, String property) {
5960
initialize();
60-
QView view = getView(this, joinPath);
61-
return view.getLambda(property);
61+
HModel model = getModel(this, joinPath);
62+
return model.getLambda(property);
6263
}
6364

64-
public static HSchema getView(Class<? extends QView> clazz) { return relations.get(clazz); }
65+
public static HSchema getSchema(Class<? extends QView> clazz) { return relations.get(clazz); }
6566

6667
public static HSchema registerSchema(Class<? extends QView> clazz) {
6768
HSchema relation = relations.get(clazz);
@@ -106,8 +107,19 @@ else if (QLambda.class.isAssignableFrom(propertyType)) {
106107
this.joins = joins;
107108
}
108109

109-
public String getJoinTarget() {
110-
return super.getQuery();
110+
@Override
111+
protected HSchema loadSchema() {
112+
return this;
113+
}
114+
115+
@Override
116+
protected String getQuery() {
117+
return "";
118+
}
119+
120+
@Override
121+
protected String getTableName() {
122+
return this.tableName;
111123
}
112124

113125
public QJoin getJoin(String join) {

0 commit comments

Comments
 (0)