Associate multiple properties in advanced search in Alfresco - alfresco

I've successfully added a custom form to the advanced search interface in Alfresco, but I'm facing a problem. Here's my custom form (search-config-custom.xml):
<config evaluator="model-type" condition="cv:document">
<forms>
<form id="search">
<field-visibility>
<show id="cv:appl_name" />
<show id="cv:appl_surn" />
<show id="cv:appl_phone" />
<show id="cv:appl_lang_1" />
<show id="cv:appl_level_1" />
<show id="cv:appl_lang_2" />
<show id="cv:appl_level_2" />
<show id="cv:appl_lang_3" />
<show id="cv:appl_level_3" />
</field-visibility>
</form>
</forms>
</config>
The form is basically querying information regarding job applicants. Applicants can enter up to three foreign languages in their profile, and assign a level of proficiency to them.
Now, here's the problem: let's say a recruiter wants to search for candidates with a high level of Spanish. As I have my form now, they would have to enter "Spanish" in the three language fields in order to get reliable results, as it's not known beforehand the order in which candidates entered their languages, if any.
So, I'm looking for a way to have a field that can automatically search across all the different language fields, so that instead of having "Language 1", "Language 2" and "Language 3", I can simply have "Languages" as a single search field. Then, language fields should be associated with their respected levels, and I really don't know how to do this.
Here's the content model the custom search form is querying:
<types>
<type name="cv:document">
<title>Job Application</title>
<parent>cm:content</parent>
<properties>
<property name="cv:appl_name">
<title>Applicant's first name</title>
<type>d:text</type>
</property>
<property name="cv:appl_surn">
<title>Applicant's last name</title>
<type>d:text</type>
</property>
<property name="cv:appl_phone">
<title>Applicant's phone number</title>
<type>d:text</type>
</property>
<property name="cv:appl_lang_1">
<title>Language 1</title>
<type>d:text</type>
</property>
<property name="cv:appl_level_1">
<title>Level for Language 1</title>
<type>d:text</type>
</property>
<property name="cv:appl_level_2">
<title>Level for Language 2</title>
<type>d:text</type>
</property>
<property name="cv:appl_level_3">
<title>Level for Language 3</title>
<type>d:text</type>
</property>
</properties>
</type>
</types>
I'm running Alfresco 5.0.0.

You could edit your SOLR schema to add a new SOLR field which would be filled with all languages. Then you'd query against that single field.
For example.
<field name="all" type="text___" indexed="true" omitNorms="false" stored="false" multiValued="true" />
<copyField source="*" dest="all" />

Related

alfresco evaluator on custom component

I've made a component and I'd like to show that component on the document-details page only if the document has a certain aspect, so I tried to use an evaluator. I've added this bean in custom-slingshot-application-context.xml
<bean id="evaluator.doclib.metadata.hasInvoiceAspect"
parent="evaluator.doclib.action.propertyNotNull">
<property name="property" value="inv:invoice"/>
</bean>
In document-details.xml I added this
<component>
<region-id>custom-comp</region-id>
<sub-components>
<sub-component id="default">
<evaluations>
<evaluation>
<evaluators>
<evaluator type="evaluator.doclib.metadata.hasInvoiceAspect"/>
</evaluators>
<url>/components/custom/custom-comp</url>
</evaluation>
</evaluations>
</sub-component>
</sub-components>
</component>
I guess I've missed something as the component doesn't show up. I have 2 files named custom-slingshot, I tried both tomcat/shared/classes/alfresco/web-extension and tomcat/webapps/share/WEB-INF/classes/alfresco/web-extension.
Am I completely wrong with this? Is it possible to achieve what I want like that? How should I proceed?
There is a predefined evaluator to check whether a node has an aspect called evaluator.doclib.action.hasAspect. You simply need to create a bean with this evaluator as the parent and give an aspect to check against in the properties:
*added to some -context.xml in web-extension
<bean id="my.custom.evaluator" parent="evaluator.doclib.action.hasAspect">
<property name="aspects">
<list>
<value>my:hasInvoiceAspect</value>
</list>
</property>
</bean>
Then you'll reference that bean in your DocLibActions config added to *extension-modules.xml (web-extension/site-data/extensions)...
<config condition="DocLibActions" evaluator="string-compare">
<actions>
<action...>
<!-- Custom evaluator -->
<evaluator>my.custom.evaluator</evaluator>
</action>
</actions>
</config>
Voila.
More info on predefined evaluators.
Good sample project here.

How to fetch & update custom aspect property in 5.1.1

We have created custom property using custom content model.We need to fetch below information from the custom content model.
1)How can we fetch all Node Ref's which is having the cc:status property?
2)Lets say I will create new namespace[http://www.XXXX.co/model/copy-status/1.0] and new aspect name[cc:new-digeststatus].How can we update all old properties of cc:status to the different aspect name[cc:new-digeststatus] with different namespace?
<namespaces>
<namespace uri="http://www.custom.co/model/custom-status/1.0" prefix="cc"/>
</namespaces>
<aspects>
<aspect name="cc:digeststatus">
<title>Status</title>
<parent/>
<properties>
<property name="cc:status">
<title>status</title>
<type>d:text</type>
</property>
</properties>
</aspect>
</aspects>

Remove default value for a custom property in Advanced search

I'm using Alfresco Share and I have a property with a default value
<property name="my:Property1">
<title>Property1</title>
<type>d:text</type>
<multiple>true</multiple>
<default>0</default>
</property>
I have customised the advanced search
<form id="search">
<field-visibility>
<show id="my:Property1"/>
</field-visibility>
<appearance>
<field id="my:Property1" label-id="Property1">
</appearance>
</form>
In Advanced search this property is initially filled with a default value, in my case with 0. Is there any way to remove that value from a search field?
I guess in this case it's best to create a custom Share Form controller like the textfield.ftl.
In the default controller there is a freemarker entry {field.value}. Just remove this entry throughout the template and there won't be any default value shown.

Log current page url with NLog

I'm trying to log the current pages URL as part of our NLog layout. I've scoured the NLog layout variables and have come up with nothing.
Does anyone know how to get the current page URL as a variable for the layout? Also is it possible just to extract the domain name so this can be used in the EventLog source attribute?
Use the Aspnet-request layout renderer.
<target xsi:type="Trace"
name="trace"
layout="${message} ${aspnet-request:serverVariable=Url}" />
You have full access to the request properties.
I tested many approached and only "item" seems to work in regards to http://msdn.microsoft.com/en-us/library/ms524602.aspx
method = ${aspnet-request:item=HTTP_METHOD}
url with query string = ${aspnet-request:item=HTTP_URL}
user agent / browser = ${aspnet-request:item=HTTP_USER_AGENT}
and so on...
UPDATE
Additionally to my answer above (I don't remember if I knew it back then or not) but I found somewhere (also don't remember where, was a while ago) that NLog.Extended.dll must be also referenced to use functionality relevant to ASP.NET logging ie. layouts with ${aspnet-...
Answer for .NET Core as I tried the above before finding that the above does not work for .NET Core
THE FOLLOWING DO NOT WORK FOR .NET CORE
${aspnet-request:serverVariable=Url}
${aspnet-request:item=HTTP_URL}
Instead use:
${aspnet-request-url}
${aspnet-request-querystring}
e.g.
<target name="jsonFile" xsi:type="File" fileName="log.json" archiveNumbering="DateAndSequence" archiveAboveSize="5000000" maxArchiveFiles="10">
<layout xsi:type="JsonLayout">
<attribute name="time" layout="${longdate}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString,StackTrace:maxInnerExceptionLevel=2}" />
<attribute name="machineName" layout="${machinename}" />
<attribute name="ip" layout="${aspnet-request-ip}" />
<attribute name="method" layout="${aspnet-request-method}" />
<attribute name="url" layout="${aspnet-request-url}" />
<attribute name="query" layout="${aspnet-request-querystring}" />
<attribute name="postedBody" layout="${aspnet-request-posted-body}" />
<attribute name="userAgent" layout="${aspnet-request-useragent}" />
</layout>
</target>
For more see:
https://nlog-project.org/config/?tab=layout-renderers&search=package:nlog.web.aspnetcore

Creating a Web Form from an XML Description of It

i am assigned to web part of some project.My duty is to create web form from xml.
These xml comes from window part and tells which controls are include in my web form and their properties.My xml Format is like below.
<Object type="System.Windows.Forms.Form">
<Property name="Name">Form1</Property>
<Property name="Text">Option</Property>
<Object type="System.Windows.Forms.RadioButton">
<Property name="Name">RadioButton1</Property>
<Property name="Size">86, 24</Property>
<Property name="Text">RadioButton1</Property>
<Property name="Location">175, 126</Property>
</Object>
<Object type="System.Windows.Forms.CheckBox">
<Property name="Name">CheckBox1</Property>
<Property name="Size">84, 24</Property>
<Property name="Text">Accept</Property>
<Property name="Location">84, 126</Property>
</Object>
<Object type="System.Windows.Forms.TextBox">
<Property name="Name">TextBox1</Property>
<Property name="Size">177, 20</Property> 1
<Property name="Text">Singapore</Property>
<Property name="Location">84, 88</Property>
</Object>
<Object type="System.Windows.Forms.Label">
<Property name="Name">Label1</Property>
<Property name="Size">100, 23</Property>
<Property name="Text">Name</Property>
<Property name="Location">7, 53</Property>
</Object>
<DataSet1>
<Table1>
<TableName>TableOne</TableName>
<ItemName>item001</ItemName>
<Qty>100</Qty>
<Price>1000</Price>
</Table1>
<Table2>
<TableName>TableTwo</TableName>
<ItemName>item002</ItemName>
<Qty>200</Qty>
<Price>2000</Price>
</Table2>
</DataSet1>
</Object>
what is the best way to solve my problem? i found some people used
XmlSerialization, so, can i use this way or is there any other way?
I hope you don't expect to be adding Windows Forms controls onto your web form.
This doesn't make much sense. You will not only need to create a web form - you also need to be able to create code to handle events from the controls on the form. I don't see anything in your XML that describes that.

Resources