public Grounding generateOWLGrounding ( Service service ) throws DynamicGroundingBuildingException { JavaGrounding javaGrounding = service . getOntology ( ) . createJavaGrounding ( null ) ; JavaAtomicGrounding javaAtomicGrounding = service . getOntology ( ) . createJavaAtomicGrounding ( null ) ; AtomicProcess atomicProcess = service . getProcess ( ) . castTo ( AtomicProcess . class ) ; URI javaTransformatorURI = null ; try { javaTransformatorURI = new URI ( javaTransformatorURL ) ; } catch ( URISyntaxException ex ) { throw new DynamicGroundingBuildingException ( "cannot load needed ontology on " + javaTransformatorURL ) ; } // set Output with transformatorClass javaAtomicGrounding . setOutput ( null , method ( ) . getReturnType ( ) . getName ( ) , atomicProcess . getOutput ( ) ) ; javaAtomicGrounding . getOutput ( ) . addProperty ( javaTransformatorURI , service . getKB ( ) . createDataValue ( javaTransformatorClass ) ) ; // add Inputs with transformatorClass OWLIndividualList < Input > inputs = atomicProcess . getInputs ( ) ; Class < ? > [ ] methodParameterTypes = method ( ) . getParameterTypes ( ) ; if ( inputs . size ( ) != methodParameterTypes . length ) { throw new DynamicGroundingBuildingException ( "the method (" + ") and the service have different number of input parameters" ) ; } for ( int i = 0 ; i < inputs . size ( ) ; i ++ ) { javaAtomicGrounding . addInputParameter ( null , methodParameterTypes [ i ] . getName ( ) , i , inputs . get ( i ) ) ; } for ( Iterator < Input > it = inputs . iterator ( ) ; it . hasNext ( ) ; ) { javaAtomicGrounding . getInputParamter ( it . next ( ) ) . addProperty ( javaTransformatorURI , service . getKB ( ) . createDataValue ( javaTransformatorClass ) ) ; } // set Class and Method javaAtomicGrounding . setClazz ( clas . getName ( ) ) ; javaAtomicGrounding . setMethod ( methodName ) ; javaAtomicGrounding . setProcess ( atomicProcess ) ; javaGrounding . addGrounding ( javaAtomicGrounding ) ; javaGrounding . setService ( service ) ; service . addGrounding ( javaGrounding ) ; return javaGrounding ; }
It automatically creates Output and Inputs assigning them a Java Transformator class