Author Topic: Adding annotations  (Read 5229 times)

jeffs42885

  • Guest
Adding annotations
« on: February 13, 2015, 08:35:04 AM »
We are working on a phase of a project which the client wants to load annotations manually for a particular file. Basically, the business would send a CSV file, and it needs to be processed, searches for the correct report/date/Field1/Field2. We've worked with IBM and they are able to do this, I am just wondering if anyone else has done something similar using the CMOD API's and if you've had any successes, failures, etc.

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • Tenacious Consulting
Re: Adding annotations
« Reply #1 on: February 16, 2015, 03:43:34 AM »
It's also possible to add annotations when loading generic index files.  When you fetch data with arsdoc get, and select that generic index files should be created, if there's an annotation, it appears in the generic index file.  There doesn't appear to be any documentation for this though.  Not sure if that would work in your situation...

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

jeffs42885

  • Guest
Re: Adding annotations
« Reply #2 on: February 16, 2015, 05:04:29 AM »
Did some homework.

GROUP_FIELD_NAME:Image
GROUP_FIELD_VALUE:Helen
GROUP_FIELD_NAME:Date_Taken
GROUP_FIELD_VALUE:08/07/07
GROUP_OFFSET:0
GROUP_LENGTH:113508
GROUP_FILENAME:E:\PMR\cftiff_2pg.tif
COMMENT: Note 1
GROUP_ANNOTATION_ID:0
GROUP_ANNOTATION_USERID:admin
GROUP_ANNOTATION_PAGE:1
GROUP_ANNOTATION_TYPE:5
GROUP_ANNOTATION_XOFF:0
GROUP_ANNOTATION_YOFF:0
GROUP_ANNOTATION_COLOR:YELLOW
GROUP_ANNOTATION_TIMESTAMP:20070928154956
GROUP_ANNOTATION_OFFSET:0
GROUP_ANNOTATION_LENGTH:147
GROUP_ANNOTATION_FILE:E:\PMR\cftiff_2pg.tif.an

This looks like what I am looking for. The business is unsure of the XY coordinates of the annotation, and would like like to add the information. Any idea what the inside of the .an file looks like?
« Last Edit: February 16, 2015, 05:33:24 AM by jeffs42885 »

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • Tenacious Consulting
Re: Adding annotations
« Reply #3 on: February 17, 2015, 02:23:52 AM »
Any idea what the inside of the .an file looks like?

That's one of the undocumented parts.  :)

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

jeffs42885

  • Guest
Re: Adding annotations
« Reply #4 on: February 17, 2015, 05:07:27 AM »
Any idea what the inside of the .an file looks like?

That's one of the undocumented parts.  :)

-JD.

I figured as much. I am going to do some homework and play with arsdoc to see if I can extract an annotation already added to a report. Are there any specific flags I need to add to my command

jeffs42885

  • Guest
Re: Adding annotations
« Reply #5 on: February 17, 2015, 07:20:04 AM »
Alrighty, I was able to extract a load from CMOD and the index file / .ann file. I attempted to load and I'm getting this message:

Invalid structured field header in the file

Here's another question- I checked arsdoc / arsadmin and I don't think this part is possible. Is it possible to load annotations to an existing file by using OOB functionality and not manually going in and touching the tables?


Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • Tenacious Consulting
Re: Adding annotations
« Reply #6 on: February 18, 2015, 03:01:18 AM »
As far as I know, there isn't a way to add annotations from the command line (except the arsdoc / arsload item I mentioned).  I'm pretty sure there's functionality in the Java API for this -- but that involves writing Java & installing ODWEK if you don't already have it.

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

jeffs42885

  • Guest
Re: Adding annotations
« Reply #7 on: February 18, 2015, 05:34:40 AM »
I verified what the buisness is trying to do.

It looks like they want to send a CSV file that contains annotations, and have them loaded into CMOD based on dates/segments, etc..any feedback on that?

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
Re: Adding annotations
« Reply #8 on: March 18, 2015, 09:25:21 AM »
You need really to use ODWEK Java API...
Now... how exactly that's the million $ question, without the exact requirement from the business, we can only guess...
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

jeffs42885

  • Guest
Re: Adding annotations
« Reply #9 on: April 03, 2015, 06:55:40 AM »
Im going to play with this now but has anyone ever done this via arsdoc update?

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
Re: Adding annotations
« Reply #10 on: April 07, 2015, 04:42:36 AM »
You can forget about "arsdoc update", it won't help you in your problem of annotation.

I've done something in the past, that could help you... This is a java program that does the following:

- Read a file with the following information (basically 1 document per line):  <folder name>;<folder field>;<doc ID>
- Attach the content of a text file to be attached as annotation to the documents found in previous point

It needs also an additional file for the server/credential information.

Would that be interesting for you?

Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • Tenacious Consulting
Re: Adding annotations
« Reply #11 on: November 06, 2015, 06:22:07 AM »
I would be interested in the sample code.  I have a requirement to move thousands of annotations into CMOD as part of a migration file Filenet, but it was considered an 'after-thought', so the annotations don't appear to have been extracted with the rest of the data.  It's quite a mess.  :)

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

Alessandro Perucchi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1002
Re: Adding annotations
« Reply #12 on: November 09, 2015, 03:14:08 AM »
Hello Justin,

Here is my example code:

Code: [Select]
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Properties;
import java.util.Vector;

import com.ibm.edms.od.ODConfig;
import com.ibm.edms.od.ODCriteria;
import com.ibm.edms.od.ODFolder;
import com.ibm.edms.od.ODHit;
import com.ibm.edms.od.ODNote;
import com.ibm.edms.od.ODServer;

/**
 * @author fc065089
 *
 */
public class Main {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
if (args.length != 3) {
System.out
.println("Usage: Program <Property File> <Doc Id File> <Annotation file>");
System.exit(1);
}

// Handle Property file
String propertyFile = args[0];
Properties prop = new Properties();
prop.load(new FileInputStream(propertyFile));

String cmodServer = prop.getProperty("cmod.server");
int cmodPort = Integer.parseInt(prop.getProperty("cmod.port"));
String cmodUser = prop.getProperty("cmod.user");
String cmodPWD = prop.getProperty("cmod.pwd");
String odwekInstallDir = prop.getProperty("odwek.installdir");

boolean isNotePublic = Boolean.parseBoolean(prop
.getProperty("cmod.annot.public"));
boolean canCopyNote = Boolean.parseBoolean(prop
.getProperty("cmod.annot.copy"));

// Handle Doc IDs
String listDocID = args[1];

// Handle Annotation file
String annotationFile = args[2];

BufferedReader bufferedReader = new BufferedReader(new FileReader(
annotationFile));

StringBuffer annotationText = new StringBuffer();
String line = null;
while ((line = bufferedReader.readLine()) != null)
annotationText.append(line).append("\n");

bufferedReader.close();

ODNote odNote = new ODNote();
odNote.setPublic(isNotePublic);
odNote.setOkToCopy(canCopyNote);
odNote.setText(annotationText.toString());

if (odwekInstallDir != null)
Utils.addLibraryPathUsr(odwekInstallDir);

ODConfig odc = new ODConfig();
ODServer ods = new ODServer(odc);
ods.setPort(cmodPort);
ods.setServerName(cmodServer);
ods.setUserId(cmodUser);
ods.setPassword(cmodPWD);
ods.initialize("Testing annotation");
ods.logon();

bufferedReader = new BufferedReader(new FileReader(listDocID));
HashMap<String, HashMap<String, HashSet<String>>> myList = new HashMap<String, HashMap<String, HashSet<String>>>();
int count = 1;
while ((line = bufferedReader.readLine()) != null) {
if (line.startsWith("#") || "".equals(line.trim()))
continue;

String[] lineSplitted = line.split(";");
if (lineSplitted[0] == null || lineSplitted[1] == null
|| lineSplitted[2] == null
|| "".equals(lineSplitted[0].trim())
|| "".equals(lineSplitted[1].trim())
|| "".equals(lineSplitted[2].trim())) {
System.err.println("WARNING: Problem with line " + count
+ " of file " + listDocID
+ ", the format is 'Folder;FolderField;DocId");
System.err.println("Skipping");
continue;
}
String folder = lineSplitted[0];
String folderField = lineSplitted[1];
String docId = lineSplitted[2];
if (!myList.containsKey(folder))
myList.put(folder, new HashMap<String, HashSet<String>>());

HashMap<String, HashSet<String>> myFields = myList.get(folder);
if (!myFields.containsKey(folderField))
myFields.put(folderField, new HashSet<String>());

HashSet<String> myDocIds = myFields.get(folderField);
myDocIds.add(docId);
count++;
}
bufferedReader.close();

for (String folder : myList.keySet()) {
@SuppressWarnings("unchecked")
Enumeration<String> odfstr = ods.getFolderNames();
boolean found = false;
for (; odfstr.hasMoreElements();) {
String odftmp = odfstr.nextElement();
if (odftmp.equals(folder)) {
found = true;
}
}
if (!found) {
System.err.println("WARNING: Problem for the the folder '"
+ folder + "' because the folder doesn't exist.");
System.err.println("Skipping");
continue;
}
ODFolder odf = ods.openFolder(folder);
for (String folderField : myList.get(folder).keySet()) {
@SuppressWarnings("unchecked")
Enumeration<ODCriteria> odcs = odf.getCriteria();
found = false;
for (; odcs.hasMoreElements();) {
ODCriteria odctmp = odcs.nextElement();
if (odctmp.getName().equals(folderField)) {
found = true;
}
}
if (!found) {
System.err
.println("WARNING: Problem for the Folder Field '"
+ folderField
+ "' in the folder '"
+ folder
+ "' because the folder field doesn't exist in Folder.");
System.err.println("Skipping");
continue;
}
ODCriteria odCrit = odf.getCriteria(folderField);
for (String docId : myList.get(folder).get(folderField)) {
odCrit.setSearchValue(docId);
@SuppressWarnings("unchecked")
Vector<ODHit> odHits = odf.search();
odHits.size();
if (odHits.size() > 1) {
System.err.println("WARNING: Problem the docID '"
+ docId + "' for the Folder Field '"
+ folderField + "' in the folder '" + folder
+ "' because it is not uniq, found "
+ odHits.size() + " entries.");
System.err.println("Skipping");
continue;
} else {
if (odHits.size() == 0) {
System.err.println("WARNING: Problem the docID '"
+ docId + "' for the Folder Field '"
+ folderField + "' in the folder '"
+ folder + "' because it is not found.");
System.err.println("Skipping");
continue;
}
}
if (odHits.get(0).hasPermToAddNotes()) {
odHits.get(0).addNote(odNote);
System.out.println("Note added in folder '" + folder
+ "'  " + folderField + "='" + docId + "'");
} else {
System.err
.println("WARNING: Problem the docID '"
+ docId
+ "' for the Folder Field '"
+ folderField
+ "' in the folder '"
+ folder
+ "' because user '"
+ cmodUser
+ "' don't have permission to add annotations.");
System.err.println("Skipping");
}
odHits.clear();
}
}
odf.close();
}
ods.logoff();
ods.terminate();
}
}

I give this code as is, without any support.
It works for me, but it might not work for you!!!
It does only a mass add of one single annotation to many documents.



It requires several information
  • Property file
  • List of DocIds
  • Annotation to add

The property file must have the following entries:

Code: [Select]
cmod.server=locahost
cmod.port=1445
cmod.user=admin
cmod.pwd=password
odwek.installdir=/usr/lpp/ars/www

cmod.annot.public=true
cmod.annot.copy=false

The format of the file for the DocID is the following:

Code: [Select]
Folder;Folder Field;DocId

Then the annotation file is really only... the text file, and the whole content will be added to each DocId entries found.

This is a very specific use case, and the code was done in 30 minutes... so don't expect it to be enterprise ready :-D

--
Alessandro
Alessandro Perucchi

#Install #Migrations #Conversion #Educate #Repair #Upgrade #Migrate #Enhance #Optimize #AIX #Linux #Multiplatforms #DB2 #Windows #Oracle #TSM #Tivoli #Performance #Audits #Customizing #Availability #HA #DR #JavaApi #ContentNavigator #ICN #WEBi #ODWEK #Services #PDF #AFP #XML