Can I create sequences in Alfresco configuration files? - alfresco

I am in the process of developing a custom content model for Alfresco and customizing the share interface to match. I'm cosidering using constraints and selectone templates in the model definition and the share configuration respectively.
However, I think there must be a better way to implement things like years and year periods rather than having to explicitly hard code them into a list. Is there a way to generate a sequence of numbers (in this case, years and year periods) in these configuration files?
Here is a sample of the data I need to have in the constraints or selectone templates:
Years: 1953, 1954, 1955 ... 2012, 2013, 2014.
Year Periods: 1953-1955, 1957-1960, 1961-1964 ... 2001-2004, 2005-2008, 2009-2012.

Sure you can,
here you can find everything about content model constraints, but more specifically you can use:
<constraint name="test:minMax1" type="MINMAX">
<parameter name="minValue"><value>0</value></parameter>
<parameter name="maxValue"><value>256</value></parameter>
</constraint>
For your sequence. In this example you would have 257 numeric entries (from 0 to 256).
Hope it helps.

Related

D365 FO Simple Query for expiring contract

I need to create simple query which will show all contracts which will expire in next 3 months. I know how to do that with SQL, but how to do that in Visual Studio when I create query. I added data source Contract table. Added range. Column where is date about expiring is VALIDTO.
So, something to write up in value, or how to do that ?
Solved with two ranges on VALIDTO column. Used (MonthRange(0,3)) with (Day(0)) formulas.

marklogic 8 query performance down after inserting large number xml files in my database

I inserted 200000 xml document (approximately Total size 1GB) in my database through MLCP command. Now I want to run below search query against that database (database with default index setup in the admin api) to get all documents.
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<search-option>unfiltered</search-option>
<term>
<term-option>case-insensitive</term-option>
</term>
<constraint name="Title">
<range collation="http://marklogic.com/collation/" facet="true">
<element ns="http://learning.com" name="title" />
</range>
</constraint>
<constraint name="Keywords">
<range collation="http://marklogic.com/collation/" facet="true">
<element ns="http://learning.com" name="subjectKeyword" />
</range>
</constraint>
<constraint name="Subjects">
<range collation="http://marklogic.com/collation/" facet="true">
<element ns="http://learning.com" name="subjectHeading" />
</range>
</constraint>
<return-results>true</return-results>
<return-query>true</return-query>
</options>
let $result := search:search("**", $options, 1, 20)
return $result
Range Index:-
<range-element-index>
<scalar-type>string</scalar-type>
<namespace-uri>http://learning.com</namespace-uri>
<localname>title</localname>
<collation>http://marklogic.com/collation/</collation>
<range-value-positions>false</range-value-positions>
<invalid-values>ignore</invalid-values>
</range-element-index>
<range-element-index>
<scalar-type>string</scalar-type>
<namespace-uri>http://learning.com</namespace-uri>
<localname>subjectKeyword</localname>
<collation>http://marklogic.com/collation/</collation>
<range-value-positions>false</range-value-positions>
<invalid-values>ignore</invalid-values>
</range-element-index>
<range-element-index>
<scalar-type>string</scalar-type>
<namespace-uri>http://learning.com</namespace-uri>
<localname>subjectHeading</localname>
<collation>http://marklogic.com/collation/</collation>
<range-value-positions>false</range-value-positions>
<invalid-values>ignore</invalid-values>
</range-element-index>
In each xml document subjectkeyword and title value like be
<lmm:subjectKeyword>anatomy, biology, illustration, cross, section, digestive, human, circulatory, body, small, neck, head, ear, torso, veins, teaching, model, deep, descending, heart, brain, muscles, lungs, diaphragm, c</lmm:subjectKeyword><lmm:title>CORTY_EQ07-014.eps</lmm:title>
But it taking lots of time even query console saying Too many elements to render or Parser Error: Cannot parse result. File Size too large
I'd also add that if you wanted to fetch all documents (which I wouldn't recommend on a non-trivial database) doing it directly rather than as a wildcarded search is going to be more efficient: fn:doc() (or, as Geert suggests, paginated: fn:doc[1 to 20]
First of all, don't try to get all documents at once. It will mean MarkLogic will have to go to disk for every document, process, and serialize it, and last but not least, client-side need to receive and display too. The latter is probably the bottle-neck here. This is typically why user application show search results by 10 or 20 at a time. In other words: use pagination.
I also recommend running unfiltered for better performance.
HTH!
Pagination is definitely key here, and I'm curious about your facets. From your example, I'm imagining "Title" is almost always unique across your 200k documents. And the lmm:subjectKeyword element seems like it needs a little post-processing to make it more useful as a facet - it's a string of comma-delimited values, which means subjectKeyword will almost always be unique too (I recommend putting each of these values into a separate element, that would be much more useful as a facet). And I'm guessing subjectHeading is mostly unique too.
Facets are generally useful when you have a bounded set of values - e.g. for laptops, bounded sets include manufacturer, monitor size, and buckets for price range. Once you get into hundreds of values, the utility of a facet decreases for a user - how many users really want to sort through hundreds or thousands of values to find what they want? And in your case, we're probably talking about tens of thousands of unique values, if not 200k unique values (particularly for "Title"). And - when you have that many unique values, facet resolution time is going to take longer.
So before exploring the facet resolution time - what problem are you trying to solve with these 3 facets?
Without knowing anything more, I'd post-process that subjectKeyword element into many elements, each with a single keyword in it, and then put a facet on that element. Ideally, you have dozens of keywords, maybe hundreds, and resolving that facet should be very fast.

Adding custom index in Drupal SOLR Search API

Hi I have a requirement as below
I have a field collection which stores skill and years of experience. For example
Java 5 years
Spring 1 years
I have added the custom module to extract the skills to index , Ex : Java, Spring using
hook_entity_property_info_alter.
I also want to index the number of years for each skill, i.e., java_year_of_experience = 5 years, spring_years_of_experience = 1 years, etc...
How can I do this?
Use Solr dynamic fields.
Dynamic fields would allow to pass fields name that match certain patterns and are defined as below
e.g. <dynamicField name="*__year_of_experience" type="integer" indexed="true" stored="true"/>
By this you can handle any number of *_year_of_experience fields.
The fields will be created dynamically and need not be defined.

Date formatting issue in Marklogic

I am using xdmp:document-filter(doc(uri)) to fetch the metadata from the documents. When I run this command on one of the documents I get the following result:-
xdmp:document-filter(doc("/Vision.doc"))//*:meta[#name eq "Creation_Date"]/#content
<?xml version="1.0" encoding="UTF-8"?>
<results warning="attribute node">
<warning warning="attributes cannot be root nodes" content="17-05-2012 00:48:00"/>
</results>
And when I run this command on another document then I get this:-
<?xml version="1.0" encoding="UTF-8"?>
<results warning="attribute node">
<warning warning="attributes cannot be root nodes" content="2012-06-03T13:45:00Z"/>
</results>
You can see that date format is different in both the outputs. There may be different date formats in documents uploaded in Marklogic Server. But I want to show the creation date of documents in some fixed format (e.g. May 16, 2012). How can I convert the different date formats to a fixed date format ? And also I want to compare these dates to the date entered by the user. The documents matching the search criteria should get returned by the search query. So I have two questions here:-
How to convert creation date of particular documents to some fixed format and to display it in the UI.
How to compare this creation date to the date entered by the user(which is in "mm/dd/yyyy" format) so that I can get the correct result.
You will have to parse the dateTime value. For example:
let $dt := "17-05-2012 00:48:00"
return
if ($dt castable as xs:dateTime)
then xs:dateTime($dt)
else xdmp:parse-dateTime("[Y01]-[M01]-[D01] [h01]:[m01]:[s01]", $dt)
This will return an xs:dateTime atomic value, which can be compared and displayed in the UI. If you want to support additional formats, you will need to create additional parse "picture" strings so they can also be converted to xs:dateTime. See the documentation on xdmp:parse-dateTime() for more information.
As a part of a larger open source project I cooked up a date parsing library that handles at least 20 different formats in 6 different languages. You can also supply your own formats if one is not already defined. It works by feeding it a date as a string in any of the defined formats and returning an xs:dateTime if it was able to successfully parse it. You can find the library here:
https://github.com/marklogic/Corona/blob/master/corona/lib/date-parser.xqy
To use it:
import module namespace dateparser="http://marklogic.com/dateparser" at "date-parser.xqy";
dateparser:parse($filteredDocument//*:meta[#name eq "Creation_Date"]/#content)
This will allow you to normalize the various date formats that binary documents can have. I will note that different binary formats (Word, PDF, JPEG, etc) will use different names for the creation date. So just looking for the "Creation_Date" metadata could leave some holes depending on what formats you're storing in MarkLogic.
Also note, that if you just want the date information without the time portion, you can cast the xs:dateTime to an xs:date. Doing so will retain the timezone information which is likely a good thing.
As for your second question…
There is a number of different ways to do this and reading some of the MarkLogic documentation is a good place to start. I'd recommend taking a look at:
http://docs.marklogic.com/guide/search-dev/rangequery
Hopefully that will shed a bit of light on what your query needs to look like. In simplest form you will probably have to first parse the date that the user provided. This can also be done with the date parsing library so users can enter tons of different date formats (eg: November 13th, 2012 or even in Spanish Noviembre 13th, 2012). Then use that parsed date to construct date range queries in MarkLogic.
If that doesn't help I'd post another question here with the specifics of where you're getting hung up.

Month navigation sidebar in blog section?

I have a blog section in a drupal website, built with Views. I want to add a sidebar with month navigation (as in each mont is listed with the number of posts, etc). How can I do this, preferably with Views?
Drupal views can create views which allow you to select and list or summarise lists of nodes by various fields including the date related fields. You can do this by adding an argument, and then setting how the view behaves when no argument is supplied.
Are you looking for something along the following lines?
March 2010 (3)
February 2010 (12)
January 2010 (7)
... etc.
Create a view called Monthly Summary, and add an "argument" 'Node: Created year + month'.
Then use the options on the argument to select the 'action to take if argument is not present'. Select 'Summary, sorted descending' to create list with most recent month at top.
Watch out for sorting issues - this choice of how you sort the monthly summary in the argument settings will override the usual views sort order. This caught me out for a while.
Have you tried the Date/Calendar modules? Some more details about the Calendar module (from its project page):
This module will display any Views date field in calendar formats, including CCK date fields, node created or updated dates, etc. Switch between year, month, and day views. Back and next navigation is provided for all views. Lots of the Calendar functionality comes from the Date module, so any time you update the Calendar module you should be sure you also update to the latest version of the Date module at the same time.
See also Date iCal, a project that contains code and features needed to either import or export dates using iCal feeds. The functionality that used to be in the Calendar iCal module has been moved into that module.

Resources