Skip to content

Commit 4e9d7a3

Browse files
authored
revert milestoning change (finos#3995)
1 parent 394941f commit 4e9d7a3

File tree

36 files changed

+405
-2024
lines changed

36 files changed

+405
-2024
lines changed

legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PropertyMappingBuilder.java

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,12 @@
2828
import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.mapping.PurePropertyMapping;
2929
import org.finos.legend.engine.shared.core.operational.Assert;
3030
import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException;
31-
import org.finos.legend.pure.generated.Root_meta_external_format_shared_binding_Binding;
32-
import org.finos.legend.pure.generated.Root_meta_external_format_shared_binding_BindingTransformer_Impl;
3331
import org.finos.legend.pure.generated.Root_meta_pure_mapping_aggregationAware_AggregationAwarePropertyMapping_Impl;
3432
import org.finos.legend.pure.generated.Root_meta_external_store_model_PurePropertyMapping_Impl;
3533
import org.finos.legend.pure.generated.Root_meta_pure_mapping_relation_RelationFunctionPropertyMapping_Impl;
3634
import org.finos.legend.pure.generated.Root_meta_pure_mapping_xStore_XStorePropertyMapping_Impl;
3735
import org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_LambdaFunction_Impl;
38-
import org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl;
3936
import org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl;
40-
import org.finos.legend.pure.generated.core_pure_model_modelUnit;
4137
import org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningFunctions;
4238
import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping;
4339
import org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.InstanceSetImplementation;
@@ -63,12 +59,9 @@
6359
import org.finos.legend.pure.m3.navigation.relation._RelationType;
6460
import org.finos.legend.pure.m4.coreinstance.SourceInformation;
6561

66-
import java.util.List;
6762
import java.util.Iterator;
6863
import java.util.function.Function;
6964

70-
import static org.finos.legend.pure.generated.platform_pure_essential_meta_graph_elementToPath.Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_;
71-
7265
public class PropertyMappingBuilder implements PropertyMappingVisitor<org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping>
7366
{
7467
private final CompileContext context;
@@ -273,15 +266,15 @@ public PropertyMapping visit(RelationFunctionPropertyMapping propertyMapping)
273266
}
274267

275268
Type propertyType = property._genericType()._rawType();
276-
if (!processorSupport.type_isPrimitiveType(propertyType) && propertyMapping.bindingTransformer == null)
269+
if (!processorSupport.type_isPrimitiveType(propertyType))
277270
{
278-
throw new EngineException("Relation mapping is only supported for primitive properties or mapping to semi-structured data (which requires a binding), but the property '" + org.finos.legend.pure.m3.navigation.property.Property.getPropertyName(property) + "' has type " + propertyType._name() + " and no binding was specified.", propertyMapping.sourceInformation, EngineErrorType.COMPILATION);
271+
throw new EngineException("Relation mapping is only supported for primitive properties, but the property '" + org.finos.legend.pure.m3.navigation.property.Property.getPropertyName(property) + "' has type " + propertyType._name() + ".", propertyMapping.sourceInformation, EngineErrorType.COMPILATION);
279272
}
280-
String propertyTypeName = processorSupport.type_isPrimitiveType(propertyType) ? propertyType._name() : M3Paths.Variant;
281-
RelationType<?> newRelationType = _RelationType.build(Lists.mutable.with(_Column.getColumnInstance(propertyMapping.column, false, propertyTypeName, property._multiplicity(), sourceInfo, processorSupport)), sourceInfo, processorSupport);
273+
RelationType<?> newRelationType = _RelationType.build(Lists.mutable.with(_Column.getColumnInstance(propertyMapping.column, false, propertyType._name(), property._multiplicity(), sourceInfo, processorSupport)), sourceInfo, processorSupport);
282274
org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.relation.RelationFunctionPropertyMapping relationFunctionPropertyMapping = new Root_meta_pure_mapping_relation_RelationFunctionPropertyMapping_Impl("", sourceInfo, context.pureModel.getClass("meta::pure::mapping::relation::RelationFunctionPropertyMapping"))
283275
._property(property)
284276
._sourceSetImplementationId(propertyMapping.source == null || propertyMapping.source.isEmpty() ? immediateParent._id() : propertyMapping.source)
277+
._targetSetImplementationId(HelperMappingBuilder.getPropertyMappingTargetId(propertyMapping, property, context))
285278
._column(newRelationType._columns().toList().get(0))
286279
._owner(immediateParent);
287280

@@ -291,40 +284,6 @@ public PropertyMapping visit(RelationFunctionPropertyMapping propertyMapping)
291284
relationFunctionPropertyMapping._localMappingPropertyType(this.context.resolveType(propertyMapping.localMappingProperty.type, propertyMapping.localMappingProperty.sourceInformation));
292285
relationFunctionPropertyMapping._localMappingPropertyMultiplicity(this.context.pureModel.getMultiplicity(propertyMapping.localMappingProperty.multiplicity));
293286
}
294-
295-
if (propertyMapping.bindingTransformer != null)
296-
{
297-
Root_meta_external_format_shared_binding_Binding binding = (Root_meta_external_format_shared_binding_Binding) context.resolvePackageableElement(propertyMapping.bindingTransformer.binding, propertyMapping.sourceInformation);
298-
List<? extends Class<?>> bindingClasses = org.eclipse.collections.api.factory.Lists.mutable.withAll(core_pure_model_modelUnit.Root_meta_pure_model_unit_resolve_ModelUnit_1__ResolvedModelUnit_1_(binding._modelUnit(), context.getExecutionSupport()).classes(context.getExecutionSupport()));
299-
300-
if (!"Class".equals(propertyType._classifierGenericType()._rawType()._name()))
301-
{
302-
throw new EngineException("Binding transformer can be used with complex properties only. Property '" + property._name() + "' return type is '" + propertyType._name() + "'", propertyMapping.sourceInformation, EngineErrorType.COMPILATION);
303-
}
304-
305-
Class<?> propertyReturnType = (Class<?>) propertyType;
306-
if (!bindingClasses.contains(propertyReturnType))
307-
{
308-
throw new EngineException("Class: " + Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_((org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement) propertyType, context.getExecutionSupport()) + " should be included in modelUnit for binding: " + propertyMapping.bindingTransformer.binding, propertyMapping.sourceInformation, EngineErrorType.COMPILATION);
309-
}
310-
311-
Class<?> classifier = context.pureModel.getClass("meta::external::format::shared::binding::BindingTransformer");
312-
GenericType genericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("", null, context.pureModel.getClass("meta::pure::metamodel::type::generics::GenericType"))
313-
._rawType(classifier)
314-
._typeArguments(org.eclipse.collections.api.factory.Lists.fixedSize.of(context.pureModel.getGenericType(propertyReturnType)));
315-
relationFunctionPropertyMapping._transformer(
316-
new Root_meta_external_format_shared_binding_BindingTransformer_Impl<>("", SourceInformationHelper.toM3SourceInformation(propertyMapping.bindingTransformer.sourceInformation), classifier)
317-
._binding(binding)
318-
._classifierGenericType(genericType)
319-
._class(propertyReturnType)
320-
);
321-
relationFunctionPropertyMapping._targetSetImplementationId("");
322-
}
323-
else
324-
{
325-
relationFunctionPropertyMapping._targetSetImplementationId(HelperMappingBuilder.getPropertyMappingTargetId(propertyMapping, property, context));
326-
}
327-
328287
return relationFunctionPropertyMapping;
329288
}
330289
}

legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,6 @@ private void registerElementsForPathToElement()
522522
registerElementForPathToElement("meta::pure::metamodel::relation", Lists.mutable.with(
523523
"Column"
524524
));
525-
registerElementForPathToElement("meta::pure::metamodel::variant", Lists.mutable.with(
526-
"Variant"
527-
));
528525
this.extensions.getExtraElementForPathToElementRegisters().forEach(register -> register.value(this::registerElementForPathToElement));
529526
}
530527

legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/mapping/relationFunctionMapping/RelationFunctionMappingLexerGrammar.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ lexer grammar RelationFunctionMappingLexerGrammar;
33
import M3LexerGrammar;
44

55
RELATION_FUNC: '~func' ;
6-
BINDING: 'Binding';
6+
STRING: String;

legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/mapping/relationFunctionMapping/RelationFunctionMappingParserGrammar.g4

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,13 @@ options
77
tokenVocab = RelationFunctionMappingLexerGrammar;
88
}
99

10-
// -------------------------------------- IDENTIFIER --------------------------------------------
10+
// -------------------------------------- RELATION MAPPING --------------------------------------
1111

12-
identifier: VALID_STRING | STRING | RELATION_FUNC | BINDING | ALL | LET | ALL_VERSIONS
13-
| ALL_VERSIONS_IN_RANGE | TO_BYTES_FUNCTION
14-
;
15-
16-
// -------------------------------------- RELATION FUNCTION MAPPING --------------------------------------
17-
18-
relationFunctionMapping: RELATION_FUNC functionIdentifier
12+
relationMapping: RELATION_FUNC functionIdentifier
1913
(singlePropertyMapping (COMMA singlePropertyMapping)*)?
2014
EOF
2115
;
2216

23-
singlePropertyMapping: singleLocalPropertyMapping | singleNonLocalPropertyMapping
24-
;
25-
26-
singleLocalPropertyMapping: PLUS qualifiedName COLON type multiplicity relationFunctionPropertyMapping
27-
;
28-
29-
singleNonLocalPropertyMapping: qualifiedName relationFunctionPropertyMapping
30-
;
31-
32-
relationFunctionPropertyMapping: COLON (transformer)? identifier
17+
singlePropertyMapping: ((PLUS qualifiedName COLON type multiplicity) | qualifiedName) COLON identifier
3318
;
3419

35-
transformer: bindingTransformer
36-
;
37-
38-
bindingTransformer: BINDING qualifiedName COLON
39-
;

legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/CorePureGrammarParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public Iterable<? extends MappingElementParser> getExtraMappingElementParsers()
110110
MappingElementParser.newParser(XSTORE_ASSOCIATION_MAPPING_TYPE, CorePureGrammarParser::parseXStoreAssociationMapping),
111111
MappingElementParser.newParser(AGGREGATION_AWARE_MAPPING_TYPE, CorePureGrammarParser::parseAggregationAwareMapping),
112112
MappingElementParser.newParser(AGGREGATE_SPECIFICATION, CorePureGrammarParser::parseAggregateSpecification),
113-
MappingElementParser.newParser(RELATION_EXPRESSION, CorePureGrammarParser::parseRelationFunctionClassMapping)
113+
MappingElementParser.newParser(RELATION_EXPRESSION, CorePureGrammarParser::parseRelationFunctionMapping)
114114
);
115115
}
116116

@@ -291,7 +291,7 @@ private static AggregateSpecification parseAggregateSpecification(MappingElement
291291
return aggregateSpecification;
292292
}
293293

294-
private static ClassMapping parseRelationFunctionClassMapping(MappingElementSourceCode mappingElementSourceCode, PureGrammarParserContext parserContext)
294+
private static ClassMapping parseRelationFunctionMapping(MappingElementSourceCode mappingElementSourceCode, PureGrammarParserContext parserContext)
295295
{
296296
MappingParserGrammar.MappingElementContext ctx = mappingElementSourceCode.mappingElementParserRuleContext;
297297
SourceCodeParserInfo parserInfo = getRelationFunctionMappingParserInfo(mappingElementSourceCode);
@@ -303,7 +303,7 @@ private static ClassMapping parseRelationFunctionClassMapping(MappingElementSour
303303
relationFunctionClassMapping.root = ctx.STAR() != null;
304304
relationFunctionClassMapping.extendsClassMappingId = ctx.superClassMappingId() != null ? ctx.superClassMappingId().getText() : null;
305305
relationFunctionClassMapping.sourceInformation = parserInfo.sourceInformation;
306-
walker.visitRelationFunctionClassMapping((RelationFunctionMappingParserGrammar.RelationFunctionMappingContext) parserInfo.rootContext, relationFunctionClassMapping);
306+
walker.visitRelationFunctionMapping((RelationFunctionMappingParserGrammar.RelationMappingContext) parserInfo.rootContext, relationFunctionClassMapping);
307307
return relationFunctionClassMapping;
308308
}
309309

@@ -433,7 +433,7 @@ private static SourceCodeParserInfo getRelationFunctionMappingParserInfo(Mapping
433433
parser.removeErrorListeners();
434434
parser.addErrorListener(errorListener);
435435
SourceInformation source = mappingElementSourceCode.mappingParseTreeWalkerSourceInformation.getSourceInformation(mappingElementSourceCode.mappingElementParserRuleContext);
436-
return new SourceCodeParserInfo(mappingElementSourceCode.code, input, source, mappingElementSourceCode.mappingElementParseTreeWalkerSourceInformation, lexer, parser, parser.relationFunctionMapping());
436+
return new SourceCodeParserInfo(mappingElementSourceCode.code, input, source, mappingElementSourceCode.mappingElementParseTreeWalkerSourceInformation, lexer, parser, parser.relationMapping());
437437
}
438438

439439
private static Section parseDataSection(SectionSourceCode sectionSourceCode, Consumer<PackageableElement> elementConsumer, PureGrammarParserContext pureGrammarParserContext)

0 commit comments

Comments
 (0)