You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Luigi Selmi <lu...@gmail.com> on 2013/01/10 16:00:42 UTC

how to store a triple into the entityhub from within an enhacement engine

Hello all,
as in the subject of the email I need to store the enhancements that are
extracted from some text passed to my enhancer in a ContentItem. I am quite
new to Stanbol and OSGi programming and thought I should get a reference to
the Entityhub service through its interface
(org.apache.stanbol.entityhub.serviceapi.Entityhub ? ) and then call the
store(..) method to store an enhancement into the Entityhub. Following the
Felix documentation I should use a ServiceReference or a ServiceTracker to
get the reference of the Entityhub but an enhancer in Stanbol must
implement an EnhancementEngine interface that is different from a
BundleActivator so I am not sure how to get the Entityhub's reference. Any
help, best with some example code, will be greatly appreciated.

Regards

Luigi

Re: how to store a triple into the entityhub from within an enhacement engine

Posted by Gabriel Vince <ga...@apogado.com>.
Hello Luidi,

1. Practically - you are right that you have to implement and publish
a service implementing the EnhancementEngine interface.

2. Then you set up a chain - in the configuration console add a new /
update an existing enhancement chain to contain your enhancement
engine

and that's more or less all. You can use content hub to store content
and enhancements (even yours) into the rdf store.

Best regards
                Gabriel


-- 
Gabriel Vince
Senior Consultant
Apogado
http://www.apogado.com

Re: how to store a triple into the entityhub from within an enhacement engine

Posted by Rafa Haro <rh...@zaizi.com>.
Oh sorry,

I misunderstood the question then :-(

Regards

El 10/01/13 16:18, Luigi Selmi escribió:
> Hi Rafa,
> thanks for your quick response. I know that enhancements are automatically
> stored into a triple collections for the documents metadata. Maybe my
> example was not clear. What I need to know is how to get a reference to the
> Entityhub using the Java API (not the REST API).
>
> Best
>
> Luigi
>
>
>
> 2013/1/10 Rafa Haro <rh...@zaizi.com>
>
>> Hi Luigi,
>>
>> El 10/01/13 16:00, Luigi Selmi escribió:
>>
>>   Hello all,
>>> as in the subject of the email I need to store the enhancements that are
>>> extracted from some text passed to my enhancer in a ContentItem. I am
>>> quite
>>> new to Stanbol and OSGi programming and thought I should get a reference
>>> to
>>> the Entityhub service through its interface
>>>
>> I think that the enhancement graph is automatically store in the
>> ContentHub associated with the ContentItem. You can the retrieve it using
>> ContentHub REST API. Take a look to the API documentation:
>>
>> http://dev.iks-project.eu:**8081/contenthub/contenthub/**store/#<http://dev.iks-project.eu:8081/contenthub/contenthub/store/#>
>>
>>
>> Regards
>>
>>   (org.apache.stanbol.entityhub.**serviceapi.Entityhub ? ) and then call
>>> the
>>> store(..) method to store an enhancement into the Entityhub. Following the
>>> Felix documentation I should use a ServiceReference or a ServiceTracker to
>>> get the reference of the Entityhub but an enhancer in Stanbol must
>>> implement an EnhancementEngine interface that is different from a
>>> BundleActivator so I am not sure how to get the Entityhub's reference. Any
>>> help, best with some example code, will be greatly appreciated.
>>>
>>> Regards
>>>
>>> Luigi
>>>
>>>
>> This message should be regarded as confidential. If you have received this
>> email in error please notify the sender and destroy it immediately.
>> Statements of intent shall only become binding when confirmed in hard copy
>> by an authorised signatory.
>>
>> Zaizi Ltd is registered in England and Wales with the registration number
>> 6440931. The Registered Office is 222 Westbourne Studios, 242 Acklam Road,
>> London W10 5JJ, UK.
>>
>>

This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 222 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.


Re: how to store a triple into the entityhub from within an enhacement engine

Posted by Luigi Selmi <lu...@gmail.com>.
Hello Rupert,

thanks, the annotation works fine. One more thing to add to the pom is the
following dependency

<dependency>
        <groupId>org.apache.stanbol</groupId>
        <artifactId>org.apache.stanbol.entityhub.serviceapi</artifactId>
        <version>0.11.0-SNAPSHOT</version>
</dependency>

Regards

Luigi



2013/1/10 Rupert Westenthaler <ru...@gmail.com>

> Hi Luigi
>
> To get the Entityhub injected it is typically enough to add a field
> with an @Reference annotation to your EnhancementEngine
>
>
>    @Reference
>    protected Entityhub entityhub;
>
>
> Please make sure that your pom.xml file includes the
>
>       <plugin>
>         <groupId>org.apache.felix</groupId>
>         <artifactId>maven-scr-plugin</artifactId>
>       </plugin>
>
> maven plugin as this will consume those annotations.
>
> If you want to use a ServiceTracker you can do so. In this case you
> need to create and open the ServiceTracker in the "activate" method
> and close it in the "deactivate" method. During operation you can
> obtain the Entityhub by calling "Entityhub entityhub =
> (Entityhub)tracker.getService();"
>
> I hope this answers your question
>
> best
> Rupert
>
>
> On Thu, Jan 10, 2013 at 4:35 PM, Gabriel Vince
> <ga...@apogado.com> wrote:
> > Hello Luigi,
> >
> > 1. to add custom enhancements to the content you can just add triples
> > to the content's metadata graph (accessible in the enhancement
> > engine).
> >
> > 2. if you really want a reference to the EntityHub, indeed you can use
> > the OSGi API (through a BundleContent from your Activator).
> >
> http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#getServiceReference%28java.lang.Class%29
> >
> >
> >
> > Carpe diem
> >                 Gabriel
> >
> > On Thu, Jan 10, 2013 at 4:18 PM, Luigi Selmi <lu...@gmail.com>
> wrote:
> >> Hi Rafa,
> >> thanks for your quick response. I know that enhancements are
> automatically
> >> stored into a triple collections for the documents metadata. Maybe my
> >> example was not clear. What I need to know is how to get a reference to
> the
> >> Entityhub using the Java API (not the REST API).
> >>
> >> Best
> >>
> >> Luigi
> >>
> >>
> >>
> >> 2013/1/10 Rafa Haro <rh...@zaizi.com>
> >>
> >>> Hi Luigi,
> >>>
> >>> El 10/01/13 16:00, Luigi Selmi escribió:
> >>>
> >>>  Hello all,
> >>>> as in the subject of the email I need to store the enhancements that
> are
> >>>> extracted from some text passed to my enhancer in a ContentItem. I am
> >>>> quite
> >>>> new to Stanbol and OSGi programming and thought I should get a
> reference
> >>>> to
> >>>> the Entityhub service through its interface
> >>>>
> >>> I think that the enhancement graph is automatically store in the
> >>> ContentHub associated with the ContentItem. You can the retrieve it
> using
> >>> ContentHub REST API. Take a look to the API documentation:
> >>>
> >>> http://dev.iks-project.eu:**8081/contenthub/contenthub/**store/#<
> http://dev.iks-project.eu:8081/contenthub/contenthub/store/#>
> >>>
> >>>
> >>> Regards
> >>>
> >>>  (org.apache.stanbol.entityhub.**serviceapi.Entityhub ? ) and then call
> >>>> the
> >>>> store(..) method to store an enhancement into the Entityhub.
> Following the
> >>>> Felix documentation I should use a ServiceReference or a
> ServiceTracker to
> >>>> get the reference of the Entityhub but an enhancer in Stanbol must
> >>>> implement an EnhancementEngine interface that is different from a
> >>>> BundleActivator so I am not sure how to get the Entityhub's
> reference. Any
> >>>> help, best with some example code, will be greatly appreciated.
> >>>>
> >>>> Regards
> >>>>
> >>>> Luigi
> >>>>
> >>>>
> >>> This message should be regarded as confidential. If you have received
> this
> >>> email in error please notify the sender and destroy it immediately.
> >>> Statements of intent shall only become binding when confirmed in hard
> copy
> >>> by an authorised signatory.
> >>>
> >>> Zaizi Ltd is registered in England and Wales with the registration
> number
> >>> 6440931. The Registered Office is 222 Westbourne Studios, 242 Acklam
> Road,
> >>> London W10 5JJ, UK.
> >>>
> >>>
> >
> >
> >
> > --
> > Gabriel Vince
> > Senior Consultant
> > Apogado
> > http://www.apogado.com
>
>
>
> --
> | Rupert Westenthaler             rupert.westenthaler@gmail.com
> | Bodenlehenstraße 11                             ++43-699-11108907
> | A-5500 Bischofshofen
>

Re: how to store a triple into the entityhub from within an enhacement engine

Posted by Rupert Westenthaler <ru...@gmail.com>.
Hi Luigi

To get the Entityhub injected it is typically enough to add a field
with an @Reference annotation to your EnhancementEngine


   @Reference
   protected Entityhub entityhub;


Please make sure that your pom.xml file includes the

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-scr-plugin</artifactId>
      </plugin>

maven plugin as this will consume those annotations.

If you want to use a ServiceTracker you can do so. In this case you
need to create and open the ServiceTracker in the "activate" method
and close it in the "deactivate" method. During operation you can
obtain the Entityhub by calling "Entityhub entityhub =
(Entityhub)tracker.getService();"

I hope this answers your question

best
Rupert


On Thu, Jan 10, 2013 at 4:35 PM, Gabriel Vince
<ga...@apogado.com> wrote:
> Hello Luigi,
>
> 1. to add custom enhancements to the content you can just add triples
> to the content's metadata graph (accessible in the enhancement
> engine).
>
> 2. if you really want a reference to the EntityHub, indeed you can use
> the OSGi API (through a BundleContent from your Activator).
> http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#getServiceReference%28java.lang.Class%29
>
>
>
> Carpe diem
>                 Gabriel
>
> On Thu, Jan 10, 2013 at 4:18 PM, Luigi Selmi <lu...@gmail.com> wrote:
>> Hi Rafa,
>> thanks for your quick response. I know that enhancements are automatically
>> stored into a triple collections for the documents metadata. Maybe my
>> example was not clear. What I need to know is how to get a reference to the
>> Entityhub using the Java API (not the REST API).
>>
>> Best
>>
>> Luigi
>>
>>
>>
>> 2013/1/10 Rafa Haro <rh...@zaizi.com>
>>
>>> Hi Luigi,
>>>
>>> El 10/01/13 16:00, Luigi Selmi escribió:
>>>
>>>  Hello all,
>>>> as in the subject of the email I need to store the enhancements that are
>>>> extracted from some text passed to my enhancer in a ContentItem. I am
>>>> quite
>>>> new to Stanbol and OSGi programming and thought I should get a reference
>>>> to
>>>> the Entityhub service through its interface
>>>>
>>> I think that the enhancement graph is automatically store in the
>>> ContentHub associated with the ContentItem. You can the retrieve it using
>>> ContentHub REST API. Take a look to the API documentation:
>>>
>>> http://dev.iks-project.eu:**8081/contenthub/contenthub/**store/#<http://dev.iks-project.eu:8081/contenthub/contenthub/store/#>
>>>
>>>
>>> Regards
>>>
>>>  (org.apache.stanbol.entityhub.**serviceapi.Entityhub ? ) and then call
>>>> the
>>>> store(..) method to store an enhancement into the Entityhub. Following the
>>>> Felix documentation I should use a ServiceReference or a ServiceTracker to
>>>> get the reference of the Entityhub but an enhancer in Stanbol must
>>>> implement an EnhancementEngine interface that is different from a
>>>> BundleActivator so I am not sure how to get the Entityhub's reference. Any
>>>> help, best with some example code, will be greatly appreciated.
>>>>
>>>> Regards
>>>>
>>>> Luigi
>>>>
>>>>
>>> This message should be regarded as confidential. If you have received this
>>> email in error please notify the sender and destroy it immediately.
>>> Statements of intent shall only become binding when confirmed in hard copy
>>> by an authorised signatory.
>>>
>>> Zaizi Ltd is registered in England and Wales with the registration number
>>> 6440931. The Registered Office is 222 Westbourne Studios, 242 Acklam Road,
>>> London W10 5JJ, UK.
>>>
>>>
>
>
>
> --
> Gabriel Vince
> Senior Consultant
> Apogado
> http://www.apogado.com



-- 
| Rupert Westenthaler             rupert.westenthaler@gmail.com
| Bodenlehenstraße 11                             ++43-699-11108907
| A-5500 Bischofshofen

Re: how to store a triple into the entityhub from within an enhacement engine

Posted by Gabriel Vince <ga...@apogado.com>.
Hello Luigi,

1. to add custom enhancements to the content you can just add triples
to the content's metadata graph (accessible in the enhancement
engine).

2. if you really want a reference to the EntityHub, indeed you can use
the OSGi API (through a BundleContent from your Activator).
http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#getServiceReference%28java.lang.Class%29



Carpe diem
                Gabriel

On Thu, Jan 10, 2013 at 4:18 PM, Luigi Selmi <lu...@gmail.com> wrote:
> Hi Rafa,
> thanks for your quick response. I know that enhancements are automatically
> stored into a triple collections for the documents metadata. Maybe my
> example was not clear. What I need to know is how to get a reference to the
> Entityhub using the Java API (not the REST API).
>
> Best
>
> Luigi
>
>
>
> 2013/1/10 Rafa Haro <rh...@zaizi.com>
>
>> Hi Luigi,
>>
>> El 10/01/13 16:00, Luigi Selmi escribió:
>>
>>  Hello all,
>>> as in the subject of the email I need to store the enhancements that are
>>> extracted from some text passed to my enhancer in a ContentItem. I am
>>> quite
>>> new to Stanbol and OSGi programming and thought I should get a reference
>>> to
>>> the Entityhub service through its interface
>>>
>> I think that the enhancement graph is automatically store in the
>> ContentHub associated with the ContentItem. You can the retrieve it using
>> ContentHub REST API. Take a look to the API documentation:
>>
>> http://dev.iks-project.eu:**8081/contenthub/contenthub/**store/#<http://dev.iks-project.eu:8081/contenthub/contenthub/store/#>
>>
>>
>> Regards
>>
>>  (org.apache.stanbol.entityhub.**serviceapi.Entityhub ? ) and then call
>>> the
>>> store(..) method to store an enhancement into the Entityhub. Following the
>>> Felix documentation I should use a ServiceReference or a ServiceTracker to
>>> get the reference of the Entityhub but an enhancer in Stanbol must
>>> implement an EnhancementEngine interface that is different from a
>>> BundleActivator so I am not sure how to get the Entityhub's reference. Any
>>> help, best with some example code, will be greatly appreciated.
>>>
>>> Regards
>>>
>>> Luigi
>>>
>>>
>> This message should be regarded as confidential. If you have received this
>> email in error please notify the sender and destroy it immediately.
>> Statements of intent shall only become binding when confirmed in hard copy
>> by an authorised signatory.
>>
>> Zaizi Ltd is registered in England and Wales with the registration number
>> 6440931. The Registered Office is 222 Westbourne Studios, 242 Acklam Road,
>> London W10 5JJ, UK.
>>
>>



-- 
Gabriel Vince
Senior Consultant
Apogado
http://www.apogado.com

Re: how to store a triple into the entityhub from within an enhacement engine

Posted by Luigi Selmi <lu...@gmail.com>.
Hi Rafa,
thanks for your quick response. I know that enhancements are automatically
stored into a triple collections for the documents metadata. Maybe my
example was not clear. What I need to know is how to get a reference to the
Entityhub using the Java API (not the REST API).

Best

Luigi



2013/1/10 Rafa Haro <rh...@zaizi.com>

> Hi Luigi,
>
> El 10/01/13 16:00, Luigi Selmi escribió:
>
>  Hello all,
>> as in the subject of the email I need to store the enhancements that are
>> extracted from some text passed to my enhancer in a ContentItem. I am
>> quite
>> new to Stanbol and OSGi programming and thought I should get a reference
>> to
>> the Entityhub service through its interface
>>
> I think that the enhancement graph is automatically store in the
> ContentHub associated with the ContentItem. You can the retrieve it using
> ContentHub REST API. Take a look to the API documentation:
>
> http://dev.iks-project.eu:**8081/contenthub/contenthub/**store/#<http://dev.iks-project.eu:8081/contenthub/contenthub/store/#>
>
>
> Regards
>
>  (org.apache.stanbol.entityhub.**serviceapi.Entityhub ? ) and then call
>> the
>> store(..) method to store an enhancement into the Entityhub. Following the
>> Felix documentation I should use a ServiceReference or a ServiceTracker to
>> get the reference of the Entityhub but an enhancer in Stanbol must
>> implement an EnhancementEngine interface that is different from a
>> BundleActivator so I am not sure how to get the Entityhub's reference. Any
>> help, best with some example code, will be greatly appreciated.
>>
>> Regards
>>
>> Luigi
>>
>>
> This message should be regarded as confidential. If you have received this
> email in error please notify the sender and destroy it immediately.
> Statements of intent shall only become binding when confirmed in hard copy
> by an authorised signatory.
>
> Zaizi Ltd is registered in England and Wales with the registration number
> 6440931. The Registered Office is 222 Westbourne Studios, 242 Acklam Road,
> London W10 5JJ, UK.
>
>

Re: how to store a triple into the entityhub from within an enhacement engine

Posted by Rafa Haro <rh...@zaizi.com>.
Hi Luigi,

El 10/01/13 16:00, Luigi Selmi escribió:
> Hello all,
> as in the subject of the email I need to store the enhancements that are
> extracted from some text passed to my enhancer in a ContentItem. I am quite
> new to Stanbol and OSGi programming and thought I should get a reference to
> the Entityhub service through its interface
I think that the enhancement graph is automatically store in the 
ContentHub associated with the ContentItem. You can the retrieve it 
using ContentHub REST API. Take a look to the API documentation:

http://dev.iks-project.eu:8081/contenthub/contenthub/store/#


Regards
> (org.apache.stanbol.entityhub.serviceapi.Entityhub ? ) and then call the
> store(..) method to store an enhancement into the Entityhub. Following the
> Felix documentation I should use a ServiceReference or a ServiceTracker to
> get the reference of the Entityhub but an enhancer in Stanbol must
> implement an EnhancementEngine interface that is different from a
> BundleActivator so I am not sure how to get the Entityhub's reference. Any
> help, best with some example code, will be greatly appreciated.
>
> Regards
>
> Luigi
>

This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 222 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.