devdoc

Tuesday, November 29, 2005

DQL to get the folder_path from r_object_id

Select s.r_object_id, fr.r_folder_path + s.object_name
From dm_sysobject s,dm_sysobject_r sr,dm_sysobject_r sr3, dm_folder_r fr
Where s.i_is_deleted = 0
AND sr3.r_object_id = s.r_object_id
AND sr3.i_position = -1
AND sr.r_object_id = s.r_object_id
AND fr.r_object_id = sr.i_folder_id
AND fr.i_position = -1
AND s.r_object_id = '[OBJECT_ID]'

Monday, November 28, 2005

SpringFramework kills me softly

This 2 lines have caused me a lot of trouble... Well, at the end it was not so complicated, but it does not help to feel me better... How much time lost for these two lines... snif snif...


WebApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext(
portlet.getContext());
BasicDataSource ds = (BasicDataSource) ctx.getBean("dataSource");



When you have a web application using Spring, and you want to use some bean from the definition, you ca use several different methods, but this one is probably the most powerful and leverages your Webapp....

But to make it work, you have to add this to the web.xml config file:


<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/intranet-servlet.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Wednesday, October 19, 2005

RSS and XSLT

If you have a feed and want to display only a few elements and add an alternate backgournd color maybe this stylesheet can give you some ideas :)


<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="/">

<div id="bbcNews">
<h2 class="bbc">World News</h2>
<xsl:apply-templates/>
</div>
</xsl:template>



<xsl:template match="rss">
<xsl:apply-templates/>
</xsl:template>



<xsl:template match="item">
<xsl:variable name="numItem"><xsl:number count="item" level="multiple" format="1"></xsl:variable>
<xsl:if test="$numItem &lt; 10">
<xsl:if test="$numItem mod 2 = 0">
<p class="bbcNotShaded"><xsl:value-of select="title"> <a href="{link}"> ...more</a></p>
</xsl:if>
<xsl:if test="$numItem mod 2 = 1">
<p class="bbcShaded"><xsl:value-of select="title"> <a href="{link}"> ...more</a></p>
</xsl:if>
</xsl:if>

</xsl:template>




<xsl:template match="text()">


</xsl:stylesheet>

Tuesday, October 18, 2005

Images

It would be nice if we could set the height and width to any image withot knowing anything about the image....


/*
* Ivan Pedrazas, Created on 18-Oct-2005
*
* (c) SWORD-UK 18-Oct-2005
* FILE: ImageAnalizer.java
*
* */
package com.sword.intranet.documentum.job;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.common.DfException;


public class ImageAnalizer {


private static final long serialVersionUID = 1L;
/** Logger for this class and subclasses */
protected static final Log logger = LogFactory.getLog(ImageAnalizer.class);

public static void analize(IDfSysObject sysObj){

ByteArrayInputStream bias = null;

try {
bias = sysObj.getContent();
BufferedImage image = ImageIO.read(bias);
setData(image,sysObj);
bias.close();
} catch (IOException e) {
logger.error(e.getMessage());
}catch (DfException e) {
logger.error(e.getMessage());
}

}

private static void setData(BufferedImage image,IDfSysObject sysObj){
boolean fSave = false;
try {
if(sysObj.hasAttr("cs_width")){
int width = image.getWidth();
if(width>0){
sysObj.setString("cs_width",Integer.toString(width));
fSave = true;
}
}
if(sysObj.hasAttr("cs_height")){
int height = image.getHeight();
if(height>0){
sysObj.setString("cs_height",Integer.toString(height));
fSave = true;
}
}
if(fSave){
sysObj.save();
}
} catch (DfException e) {
logger.error(e.getMessage());
}

}
}

Thursday, May 19, 2005

Renditions

What is the API statement to queue an HTML rendition of a document?


queue,c,[object_id],dm_autorender_win31,
rendition, 0, F,, rendition_req_html:html:zip_html


And the DFC???

In Javadocs we find: IdfSysobject Method public IDfId queue(String queueOwner, String event, int priority, boolean sendMail, IDfTime dueDate, String message) throws DfException

This is, if we have a SysObj. We just need to call the method queue with the same parameters from the API statement.

   IDfId objId = new DfId(objectId);
IDfSysObject sysObj= (IDfSysObject) session.getObject(objId )

IDfTime dueDate= new DfTime("19/05/2005 11:33:00");
sysObj.queue("dm_autorender_win31","rendition", 0,
false,dueDate,"rendition_req_html:html:zip_html");


:)

Tuesday, May 10, 2005

DQL: Retrive the child components in virtual document

If you have the r_object_id of a Virtual Document you always can launch the following DQL:



SELECT r_object_id FROM dm_sysobject
IN DOCUMENT ID('virtual_doc_id') DESCEND


But if you don't have the r_object_id and you want to extract the child components with a sigle query you must execute:


SELECT r_object_id,object_name,r_object_type,r_content_size,
a_content_type,r_is_virtual_doc,r_link_cnt,r_lock_owner,
a_content_type,owner_name,i_is_reference
FROM dm_document
WHERE r_is_virtual_doc <> 1 AND
i_chronicle_id IN (
SELECT component_id
FROM dmr_containment
WHERE parent_id = 'Virtual_Doc_ID'
)

If you want, for example, to retrieve all the child components from a virtual doc associated to a task you could launch the following query:


SELECT r_object_id,object_name,r_object_type,r_content_size,
a_content_type,r_is_virtual_doc,r_link_cnt,
r_lock_owner,a_content_type,owner_name,i_is_reference
FROM dm_document
WHERE r_is_virtual_doc <> 1 AND
i_chronicle_id IN (
SELECT component_id
FROM dmr_containment
WHERE parent_id IN (
SELECT distinct r_component_id
FROM dmi_package
WHERE r_workflow_id IN (
SELECT router_id
FROM dmi_queue_item
WHERE r_object_id='TASK_ID'
)
)
)

Wednesday, April 27, 2005

LDAP and Documentum

If anyone needs to configure Documentum to use an Active Directory to import the users, maybe it's going to find a tricky part... how to set the user_os_name when there's not an option to use it from the combo... Well, here it's described how to do it.

Once more, I don't understand why this information is not in any plae in Documentum Support forums or documentation.

How to set user_os_name to sAMAccountName?

Edit the atribute and write the filed name as a custom value

DM Attribute = user_os_name
LDAP Attribute = null
Custom Value = sAMAccountName

Query to get all the LDAP jobs
select * from dm_ldap_config


Query to get all the repeating attributes
select * from dm_ldap_config_r

Query to update an object to set the map_val_type to 'A'

UPDATE dm_ldap_config
OBJECT SET map_val_type[1]='A' WHERE r_object_id=''

Hope this saves some time!