Listing information about annotations
You use methods from the ODNote class to display information about the annotations (also known as notes) in a folder.
About this task
The following example uses ODNote methods to list detailed information about an annotation (also
known as notes). The following example does the following tasks:
- Logs on to the specified server
- Opens the specified folder
- Searches the folder using the default criteria
- Displays the number of hits
- Displays the number of annotations associated with the first document
- Displays detailed information for each annotation that is attached to the document
- The position of the annotation on the page of the document
- The background color
- Date and time that the annotation was attached to the document
- The user ID that created the annotation
- Other attributes
This example demonstrates the following ODNote methods:
- getColor
- getDateTime
- getGroupName
- getOffsetX
- getOffsetY
- getPageNum
- getText
- getUserid
- isOkToCopy
- isPublic
This example also demonstrates these ODServer methods:
- initialize
- logon
- openFolder
- logoff
- terminate
- search
- close
- getNotes
- getNoteStatus
This example uses the following runtime parameters:
- Server name
- Port
- User Id
- Password
- Folder name
Example of listing information about annotations:
import java.util.*;
import java.io.*;
import com.ibm.edms.od.*;
public class TcListNotes
{
public static void main ( String argv[] )
{
ODServer odServer;
ODFolder odFolder;
ODHit odHit;
ODNote odNote;
Vector hits, notes;
String str;
int j, exist;
//----------
// If too few parameters, display syntax and get out
//----------
if ( argv.length < 5 )
{
System.out.println( "usage: java TcListNotes <server> <port> <userid> <password> <folder>" );
return;
}
try
{
//----------
// Set the stage
//----------
System.out.println("Testcase TcListNotes started." );
System.out.println("This testcase should:");
System.out.println(" Logon to the specified server");
System.out.println(" Open the specified folder");
System.out.println(" Search the folder using the default criteria");
System.out.println(" Display the number of hits");
System.out.println(" Display the note status for the first hit");
System.out.println(" Display the number of notes associated with the first hit");
System.out.println(" Display info for each note");
System.out.println("");
System.out.println("---------------------------------------------------");
System.out.println("");
//----------
// Logon to specified server
//----------
ODConfig odConfig = new ODConfig();
if (odConfig != null)
{
odServer = new ODServer(odConfig);
odServer.initialize("TcListNotes.java");
odServer.setPort(Integer.parseInt(argv[1]));
System.out.println( "Logging on to " + argv[0] + " server with user " + argv[2] + "..." );
odServer.logon( argv[0], argv[2], argv[3]);
//----------
// Open the specified folder and search with the default criteria
//----------
System.out.println( "Opening " + argv[4] + " folder..." );
odFolder = odServer.openFolder( argv[4] );
System.out.println("Searching with default criteria...");
hits = odFolder.search();
System.out.println(" Number of hits: " + hits.size());
//----------
// List info for each note for the first hit
//----------
if ( hits.size( ) > 0 )
{
odHit = (ODHit) hits.elementAt(0);
System.out.println(" For the first hit:");
System.out.println(" Note status is: "
+ odHit.getNoteStatus());
notes = odHit.getNotes();
if (notes.size() > 0)
System.out.println(" There is(are) " + notes.size() + " note(s)");
for ( j = 0; j < notes.size( ); j++ )
{
odNote = (ODNote) notes.elementAt(j);
System.out.println(" " + (j+1) + ". Text='" + odNote.getText( ) + "'" );
System.out.println(" UserId=" + odNote.getUserId());
System.out.println(" Page=" + odNote.getPageNum());
System.out.println(" Color=" + odNote.getColor());
System.out.println(" Date=" + odNote.getDateTime());
System.out.println(" Group=" + odNote.getGroupName());
System.out.println(" Offset=(" + odNote.getOffsetX( ) + "," +
odNote.getOffsetY( ) + ")" );
System.out.println(" OkToCopy=" + odNote.isOkToCopy());
System.out.println(" Public=" + odNote.isPublic());
System.out.println(" Text=" + odNote.getText());
}
}
else
System.out.println("There is no document - cannot list notes");
//----------
// Cleanup
//----------
odFolder.close();
odServer.logoff();
odServer.terminate();
System.out.println("");
System.out.println("---------------------------------------------------");
System.out.println("");
System.out.println( "Testcase TcListNotes completed - Ensure that the information" );
System.out.println(" is the same as shown by the Windows Client");
System.out.println("");
}
}
catch ( ODException e )
{
System.out.println( "ODException: " + e );
System.out.println( " id = " + e.getErrorId( ) );
System.out.println( " msg = " + e.getErrorMsg( ) );
e.printStackTrace( );
}
catch ( Exception e2 )
{
System.out.println( "exception: " + e2 );
e2.printStackTrace( );
}
}
static String getExistenceName( int code )
{
String str;
switch( code )
{
case ODConstant.NoteStatusUnknown:
str = "UNKNOWN";
break;
case ODConstant.NoteStatusYes:
str = "YES";
break;
case ODConstant.NoteStatusNo:
str = "NO";
break;
case ODConstant.NoteStatusError:
str = "ERROR";
break;
default:
str = "UNDEFINED VALUE";
}
return str;
}
}