How to access a level 2 parent (grandparent) behaviour in JADE? - agents-jade

I am trying to access a grandparent behaviour and its Datastore in JADE. I have a level 3 nested behaviour in the Supervisor agent, as shown in the figure below.
The hierachy is
ContractNetResponder->Sequencial->ContractNetInitiator
ContractResponder(blue)->InquireServiceList(white)->Inquire(yellow)
I am trying access the the data store of the ContractResponder in the Inquire behaviour. I can access the InquireServiceList behaviour from within the Inquire behave but not the ContractResponder. This is what i have thus far:
InquireServiceList parent= (InquireServiceList) this.getParent();
System.out.println("1!! Parent ="+parent.getBehaviourName()+" Class ="+parent.getClass());
ContractNetResponder grandparent= parent. //I need to get parent here

One solution to this problem was to overide the getParent() method in the parent behaviour and change visibilty from protected to public. This solution was suggest by Arnould Guidat in the jade-development mailing list.

Also check root(); method in behaviour to access root behaviour.

Related

Determine if i18n is enabled for a JCR Property

How to access the corresponding FieldDefinition, if I have only the jcr property name at hand.
Is there any desired functionality,like find a field definition by a jcr property name ? If not, how would I access configured field definitions in java code ?
Scenario : I need to determine, if a given jcr property name was configured to be an i18n-capable field in definition ?
The answer is you can never be sure if property was configured to be i18n-able (or have any other trait) at the time it was last edited as definition might have changes since.
However to achieve what you want (obtain the definition), what you need to do is:
get a parent node of the property in question,
get value of it's mgnl:template property. That's your templateId,
use the templateId to obtain template from the registry,
read value of dialog property of the template, that's your dialogId
use the dialogId to obtain dialog from the registry
scan tabs in the dialog to find property definition with name of the jcr property you have started with

GetResource, dynamic parent.

my problem is the following. I'm currently making a blog-page with get-page, get-resources, form-it, and wayfinder. This question requires a decent amount of knowledge about Modx and snippits. I've got the page numberin and all working and i've got a template page with all my calls in it (called weblogTemplate). This template has the following wayfinder call in it :
[[!getResources? &parents=`5` &limit=`5` &tpl=`blogPost`]]
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=`4`
&depth=`2`
&limit=`5`
&pageNavOuterTpl=`[[+first]][[+prev]][[+pages]][[+next]][[+last]]`
&pageVarKey=`page`
&pageFirstTpl=`<li class="controlFirst"><a[[+classes]][[+title]] href="[[+href]]">Eerste pagina</a></li>`
&pageLastTpl=`<li class="controlLast"><a[[+classes]][[+title]] href="[[+href]]">Laatste pagina</a></li>`
&pagePrevTpl=`<li class="controlPrev"><a[[+classes]][[+title]] href="[[+href]]"><<</a></li>`
&pageNextTpl=`<li class="controlNext"><a[[+classes]][[+title]] href="[[+href]]">>></a></li>`
&includeTVs=`1`
&includeContent=`1`
&tpl=`blogListPost`
]]
as you can see the parent is set here to id number 5. This is fine for the homepage but any child page connected in the blog page also uses the same template and so would also have the same menu as the parent. You could use a fix to simply create 1 template for a page and keep using a different getResource call but keep in mind that it is a blog im making, new pages keep getting added. The user can't (, and wouldn't even understand to) make a template and edit any code. A solution i thought of would be to make the parent id dynamic, so it adjust to whatever page it is currently on. So for example if it was on the page with id number 12 it would make the parent call set to 12 and so show all the content under id number 12. If anyone has any ideas / thoughts / solutions i would be very grateful to hear them.
(a link about wayfinder that i used.)
The best solution would be to use two templates - one for main and one for the blog pages and use in blog templates:
&parents=`[[*id]]`
The problem with the user solveds by setting default_template in the system settings.
This worked for me:
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=`[[*id]]`
&depth=`0`
&limit=`10`
&pageNavOuterTpl=`[[+first]][[+prev]][[+pages]][[+next]][[+last]]`
&pageVarKey=`page`
&pageFirstTpl=`<li class="controlFirst"><a[[+classes]][[+title]] href="[[+href]]">Eerste pagina</a></li>`
&pageLastTpl=`<li class="controlLast"><a[[+classes]][[+title]] href="[[+href]]">Laatste pagina</a></li>`
&pagePrevTpl=`<li class="controlPrev"><a[[+classes]][[+title]] href="[[+href]]"><<</a></li>`
&pageNextTpl=`<li class="controlNext"><a[[+classes]][[+title]] href="[[+href]]">>></a></li>`
&includeTVs=`1`
&includeContent=`1`
&tpl=`blogListPost`
]]
Thanks to Vasis for the provided help.

update_attributes rails differentiate between create and update

I have a nested form (very similar to the one shown in RailsCasts) that I use an update_attributes, which updates the parent object as well as updating and creating new child objects. I want to be able to differentiate between when a child object is created and when a child object is updated and when the parent object is updated. Is there anyway to do so? My immediate goal is to push a broadcast when a new child object is created.
Trying to use an after_create do in the child model doesn't work for my purpose because I'm trying to call an action in the application_controller.rb.
The code is my parent object controller is
if #parent_object.update_attributes(params[:parent_object])
...want the push_broadcast to go here if it's a new record.
If I use debugger, params[:parent_object] returns this
{"overall_sharing"=>"1", "permissions_attributes"=>{"0"=>{"id"=>"66"}, "1"=> {"can_edit"=>"1", "can_copy"=>"1", "_destroy"=>"false", "id"=>"74"}, "1341967403169"=>{"user_id"=>"171", "can_edit"=>"1", "can_copy"=>"1", "_destroy"=>"false", "note_id"=>"423"}}}
for reference, the last bit is the new child object, the first is updating the parent object and the middle is updating the child objects.
I don't know if the correct path is the try to mess with the params or to think of a different route. Any advice would be much appreciated.
Thanks, Welles
If it's a new record it won't have an id. Unlike when editing or updating.
Just try to find it. If you can't then it's new.
if params[:id]
#existing record
else
#new record
end
Rails api has a nice documentation for nested attributes. (Rails guide falls short in this regard, in my opinion). I think it should answer most of your questions.

Is it possible to make Lucene queries in alfresco that find nodes based on their parent/children properties

is it possible to make Lucene query in alfresco that finds nodes based on their parent/children properties? For example i want to find all the nodes that have the property "foo" set to '1' and have nodes associated to them by a child association with the property "baz" set to '2' (maybe specifing somehow the name of their child association)
something like
#crl\:numeroAtto:"6555" AND #crl\:firmatario:"Marco rossi"
Where "numeroAtto" is a property of the parent node and "firmatario" is a property of the child. The association type is "firmatari" (It's not in the query because i don't know how to use it)
To be even clearer i'm trying to tell lucene: "Find all nodes that have the property numeroAtto set to 6555 and that have children (association type with the children: firmatari) with the property "firmatario" set to Marco rossi.
Thanx in advance
You can't search on associations, so what we do is not to build slow queries.
But add a new d:text property of the association on the parent Type.
So it's searchable through Lucune.
To make it fully working, create a Java Behaviour which checks on content update. And when 'your' association is found it adds it to the d:text property.
This way lucene searches are very quick.
There is no direct lucene way to do this.
Another idea: the first would return all of the parent nodes and then build searches based on the root of each returned node.

Displaying Custom Attributes in Documentum - Webtop

I am following an article that explains how to use the ICustomAttributeDataHandler class.
I am creating a custom column for the inbox screen, but the problem is that the value I set for my custom attribute is not being reflected on the screen.
As a test I am changing the task name to "whoKnows". But this code is not effecting what is output on the screen:
ICustomAttributeRecordSet.setCustomAttributeValue(i, "taskName", "whoKnows");
(I am able to print debug lines from my custom class when the inbox is viewed, so I know my code is being run.)
Someone on the comments of that article wrote:
the user must call the
"setCustomAttributesInQuery() method
on the dataprovider passing in a
string array of the custom attributes
...what does that meen? Could this be my problem?
thanks.
To be honest, I have already used Webtop, but just as an user. I found a post in the dm developer discussion group that can be useful, though:
For creating a custom column in the
doclist you dont need to go through
this complex procedures. You can use
custom attribute datahandlers for
this.
First in your object list component xml file add your custom column
definition in the "columns" tag. You
can even add static columns instead of
the documentum attributes.
Now create a class which implements the ICustomAttributeDataHandler.
Implement the default the methods getRequiredAttributes and the getData
function.
In getRequiredAttributes add attributes of the object that you are
looking for.
In your getdata method retrieve each row and then based on the
attribute that you see, just set the
value that you want to. 6) Finally
define your class in the app.xml file
There is a section in WDK developement
guide regarding
ICustomAttribuetDataHandlers. Look for
the topic named "Adding custom
attributes to a datagrid".
I'm not sure if this is the final solution, but I hope it helps!
To answer you question about setCustomAttributesInQuery()
every datagrid in WDK is backed by an underlying data provider. You can get this proivder by using the following code.
Datagrid datagrid = (Datagrid)getControl("doclist_grid",com.documentum.web.form.control.databound.Datagrid.class);
DataProvider dp = datagrid.getDataProvider();
Once you've done that, you can call
dp.setCustomAttributesInQuery(myArr);
I'm not actually sure if this is part of the solution to your problem, but you could try this and see where it gets you.
You have to configure the inbox component.
if using classic view, go to inboxlist component and add your custom attribute.
<column>
<attribute>CustomAttributeName</attribute>
<label>Custom Attribute Label</label>
<visible>true</visible>
</column>
Your custom attribute has to be in a custom type that is a sub type of dmi_queue_item, because inboxlist shows only dmi_queue_item objects.
Hope this helps,
Regards,
Tejas.
This may be a non-issue, but based on your code, I can't tell if you're doing this:
ICustomAttributeRecordSet.setCustomAttributeValue(i, "taskName", "whoKnows");
or this:
ICustomAttributeRecordSet rs;
rs.setCustomAttributeValue(i, "taskName", "whoKnows");
You should be calling the setCustomAttributeValue method on the rs object instance, not on the interface.