protected override HashComponent loadComponent_(ComponentType c) { // CREATE Component AbstractComponentFunctor c_ = new AbstractComponentFunctor(); c_.Id_abstract = Connector.nextKey("id_abstract", "abstractcomponentfunctor"); c_.Hash_component_UID = c.header.hash_component_UID; c_.Library_path = c.header.packagePath + "." + c.header.name; c_.Kind = c.header.kind.ToString(); if (c.header.baseType != null) { ExtensionTypeType extType = c.header.baseType.extensionType; ComponentInUseType baseC = null; if (extType.ItemElementName == ItemChoiceType.extends && extType.Item) { baseC = c.header.baseType.component; parameterRenamingSuper = baseC.parameter; AbstractComponentFunctorApplication baseCapp = newAbstractComponentFunctorApplication(baseC); // FOLLOW arrow subtype if (baseCapp == null) { throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (extends) : " + baseC.name); } c_.Id_functor_app_supertype = baseCapp.Id_functor_app; } br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.insert(c_); // LOAD EXPOSED INNER COMPONENTS OF THE BASE if (baseC.port != null) { foreach (InnerComponentType port in baseC.port) { innerAll.Add(port); InnerComponent iNewPort = new InnerComponent(); iNewPort.Id_abstract_owner = c_.Id_abstract; string old_port_localRef = port.localRef; port.localRef = lookForRenamingNew(baseC.localRef, old_port_localRef, port.index_replica); iNewPort.Id_inner = port.localRef; iNewPort.Parameter_top = port.parameter_id; iNewPort.Transitive = true; iNewPort.IsPublic = true; iNewPort.Multiple = port.multipleSpecified ? port.multiple : false; AbstractComponentFunctorApplication appPort = newAbstractComponentFunctorApplication(port); if (appPort == null) { throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (public inner component) : " + port.name); } iNewPort.Id_functor_app = appPort.Id_functor_app; iNewPort.Id_abstract_inner = appPort.Id_abstract; InnerComponentExposed ice = new InnerComponentExposed(); ice.Id_abstract = c_.Id_abstract; ice.Id_inner_rename = iNewPort.Id_inner; ice.Id_inner_owner = null; ice.Id_inner = old_port_localRef; br.ufc.pargo.hpe.backend.DGAC.BackEnd.icedao.insert(ice); if (br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(iNewPort.Id_abstract_owner, iNewPort.Id_inner) == null) { br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNewPort); } } } } else { br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfdao.insert(c_); } loadAbstractComponentFunctorParameters(c_); return(c_); }
private void loadInnerComponents(AbstractComponentFunctor absC) { IList <InnerComponentType> includeAsInner = new List <InnerComponentType>(); IDictionary <string, InnerComponentType> innersByVarName = new Dictionary <string, InnerComponentType>(); if (parameter != null) { foreach (ParameterType ir in parameter) { InnerComponentType ic = this.lookForInnerComponent(ir.componentRef); if (ic == null) { Console.WriteLine("LOOK FOR INNER COMPONENT RETURNED NULL " + ir.componentRef); } if (!innersByVarName.ContainsKey(ir.varName)) { innersByVarName[ir.varName] = ic; } else { Console.WriteLine("ALREADY EXISTS - key=" + ir.varName + ", value=" + ic.localRef); } } } if (parameterSupply != null) { foreach (ParameterSupplyType ir in parameterSupply) { InnerComponentType ic = this.lookForInnerComponent(ir.cRef); if (!innersByVarName.ContainsKey(ir.varName)) { innersByVarName[ir.varName] = ic; } else { Console.WriteLine("ALREADY EXISTS - key=" + ir.varName + ", value=" + ic.localRef); } } } importInnerComponentsOfSuper(absC, includeAsInner); if (inner != null) { foreach (InnerComponentType c in inner) { Console.WriteLine("BEGIN loadInnerComponent : " + c.localRef + " :: " + c.package + "." + c.name); // innerAll.Add(c); if (((isNotInSupply(c) || this.findInSlices(c.localRef)) && (isNotParameter(c) || this.findInSlices(c.localRef))) || includeAsInner.Contains(c)) { // CREATE INNER COMPONENT InnerComponent iNew = new InnerComponent(); iNew.Id_abstract_owner = absC.Id_abstract; iNew.Id_inner = c.localRef; // localRef is used to uniquely identify the inner component among the inner components.... // FOLLOW arrow has-parameters AbstractComponentFunctorApplication app = newAbstractComponentFunctorApplication(c); if (app == null) { throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (inner component) : " + c.name); } iNew.Id_functor_app = app.Id_functor_app; iNew.Id_abstract_inner = app.Id_abstract; // CHECKS IF IT IS A TOP PARAMETER ParameterType p = lookForParameterByCRef(c.localRef); iNew.Parameter_top = p != null ? p.formFieldId : null; iNew.Transitive = false; iNew.IsPublic = c.exposed; iNew.Multiple = c.multipleSpecified ? c.multiple : false; // LOAD EXPOSED INNER COMPONENTS if (c.port != null) { foreach (InnerComponentType port in c.port) { Console.WriteLine("loadInnerComponent - BEGIN PORT " + port.localRef); // -------------------------------------------------- string varName = null; int id_abstract_port = app.Id_abstract; string id_inner_port = port.localRef; InnerComponent ic_port = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(id_abstract_port, id_inner_port); Console.WriteLine("loadInnerComponent - STEP 1"); if (c.parameter != null && ic_port != null) { foreach (ParameterRenaming par in c.parameter) { Console.WriteLine("loadInnerComponent - STEP 2 begin " + par.formFieldId + " - " + par.varName); if (par.formFieldId.Equals(ic_port.Parameter_top)) { varName = par.varName; } Console.WriteLine("loadInnerComponent - STEP 2 end " + par.formFieldId + " - " + par.varName); } } InnerComponentType port_replace = port; if (varName != null) { Console.WriteLine("loadInnerComponent - STEP 3 " + varName); foreach (KeyValuePair <string, InnerComponentType> iii in innersByVarName) { Console.WriteLine("loadInnerComponent x " + iii.Key); Console.WriteLine("loadInnerComponent y " + (iii.Value == null)); Console.WriteLine("loadInnerComponent z " + c.package); Console.WriteLine("loadInnerComponent w " + c.name); } port_replace = innersByVarName[varName]; } else { Console.WriteLine("loadInnerComponent - STEP 3 "); } // -------------------------------------------------- innerAll.Add(port); InnerComponent iNewPort = new InnerComponent(); iNewPort.Id_abstract_owner = absC.Id_abstract; string old_port_localRef = port.localRef; port.localRef = lookForRenamingNew(c.localRef, old_port_localRef, port.index_replica); iNewPort.Id_inner = port.localRef; iNewPort.Parameter_top = port_replace.parameter_id; iNewPort.Transitive = true; iNewPort.IsPublic = port.exposed; iNewPort.Multiple = port.multipleSpecified ? port.multiple : false; AbstractComponentFunctorApplication appPort = newAbstractComponentFunctorApplication(port_replace); if (appPort == null) { throw new Exception("DEPLOY ERROR: Unresolved Dependency for base component (public inner component) : " + port.name); } iNewPort.Id_functor_app = appPort.Id_functor_app; iNewPort.Id_abstract_inner = appPort.Id_abstract; InnerComponentExposed ice = new InnerComponentExposed(); ice.Id_abstract = absC.Id_abstract; ice.Id_inner_rename = iNewPort.Id_inner; ice.Id_inner_owner = iNew.Id_inner; ice.Id_inner = old_port_localRef; br.ufc.pargo.hpe.backend.DGAC.BackEnd.icedao.insert(ice); InnerComponent ic_port_exists = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(iNewPort.Id_abstract_owner, iNewPort.Id_inner); if (ic_port_exists == null && (fusion == null || !fusion.ContainsKey(port.localRef) || (fusion.ContainsKey(port.localRef) && fusion[port.localRef].Equals(c.localRef)))) { br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNewPort); } Console.WriteLine("loadInnerComponent - END PORT " + port.localRef); } } InnerComponent ic = br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.retrieve(iNew.Id_abstract_owner, iNew.Id_inner); if (ic != null && includeAsInner.Contains(c)) { Console.WriteLine("loadInnerComponent - BLOCK 2 OPEN"); br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.remove(iNew.Id_abstract_owner, iNew.Id_inner); br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNew); Console.WriteLine("loadInnerComponent - BLOCK 2 CLOSE"); } else if (ic == null) { Console.WriteLine("loadInnerComponent - BLOCK 3 OPEN"); br.ufc.pargo.hpe.backend.DGAC.BackEnd.icdao.insert(iNew); Console.WriteLine("loadInnerComponent - BLOCK 3 CLOSE"); } } Console.WriteLine("END loadInnerComponent : " + c.localRef + " :: " + c.package + "." + c.name); } } }