public static DomainType getDomainOfEClass(SQLRepository repository, SQLElement eClass) { //Get the TGG Schema diagram EA.Diagram tggSchema = repository.GetCurrentDiagram(); //Get the TGG Project SQLPackage tggProject = repository.GetPackageByID(tggSchema.PackageID); SQLPackage parentPackage = repository.GetPackageByID(tggProject.ParentID); while (parentPackage.ParentID != 0) { tggProject = parentPackage; parentPackage = repository.GetPackageByID(tggProject.ParentID); } TGG tgg = new TGG(repository, tggProject); tgg.loadTreeFromTaggedValue(); String sourceDomainID = tgg.getDomain(DomainType.SOURCE).MetamodelGuid; String targetDomainID = tgg.getDomain(DomainType.TARGET).MetamodelGuid; SQLPackage currentPackage = repository.GetPackageByID(eClass.PackageID); SQLPackage parentOfCurrentPackage = repository.GetPackageByID(currentPackage.ParentID); while (parentOfCurrentPackage.ParentID != 0) { currentPackage = parentOfCurrentPackage; parentOfCurrentPackage = repository.GetPackageByID(parentOfCurrentPackage.ParentID); } SQLPackage modelOfTheEClass = currentPackage; Boolean isSource = sourceDomainID == modelOfTheEClass.PackageGUID; Boolean isTarget = targetDomainID == modelOfTheEClass.PackageGUID; if (isTarget && isSource) { return(DomainType.UNDEFINED); } else if (isTarget) { return(DomainType.TARGET); } else if (isSource) { return(DomainType.SOURCE); } else { return(DomainType.UNDEFINED); } }
private static DomainType determineDomainSimple(SQLRepository repository, TGGObjectVariable tggOv) { if (tggOv.sqlElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype) { return(DomainType.CORRESPONDENCE); } EClass classifierElement = tggOv.Classifier; if (classifierElement != null) { SQLElement eClass = repository.GetElementByID(classifierElement.EaElement.ElementID); SQLPackage wantedDomainPkg = repository.GetPackageByID(eClass.PackageID); while (!wantedDomainPkg.IsModel) { wantedDomainPkg = repository.GetPackageByID(wantedDomainPkg.ParentID); } SQLPackage tggPackage = repository.GetPackageByID(tggOv.sqlElement.PackageID); while (!tggPackage.IsModel) { tggPackage = repository.GetPackageByID(tggPackage.ParentID); } TGG tgg = new TGG(repository, tggPackage); tgg.loadTreeFromTaggedValue(); // source metamodel == target metamodel if (tgg.getDomain(DomainType.SOURCE).MetamodelGuid == tgg.getDomain(DomainType.TARGET).MetamodelGuid) { return(determineDomainUsingPrefixConvention(tggOv, repository)); } if (wantedDomainPkg.PackageGUID == tgg.getDomain(DomainType.SOURCE).MetamodelGuid) { return(DomainType.SOURCE); } else if (wantedDomainPkg.PackageGUID == tgg.getDomain(DomainType.TARGET).MetamodelGuid) { return(DomainType.TARGET); } } return(determineDomainUsingPrefixConvention(tggOv, repository)); }
public override List <String> doRule(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository sqlRepository) { List <String> results = new List <string>(); if (eaPackage.Element != null && eaPackage.Element.Stereotype == TGGModelingMain.TggSchemaPackageStereotype) { TGG tggSchema = new TGG(sqlRepository, eaPackage); tggSchema.loadTreeFromTaggedValue(); if (tggSchema.getDomain(DomainType.SOURCE) == null || tggSchema.getDomain(DomainType.TARGET) == null) { results.Add("TGG source/target metamodel definition is invalid"); } SQLPackage sourceMm = sqlRepository.GetPackageByGuid(tggSchema.getDomain(DomainType.SOURCE).MetamodelGuid); SQLPackage targetMm = sqlRepository.GetPackageByGuid(tggSchema.getDomain(DomainType.TARGET).MetamodelGuid); if (sourceMm == null || targetMm == null) { results.Add("TGG source/target metamodel definition is invalid"); } } return(results); }