use of io.crnk.gen.typescript.transform.TSMetaTransformation in project crnk-framework by crnk-project.
the class TSGenerator method transformMetaToTypescript.
public void transformMetaToTypescript() {
Collection<MetaElement> elements = lookup.getMetaById().values();
LOGGER.debug("transforming {} elements", elements.size());
for (MetaElement element : elements) {
boolean isRoot = isRoot(element);
boolean isGenerated = isGenerated(element);
if (isRoot && isGenerated) {
LOGGER.debug("transforming {}", element.getId());
transform(element, TSMetaTransformationOptions.EMPTY);
} else {
LOGGER.debug("ignoring {}, root={}, generated={}", element.getId(), isRoot, isGenerated);
}
}
try {
postProcessing = true;
for (TSElement transformedElement : new ArrayList<>(transformedElements)) {
for (TSMetaTransformation transformation : transformations) {
transformation.postTransform(transformedElement, createMetaTransformationContext());
}
}
} finally {
postProcessing = false;
}
}
use of io.crnk.gen.typescript.transform.TSMetaTransformation in project crnk-framework by crnk-project.
the class TSGenerator method transform.
protected TSElement transform(MetaElement element, TSMetaTransformationOptions options) {
if (elementSourceMap.containsKey(element)) {
return elementSourceMap.get(element);
}
if (postProcessing) {
throw new IllegalStateException("cannot add further element while post processing: " + element.getId());
}
for (TSMetaTransformation transformation : transformations) {
if (transformation.accepts(element)) {
TSElement tsElement = transformation.transform(element, createMetaTransformationContext(), options);
transformedElements.add(tsElement);
return tsElement;
}
}
throw new IllegalStateException("unexpected element: " + element);
}
Aggregations