generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove import from generation extension (#2677)
- Loading branch information
1 parent
6a43b15
commit 851200d
Showing
37 changed files
with
1,290 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
legend-engine-xts-avro/legend-engine-xt-avro-api/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-xts-avro</artifactId> | ||
<version>4.40.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>legend-engine-xt-avro-api</artifactId> | ||
<name>Legend Engine - XT - AVRO -API</name> | ||
|
||
<dependencies> | ||
<!-- ENGINE --> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-xt-avro</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-external-shared</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-language-pure-dsl-generation-pure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-xt-avro-pure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-protocol-pure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-language-pure-modelManager</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-language-pure-compiler</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-shared-core</artifactId> | ||
</dependency> | ||
<!-- ENGINE --> | ||
|
||
<!-- ANNOTATIONS --> | ||
<dependency> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>javax.ws.rs-api</artifactId> | ||
</dependency> | ||
<!-- ANNOTATIONS --> | ||
|
||
<!-- ECLIPSE COLLECTIONS --> | ||
<dependency> | ||
<groupId>org.eclipse.collections</groupId> | ||
<artifactId>eclipse-collections-api</artifactId> | ||
</dependency> | ||
<!-- ECLIPSE COLLECTIONS --> | ||
|
||
<!-- OPEN TRACING --> | ||
<dependency> | ||
<groupId>io.opentracing</groupId> | ||
<artifactId>opentracing-util</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentracing</groupId> | ||
<artifactId>opentracing-api</artifactId> | ||
</dependency> | ||
<!-- OPEN TRACING --> | ||
|
||
<!-- LOG --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<!-- LOG --> | ||
|
||
<!-- PAC4J --> | ||
<dependency> | ||
<groupId>org.pac4j.jax-rs</groupId> | ||
<artifactId>core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.pac4j</groupId> | ||
<artifactId>pac4j-core</artifactId> | ||
</dependency> | ||
<!-- PAC4J --> | ||
</dependencies> | ||
|
||
|
||
</project> |
107 changes: 107 additions & 0 deletions
107
...inos/legend/engine/external/format/avro/schema/generations/api/AvroGenerationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright 2024 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.external.format.avro.schema.generations.api; | ||
|
||
import io.opentracing.Scope; | ||
import io.opentracing.util.GlobalTracer; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiParam; | ||
import org.eclipse.collections.api.RichIterable; | ||
import org.eclipse.collections.api.block.function.Function0; | ||
import org.eclipse.collections.api.list.MutableList; | ||
import org.finos.legend.engine.external.format.avro.schema.generations.AvroGenerationConfig; | ||
import org.finos.legend.engine.external.format.avro.schema.generations.AvroGenerationInput; | ||
import org.finos.legend.engine.external.shared.format.generations.GenerationOutput; | ||
import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; | ||
import org.finos.legend.engine.language.pure.modelManager.ModelManager; | ||
import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; | ||
import org.finos.legend.engine.shared.core.api.result.ManageConstantResult; | ||
import org.finos.legend.engine.shared.core.identity.Identity; | ||
import org.finos.legend.engine.shared.core.identity.factory.IdentityFactoryProvider; | ||
import org.finos.legend.engine.shared.core.kerberos.ProfileManagerHelper; | ||
import org.finos.legend.engine.shared.core.operational.errorManagement.ExceptionTool; | ||
import org.finos.legend.engine.shared.core.operational.logs.LogInfo; | ||
import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType; | ||
import org.finos.legend.pure.generated.Root_meta_pure_generation_metamodel_GenerationOutput; | ||
import org.finos.legend.pure.generated.core_external_format_avro_transformation_transformation_avroSchemaGenerator; | ||
import org.pac4j.core.profile.CommonProfile; | ||
import org.pac4j.core.profile.ProfileManager; | ||
import org.pac4j.jax.rs.annotations.Pac4JProfileManager; | ||
import org.slf4j.Logger; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import static org.finos.legend.engine.shared.core.operational.http.InflateInterceptor.APPLICATION_ZLIB; | ||
|
||
@Deprecated | ||
@Api(tags = "Z - Deprecated - Generation - Schema") | ||
@Path("pure/v1/schemaGeneration") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public class AvroGenerationService | ||
{ | ||
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(AvroGenerationService.class); | ||
private final ModelManager modelManager; | ||
|
||
public AvroGenerationService(ModelManager modelManager) | ||
{ | ||
this.modelManager = modelManager; | ||
} | ||
|
||
@Deprecated | ||
@POST | ||
@Path("avro") | ||
@ApiOperation(value = "Generates Avro schema for a given class and transitive dependencies") | ||
@Consumes({MediaType.APPLICATION_JSON, APPLICATION_ZLIB}) | ||
public Response generateAvro(AvroGenerationInput generateAvroInput, @ApiParam(hidden = true) @Pac4JProfileManager ProfileManager<CommonProfile> pm) | ||
{ | ||
MutableList<CommonProfile> profiles = ProfileManagerHelper.extractProfiles(pm); | ||
Identity identity = IdentityFactoryProvider.getInstance().makeIdentity(profiles); | ||
boolean interactive = generateAvroInput.model instanceof PureModelContextData; | ||
try (Scope scope = GlobalTracer.get().buildSpan("Service: Generate Avro").startActive(true)) | ||
{ | ||
return exec(generateAvroInput.config != null ? generateAvroInput.config : new AvroGenerationConfig(), | ||
() -> this.modelManager.loadModelAndData(generateAvroInput.model, generateAvroInput.clientVersion, identity, null).getTwo(), | ||
interactive, | ||
identity); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return ExceptionTool.exceptionManager(ex, interactive ? LoggingEventType.GENERATE_AVRO_CODE_INTERACTIVE_ERROR : LoggingEventType.GENERATE_AVRO_CODE_ERROR, identity.getName()); | ||
} | ||
} | ||
|
||
private Response exec(AvroGenerationConfig avroConfig, Function0<PureModel> pureModelFunc, boolean interactive, Identity identity) | ||
{ | ||
try | ||
{ | ||
long start = System.currentTimeMillis(); | ||
LOGGER.info(new LogInfo(identity.getName(), interactive ? LoggingEventType.GENERATE_AVRO_CODE_INTERACTIVE_START : LoggingEventType.GENERATE_AVRO_CODE_START).toString()); | ||
PureModel pureModel = pureModelFunc.value(); | ||
RichIterable<? extends Root_meta_pure_generation_metamodel_GenerationOutput> output = core_external_format_avro_transformation_transformation_avroSchemaGenerator.Root_meta_external_format_avro_generation_generateAvroFromPureWithScope_AvroConfig_1__AvroOutput_MANY_(avroConfig.process(pureModel), pureModel.getExecutionSupport()); | ||
LOGGER.info(new LogInfo(identity.getName(), interactive ? LoggingEventType.GENERATE_AVRO_CODE_INTERACTIVE_STOP : LoggingEventType.GENERATE_AVRO_CODE_STOP, (double) System.currentTimeMillis() - start).toString()); | ||
return ManageConstantResult.manageResult(identity.getName(), output.collect(v -> new GenerationOutput(v._content(), v._fileName(), v._format())).toList()); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return ExceptionTool.exceptionManager(ex, interactive ? LoggingEventType.GENERATE_AVRO_CODE_INTERACTIVE_ERROR : LoggingEventType.GENERATE_AVRO_CODE_ERROR, identity.getName()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.