cancel
Showing results for 
Search instead for 
Did you mean: 

Share, Aspects and Advanced Search

arnieaustin2
Champ in-the-making
Champ in-the-making
After having problems with the examples found in books and via Google, I browsed through this forum.

So, let me get this straight - we have Aspects, and can create custom forms to edit the properties - but we cannot search for content with these properties because for SOME reason, Advance Search cannot do that. What?!

I'm using the Community Edition, version 4.2c.

If I am wrong, then show me how to do it. I added:

<form labelId="aspect.agy_agencyDocument"
   descriptionId="aspect.agy_agencyDocument.search.description">agy:agencyDocument</form>


and it shows up in the menu, but when I select the option, I get:

org.alfresco.repo.forms.FormNotFoundException: 01050034 A form could not be found for item: [type]agy:agencyDocument


My form definition is:


<config evaluator="model-type" condition="agy_agencyDocument">
   <forms>
      <form id="search">
         <field-visibility>
            <show id="cm:name" />
            <show id="cm:title" force="true" />
            <show id="cm:description" force="true" />
            <show id="mimetype" />
            <show id="cm:modified" />
            <show id="cm:modifier" />
            <show id="agy:agencyId" />
            <show id="agy:agencyBusinessUnit" />
            <show id="agy:agencyDivision" />
         </field-visibility>
      </form>
      <appearance>
         <field id="cm:description">
            <control template="/org/alfresco/components/form/controls/textfield.ftl" />
         </field>
         <field id="mimetype">
            <control template="/org/alfresco/components/form/controls/mimetype.ftl" />
         </field>
         <field id="cm:modified">
            <control template="/org/alfresco/components/form/controls/daterange.ftl" />
         </field>
         <field id="cm:modifier">
            <control>
               <control-param name="forceEditable">true</control-param>
            </control>
         </field>
         <!– agy:agencyDocument –>
         <field id="agy:agencyId" label-id="agy_agencyCommonModel.type.agy_agencyDocument.title">
            <control template="/org/alfresco/components/form/controls/textfield.ftl" />
         </field>
         <!– agy:agencyBusinessUnit –>
         <field id="agy:agencyBusinessUnit" label-id="agy_agencyCommonModel.property.agy_agencyId.title">
            <control template="/org/alfresco/components/form/controls/textfield.ftl" />
         </field>
         <!– agy:agencyDivision –>
         <field id="agy:agencyDivision" label-id="agy_agencyCommonModel.property.agy_agencyDivision.title">
            <control template="/org/alfresco/components/form/controls/textfield.ftl" />
         </field>
      </appearance>
   </forms>
</config>

12 REPLIES 12

dantuffery
Champ in-the-making
Champ in-the-making
Is your aspect applied to a type? If so, change the condition to the type



<config evaluator="model-type" condition="my:type">
   <forms>
      <form id="search">
                ….
                ….
                </form>
        </forms>
</config>


Dan

Uh, no:

<aspects>
   <aspect name="agy:agencyDocument">
      <title>Agency Document</title>
       <description>Agency Document Metadata</description>
       <parent>cm:titled</parent>

<aspect name="oag:matter">
   <title>OAG Matter</title>
   <description>OAG Matter Metadata</description>
   <parent>agy:agencyDocument</parent>

mitpatoliya
Star Collaborator
Star Collaborator
you can change this


<config evaluator="model-type" condition="agy_agencyDocument">
to this
<config evaluator="model-type" condition="agy:agencyDocument">

I started with that actually. So, is it just not possible?

afaust
Legendary Innovator
Legendary Innovator
Hello,

yes, it is currently not possible to setup a search form based <b>just</b> on an aspect. The reason for this is that there is no FormProcessor on the Repository tier that can handle aspect-based forms.
The only way to setup a search form for an aspect is by using
sys:base
as your type and providing your aspect properties as filter fields. Unfortunately, if the user does not enter anything in at least on of the filter fields, you will find all nodes that match your search string, as there is no way to tell the search to search for
ASPECT:"prefix:localName"
via the form configuration. The only way to change that is by forcing a hidden property value into your nodes and search form that you know is the same for all nodes that have the aspect - that way, there will be an implicit filter on a property only your aspect provides and the search can only find nodes that have it applied.

I used the following approach to define a search just for wiki articles:
1) Setup a content rule / policy, that applies
myPrefix:wikiArticle
to any content created in a site ./cm:wiki container
2) Define the aspect with a boolean property
myPrefix:isWikiArticle
with default value set to true
3) Setup a search form for
cm:content
that includes a hidden field
myPrefix:isWikiArticle
with predefined value of true

Regards
Axel

Edit: added code-blocks to prevent smileys on qnames (hopefully)

arnieaustin2
Champ in-the-making
Champ in-the-making
Thanks! I can stop wondering/trying about it in the short term. But I was wondering, didn't I do something similar? My notes above didn't come out quite right, my aspects hierarchy is:

<aspect name="agy:agencyDocument">
   <parent>cm:titled</parent>

<aspect name="oag:matter">
   <parent>agy:agencyDocument</parent>


So, am I not part way there already?

I have another related question: so, if I do not provide a search for for users to use initially, but create content and apply my aspect and metadata - either through the edit forms or via code - can I at least search for such content in code? That is a big problem if not.

Lastly, is this a planned fix for the future? Because I really consider it a major lack of functionality.

arnieaustin2
Champ in-the-making
Champ in-the-making
Oh, one more thing, when setting up search: should I bother with:

<config>
   <simple-search-additional-attributes>
      <qname>{http://www.texasattorneygeneral.gov/model/common/1.0}agencyId</qname>



?

arnieaustin2
Champ in-the-making
Champ in-the-making
So, if I setup a form where
evaluator="model-type" condition="sys:base"
on the search form, how do I have a search page for for each my 5 aspects? Like:

<blockcode>
<form labelId="aspect.agy_agencyDocument" descriptionId="aspect.agy_agencyDocument.search.description">sys:base</form>
<form labelId="aspect.agy_accountingDocument" descriptionId="aspect.agy_accountingDocument.search.description">sys:base</form>
<form labelId="aspect.agy_purchasingDocument" descriptionId="aspect.agy_purchasingDocument.search.description">sys:base</form>
<form labelId="aspect.oag_matter" descriptionId="aspect.oag_matter.search.description">sys:base</form>
<form labelId="aspect.ord_itemIdentification" descriptionId="aspect.ord_itemIdentification.search.description">sys:base</form>
</blockcode>

afaust
Legendary Innovator
Legendary Innovator
Hello,

1) If possible, I'd advise to avoid aspect type hierarchies, as they can be quite tricky in programmatic evaluation. I.e. if you would execute a
nodeService.hasAspect("cm:titled")
on a document with
agy:agencyDocument
, you might find yourself surprised it returns "false", since this aspect has not been applied directly. If you want your agency documents to always also have the
cm:titled
aspect, you could use it as a default aspect of your custom aspect.
That is not to say that aspect type hierarchies should never be used - I use them quite extensively in some use cases. But they are not always strictly necessary and there are simpler ways of handling aspect inheritence.

2) You can always search for content with aspects in code. The only limitation is in the UI configuration of Share Advanced Search. You can also search for content with aspects as an end user if you know how to write that query and how the aspects are named on a technical level. You can try it yourself by entering
ASPECT:"agy:agencyDocument"
in the quick search / keywords input.

3) If you want to have several different types of search forms / pages for your 5 aspects, you need to provide an "id" in the AdvancedSearch config-section, which references a specific form from
evaluator="model-type" condition="sys:base"
.
I'll share the configuration I used to get wiki search working:
<blockcode>
    <config evaluator="string-compare" condition="AdvancedSearch">
        <advanced-search>
            <forms>
                <form id="wiki-search" labelId="search.form.label.cm_content.wiki-search" descriptionId="search.form.desc.cm_content.wiki-search">cm:content</form>
            </forms>
        </advanced-search>
    </config>

    <config evaluator="model-type" condition="cm:content">
        <forms>
            <form id="wiki-search">
                <field-visibility>
                    <show id="cm:name" />
                    <show id="cm:modified" />
                    <show id="cm:modifier" />
                    <show id="sthi:wikiContentMarker" force="true" />
                </field-visibility>
                <appearance>
                    <field id="cm:modifier">
                        <control>
                            <control-param name="forceEditable">true</control-param>
                        </control>
                    </field>
                    <field id="cm:modified">
                        <control template="/org/alfresco/components/form/controls/daterange.ftl" />
                    </field>
                    <field id="sthi:wikiContentMarker">
                        <control template="/com/bcc/alfresco/sitehierarchy/components/form/controls/hiddenTrue.ftl" />
                    </field>
                </appearance>
            </form>
        </forms>
    </config>
</blockcode>

Note that I wrote up a small FTL myself to have a hidden field with default value "true" in the search form for the dummy property I've included in my aspect (which is
sthi:wikiContent
and doesn't appear anywhere in the configuration at all directly).

Regards
Axel