Ejemplo n.º 1
0
        private void collectFV(AbstractComponentFunctorApplication acfa,
                               IDictionary <string, AbstractComponentFunctorApplication> pars,
                               IDictionary <string, AbstractComponentFunctorApplication> apars)
        {
            //SupplyParameterDAO spdao = new SupplyParameterDAO();
            IList <SupplyParameter> sps = br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.list(acfa.Id_functor_app);

            foreach (SupplyParameter sp in sps)
            {
                if (sp is SupplyParameterComponent)
                {
                    SupplyParameterComponent sp_ = (SupplyParameterComponent)sp;
                    // AbstractComponentFunctorApplicationDAO acfadao = new AbstractComponentFunctorApplicationDAO();
                    AbstractComponentFunctorApplication acfaPar = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(sp_.Id_functor_app_actual);
                    collectFV(acfaPar, pars, apars);
                }
                else if (sp is SupplyParameterParameter)
                {
                    SupplyParameterParameter            sp_     = (SupplyParameterParameter)sp;
                    AbstractComponentFunctorApplication acfaPar = null;
                    pars.TryGetValue("#" + sp_.Id_functor_app + sp_.Id_parameter, out acfaPar);
                    if (acfaPar == null)
                    {
                        pars.TryGetValue(sp_.Id_argument, out acfaPar);
                    }
                    Console.WriteLine("collectFV : id_functor_app=" + acfa.Id_functor_app + ", id_abstract=" + acfa.Id_abstract + ", " + "#" + sp_.Id_functor_app + sp_.Id_parameter + ", " + ", " + sp_.Id_argument + (acfaPar == null));
                    apars.Add("#" + sp_.Id_functor_app + sp_.Id_parameter, acfaPar);
                }
            }
        }
Ejemplo n.º 2
0
    internal IList<SupplyParameterParameter> listFreeVariables(AbstractComponentFunctor absC)
    {
        IList<SupplyParameterParameter> spp_List = new List<SupplyParameterParameter>();
        IDbConnection dbcon = Connector.DBcon;
        IDbCommand dbcmd = dbcon.CreateCommand();
        string sql =
            "SELECT ss.id_abstract, s.id_parameter, s.id_functor_app, s.id_parameter_actual, s.freevariable " +
            "FROM supplyparameterparameter s, supplyparameter ss, innercomponent i " +
            "WHERE  s.id_functor_app = i.id_functor_app AND " +
                    "s.id_functor_app = ss.id_functor_app AND " + 
                    "s.id_parameter = ss.id_parameter AND " +
                    "i.id_abstract_owner = " + absC.Id_abstract + " AND " +
                    "s.freeVariable = 1";
                    
        dbcmd.CommandText = sql;
        IDataReader reader = dbcmd.ExecuteReader();
        while (reader.Read())
        {
            SupplyParameterParameter spc = new SupplyParameterParameter();
            spc.Id_abstract = (int)reader["id_abstract"];
            spc.Id_parameter = (string)reader["id_parameter"];
            spc.Id_functor_app = (int)reader["id_functor_app"];
            spc.Id_argument = (string)reader["id_parameter_actual"];
            spc.FreeVariable = ((int)reader["freeVariable"]) == 0 ? false : true;
            spp_List.Add(spc);

        }//while
        // clean up
        reader.Close();
        reader = null;
        dbcmd.Dispose();
        dbcmd = null;
        return spp_List;
    }
Ejemplo n.º 3
0
	public SupplyParameterParameter retrieve(string id_parameter, int id_functor_app){
	
	   SupplyParameterParameter spc = null;
	   IDbConnection dbcon = Connector.DBcon;
       IDbCommand dbcmd = dbcon.CreateCommand();
       string sql =
           "SELECT id_parameter, id_functor_app, id_parameter_actual, freevariable " +
           "FROM supplyparameterparameter " +
           "WHERE id_parameter like '" + id_parameter + "' AND id_functor_app="+id_functor_app;
       dbcmd.CommandText = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       while(reader.Read()) {
       		spc = new SupplyParameterParameter();
       	    spc.Id_parameter = (string)reader["id_parameter"];
       	    spc.Id_functor_app = (int)reader["id_functor_app"];
       	    spc.Id_argument = (string)reader["id_parameter_actual"];
            spc.FreeVariable = ((int)reader["freeVariable"])==0 ? false : true;
             
             
       }//while
       // clean up
       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
			
	   if (spc==null) 
	   {
	  	  Console.WriteLine("SupplyParameterParameterDAO.cs: Parameter NOT FOUND " + id_parameter + "," + id_functor_app);
	   }
			
       return spc;
	}//list
    public void insert(SupplyParameter ac)
    {
			Console.WriteLine("SupplyParameter.cs: TRY INSERT 1: " + (ac==null));

        String sql1 =
            "INSERT INTO supplyparameter (id_parameter, id_functor_app, id_abstract)" +
            "VALUES ('" + ac.Id_parameter + "'," + ac.Id_functor_app + "," + ac.Id_abstract + ")";

        String sql2 = null;


        if (ac is SupplyParameterComponent)
        {
   			Console.WriteLine("SupplyParameter.cs: TRY INSERT 2: ");
            SupplyParameterComponent acc = (SupplyParameterComponent)ac;
            sql2 =
            "INSERT INTO supplyparametercomponent (id_parameter, id_functor_app, id_functor_app_actual)" +
            " VALUES ('" + acc.Id_parameter + "'," + acc.Id_functor_app + "," + acc.Id_functor_app_actual + ")";
        }
        else if (ac is SupplyParameterParameter)
        {
   			Console.WriteLine("SupplyParameter.cs: TRY INSERT 3: ");
            SupplyParameterParameter acp = (SupplyParameterParameter) ac;
            sql2 =
            "INSERT INTO supplyparameterparameter (id_parameter, id_functor_app, id_parameter_actual, freeVariable)" +
            " VALUES ('" + acp.Id_parameter + "'," + acp.Id_functor_app + ",'" + acp.Id_argument + "'," + (acp.FreeVariable ? 1 : 0) + ")";
        }

   		Console.WriteLine("SupplyParameter.cs: TRY INSERT 4: " + sql1);
   		Console.WriteLine("SupplyParameter.cs: TRY INSERT 5: " + sql2);

        Connector.performSQLUpdate(sql1);
        Connector.performSQLUpdate(sql2);
    }
Ejemplo n.º 5
0
	}//list


    public void remove(SupplyParameterParameter spp)
    {
        String sql =
            "DELETE FROM supplyparameterparameter" +
            " WHERE id_functor_app like '" + spp.Id_functor_app + "' AND id_parameter like '" + spp.Id_parameter + "'" ;

        Connector.performSQLUpdate(sql);
    }
Ejemplo n.º 6
0
    public void insert(SupplyParameterParameter ac)
    {
        String sql =
            "INSERT INTO supplyparameterparameter (id_parameter, id_functor_app, id_parameter_actual, freeVariable)" +
            " VALUES ('" + ac.Id_parameter + "'," + ac.Id_functor_app + ",'" + ac.Id_argument + "'," + ac.FreeVariable + ")";

   		Console.WriteLine("SupplyParameterParameter.cs: TRY INSERT: " + sql);

        Connector.performSQLUpdate(sql);
    }
Ejemplo n.º 7
0
        public static TreeNode generate(IDictionary <string, int> actualParametersTop, AbstractComponentFunctorApplication acfaRef)
        {
            //foreach (KeyValuePair<string,int> parTop in actualParametersTop)
            //	Console.WriteLine ("actualParametersTop[" + parTop.Key + "] = " + parTop.Value);

            //foreach (KeyValuePair<string,int> parTop in acfaRef.ParametersList)
            //	Console.WriteLine ("acfaRef.ParametersList[" + parTop.Key + "] = " + parTop.Value);

            IDictionary <TreeNode, int> level_log = new Dictionary <TreeNode, int> ();

            //Console.WriteLine("begin generate " + acfaRef.Id_functor_app);
            mmm = new Dictionary <String, String>();

            IDictionary <int, TreeNode> memory = new Dictionary <int, TreeNode>();

            IList <AbstractComponentFunctorApplication> lll = new List <AbstractComponentFunctorApplication>();

            lll.Add(acfaRef);

            TreeNode  root  = new TreeNode(lll, null);
            ArrayList queue = new ArrayList();

            queue.Add(root);

            level_log.Add(root, 0);

            while (queue.Count != 0)
            {
                TreeNode nodeRef = (TreeNode)queue[0];

                int level = level_log[nodeRef];
                //Console.WriteLine ("ENTERING LEVEL " + level);

                int id_abstract           = nodeRef.Functor_app.Id_abstract;
                int id_functor_app_actual = nodeRef.Functor_app.Id_functor_app;
                int id_abstract_top       = nodeRef.Functor_app_top.Id_abstract;

                //Console.WriteLine("Dequeue LOOP " + id_functor_app_actual);

                queue.RemoveAt(0);

                IList <SupplyParameter> parameterList = br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.list2(id_functor_app_actual);
                foreach (SupplyParameter sp in parameterList)
                {
                    bool flag_par = false;
                    //	Console.WriteLine("generate LOOP " + sp.Id_parameter + "," + sp.Id_functor_app + "IN LEVEL " + level);
                    bool freeVariable = false;

                    string parameter_id = sp.Id_parameter;

                    AbstractComponentFunctorApplication acfaTop = null;
                    if (id_abstract_top != id_abstract)
                    {
                        AbstractComponentFunctorParameter acfpTop = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.retrieve(id_abstract_top, parameter_id);
                        acfaTop = acfpTop == null ? null : br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(acfpTop.Bounds_of);
                        if (acfaTop == null)
                        {
                            AbstractComponentFunctorParameter acfp = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.retrieve(id_abstract, parameter_id);
                            acfaTop = acfp == null ? null : br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(acfp.Bounds_of);
                        }
                    }
                    else
                    {
                        AbstractComponentFunctorParameter acfp = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.retrieve(id_abstract, parameter_id);
                        acfaTop = acfp == null ? null : br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(acfp.Bounds_of);
                    }

                    //Console.WriteLine("acfaTop is null ? " + (acfaTop==null));

                    AbstractComponentFunctorApplication acfaActual = null;
                    if (sp is SupplyParameterComponent)
                    {
                        SupplyParameterComponent spc = (SupplyParameterComponent)sp;
                        //	Console.WriteLine ("acfaActual 1 ??? " + spc.Id_functor_app_actual);
                        acfaActual = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(spc.Id_functor_app_actual);
                        if (acfaActual == null)
                        {
                            throw new FreeVariableException();
                        }
                        //flag_par = true;
                    }
                    else if (sp is SupplyParameterParameter)
                    {
                        SupplyParameterParameter spp = (SupplyParameterParameter)sp;
                        int Id_functor_app_actual    = 0;

                        //	Console.WriteLine ("****** parameter_id#??? =" + parameter_id + "#" + sp.Id_functor_app);
                        if (!(flag_par = acfaRef.ParametersList.TryGetValue(parameter_id + "#" + sp.Id_functor_app, out Id_functor_app_actual)))
                        {
                            acfaRef.ParametersList.TryGetValue(parameter_id, out Id_functor_app_actual);
                        }

                        //	Console.WriteLine (" acfaRef.ParametersList.Count = " + acfaRef.ParametersList.Count);
                        //	foreach (KeyValuePair<string,int> p in acfaRef.ParametersList)
                        //		Console.WriteLine("acfaRef.ParametersList -- " + p.Key + " -> " + p.Value);

                        if (Id_functor_app_actual <= 0) // LOOK AT THE TOP PARAMETERS
                        {
                            bool found = actualParametersTop.TryGetValue(spp.Id_argument, out Id_functor_app_actual);
                            //	    Console.WriteLine (" actualParametersTop.Count = " + actualParametersTop.Count);
                            //	    foreach (KeyValuePair<string,int> p in actualParametersTop)
                            //		     Console.WriteLine("actualParametersTop -- " + p.Key + " -> " + p.Value);
                            if (!found)
                            {
                                string key = spp.Id_argument + "#" + sp.Id_functor_app;
                                //		Console.WriteLine ("key ??? " + key);
                                acfaRef.ParametersList.TryGetValue(key, out Id_functor_app_actual);
                            }

                            //	Console.WriteLine ("spp.Id_parameter_actual ??? " + spp.Id_argument);
                            //	Console.WriteLine ("found ??? " + found);
                        }
                        //	Console.WriteLine ("acfaRef ??? " + acfaRef.Id_functor_app);
                        //	Console.WriteLine ("parameter_id ??? " + parameter_id);
                        //	Console.WriteLine ("acfaActual 2 ??? " + Id_functor_app_actual);
                        if (Id_functor_app_actual <= 0)
                        {
                            // FREE VARIABLE !!! USE THE BOUND !!!
                            //AbstractComponentFunctorApplication acfaParF = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(spp.Id_functor_app);
                            //AbstractComponentFunctorParameter parF = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.retrieve(acfaParF.Id_abstract,parameter_id);
                            //Id_functor_app_actual = parF.Bounds_of;
                            //Console.WriteLine ("FREE VARIABLE !!! BOUND=" + Id_functor_app_actual);
                            freeVariable = true;
                        }
                        acfaActual = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(Id_functor_app_actual);
                    }

                    //	Console.WriteLine ("acfaActual ??? " + acfaActual.Id_functor_app);

                    if (!freeVariable)
                    {
                        // LOOK FOR ACTUAL PARAMETER IDs for THE NEXT ITERATIONS !!!
                        //	Console.WriteLine ("acfaTop.Id_functor_app = " + acfaTop.Id_functor_app);
                        IList <SupplyParameter> sss = br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.list(acfaTop.Id_functor_app);
                        foreach (SupplyParameter sssx in sss)
                        {
                            if (sssx is SupplyParameterComponent)
                            {
                                SupplyParameterComponent ssxc = (SupplyParameterComponent)sssx;
                                if (!mmm.ContainsKey(acfaActual.Id_functor_app + "." + ssxc.Id_parameter))
                                {
                                    mmm.Add(acfaActual.Id_functor_app + "." + ssxc.Id_parameter, ssxc.Id_parameter);
                                }
                            }
                            else if (sssx is SupplyParameterParameter)
                            {
                                SupplyParameterParameter ssxp = (SupplyParameterParameter)sssx;
                                if (!mmm.ContainsKey(acfaActual.Id_functor_app + "." + ssxp.Id_parameter))
                                {
                                    mmm.Add(acfaActual.Id_functor_app + "." + ssxp.Id_parameter, ssxp.Id_argument);
                                }
                            }
                        }

                        int    memory_key = acfaActual.Id_functor_app;
                        string parameter_id_2;
                        mmm.TryGetValue(id_functor_app_actual + "." + parameter_id, out parameter_id_2);
                        if (parameter_id_2 == null)
                        {
                            parameter_id_2 = parameter_id;
                        }
                        else
                        {
                            acfaRef.ParametersList.TryGetValue(parameter_id_2, out memory_key);
                        }

                        TreeNode node       = null;
                        bool     node_found = memory.TryGetValue(memory_key, out node);

                        //		foreach (KeyValuePair<string, string> ppp in mmm)
                        //			Console.WriteLine ("mmm[" + ppp.Key + "]=" + ppp.Value);
                        //		foreach (KeyValuePair<int, TreeNode> pair in memory)
                        //			Console.WriteLine ("memory: key=" + pair.Key + ", value=" + pair.Value.Functor_app.Id_functor_app);

                        if (!node_found)
                        {
                            IList <AbstractComponentFunctorApplication> generalizeSteps = buildGeneralizationSteps(acfaActual, acfaTop);

                            //			foreach (AbstractComponentFunctorApplication yyy in generalizeSteps)
                            //				Console.WriteLine("generate - " + yyy.Id_functor_app);

                            node = new TreeNode(generalizeSteps, nodeRef);
                            level_log.Add(node, level + 1);
                            node.addParameterIdSyn(parameter_id_2);
                            node.Parameter_id = parameter_id_2;
                            queue.Add(node);
                            //			Console.WriteLine("BEGIN " + parameter_id + "," + parameter_id_2 + "," + flag_par + " *** "  + node.Functor_app.Id_functor_app);
                            if (level == 0 || flag_par)
                            {
                                memory.Add(node.Functor_app.Id_functor_app /*parameter_id_2 + (flag_par ? sp.Id_functor_app.ToString () : "")*/, node);
                            }
                            //			else
                            //				Console.WriteLine ("LEVEL " + level);
                            //			Console.WriteLine("END" + parameter_id + "," + parameter_id_2);
                        }
                        else
                        {
                            //			Console.WriteLine ("parameter_id_2 = " + parameter_id_2 + (flag_par ? sp.Id_functor_app.ToString() : ""));
                            node.addParameterIdSyn(parameter_id_2);
                        }

                        nodeRef.addChild(node);
                    }
                    else
                    {
                    }
                }
            }

            //	Console.WriteLine("end generate " + root.Parameter_id + "," +  root.Functor_app.Id_functor_app);
            return(root);
        }
Ejemplo n.º 8
0
        private void collectParameters(IDictionary <string, AbstractComponentFunctorApplication> pars,
                                       AbstractComponentFunctorApplication acfa,
                                       out IDictionary <string, AbstractComponentFunctorApplication> parsSlice)
        {
            IList <SupplyParameter> spList = br.ufc.pargo.hpe.backend.DGAC.BackEnd.spdao.list(acfa.Id_functor_app);

            parsSlice = new Dictionary <string, AbstractComponentFunctorApplication>();

            foreach (SupplyParameter sp in spList)
            {
                AbstractComponentFunctorApplication acfaPar = null;
                if (sp is SupplyParameterComponent)
                {
                    SupplyParameterComponent sp_ = (SupplyParameterComponent)sp;
                    acfaPar = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(sp_.Id_functor_app_actual);
                    parsSlice.Add(sp_.Id_parameter, acfaPar);
                    Console.WriteLine("collectParameter -TRACE 1 " + sp_.Id_parameter + ":" + acfaPar.Id_abstract);
                }
                else if (sp is SupplyParameterParameter)
                {
                    SupplyParameterParameter sp_ = (SupplyParameterParameter)sp;
                    acfaPar = null;
                    Console.WriteLine("collectParameter -TRACE 2 " + "#" + sp_.Id_functor_app + sp_.Id_parameter);

                    pars.TryGetValue("#" + sp_.Id_functor_app + sp_.Id_parameter, out acfaPar);
                    if (acfaPar == null)
                    {
                        Console.WriteLine("collectParameter -TRACE 3 " + sp_.Id_argument);

                        if (pars.TryGetValue(sp_.Id_argument, out acfaPar))
                        {
                            parsSlice.Add(sp_.Id_parameter, acfaPar);
                            Console.WriteLine("collectParameter -TRACE 4 " + sp_.Id_parameter + " : " + acfaPar.Id_abstract);
                        }
                        else
                        {
                            AbstractComponentFunctorParameter acfp = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.retrieve(Id_abstract, sp_.Id_argument);
                            if (acfp == null)
                            {
                                acfp = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfpdao.retrieve(sp_.Id_abstract, sp_.Id_parameter);
                            }
                            acfaPar = br.ufc.pargo.hpe.backend.DGAC.BackEnd.acfadao.retrieve(acfp.Bounds_of);
                            parsSlice.Add(sp_.Id_parameter, acfaPar);
                            Console.WriteLine("collectParameter -TRACE 5 " + sp_.Id_parameter + " : " + acfaPar.Id_abstract);
                        }
                    }
                    else
                    {
                        Console.WriteLine("collectParameter -TRACE 6 " + "#" + sp_.Id_functor_app + sp_.Id_parameter + " : " + acfaPar.Id_abstract);
                        parsSlice.Add(sp_.Id_parameter, acfaPar);
                    }


                    /* else
                     * {
                     *  throw new Exception("ERROR !!!! collectParameters (Interface.cs)");
                     * }*/
                }

                collectFV(acfaPar, pars, parsSlice);
            }
        }
	public SupplyParameter retrieve(string id_parameter, int id_functor_app){
	
	   SupplyParameter spc = null;

       int key = makeKey(id_functor_app, id_parameter);

       if (cache_c_pars_2.TryGetValue(key, out spc)) return spc;     

	   IDbConnection dbcon = Connector.DBcon;
       IDbCommand dbcmd = dbcon.CreateCommand();
       bool achou = false;
       string sql =
           "SELECT id_parameter, id_functor_app, id_functor_app_actual " +
           "FROM supplyparametercomponent " +
           "WHERE id_parameter like '" + id_parameter + "' AND id_functor_app=" + id_functor_app;
       dbcmd.CommandText = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       if(reader.Read()) {
           achou = true;
           SupplyParameterComponent spc_ = new SupplyParameterComponent();
       	    spc_.Id_parameter = (string)reader["id_parameter"];
       	    spc_.Id_functor_app = (int)reader["id_functor_app"];
       	    spc_.Id_functor_app_actual = (int)reader["id_functor_app_actual"];
            spc = spc_;
            cache_c_pars_2.Add(key, spc_);
       }


       if (!achou)
       {

           reader.Close();
           dbcmd.Dispose();

           sql =
               "SELECT id_parameter, id_functor_app, id_parameter_actual, freeVariable " +
               "FROM supplyparameterparameter " +
               "WHERE id_parameter like '" + id_parameter + "' AND id_functor_app=" + id_functor_app;
           dbcmd.CommandText = sql;
           reader = dbcmd.ExecuteReader();
           if (reader.Read())
           {
               achou = true;
               SupplyParameterParameter spc_ = new SupplyParameterParameter();
               spc_.Id_parameter = (string)reader["id_parameter"];
               spc_.Id_functor_app = (int)reader["id_functor_app"];
               spc_.Id_argument = (string)reader["id_parameter_actual"];
               spc_.FreeVariable= ((int)reader["freeVariable"])==0 ? false : true;
               spc = spc_;
               cache_c_pars_2.Add(key, spc_);
           }

      }

      reader.Close();
      dbcmd.Dispose();
      
      sql =
          "SELECT id_parameter, id_functor_app, id_abstract " +
          "FROM supplyparameter " +
          "WHERE id_parameter like '" + id_parameter + "' AND id_functor_app=" + id_functor_app;
      dbcmd.CommandText = sql;
      reader = dbcmd.ExecuteReader();
      if (reader.Read())
      {
          spc.Id_abstract = (int)reader["id_abstract"];
      }

       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
			
			
	   if (spc==null) 
	   {
	  	  Console.WriteLine("SupplyParameterDAO.cs: PARAMETER NOT FOUND "+ id_parameter + "," + id_functor_app);
	   }
			
       return spc;
       
	}//list