以前准备的一个PPT内容:
lIBM DB2 Content Manager OnDemand System
l马如林
l2008-9-4
l课程描述
l介绍OnDemand系统
l简单示例一个应用。
l使用Java通过API进行开发演示。
l培训目标
l了解OnDemand系统的体系结构和功能。
l了解OnDemand基本实现。
l开发人员能够看懂API,能够大概明白示例程序。
l前提知识
l数据库基础知识
l目录结构
l第一部分 OnDemand系统介绍
l第二部分 OnDemand数据库表
l第三部分 OnDemand简单示例
l第四部分 文档查询、更新、删除和添加
l第五部分 OnDemand客户机使用
l第六部分 OnDemand开发
l第一部分 OnDemand系统介绍
l1 什么是OnDemand?
lIBM DB2 Content Manager OnDemand(简称 OnDemand)是一种自动化的归档和检索系统,用于存储报告、声明、发票和图片文档之类的印刷品。这些印刷品经过处理之后保存在各种类型的存储媒介上,包括硬盘、光碟和磁带等。从印刷品中抽取的索引信息保存在关系数据库中,比如 DB2 Universal Database™ (UDB) 。在保存印刷品及其索引之后,您就可以使用任何OnDemand 客户程序查询和检索文档,一般不需要更新和删除。
l1 OnDemand体系结构图
l1 OnDemand体系结构
l由1个Library Server和一个或多个Object Server及Client(客户端)组成。
lLibrary Server:包含系统用户和报表存储信息,维护数据索引和服务器控制信息。
lObject Server:管理文件,存放在磁盘,光盘以及磁带等设备上。
lClient:在个人计算机或终端上运行,有管理客户端,用户客户端和网络客户端等不同呈现形式。使用客户端可以搜索和获取数据。
lOnDemand实用工具:用来访问OnDemand系统,执行管理任务,比如索引和装载文档。
l1 Library Server
l是OnDemand系统的核心,维护系统对象和归档文件的数据库信息,处理用户和管理员的请求。
lLibrary Server 使用关系数据库 比如DB2 创建和维护OnDemand 数据库,OnDemand 数据库管理OnDemand 系统信息。OnDemand 数据库包含用户(user) 信息表,组(group) 信息表,应用(application) 信息表和其他OnDemand 对象信息表。而且也包含系统消息,文档位置信息表等。
l 处理客户的登录、登出请求,验证安全性,解析文档查询,处理打印请求。
l1 Object Server
l主要是存储和管理文档
lcache 存储
l 在线存储,有速度快,迅速访问的优点。
lArchive Storage Manager( 可选)
l 过期文档,长期(long term) 存储,一般使用光盘和磁带,此时需要使用TSM(Tivoli) 或者OAM(Object Access Method) 。
l1 Client
l运行在Windows平台下,提供GUI接口:
lAdministrative Client
l定义和操作OnDemand对象(users, applications, folders)和控制数据(安全和访问权限)
lUser Clients
l 查询,检索,显示和打印文档
lWeb Clients
lODWek(OnDemand Web Enablement Kit) 的一部分,需要单独购买
l1 Utility Programs(实用程序)
l文档索引和转换
l文档存入OnDemand前,首先需要建立索引,如果需要可以进行转换,比如EBCDIC到AFP(Advanced Function Presentation)格式的转换。
l数据装载
l索引建立后,其文件被装载进OnDemand系统,Library Server更新关联数据库表,Object Server存储文档。
l维护和管理
l文档过期,压缩,删除等管理。
l1 OnDemand对象图
l1 OnDemand对象
l用户(Users)
l组(Groups)
l应用程序(Applications)
l应用程序组(Application Groups)
l存储集(Storage Sets)
l文件夹(Folders)
l打印机(Printers)
l注:可以使用客户机对上述对象进行维护。
l1 用户(Users)
¡用来访问OnDemand系统,每个用户有自己的user id ,password,控制信息和对不同组件的访问权限。
¡系统默认创建ADMIN用户,密码为空。
¡创建用户是需要指定“用户类型”和“权限”
“用户类型”分为:用户(User),用户管理员(User Administrator),应用程序组/文件夹管理员(Application Group/Folder Administrator),系统管理员(System Administrator)
“权限”分为:创建用户(Create User),创建组(Create Group),创建应用程序组(Create Application Group),创建文件夹(Create Folder)。“权限”是有选择性的使用户在系统上执行其他操作。
l
l注:用户相关信息使用数据库表进行存放。系统管理员(System Administrator)是唯一可以维护存储集和打印机的用户。
l1 组(Groups)
l对用户可以进行编组,简化管理
l1 应用程序(Application)
l每个不同的文档需要创建一个应用程序(Application),该应用程序描述了文档的物理特征和逻辑特征,包含文档类型,编码方式(EBCDIC或ASCII),索引参数(索引时查找和抽取关键字),字段定义。
l可以为应用程序(Application)创建逻辑视图,提供显示报告页的不同方式。
l1 应用程序组(Application Group)
l是一个或多个具有相同查找值和相同存储的应用程序(Application)集合。
l应用程序组(Application Group)决定怎么存储数据,过期日期,字段定义以及类型选择,用户以及权限访问,消息日志管理。
l1 文件夹(Folder)
l用户需要通过文件夹(Folder)访问文档,用户需要打开文件夹(Folder)进行查询。
l文件夹(Folder)定义了哪些字段可以查询,查询方式,结果的显示方式,用户访问权限等。
l1 存储集(Storage Set)
l实现存储需求,是OnDemand和Archive Storage Manager之间的接口,在应用程序组(Application Group)中定义,存储集表明文档的存放位置和过期日期。
l包含cache storage / archive storage。
l1 打印机
l提供信息给OnDemand系统去定位打印机。
l打印机可以是本地的,也可以是网络的,也可以是服务器打印机。
l1 文档访问
l构建查询
l查找文档
l显示文档
l添加注释
l打印
l如图:
l1文档归档-Indexing and Loading图
l如图:
l1文档归档-Indexing and Loading
l使用ARSLOAD根据Application Parameters, Application Group Parameters 和 Input Data File建立Indexer(.ind,.out,.res文件)其中.ind是索引文件存储在Application Group Table对应的表中,.out和.res存储在Cache and /or SM storage中。在indexing成功后才调用arsadmin进行压缩、文档和资源、索引的存储。
l
l 注意:输入文件的大小不超过4GB。
l1文档归档-Index Tables
l每个应用程序组包含一个逻辑索引表
l1 文档的物理存储
l/arscache1
l /14208 Date Directory
l / BAA Application Group Directory
l /DOC
l / 1FAA1 1FAAA Storage Objects
l1 应用程序组表(Application Group Table)
lApplication Group Tables用来维护index信息和文档位置。Index信息从文档中抽取,存储位置信息在系统存贮时存储。
l一个Application Group 关联一个Logic Table,一个Logic Table包含多个Physical Table,每个Physical Table称为Segment。
l相关联表:arsag,arsagfld,arsfol,arsfolfld,arsag2fol,arsseg,以及arsseg中TABLE NAME字段对应的一个表。
l1 Segment Table
lSegment为提高系统效率的方法而使用。
l每个物理索引表是个Segment。
l每个Segment包含开始日期和结束日期,查询时可以通过该日期缩小查询范围。
l1文档检索步骤
l用户输入查询
l使用segments消除不符合的segment
l使用数据库索引消除不符合的记录
l查找符合条件的记录
l返回给用户
l用户选择一个文档
l根据索引行定位该文档
l文档压缩块被检索到
l文档从文档压缩块中被检索到
l文档被解压缩并返回给用户
l1 维护和管理
l迁移过期文档
l迁移过期索引
l恢复迁移索引
l组织和优化数据库
l数据备份
l其他系统任务
l第二部分 OnDemand数据库表
l2 数据库表分类
l管理表(Administrative)
l用来存储OnDemand对象信息:用户(Users) ,组(Groups),应用程序(Applications),应用程序组(Application Groups)等。
l数据库系统表(Database System)
l关系数据库用来维护OnDemand数据库使用的。
l应用程序表(Application Group)
l存储文档索引,存储信息。
l
l注:表明一般以ARS开头,ARS(Archive Retrieve System)是OnDemand的前身。
l2 用户(User)表-ARSUSER
l用户表信息
l2 组(Group)表-ARSGROUP
l组信息表
l2 用户-组关联表-ARSUSRGRP
l用户-组表之间的关系
l第三部分 OnDemand简单示例
l3 OnDemand索引类型
lACIF------ AFP and line data documents
lPDF--------PDF documents
lXENOS----Transform a variety of data
lGENERIC(一般)-------Graphic and user defined data
lNONE------No indexing(system log & migration log)
l3 新应用处理前的用户和组准备
l用户
l创建sample用户,类型为应用程序组/文件夹。
l 组
l 创建sampleGroup 组,将sample 放入。
l
l
l 注:根据需要修改用户或组的权限。
l3 文本示例-line data
lsample.txt
l3 样本文件分析
l假设我们需要将sample.txt存入OnDemand系统,首先需要我们对该文档建立索引,对sample中的数据进行提取建立如下查找值:
lID:编号
lNAME:用户名
lSDATE:日期
l也就是说,以后可以通过ID,NAME,SDATE这些值来定位该文档
l3 应用程序组(Application Group)设置
l设置sample.txt的存储(存储位置,过期日期),索引,消息日志,访问权限等相关信息。
l索引建立:
lID(Integer,Index, 固定长度) 。
lNAME(String,Index, 变成) 。
lSDATE(Date,Segment) 使用Segment 可以提供查询速度。
l3 应用程序(Application)设置
l设置如何对sample.txt进行索引,字段设置,如何触发数据,数据是否压缩,视图显示等。
l参数如右图所示:
l3 文件导入到OnDemand系统
l使用命令行工具ARSLOAD导入文件:
l3 文档存储过程
l假设有必要,索引器分割输入物理文件为逻辑文件,存储为.out文件。
l装载器在计算机内存中分配一个存储对象的大小,该大小在应用程序组中设置。
l装载器压缩(可选)逻辑文件并存储在内存的存储对象中,当存储对象满或逻辑文件处理完毕,存储对象被传递给对应的存储管理器,在应用程序组的存储集中设置。
l存储管理器选择合适的位置保存存储对象,保存位置也在应用程序组中设置。
l3 文档查询-创建文件夹(Folder)
l文档查询前需要创建文件夹(Folder)
l创建文件夹(Folder),设置字段和查询条件,并和应用程序组(Application Group)字段对应。
l
l
l 注:客户端登录后打开文件夹即可查询。
l3 ARSLOAD自动装载文档
¡自动装载使用文件名识别哪个应用程序组
默认文件名:
lHLQ.JOBNAME.DATASET.FORMS.YYYYDDD.HHMMSST.ARD
lHLQ.JOBNAME.DATASET.FORMS.YYYYDDD.HHMMSST.PDF
HLQ(High Level Qualifier),JOBNAME,DATASET和FORMS是用户设置的,YYYYDDD是4位年数和一年的第多少天,后面是时分秒和十分之一秒。后缀PDF是PDF文档专用,其他使用ARD。
使用FORMS部分作为应用程序组,假设一个应用程序组只包含一个应用程序。
¡#./arsload –u user –p password –d /tmp/ztmp –c /tmp/indexInfo –t 3600 >> /tmp/msg.out 2>&1
其中-t是以秒为单位的,目录必须首先存在并注意目录的权限。
/tmp/ztmp目录中的文件必须按规则命名:
HSP02.job12.ds.sampleAG.2008012.13450000.ARD
l第四部分 文档查询、更新、删除和添加
l4 文档查询日期字段-ARSDATE
l需要使用其自身的日期进行转换,有ARSDATE工具实现
l>arsdate –g
l获取当前日期
l>arsdate -a 09/05/08
l09/05/08 -> 14128
l>arsdate -a 14128
l14128 -> 09/05/08
lm/d/y 格式 09/05/08
l4 文档查询-ARSDOC-query
l如图:
l4 文档查询-选择其中的字段
lquery -h localhost -u sample -p password -f sampleFolder -i "where id=111123" -v -N(ID)
l4 文档查询-复合查询
l>arsdoc query -h localhost -u sample -p password -f sampleFolder -i "where id=111123 and name='TEST123'" –v
l>arsdoc query -h localhost -u sample -p password -f sampleFolder -i "where id=111123 and name like '%TEST%'" –v
l>arsdoc query -h localhost -u sample -p password -f sampleFolder -i "where id=111123 and name like '%TEST%'" -v -N"(id)(name)"
l4 文档查询-查询日期字段
l>arsdoc get -h localhost -u sample –p password -f sampleFolder -i "where sdate=14129" –v
l
l其中14129对应2008-09-05。
l4 查询文件夹字段
l>arsdoc query -h localhost -u sample -p password -f sampleFolder -H -v
l
¡2008-09-05 17:18:48: Starting arsdoc. Version: 7.1.2.0
l
¡2008-09-05 17:18:48: arsdoc query -h localhost -u sample -f sampleFolder -H -v
l
¡2008-09-05 17:18:48: Attempting login for userid 'sample' on server 'localhost'
¡...
l
¡2008-09-05 17:18:48: Login successful
l
¡2008-09-05 17:18:48: Searching for folder 'sampleFolder' ...
l
¡2008-09-05 17:18:48: Search successful
¡ID,NAME,SDATE
l
¡2008-09-05 17:18:48: arsdoc completed.
l4 获取文档
l在命令行窗口显示文件内容。
l>arsdoc get -h localhost -u sample –p password -f sampleFolder -i "where id=111123“ –v
l 将获取的文档存在c:/tmp/out 目录下,文件名outfile.1 ,outfile.* 。
l>arsdoc get -h localhost -u sample –p password -f sampleFolder -i "where id=111123" -o outfile -d c:/tmp/out
l4 添加文档
lC:/Program Files/IBM/OnDemand for WinNT/bin>arsdoc add -h localhost -u sample -p password -v -g sampleAG -a sampleA -f sampleFolder -o c:/tmp/loadsample -n "id=123456" -n "name='hhh'" -n "sdate=14219“
l添加loadsample文件目录下的文件进入OnDemand系统。
l
l注意:由于后来ADD操作的特殊性,所以该操作必须是Multiple Loads per Table和Expiration Type为Document或Segment时才可以使用。
l5 添加同一文档的多个索引
l>arsdoc add -h localhost -u sample –p password -v -g sampleAG -a sampleA -f sampleFolder -i "where id=111111" -n "id=123456" -n "name='hhh'" -n "sdate=14219“
l在原有的111111索引的基础上添加了123456索引。
l
l注意:由于后来ADD操作的特殊性,所以该操作必须是Multiple Loads per Table和Expiration Type为Document或Segment时才可以使用。
l5 更新索引
l>arsdoc update -h localhost -u sample -p password -f sampleFolder -i "where id=111123" -n "id=111111" –v
l
l更新后,所有原id为111123的更新为111111。
l4 删除文档
l>arsdoc delete -h localhost -u sample -p password -f sampleFolder -i "where sdate=14128" –v
l
l所有日期为2008-09-05日期的文档和索引被删除。
l4 文档过期-ARSMAINT(日常维护工具)
l可以使用arsmaint命令行工具进行维护
l
larsmaint通过比较当前日期和文件原来设定的日期进行比较,进行删除处理。
l第五部分 OnDemand客户机使用
l5 客户机登录
l登录到OnDemand服务器以及设置:
l5 文档查询-打开文件夹
l使用Windows客户端登录,输入用户名和密码登录,打开文件夹。
l5 文档查询-文档索引列表
l查询效果:
l双击文档
l即可以查
l看完整文
l档
l
l 右键可见
l 文档详细
l 属性
l5 文档查询-查看文档
l如图:
l5 文档查看-多文档
l5 文档删除-ARSADMIN UNLOAD
l使用命令行:逻辑删
l
l5 文档注释-添加
l文档可以添加注释
l5 文档注释-删除
l可以删除注释
l
l 注:需要该用户具有对应权限
l5 文档右键属性显示
l如图
l第六部分 OnDemand开发
l6 开发工具
lII4C
lODWek
l6 Information Integrator for Content
lServer(com.ibm.mm.sdk.server):访问和操作内容服务器信息,直接和服务器进行通信。
lClient(com.ibm.mm.sdk.client):使用远程方法调用RMI(Remote Method Invocation)和服务器包进行通信。(多个通信异常类)
lCS(com.ibm.mm.sdk.cs):动态连接Client或Server。
lCommon(com.ibm.mm.sdk.common):共同类。
l6 映射原语-Mapping Terminology(1)
lContent Server:数据存放服务器
lData source:数据访问机制
lEntity:从中检索数据的对象或单元
lAttributes:存储信息特征
l6 映射原语-Mapping Terminology(2)
l6 开发简述
lCM整个系统的设计完全围绕着对象管理来进行的,所以不管是数据模型,还是权限管理以及开发接口,我们都可以通过对象管理的方法DDO/XDO来进行设置和开发,而不需要面向SQL和底层的表结构来进行开发,也不需要针对底层的存储管理API来进行开发。我们只需要通过统一的、满足DDO/XDO标准的管理模式和API来进行内容管理,包括编目、权限、存储、迁移、流程控制等等。
l6 DDO(Dynamic Data Objects)
lDDO(Dynamic Data Objects):一个对象的持久表示,是装载和检索数据进入内容服务器的接口。
l每个DDO一个persistent ID(PID),是一个对象类型,是data items的集合,items的数量为data count。每个data item有名称,值和ID,一个或多个data properties,和data properties的count。每个data property可以有一个ID,名称和值。
l6 XDO(Extended Data Objects)
lXDO(Extended Data Objects) :复杂数据的表示,比如文档注释。
lXDOs有个属性集合来表示数据类型和IDs。XDOs能够作为独立的动态对象使用。
l6 DDO的应用
¡Associate a DKDDO with a content server.
¡Create a DKDDO.
¡Create Persistent Identifiers (PIDs) for DKDDO attributes.
¡Add attributes and define attribute properties.
¡Define the DKDDO as a folder or as a document.
¡Set and view values for the attribute properties.
¡Check the DKDDO properties.
¡Check the attribute properties.
¡Display the DKDDO content.
¡Delete the DKDDO.
l6 主要Java类- dkDatastore
l将内容服务器作为一个Datastore,OnDemand对应的是dkDatastoreOD。
l内容的连接,查询,服务器事务和命令管理。
l示例:
¡DKDatastoreOD dsOD = new DKDatastoreOD();
¡dsOD.connect("localhost", "admin", "password", "");
¡……
¡dsOD.disconnect();
¡dsOD.destroy();
l6显示内容服务器
lpublic static void listDatasource() throws DKException, Exception {
l DKDatastoreOD dsOD = new DKDatastoreOD();
l try {
l dsOD.connect("localhost", "admin", "password", "");
l DKSequentialCollection pCol = (DKSequentialCollection) dsOD.listDataSources();
l dkIterator pIter = pCol.createIterator();
l while (pIter.more() == true) {
l DKServerDefOD attrDef = (DKServerDefOD) pIter.next();
l System.out.println(attrDef.getName());
l System.out.println(attrDef.getServerType());
l System.out.println(attrDef.getDatastore().datastoreType());
l }
l } catch (Exception ex) {
l System.out.println(ex.toString());
l } finally {
l dsOD.disconnect();
l dsOD.destroy();
l }
l}
l6显示应用程序组
lpublic static void listAppGroup() throws DKException, Exception {
l DKDatastoreOD dsOD = new DKDatastoreOD();
l try {
l dsOD.connect("localhost", "admin", "password", "");
l
l // Gets a list of entities from a persistent datastore.
l DKSequentialCollection pCol = (DKSequentialCollection) dsOD.listEntities(); //get application group
l
l dkIterator pIter = pCol.createIterator();
l while (pIter.more() == true) {
l // DKAppGrpDefOD: This class defines methods to access entity information for an index class
l DKAppGrpDefOD attrDef = (DKAppGrpDefOD) pIter.next();
l // Gets entity name
l System.out.println(attrDef.getName());
l }
l
l } catch (Exception ex) {
l System.out.println(ex.toString());
l } finally {
l dsOD.disconnect();
l dsOD.destroy();
l }
l
l}
l6 应用程序组以及属性处理
lpublic static void listEntityAttr(String entityName) throws DKException, Exception {
l DKDatastoreOD dsOD = new DKDatastoreOD();
l try {
l dsOD.connect("localhost", "admin", "password", "");
l DKSequentialCollection pCol = (DKSequentialCollection) dsOD.listEntityAttrs(entityName);
l dkIterator pIter = pCol.createIterator();
l while (pIter.more() == true) {
l
l DKFieldDefOD attrDef = (DKFieldDefOD)pIter.next();
l
l System.out.println(" Attribute name: " + attrDef.getName());
l System.out.println(" datastoreType: " + attrDef.datastoreType());
l System.out.println(" attributeOf: " + attrDef.getEntityName());
l System.out.println(" type: " + attrDef.getType());
l System.out.println(" size: " + attrDef.getSize());
l System.out.println(" id: " + attrDef.getId());
l System.out.println(" nullable: " + attrDef.isNullable());
l System.out.println(" precision: " + attrDef.getPrecision());
l System.out.println(" scale: " + attrDef.getScale());
l System.out.println(" stringType: " + attrDef.getStringType());
l System.out.println("");
l
l }
l
l } catch (Exception ex) {
l
l } finally {
l dsOD.disconnect();
l dsOD.destroy();
l }
l}
l6文件夹处理
lpublic static void listFolder() throws DKException, Exception {
l DKDatastoreOD dsOD = new DKDatastoreOD();
l DKDatastoreDefOD dsDef3 = (DKDatastoreDefOD)dsOD.datastoreDef();
l try {
l dsOD.connect("localhost", "admin", "password", "");
l DKSequentialCollection pCol = (DKSequentialCollection) dsDef3.listSearchTemplates();
l dkIterator pIter = pCol.createIterator();
l while (pIter.more() == true) {
l DKFolderOD folderName = (DKFolderOD) pIter.next();
l System.out.println("Name :" + folderName.getName());
l System.out.println("FolderName : " + folderName.getEntityName());
l System.out.println("Number of field: " + folderName.getNumFields());
l }
l
l } catch (Exception ex) {
l
l } finally {
l dsOD.disconnect();
l dsOD.destroy();
l }
l}
l6 简单实例(访问应用程序文件夹)-1
limport java.util.Iterator;
limport com.ibm.mm.sdk.common.DKAppGrpDefOD;
limport com.ibm.mm.sdk.common.DKDatastoreDefOD;
limport com.ibm.mm.sdk.common.DKException;
limport com.ibm.mm.sdk.common.DKSequentialCollection;
limport com.ibm.mm.sdk.common.dkIterator;
limport com.ibm.mm.sdk.server.DKDatastoreOD;
lpublic class RetrieveAppGrp {
l public static void main(String[] args) throws DKException, Exception {
l DKDatastoreOD dsOD = new DKDatastoreOD();
l try {
l dsOD.connect("localhost", "admin", "password", "");
l System.out.println("Connected to datastore dbase" + " "
l + dsOD.userName() + " " + dsOD.datastoreName());
l DKSequentialCollection pCol = (DKSequentialCollection) dsOD
l .listEntities();
l dkIterator pIter = pCol.createIterator();
l int i = 0;
l while (pIter.more() == true) {
l i++;
l DKAppGrpDefOD attrDef = (DKAppGrpDefOD) pIter.next();
l System.out.println(attrDef .getName());
l }
l } catch (Exception ex) {
l System.out.println(ex.toString());
l } finally {
l dsOD.disconnect();
l dsOD.destroy();
l }
l }
l
l}
l6 简单实例(访问应用程序文件夹)-2
ltrace is off
lConnected to datastore dbase admin localhost
l1
lSystem Log
l2
lSystem Migration
l3
ltestApp
l4
lpicGrp
l5
lgenGrp
l6
lpdfGrp
l6 修改用户密码
limport com.ibm.mm.sdk.common.*;
limport com.ibm.mm.sdk.server.*;
limport java.io.*;
lpublic class TChangePasswordOD
l{
lpublic static void main(String argv[])
l {
l String libSrv = new String("localhost"), userid = new String("sample"), pwd = new String("password"), new_pwd = new String("testforp"),
ltry
l {
l DKDatastoreOD dsOD = new DKDatastoreOD();
l String userName = dsOD.userName();
l String dsName = dsOD.datastoreName();
l dsOD.connect(libSrv,userid,pwd,connect_string);
l userName = dsOD.userName();
l dsName = dsOD.datastoreName();
l dsOD.changePassword(userid, pwd, new_pwd);
l dkUserManagement userMgt = (dkUserManagement)dsOD.datastoreDef().datastoreAdmin().userManagement();
l if (userMgt != null)
l {
l //userMgt.changePassword(userid,new_pwd,pwd);
l System.out.println("password has been changed back using the dkUserManagement object.");
l }
l else
l {
l System.out.println("dkUserManagement object is null!.");
l }
l
l dsOD.disconnect();
l
l dsOD.destroy();
l }
l catch (DKException exc)
l {
l }
l catch (Exception exc)
l {
l }
l
l }
l}
l6 查询
lString appgrp = "testApp";
lString SQLcmd = "where id=111111";
lDKNVPair[] parms = new DKNVPair[3];
lparms[0] = new DKNVPair("APPL_GROUP", appgrp);
lparms[1] = new DKNVPair("MAX_RESULTS", new String(Integer.toString(5)));
lparms[2] = new DKNVPair("CONTENT", new String("ATTRONLY"));
lSystem.out.println("executing query");
ldkResultSetCursor pCur = dsOD.execute(SQLcmd,DKConstantOD.DK_CM_SQL_QL_TYPE,parms);
lwhile (pCur.isValid())
l{
¡ DKDDO p = pCur.fetchNext();
¡ if (p != null)
l {
lString idstr = ((DKPid)p.getPidObject()).pidString();
lSystem.out.println(" pidString : " + idstr);
lDKPid pid = new DKPid (idstr);
lDKDDO ddoold = p;
lshort id, docType = 0;
lif ((id = ddoold.propertyId(DKConstantOD.DK_CM_PROPERTY_ITEM_TYPE)) > 0)
ldocType = ((Short)ddoold.getProperty(id)).shortValue();
lf (docType == DKConstantOD.DK_CM_DOCUMENT)
l {
System.out.println("create a new DDO with a cloned pid to retrieve!");
p = dsOD.createDDO(ddoold.getObjectType(), DKConstantOD.DK_CM_DOCUMENT);
p.setPidObject(pid);
try
l {
l dsOD.retrieveObject((dkDataObject)p);
l }
l catch (DKException exc)
l {
l
l }
l }
l }
l}
l6 XDO示意示例
l
lDKDDO pDDO = null;
ldkDataObjectBase pDO = null;
ldkXDO pXDO = null;
l if (pDO.protocol() == DK_CM_XDO)
l{
¡pXDO = (dkXDO)pDO;
¡DKPid pid2 = pXDO.getPidObject();
¡System.out.println(" XDO pid string: " + pid2.pidString());
¡// Retrieve and open instance handler for an XDO
¡pXDO.retrieve();
¡// 获取内容
¡DataBytes = pXDO.getContent();
¡DataString = new String(DataBytes);
l}
l6 注释的添加和删除 (1)
limport java.util.Date;
limport com.ibm.mm.sdk.common.*;
limport com.ibm.mm.sdk.server.*;
lpublic class TAnnotationOD implements DKConstant
l{
l public static void main(String argv[])
l {
l DKDatastoreOD dsOD = null;
l try
l {
l String libSrv = new String("localhost"), userid = new String("sample"), pw = new String("password"), connect_string = null;
l dsOD = new DKDatastoreOD();
l DKNVPair[] parms = new DKNVPair[3];
l parms[0] = new DKNVPair("APPL_GROUP", "sampleAG");
l parms[1] = new DKNVPair("MAX_RESULTS", "5");
l parms[2] = new DKNVPair("CONTENT", new String("YES"));
l System.out.println("connecting to datastore");
l dsOD.connect(libSrv,userid,pw,connect_string);
l System.out.println("executing query");
l dkResultSetCursor pCur = dsOD.execute("where ID=111123",DK_CM_SQL_QL_TYPE,parms);
l System.out.println("cardinality: " + pCur.cardinality());
l System.out.println("datastore executed query");
l if (pCur == null || pCur.isValid() == false)
l {
l System.out.println("cursor is null or invalid!!!");
l return;
l }
l DKDDO ddo = pCur.fetchNext();
l System.out.println("ddo count: " + ddo.dataCount() +"/n");
l for (short m = 1; m <= ddo.dataCount(); m++) {
l System.out.println("data-item name:" + ddo.getDataName(m));
l System.out.println("data: " + ddo.getData(m));
l }
l
l if (ddo != null)
l {
l displayNotes(ddo);
l //deleteNotes(ddo);
l addNote(dsOD, ddo);
l }
l pCur.destroy(); // Finished with the cursor
l }
l}
l…….
l
l
l
l6 注释的显示,添加和删除(2)
lpublic static void displayNotes(DKDDO ddo)
l {
l try
l {
l short propId = ddo.dataId("DKAnnotations");
l if (propId == 0)
l {
l System.out.println("/nNo annotations for document!");
l }
l else
l {
l DKParts notes = (DKParts)ddo.getData(propId);
l int numNotes = notes.cardinality();
l if (numNotes > 1)
l System.out.println("/nFound "+numNotes+" annotations.");
l else
l System.out.println("/nFound "+numNotes+" annotation.");
l dkIterator iter = notes.createIterator();
l while (iter.more())
l {
l dkXDO pXDO = (dkXDO)iter.next();
l // Retrieve the content for XDO
l pXDO.retrieve();
l String MimeType = pXDO.getMimeType();
l System.out.println(" MimeType = " + MimeType);
l DKAnnotationOD note = (DKAnnotationOD)pXDO.getExtension("dkAnnotationExt");
l String noteString = " Note Info: " + note.getTimestamp();
l noteString += " by " + note.getUserID();
l noteString += " for page " + Integer.toString(note.getPageNumber());
l System.out.println(noteString);
l noteString = note.isPublic() ? " Public" : " Private";
l noteString += "--";
l noteString += note.isOkToCopy() ? "Can" : "Cannot";
l noteString += " be copied to another server";
l System.out.println(noteString);
l noteString = " Note Text: " + note.getText();
l System.out.println( noteString );
l System.out.println("/n");
l } //while (iter.more())
l } //if (propId != 0)
l } //try
lcatch (Exception exc)
l {
l }
l }
l6 注释的显示,添加和删除(3)
lpublic static void addNote(DKDatastoreOD dsOD, DKDDO ddo)
l {
l try
l {
l DKPid pid = ddo.getPidObject();
l DKPidXDOOD newPid = new DKPidXDOOD();
l newPid.setDatastoreType(DKConstantOD.DK_OD_DSTYPE);
l newPid.setDatastoreName(dsOD.datastoreName());
l newPid.setPrimaryId(pid.getPrimaryId());
l newPid.setObjectType("DKBlobOD");
l newPid.setType(DK_CM_ANNOTATION);
l DKBlobOD newBlob = new DKBlobOD(dsOD);
l newBlob.setPidObject(newPid);
l Date d = new Date();
l DKAnnotationOD newNote = new DKAnnotationOD (
l true, // public
l true, // oktocopy
l 1, // pagenum
l (short)0, // x
l (short)0, // y
l DKConstantOD.DK_OD_COLOR_GREY,
l null, //group name
l "Created XXXX "+d+" from mrl!!!");
l // Adds the extension object.
l newBlob.addExtension("dkAnnotationExt", (dkExtension)newNote);
l // Adds the object content in the datastore.
l newBlob.add();
l }
l catch (DKException exc)
l {
l }
l catch (Exception exc)
l {
l }
l }
l6 注释的显示,添加和删除(4)
l public static void deleteNotes(DKDDO ddo)
l {
l int i = 0;
l dkXDO pXDO = null;
l
l try
l {
l short propId = ddo.dataId("DKAnnotations");
l if (propId == 0)
l {
l System.out.println("/nNo annotations to delete!");
l }
l else
l {
l DKParts notes = (DKParts)ddo.getData(propId);
l dkIterator iter = notes.createIterator();
l while (iter.more())
l {
l i += 1;
l pXDO = (dkXDO)iter.next();
l
l // only delete the first one
l if (i == 1)
l {
l System.out.println("/ndeleting the first annotation...");
l pXDO.del();
l break;
l }
l } //while (iter.more())
l } //if (propId != 0)
l } //try
l
l catch (DKException exc)
l {
l }
l catch (Exception exc)
l {
l }
l }
l6 日期转换
l public static String ODdate( int month, int day, int year )
l {
l int[] days = {31,28,31,30,31,30,31,31,30,31,30,31};
l int OD_days = 0;
l String od_days_str;
l Integer OD_DAY = new Integer(0);
l // Just in case someone entered a 2 digit year
l if ( year < 100 )
l {
l // 21st century
l if (year < 70)
l year += 2000;
l else
l year += 1900;
l }
l // Get the numbers of days since 1/1/1970 to 1/1/yyyy
l OD_days = ( year - 1970 ) * 365;
l // Add days from leap years
l for ( int yr = 1970; yr < year; yr++ )
l {
l if ((((yr) % 4) == 0) && ((((yr) % 100) != 0) || (((yr) % 400) == 0)))
l {
l OD_days++;
l }
l }
l // Add days sicne 1/1 of this year
l for ( int mon = 0; mon < month-1; mon++ )
l {
l OD_days += days[mon];
l }
l // Add the current day
l OD_days += day;
l // Additional Leap year adjustment
l if ((((year) % 4) == 0) && ((((year) % 100) != 0) || (((year) % 400) == 0)) && month > 2)
l OD_days++;
l od_days_str = OD_DAY.toString(OD_days);
l return od_days_str;
l }
l ODdate(9,10,2008) 14133
l6 API错误信息解决
l可以参考《Messages and Codes》
l参考文献
lContent Manager OnDemand for Multiplatforms Indexing Reference
lContent Manager OnDemand for Multiplatforms Windos 用户端手册
lContent Manager OnDemand for Multiplatforms 管理指南
lContent Manager OnDemand for Multiplatforms 介绍与规划指南
lContent Manager OnDemand for Multiplatforms 用户指南
lContent Manager OnDemand Guide(红皮书)
lData Stream and Object Architectures Mixed Object Document Content Architecture Reference
lIBM DB2 Content Manager OnDemand
lIBM DB2 Content Manager OnDemand: Messages and Codes
lThe IBM DB2 Content Manager OnDemand for Multiplatforms: Installation and Configuration Guide
lImplementing Web Applications with CM Information Integrator for Content and OnDemand Web Enablement Kit
lIBM DB2 Content Manger OnDemand System Administration
l结束
lThanks
l
__