Welcome!

January 5th, 2009 No comments
  • english
  • french

Welcome to Pierrekiroule Consulting!

I share here with you my experience and findings about Business Intelligence (BI), Document Management, or other thoughts, findings and experiences.

To contact me, please send me an email at: consultant (at) pierrekiroule (dot) com

You can check my Linkedin resume and connect to me here (link opens a new window).

Categories: Uncategorized Tags:

Javascript conversions

May 17th, 2017 No comments

Celcius <-> Fahrenheit conversion
 = 
Kilograms <-> Pounds conversion
 = 
Km/h <-> Noeuds (knots)
 = 
© 2017 Pierrekiroule Inc.

Better and more conversions using javascript here

Categories: Tech tips Tags:

eDOCS document number <--> file name converter

March 1st, 2017 2 comments

Proof of concept using HTML5, Javascript and CSS.

Convert an eDOCS document number to file name








More advanced converter here

Categories: ECM, Tech tips Tags:

Fast switching users in Content Server demo site

November 24th, 2014 No comments

In Content Server, some settings are applied at a user level by the administrator. For instance, the access controls on the content, or the ability to create more or less type of objects in the system.
In order to quickly test or demonstrate this, it is convenient to switch from one user (with administrative rights) to other users showing the applied settings.
Here is one convenient way to do this using a custom view on the front page (Enterprise Workspace):

Screen Shot 2014-11-24 at 10.59.15 AM

fast switching users in Content Server

First, you need to enable “Allow log-in via HTTP GET request” under “Server Configuration > Configure Security Parameters > Log-in Connection Policies” in the admin pages. This may not work in a production environment for security purpose, but is acceptable in a demo or development environment:

HTTP GET request

HTTP GET request

Also, your environment must be using the Content Server Internal Authentication (or use a backdoor to access internal accounts on your server) for this switching to work.

Next, you may want to retrieve some users icons to use on the top row of the custom view (optional). I chose icons with a similar look and feel, and with a 64×64 size. You will save these icons in a location that is mapped in your Content Server Site:

By default, the “http://servername/img/” is mapped to the “..OPENTEXT/support” folder, so you could use this to save your icons in a subfolder within the “support” folder. Check the proper mapping (if different than “img”), and, save the icons in a folder named: “..OPENTEXT/support/appearances/users/”

You will also need to create and know the users needed for switching, together with their passwords (which will be visible to everyone, thus, making this method unsafe for a production environment)

Then you need to create a text file which will be used to build a custom view with the following code, using the “LL.login” function to pass the user name and password, and bypass the login screen of Content Server:

fast_switching
 
<style>
.center
{
text-align: center;
}
</style>
<table width="100%">
<tr>
<td class="center"><a href="http://<servername>/OTCS/cs.exe?func=LL.login&username=Admin&password=<admin_password>&NextURL=%2FOTCS%2Fcs.exe%3Ffunc%3Dllworkspace"><img src="http://<servername>/img/appearances/users/user1.png" alt="Admin" height="64" width="64"></a></td>
<td class="center"><a href="http://<servername>/OTCS/cs.exe?func=LL.login&username=<user_name>01&password=<user_password>&NextURL=%2FOTCS%2Fcs.exe%3Ffunc%3Dllworkspace"><img src="http://<servername>/img/appearances/users/user2.png" alt="John Doe" height="64" width="64"></a></td>
</tr>
<tr>
<td class="center"><a href="http://<servername>/OTCS/cs.exe?func=LL.login&username=Admin&password=<admin_password>&NextURL=%2FOTCS%2Fcs.exe%3Ffunc%3Dllworkspace">Admin</a></td>
<td class="center"><a href="http://<servername>/OTCS/cs.exe?func=LL.login&username=<user_name>&password=<user_password>&NextURL=%2FOTCS%2Fcs.exe%3Ffunc%3Dllworkspace">John Doe</a></td>
</tr>
</table>

The first row (<tr>) is for the icons, and the second row displays the text.

Replace the values between “<>” such as server name, passwords and user names with actual values, and also check for the image (icons) mapping, as well as the instance name (OTCS in this case, seen both in the beginning of the URL and in the NextURL tag).

Add as many <td> (cells) in each row of the table as you need users to switch.

Create a Customview in the Enterprise Workspace using this text file and test it. Ensure the custom view has proper permissions to allow all users to see and use it. When your user switching works, you can then hide this custom view from the Enterprise workspace.

Categories: ECM, Tech tips Tags: ,

Recursive queries with hierarchical result using SQL Server

February 10th, 2014 No comments

Recursive queries are not commonly used, yet they are very useful to display hierarchical data stored in flat tables.

Unlike the “Connect by” statement in Oracle, SQL Server doesn’t provide an easy answer to build them.

Here is a way to solve this with SQL Server, found after a bit of reading.

Lets use a flat table named “Example” containing some hierarchical data with the following column:

IDNameParentID
1Root NameNULL
2child11
3child21
4Grandchild12
5Crandchild22
6Grandchild13

In this table, any row can have a parent (except the root one), and therefore a hierarchy view could be created:

Root: Level 1Level 2Level 3
Root Name
Child1
Grandchild1
Grandchild2
Child2
Grandchild1

In order to create a query to display this hierarchical view, we first create a recursive source (‘recursive_source’) to provide the expected result. We will need the following 4 columns in our result:

  1. ID: a unique identifier used for joining itself recursively to the parent ID,
  2. The name: this is what we want to display in our report,
  3. The depth level: to be able to indent the result nicely
  4. A sort field: to ensure we display the data in proper hierarchical order

WITH recursive_source( ID, Name, Depth_Level, Sort) AS

(

The first selection is only to get the starting point, the root of our hierarchy (level 1), with the “Parent Name”:

Select    root.ID,

convert(varchar(255), root.name), /* The name, we need no discrepancy in the column type so we convert this into varchar */

1, /* depth level: this is the first iteration, therefore we set it at level 1 */

convert(varchar(255), root.name) /* we will start with the parent name for sorting our output */

from Example as root /* we name this first iteration table "root" */

Where root.ID = /* either know the parent ID, or prompt users to select where they would like to start the hierarchical report from */

This is where we create the recursive query

UNION ALL

Select    iteration.ID,

convert(varchar(255), REPLICATE('|---', Depth_Level) + iteration.Name), /* Add "|---" as many time as Depth_Level (= Replicate) in front of the name, this creates a natural indentation of the result */

Depth_Level + 1,  /* increment Depth_Level for next iteration */

convert(varchar(255), RTRIM(Sort) + '|---' + iteration.Name) /* Append the new name at the end of the sort field + "|---" to keep the hierarchical order of the data as previous level are in front of the name */

From Example as iteration, recursive_source /* The source is recursively queried */

where recursive_source.ID = iteration.ParentID

)

Then create the select statement which will display the sorted recursive result with hierarchical indentation:

Select Name 'Hierarchical Structure'

from recursive_source

order by Sort

Here is the full query in one block an no comment:

WITH recursive_source( ID, Name, Depth_Level, Sort) AS

(Select  root.ID,

convert(varchar(255), root.name),

1,

convert(varchar(255), root.name)

from Example as root

where root.ID =

UNION ALL

Select    iteration.ID,

convert(varchar(255),

REPLICATE('|---', Depth_Level) + iteration.Name),

Depth_Level + 1,

convert(varchar(255), RTRIM(Sort) + '|---' + iteration.Name)

From Example as iteration, recursive_source

where recursive_source.ID = iteration.ParentID

)

Select Name 'Hierarchical Structure'

from recursive_source

order by Sort

Excel macro n00b

December 10th, 2013 No comments

I just got tired and lazy while formating a report in Excel. Instead of manually clean the same rows more than 1100 times, I thought I’d better use my time creating a macro to automate the process…

All I wanted to do was to cut and paste a cell, and delete 3 rows, then repeat:

Move the cell to the right of the name (cut and paste it 2 rows above and one column right):

excel Macro 1

Delete empty rows (rows 3, 4 and 5 in the example above), and repeat this 1100 times:

excel Macro 2

So this is my extremely basic macro for doing this:

vb_code
 
  1. Sub Move_action()
  2. ' Move_action Macro
  3. ' Keyboard Shortcut: Ctrl+Shift+A
  4. Do While InStr(ActiveCell.Value, "Action") > 0
  5. ActiveCell.Cut Destination:=ActiveCell.Offset(-2, 1)
  6. ActiveSheet.Range(ActiveCell.Offset(-1, 0).EntireRow, ActiveCell.Offset(1, 0).EntireRow).Delete
  7. ActiveCell.Offset(1, 0).Select
  8. Loop
  9. End Sub

I then just selected the first “Action” cell, and ran the macro, watching Excel (slowly) do the work for me while I was eating my lunch 🙂

Categories: Tech tips Tags:

Creating cascading attributes with Open Text Content Server

January 23rd, 2012 1 comment

“Categories and Attributes” in Open Text Content server is a nice way to add customized metadata to your content stored in the system.

If you want to have “cascading” attributes, for instance “Country >> City”, where you will only display the list of cities within the selected country, you need to use some look-up tables and a bit of SQL.

Here is an example of how you can implement this, with one pitfall and how you can avoid it.

We will use the following sample data:

Countries:

Country_CodeCountry_ENCountry_FR
CNChinaChine
DEGermanyAllemagne
BEBelgiumBelgique

Cities:

Country_codeCity_CodeCity_ENCity_FR
CNBJBeijingPékin
CNGZGuangzhouCanton
CNSHShanghaiShanghaï
DEFRFrankfurtFrancfort
DEHAHamburgHambourg
DEBEBerlinBerlin
BEBXBrusselBruxelles
BENANamurNamur
BEGNGhentGent

 

Step 1: setting up the look-up tables with the data from above (SQL Server code / Transact-SQL):

  • Create the countries table:

CREATE TABLE CAT_COUNTRY(

[Country_code] [nchar](10) NULL,

[Country_EN] [nchar](255) NULL,

[Country_FR] [nchar](255) NULL

) ON [PRIMARY]

  • Populate the countries table:

INSERT INTO CAT_COUNTRY(

[Country_code]

,[Country_EN]

,[Country_FR])

VALUES

('CN','China','Chine'),

('DE','Germany','Allemagne'),

('BE','Belgium','Belgique')

GO

  • Create the cities table:

CREATE TABLE CAT_CITY(

[Country_code] [nchar](10) NULL,

[City_code] [nchar](10) NULL,

[City_EN] [nchar](255) NULL,

[City_FR] [nchar](255) NULL

) ON [PRIMARY]

  • Populate the cities table:

INSERT INTO CAT_CITY(

[Country_code]

,[City_code]

,[City_EN]

,[City_FR])

VALUES

('CN','BJ','Beijing','Pékin'),

('CN','GZ','Guangzhou','Canton'),

('CN','SH','Shanghai','Shanghaï'),

('DE','FR','Frankfurt','Francfort'),

('DE','HA','Hamburg','Hambourg'),

('DE','BE','Berlin','Berlin'),

('BE','BX','Brussel','Bruxelles'),

('BE','NA','Namur','Namur'),

('BE','GN','Ghent','Gent')

GO

Step 2: fixing a “Table Key Lookup” attribute type shortcoming:

The SQL code provided in the “Table Key Lookup” can’t be more than 255 characters, and must be very simple.

As we would like to combine and display in our look-up values the English and French description, and in order to keep the select statements simple in the attribute definition, we will then create 2 views from our previous tables as follow:

Create Country_View:


SELECT DISTINCT
RTRIM(country_EN) + ' - ' + RTRIM(country_FR) AS Country_desc
FROM CAT_COUNTRY
ORDER BY Country_desc

Create City_View:


SELECT DISTINCT
RTRIM(dbo.CAT_Country.Country_EN) + ' - ' + RTRIM(dbo.CAT_Country.Country_FR) AS Country_Desc,
RTRIM(dbo.CAT_City.City_EN) + ' - ' + RTRIM(dbo.CAT_City.City_FR) AS City_Desc,
FROM CAT_CITY
INNER JOIN CAT_COUNTRY
ON dbo.CAT_CITY.Country_Code = dbo.CAT_Country.Country_Code
ORDER BY Country_Desc, City_Desc

Step 3: Creating the Country and City category:

In the Content Server Categories volume, create a new Category named “Country and City” from the “Add Item” menu:

Click on the newly created category name to edit it.

In the “Add Attribute” drop down menu, select “Text: Table Key Lookup” to create the “Country” attribute:

Name it “Country” and use the following settings:

The “Custom SQL statement” box should be checked in order to edit the “Values” box where we will add the SQL statement to query the list of available countries in our look-up table:

Use the following simple select statement to retrieve the list of available countries from the look-up table:

Select Country_desc from Country_view

Create the “City” attribute in the same way (except that this one may not be required, and display it after “Country”), and with the following SQL select statement to retrieve the list of cities based on the selected country:

SELECT City_Desc FROM City_view where Country_Desc = <Country>

Then, test your newly created category by selecting first a country, and then display the available cities you can select:

Categories: ECM, Tech tips Tags:
"