Beispiel #1
0
 /**
  * Registers all templates defined in a given Model.
  * This basically iterates over all instances of spin:Template and calls
  * <code>register(template)</code> for each of them.
  * @param model  the Model to add the templates of
  */
 public static void registerTemplates(SpinProcessor model)
 {
     foreach (IResource resource in model.GetAllInstances(SPIN.ClassTemplate))
     {
         if (resource.isUri())
         {
             ITemplate template = (ITemplate)resource.As(typeof(TemplateImpl));
             register(template);
             ExtraPrefixes.Add(template);
         }
     }
 }
Beispiel #2
0
        /* *
         * Initializes this registry with all system functions and templates
         * from the SPL namespace.
         */
        //public void init()
        //{
        //    IGraph splModel = SPL.GetModel();
        //    IGraph spinModel = SPIN.GetModel();
        //    //TODO find as way to register common modules into
        //    MultiUnion multiUnion = JenaUtil.createMultiUnion(new Graph[] {
        //    splModel.getGraph(),
        //    spinModel.getGraph()
        //});
        //    multiUnion.setBaseGraph(splModel.getGraph());
        //    Model unionModel = ModelFactory.createModelForGraph(multiUnion);
        //    registerAll(unionModel, null);

        //    FunctionRegistry.get().put(SPIN.eval.Uri, new EvalFunction());
        //    PropertyFunctionRegistry.get().put("http://topbraid.org/spin/owlrl#propertyChainHelper", PropertyChainHelperPFunction);
        //}

        /**
         * Registers a Function with its URI to this registry.
         * As an optional side effect, if the provided function has a spin:body,
         * this method can also register an ARQ FunctionFactory at the current
         * Jena FunctionRegistry, using <code>registerARQFunction()</code>.
         * <b>Note that the Model attached to the function should be an OntModel
         * that also imports the system namespaces spin.owl and sp.owl - otherwise
         * the system may not be able to transform the SPIN RDF into the correct
         * SPARQL string.</b>
         * @param function  the Function (must be a URI resource)
         * @param source  an optional source for the function (e.g. a File)
         * @param addARQFunction  true to also add an entry to the ARQ function registry
         */
        public static void register(IFunction function, Object source, bool addARQFunction)
        {
            functions[function.Uri] = function;
            if (source != null)
            {
                sources[function] = source;
            }
            ExtraPrefixes.Add(function);
            if (addARQFunction)
            {
                registerARQFunction(function);
                if (function.isMagicProperty())
                {
                    registerARQPFunction(function);
                }
            }
        }