Skip to content

Commit f44c146

Browse files
committed
fix sql expressions
1 parent b39bf35 commit f44c146

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

plugins/xtraserver-hale-io/src/main/java/de/ii/xtraserver/webapi/hale/io/writer/handler/SqlExpressionHandler.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.google.common.collect.ListMultimap;
1919
import de.ii.xtraplatform.features.domain.FeatureSchema;
2020
import de.ii.xtraplatform.features.domain.ImmutableFeatureSchema;
21+
import de.ii.xtraserver.hale.io.writer.XtraServerMappingUtils;
2122
import de.ii.xtraserver.hale.io.writer.handler.TransformationHandler;
2223
import eu.esdihumboldt.hale.common.align.model.Cell;
2324
import eu.esdihumboldt.hale.common.align.model.ParameterValue;
@@ -36,11 +37,11 @@ class SqlExpressionHandler extends RenameHandler {
3637
}
3738

3839
/**
39-
* @see TransformationHandler#handle(Cell)
40+
* @see TransformationHandler#handle(Cell, String)
4041
*/
4142
@Override
4243
public Optional<ImmutableFeatureSchema.Builder> doHandle(
43-
final Cell propertyCell, final Property targetProperty) {
44+
final Cell propertyCell, final Property targetProperty, String providerId) {
4445

4546
ImmutableFeatureSchema.Builder propertyBuilder =
4647
buildPropertyPath(propertyCell, targetProperty);
@@ -49,7 +50,19 @@ public Optional<ImmutableFeatureSchema.Builder> doHandle(
4950
propertyCell.getTransformationParameters();
5051
final List<ParameterValue> expressions = parameters.get(PARAMETER_VALUE);
5152
final String expression = expressions.get(0).as(String.class);
52-
final String sourcePath =String.format("[EXPRESSION]{sql=%s}", expression);
53+
String sourcePath = String.format("[EXPRESSION]{sql=%s}", expression);
54+
55+
Property sourceProperty = XtraServerMappingUtils.getSourceProperty(propertyCell);
56+
57+
Optional<String> joinSourcePath =
58+
this.mappingContext.computeJoinSourcePath(sourceProperty.getDefinition());
59+
if (joinSourcePath.isPresent()) {
60+
if (this.mappingContext.hasFirstObjectBuilderMapping(targetProperty)) {
61+
this.mappingContext.getFirstObjectBuilder(targetProperty).sourcePath(joinSourcePath.get());
62+
} else {
63+
sourcePath = joinSourcePath.get() + "/" + sourcePath;
64+
}
65+
}
5366

5467
setTypesAndSourcePaths(propertyBuilder, targetProperty, sourcePath);
5568

0 commit comments

Comments
 (0)