Class LibraryComPADRE

java.lang.Object
org.opensourcephysics.tools.LibraryComPADRE

public class LibraryComPADRE extends Object
This provides static methods for getting a LibraryCollection from ComPADRE. Adapted from code written for EJS by Francisco Esquembre.
Version:
1.0
Author:
Francisco Esquembre, Douglas Brown
  • Field Details

  • Constructor Details

    • LibraryComPADRE

      public LibraryComPADRE()
  • Method Details

    • load

      protected static boolean load(LibraryCollection collection, String query)
      Loads a collection using a specified comPADRE search query.
      Parameters:
      collection - the LibraryCollection to load
      query - the search query
      Returns:
      true if successfully loaded
    • loadSubtrees

      protected static boolean loadSubtrees(LibraryCollection collection, NodeList nodeList, String attributeType, String serviceParameter)
      Loads a collection with subtree collections that meet the specified requirements.
      Parameters:
      collection - the LibraryCollection to load
      nodeList - a list of Nodes
      attributeType - the desired attribute
      serviceParameter - the desired service parameter
      Returns:
      true if at least one subtree collection was loaded
    • loadResources

      protected static void loadResources(LibraryTreeNode treeNode, Runnable onSuccess, Runnable onFailure)
      Loads ComPADRE records into a LibraryTreeNode collection.
      Parameters:
      treeNode - the LibraryTreeNode to load--note record MUST be a collection
    • start

      protected static void start(Runnable runnable)
    • loadNode

      protected static void loadNode(Node node, LibraryCollection collection, LibraryTreeNode treeNode, String urlPath, Runnable onFound, Runnable onNothingNew)
    • reloadResource

      protected static void reloadResource(LibraryTreeNode treeNode, String urlPath, Runnable whenDone)
      Reloads a ComPADRE record into a LibraryTreeNode.
      Parameters:
      treeNode - the LibraryTreeNode to reload
    • setRecord

      protected static boolean setRecord(LibraryResource record, Node node, org.opensourcephysics.tools.LibraryResource.Attachment attachment, LibraryTreeNode treeNode)
      Sets a LibraryTreeNode to a ComPADRE record.
      Parameters:
      treeNode - the LibraryTreeNode to set
      Returns:
      true if successfully set
    • getAttachment

      protected static org.opensourcephysics.tools.LibraryResource.Attachment getAttachment(Node node, String[] attachmentTypes)
      Returns data for a downloadable DOM Node attachment.
      Parameters:
      node - the DOM Node
      attachmentType - the attachment type
      Returns:
      Attachment, or null if no attachment found
    • getFirstChild

      protected static Node getFirstChild(Node parent, String name)
      Returns the first child node with the given name.
      Parameters:
      parent - the parent Node
      name - the child name
      Returns:
      the first child Node found, or null if none
    • getAllChildren

      protected static List<Node> getAllChildren(Node parent, String name)
      Returns all child nodes with the given name.
      Parameters:
      parent - the parent Node
      name - the name
      Returns:
      a list of Nodes (may be empty)
    • getNodeValue

      protected static String getNodeValue(Node node)
      Gets the value of a Node.
      Parameters:
      node - the Node
      Returns:
      the value
    • getChildValue

      protected static String getChildValue(Node parent, String name)
      Gets the value of the first child node with a given name.
      Parameters:
      parent - the parent Node
      name - the name of the child
      Returns:
      the value of the first child found, or null if none
    • processURL

      protected static String processURL(String url)
      Replaces "&amp" with "&" in HTML code.
      Parameters:
      url - the HTML code
      Returns:
      the clean URL string
    • writeXmlFile

      protected static String writeXmlFile(Document doc, String filename)
      Writes a DOM document to a file for testing.
      Parameters:
      doc - the Document
      filename - the filename to write to
      Returns:
      the String contents of the document
    • getCollectionName

      public static String getCollectionName(String path)
      Returns a descriptive name for a given ComPADRE path (query).
      Parameters:
      path - the query string
      Returns:
      the name of the collection
    • getCollection

      protected static LibraryCollection getCollection(String path)
      Returns the LibraryCollection for a given ComPADRE path (query).
      Parameters:
      path - the query string
      Returns:
      the collection
    • getCollectionPath

      protected static String getCollectionPath(String path, boolean primarySubjectOnly)
      Returns the collection path for an EJS or tracker tree.
      Parameters:
      path - the ComPADRE query string
      primarySubjectOnly - true to limit results to their primary subject
      Returns:
      the corrected ComPADRE query string
    • isComPADREPath

      protected static boolean isComPADREPath(String path)
      Determines if a path is a ComPADRE query.
      Parameters:
      path - the path
      Returns:
      true if path starts with the standard partial ComPADRE query string
    • isPrimarySubjectOnly

      protected static boolean isPrimarySubjectOnly(String path)
      Determines if a query path limits results to the primary subject only.
      Parameters:
      path - the path
      Returns:
      true if path contains a primary-subject-only flag
    • isDesiredOSPType

      protected static boolean isDesiredOSPType(Node node)
      Determines if a node has an <osp-type> consistent with desiredOSPType.
      Parameters:
      node - the node
      Returns:
      true if is of the desired <osp-type>
    • isTrackerType

      protected static boolean isTrackerType(Node node)