manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1609115 - /manifoldcf/branches/CONNECTORS-989-2/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/DocumentVersions.java
Date Wed, 09 Jul 2014 11:55:12 GMT
Author: kwright
Date: Wed Jul  9 11:55:11 2014
New Revision: 1609115

URL: http://svn.apache.org/r1609115
Log:
Code to handle child documents at getDocumentVersions() time

Modified:
    manifoldcf/branches/CONNECTORS-989-2/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/DocumentVersions.java

Modified: manifoldcf/branches/CONNECTORS-989-2/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/DocumentVersions.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-989-2/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/DocumentVersions.java?rev=1609115&r1=1609114&r2=1609115&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-989-2/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/DocumentVersions.java
(original)
+++ manifoldcf/branches/CONNECTORS-989-2/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/DocumentVersions.java
Wed Jul  9 11:55:11 2014
@@ -23,12 +23,22 @@ import java.util.*;
 
 /** This class represents a set of document versions, organized by document identifier.
 * It's part of the IRepositoryConnector API.
+* This structure does two things: (1) describe the version string for child documents of
a given primary document, and (2) list the
+* current set of child documents.
+* For each parent document, this API class can specify:
+* - that the parent document should be refetched, regardless
+* - the default version string for all child documents of a parent document
+* - the actual version string for each child document of a parent document
+* - the list of child documents for a given parent document
+* 
 */
 public class DocumentVersions
 {
   public static final String _rcsid = "@(#)$Id$";
 
   protected final Map<String,VersionContext> documentVersions = new HashMap<String,VersionContext>();
+  protected final Map<String,Map<String,VersionContext>> childDocumentVersions
= new HashMap<String,Map<String,VersionContext>>();
+  protected final Map<String,Set<String>> childDocumentIDs = new HashMap<String,Set<String>>();
   protected final Set<String> alwaysRefetch = new HashSet<String>();
   
   /** Constructor */
@@ -36,32 +46,105 @@ public class DocumentVersions
   {
   }
   
-  /** Set a non-special document version.
-  *@param documentIdentifier is the document identifier.
+  /** Set a default document version.
+  *@param documentIdentifier is the parent document identifier.
   *@param documentVersion is the document version.
   */
   public void setDocumentVersion(String documentIdentifier, VersionContext documentVersion)
   {
     documentVersions.put(documentIdentifier,documentVersion);
   }
+
+  /** Set a child document version.
+  *@param documentIdentifier is the parent document identifier.
+  *@param childIdentifier is the child document identifier.  Use empty string for the primary
document.
+  *@param documentVersion is the document version.
+  */
+  public void setChildDocumentVersion(String documentIdentifier, String childIdentifier,
VersionContext documentVersion)
+  {
+    Map<String,VersionContext> map = childDocumentVersions.get(documentIdentifier);
+    if (map == null)
+    {
+      map = new HashMap<String,VersionContext>();
+      childDocumentVersions.put(documentIdentifier,map);
+    }
+    map.put(childIdentifier,documentVersion);
+    noteChildDocument(documentIdentifier,childIdentifier);
+  }
+  
+  /** Note the existence of a child document.
+  *@param documentIdentifier is the parent document identifier.
+  *@param childIdentifier is the child document identifier.
+  */
+  public void noteChildDocument(String documentIdentifier, String childIdentifier)
+  {
+    Set<String> set = childDocumentIDs.get(documentIdentifier);
+    if (set == null)
+    {
+      set = new HashSet<String>();
+      childDocumentIDs.put(documentIdentifier,set);
+    }
+    set.add(childIdentifier);
+  }
   
   /** Signal to always refetch document.
-  *@param documentIdentifier is the document identifier.
+  *@param documentIdentifier is the parent document identifier.
   */
   public void alwaysRefetch(String documentIdentifier)
   {
     alwaysRefetch.add(documentIdentifier);
   }
   
-  /** Get the document version, if any.
+  /** Get the parent document version, if any.
   *@param documentIdentifier is the document identifier.
   *@return the document version, if any.  Null indicates that no such document was found.
   */
   public VersionContext getDocumentVersion(String documentIdentifier)
   {
+    return getChildDocumentVersion(documentIdentifier,"");
+  }
+  
+  /** Get the child document version, if any.
+  *@param documentIdentifier is the document identifier.
+  *@param childIdentifier is the child document identifier.  Use empty string for the primary
document.
+  *@return the document version, if any.  Null indicates that no such document was found.
+  */
+  public VersionContext getChildDocumentVersion(String documentIdentifier, String childIdentifier)
+  {
+    Map<String,VersionContext> map = childDocumentVersions.get(documentIdentifier);
+    if (map != null)
+    {
+      VersionContext rval = map.get(childIdentifier);
+      if (rval != null)
+        return rval;
+    }
     return documentVersions.get(documentIdentifier);
   }
   
+  /** Get a count of child document identifiers.
+  *@param documentIdentifier is the document identifier.
+  *@return the count of children.
+  */
+  public int countChildren(String documentIdentifier)
+  {
+    Set<String> children = childDocumentIDs.get(documentIdentifier);
+    if (children == null)
+      return 0;
+    return children.size();
+  }
+  
+  /** List the child documents for a document identifier.
+  *@param documentIdentifier is the document identifier.
+  *@return an iterator over the set of child ID's, or null if the document identifier doesn't
have any children.
+  */
+  public Iterator<String> childIterator(String documentIdentifier)
+  {
+    Set<String> children = childDocumentIDs.get(documentIdentifier);
+    if (children == null)
+      return null;
+    return children.iterator();
+  }
+  
   /** Check whether we should always refetch a specified document.
   *@param documentIdentifier is the document identifier.
   *@return true if we are directed to always refetch.  False will be returned by default.



Mime
View raw message