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

ulting.orcas.orcas-domainextension-extenions.8.6.4.source-code.DomainExtension01HandleExtends Maven / Gradle / Ivy

Go to download

orcas custom extensions (contains only support classes and an empty-extension). If custom-extensions are provided, there will be a custom artifact.

The newest version!
package de.opitzconsulting.orcas.extensions;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.EcoreUtil2;

import de.opitzconsulting.orcasDsl.ColumnDomain;
import de.opitzconsulting.orcasDsl.Domain;
import de.opitzconsulting.orcasDsl.GenNameRule;
import de.opitzconsulting.orcasDsl.GenNameRulePart;
import de.opitzconsulting.orcasDsl.Model;
import de.opitzconsulting.orcasDsl.ModelElement;

public class DomainExtension01HandleExtends extends OrcasBaseExtensionWithParameter
{
  private void mergeSuperDomain( Domain pDomain, Domain pSuperDomain )
  {
    pDomain.getColumns().addAll( 0, EcoreUtil.copyAll( pSuperDomain.getColumns() ) );

    if( pDomain.getHistoryTable() == null )
    {
      pDomain.setHistoryTable( EcoreUtil.copy( pSuperDomain.getHistoryTable() ) );
    }

    pDomain.setExtends( null );
  }

  private Domain getMergedDomain( String pDomainName, Model pModel )
  {
    Domain lDomain = DomainExtensionHelper.getDomain( pDomainName, pModel );

    mergeSuperDomainIfNeeded( lDomain, pModel );

    return lDomain;
  }

  private void mergeSuperDomainIfNeeded( Domain pDomain, Model pModel )
  {
    if( pDomain.getExtends() != null )
    {
      mergeSuperDomain( pDomain, getMergedDomain( pDomain.getExtends(), pModel ) );
    }
  }

  @Override
  public Model transformModel( Model pModel )
  {
    for( ModelElement lModelElement : new ArrayList( pModel.getModel_elements() ) )
    {
      if( lModelElement instanceof Domain )
      {
        mergeSuperDomainIfNeeded( (Domain)lModelElement, pModel );
      }
    }

    return pModel;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy