Exemplo n.º 1
0
        /**
         * Collects all queries or template calls at a given class.
         * @param cls  the class to get the queries at
         * @param predicate  the predicate such as <code>spin:rule</code>
         * @param results  the List to add the results to
         */
        public static void addQueryOrTemplateCalls(IResource cls, INode predicate, List <QueryOrTemplateCall> results)
        {
            IEnumerable <Triple> ss = cls.listProperties(predicate);

            // Special case: we might have an instance of a template call like spl:Attribute
            //               Then try to find the Template in the registry
            if (!ss.Any() && cls != null && cls.isUri())
            {
                ITemplate template = SPINModuleRegistry.getTemplate(cls.Uri(), null);
                if (template != null)
                {
                    ss = template.listProperties(predicate);
                }
            }

            foreach (Triple s in ss)
            {
                if (!(s.Object is ILiteralNode))
                {
                    ITemplateCall templateCall = SPINFactory.asTemplateCall(Resource.Get(s.Object, cls.getModel()));
                    if (templateCall != null)
                    {
                        results.Add(new QueryOrTemplateCall(cls, templateCall));
                    }
                    else
                    {
                        IQuery query = SPINFactory.asQuery(Resource.Get(s.Object, cls.getModel()));
                        if (query != null)
                        {
                            results.Add(new QueryOrTemplateCall(cls, query));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        // TODO perhaps the one and only time we will refer to graphs instead of models ?

        /**
         * Gets all Models that are associated to registered functions and templates.
         * @return the Models
         */
        public static HashSet <SpinProcessor> getModels()
        {
            HashSet <SpinProcessor> spinModels = new HashSet <SpinProcessor>();

            foreach (IFunction function in SPINModuleRegistry.getFunctions())
            {
                spinModels.Add(function.getModel());
            }
            foreach (ITemplate template in SPINModuleRegistry.getTemplates())
            {
                spinModels.Add(template.getModel());
            }
            return(spinModels);
        }
Exemplo n.º 3
0
 /**
  * Sets the SPINModuleRegistry to another value.
  * @param value  the new value (not null)
  */
 public static void set(SPINModuleRegistry value)
 {
     // TODO Do we really need an instance ???
     //singleton = value;
 }