use of org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC in project legend-sdlc by finos.
the class PureModelContextDataResource method getPureModelContextData.
protected PureModelContextData getPureModelContextData(String projectId, String revisionOrVersionId, Iterable<? extends Entity> entities) {
AlloySDLC sdlc = new AlloySDLC();
sdlc.project = projectId;
sdlc.baseVersion = revisionOrVersionId;
return PureModelContextDataBuilder.newBuilder().withProtocol("pure", PureClientVersions.production).withSDLC(sdlc).withEntitiesIfPossible(entities).build();
}
use of org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC in project legend-engine by finos.
the class SDLCLoader method load.
@Override
public PureModelContextData load(MutableList<CommonProfile> pm, PureModelContext ctx, String clientVersion, Span parentSpan) {
PureModelContextPointer context = (PureModelContextPointer) ctx;
Assert.assertTrue(clientVersion != null, () -> "Client version should be set when pulling metadata from the metadata repository");
Function0<PureModelContextData> fetchMetadata;
final Subject subject = getSubject();
if (context.sdlcInfo instanceof PureSDLC) {
fetchMetadata = () -> {
parentSpan.setTag("sdlc", "pure");
try (Scope scope = GlobalTracer.get().buildSpan("Request Pure Metadata").startActive(true)) {
return ListIterate.injectInto(new PureModelContextData.Builder(), context.sdlcInfo.packageableElementPointers, (builder, pointers) -> builder.withPureModelContextData(this.pureLoader.loadPurePackageableElementPointer(pm, pointers, clientVersion, subject == null ? "" : "?auth=kerberos"))).distinct().sorted().build();
}
};
} else if (context.sdlcInfo instanceof AlloySDLC) {
fetchMetadata = () -> {
parentSpan.setTag("sdlc", "alloy");
try (Scope scope = GlobalTracer.get().buildSpan("Request Alloy Metadata").startActive(true)) {
AlloySDLC sdlc = (AlloySDLC) context.sdlcInfo;
PureModelContextData loadedProject = this.alloyLoader.loadAlloyProject(pm, sdlc, clientVersion);
loadedProject.origin.sdlcInfo.packageableElementPointers = sdlc.packageableElementPointers;
List<String> missingPaths = this.alloyLoader.checkAllPathsExist(loadedProject, sdlc);
if (missingPaths.isEmpty()) {
return loadedProject;
} else {
throw new RuntimeException("The following PackageableElementPointers:" + missingPaths.toString() + " do not exist in the project data loaded from the metadata server");
}
}
};
} else {
throw new UnsupportedOperationException("To Code");
}
PureModelContextData metaData = subject == null ? fetchMetadata.value() : exec(subject, fetchMetadata::value);
if (metaData.origin != null) {
Assert.assertTrue("none".equals(metaData.origin.sdlcInfo.version), () -> "Version can't be set in the pointer");
metaData.origin.sdlcInfo.version = metaData.origin.sdlcInfo.baseVersion;
metaData.origin.sdlcInfo.baseVersion = null;
}
return metaData;
}
Aggregations