On Tue, Oct 24, 2017 at 9:34 PM, Vincent Massol <vincent(a)massol.net> wrote:
Hi Sarthak,
On 24 Oct 2017, at 17:30, Sarthak Gupta
<sarthakgupta072(a)gmail.com>
wrote:
Hello Vincent,
I have some confusion regarding transformations.
https://github.com/xwiki-contrib/application-glossary/
blob/master/application-glossary-api/src/main/java/
org/xwiki/contrib/glossary/internal/GlossaryTransformation.java
In my transformations, I am basically executing a query, which will get
the
document names(say 'name') of glossary
items from the glossary space
. And the simply passing a string reference called 'Glossary.name' as a
parameter to the DocumentResourceReference just like WikiWord
Transformation. So, I think it should create links to the respective
glossary pages.
But as you commented on my recent commit
<https://github.com/xwiki-contrib/application-glossary/commit/
9b04543627c7ccec0461a5d39d2b3f53f0d2815c#comments>
that
the method instead of returning the "names", it should load the glossary
data from the xobjects. I suppose this will function like: when a user
will
move their cursor on a particular glossary item
present on a particular
page, then it will load the information on the spot. Am I right? I don't
know but I think that I am not getting it right?
When a page is rendered, it’s first parsed into a XDOM object and then all
active transformations are executed one after another. Active
Transformations are controlled by the rendering.transformations property in
xwiki.properties.
(See architecture on
http://rendering.xwiki.org/
xwiki/bin/view/Main/WebHome for more details)
When a transformation executes, it’s execute() method is called.
The GlossaryTransformation should traverse the whole
tree of Blocks inside
the XDOM and try to find set of words that match the entries contained in
Glossary xobjects.
So in the 1st version, all you need to do is at the beginning of execute()
you run a query to get the full list of glossary xobjects and extract the
name from it.
I think I am doing the same thing.
You should ofc never run a query on each Block! That would kill the wiki :)
I have rectified this. I am just executing the query once inside the
transform()
block and storing the names in a list. And for each Block, I am
just fetching the names from the list.
Ok. wait! I should try executing this tranformation locally on my xwiki
instance first and make changes accordingly.
For running the transformation, I am placing the jar file generated in
application-glossary/application-glossary-api/target in
usr/lib/xwiki/WEB-INF/lib/ (and) importing the xar file in
application-glossary-api/target. Is this right?
Thanks
-Sarthak Gupta
There’s nothing more, it’s very very simple.
The harder part comes in the second version of the code when you improve
the performance so that the query is only executed when a Glossary xobject
is added/modified/deleted. You’ll implement that by using an EventListener
to refresh the cached list of Glossary names.
Is that clear? :) I thought I had explained this already several times but
maybe I’m not clear but I don’t know how to make it more clear. So you need
to tell me if there’s something not clear and what.
Thanks.
-Sarthak Gupta
P.S Sorry for my previous commits, Instead of 'git pull -f' I did simply
'git pull' so changes got merged. :P
ok!! You should always check the diff (git show -p <sha1>) before pushing
changes to avoid pushing wrong or unfinished things :)
Thanks
-Vincent
On Tue, Oct 17, 2017 at 7:31 PM, Vincent Massol
<vincent(a)massol.net>
wrote:
> Hi Sarthak,
>
>> On 15 Oct 2017, at 21:43, Sarthak Gupta <sarthakgupta072(a)gmail.com>
> wrote:
>>
>>
>>
>> On Sun, Oct 15, 2017 at 7:53 PM, Vincent Massol <vincent(a)xwiki.com>
> wrote:
>> Hi Sarthak,
>>
>>> On 14 Oct 2017, at 09:52, Sarthak Gupta <sarthakgupta072(a)gmail.com>
> wrote:
>>>
>>> Hello,
>>> As the tests of my project application-glossary
>>> <https://github.com/xwiki-contrib/application-glossary> are not
> working
>>
>> I’ll try to have a look when I’m back from GSOC summit.
>>
>>> , in
>>> spite of my attempts(I will handle then later), I am moving on to
>>> implementing the next feature of the application i.e creating
>>> transformation.
>>> As far as I understand, the transformation requires a cache component
> from
>>> which entries shall be taken for rendering purpose. This cache should
> get
>>> updated when a glossary xobject is added, deleted or modified. For
this
>>> functionality to take place, it
should make use of an Event Listener.
>>>
>>> Hope I am right till now?
>>
>> Yes that’s exactly it!
>>
>>
>> Hello Vincent,
>>
>> What I would suggest is that you implement the Transformation without
> cache for the first version, you make the app work fully end to end, you
> release a 1.0 version that the community can try out, and then you start
> working on version 1.1 which adds the cache to improve performance.
>>
>> WDYT?
>>
>> I think for implementing the transformations, some source will be
> required from which the entries already present in the Glossary space
will
> be taken. Here it is the cache object. So, an
alternative here can be to
> use the "query module" everytime for knowing which entries are present
in
> the Glossary Space. And that would slow down
the Xwiki to a large
extent I
> guess because for each word a query will be
executed. Would using the
> "Query" be fine or there can be any other better approach?
>
> Some ideas:
>
> Version 1.0:
> * When the transformation executes (i.e. when a page is rendered), you
do
> a query to get the glossary entries.
>
> Version 1.1:
> * You make your transformation implement Initializable and in
initialize()
> you go a query to get all existing Glossary
entries that you save in a
> cache component that you write
> * The cache component internally uses a Cache<> object for storing the
> Glossary entries
> * You also implement a component implementing EventListener that gets
the
> cache component injected so that you can
update the cache when glossary
> xobjects are created/modified/deleted.
>
> If you feel comfortable you can implement directly version 1.1 but my
> recommendation would be get a working v1.0 version ASAP and then
iterate to
> improve it.
>
> Hope it helps,
> Thanks
> -Vincent
>
> PS: Please keep the discussion on the list so that anyone can help you
and
> see the answers and chime in or just learn
from it! :)
>
>> Thanks
>>
>> Sarthak Gupta
>>
>>
>>>
>>> I have a question in my mind.
>>>
>>> The "cache" and the "event Listener" are to be
implemented as two
> separate
>>> components. right?
>>
>> Correct.
>>
>>> What I think is, that the EventListener component should be filled
with
>>> appropriate methods just like this
>>> <https://github.com/xwiki/xwiki-platform/blob/master/
> xwiki-platform-core/xwiki-platform-component/xwiki-
> platform-component-wiki/src/main/java/org/xwiki/component/
> wiki/internal/bridge/DefaultWikiObjectComponentMana
gerEventListener.java>
>>> and
>>> then in these methods, the cache should be updated.
>>>
>>> Is this implementation right?
>>
>> Correct.
>>
>>> And after this, the rendering part will come….
>>
>> Awesome.
>>
>> Thanks. Let me know if you need more of my/our help.
>> -Vincent
>>
>>>
>>> Thanks
>>>
>>> Sarthak Gupta
>
>