11-02-2016 08:23 AM
Hi,
I'm looking for a way to search by custom field in my custom aspect. I found some information, like https://www.bluefishgroup.com/insights/ecm/adding-metadata-fields-to-simple-search-and-live-search-w... or How to search metadata of documents ,but it seems very complicated. I can't find XML files, which are mentioned in these documents:
For example in first document from BlueFishGroup, there is information, that files
- live-search-docs.get.config.xml
- search.get.config.xml
should be extracted from file tomcat/webapps/alfresco/WEB-INF/lib/alfresco-remote-api-5.0.2.1.jar, from directory alfresco/templates/webscripts/org/alfresco/slingshot/search/, but I don't have that directory in this JAR file (in alfresco/templates/webscripts/org/alfresco/slingshot/ there are only directories called calendar and quadds, there is no search). Also even if I somehow would find this file, it is written, that
These files can now be modified to add additional metadata fields as needed. Once the files have been updated, they should be deployed to the ‘extensions’ directory so that they will override the out of the box configuration. If you are deploying your code as a custom AMP file, the files should target the following directory:
- tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search
I don't want to deploy it as a custom AMP, so I assume I should copy them to 'extension' directory. But where is that? Should i put them to those JAR file? Or should it be tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension directory? Or maybe /tomcat/shared/classes/alfresco/extension/ ?
I'm looking for help in that matter, because I'm begginer in Alfresco, and I just don't have enough knowledge to do that.
In second document, there is information, that if I want to search by custom metadata, I should write a webscript, and it is way over my knowledge.
Maybe there are some other ways to do that? I just can't believe, that managing so basic procedure, as searching by metadata is so complicated to insert.
11-10-2016 04:29 AM
Hi
I don't know whether you created custom aspect properly. If you want to create custom aspect, you need to create model file and register it through context file.You can place these files in tomcat/shared/classes/alfresco/extension. In extension folder you may find "exampleModel.xml.sample", make a copy of that file in same folder(extension) and remove its .sample extension and make .xml file. After that, edit imports if you want to inherit some aspect defined in other content model this comes under <imports> tag. If you don't want inheritance , keep it as it is. Under <namespaces> tag create your namespace by giving unique URI and prefix. Remove the <types> element. And edit the <aspects> element and define your custom aspect there by giving it's name and add your custom properties in <properties> element. Also in order to make your property indexed add index tag and define its enabled attribute to "true" as code snippet given below:
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
At this stage you created custom model which contains your aspect. In order to make alfresco to know your model register it with spring bean from a context file. You can also get sample context file example-model-context.xml, copy it and change its extension as you did before and in that file edit <beans> element and change bean id. And also change the path of the model file to the model file created by you.
After restart of alfresco service this model will be created and you can apply your aspect to any content in repository and can also search its properties through REST API or CMIS or alfresco share.
Here I am assuming you are using share. In order to make your aspect visible to share, edit share-config-custom.xml file present in tomcat/shared/classes/alfresco/web-extension(create if it is not present). Add aspect created by you to <visible> element. And you can edit or create advanced search forms through by placing this code in the same file.
Refer this code if you want to register your own advanced search form
<config replace='true' evaluator='string-compare' condition='AdvancedSearch'>
<advanced-search>
<forms>
<form labelId='search.form.label.cm_content' descriptionId='search.form.desc.cm_content'>cm:content</form>
<form labelId='search.form.label.cm_folder' descriptionId='search.form.desc.cm_folder'>cm:folder</form>
</forms>
</advanced-search>
</config>
And Refer this code to create or edit form
<config evaluator='model-type' condition='cm:folder'>
<forms>
<form id='doclib-common'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
</field-visibility>
<create-form template='../documentlibrary/forms/doclib-common.ftl' />
<appearance>
<field id='cm:title'>
<control template='/org/alfresco/components/form/controls/textfield.ftl' />
</field>
</appearance>
</form>
<form id='search'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
</field-visibility>
</form>
</forms>
</config>
For further details you can go through this link
Apart from share, if you are using CMIS then you can search your properties through query. Or you can also search it by REST APIs provided by alfresco.
Thanks,
Kalpesh
11-02-2016 12:23 PM
Hi:
A direct way of searching for a custom metadata of your content model (without developing) is just to put in Alfresco search something like:
ASPECT:"mycustom:somethingable"
@mycustomroperty:"whatever"
http://docs.alfresco.com/4.2/concepts/rm-searchsyntax-intro.html
Regards.
--C.
11-10-2016 04:29 AM
Hi
I don't know whether you created custom aspect properly. If you want to create custom aspect, you need to create model file and register it through context file.You can place these files in tomcat/shared/classes/alfresco/extension. In extension folder you may find "exampleModel.xml.sample", make a copy of that file in same folder(extension) and remove its .sample extension and make .xml file. After that, edit imports if you want to inherit some aspect defined in other content model this comes under <imports> tag. If you don't want inheritance , keep it as it is. Under <namespaces> tag create your namespace by giving unique URI and prefix. Remove the <types> element. And edit the <aspects> element and define your custom aspect there by giving it's name and add your custom properties in <properties> element. Also in order to make your property indexed add index tag and define its enabled attribute to "true" as code snippet given below:
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
At this stage you created custom model which contains your aspect. In order to make alfresco to know your model register it with spring bean from a context file. You can also get sample context file example-model-context.xml, copy it and change its extension as you did before and in that file edit <beans> element and change bean id. And also change the path of the model file to the model file created by you.
After restart of alfresco service this model will be created and you can apply your aspect to any content in repository and can also search its properties through REST API or CMIS or alfresco share.
Here I am assuming you are using share. In order to make your aspect visible to share, edit share-config-custom.xml file present in tomcat/shared/classes/alfresco/web-extension(create if it is not present). Add aspect created by you to <visible> element. And you can edit or create advanced search forms through by placing this code in the same file.
Refer this code if you want to register your own advanced search form
<config replace='true' evaluator='string-compare' condition='AdvancedSearch'>
<advanced-search>
<forms>
<form labelId='search.form.label.cm_content' descriptionId='search.form.desc.cm_content'>cm:content</form>
<form labelId='search.form.label.cm_folder' descriptionId='search.form.desc.cm_folder'>cm:folder</form>
</forms>
</advanced-search>
</config>
And Refer this code to create or edit form
<config evaluator='model-type' condition='cm:folder'>
<forms>
<form id='doclib-common'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
</field-visibility>
<create-form template='../documentlibrary/forms/doclib-common.ftl' />
<appearance>
<field id='cm:title'>
<control template='/org/alfresco/components/form/controls/textfield.ftl' />
</field>
</appearance>
</form>
<form id='search'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
</field-visibility>
</form>
</forms>
</config>
For further details you can go through this link
Apart from share, if you are using CMIS then you can search your properties through query. Or you can also search it by REST APIs provided by alfresco.
Thanks,
Kalpesh
11-17-2016 07:32 AM
Hey
I did it thanks to Kalpesh Patel's description (by the way Dobra robota). Thank you very much. But I have one small problem. Properties from my aspects are often lists of predefinied vavues, when one option is already selected, like here:
so if i'm searching anything I have to chose one value from list (in this example, in 'Rodzaj' or 'Projekt Rok' property, there are selected 'Publikacje' and '2000'), but I want be able to search something, that hasn't got my aspect's properties filled, or just search something by only one property.
So I assume, I need to have some "universal" value, which will be some kind of widcard for all other values, but of course if I just add one extra value (named for example "undefinied"), it won't do the trick.
So my question is, how to do that?
12-13-2016 09:56 AM
I've managed to do this. I had to add <apperance> for <form id='search'> section and chose control template for each property. Thank you all for all replies and help. This is how it looks like in share-config-custom.xml:
<config replace='true' evaluator='string-compare' condition='AdvancedSearch'>
<advanced-search>
<forms>
<form labelId='search.form.label.cm_content' descriptionId='search.form.desc.cm_content'>cm:content</form>
<form labelId='search.form.label.cm_folder' descriptionId='search.form.desc.cm_folder'>cm:folder</form>
</forms>
</advanced-search>
</config>
<config evaluator='model-type' condition='cm:content'>
<forms>
<form id='doclib-common'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
<show id='meta:date_asp' force='true' />
<show id='meta:type_asp' force='true' />
<show id='meta:proj-rok_asp' force='true' />
<show id='meta:komorka_asp' force='true' />
</field-visibility>
<create-form template='../documentlibrary/forms/doclib-common.ftl' />
<appearance>
<field id='cm:title'>
<control template='/org/alfresco/components/form/controls/textfield.ftl' />
</field>
</appearance>
</form>
<form id='search'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
<show id='meta:date_asp' force='true' />
<show id='meta:type_asp' force='true' />
<show id='meta:proj-rok_asp' force='true' />
<show id='meta:komorka_asp' force='true' />
</field-visibility>
<appearance>
<field id='cm:title'>
<control template='/org/alfresco/components/form/controls/textfield.ftl' />
</field>
<field id='meta:date_asp'>
<control template='/org/alfresco/components/form/controls/daterange.ftl' />
</field>
<field id='meta:type_asp'>
<control template='/org/alfresco/components/form/controls/selectmany.ftl' />
</field>
<field id='meta:proj-rok_asp'>
<control template='/org/alfresco/components/form/controls/selectmany.ftl' />
</field>
</appearance>
</form>
</forms>
</config>
and this is how looks the final effect:
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.