Class ResourceMapModifier

java.lang.Object
edu.ucsb.nceas.metacat.dataone.resourcemap.ResourceMapModifier

public class ResourceMapModifier extends Object
This class will create a new resource map by modifying a given resourceMap input stream. Note: this class can only be used on the mn.publish method since it will replace the all old pid existing places by the new id. It is only safe for the the mn.publish method.
Author:
tao
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceMapModifier(org.dataone.service.types.v1.Identifier oldResourceMapId, InputStream originalResourceMap, org.dataone.service.types.v1.Identifier newResourceMapId)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.hp.hpl.jena.rdf.model.Resource
    generateAgentResource(org.dataone.service.types.v1.Subject subject, com.hp.hpl.jena.rdf.model.Model model)
    Generate an agent resource.
    static com.hp.hpl.jena.rdf.model.Resource
    generateNewComponent(com.hp.hpl.jena.rdf.model.Model model, String id)
    Create a Resource object for the given id.
    static com.hp.hpl.jena.rdf.model.Resource
    generateNewOREResource(com.hp.hpl.jena.rdf.model.Model model, org.dataone.service.types.v1.Subject subject, org.dataone.service.types.v1.Identifier newId)
    This method generates a Resource object for the new ore id in the given model
    static com.hp.hpl.jena.rdf.model.Resource
    getResource(com.hp.hpl.jena.rdf.model.Model model, String id)
    Get the Resource object which has the given identifier
    List<org.dataone.service.types.v1.Identifier>
    getSubjectsOfDocumentedBy(org.dataone.service.types.v1.Identifier metadataId)
    Get all subjects of the triple - * is documentedBy metadataId on the resource map
    static List<org.dataone.service.types.v1.Identifier>
    getSubjectsOfDocumentedBy(org.dataone.service.types.v1.Identifier metadataId, com.hp.hpl.jena.rdf.model.Model dataModel)
    Get all subjects of the triple - * is documentedBy metadataId in the given model
    void
    replaceObsoletedId(org.dataone.service.types.v1.Identifier obsoletedId, org.dataone.service.types.v1.Identifier newId, OutputStream newResourceMap, org.dataone.service.types.v1.Subject subject)
    Create new resource map by replacing obsoleted ids by new ids.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ResourceMapModifier

      public ResourceMapModifier(org.dataone.service.types.v1.Identifier oldResourceMapId, InputStream originalResourceMap, org.dataone.service.types.v1.Identifier newResourceMapId)
      Constructor
      Parameters:
      oldResourceMapId - the identifier of the old resource map which will be modified
      originalResourceMap - the content of original resource map
      newResourceMapId - the identifier of the new resource map which will be generated
  • Method Details

    • replaceObsoletedId

      public void replaceObsoletedId(org.dataone.service.types.v1.Identifier obsoletedId, org.dataone.service.types.v1.Identifier newId, OutputStream newResourceMap, org.dataone.service.types.v1.Subject subject) throws UnsupportedEncodingException
      Create new resource map by replacing obsoleted ids by new ids. Note: this method can only be used on the mn.publish method since it will replace the all old pid existing places by the new id. It is only safe for the the mn.publish method.
      Parameters:
      obsoletedId - the pid will be replaced
      newId - the pid will be used to replace the old pid
      newResourceMap - the place where the created new resource map will be written
      subject - the subject who generates the resource map
      Throws:
      UnsupportedEncodingException
    • generateNewOREResource

      public static com.hp.hpl.jena.rdf.model.Resource generateNewOREResource(com.hp.hpl.jena.rdf.model.Model model, org.dataone.service.types.v1.Subject subject, org.dataone.service.types.v1.Identifier newId) throws UnsupportedEncodingException
      This method generates a Resource object for the new ore id in the given model
      Parameters:
      model - the model where the new generated Resource object will be attached
      subject - name of the creator of this resource map
      Returns:
      the generated new ORE Resource object
      Throws:
      UnsupportedEncodingException
    • generateAgentResource

      public static com.hp.hpl.jena.rdf.model.Resource generateAgentResource(org.dataone.service.types.v1.Subject subject, com.hp.hpl.jena.rdf.model.Model model)
      Generate an agent resource. If there is an existing agent with the same name and the type, the existing agent will be returned.
      Parameters:
      subject - the name of the agent resource
      Returns:
      the agent resource
    • generateNewComponent

      public static com.hp.hpl.jena.rdf.model.Resource generateNewComponent(com.hp.hpl.jena.rdf.model.Model model, String id) throws UnsupportedEncodingException
      Create a Resource object for the given id.
      Parameters:
      model - the model where the new Resource object will be attached
      id - the identifier of the new Resource object will have
      Returns:
      the uri of the new generated Resource object
      Throws:
      UnsupportedEncodingException
    • getResource

      public static com.hp.hpl.jena.rdf.model.Resource getResource(com.hp.hpl.jena.rdf.model.Model model, String id)
      Get the Resource object which has the given identifier
      Parameters:
      model - the model where the query will be applied
      id - the identifier of the Resource object has
      Returns:
      the Resource object with the given identifier. It can return null if not found.
    • getSubjectsOfDocumentedBy

      public List<org.dataone.service.types.v1.Identifier> getSubjectsOfDocumentedBy(org.dataone.service.types.v1.Identifier metadataId)
      Get all subjects of the triple - * is documentedBy metadataId on the resource map
      Parameters:
      metadataId - the id of object on the triple (it always be a metadata id). If it is null, it will be anything.
      Returns:
      the all the identifiers of the subjects match the query
    • getSubjectsOfDocumentedBy

      public static List<org.dataone.service.types.v1.Identifier> getSubjectsOfDocumentedBy(org.dataone.service.types.v1.Identifier metadataId, com.hp.hpl.jena.rdf.model.Model dataModel)
      Get all subjects of the triple - * is documentedBy metadataId in the given model
      Parameters:
      metadataId - the id of object on the triple (it always be a metadata id). If it is null, it will be anything.
      dataModel - the model of the result map
      Returns:
      the all the identifiers of the subjects match the query