All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.reprezen.genflow.common.jsonschema.builder.ObjectResourceNode Maven / Gradle / Ivy

package com.reprezen.genflow.common.jsonschema.builder;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.reprezen.genflow.common.jsonschema.builder.JsonSchemaNodeFactory;
import com.reprezen.genflow.common.jsonschema.builder.NamedSchemaNode;
import com.reprezen.genflow.common.jsonschema.builder.PropertyRealizationNode;
import com.reprezen.rapidml.ObjectResource;
import com.reprezen.rapidml.PropertyRealization;
import com.reprezen.rapidml.ReferenceTreatment;
import com.reprezen.rapidml.ServiceDataResource;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

@SuppressWarnings("all")
public class ObjectResourceNode extends NamedSchemaNode {
  private NamedSchemaNode delegate;
  
  public ObjectResourceNode(final JsonSchemaNodeFactory director, final ServiceDataResource element) {
    super(director, element);
    boolean _useDefaultRealization = this.useDefaultRealization();
    if (_useDefaultRealization) {
      this.delegate = this.factory.createDefaultRealizationNode(element);
    }
  }
  
  protected boolean useDefaultRealization() {
    return (((this.element instanceof ObjectResource) && this.element.isWithDefaultRealization()) && (this.element.getDataType() != null));
  }
  
  @Override
  public String getName() {
    if ((this.delegate != null)) {
      return this.delegate.getName();
    }
    return this.element.getName();
  }
  
  @Override
  public void writeBody(final ObjectNode node) {
    if ((this.delegate != null)) {
      this.delegate.writeBody(node);
      return;
    }
    this.setObjectAsType(node);
    this.putDescription(node, this._zenModelHelper.getDocumentation(this.element));
    this.addVendorExtensions(node, this._extensionsHelper.getRapidExtensions(this.element.getDataType()));
    this.addVendorExtensions(node, this._extensionsHelper.getRapidExtensions(this.element));
    final ObjectNode propertiesNode = node.putObject("properties");
    final Function1 _function = (PropertyRealization e) -> {
      boolean _hasReferenceTreatment = this._zenModelHelper.hasReferenceTreatment(this.element, e.getBaseProperty());
      return Boolean.valueOf((!_hasReferenceTreatment));
    };
    Iterable includedProperties = IterableExtensions.filter(this.element.getProperties().getAllIncludedProperties(), _function);
    for (final PropertyRealization includedProperty : includedProperties) {
      new PropertyRealizationNode(this.factory, includedProperty).write(propertiesNode);
    }
    EList _referenceTreatments = this.element.getReferenceTreatments();
    for (final ReferenceTreatment referenceTreatment : _referenceTreatments) {
      this.factory.createReferenceTreatmentNode(referenceTreatment).inlineOrAddTopLevelNode(propertiesNode);
    }
    this.writeRequiredProperties(node, this.getRequiredPropertyNames(this.element));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy